Repository navigation
retention: make backup and restore disposition-aware - #246
Conversation
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: e077c8fc8f
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c44d04aca5
ℹ️ 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".
Updated local proof receipt — passed (
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Local proof receipt — passed (
|
Primary Issue
Closes #213
Refs #64, #44
Problem And Outcome
Before confirmed disposition execution (
#214) can be enabled, backups, off-server copies, andrestoremust enforce the ADR 0030 recovery protocol so lawfully disposed records cannot be silently resurrected by restoring an older snapshot or republished off the server by backup copy catch-up, while missing, stale, corrupt, or unreachable recovery evidence fails closed.This PR implements the canonical installation-scoped recovery ledger (
data/instance/disposition-ledger.json, mirrored toCONSOLEBOOK_BACKUP_COPY_DIR), makesbackup,backup_copy,restore, and read-onlydoctordisposition-aware, adds forward migration0019_evaluation_record_id_floor.sqlso new records can never reuse disposed or ledger-reserved IDs (movinginstallation_exporttoformat_version: 4while preserving v1–v3 verification), and adds typed recovery health states and durabledisposition_runprogress interfaces for#214. No destruction endpoint is exposed in this PR.Changes
src/disposition_recovery/ledger.rs,src/data_dir.rs)consolebook-disposition-ledgerformat_version: 1in canonical JSON with"authenticity": "self_consistency_only"and strict root/entry allowlists carrying only opaque IDs, sorted SHA-256 content hashes, UTCdisposed_at, and boundedpolicy_authority(zero narratives, ratings, acknowledgments, display names, or free-form reasons).temp + sync_all + rename + file/dir fsync), reads live DB state through WAL-awarestorage::open_diagnostic(and finished snapshots throughstorage::open_snapshot), merges deterministically across sources, mirrors safely to off-server copy directories, and inspects snapshots by bothevaluation_record.idandevaluation_version.content_hash.0019_evaluation_record_id_floor.sql,evaluation_drafts.rs,summaries.rs,installation_exportv4) (persisted schema & constraints)0019_evaluation_record_id_floor.sqlwith singleton monotonic tableevaluation_record_id_floor (id CHECK (id = 1), last_reserved_id CHECK (last_reserved_id >= 0)), no-delete and monotonic-update triggers, anAFTER INSERT ON disposition_eventtrigger advancinglast_reserved_id, and anAFTER INSERT ON evaluation_recordtrigger refusing reuse of any ID<= last_reserved_idor present indisposition_event.evaluation_drafts::createandsummaries::createthrough one sharedallocate_record_id(&mut tx)allocator insidestorage::write_tx, and advancesevaluation_record_id_floorfrom the merged recovery ledger duringrestore.installation_exporttoformat_version: 4(48 carried tables), pins its specification fingerprint andtests/fixtures/installation-export-v4.zip, and keeps v1, v2, and v3 golden archives verifying untouched.src/disposition_recovery/progress.rs)disposition_runread and monotonic transition helpers (list_all_runs,list_incomplete_runs,record_step_failure,advance_to_copy_cleanup_pending,mark_run_completed), read-onlyenumerate_controlled_artifactscovering scheduled/manual, pre-migration, pre-restore (.dband.damaged),.partial/.tmp,data/exports/, and off-server copy directories, plus explicitEXTERNAL_COPIES_NON_GUARANTEEtext so Consolebook never claims external copies were deleted.inspect_recovery_healthsurfaced bydoctorand/api/backups/status(with matching TypeScript types inweb/src/lib/api/installation.ts).restore,backup,backup_copy, and read-onlydoctorrestore(RestoreOptions, CLI--backup-copy-dirand--disposition-ledger) consults local ledger, copy-dir mirror, explicit ledger, and WAL-aware live DB before touching the database; fails closed on corrupt, mismatched, missing-required, stale local, or unreachable copy-dir evidence; refuses any snapshot containing disposed record IDs or content hashes; persists collected recovery evidence todata/instance/disposition-ledger.jsonbefore promoting the restored database; advancesevaluation_record_id_floorafter opening the restored DB; prints an explicit honest warning when restoring onto a clean host with no ledger available; and fails closed on externally encrypted blobs with ADR 0027 storage-layer decryption guidance.backup::run,backup::run_after_restore,backup::before_migrating,backup_copy::copy_snapshot,backup_copy::copy_snapshot_with_data_dir, andbackup_copy::catch_upverify snapshot DB disposition coverage against the local ledger, refuse snapshots contradicting recovery evidence, refuse stale/corrupt ledgers, recognize ledger-only copy-directory ownership, and mirror clean recovery ledgers off-server.doctoradds a strictly read-onlydisposition recoverycheck reporting incomplete runs and corrupt/stale ledgers as failures and unreachable/lagging copy mirrors as warnings without modifying any file or database state.Correction Ladder
Rung 1 & Rung 2: persisted monotonic record-ID floor and triggers (
0019_evaluation_record_id_floor.sql), canonical allowlist ledger verifier and fail-closed snapshot inspection in one owning module (disposition_recovery), wired into every backup/copy/restore/doctor/draft-creation path, with process-level CLI and integration drills (tests/disposition_recovery/).Verification
All recovery drill evidence is from automated local process-level tests with invented agencies, people, schedules, and records — separate from real-host deployment verification and hosted CI. Local
cargo xtask proofreceipt for the latest head (661297a60194) is posted in comments once completed.