Skip to content

retention: add separate disposition authority and exact-scope preview - #244

Merged
TusanHomichi merged 2 commits into
mainfrom
issue-211-disposition-authority-preview
Nov 20, 2026
Merged

TusanHomichi merged 2 commits into
mainfrom
issue-211-disposition-authority-preview

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Primary Issue

Closes #211
Refs #64, #44

Problem And Outcome

ADR 0030 and ADR 0020 require lawful disposition to be separated from retention policy/hold administration (manage_retention) and from all role bundles, and to require a read-only exact-scope preview bound to a deterministic confirmation digest before any destruction path is introduced.

This PR implements separate explicit destruction authority (execute_disposition) with attributed grant/revocation history and read-only exact-scope disposition preview + confirmation verification, without exposing any destruction or deletion path.

Changes

  • Separate authority & forward schema (0017_disposition_authority.sql)
    • Added Capability::ExecuteDisposition (execute_disposition) outside every role bundle (Administrator, Coordinator, Trainer, Trainee).
    • Added EventKind::DispositionAuthorityGranted and EventKind::DispositionAuthorityRevoked.
    • Forward migration crates/consolebook-server/migrations/0017_disposition_authority.sql adds capability TEXT NOT NULL DEFAULT 'manage_retention' CHECK (capability IN ('manage_retention', 'execute_disposition')) to retention_authority_event (persisted constraint change: constrains the new column to the closed two-capability vocabulary while existing append-only triggers remain unchanged).
    • Extended crates/consolebook-server/src/retention/authority.rs with set_disposition_authority and disposition_authority_history under manage_users, keeping manage_retention and execute_disposition completely independent.
  • Read-only exact-scope disposition preview (retention/disposition_preview.rs + queries.rs)
    • Evaluates explicit record_ids inside one read transaction after verifying Capability::ExecuteDisposition.
    • Resolves complete finalized version lineages, dependent row counts, current immutable policy versions, elapsed 24-hour-day triggers (finalized_at resetting on amendment v2+, enrollment_closed_at requiring closed non-reinstated status), all six hold kinds (litigation, anticipated_litigation, audit, investigation, public_records_request, other with configured operator authority) across all three scopes (installation, enrollment, record), and linked weekly_summary dependencies (DependentSummaryRetained / DependentSummaryBlocked without silent broadening).
    • Surfaces controlled copy inventories (data/backups/ across all four prefixes + .partial, data/exports/, and off-server copy_dir reachability), ADR 0030 §8 uncontrolled copy boundaries, and ADR 0030 §5–6 recovery obligations.
    • Binds deterministic SHA-256 confirmation_digest (15-minute validity) to actor, authority watermarks, policy watermarks, hold/release watermarks, scope/target watermarks, enrollment weekly-summary revisions/links, and controlled copy inventory — rejecting expiry, wrong actor, concurrent writes, forged digests, ineligible previews, and intervening reverted changes (revoke+regrant, policy revise+revert, hold place+release, enrollment reinstate+reclose, summary link add+remove).
    • Thin HTTP routes in retention_http.rs: GET/POST /api/retention/disposition/authority and POST /api/retention/disposition/preview. No destruction route is exposed.
    • Added execute_disposition display label in web/src/lib/format.ts.
  • Installation export format_version: 2 (installation_export, installation_verify, docs/formats/installation-export.md)
    • Bumped INSTALLATION_FORMAT_VERSION from 1 to 2 to carry retention_authority_event.capability, appended v2's spec fingerprint and vocabulary floor beside untouched v1, committed tests/fixtures/installation-export-v2.zip, and preserved full verification of committed format_version: 1 archives (installation-export-v1.zip).

Correction Ladder

Rung 1 & Rung 2: persisted schema CHECK + append-only triggers (0017_disposition_authority.sql), domain-service capability enforcement and high-watermark confirmation digest binding (retention/disposition_preview.rs), and integration tests with negative controls (tests/disposition_preview/).

Verification

  • cargo test -p consolebook-server --test disposition_preview: 7/7 passed (authority separation, policies/triggers/amendments/unfinalized, all 6 hold kinds × 3 scopes, linked summaries, expiry/wrong-actor/intervening-reverted changes, concurrent write + forged/ineligible digest negative controls, controlled copies & HTTP routes).
  • cargo test -p consolebook-server --test installation_export: 28/28 passed (1 ignored golden::regenerate), including both the_golden_version_1_archive_verifies and the_golden_version_2_archive_verifies.
  • cargo test -p consolebook-server --test retention --test doctor_migrations --test upgrade_compat --test no_credential_literals: all passed.

