feat(core): make path-local instruction discovery durable#35497
Open
kitlangton wants to merge 1 commit into
Open
feat(core): make path-local instruction discovery durable#35497kitlangton wants to merge 1 commit into
kitlangton wants to merge 1 commit into
Conversation
c00ae67 to
cda08a7
Compare
Replace synthetic-message instruction injection with a durable discovery projection so discovered AGENTS.md files survive compaction, forks, reverts, and restarts. - Add the instruction_file table and the durable session.instructions.discovered event; projection stores each discovered path and content with its owning assistant-message boundary and durable discovery order. - Fold discovered files into the core/instructions source through InstructionDiscovery, absorbing SessionInstructions. Completed compaction rebaselines restate discovered instructions instead of summarizing them away. - Re-read discovered files live at each observation so mid-session edits reach the model; the frozen discovery content stands in only when a file becomes unreadable. - Narrate instruction file changes as per-file deltas via diffByKey, restating the full set only for pure reorderings. - Fork copies discoveries within the inherited transcript, committed revert removes discoveries past the revert boundary, and Session movement clears them so the destination initializes a complete baseline.
cda08a7 to
0726f09
Compare
Contributor
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.
Stacked on #35583 (rename). This PR contains only the schema/event additions and the discovery redesign.
Why
Discovered subdirectory
AGENTS.mdfiles were injected as synthetic history messages. Synthetic messages are just history: compaction summarizes them away, the model silently loses authoritative path-local conventions, and nothing can restate them — the baseline never contained them. The in-memory dedup ledger also reset on Location layer restarts.What changes
One new table + one new event; everything else follows from them.
instruction_filerecords which path-localAGENTS.mdfiles a session has discovered:(session_id, path)PK,content(discovery snapshot, fallback only),message_seq(owning assistant message; drives fork copy and revert deletion),discovered_seq+position(durable order). Added by its own append-only migration.session.instructions.discoveredis the durable fact; the projector folds it intoinstruction_file, applying it only when the session's directory/workspace still matches the recorded Location.InstructionDiscoveryabsorbsSessionInstructions(deleted): discovered files join thecore/instructionssource, so completed compaction rebaselines restate them instead of summarizing them away.Instructions.diffByKey: added files render asInstructions from: <path>, edits as per-file supersessions, removals as one line. Full-set restatement survives only for pure reorderings (previously every discovery re-sent the entire accumulated set — O(n²) tokens).Compatibility
session.instructions.discoveredjoins the public event manifest; generated clients and SDK types are regenerated.Verification
bun typecheckclean in core, protocol, server, client, codemode, sdk-next, schema.bun script/migration.ts --checkpasses), events, tool-read; codemode, sdk-next, schema manifest green.