Repository navigation
Stop the persisted state growing by megabytes per run - #17
Merged
Merged
Conversation
Every Worker result stored the complete repository tree (every file's bytes, base64) in workerEvidence.entries, streamed progress events kept the raw provider event, and each 5 s poll of a running assignment appended an event and rewrote the whole state file. On a 2.5 MB fixture repository the state grew 3.5 MB per run: 121 MB after 35 runs, with a state write taking ~950 ms and a run ~95 s. - New Worker evidence stores only its exact changes plus the complete snapshot's entry count and a sha256 over the canonical tree (snapshotFormat 'base_plus_changes'). fullSnapshotEntries() rebuilds the tree from the pinned Git base plus the changes, requires every "before" to match the base, and rejects any count or digest mismatch. Validation and promotion use the rebuilt tree; promotion's copy is transient and never written back. - Legacy records keep their stored entries and are read exactly as before, so their approval and promotion digests are unchanged. A recorded legacy state fixture covers approving, promoting and tamper detection. - The approval digest still binds the whole result: it hashes the stored record, which now carries the snapshot digest. - Progress events store a bounded record (response id, model, status, assignment id, activity kind and summary) instead of the raw provider event. That is everything the Live Response panel reads. - assignment.progress and assignment.reconciled events are capped at 500 in persisted state. Sequence numbers stay monotonic. - A poll that finds a running assignment still running no longer appends an event or rewrites the state. Measured with the same benchmark: 42-60 KB per run, 1.8 MB after 35 runs, state writes ~23 ms, runs ~7 s, and 200 polls of a running assignment cause no writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DXCvrGWmmRNDLmy7nYS2QP
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.
The state file grew by megabytes per run for three reasons:
workerEvidence.entries.On a 2.5 MB fixture repository the state grew 3.5 MB per run: 121 MB after 35 runs, with each state write taking about 950 ms and each run about 95 s.
Changes
snapshotFormat: 'base_plus_changes').fullSnapshotEntries()rebuilds the tree from the pinned Git base plus the changes. Every "before" must match the base, and a count or digest mismatch is rejected.tests/fixtures/legacy-evidence-state.json) covers approve, promote, and tamper detection on old records.assignment.progressandassignment.reconciledare capped at 500 in persisted state, and sequence numbers stay monotonic.Measured (same benchmark, before → after)
mutate) at run 20Verification
snapshot-evidence,event-volumeandlive-response, plus a compact-evidence approve → promote assertion inrecorded-integration.pnpm test:bridge: 62/62 passing.The work was started by a sub-agent that was stopped partway through. I reviewed it, merged it onto current main, and updated its legacy test to send the evidence digest that approvals now require.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DXCvrGWmmRNDLmy7nYS2QP
Generated by Claude Code