Local proof receipt — passed

  • Candidate: 6f999c4fafb8515f451f902fc2ed3c75e701c5be tree 826724d084e61b945c807a7c486a652f4311021f; 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-20T18:36:13Z, finished 2026-11-20T18:43:42Z, 449.2s
  • 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 0be193ceff37ec56ffe2bf9d41183320c6dc2409f42cdeef6870ac9044ae2baa
  • Web build manifest: 54 files, sha256 6229ad2a596ad5607877f03602cf9f1ad218997f04019bbabc4ba2ab04cc6899
  • Browser suite: 74 expected, 0 unexpected, 0 flaky, 0 skipped; report sha256 9fc5f33918383ecb3d71239332e8e6ee51b7d36b9caa61bbd54254adf1dea0ff
# Command Status Exit Seconds Log sha256 (prefix)
1 scripts/check-guidance-names.sh passed 0 0.104 01.log 2b172a8e66c87574
2 (cd web && npm ci && npm run check && npm run build) passed 0 27.907 02.log 361c6a05682bd1cf
3 cargo fmt --check passed 0 1.297 03.log e3b0c44298fc1c14
4 cargo clippy --workspace --all-targets -- -D warnings passed 0 12.618 04.log 4d1b01c142939eea
5 cargo test --workspace passed 0 139.549 05.log 150ca34b142c34d8
6 cargo build -p consolebook-server passed 0 0.528 06.log 92bec25ad54c6504
7 (cd web && npx playwright install chromium && npm run e2e) passed 0 267.132 07.log 43829c2d29a63547

Implements separate explicit disposition execution authority (execute_disposition) and read-only exact-scope disposition preview per ADR 0030 and ADR 0020, with no destruction operation exposed.

- Adds Capability::ExecuteDisposition (outside all role bundles), audit kinds disposition_authority_granted/revoked, and forward migration 0017_disposition_authority.sql adding capability discrimination to retention_authority_event.
- Adds read-only disposition preview and confirmation digest verification (retention/disposition_preview.rs + queries.rs) evaluating policy versions, elapsed-day triggers, all six hold kinds across all three scopes, linked weekly-summary dependencies without silent broadening, controlled copy inventories, uncontrolled copy boundaries, recovery obligations, and high-watermark confirmation binding that detects intervening reverted changes.
- Bumps installation-export format_version from 1 to 2 to carry retention_authority_event.capability while preserving version-1 verification and committed v1/v2 golden fixtures.

Closes #211
Refs #64, #44
@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-20T18:52:36.246644Z 5acdcab New commits
ℹ️ 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.

@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: 6f999c4faf

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

@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
Addresses review feedback on PR #244 by binding expires_at (as a decimal string so extreme i64 values fail closed as StaleConfirmation instead of hitting canonical JSON integer bounds) into ConfirmationBinding, and adds forged-expiry negative controls.
@TusanHomichi

Copy link
Copy Markdown
Member Author

Local proof receipt — passed (5acdcab)

  • Candidate: 5acdcabfbac0f496e9fd18138377c39633db9028 tree f8229f5055e41f24013619f7d66309e9df0ab9d2; 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-20T18:51:02Z, finished 2026-11-20T19:02:26Z, 683.5s
  • 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 f8847dd2d53c6bf8ab635720d292a5e5112d445ba01972c044b7187a2be826b6
  • Web build manifest: 54 files, sha256 fcffbe0e6cbaa57090c9654f817e316aa3174c754639d5ea8d037326aceaf38e
  • Browser suite: 74 expected, 0 unexpected, 0 flaky, 0 skipped; report sha256 7e83579163873ef5b8984150c7f900816c8f17cce1f8dcaa44aea472b0d41160
# Command Status Exit Seconds Log sha256 (prefix)
1 scripts/check-guidance-names.sh passed 0 0.101 01.log 2b172a8e66c87574
2 (cd web && npm ci && npm run check && npm run build) passed 0 31.387 02.log 764cd574278b1be8
3 cargo fmt --check passed 0 1.367 03.log e3b0c44298fc1c14
4 cargo clippy --workspace --all-targets -- -D warnings passed 0 21.841 04.log e0122f1c1bee6628
5 cargo test --workspace passed 0 185.723 05.log c234e5a45c25eb75
6 cargo build -p consolebook-server passed 0 1.759 06.log 129e0c530cfde4e7
7 (cd web && npx playwright install chromium && npm run e2e) passed 0 441.28 07.log 362a6d3763a2a36c

@TusanHomichi
TusanHomichi merged commit 5ce4263 into main Nov 20, 2026
23 of 24 checks passed
@TusanHomichi
TusanHomichi deleted the issue-211-disposition-authority-preview branch November 20, 2026 19:03
@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: add separate disposition authority and exact-scope preview

1 participant