Skip to content

records(amend): amendments and successor versions - #41

Merged
TusanHomichi merged 3 commits into
mainfrom
claude/milestone-2-org-rename-q8b2q8
Aug 31, 2026
Merged

TusanHomichi merged 3 commits into
mainfrom
claude/milestone-2-org-rename-q8b2q8

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Primary Issue

Closes #40. Refs #32 (Milestone 4 slice 3; decision 4: amendments by the finalizing capability set, always with a required reason, always re-acknowledged).

Problem And Outcome

Finalized records could not be corrected: the 0010 placeholder trigger admitted first versions only, and any mistake sealed into a record was permanent with no lawful correction path. This slice delivers corrections without erasure, exactly as docs/records-integrity.md requires: an amendment — recorded reason, authority, identity snapshot — reopens the record's one working copy; the correction travels the ordinary workflow under the pinned version's policy; sealing produces the successor EvaluationVersion, numbered next, linked to its true predecessor, chained per ADR 0011 (the envelope commits to the predecessor's content hash; the chain hash covers it). The original stays readable and exportable while retained, and the successor starts unacknowledged — an amendment never inherits acknowledgment silently.

Changes

  • Migration 0012 — the amendment table (record, target version, required non-blank reason under the 0009 White_Space trim, authority id plus display-name snapshot, instant, append-only) doubling as the open-state marker: an amendment targeting the record's current latest version is in progress; the successor's arrival ends it by derivation, never by a mutable status column. Succession replaces evaluation_version_first_versions_only: a predecessor-bearing version lands only next-in-order on its own record's latest version, and only under that version's recorded amendment. The reopened cycle is scoped by event/decision high-water marks recorded at opening and held truthful by a trigger (a forged low mark would resurrect the superseded cycle's approval). The frozen derivation gains the reopened cycle, and the approval gate holds raw for successors — with the empty-cycle NULL comparison coalesced closed.
  • Services — amendments::open (review_evaluation, typed refusals: unfinalized, already open, blank reason; audited amendment_opened; owner noticed), amendments::history (per-version meta, amendment, and acknowledgment — every name from stored snapshots: the envelope's finalizer via json_extract over the stored bytes, the amendment's and acknowledgment's snapshot columns; no live joins). status_of and the frozen view derive the reopened cycle from post-mark events, so NotApproved answers again under a review-required policy until the correction earns its own approval. finalize seals version N+1 with predecessor_id, envelope record.predecessor_content_hash, and the chained hash; verify recomputes successor chains against the stored predecessor.
  • API — POST /api/drafts/{id}/amend, GET /api/drafts/{id}/versions; the workspace carries viewer_may_amend, latest_version_number, and open_amendment.
  • Web — the sealed view gains the version-history panel (per-version finalizer, amendment reason and authority, acknowledgment state, content hash) and the amend control; the reopened workspace shows an amendment-in-progress banner; the trainee timeline marks amended records (Amended — vN), which show awaiting acknowledgment again.

Scope

No amendment withdrawal (a mistaken opening is closed by re-sealing, which is explicit and audited; withdrawal can be modeled later if the burden proves real). No acknowledgment windows, weekly summaries, or task signoffs (slice 4), no attachments, no retention/disposition of superseded versions, no exports.

Verification

  • cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings (pedantic): clean.
  • cargo test --workspace: 101 tests green, including the new 4-test amendments suite — the full chained-successor round trip (chain hash recomputed from the stored predecessor against ADR 0011's rule, envelope lineage fields, history with per-version acknowledgments, re-acknowledgment of version 2); raw forgeries refused at the database (successor without amendment, blank reason, forged reopening marks, wrong-record target, out-of-order successor, amendment permanence); the review-required policy proving the superseded cycle's approval never leaks (service and raw); and the HTTP round trip.
  • npm run check, npm run build, npm run e2e in web/: 5/5, the drafts spec now driving finalize → acknowledge → amend with reason → correct → re-review → seal version 2 → verify chained hashes → trainee re-acknowledges.

Review And Merge Notes

Two design points worth a look:

  1. The open-amendment marker is derived, not stored: an amendment row whose target is still the latest version is the open state. This keeps the amendment append-only and makes "successor arrives → record refreezes" hold with no second authority.
  2. High-water-mark scoping rather than clearing or re-writing the event stream: the contributor-event kind set stays closed (ADR 0011's reasoning for deriving Finalized), the whole history stays intact, and the reopened cycle simply reads past the marks. The marks are facts checkable at insert, so the database holds them truthful.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg


Generated by Claude Code

A correction never edits a finalized version (docs/domain-model.md
Amendment; #32 decision 4). Opening an amendment — review_evaluation,
required reason, identity snapshotted — reopens the record's one
working copy; the correction travels the ordinary workflow under the
pinned version's policy; sealing produces the successor version,
numbered next, linked to its true predecessor, its envelope committing
to the predecessor's content hash and its chain hash extending
ADR 0011's rule. Both versions stay readable; the successor starts
unacknowledged because acknowledgments bind to exact versions.

The amendment row doubles as the open-state marker: it targets the
record's latest version, and the successor's arrival ends it by
derivation. Reopened-cycle state is scoped by event and decision
high-water marks recorded at opening and held truthful by triggers, so
a superseded cycle's approval never leaks into the new one — at the
service or raw. Migration 0012 replaces the first-versions-only
placeholder with the succession contract and reworks the frozen
derivation for the reopened cycle.

The web sealed view gains version history with amendment reasons and
per-version acknowledgments, the amend control, and an
amendment-in-progress banner; the trainee timeline marks amended
records, which await acknowledgment again.

Refs #40.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-31T07:45:07.503817Z 3e5395b 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: 4754fb66e3

ℹ️ 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 round one on the amendment slice, all three verified. An
own-record reader now sees the record's sealed self even while an
amendment is in progress: status reads finalized, the working copy and
reopened-cycle events and decisions stay out of the response, and the
amendment internals are absent — a draft in progress about the trainee
was never theirs to see. Opening an amendment advances the record's
revision, so a save or finalization carrying a prior cycle's token is
a typed stale refusal, never a silent overwrite of the new copy. And
every retained version is now readable and verifiable by number —
GET /api/drafts/{id}/versions/{n} and its verify — with the sealed
page rendering a superseded original behind an explicit banner and the
history linking each version.

Refs #40.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg

@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: 30c4345f16

ℹ️ 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 round two, both verified. ADR 0012 records the amendment state
machine as the durable decision it is: the amendment row as permanent
record and derived open-state marker, workflow reuse under the pinned
policy, high-water-mark scoping with truthfulness triggers, the
revision advance at opening, the own-record sealed projection,
retained versions readable by number, and no withdrawal in v1 — with
the rejected alternatives (event-kind extension, a mutable state
column, content resets, a parallel amendment-draft table).

And contribution coalescing now ends at the reopening mark: the
correction's first save is attributed within its own cycle instead of
coalescing into a stretch the sealed version already owns, so draft
edits remain attributable (ADR 0008) across cycles. Regression: the
same contributor saving before sealing and again in the amendment
yields one contributed event per cycle.

Refs #40.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
@TusanHomichi
TusanHomichi merged commit eec0406 into main Aug 31, 2026
1 check passed
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.

Milestone 4 slice 3: amendments and successor versions

2 participants