Skip to content

retention: define the disposition scope and recovery contract - #240

Merged
TusanHomichi merged 1 commit into
mainfrom
issue-210-disposition-scope-contract
Nov 20, 2026
Merged

TusanHomichi merged 1 commit into
mainfrom
issue-210-disposition-scope-contract

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Primary Issue

Closes #210
Refs #64

Note: This PR adds an ADR (docs/decisions/0030-lawful-disposition-scope-and-recovery.md), so per AGENTS.md it is left open for the owner's review and merge once CI is green.

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.md
    • Decides the exact scope of lawful disposition across evaluation_record and all dependent tables, separating removed substantive record content from retained disposition certificates and audit/accountability provenance.
    • Defines the separate execute_disposition capability (distinct from administer_retention), exact-scope preview & confirmation digest contract (#211), and fail-closed refusal rules including DependentSummaryRetained when a daily report is referenced by a retained weekly summary via summary_daily_link.
    • Records the forward schema migrations required in downstream implementation PRs (record_hold.evaluation_record_id FK → insert-time existence trigger so released holds do not block lawful disposal; nullable notice.evaluation_record_id for new notices, with honest disclosure for pre-migration notices).
    • Defines the local 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
    • Exhaustive table-by-table disposition matrix, backup/recovery artifact matrix, and cross-references to the Milestone 5 implementation issues (#211–#221).
  • docs/development.md & docs/retention.md
    • Link ADR 0030 and docs/disposition-scope.md from 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.
  • Relative markdown link check across all modified/added docs: all links resolve.

Local proof receipt — passed

  • Candidate: d0875d3fefb03ae6a1f0c4ec42a8ab121868cdf3 tree 581cdc0ec1c7acd40766545a6cb4766c4c60e10d; unchanged during run: true
  • Scope: local (local run; hosted pr-gate results are separate evidence, linked not copied)
  • Command: cargo xtask proof in /data/dev/src/consolebook
  • Started 2026-11-20T17:37:11Z, finished 2026-11-20T17:44:16Z, 424.1s
  • Sequence source: CONTRIBUTING.md sha256 87f297e8dad4868f1364b29eb9a45b372ca3dc34e8e205c3505d15883036daa5
  • Browser: playwright-managed /home/dev/.cache/ms-playwright/chromium-1254/chrome-linux64/chrome (Google Chrome for Testing 158.0.8127.18)
  • Host: Linux-6.18.64-x86_64; euid 1001; can bypass file permissions: false (from CapEff)
  • Toolchain: rustc 1.99.1 (58cf8f9c3 2026-10-13); node v22.23.5; npm 10.9.9
  • Binary: target/debug/consolebook-server sha256 0dc8a5cc27fa1c04eb33c3a40f7b7b12ecf7c47ee31790ac6f58c57d97ce250e
  • Web build manifest: 54 files, sha256 976821db30ae0f8b61bd2bcaaa2498c373ecef23a571dfdca6ee36fa3cd9f495
  • Browser suite: 74 expected, 0 unexpected, 0 flaky, 0 skipped; report sha256 c89470cceac8dc4b054742e8d9aac68b7656bd66a68ccc3db38d7bb593536ca9
# Command Status Exit Seconds Log sha256 (prefix)
1 scripts/check-guidance-names.sh passed 0 0.081 01.log 2b172a8e66c87574
2 (cd web && npm ci && npm run check && npm run build) passed 0 19.222 02.log 02fbfd1b102a5552
3 cargo fmt --check passed 0 1.067 03.log e3b0c44298fc1c14
4 cargo clippy --workspace --all-targets -- -D warnings passed 0 8.682 04.log ee86f8b1b0dc5286
5 cargo test --workspace passed 0 110.606 05.log 677229ae3b4d7585
6 cargo build -p consolebook-server passed 0 0.303 06.log f591e097f22f91dd
7 (cd web && npx playwright install chromium && npm run e2e) passed 0 284.127 07.log 246a4809f6a15480

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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T17:47:09.032634Z d0875d3 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@fieldmouseworks-steward fieldmouseworks-steward Bot added the waiting: review Its reviewers, or a Claude job judging it, are looking at this head label Nov 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +215 to +220
- 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +177 to +178
1. Write the durable recovery ledger update first (`data/instance/disposition-ledger.json`,
fsynced atomically via temp file + rename + directory fsync).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@TusanHomichi
TusanHomichi merged commit 1a92c83 into main Nov 20, 2026
23 of 24 checks passed
@TusanHomichi
TusanHomichi deleted the issue-210-disposition-scope-contract branch November 20, 2026 18:13
@fieldmouseworks-steward fieldmouseworks-steward Bot removed the waiting: review Its reviewers, or a Claude job judging it, are looking at this head label Nov 20, 2026
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.

retention: define the disposition scope and recovery contract

1 participant