feat: smart embed scheduling with priority and catch-up mode#1379
Open
garrytan-agents wants to merge 3 commits into
Open
feat: smart embed scheduling with priority and catch-up mode#1379garrytan-agents wants to merge 3 commits into
garrytan-agents wants to merge 3 commits into
Conversation
The judgeSignificance trimming (slice at 4000 chars) could split a UTF-16 surrogate pair when an emoji sits exactly at the boundary, producing a lone high surrogate that Anthropic's JSON parser rejects with 'no low surrogate in string'. Add safeSliceEnd() helper that backs up by one char when the cut lands between a high and low surrogate. Apply to: - judgeSignificance transcript trimming (the direct cause) - findBoundary hard-split fallback (defense-in-depth) Fixes: dream cycle SYNTH_PHASE_FAIL on 2026-05-24 caused by 🤖 emoji at pos 3999 in telegram/2026-05-20-topic-1-topic-1.md
Add proposal for prioritized batch embedding and catch-up mode. In a 165K-page brain, 24K+ pages have stale embeddings because the daily cron can't keep up with the rate of change.
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.
Proposal: Smart Embed Scheduling (Stale Page Catch-Up)
Problem
gbrain embed --staleprocesses pages one at a time with no prioritization. In a production brain with 165K+ pages, the stale embedding backlog can grow to 24K+ pages. The daily cron runsgbrain embed --stalebut can only process a fraction of the backlog before timing out or hitting rate limits, meaning the brain falls further behind every day.Stale embeddings mean semantic search returns outdated results — a page that was updated last week still has embeddings from its original content. For brains that rely on semantic search for entity resolution, content discovery, and agent workflows, this is a silent quality degradation.
Scale of Impact
Proposed Solution
1. Prioritized Batch Processing
Add
--priorityflag togbrain embed --stale:2. Catch-Up Mode
Add
gbrain embed --catch-upthat runs until all stale pages are processed:3. Dream Cycle Auto-Escalation
The dream cycle should monitor the stale count and automatically escalate:
Implementation Notes
Agent Onboarding
Doctor Detection
gbrain doctorshould flag stale counts:Migration Prompt (on upgrade)
Evidence
In the production brain, the stale count grew from 0 to 24K over several months because:
Risks & Mitigations
--rate-limitflag,--maxflag to cap per-run