You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or wi
8000
ndow. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Indexer cross-tick resume: persist state on cap-halt (try/finally saveState) #41
Filed 2026-06-30 by agent-d (the-brain indexer lane). Durable root-fix behind the references-starvation symptom (INK-586/588 mitigated the symptom by manually embedding references; this fixes the underlying cause).
Root cause (verified in source)
core/indexer/files.ts::indexAll() mutates the shared state object in-place as each directory (brain -> observations -> reflections -> references -> MEMORY.md) is walked, but only calls saveState(state) ONCE, at line 429, after a fully clean pass.
The per-tick embed cap (core/embedder/gate.ts:159) THROWS Embed quota exceeded when tickCounter > MAX_EMBEDS_PER_TICK (default 5000). That throw propagates out of indexDirectory -> out of indexAll, so line 429 never runs. All state progress from the directories that DID complete this tick is discarded. The next tick re-loadState()s the stale state and re-walks from the top, so directories indexed LAST (references, MEMORY.md) are perpetually starved on a large backlog.
Fix
Wrap the indexing body of indexAll() in try { ... } finally { await saveState(state); }. Move state.lastFullIndex = new Date().toISOString() to the END of the try (so it is only stamped on a genuinely clean completion); the finally persists partial per-file progress on a cap-halt throw, letting the next tick resume where it stopped. The throw still propagates after the finally (the daemon must still log the cap-halt).
Acceptance
Cap-halt mid-run persists partial state (next tick resumes, does not re-walk).
Clean run unchanged: lastFullIndex stamped, full state saved.
Regression test in test/indexer/ asserts state is saved when indexDirectory throws partway.
typecheck + vitest green.
Daylight MR; agent-d builds in an isolated worktree (the-brain shared tree stays on main), no merge without the maintainer.
Origin
Migrated from Linear: INK-602. The original wording is retained except the disclosed privacy and rendering edits below.
Current scope and qualifications
The description above is the original Linear account, including its historical findings and scope. It is not a fresh claim that every described defect still exists.
Current Linear state is Backlog. Prior source review recorded partial, with this remaining scope:
Obtain dated exact-SHA green typecheck and Vitest receipts; do not infer execution from source.
Publication transfers the task; it does not authorise live recovery, deployment, spending or configuration changes.
Transfer edits
Historical fleet identities are aliased; code identifiers and permitted source paths remain references.
Linear rich issue embeds are rendered as clickable Markdown links.
Additional transfer edits: principal prose alias; preserve explicit human merge gate.
Activity