Repository navigation
retention: define the disposition scope and recovery contract - #240
Conversation
Add ADR 0030 and the source-linked disposition scope specification (docs/disposition-scope.md) inventorying every evaluation-lineage table, working copy, review snapshot, acknowledgment, amendment, summary link, notice/audit reference, index, SQLite residual byte source, local/pre-migration/pre-restore snapshot, and configured off-server copy path, plus separate execute_disposition authority, exact-scope confirmation invalidation, crash/retry states, recovery-ledger resurrection prevention, independent tombstone expiry, and non-controlled copy boundaries. No runtime destruction in this change. Closes #210 Refs #64
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0875d3fef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - If the snapshot contains any `evaluation_record.id` or | ||
| `evaluation_version.content_hash` present in the ledger, `restore` | ||
| **refuses** plain promotion so disposed records cannot silently return. | ||
| - Disposition-aware recovery either requires a post-disposition snapshot or | ||
| runs an explicit, audited re-disposition pass on the staged scratch | ||
| database (removing the ledger-listed records, vacuuming, recording the |
There was a problem hiding this comment.
Require non-reusable identities before matching disposed record IDs
When disposition deletes the highest-numbered record, the next record created by the existing services can reuse that ID: 0008_drafts.sql declares evaluation_record.id INTEGER PRIMARY KEY without AUTOINCREMENT, and both record-creation paths let SQLite allocate it. Consequently, the specified ID-or-hash restore check rejects a clean post-disposition snapshot containing the new, unrelated record; the alternative reconciliation pass could delete that legitimate record as well. Require a durable non-reuse identity/allocation contract, including across recovery, before treating a ledger record ID as sufficient evidence for refusal or deletion.
Useful? React with 👍 / 👎.
| 1. Write the durable recovery ledger update first (`data/instance/disposition-ledger.json`, | ||
| fsynced atomically via temp file + rename + directory fsync). |
There was a problem hiding this comment.
Close the database-commit-to-ledger crash window
If the process crashes after the deletion transaction commits but before this ledger update, the committed disposition certificates exist only in the live database, while every recovery ledger still lacks the new disposal. Restoring a pre-disposition snapshot under section 6 can therefore pass the ledger check and replace the database containing those certificates, resurrecting the records and losing the pending run. An existing ledger from an earlier run also means the missing-ledger warning will not expose this case. Define restore-time reconciliation with committed certificates before replacement, or another crash-safe protocol that fails closed during this window.
Useful? React with 👍 / 👎.
Primary Issue
Closes #210
Refs #64
Problem And Outcome
Milestone 5's lawful disposition work (
#211–#219, plus backup retention/verification#220–#221) needs an explicit architectural contract before any destructive code, schema migration, or backup-pruning logic is written. Without a single decision record covering every stored table, linked artifact, local backup copy, and restore boundary, downstream PRs would have to invent rules piecemeal for released holds, weekly-summary links, notices, and backup resurrection.This PR adds ADR 0030 and a companion reference specification (
docs/disposition-scope.md) that define the end-to-end lawful disposition scope, authority boundary, retention of non-substantive provenance, local backup/restore non-resurrection contract, and honest off-host copy boundary.Changes
docs/decisions/0030-lawful-disposition-scope-and-recovery.mdevaluation_recordand all dependent tables, separating removed substantive record content from retained disposition certificates and audit/accountability provenance.execute_dispositioncapability (distinct fromadminister_retention), exact-scope preview & confirmation digest contract (#211), and fail-closed refusal rules includingDependentSummaryRetainedwhen a daily report is referenced by a retained weekly summary viasummary_daily_link.record_hold.evaluation_record_idFK → insert-time existence trigger so released holds do not block lawful disposal; nullablenotice.evaluation_record_idfor new notices, with honest disclosure for pre-migration notices).data/backups/inventory (consolebook-*.db,consolebook-premigration-*.db,consolebook-prerestore-*.db,consolebook-prerestore-*.damaged), restore non-resurrection contract against committed disposition certificates, and off-host/plain-SQLite boundary consistent with ADR 0027.docs/disposition-scope.md#211–#221).docs/development.md&docs/retention.mddocs/disposition-scope.mdfrom the retention task index and "Remaining disposition work" section.Correction Ladder
Design/architecture contract (pre-implementation for Milestone 5; no runtime behavior changed in this PR). Downstream implementation PRs (
#211–#219) will enforce each contract rule with domain types, forward migrations, and integration/E2E tests.Verification
git diff --check: clean.Local proof receipt — passed
d0875d3fefb03ae6a1f0c4ec42a8ab121868cdf3tree581cdc0ec1c7acd40766545a6cb4766c4c60e10d; unchanged during run: truecargo xtask proofin/data/dev/src/consolebook87f297e8dad4868f1364b29eb9a45b372ca3dc34e8e205c3505d15883036daa5/home/dev/.cache/ms-playwright/chromium-1254/chrome-linux64/chrome(Google Chrome for Testing 158.0.8127.18)target/debug/consolebook-serversha2560dc8a5cc27fa1c04eb33c3a40f7b7b12ecf7c47ee31790ac6f58c57d97ce250e976821db30ae0f8b61bd2bcaaa2498c373ecef23a571dfdca6ee36fa3cd9f495c89470cceac8dc4b054742e8d9aac68b7656bd66a68ccc3db38d7bb593536ca9scripts/check-guidance-names.sh2b172a8e66c87574(cd web && npm ci && npm run check && npm run build)02fbfd1b102a5552cargo fmt --checke3b0c44298fc1c14cargo clippy --workspace --all-targets -- -D warningsee86f8b1b0dc5286cargo test --workspace677229ae3b4d7585cargo build -p consolebook-serverf591e097f22f91dd(cd web && npx playwright install chromium && npm run e2e)246a4809f6a15480