Repository navigation
feat(reporting): opt-in compaction of superseded snapshot revision content - #3200
Merged
Merged
Conversation
…ntent Implements the compaction adcontextprotocol/adcp#8100 permits: drops row content of superseded snapshots no caller is owed, keeping every revision's metadata. Off by default; reuses retirement's resumable, fenced deletes. Co-Authored-By: Claude Sonnet <[email protected]>
bokelley
enabled auto-merge (squash)
October 11, 2026 10:31
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — opt-in snapshot compaction for the Postgres reporting ledger, no blocking findings.
Checked:
compactSupersededSnapshotsmirrors retirement's resumable three-phase delete narrowed to one revision; eligibility CTE (postgres.ts L260-325) is fail-closed — only superseded snapshots pastmax(grace,3600)s, never the current revision's predecessor, excluded while owed by any caller's receipt/current statement, and respects the full lease/materialization/feed-consumer hold set.- Phase-2 shared-object guard (L417-423) keeps byte-identical shared chunks until the last referencing revision is compacted; resume arm excludes tombstoned obligations so it won't collide with retirement's own
pruningmarks (L1754);binding.rows.length === 0handles the retirement-wins-the-race case. - Changeset present and correctly typed
minorfor the newsrc/lib/**surface (satisfies changeset-vs-wire-impact). - 592-line PG integration test covers grace boundary, official/current protection, per-caller owed holds, shared-chunk/PG-body survival, crash resume, failed-delete retry, owed-but-lost → SERVICE_UNAVAILABLE, and maintenance wiring.
Decision table: no critical/high/medium findings; gated_paths false; high_risk false; no team gate; no prior decision. Note review_decision is REVIEW_REQUIRED but gated_paths is false, so row 2 does not fire. Falls through to row 9 → approve.
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
Adds opt-in compaction of superseded snapshot revision content, as permitted by adcontextprotocol/adcp#8100 (
reporting-revision.jsoncontent_retention). Off by default; do not enable in production before the next eligible minor after November 20, 2026 (documented in the guides and the option's TSDoc).PostgresReportingLedgerStore.compactSupersededSnapshots({ statusRetentionDays, automatedRecoveryWindowSeconds, limit?, maxFeedHoldDays?, account_id?, signal? }).maintenance: { compaction: { enabled: true; limit? } }oncreateReliableReportingService, andcompaction: { enabled: true; limit? }oncreatePostgresReliableReportingProductionService. Both reuse the service'sstatusRetentionDaysandautomatedRecoveryWindowSeconds. New maintenance task:snapshot compaction.What is compacted
A snapshot is compacted only when: a later revision supersedes it and it is not the revision the current revision supersedes (so current and official revisions are never touched); its grace of
max(automatedRecoveryWindowSeconds, 3600)s since the successor'screated_athas passed; no caller is owed it (any caller's receipt in any status, or currentreceived/unreadable/content_mismatchstatement, while the window ofstatusRetentionDaysfrom the successor'screated_atis open); it has rows; and there is no live obligation lease, pending materialization of it, or unread live feed consumer for its change row.Only row content is dropped; headers, manifests and metadata listings stay. The row set becomes
pruned, so exact reads give the existingROWS_EXPIRED-> nondisclosingREFERENCE_NOT_FOUND. A revision that is owed but unreadable still answersSERVICE_UNAVAILABLE.Safety
Same three resumable phases as retirement: eligibility re-check plus
pruningmark in one statement under the account lock (so no new revision can share its chunks), fenced external object deletes via the existing path skipping any object a non-pruned row set still references, then chunk manifest / unreferenced PostgreSQL body removal andpruned. A crash after phase 1 resumes on the next pass.Interpretations
statusRetentionDaysfrom its successor'screated_at) is open; (b) always holds while the current revision names it (stricter than the minimum).listRevisions(which hydrates rows) now omits compacted revisions rather than failing;listRevisionMetadatalists all.Testing
New PG suite
test/lib/reporting-snapshot-compaction-pg.test.js(added to the CI PG list): five-snapshot chain, grace and recovery-window math, official/current never compacted, receipt and statement pins across callers and window lapse, shared chunks (object and PostgreSQL bindings), filesystem object deletes, crash/resume, provider failure, owed-but-lost content, lease/materialization/feed holds, default-off and maintenance wiring. Existing retention, core-maintenance, row-storage and ledger PG suites pass.🤖 Generated with Claude Code