Repository navigation
Widen the origin-retention walk to every visited commit, not just the tip - #999
Conversation
… tip The #833 refuse guard (ratifying_commit / ratified_under_a_former_path) only asked ratified_under_a_former_path about the commit whose OWN blob declares Status: ratified. A commit that renames an already-ratified packet AND un-ratifies the destination in the same commit is never such a candidate, so it was skipped, and a later, pairing-free re-ratification commit was accepted as the baseline instead -- later than the real ratification, waving through any origin mutation in between. That is #833's failure reached by a longer route, and PR #846 left it as a stated gap pinned by test_an_unratifying_rename_escapes_the_guard_a_stated_gap. ratifying_commit now calls ratified_under_a_former_path for every commit its walk visits, not only the one that declares ratified: kinds="RC" (unchanged) where the commit's own blob is ratified, kinds="R" (new, renames only) where it is not. Restricting the broadened case to true renames -- never copies -- keeps a packet honestly authored as a draft copy of an already-ratified one archivable: only a rename destroys the former path outright, so only a rename can be told apart from ordinary authoring by history alone. The refusal message is reworded to stay truthful whether or not the flagged commit itself declares ratified, while keeping every substring the existing #833 tests assert on. test_an_unratifying_rename_escapes_the_guard_a_stated_gap is repurposed into test_an_unratifying_rename_now_refuses_the_walk, asserting the walk now raises OriginRetentionError naming the rename commit rather than the re-ratification. All other origin-retention fixtures (happy path, draft rename then ratify, squash rename+ratify, copy into an already-ratified destination, hostile git config) are unchanged. refs #849, #833, #846 Lane: openxfactory-2 Co-Authored-By: Claude Fable 5.1 <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
Reviewer's GuideThe PR closes the #849 origin-retention gap by checking every visited commit, using rename-only detection for non-ratified hops so un-ratifying renames cannot hide behind later re-ratification while legitimate copy-based forks remain archivable; tests update the former gap fixture to verify the refusal and propagation behavior. Sequence diagram for widened origin-retention commit walksequenceDiagram
participant Walk as ratifying_commit
participant Guard as ratified_under_a_former_path
participant Git as renamed_from
loop Every visited commit
Walk->>Walk: declares_ratified(blob)
alt commit declares ratified
Walk->>Guard: ratified_under_a_former_path(revision, rel, kinds=RC)
else commit is not ratified
Walk->>Guard: ratified_under_a_former_path(revision, rel, kinds=R)
end
Guard->>Git: renamed_from(revision, rel, kinds)
Git-->>Guard: former path or None
Guard-->>Walk: former path or None
alt former path found
Walk-->>Walk: raise OriginRetentionError
else ratified commit with no former path
Walk-->>Walk: return revision
end
end
Flow diagram for rename-only protection of un-ratifying commitsflowchart TD
A[Walk a commit in the packet history] --> B{Commit blob declares ratified?}
B -->|Yes| C[Check ratified_under_a_former_path with kinds=RC]
B -->|No| D[Check ratified_under_a_former_path with kinds=R]
C --> E{Former path found?}
D --> E
E -->|Yes| F[Raise OriginRetentionError]
E -->|No| G{Commit is ratified?}
G -->|Yes| H[Accept commit as ratification baseline]
G -->|No| I[Continue to the next visited commit]
D -.-> J[Copies excluded for non-ratified hops]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟡 Changes recommended
Outstanding history-chain, copy-path coverage, messaging, and helper API findings remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR broadens origin-retention validation to reject already-ratified packets renamed and un-ratified before later re-ratification.
Changes:
- Checks non-ratified commits for true renames.
- Preserves draft fork-by-copy behavior.
- Adds regression coverage for issue #849.
File summaries
| File | Findings |
|---|---|
scripts/proposal-support.py |
Moderate (2 votes): Add end-to-end coverage for copied-as-draft packets later ratified. Moderate (1 vote): Follow the complete rename chain and add multi-hop coverage. Nit (1 vote): Make refusal messaging distinguish renames from copies. Nit (1 vote): Make kinds keyword-only in renamed_from.Nit (1 vote): Apply the same keyword-only contract to the second helper. |
tests/proposal-support/test_proposal_support.py |
Moderate (1 vote): Add coverage confirming copied-as-draft packets can later be ratified and archived successfully. |
Review details
Suppressed comments (5)
scripts/proposal-support.py:853
- When
ratified_hereis false this call useskinds="R", soformercan only come from a true rename. The shared message still calls the commit aMOVE OR COPYand infers a copy from a surviving former path; a later commit can recreate that old path, so this diagnosis is false for the new #849 case and obscures the deliberate copy-vs-rename distinction. Make the refusal text conditional on the detected kind and omit the copy deduction for rename-only refusals.
f"(`{rel}`), and {short} is a MOVE OR COPY of that ratified "
f"packet rather than its ratification, whatever `{rel}` "
f"itself declares as of {short} — and if `{former}` still "
f"stands in the tree then the packet was COPIED to this id "
f"rather than moved to it, which git pairs the same way and "
scripts/proposal-support.py:840
- This calls the guard for every revision in
listed, butlistedis still produced bygit log ... -- <rel>without--follow, so the revision set stops at the first rename. A ratified packet moved A→B while being un-ratified, then moved B→C while still draft and finally ratified at C will visit only the B→C hop; its source is draft, so this returns no former path and the later C ratification remains the baseline. Enumerate the full rename chain (or otherwise retain predecessor paths) and add a multi-hop fixture so an earlier ratified rename cannot bypass the guard.
former = ratified_under_a_former_path(
root, revision, rel, kinds="RC" if ratified_here else "R")
scripts/proposal-support.py:574
- The PR contract describes
kindsas keyword-only, but this signature still accepts positional calls such asrenamed_from(root, revision, rel, "R"). Add the keyword-only separator so the new optional filter cannot become an accidental positional API and the helper matches the stated compatibility contract.
def renamed_from(root: Path, revision: str, rel: str,
kinds: str = "RC") -> str | None:
scripts/proposal-support.py:672
- This second helper has the same mismatch with the stated keyword-only contract:
kindsis currently positional-or-keyword. Keep the new filter explicitly keyword-only here as well, consistently with the caller and the other helper.
def ratified_under_a_former_path(root: Path, revision: str, rel: str,
kinds: str = "RC") -> str | None:
tests/proposal-support/test_proposal_support.py:1682
- The new rename-only branch is justified by preserving lawful fork-by-copy authoring, but this replacement test covers only rename-plus-unratify. The existing copy test keeps the destination ratified and therefore exercises the unchanged
RCpath. Add a fixture that copies a ratified packet into a new id as draft and ratifies it later, asserting the walk/archive succeeds; otherwise regressing this branch toRCwould make that promised case unarchivable without a failing test.
`ratifying_commit` now asks EVERY commit it visits, not only the one
whose own blob declares `ratified`, so the rename-and-un-ratify
commit answers the question before the re-ratification is ever
reached, and refuses there instead — naming the RENAME commit, not
the pairing-free re-ratification a caller might otherwise suspect.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ity case Two fix-round items, both confined to the guard's tests. SonarCloud flagged 9.3% duplication on new code (gate: <=3%). The un-ratifying-rename regression test (test_an_unratifying_rename_now_ refuses_the_walk) asserted the same "walk refuses, names the right commit, origin_retention_errors and archive_change both stop" shape as the pre-existing test_a_ratified_change_renamed_afterwards_refuses_the_ walk, nearly line for line -- the two differ only in which commit the message must name and one #849-only substring. Both now call a new shared helper, assert_walk_refuses, that asserts the common shape once; each caller passes only what is actually different. Copilot's outstanding review thread on the kinds="R" branch (added to close #849): the sibling copy test, test_a_ratified_packet_copied_to_a_ new_id_refuses_too, copies a destination that is ALREADY ratified at the copy commit, so it exercises the kinds="RC" arm and would still pass even if the kinds="R" arm were accidentally widened back to "RC" -- which would make a lawful fork-by-copy (a new packet authored as a draft copy of a ratified one, ratified later) unarchivable, the exact failure ratified_under_a_former_path's own docstring says that arm exists to avoid. Added test_a_ratified_packet_copied_as_a_draft_and_ratified_later_is_not_ refused: copies a ratified packet, flips the copy back to draft in the same commit, ratifies it later, and asserts the walk does not refuse. Verified against a local mutation (kinds="RC" unconditionally): the new fixture fails on it while the existing copy test still passes, then both pass again once the mutation is reverted. Neither change touches scripts/proposal-support.py (unmodified from 99adaa9) or what the guard refuses; the CLI contract is unchanged. Confirmed test_an_unratifying_rename_now_refuses_the_walk still fails against origin/main's pre-#849-fix guard ("OriginRetentionError not raised") and passes against this branch's guard. refs #849, #833, #846 Lane: openxfactory-2 Co-Authored-By: Claude Fable 5.1 <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The retention walk misses earlier renames in a rename chain, and API and diagnostic issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (2)
scripts/proposal-support.py:672
- This companion signature has the same mismatch:
kindsis described as keyword-only, but callers can pass it positionally. Add*beforekindsso both helper APIs enforce the documented calling convention.
def ratified_under_a_former_path(root: Path, revision: str, rel: str,
kinds: str = "RC") -> str | None:
scripts/proposal-support.py:846
- The new refusal diagnostic says
carries ... in from ..., which is malformed and makes the source/destination relationship harder to parse for operators. Removeinso the message reads as carrying the current path from the former path.
f"origin-retention walk CANNOT RUN. Commit {short} carries "
f"`{rel}` in from `{former}`, which already declared "
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
Copilot review on PR #999: the PR description states kinds is keyword-only, but both signatures still accepted it positionally as a fourth argument -- inconsistent with origin_errors(..., *, strict) in this same module, which does enforce its own keyword-only boundary. Every existing call site already passes kinds=... by keyword or omits it (grepped scripts/ and tests/), so adding the `*` separator to both renamed_from and ratified_under_a_former_path is a pure API-boundary tightening with no behavioural change: full module test run is unaffected (85 passed, 67 subtests passed). refs #849 Lane: openxfactory-2 Co-Authored-By: Claude Fable 5.1 <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The moderate contract issue remains unresolved.
Review details
Suppressed comments (2)
scripts/proposal-support.py:840
- This broadened call changes the no-ratification contract: a history like ratified
change-r→ true rename tochange-s+ draft, with no later re-ratification, now raisesOriginRetentionErrorat the rename. That contradictsratifying_commit's documented... or None when no commit ...result and makesorigin_retention_errorsuse the moved-path refusal instead of itsnot ratifiedarm. Either defer the broadened refusal until a later ratification is found, or update the function/caller contract and add a regression test documenting this intentional behavior.
former = ratified_under_a_former_path(
root, revision, rel, kinds="RC" if ratified_here else "R")
scripts/proposal-support.py:731
- This new exception for a copy that enters as draft and is ratified later contradicts the public archive contract in
docs/document-lifecycle.md:453-456, which currently says that copying a ratified packet to a second id refuses identically without qualification. Please update that documentation to distinguish a copy that lands ratified (still refused) from a fork-by-copy that lands draft (now allowed), so operators are not given contradictory guidance.
default `kinds="RC"` — and a copy that enters as a draft and is ratified
later remains the fork-by-copy this gate must not trap, exactly as
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 2 days and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
Lane: openxfactory-2 (openXfactory-2) |
origin/main moved five commits ahead of this branch's fork point, three of which touch files this PR also declares edits on: - #995 (9e43f3d, ASK-7 window): four declared lines on the cli.py and serve.py rows of docs/opendox-carve-manifest.yaml, plus the four scripts/tests files that quote the running "862" declared-line total (carve_lines.py, validate-carve-manifest.py, verify-carve-arrival.py, tests/carve_manifest/test_carve_manifest.py). - #984 (a1ef886): carve tooling/admissions hardening unrelated to the five rows this PR touches. - #997, #996, #999: no overlap with this PR's files. Conflict resolution, keeping both sides: - docs/opendox-carve-manifest.yaml: the header comment block now carries the ASK-7 window's paragraph (landed first, 2026-09-11) ahead of the § 3.4 SLICE-S3 paragraph (2026-09-12), in landing order. The S3 paragraph's own arithmetic is untouched (it was already stated as a DELTA — "+40 over two rows" — precisely so a later-landing sibling act would not need to rewrite it); only its framing of the ASK-7 window changed from "is in flight" to "already moved the running total to 866", since this merge is the event that makes ASK-7's landing a fact rather than a future one. The four ASK-7 row edits (cli.py:834, serve.py:155/725/1338) and the two S3 row edits (app.js's 37 lines, test_bullseye_widget.py's 3 lines) are all kept. - scripts/carve_lines.py, scripts/validate-carve-manifest.py, scripts/verify-carve-arrival.py: each had a single docstring line citing the running declared-line total — "866" from main (ASK-7), "902" from this branch (which assumed the pre-ASK-7 base of 862). Corrected to 906 in all three: 866 (post-ASK-7) + 40 (this act's own delta) = 906, matching the pinned test assertion. - tests/carve_manifest/test_carve_manifest.py: merged both narrative additions to test_the_real_manifest_carries_the_ruled_q_l7_amendment in landing order (ASK-7 then S3), corrected the final aggregate assertion from this branch's stale (902, 151) to (906, 151), kept main's per-row pinned ASK-7 checks (cli_row/serve_row) verbatim, and fixed their comment's citation of the aggregate from (866, 150) to (906, 151) to match the corrected assert two lines above. Also fixed a second, non-conflicting docstring in test_the_line_count_is_exactly_the_expression_the_validator_carried that still read "902". A pre-existing defect, unrelated to the conflict, found while resolving: the test_bullseye_widget.py row's two edits (already on this branch's HEAD before any merge, commit 6843a25) had a blank line splicing them apart, which left the `adapter calls` edit's `note:` key duplicated with the `path constants` edit's original note — YAML silently keeps the last of a duplicate key, so the S3 note was silently discarded and the wrong note landed on the wrong edit. Confirmed with a duplicate-key-aware loader before and after. Fixed by restoring each edit's own note; a full-document duplicate-key scan afterward finds none remaining anywhere in the manifest. Verified after resolution: - python3 scripts/validate-carve-manifest.py: OK, 456 rows, 168 moved_verbatim / 150 moved_with_declared_edit / 138 not_moved. - python3 scripts/verify-carve-arrival.py --destination opendox_code --phase B against openDox-code PR #14's head (09b42f5b): DECLARED src/opendox/web/app.js, DECLARED tests/test_bullseye_widget.py, 0 refusals (three newly-created files admitted ad hoc for this local check only: src/opendox/view_extension.py, src/opendox/web/views/view_extension.js, tests/test_view_registry.py — the governed admissions-file entries for those belong to the pin-bump PR that follows #14's own landing, not this row-annotation PR). The one "unapplied" declared-edit row the summary counts is scripts/ideation_dashboard/doxbench_scope_types.py, an unrelated pre-existing row (successor #838, open at the carve) — not S3. - pytest tests/carve_arrival tests/carve_manifest tests/carve_conformance -q: 269 passed (121 + 110 + 38). Lane: openxfactory-4-opendox-extraction Refs #656 Co-Authored-By: Claude Sonnet 5 <[email protected]>



Lane: openxfactory-2 (openXfactory-2)
What. The origin-retention walk (
ratifying_commit/ratified_under_a_former_pathinscripts/proposal-support.py) now asks its "was this a move from an already-ratified path" question of EVERY commit it visits while resolving a change's ratifying commit, not only the commit whose own blob happens to declareStatus: ratified. Where that commit's own blob IS ratified, the check still runs withkinds="RC"exactly as before (a move or copy landing already-ratified still refuses). Where it is NOT ratified, the check now also runs, restricted tokinds="R"(true renames only, never copies).Why. PR #846 addressed #833 (a ratified packet renamed afterwards) but left one shape open, filed as #849: a commit that renames an already-ratified packet AND un-ratifies the destination in the same commit is never a "candidate" (its own blob isn't ratified), so it was skipped, and a later, pairing-free re-ratification commit was accepted as the baseline instead — later than the real ratification, waving through any origin mutation made in between. #846 pinned this as a stated gap via
test_an_unratifying_rename_escapes_the_guard_a_stated_gap, asserting NO refusal. Copies are deliberately excluded from the broadened check: a copy that lands short of ratified and is ratified later is indistinguishable, by history alone, from a packet honestly authored as a new draft copied from a ratified one (the former path survives either way) — only a true rename (the former path gone) can safely be told apart from ordinary authoring, so only renames are widened here. This keeps the fork-by-copy case archivable, exactly as the pre-existing docstring reasoning required.How verified.
test_an_unratifying_rename_now_refuses_the_walk, which reproduces the The #833 refuse guard asks only the candidate commit: an un-ratifying rename followed by a re-ratification still re-bases the origin-retention baseline #849 scenario (ratify → mutate origin → rename+un-ratify in one commit → re-ratify in a later commit) and assertsratifying_commitnow raisesOriginRetentionErrornaming the RENAME commit (not the re-ratification), with the same required substrings the proposal-support's origin-retention walk silently re-bases to a LATER commit when a ratified change's path moves (a rename), waving through every mutation between the real ratification and it — the failure its own docstring names; no refuse, no bypass #833 tests assert on, plus#849.self.assertRaisesfinding no exception) and PASSES against the fixed code (full tail quoted in the PR thread / final report).tests/proposal-support/test_proposal_support.pymodule: all origin-retention fixtures (the ordinary happy path, draft-renamed-then-ratified, squash rename+ratify, copy into an already-ratified destination, hostile git config, any-spelling-of-the-revision) still pass unchanged..github/workflowsfor callers ofproposal-support.py(pytest-suite.yml,openspec-cli-pin-gate.yml): neither callsrenamed_from/ratified_under_a_former_pathdirectly, and the CLI contract (archive_change, subcommands) is unchanged — only optional keyword-onlykindsparameters were added to internal helpers, defaulting to the prior behaviour.Follow-up. A multi-hop rename-chain gap raised in Copilot's review (a rename+un-ratify hop followed by a separate later rename, then ratification) is out of this PR's scope and is tracked as #1003.
refs #849, #833, #846
🤖 Generated with Claude Code
Summary by Sourcery
Broaden origin-retention checks across every visited commit while limiting the new history validation to true renames.
Bug Fixes:
Enhancements:
Tests: