Repository navigation
Realize origin retention at the archive gate: proposal-support refuses a mutated origin declaration (#690) - #695
Conversation
…s a mutated origin declaration (#690) `release-realization` § "Origin retention at archive" says "Mutation of an origin declaration after ratification SHALL be rejected at the archive gate", and nothing ran it. `origin_errors` reads presence and shape off the packet in front of it; the nightly `proposal-origin` family's own "post-ratification mutation" finding compares the support manifest against that same packet. Those are two copies a lockstep edit moves together, and neither of them is the declaration the change was ratified over. PR #685 edited the `origin.approved_by` prose of an already-ratified packet — commit `ab2003aa`, after the ratifying commit `517980e1` — and the archive landed green. THE BASELINE NOW COMES FROM HISTORY, the one copy an edit at archive time cannot reach: the packet's `.openspec.yaml` at the RATIFYING COMMIT, the first commit whose `proposal.md` declares `Status: ratified`. It is resolved by walking the commits that touched that one path — `--full-history --topo-order --reverse`, so a merged branch cannot hide the earliest one and a rebased clock cannot reorder them — and reading each blob through this module's fence-aware header reader, not `git log -S`, which matches a quoted `Status: ratified` inside a ``` block as readily as a real header, and this corpus quotes lifecycle headers constantly. The origin block is compared as LINES, normalized for trailing whitespace and nothing else, so a re-indent or a re-quote after ratification is a changed declaration too. A difference refuses the archive with the changed keys and a named unified diff, exit 2, no traceback — a status a caller can tell apart from the shape errors an operator fixes and retries. For staged origins the support manifest's origin id and path are compared against the SAME baseline, which is what catches the lockstep edit that moves both copies together. There is no bypass flag: the requirement's own scenario makes accepting a mutation a contested-class act requiring an explicit disposition, and a flag here would be the disposition nobody records. TWO ARMS THAT DO NOT REFUSE, both measured rather than assumed: * NO BASELINE IS NOT A MUTATION. Four of the thirty-five active changes on `main` — add-composed-view-authoring, add-doxchat-model-intake, add-lens-document-selection, add-worker-enrollment-broker — carry an origin their ratifying commit does not, because their `Status:` headers were written by the lifecycle-header backfill (`da1b0e90`, `02009d02`) and their origins by the recorded origin sweeps (`b7513733`, `f9bb1a88`) afterwards. There is no original declaration for the current one to differ from; the missing-origin case belongs to `origin_errors` (strict) and to the family's class 1, both of which still run. The gate prints what it could not compare rather than passing silently. * NOT RATIFIED REFUSES. No commit carrying `Status: ratified` means no declaration to retain, and the message says to commit the ratification first. 137 of the 138 archived packets already declare `ratified`. A check that cannot run must not pass: an unreadable history refuses too, rather than skipping into a green. MEASURED AGAINST THE LIVE CORPUS before landing: of the 35 active changes, 25 retain their declaration, 4 are the pre-contract arm, 2 are genuinely unratified drafts, and FOUR carry a real post-ratification origin difference — add-credential-escrow-checkout (`f5e53364` wrote a second approval act into `reason` and `approved_by`), add-identity-brokering and add-trust-anchor (the install-repo rename sweep `e11a057b`, #242, rewrote the `reason` prose of two ratified packets), and retire-hermes-flat-keys-and-openworkflow-tokens (`a951be76`, #562, appended a realization note to `reason`). #685 is the fifth instance of one shape. None of them is archiving today, so this lands nothing red; when they reach their gate the remedy is the contested-class one the requirement names, which is Brett's call and not this PR's. The three archive-wrapper fixtures become real git repositories with a real ratification in history, which is what the gate reads; two of them wrote a `proposal.md` with no lifecycle header at all. `pytest tests/proposal-support`: 36 -> 50 passed (2 subtests), no new skips, run against the pinned openspec CLI 1.12.0. Refs #690. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv Lane: openxfactory-1
|
@codex review |
There was a problem hiding this comment.
Hi @brettheap! 👋
Your private repo does not have access to Sourcery.
Please upgrade to continue using Sourcery ✨
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PEP 8 spacing only; no behavior, no test changed. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv Lane: openxfactory-1
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped to the archive gate, aligns with the stated requirement, and is backed by focused, history-realistic tests that cover both success and refusal paths.
Pull request overview
Implements the missing “origin retention at archive” enforcement in scripts/proposal-support.py archive by resolving the ratifying commit from git history and refusing archives when the on-disk packet’s origin: declaration (or the support manifest’s origin fields) differs from what was ratified.
Changes:
- Add an archive-gate check that resolves the first commit where
proposal.mddeclaresStatus: ratified(fence-aware) and compares the ratifiedorigin:block (line-based, trailing-whitespace-normalized) against the working tree. - Refuse post-ratification origin mutations with a distinct CLI exit status (
2) via a dedicatedOriginRetentionError. - Add git-backed fixtures and targeted tests covering unchanged/mutated origins, fenced-header anti-vacuity, lockstep manifest edits, unreadable history, and CLI behavior; update lifecycle docs to describe the new gate.
File summaries
| File | Description |
|---|---|
scripts/proposal-support.py |
Adds ratifying-commit resolution + origin-retention comparison at archive time, plus exit-2 handling for contested-class origin mutation refusals. |
tests/proposal-support/test_proposal_support.py |
Introduces real git-history fixtures and a comprehensive test suite for the origin-retention archive gate behavior. |
docs/document-lifecycle.md |
Documents the archive gate’s new origin-retention comparison and refusal semantics (exit 2, no bypass). |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🔵 Needs a closer look
The new OriginRetentionError/exit-2 documentation is internally inconsistent with how the exception is actually raised (it’s used beyond post-ratification mutation), and should be corrected before approval.
Review details
Suppressed comments (3)
Previously missed (3) — in code that hasn't changed since the last review.
scripts/proposal-support.py:461
- OriginRetentionError’s docstring says it is raised only when the origin declaration “moved after ratification” and frames it as a contested-class mutation, but archive_change raises this exception for any non-empty origin_retention_errors output (including “not ratified” and “history unreadable”). This makes the exception contract misleading for callers and for the CLI’s exit-code semantics.
docs/document-lifecycle.md:406 - This new sentence says the gate refuses when the support manifest’s origin “id/path has moved”, but the implementation also compares
kind(and always will when an origin exists at the ratifying commit). Updating the wording avoids underspecifying what can trigger exit 2.
scripts/proposal-support.py:1546 - The comment in the OriginRetentionError handler currently describes exit 2 as specifically for a “post-ratification origin mutation” contested-class refusal, but OriginRetentionError is also raised for other retention-gate refusals (e.g., “not ratified”, “history unreadable”). Either narrow the exception usage or broaden this comment so scripts don’t draw incorrect conclusions from the exit code.
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
…that an origin moved Copilot's second pass on this branch, all three findings taken. The exception's docstring and the CLI handler's comment both described exit 2 as the post-ratification-mutation refusal, while `archive_change` raises `OriginRetentionError` for every non-empty finding list — including "not ratified" and "history is unreadable". A caller branching on the status would have drawn a conclusion the code does not support. The contract is now the honest one: exit 2 means RETENTION COULD NOT BE ESTABLISHED, which arm it was is in the message, and only the mutation arm is the contested-class refusal that goes to a disposition. A test pins it — `not ratified` through the CLI must also exit 2 with no traceback — because a promise about an exit code that nothing exercises is the kind that quietly stops being true. The lifecycle sentence said the gate refuses when the manifest's origin `id`/`path` has moved; it also compares `kind`, and it refuses on the other two arms as well. Reworded to the fields and the conditions the code has. No behavior change: same exception, same status, same three arms. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv Lane: openxfactory-1
|
Lane: openxfactory-1 Copilot's second pass (19:23Z) raised three findings, all three taken in
A test now pins the broadened contract ( Codex: usage-limit refusal on the |
|
You have reached your Codex usage limits. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
🟢 Approval recommended
The new retention gate is narrowly integrated into archive_change, has clear refusal semantics (including exit code coverage), and is backed by targeted git-history-based tests for the key mutation and edge-case arms.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
Resolves the conflict in scripts/proposal-support.py between #694 (the pinned-CLI archive wrapper, PinnedCliRefusal, exit 2) and this branch (origin_retention_errors, OriginRetentionError, exit 2). Kept both: archive_change already ran retention before pin resolution after the auto-merge (SHAPE FIRST via origin_errors, then RETENTION via origin_retention_errors, both before pinned_openspec/ validate_through_the_pin is ever reached), so the only remaining conflict was main()'s two exception arms. Combined them as two separate except clauses, OriginRetentionError first (matching the order archive_change actually raises them in), each keeping its own distinct message and both landing on exit 2 with a comment cross- referencing the other. No bypass flags added on either side. Lane: openxfactory-1 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv
…tures The merge of origin/main (#694, the pinned-CLI archive wrapper) brought in tests/proposal-support/test_pinned_openspec_cli.py, whose `a_change` fixture built a plain directory tree with no git history at all — sufficient before this branch's change, because `archive_change` never read history. Now it does (`origin_retention_errors`, before any CLI resolution), and eight of that file's tests failed with "not ratified" even after `a_change` was updated to commit a real, already-ratified one-commit repository, because the `recorded` fixture those eight tests install fakes EVERY call reachable through `subprocess.run` — the same module attribute `ratifying_commit`/`git_show_text`/`repo_revision` call `git` through — so the retention gate's own history reads came back empty regardless of what was on disk. Two changes, both scoped to this one test file: - `a_change` now creates a real one-commit git repository whose single commit already declares `Status: ratified`, built through a `subprocess .run` reference captured at import time (`_REAL_SUBPROCESS_RUN`) rather than through the module attribute the `recorded` fixture later replaces. - `recorded`'s `fake_run` passes a `git` argv straight through to that same real function and leaves it out of the recorded list, so the exact- equality assertions on openspec/npm calls are unaffected and the origin- retention gate reads the fixture's actual history. `pytest tests/proposal-support -q`: 68 passed, 2 subtests (60 passed + 8 failed before this commit). Lane: openxfactory-1 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv
| import os | ||
| from pathlib import Path | ||
| import os | ||
| import shutil |
|
Lane: openxfactory-1 (openXfactory-1; session 5e783e4d) Provenance for the admin merge of #695 (origin retention at the archive gate, issue #690 part 2).
🤖 Generated with Claude Code |
…ane re-pin `origin/main` advanced to `391d2404` while this archive was in review. The one that matters here is **#695 (`c6615a90`, 2026-09-05 22:34:48Z)**, which realizes `release-realization` § *Origin retention at archive* as running code inside `scripts/proposal-support.py` — the gate this branch's archive commit ran BY HAND because it landed **3m35s** before that commit and was not in this branch's tree. It is in the tree now, and the comparison is re-run against it. **THE GATE DOES NOT RE-RUN ON THIS MERGE, and that is by design rather than an omission.** It lives inside `proposal-support archive` — `archive_change` calls `origin_retention_errors` before the pinned CLI is even resolved — so it fires at the moment of archiving, not on every push. This packet was already archived by `8ea86896`. The comparison is therefore invoked DIRECTLY against the archived directory, which the function documents as supported (*"`directory` may be the active packet or an archived one — the replay of a landed archive reads the archived path"*), and its result is recorded in the pull request. Also in: #702's review-lane re-pin (floor 67 → 68) and #701's five corrections to `split-opendox-two-layer-product`. Every hunk auto-merged; neither `README.md` nor `tests/sequenced_after/corpus-ledger.yaml` was touched by `main` in this range, so no row moved and no partner flipped — **no MOVEMENT LOG entry is owed.** Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv Lane: openxfactory-1
… realized by #688 (a59d546), green on main (run 33995187827) (#703) Lane: openxfactory-1 (openXfactory-1) Archive of amend-unreadable-read-sibling-scenarios (ratified 2026-09-05; realized by #688 a59d546; green on main run 33995187827). First archive under the origin-retention gate (#695) and the pinned-CLI archive (#694): origin block and records byte-identical to the ratifying commit d6fd07b; MODIFIED promoted into doc-health canon byte-identical; one ledger row; owed successor (D6) carried. Brett's word: 'land it when green'. Landed under Rule 6. Admin merge: self-authored PR (standing pattern B2). Refs #662 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv
Lane: openxfactory-1 (openXfactory-1)
Refs #690, part (2): the sanctioned archive path never compared a change's origin declaration against the one it was ratified over, so the promoted requirement had no running implementation. Part (1) — restoring the mutated block on
mainbyte-for-byte to517980e1— is a separate remedy and is not in this PR.The hole
openspec/specs/release-realization/spec.md:260§ "Origin retention at archive": Mutation of an origin declaration after ratification SHALL be rejected at the archive gate.What actually ran:
origin_errors— presence and shape (a declaration exists, its kind is known, its id matches the grammar, the support manifest repeats it), all of it read off the packet in front of it. The nightlyproposal-originfamily calls its class-3 finding "post-ratification mutation", but that finding compares the manifest against the packet — two copies a lockstep edit moves together. Neither reader can see the declaration the change was ratified over, which is why #685 edited theorigin.approved_byprose of an already-ratified packet (ab2003aa, after the ratifying commit517980e1) and archived green.What the gate does now
scripts/proposal-support.py archive— before validation, before packaging, beforeopenspec archive:openspec/changes/<change>/proposal.mddeclaresStatus: ratified, by walking the commits that touched that one path (--full-history --topo-order --reverse, so a merged branch cannot hide the earliest one and a rebased clock cannot reorder them) and reading each blob through this module's fence-aware header reader. Notgit log -S: a quotedStatus: ratifiedinside a fence would resolve a ratification that never happened, and this corpus quotes lifecycle headers constantly. No such commit → refusal,not ratified.origin:block as LINES, normalized for trailing whitespace and nothing else, between that commit's.openspec.yamland the packet on disk — the working tree, notHEAD: the bytes that archive are the bytes on disk, and readingHEADwould wave through the very edit about to be committed as part of the archive. Any difference refuses, naming the changed keys and a unified diff.kind/id/pathagainst the same baseline (the requirement's second clause), which is what catches the lockstep edit that moves packet and manifest together.not ratified, unreadable history) and WHICH arm it was is in the message, never in the number. Distinct from the exit 1 this script has always used for the shape errors an operator fixes and retries. No bypass flag: the requirement's own scenario makes accepting a mutation a contested-class act requiring an explicit disposition, and a flag here would be the disposition nobody records.The #685 replay — proof it would have refused
Pre-merge
mainis543c1982^=87c15baa(the archived packet does not exist there yet);ab2003aais the archive branch head that carried the edit. Checked out in a worktree, the gate on this branch reads that tree and compares it against the ratifying commit it resolves for itself:The ratifying commit the gate resolves on its own is exactly the one #690 names, and the finding names the mutated key and both halves of the changed line.
Two arms that do not refuse — measured, not assumed
main—add-composed-view-authoring,add-doxchat-model-intake,add-lens-document-selection,add-worker-enrollment-broker— carry an origin their ratifying commit does not: theirStatus:headers were written by the lifecycle-header backfill (da1b0e90,02009d02) and their origins by the recorded origin sweeps (b7513733,f9bb1a88) afterwards. There is no original declaration for the current one to differ from, and refusing them would block four lawful archives on a defect none of them has. The gate PRINTS what it could not compare rather than passing silently; presence and shape are still gated byorigin_errors(strict) and by the family's class 1.Status: ratifiedmeans no declaration to retain; the message says to commit the ratification first. Measured, not assumed: running this gate'sorigin_retention_errorsover all 138 archived packets resolves a ratifying commit for only 79 of them (53 retained, 22 not-comparable — the same pre-contract arm as above, now measured against the archived corpus rather than the active one — and 4 mutated) and reads the remaining 59 asnot ratified: 6 were created and archived in a single squashed commit that never recorded a separate history for the active path (2026-09-03-amend-owner-layer-severity,6a39d2ab, is one), and 53 had the flip fromdrafttoratifiedland IN the very commit that moved the packet toarchive/, never in a prior one (2026-08-29-declare-generated-projection-status,b90365ff, is one). Over the last 18 archives (2026-08-31→2026-09-05) the gate reads 17 PASS and 1not ratified(the same squash artifact); Archive amend-published-tip-unreadable-scenario: ratified 2026-09-05, landed #678 (87c15baa), no code surface #685's own packet is one of the 17, this branch's tree already carrying its restore from Restore the archived origin declaration of amend-published-tip-unreadable-scenario to its ratified text (#690) #693, so none of the table's four mutations falls in that window. The workflow consequence, stated plainly: the ratification must be COMMITTED beforeproposal-support archiveruns — current practice already does.And a check that cannot run must not pass: an unreadable history refuses too, rather than skipping into a green.
One workflow consequence, stated plainly: the ratification must be COMMITTED before the archive runs. An operator who flips
Status: ratifiedin the working tree and archives in the same breath now gets thenot ratifiedrefusal, because there is no committed declaration for the archived packet to be compared against. That ordering is the requirement's, not this implementation's — a baseline that lives only in an uncommitted file is one the next reader cannot check.What the gate finds on today's corpus — please read before merging
Run against all 35 active changes on
main: 25 retained, 4 not comparable (the pre-contract arm above), 2 refused as not-ratified (both genuinelyStatus: draft), and 4 refused for a real post-ratification origin difference. The four are not artefacts of this implementation — each has a named commit that edited the origin block of an already-ratified packet, and #685 is the fifth instance of the same shape:add-credential-escrow-checkout0e2de331f5e53364(2026-08-28) — a SECOND approval act written intoreason+approved_byadd-identity-brokering1570ff7ee11a057b(#242, 2026-08-21) — an install-repo rename sweep rewrote thereasonproseadd-trust-anchor1570ff7ee11a057b(#242, 2026-08-21) — the same sweepretire-hermes-flat-keys-and-openworkflow-tokens59eb913ea951be76(#562, 2026-09-01) — a "REALIZATION NOTE, added 2026-09-01 after the fact" appended toreasonNothing is blocked by merging this PR: the comparison runs at the archive gate, and none of those four is archiving today. But when they reach it they will refuse, and the requirement's remedy is the contested-class one — restore the block to the ratifying commit's bytes (the later text belonging in the packet's own ratification record or realization note, where the #685 remedy also puts it) or record an explicit disposition. That is a governance call, not a code one, so it is named here rather than pre-empted. The operational rule it implies is worth stating plainly: a corpus-wide rename sweep must not touch the
origin:block of a ratified packet.Fixtures
Fourteen new cases in
tests/proposal-support/, each a real git repository because the baseline is real history: unchanged origin passes; the resolver lands on the commit that flipped the header (anti-vacuity); mutatedapproved_byprose refused naming both halves of the line; mutatedreasonrefused; a staged origin id moved in lockstep with its manifest refused — withorigin_errorsasserted GREEN on that same tree, so the test proves the new gate is the one that catches it; a fencedStatus: ratifiedexample does not ratify a packet; a comment appended to the block is still a changed declaration while trailing whitespace alone is not; a deleted origin refused; an unreadable history refused rather than skipped; the CLI exits 2 with no traceback; and the archive subcommand is asserted to offer no bypass flag.The three existing archive-wrapper tests become git repositories with a real ratification in history — two of them wrote a
proposal.mdwith no lifecycle header at all, so they were exercising a packet shape the corpus does not have.pytest tests/proposal-support -q: 50 passed, 2 subtests (36 before; +14), against the pinned openspec CLI 1.12.0. No new skips.Docs
One sentence in
docs/document-lifecycle.md§ "Gates In Practice", inside the paragraph that already describes what the archive gate rejects. Status unchanged (standard).Not in this PR
Restoring the mutated block on
main(#690 part 1) — that is PR #693, and this PR's replay reads the immutable commitab2003aa, so the two are independent; the vacuous--archive-gatecomparison and the archived packet's staletasks.md§2.4 that #690 also notes; wiring the retention comparison intoproposal-support verify(the gate is the archive path, which is where the requirement puts it).Sibling-lane overlap: PR #694 (#691, the pinned-CLI wrapper) edits the same file —
archive_changeandmain's exception arms. The two changes are independent in substance; whichever lands second rebases.🤖 Generated with Claude Code
https://claude.ai/code/session_01H9aKd8YF3ktcLmVJJxQYKv