Repository navigation
records(finalize): canonical bytes, completion rules, and the immutable version - #37
Conversation
ADR 0011 fixes the canonical record format Milestone 0 left open: RFC 8785 JCS semantics over a closed integer-safe subset, the record-schema 1 envelope carrying the complete historical presentation, the SHA-256 content hash, and the domain-separated chain hash with the missing-predecessor treatment pinned. Migration 0010 adds the immutable evaluation_version (update and delete refuse; first versions only until amendments; the approval gate holds raw against the pinned version's policy), finalization_policy as versioned per-version configuration backfilled all-on and frozen by publication, the typed not_observed rating marker, and the frozen derivation's terminal case. The finalization service evaluates the completion rules typed, builds the envelope from committed rows inside the write transaction, and the finalized record presents from stored bytes only, with hash verification reads. Drafts gain the Finalized status and refusal; saves accept the explicit not-observed marking; program authoring, export, and import carry the policy. Refs #36. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
The workspace gains the sealing surface: reviewers finalize with the completion rules answering typed at the act; a finalized record swaps the editing panels for a view rendered from the stored envelope — trainee identity as presented, ratings with explicit not-observed markings, narratives, both fingerprints, and hash verification with the honest wording (consistency from what is stored, not proof against a direct database writer). Rating rows take the typed "not observed" marking, which clears and disables the value. Program version authoring carries the three finalization rules with conservative defaults. Refs #36. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
Designing the completion-rule tests surfaced a reachable dead end: with review required, a reviewer could approve an incomplete draft, leaving it frozen by approval yet refused by finalization, with no thaw path. The rules now also gate submission — a draft never enters review missing what finalization will demand — and with review off they answer at the sealing attempt, where the copy is still editable; no state is a dead end (ADR 0011 records the rule). The shared rule evaluators live in one place and both paths call them. tests/canonical_format.rs pins the format with golden vectors: member ordering, exact JCS escapes, the integer subset's boundaries, the content hash, and both chain cases. tests/finalization.rs drives the rules through submission and sealing (including the explicit not-observed marker and the marker-beside-value refusal), proves the stored envelope reproduces its content hash byte-for-byte, walks the presentation fields, and forges raw: content edits, event appends, version mutation and deletion, a second version, an unapproved raw version, and coverage shrink — every one refused. The API round trip covers the typed refusal codes end to end, and the browser e2e finalizes the approved draft, reads the sealed view, and verifies the fingerprints. Review-era test fixtures pin their policies to the rules they exercise. Refs #36. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc46d37b24
ℹ️ 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".
Codex review, three confirmed findings. Finalization now carries the revision the sealer viewed and rechecks it inside the write transaction — the submission contract — so under a policy without required review a racing save resolves as a typed stale refusal instead of being sealed sight unseen; the API takes the revision and the page passes it, reloading visibly on the stale answer. The page also refuses to seal over a failed save or a stale reload, mirroring the submission guard. And the finalized header (form, trainee, program, covered sessions, instructions) now renders from the stored envelope like the rest of the sealed view, so a later rename or session close changes nothing the record presents. Tests drive the exact race — a save landing between viewing and sealing — plus the stale refusal after approval, and the API round trip carries the revision. Refs #36. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad3f9d3a67
ℹ️ 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".
Codex review, two confirmed follow-ups completing the presents-from-envelope rule: on a finalized record the attribution stream and review decisions now render the sealed identities from the envelope instead of workspace rows that join current display names, and the finalizer line reads the hashed envelope identity rather than the metadata join — a contributor, reviewer, or finalizer renamed later keeps the name the record was sealed with. Refs #36. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e8bf6be95
ℹ️ 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".
Codex review, two confirmed findings. The 0010 backfill no longer imposes the two content-completeness rules on versions that predate them: an existing approved draft missing a required narrative — legal when it was authored — would have wedged with no recovery (frozen since submission, no further decision possible, finalization refusing). Pre-existing versions keep review approval on with the content rules off; newly authored versions default all-on, and ADR 0011 records why retroactive configuration is refused. And the finalized page now fails closed: the envelope loads before the view is presented, so a failed envelope fetch shows the error and nothing from live joins — never a finalized record rendered from mutable rows. Refs #36. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ef2891b5a
ℹ️ 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".
Primary Issue
Closes #36
Refs #32
Problem And Outcome
Milestone 4 slice 1 — the transition the whole milestone rests on, and the close of Milestone 0's one open deliverable (the canonical-record-bytes specification). After merge, an approved daily draft whose completion rules pass becomes an immutable
EvaluationVersion: canonical bytes under a fixed format, a SHA-256 content hash, and a domain-separated chain hash — refused every later mutation by the database and presented from its stored envelope, never from live joins.Changes
docs/domain-model.md's EvaluationVersion (attribution stream, trainee identity as presented including the profile fields Milestone 3 design: sessions, drafts, and attribution (owner decisions needed) #22 reserved, program/form/competency/scale definitions with anchors and task prompts, ratings with the explicit not-observed marker, narratives, review decisions, covered sessions with local-time representation, finalizing actor and the policy in force, instance identity,predecessor_content_hashcommitting lineage into the bytes); both fingerprints with the missing-predecessor treatment fixed (32 zero bytes); honest hash limits per ADR 0010; who finalizes (review_evaluation);Finalizedas a derived status; completion rules enforced at submission as well as sealing so no state is a dead endevaluation_version— immutable (update/delete refuse), first versions only until amendments (slice 3 replaces that trigger), the review-approval workflow gate held raw against the pinned version's policy (missing policy fails closed);finalization_policyas versioned configuration frozen by publication — newly authored versions default all-on, while pre-existing versions are backfilled with review approval on and the two content rules off, because a completeness contract their drafts were never authored under could wedge an already-approved copy with no recovery (ADR 0011 records the retroactivity refusal);draft_rating.not_observedas a typed marker with its shape triggers (value and marker never combine); the frozen derivation gains the terminal finalized case, extending every existing freeze and event-stream guard through one ownercanonical(the serializer that refuses what the format forbids, plus both hash constructions) andfinalization(typed completion-rule evaluation shared with submission, the sealing transaction — carrying the sealer's viewed revision, rechecked in-transaction — building the envelope from committed rows, the sealed read presenting stored bytes, hash verification); drafts gainFinalized/DraftFinalizedand the two completion refusals; saves accept the not-observed marking withValueNotAllowedguarding the combination; program authoring, export, and import carry the policy (older exports import with conservative defaults)POST /api/drafts/{id}/finalize(with the viewed revision),GET /api/drafts/{id}/version,GET /api/drafts/{id}/version/verify; refusal codesnot_approved,narratives_incomplete,ratings_incomplete,already_finalized,stale_save,draft_finalizedtests/canonical_format.rs— golden vectors for member ordering, exact JCS escapes, the integer boundaries, the content hash, and both chain cases;tests/finalization.rs— completion rules at submission and sealing, the stale-seal race in both policy modes, the not-observed marker and its refusal beside a value, byte-for-byte reproducibility of the stored envelope against its hash, the presentation field walk, raw forgeries (content edits, event appends, version mutation/deletion, a second version, an unapproved raw version, coverage shrink) all refused, audit and notice counts, and the API round trip;web/e2e/drafts.spec.tsextended to finalize the approved draft, read the sealed view, and verify the fingerprints in a real browserScope
Verification
Review And Merge Notes
🤖 Generated with Claude Code
https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
Generated by Claude Code