Skip to content

exports: report disposition honestly in record archives and verification - #251

Open
fieldmouseworks-workers[bot] wants to merge 4 commits into
mainfrom
issue-215-record-export-disposition-v2
Open

fieldmouseworks-workers[bot] wants to merge 4 commits into
mainfrom
issue-215-record-export-disposition-v2

Conversation

@fieldmouseworks-workers

Copy link
Copy Markdown
Contributor

Fixes #215. Refs #64, #44.

Record exports now carry disposition in the archive itself. A file verified alone says which content it holds, which records were lawfully disposed, and where a policy boundary closed the metadata. It never claims destroyed bytes were checked or that a scope is legally complete.

What changes

  • Format v2 (docs/formats/record-export.md). The archive manifest adds disposition_evidence: a path and SHA-256 for disposition/evidence.json, a portable disposition evidence document for the scope, or null.
    • units lists retained versions only. It may be empty only when the evidence accounts for the scope.
    • A record is never both a unit and a tombstone.
    • Unit manifests keep format_version 1, so trainee packets and installation exports are unchanged.
  • Producer (record_export.rs, record_export/disposition.rs). The manifest and evidence are read in one transaction.
    • A fully disposed version or record scope exports its tombstone. It is not refused, and it is not presented as empty.
    • Enrollment and installation scopes carry their tombstones and every boundary checkpoint.
    • The read rule for a disposed record keeps only the grounds that survive disposition: enrollment-history readers, assigned authors, and the trainee (draft_access::may_read_disposed_record).
  • Races. A version disposed between the manifest pass and its payload fails the transfer, with no terminating chunk.
    • Fixed along the way: zip's ZipWriter finalizes itself on drop. A failed streamed export used to append a central directory and reach the client as a readable ZIP, with only a missing unit to show the failure.
    • ArchiveWriter now seals its sink when dropped unfinished, so a failed archive is never finalized. This is shared by every export family.
  • Verifier (export_verify/record.rs, file-only). Version 1 and version 2 are dispatched by name, and any other version is refused.
    • Embedded evidence is checked by the existing evidence verifier, plus the hash, installation, instant, conflict and scope-fit rules.
    • content_status() distinguishes retained-only, mixed, fully disposed, retained with a policy boundary, and boundary-only outcomes. The CLI prints each one honestly.
  • UI. The installation export card counts disposed records and boundary checkpoints. Its empty state still appears only when nothing at all is in scope.
  • Decision. ADR 0030 §9 records the format, the scopes, the read rule, races and compatibility, and amends ADR 0014's shared-version cost line. This PR touches ADRs, so per AGENTS.md it waits for the owner's merge once settled.
  • Public destruction stays unexposed. There is no HTTP or CLI route to execution; the only retention routes are authority and preview. Trainee packets (exports: carry disposition boundaries through trainee packets #216) and installation exports (exports: reconcile installation archives with completed disposition #217) reconcile separately.

Proof

  • Goldens (tests/fixtures/):
    • record-export-v1.zip was produced by origin/main's own build (format v1), so compatibility is proven against real v1 output, not an archive rewritten through the new types.
    • The v2 goldens are -mixed, -fully-disposed and -boundary-only. All four verify on every build, fail once tampered, and the regenerator refuses to overwrite them.
  • Negative fixtures (tests/record_export_disposition/) cover missing and tampered evidence, conflicts, out-of-scope tombstones, unsupported versions, and a v1 archive with an extra evidence entry.
  • Streaming:
    • An in-process race test.
    • A real-server HTTP test that disposes the last record while the transfer is stalled. The client pins a 16 KiB receive window and the corpus is about 12 MiB, so the producer is always backpressured before the victim. The test asserts the stall stayed well inside EXPORT_STALL_LIMIT, so the abort cannot come from a stall.
  • File-only CLI: export verify runs in an empty directory with CONSOLEBOOK_DATA_DIR unset, and the test asserts that only the three archives remain there afterwards.
  • Negative controls, each run with the rule disabled and observed failing:
    • The drop seal: a_dropped_writer_leaves_no_readable_archive fails.
    • The v2 empty-units rule: verification_names_every_finding fails.
    • The unit/tombstone conflict rule: the legacy/negative test fails.
    • The payload-pass missing-version check: both streaming tests fail.
  • Local gates. cargo xtask proof --chromium /nix/store/v62sqj1frk8ggvbibvgicf4dqc60y5q3-chromium-158.0.8127.36/bin/chromium ran inside nix develop in a heavy slot, under env -u LD_LIBRARY_PATH, on 8bea324. All 7 gates passed (guidance names, web check/build, fmt, clippy, workspace tests, build, e2e). Receipt sha256 3b87d4d0875e5e6fe96aa966f5c6c3ddc82db4693673099e9abc4c0401028497. CI results are separate and still to come.

Correction-ladder rung: 1 (codebase) for the failed-archive finalization, since ArchiveWriter now makes a finalized failed archive unrepresentable, and 2 (mechanical) for its unit test and the golden pins.

Roles: integrator, with one independent review pass before freezing.

🤖 Generated with Claude Code

@fieldmouseworks-steward fieldmouseworks-steward Bot added the waiting: review Its reviewers, or a Claude job judging it, are looking at this head label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting: review Its reviewers, or a Claude job judging it, are looking at this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exports: report disposition honestly in record archives and verification

1 participant