Repository navigation
Closed
Description
Problem or outcome
Milestone 5's exit is that a center can leave with all of its data. Finalized records exist only inside the installation's database today: a version is readable over the API and its hashes can be verified there, but nothing produces a portable artifact whose integrity can be checked without the installation. This slice delivers the structured record export decided in #44 (decision 1): the stored canonical bytes travel verbatim beside a manifest, multi-record exports are an archive of the same units plus an archive manifest, and verification of an export needs nothing but the export.
Scope
In scope:
- An export unit: the stored
canonical_bytesof one finalized version, byte for byte, beside a canonical-JSON unit manifest (format and format version, installation identity, record and version identity,record_schema, content hash, chain hash, predecessor content hash, export instant). - Archives as ZIP containers with stored (uncompressed) entries, deterministic for a given scope and export instant, holding an archive manifest that lists every unit with its identity and hashes, plus the units themselves.
- Four scopes: one version, one record (every retained version, superseded originals included), one enrollment (every finalized version of its records), and the whole installation.
- Authorization as typed service contracts: version and record scopes follow the record read rule (workflow readers and the trainee's own finalized record); the enrollment scope follows the training-history read rule; the installation scope takes the existing
export_recordscapability. Empty scopes are a typed refusal, never an empty archive. - Verification from the export alone: recompute the content hash from the bytes, prove the bytes are canonical, cross-check the envelope's own identity members against the manifest, recompute the chain hash from the carried predecessor hash, link predecessors present in the same archive, and report anything in the container the manifest does not list. Available as a library function and as
consolebook-server export verify <archive>, which never opens a data directory. - Every export audited (
record_exported) with actor and subject, never content. - HTTP downloads for all four scopes and an export summary for
export_recordsholders; web links on the record page (this version, all versions), the enrollment page, and an installation-export card on Home. docs/formats/record-export.md(normative), ADR 0014, a domain-model entry for the export, and thezipdependency (no default features).
Out of scope:
- Trainee packets (slice 2), retention/holds/disposition (slice 3), PDFs, backup retention, and restore verification (slice 4).
- Persisted exports under
data/exports/: this slice streams downloads and retains nothing on disk. - Import of record exports into another installation.
Acceptance criteria
- Exporting a version yields an archive whose
record.jsonequals the storedcanonical_bytesexactly and whose manifests carry the documented fields. - The same scope exported at the same instant produces identical bytes.
-
verifyon an untouched export reports every unit verified and predecessor links resolved where the predecessor is present; a flipped byte, a swapped hash, a missing unit, or an unlisted file each produce a named finding and a failing verdict. - Authorization refusals are typed and tested for every scope; the installation scope requires
export_records. - The CLI verifier accepts a path and exits non-zero on a failing export, without touching any data directory.
- Web: the record page, enrollment page, and Home offer the downloads; the e2e proof downloads a version export from the browser and verifies it with the CLI.
- Every export is audited without record content.
Expected proof
cargo fmt --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace(newtests/record_export.rs)web/:npm run check,npm run build,npm run e2e
Related roadmap, decisions, or issues
- Refs Milestone 5 design: exports and recovery #44 (Milestone 5 design; decision 1 and slice plan)
docs/roadmap.mdMilestone 5;docs/records-integrity.md(export round-trip tests, honest verification wording); ADRs 0011–0013 fix what the bytes carry- Existing format precedent:
docs/formats/program-version-export.md
Metadata
Metadata
Assignees
Labels
No labels
Activity
records(export): structured record exports and the export format
records(export): check scope against units and reject duplicate entries
records(export): move verification into export_verify
records(export): verify record bytes as typed envelopes
records(export): refuse attachment elements and non-positive identity
records(export): require lowercase hashes; release bytes as written
docs(formats): say what export verification does not check