[integrations] Consolidation workers (bio + metadata)#200
Merged
justfinethanku merged 3 commits intoJun 19, 2026
Merged
Conversation
Collaborator
Author
|
Conflicts with |
…ardening
Two Edge Functions for post-import thought quality:
- metadata-norm: LLM reclassification of type/importance on accumulated thoughts
- bio: biographical profile synthesis ("Who is {subject}")
Three-tier LLM fallback (OpenRouter -> OpenAI -> Anthropic) for both workers,
with the isTransientError predicate gating provider hops so 4xx/auth errors
fail fast rather than cascading.
Hardening included from Wave 2.5 review:
- CONSOLIDATION_MAX_CALLS budget cap (default 100, 0 = unlimited); preserves
consolidation_reviewed markers on budget trip
- AbortController timeout on every LLM fetch (FETCH_TIMEOUT_MS default 60s)
- Prompt-injection defense: thought content wrapped in <thought_content> tags
with closing-tag escape; system/user role split; importance>=6 treated as
injection signal
- Bio worker writes type/importance/source_type via direct .insert() with
content_fingerprint (stock upsert_thought RPC reads only metadata)
- findExistingProfile scoped by subject to prevent silent data-loss when
profiling multiple subjects
- b361df1 name-filter preserved across all three source queries in bio
- UUID thought.id typings throughout; removed dead typeof===number branches
Part of the OB1 alpha milestone.
371a77f to
73f1047
Compare
Collaborator
Author
|
Rebased onto |
justfinethanku
approved these changes
Jun 19, 2026
justfinethanku
left a comment
Collaborator
There was a problem hiding this comment.
Validated both worker entrypoints with deno check and added the missing OB1 community credit header. Ready to merge.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two Deno/Supabase Edge Functions for post-import thought quality improvement:
Both workers use three-tier LLM fallback (OpenRouter → OpenAI → Anthropic) with transient-error gating (`isTransientError` predicate) so provider hops only fire on 5xx/429/timeout — not on 4xx/auth errors that would waste calls.
Hardened per Wave 2.5 review:
Why
Open Brain's import paths accumulate thoughts faster than classification can keep up, especially for pre-enrichment backfills (drag-and-drop archives, Takeout dumps). `metadata-norm` is a targeted re-classifier for the long tail. `bio` is a different shape: synthesize a stable "self" or "about-{person}" anchor document that LLMs can efficiently ground against.
Test plan