Skip to content

retention: execute confirmed disposition with recoverable copy cleanup - #247

Merged
TusanHomichi merged 3 commits into
mainfrom
issue-214-disposition-execution
Nov 20, 2026
Merged

TusanHomichi merged 3 commits into
mainfrom
issue-214-disposition-execution

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Closes #214
Refs #64, #44

Implements confirmed lawful disposition execution, residual-byte reclamation, durable recovery ledger updates, safe clean-snapshot replacement, and idempotent post-commit retry under ADR 0030 §§3–5.

Summary of changes

  • Forward migration 0020_disposition_execution.sql (persisted constraint changes):
    • Rebuilds record_hold and child hold_release atomically under PRAGMA foreign_keys = ON to decouple record_hold.evaluation_record_id's foreign key so historical released holds survive record destruction, while adding record_hold_record_exists (insert-time trigger) and preserving all 0015_retention_administration.sql triggers and indexes.
    • Adds nullable notice.evaluation_record_id INTEGER with index notice_evaluation_record and insert-time trigger notice_record_exists so record-linked workflow notices are purged during disposition without touching unrelated notices.
    • Replaces the 11 in-scope *_no_delete / *_frozen_delete triggers (evaluation_version, acknowledgment, amendment, draft_snapshot, review_decision, contributor_event, draft_rating, draft_rating_modifier, draft_narrative, evaluation_session, summary_daily_link) preserving their original error messages, and adds evaluation_record_no_delete, permitting deletes only when a committed/in-transaction disposition_event belongs to a disposition_run in state db_committed_vacuum_pending.
  • Owning execution and retry service (crates/consolebook-server/src/retention/disposition_execute.rs + cleanup.rs):
    • execute_disposition, execute_disposition_at, execute_disposition_with_fault, and retry_disposition_run(_at/_with_fault). Deliberately NOT wired into HTTP or UI in #214 (deferred to #219).
    • Re-verifies Capability::ExecuteDisposition, input validity, expiry, policies, holds, dependency closure, and the exact confirmation digest inside storage::write_tx (BEGIN IMMEDIATE) via build_preview.
    • Commits disposition_run, minimal disposition_event tombstones (which atomically advance evaluation_record_id_floor via 0019), optional disposition_version_hash, FK-safe batch-wide deletions across all in-scope tables, and a content-free EventKind::DispositionExecuted audit event (Subject::DispositionRun(run_id)).
    • Drives post-commit PRAGMA wal_checkpoint(TRUNCATE) (verifying (busy=0, log=0, checkpointed=0)) → VACUUM → PRAGMA wal_checkpoint(TRUNCATE), advance_to_copy_cleanup_pending, durable local recovery ledger sync, fresh clean local snapshot (backup::run_after_restore) before deleting pre-disposition local artifacts (backups/, pre-migration, pre-restore .db/.damaged, .partial/.tmp, exports/), off-server clean copy verification/replacement + ledger mirror + pre-disposition copy removal, final pre-disposition verification, mark_run_completed, and EventKind::DispositionCompleted.
  • Record-linked notices (notices.rs, evaluation_drafts.rs, draft_review.rs, finalization.rs, amendments.rs, acknowledgments.rs):
    • Stamps notice.evaluation_record_id at every evaluation-record notice site so workflow notices referencing disposed records are deleted cleanly.
  • installation_export format version 5 (docs/formats/installation-export.md, installation_export/spec*, export_verify.rs, tests/fixtures/installation-export-v5.zip):
    • Bumps INSTALLATION_FORMAT_VERSION to 5 for notice.evaluation_record_id and record_hold.evaluation_record_id FK decoupling, keeping v1–v4 golden archives verifying via versioned shims and pinning v5's spec fingerprint (91b76345199ea0bd944cfada675543b8f49228fd6340875b8b74fbb2789df301) and golden archive.
  • Integration proof (tests/disposition_execution/):
    • Raw byte-level residual scan across consolebook.db, -wal, -shm, local backups/, exports/, off-server copy_dir, recovery ledgers, audit events, and notices proving every disposed content sentinel is purged while unrelated records, enrollments, task signoffs, and released hold history survive intact.
    • Joint daily + weekly summary batch execution and raw SQL immutability negative controls across all 13 delete/update guards.
    • Deterministic fault injection at BeforeDbCommit, AfterDbCommitBeforeVacuum, DuringVacuum, DuringLedgerWrite, DuringCleanSnapshot, DuringLocalCleanup, and DuringCopyCleanup with idempotent retry_disposition_run recovery.
    • Concurrency/race tests against holds, policies, scope, expiry, revoked authority, weekly summary links, and amendments.

Correction ladder rung

  • Code, schema constraints, and automated tests (0020_disposition_execution.sql triggers enforce disposition-gated deletion at the SQLite layer; disposition_execute enforces atomic re-verification and idempotent state-machine recovery; tests/disposition_execution/ proves raw-byte purge, fault recovery, and fail-closed races).

Local proof (cargo xtask proof)

  • Candidate: 22495393217de92165c2621d9e6d24b855a5aee2 (clean tree 01d0478e3f9bff6b004905645559f267e207960a)
  • Result: passed 7/7 steps in 302.8s (guidance names, web check + build, cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, cargo build -p consolebook-server, Playwright e2e 74/74 expected, 0 unexpected, 0 flaky, 0 skipped)
  • Receipt sha256: 3c54f729f0f3e44ab6edfc4e45128374e03edaca853f0ddbb3a48f737373391b
  • Hosted CI results are separate evidence on this PR.

@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-20T22:27:55.615949Z 4be73ea Manual request
ℹ️ 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: 2249539321

ℹ️ 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".

@TusanHomichi

Copy link
Copy Markdown
Member Author

@codex review

@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: 909dbb2691

ℹ️ 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".

@TusanHomichi

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 4be73ea0a7

ℹ️ 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".

@TusanHomichi
TusanHomichi merged commit 4f84203 into main Nov 20, 2026
23 of 24 checks passed
@TusanHomichi
TusanHomichi deleted the issue-214-disposition-execution branch November 20, 2026 23:18
@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: execute confirmed disposition with recoverable copy cleanup

1 participant