Preserve evidence across primary agent compaction - #842
Open
TheGreatAxios wants to merge 18 commits into
Open
Conversation
TheGreatAxios
marked this pull request as ready for review
September 9, 2026 20:40
TheGreatAxios
force-pushed
the
cl-7521-preserve-compaction-evidence-with-fresh-working-context-and
branch
2 times, most recently
from
September 10, 2026 07:55
42a4ff3 to
671cbf2
Compare
Capture the post-policy representation that enters primary history — messages, tool args lifecycle, assistant text, structured/error results, MCP blocks, and attachment/overflow blob provenance — into a session-owned evidence archive with completeness certificates. Workers omit the hook.
Workers omit the holder, so assemble keeps plain storage and skips admission and authorize recording wraps.
Context store blob keys cannot contain slashes, so archive occurrences failed to persist. Hash overflow blobs after scrub and admit string send the same way as inbound messages.
Persist blobs and stage writeTurns first. Replace reactor memory only after commit so an interrupt resumes the old generation.
A failed compact commit must not later replaceTurns stale output, and an unpublished rewrite stays off the live generation until git commit succeeds.
Dedicated archive tools made the on-disk dump the implied retrieval API. Primary sessions now search and read archive:/// through search_files, grep, and read_file. Blob keys reject slash so they cannot nest under tool-output.
Failed summaries used to write a stats stub into history, and later folds stacked frozen prefixes. The primary session now keeps the prior context on summary failure and replaces the dropped prefix with a single archive-backed handoff.
Workers have no archive plugin, so advertising archive:/// sent grep onto the filesystem. Matching the formatted URI line also made pattern archive hit every occurrence. Sit archive search after shell-guard and abort the walk so the same 10s budget applies.
Compact fail-closed because the certificate hashed live history while admission stored a different representation. Record the same bytes the gate looks up; do not weaken the certificate.
Context lines and separators were counted against max_results, so later matching occurrences were dropped.
Independent review found archive: prefixes skipped workspace sanitization, workers fell through to the filesystem, and derived handoffs fail-closed the second fold. Bound refs to well-formed archive:/// paths, fail-close workers without an archive, and skip foldable units so covering matches live history.
TheGreatAxios
force-pushed
the
cl-7521-preserve-compaction-evidence-with-fresh-working-context-and
branch
from
September 10, 2026 08:39
671cbf2 to
0ee6a94
Compare
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
The primary agent archives authorized session evidence before lossy transforms, with completeness certificates. Compaction replaces stacked frozen prefixes with one evidence-backed handoff plus recent context and
archive:///references. Archived conversation is retrievable through posix search and read. Compact fail-closes when the summary or archive certificate cannot cover dropped history. Workers omit the archive.The model-backed summarizer used to receive a lossy excerpt: clipped user and assistant text, tool names, and selected references, but no tool-result bodies. Relevant evidence could disappear before the summarizer judged it. The operator-visible session stays the same chat; only the model-facing working context is replaced.
Verification
bun run typecheckandbun run buildpassbun run checklint, typecheck, and build pass; the guarded suite failed onmcp-late-dispatchtimeouts andtranscript-anchorassertions that pass in isolation under seed 424242Fixes CL-7521