Skip to content

Preserve evidence across primary agent compaction - #842

Open
TheGreatAxios wants to merge 18 commits into
mainfrom
cl-7521-preserve-compaction-evidence-with-fresh-working-context-and
Open

Preserve evidence across primary agent compaction#842
TheGreatAxios wants to merge 18 commits into
mainfrom
cl-7521-preserve-compaction-evidence-with-fresh-working-context-and

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

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.

  • Completeness certificates record what was archived before drop.
  • Fail-close keeps usable prior context instead of silently replacing history with a statistics-only summary.
  • The summarize/drop compaction selector is gone.
  • Permissions still scope archive search/read; credentials and other sessions stay out of reach.

Verification

  • bun run typecheck and bun run build pass
  • Compaction unit tests and the three-fold integration baseline pass with the completeness gate on, recovering all four required facts each fold
  • bun run check lint, typecheck, and build pass; the guarded suite failed on mcp-late-dispatch timeouts and transcript-anchor assertions that pass in isolation under seed 424242

Fixes CL-7521

@linear-code

linear-code Bot commented Sep 9, 2026

Copy link
Copy Markdown

CL-7521

@TheGreatAxios
TheGreatAxios marked this pull request as ready for review September 9, 2026 20:40
@TheGreatAxios
TheGreatAxios force-pushed the cl-7521-preserve-compaction-evidence-with-fresh-working-context-and branch 2 times, most recently from 42a4ff3 to 671cbf2 Compare September 10, 2026 07:55
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
TheGreatAxios force-pushed the cl-7521-preserve-compaction-evidence-with-fresh-working-context-and branch from 671cbf2 to 0ee6a94 Compare September 10, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant