Skip to content

Add validate-carve-manifest.py: six ordered checks over the § 3.1 carve manifest, with its pytest driver (split-opendox § 3.1, part 1) - #839

Merged
brettheap merged 7 commits into
mainfrom
change/opendox-carve-manifest-validator
Sep 9, 2026
Merged

brettheap merged 7 commits into
mainfrom
change/opendox-carve-manifest-validator

Conversation

@brettheap

@brettheap brettheap commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)

Refs #656 — split-opendox-two-layer-product § 3.1 part 1, the validator only. Base main at 56e69a11.

FLOOR PART 1 of the RULED four-part floor (design.md § D6, RULING OQ-1) is a mapping manifest, and a manifest nothing checks is a claim rather than a floor. This PR lands the checker before its subject: docs/opendox-carve-manifest.yaml is authored at the carve commit as the last thing on that tree (scout memo § 6 ceremony), so the validator has to exist first and has to stay green until then.

NEW FILES ONLY — two of them. No existing file is touched.

file lines
scripts/validate-carve-manifest.py 1099
tests/carve_manifest/test_carve_manifest.py 1133

The six ordered checks, and what each refuses with

First failure wins; exit 0 clean / 2 on any refusal, validate-openreposhape-pin.py's convention (there is deliberately no exit 1 — "a digest drifted" and "the bytes could not be read" are the same answer to "may this carve proceed"). Prose is FAIL <manifest path>: <code> — <detail> plus one fixed remediation trailer.

  1. shape — carve-shape-invalid. schema_version the integer 1 (true and 1.0 are equal to 1 in Python and refuse), kind: opendox-carve-manifest, the three consts (digest_algorithm: sha256, digest_source: raw_git_blob, path_order: bytewise_utf8), a 40-lowercase-hex carve_commit, a label carve_tag, an owner/name source_repository, a non-empty closed destinations: map of {repository, leg}, edit_classes: asserted equal to the ruling's list, not_moved_reasons: a subset of the known five, a non-empty moved_paths:, a closed top-level key set (TOP_LEVEL_KEYS; header: is the one optional key, so a mistyped moved_path: refuses rather than being ignored), and a row grammar stated per disposition in one place (ROW_KEYS_BY_DISPOSITION): moved_* rows require git_mode (quoted) + sha256 + destination + destination_path and may not carry reason/evidence; not_moved rows require reason + evidence and may not carry sha256/git_mode/destination/destination_path. edits is grammatically legal on every disposition by design — whether it agrees with the disposition is check 6's question. A row whose source_path lies under no moved_paths: prefix refuses here too.
  2. revision — carve-revision-mismatch. Refuses unless the repository's HEAD, or --at <sha>, resolves to carve_commit. This is the ceremony's intended pressure: a file that changes on main between the manifest and the move reds the next pull request instead of surprising the destination.
  3. digest — carve-digest-mismatch / carve-path-absent. One git ls-tree -r -z --full-tree <carve_commit> supplies every mode and the whole path set; then per moved row git cat-file blob <carve_commit>:<path> is re-hashed and the recorded git_mode compared (a mode flip is the one change a blob digest cannot see, which is why the mode is carried). The blob is in hand here, so edits[].lines are also bounded by its line count — a line past EOF at the carve commit is not the falsifiable claim the numbers are recorded for (carve-shape-invalid).
  4. surface completeness — carve-surface-vacuous / carve-file-undeclared / carve-file-duplicated. Every declared prefix must match at least one file at the carve commit (a mistyped prefix otherwise contributes an empty surface while looking like coverage in review); every blob under a moved_paths: prefix appears in exactly one row; and no two moved rows may arrive at one (destination, destination_path), since completeness is otherwise guaranteed on the source side only. This is validate-openreposhape-pin.py:515-530 re-aimed, and it is RULING OQ-1's "a file in no row … is an UNDECLARED MOVEMENT and the carve REFUSES" as running code. Prefix matching is segment-aware, so scripts/pkg does not swallow scripts/pkg_old/. A row for a path the surface does not carry reports carve-path-absent, not "undeclared".
  5. closed vocabularies — carve-vocabulary-unknown. disposition ∈ the three; destination ∈ the keys of destinations:; edits[].class ∈ edit_classes:; reason ∈ not_moved_reasons:.
  6. disposition consistency — carve-disposition-inconsistent, then carve-path-order-violation. moved_with_declared_edit with empty/absent edits: is moved_verbatim mislabelled; moved_verbatim or not_moved with edits: is a contradiction. Then the rows' file order must equal their bytewise-UTF-8 sort — a ~430-row manifest is reviewed by diff, and a diff of an unsorted file hides a moved row inside a reordering.

Three refusal codes the memo did not name, and why each is separate rather than folded into carve-shape-invalid. carve-vocabulary-unknown (memo § 1.3 check 5 names the check but no code), carve-path-order-violation (§ 1.3 tacks the ordering onto check 6, which is the disposition code) and carve-surface-vacuous (round 1). Each is separate because a reader acts differently on it: "you used a word that is not in the closed list", "re-sort the file", "this prefix names nothing — re-derive it from the tree"; and none is a malformed document. The eleven-code tuple is REFUSAL_CODES, asserted as a literal in the tests so a rename or reorder reds, and now also asserted complete — test_every_code_the_validator_can_emit_is_in_the_vocabulary scans the script's own CarveRefusal(...) sites, so no code can be raised but unlisted (as carve-unreadable was) or listed but never raised.

One deviation from the memo's numbering, stated so it is a decision and not a slip. The edits[] entry grammar ({class, lines: [int…], note?}, at least one line) is enforced in check 1 rather than in check 6: it is a property of the document alone, and check 5 must read edits[].class before check 6 runs, so a vocabulary check that first had to defend itself against a malformed entry would be two checks wearing one name. Check 6 keeps what is its own — whether the entries agree with the disposition.

How the rulings are encoded

  • RULING OQ-1 (edit classes). EDIT_CLASSES = ("import rewrites", "path constants", "adapter calls"), and edit_classes: in the file is asserted equal to it, in order — declared and constant. Reading the list only from the file would let a manifest that declared its own fourth class validate against itself; the packet's "vocabulary parameterization" is not carried, so it refuses. test_a_declared_fourth_edit_class_refuses / test_a_reordered_edit_class_list_refuses.
  • RULED OQ-C (2026-09-09). The disposition list stays three and is a code constant, not a file field — nothing in the manifest can widen it. The not_moved reason vocabulary carries the nuance: the file declares its own list (so the manifest says which reasons it uses) and the validator requires that list to be a subset of KNOWN_NOT_MOVED_REASONS = stays_openxfactory_adapter, stays_openxfactory_governance, deleted_at_carve, superseded_by_split, replicated_at_destination. Declared and known, so neither a typo nor a silently widened vocabulary passes. replicated_at_destination is what makes OQ-A's scripts/output_boundary.py row expressible. A file created at a destination has no row, which the surface check enforces by construction: the manifest declares what LEAVES.
  • RULED OQ-E (2026-09-09). MANIFEST_RELPATH = "docs/opendox-carve-manifest.yaml", the ruled path verbatim, with the convention break recorded in the module docstring rather than corrected; the manifest carries a header: for the same note (permitted, unvalidated prose). Pinned by test_the_manifest_path_is_the_ruled_one.
  • The ceremony (memo § 6). carve_commit is the referent and carve_tag is a label: a tag name in carve_commit refuses as carve-shape-invalid (test_a_tag_used_as_the_referent_refuses), and the remediation trailer says re-cut and recompute, never carry digests forward.

No contracts/ schema, and no workflow

The shape checks live in code and no schema file ships under contracts/ — a new artifact there fires release-tag-gate and the digest inventory for a document with exactly one instance, and validate-openreposhape-pin.py is the precedent for a pin-like claim carrying its own grammar. There is no new workflow either: the pytest driver is the seat, which is what § 8.2 needs.

The fixture strategy

Each case builds a fresh git repository under tmp_path — git init, four files on two commits, one of them (docs/outside.md) deliberately outside moved_paths: so the completeness check cannot pass by walking the whole tree — and then generates the manifest from that tree (clean_manifest()): real git ls-tree modes, real sha256 of real blobs, all three dispositions present. Every refusal is one deliberate mutation of that document. A hand-written fixture manifest would rot against the validator and a test that had to be edited whenever a digest changed would stop being evidence.

The script is run as a subprocess — the documented invocation, tests/manifest_digests/test_manifest_digest_sweep.py:26-45's reason — and also loaded by path once, for the constant assertions. The git environment is pinned, not inherited (GIT_CONFIG_GLOBAL=/dev/null, GIT_CONFIG_NOSYSTEM=1, a repository-local identity), the treatment tests/openxwallet_pin/test_verify_pin.py:32-40 documents: a CI runner has no ambient identity and a developer's global config can carry core.hooksPath or commit.gpgsign.

Refusal-code coverage — every code is reachable, and reached

code tests
carve-shape-invalid test_a_wrong_kind_refuses, test_a_flipped_const_refuses, test_an_abbreviated_carve_commit_refuses, test_an_uppercase_carve_commit_refuses, test_a_tag_used_as_the_referent_refuses, test_a_moved_row_without_a_destination_path_refuses, test_an_unquoted_git_mode_refuses, test_a_not_moved_row_carrying_a_digest_refuses, test_a_not_moved_row_without_evidence_refuses, test_a_moved_row_carrying_a_reason_refuses, test_a_declared_fourth_edit_class_refuses, test_a_reordered_edit_class_list_refuses, test_a_not_moved_reason_the_validator_does_not_know_refuses, test_a_row_outside_the_declared_surface_refuses, test_an_edit_with_no_line_numbers_refuses, test_an_edit_with_an_unknown_key_refuses, test_a_row_with_an_unknown_key_refuses, test_a_schema_version_that_is_not_the_integer_one_refuses (5 cases), test_an_unknown_top_level_key_refuses, test_a_not_moved_row_carrying_a_destination_refuses (3 cases), test_an_edit_line_past_the_end_of_the_blob_refuses, test_an_unparseable_manifest_is_a_document_defect (22 functions / 28 cases)
carve-revision-mismatch test_head_that_is_not_the_carve_commit_refuses, test_the_revision_check_runs_before_the_digests, test_an_at_that_resolves_elsewhere_still_refuses, test_an_unresolvable_at_refuses (4)
carve-digest-mismatch test_a_drifted_digest_refuses, test_a_digest_taken_at_the_wrong_revision_refuses, test_a_mode_flip_refuses, test_the_digest_check_runs_before_the_surface_check, test_json_reports_the_refusal_code (5)
carve-path-absent test_a_moved_row_for_a_path_the_commit_does_not_carry_refuses, test_a_not_moved_row_for_an_absent_path_refuses (2)
carve-file-undeclared test_a_file_in_no_row_refuses (1)
carve-file-duplicated test_a_file_in_two_rows_refuses, test_two_rows_arriving_at_one_destination_path_refuse, test_two_destination_aliases_sharing_a_body_still_refuse_a_duplicate_arrival (3)
carve-surface-vacuous test_a_moved_paths_prefix_that_matches_nothing_refuses (1)
carve-vocabulary-unknown test_a_fourth_disposition_refuses, test_an_undeclared_destination_key_refuses, test_an_edit_class_outside_the_closed_list_refuses, test_a_reason_the_manifest_does_not_declare_refuses (4)
carve-disposition-inconsistent test_a_declared_edit_with_no_edits_refuses, test_a_declared_edit_with_no_edits_key_at_all_refuses, test_verbatim_with_edits_refuses, test_not_moved_with_edits_refuses (4)
carve-path-order-violation test_rows_out_of_bytewise_order_refuse, test_the_row_order_is_bytewise_and_not_by_code_point (2)
carve-unreadable test_a_manifest_that_is_not_utf8_refuses_rather_than_crashing, test_a_named_manifest_that_does_not_exist_refuses, test_a_named_manifest_that_does_not_exist_refuses_in_json (3)

Plus the clean pass, --at on an earlier carve commit, the negative-space cases (a file outside the surface needs no row; a sibling directory is not swallowed by the prefix; header: is still accepted; an edit on the blob's last line still passes), two ordering pins (revision before digest, digest before surface), three --json cases, the fixture's own reading of the tree (test_the_fixture_reads_the_tree_the_way_the_validator_does), and six constant assertions including the vocabulary-completeness scan and the docstring's record of the digest-field divergence.

The ABSENT-manifest behaviour, and why

Given no manifest at the default path the validator prints NO MANIFEST <path> (nothing to validate) and exits 0. It is the one branch here that is not fail-closed and it is deliberate: this file lands before its subject, and a red suite on every pull request between now and the carve would train the lane to ignore the checker — the same failure mode validate-manifest-digests.py exists to close, one level up. Everything after the manifest appears is fail-closed. The pass keys off --manifest being unset, not off the file's absence: a --manifest the caller NAMED and that is not there refuses carve-unreadable, exit 2 (round 1, S1) — otherwise the one branch here that is not fail-closed is the branch a typo selects, and a job verifying nothing reports green forever.

test_the_real_repository_answers_at_the_ruled_path runs the documented invocation from the repository root with no arguments and asserts exit 0 either way: today it asserts the NO MANIFEST line; the moment the § 6 ceremony lands the manifest at the carve commit, the same test asserts the OK line. It is a branch and never a pytest.skip — a skip is a green bar indistinguishable from a pass, and pytest-suite.yml's EXPECT_SKIPPED: "21" is an exact pin a conditional skip here would red.

Where the suite collects it

Nothing needs registering. pytest.ini declares no testpaths (it is the rootdir anchor, deliberately option-free) and the required job runs python3 -m pytest tests/ -q -m "not postgres", so tests/carve_manifest/ is collected on every pull request. No conftest.py is added — the FR-043 hermeticity guard reaches the directory through tests/conftest.py, which is what pytest.ini's own header requires. No .github/** edit is needed or made: MIN_SELECTED/MIN_PASSED are floors that 76 new passing tests only raise, and EXPECT_SKIPPED is unmoved because nothing here skips.

Evidence

  • python3 -m pytest -q tests/carve_manifest → 77 passed (51 at the first push, 53 after the Copilot round, +20 in verifier round 1 = 73, +2 in Copilot round 3 = 75, +1 in verifier round 2 = 76, +1 in Copilot round 4 = 77).
  • python3 -m pytest -q tests/manifest_digests tests/openspec_cli_pin tests/openreposhape_pin → 177 passed, unchanged from base.
  • python3 scripts/proposal-support.py . verify → proposal support verification ok.
  • python3 scripts/doc-health.py --single-repo . → 92 findings, byte-identical to the 92 the same tree reports without these two files (measured by holding them out and diffing the finding lines).
  • python3 scripts/validate-carve-manifest.py at the repository root → NO MANIFEST …/docs/opendox-carve-manifest.yaml (nothing to validate), exit 0.

Verifier round 1 — 2bf3764c

The independent verification of 122ec3fe was PASS WITH NOTES over 81 adversarial runs against four self-built fixture repositories: no attack got a wrong digest, a wrong mode, a missing file, a duplicated row, an unknown vocabulary word, an inconsistent disposition, a misordered file or a wrong revision past the validator, and no right manifest was refused. The nine wrong outcomes were all permissiveness at the edges of the row grammar. All seven should-fixes are taken, with three of the recorded notes. Each is pinned by a test that fails against 122ec3fe and passes at this head — 14 of the new cases fail against the old script, and the two fixture-side ones fail against the old Scratch.blobs().

# what changed pinned by
S1 --manifest <absent> exited 0. The seat-holding pass now keys off args.manifest is None (default path only); a named absent path refuses carve-unreadable, and --json says refused, not no-manifest. test_a_named_manifest_that_does_not_exist_refuses, …_in_json
S2 not_moved + destination/destination_path passed (and the destination was even validated against destinations:). The row grammar is now per-disposition in ONE place (ROW_KEYS_BY_DISPOSITION), and the top level is closed as well (TOP_LEVEL_KEYS, header: optional). edits stays legal on every disposition deliberately — check 6 owns the contradiction and carve-disposition-inconsistent is the more precise finding. test_a_not_moved_row_carrying_a_destination_refuses (3 cases), test_an_unknown_top_level_key_refuses, test_the_optional_header_key_is_still_accepted
S3 schema_version: true and 1.0 verified whole manifests (True == 1, 1.0 == 1). Now isinstance(v, int) and not isinstance(v, bool) and v == 1. test_a_schema_version_that_is_not_the_integer_one_refuses (5 cases)
S4 A moved_paths: prefix matching NO blob at the carve commit passed silently. New code carve-surface-vacuous, raised in check 4 because the finding is a claim about the tree that check 1 cannot make, and the remedy is to re-derive the prefix, not to fix a grammar. (The leaky direction — a row outside every prefix — already refused; its test stands.) test_a_moved_paths_prefix_that_matches_nothing_refuses
S5 An unparseable manifest was carve-unreadable while an empty one was carve-shape-invalid — two codes from two vocabularies for one kind of defect, one of them outside the closed tuple. A YAML parse error is now carve-shape-invalid with the parser's line and column; carve-unreadable means the environment and the encoding only, and is now in REFUSAL_CODES, which is asserted complete by a scan of the script's own raise sites. test_an_unparseable_manifest_is_a_document_defect, test_every_code_the_validator_can_emit_is_in_the_vocabulary, test_the_refusal_vocabulary_is_the_ratified_list
S6 Copilot's second review (12:23:07Z, suppressed comment, no thread): Scratch.blobs() claimed to read the tree "the way the validator reads it" with neither -z nor surrogateescape nor a segment-aware prefix test. Without -z git quotes a path it cannot print, so the helper silently dropped exactly the filenames S7 needs. Fixed rather than re-documented, and duplicated rather than importing in_surface (a fixture that borrowed it would agree with a broken in_surface too). test_the_fixture_reads_the_tree_the_way_the_validator_does
S7 test_the_path_order_key_survives_a_path_utf8_cannot_hold asserted nothing, ran in process, and used two paths that agree under both orders — so no test distinguished bytewise_utf8 from a code-point sort. Replaced by a subprocess test over two real files whose bytewise order is the reverse of their code-point order (\xff → U+DCFF = 56575; \xee\x80\x80 = U+E000 = 57344): the bytewise order passes, the code-point order refuses. The test asserts the fixture is actually divergent, so it cannot go vacuous again. test_the_row_order_is_bytewise_and_not_by_code_point

Notes taken. (N1) edits[].lines are bounded by the line count of the blob the digest check has already read — test_an_edit_line_past_the_end_of_the_blob_refuses, with test_an_edit_on_the_last_line_of_the_blob_passes proving the bound is inclusive. (N2) two moved rows arriving at one (destination, destination_path) refuse carve-file-duplicated with "DESTINATION" in the message — test_two_rows_arriving_at_one_destination_path_refuse. (N5) the module docstring now records in one sentence that this manifest's sha256: "<hex>" diverges from the release-digest inventory's digest: sha256:<hex> because the memo's § 1.2 example does, so the two documents' digest fields are not interchangeable — test_the_module_records_the_digest_field_divergence.

Notes NOT taken, deliberately. N3 (destination_path unvalidated — its shape is the destination repositories' question and the memo's to answer), N4 (now taken as the closed top level), N6 (leg free-form), N7 (--help does not restate the checks; matches the precedent), N8 (an assert in CarveRefusal.__init__ — the source scan makes the closure real at zero runtime risk, where an assert inside an exception constructor could itself end a run at exit 1), N9 (PyYAML's silent duplicate keys — contained, and refused downstream), N10, N11 (the line counts in the table above are refreshed), N12, N13, N14 (not this lane's worktrees). None is a hole in the floor.

Round-1 verification of the shared checkout: unchanged at 6612d323 with an empty index, touched only by fetch; all work in this lane's own worktree.

Copilot round 3 — d97371d1

Two more factual findings, both accepted. (1) destinations.<key> entries were not actually closed despite the module docstring's "closed maps" claim: an unknown key inside one was silently admitted. An entry is now closed to exactly repository (must match owner/name, the same pattern source_repository already requires) and leg (one of the RULED openRepoShape legs — code, spec, assembly — declared as the new LEGS tuple); an unknown or missing field refuses carve-shape-invalid naming the destination key and the offending field. Pinned by test_a_destination_entry_with_an_unknown_key_refuses. (2) A relative --manifest resolved against the caller's CWD rather than --repo, so --repo <other-tree> --manifest docs/....yaml pointed at the wrong file unless CWD happened to be the repo, despite the help text's "default: /...". A relative --manifest now resolves against --repo (an absolute one is untouched), and the result is always .resolve()d so NO MANIFEST, OK, a refusal's render and --json all print the absolute path actually read. Pinned by test_a_relative_manifest_resolves_against_repo_not_cwd. Both tests proven to fail against the pre-fix script (git show HEAD:scripts/validate-carve-manifest.py) and pass against the fix; the refusal-code vocabulary is unchanged (no new code). tests/carve_manifest now passes 75 (was 73); tests/manifest_digests, tests/openspec_cli_pin and tests/openreposhape_pin unchanged.

Verifier round 2 — a1205ef1

S8 taken. The RE-VERIFICATION of d97371d1 (2026-09-09) found the check_surface() duplicate-arrival check (carve-file-duplicated) keyed on the manifest's own destination ALIAS — (destination, destination_path) — not the real arrival. destinations: may legally carry two keys sharing one {repository, leg} body, so two rows naming the two different keys with one shared destination_path passed silently: keyed on the alias they look like two different destinations, but they are one real file, and one of them overwrites the other with the manifest not saying which. Now keyed on (destinations[key].repository, destinations[key].leg, destination_path); a destination naming no key of destinations: falls back to keying on the alias itself, in a 1-tuple shape that can never collide with a resolved 3-tuple — that case is check 5's carve-vocabulary-unknown and check 4 must not crash ahead of it. Pinned by test_two_destination_aliases_sharing_a_body_still_refuse_a_duplicate_arrival, proved to fail (exit 0, OK) against the pre-fix script at d97371d1 and pass (exit 2 carve-file-duplicated) against the fix.

Decided: two destinations: keys sharing one body do NOT themselves refuse at check 1. The re-verifier asked whether a redundant alias should refuse as carve-shape-invalid on its own. Answered no, and recorded in the module docstring: whether two rows actually collide at a real destination is check 4's question, not check 1's — the document alone cannot answer it — and refusing the alias regardless of row usage would make check 4's own fix permanently unreachable by any subprocess run of this file (check 1 always runs first), which is how every behavioural test in this suite is required to run.

Copilot's suppressed comment answered as unreachable, not fixed. Copilot's fifth review (5155397957, 14:03:37Z, on d97371d1) carries a suppressed comment with no thread to reply on: render() could interpolate a surrogateescape-decoded tree path and crash the "no exit 1" contract on unprintable bytes. The re-verifier proved it unreachable across 14 runs (3 refusal paths × 5 stdio configurations, plain and --json), because CPython pins sys.stderr's error handler to backslashreplace regardless of PYTHONIOENCODING. One sentence recording that guarantee is now in CarveRefusal.render()'s own docstring; no code change. This PR comment is the record, since the review carries no comment thread.

N3 stands, declared not taken. destination_path remains unvalidated shape (../../etc/passwd and /etc/passwd both still pass): the shape is the memo's row example to constrain, not this validator's, and closing it is owed at the carve rather than here.

One environmental note recorded and left alone. --repo <typo> with the DEFAULT --manifest still exits 0 NO MANIFEST, because the seat-holding pass fires before any check that --repo names a real git repository — S1's argument, applied to the sibling flag. Reasonable to leave: --repo has no production caller today and the documented invocation is argument-free.

tests/carve_manifest now passes 76 (was 75); tests/manifest_digests, tests/openspec_cli_pin and tests/openreposhape_pin unchanged at 177. python3 scripts/validate-carve-manifest.py at the repository root → NO MANIFEST …/docs/opendox-carve-manifest.yaml (nothing to validate), exit 0.

Copilot round 4 — 3544d07e

Two more factual findings, both accepted. (1) A non-string destinations: key — PyYAML parses an unquoted 1: as the int 1, not a label — passed check_shape() in silence and reached check_vocabularies()'s sorted(destinations) the moment a row's (always-string) destination failed to match it, raising a raw TypeError and exiting 1: not one of the two exit codes this file's own docstring promises. check_shape() now requires every destinations: key to be a non-empty string matching a label pattern (^[a-z][a-z0-9_]*$), refusing carve-shape-invalid and naming the offending key's repr — checked before the entry's own shape, the same first-failure-wins discipline every other check here keeps. Pinned by test_a_non_string_destination_key_refuses, proved to fail (exit 1, TypeError: '<' not supported between instances of 'str' and 'int', a traceback) against the pre-fix script at this round's base commit a25a3235, and to pass (exit 2 carve-shape-invalid, no traceback) against the fix. (2) The refusal-code closure test's regex matched only a double-quoted CarveRefusal("...") first argument, so a single-quoted raise site would silently miss its own code — the exact blind spot the test exists to close. Replaced with an ast walk over Call nodes named CarveRefusal whose first argument is a string constant, which reads either quote style alike and fails loudly (rather than skipping) on a call whose first argument is not a literal. The test's bidirectional contract is unchanged: every raised code is ratified, every ratified code is raised.

Swept for every other site a manifest-supplied value reaches a sort, comparison or hash. Every other candidate is already isinstance(str)-gated in check_shape() before use — source_path via _require_str, edits[].lines via an explicit isinstance(line, int) check, and destination/reason/edit["class"] all validated (or their row's disposition refused first) before their respective vocabulary checks run — except check_vocabularies()'s own sorted(destinations), which is the same site this fix closes at its source, since check_shape() always runs first. No other independent fix was needed.

tests/carve_manifest now passes 77 (was 76); tests/manifest_digests, tests/openspec_cli_pin and tests/openreposhape_pin unchanged at 177. python3 scripts/validate-carve-manifest.py at the repository root → NO MANIFEST …/docs/opendox-carve-manifest.yaml (nothing to validate), exit 0.

NOT DONE — deliberately, and each is somebody else's step

  • The manifest itself is not authored. docs/opendox-carve-manifest.yaml does not exist and is not created here; it is cut at the carve commit after the OQ-B pre-carve splits land (ruling order, steps 4 and 5).
  • No carve. No file moves, no git filter-repo, no destination repository is touched.
  • No openspec/**, contracts/** or .github/** edit. No proposal, no spec delta, no schema, no workflow, no task box ticked — § 3.1 and § 8.2 stay unticked until the manifest exists.
  • No existing script, module, test or README line changed. Two new files, nothing else. There is no per-validator index row in README.md to add one to (the 53 scripts/validate-*.py mentions are prose in situ, not a table), so no README change was made.
  • Floor parts 2, 3 and 4 (summing test counts, the neutral conformance corpus, the snapshot-equivalence run) are untouched — no part substitutes for another.

Asking for Brett Heap's separate word to land this.

🤖 Generated with Claude Code

https://claude.ai/code/session_0139swz8Tq3FjNveDRR2SNPv

… 3.1, part 1)

FLOOR PART 1 of the RULED four-part floor (design.md § D6, RULING OQ-1) is a
mapping manifest with per-file digests and a closed edit-class list, and a
manifest nothing checks is a claim rather than a floor. This lands the checker
BEFORE its subject: `docs/opendox-carve-manifest.yaml` is authored at the carve
commit as the last thing on that tree (scout memo § 6), so given no manifest the
validator prints `NO MANIFEST <path> (nothing to validate)` and exits 0 — the one
branch here that is not fail-closed, deliberately, because a red suite on every
pull request until the carve would train the lane to ignore the checker.

Six ordered checks, first failure wins, exit 0 clean / 2 on any refusal
(validate-openreposhape-pin.py's convention, and there is no exit 1 for its
reason): shape (`carve-shape-invalid`); revision, refusing unless HEAD or
`--at <sha>` resolves to `carve_commit` (`carve-revision-mismatch`); digest,
recomputing the sha256 of the raw git blob at the carve commit and comparing the
recorded git_mode (`carve-digest-mismatch` / `carve-path-absent`); surface
completeness over every `moved_paths:` prefix, which is RULING OQ-1's "a file in
no row is an UNDECLARED MOVEMENT" as running code (`carve-file-undeclared` /
`carve-file-duplicated`); the closed vocabularies (`carve-vocabulary-unknown`);
and disposition consistency plus the bytewise row order
(`carve-disposition-inconsistent` / `carve-path-order-violation`).

The rulings are encoded rather than described. `edit_classes:` is asserted EQUAL
to the ruling's own three, in order, so a manifest declaring its own fourth class
cannot validate against itself. The three dispositions are a code constant that
nothing in the file can widen (RULED OQ-C), while the `not_moved` reason
vocabulary is declared in the file AND required to be a subset of the known five,
so `replicated_at_destination` is expressible and a typo is not. The manifest
path is the ruled one verbatim (RULED OQ-E), with the docs/ convention break
recorded rather than corrected. `carve_tag` is a label: a tag name in
`carve_commit` refuses.

No schema ships under contracts/ — the shape checks live in code, because a new
artifact there fires release-tag-gate and the digest inventory for a document
with exactly one instance. No workflow is added: pytest.ini declares no
testpaths and the required job runs `pytest tests/`, so tests/carve_manifest/ is
collected on every pull request; nothing here skips, so the exact EXPECT_SKIPPED
pin does not move.

The driver builds a throwaway git repository per case and GENERATES the manifest
from that tree, so the clean case is clean by construction and every refusal is
one deliberate mutation away from it; each of the nine refusal codes is reached
by at least one test, and two tests pin the check ORDER. 51 tests pass; the
manifest-digests, openspec-cli-pin and openreposhape-pin suites are unchanged
(177); proposal-support verify is ok; doc-health reports 92 findings on this
branch and 92 identical findings without these files.

Refs #656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0139swz8Tq3FjNveDRR2SNPv
Copilot AI lite review requested due to automatic review settings September 9, 2026 12:07

@sourcery-ai sourcery-ai 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.

Hi @brettheap! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

Copilot AI 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.

🟡 Changes recommended

There is at least one concrete correctness issue in the validator (potential uncaught UnicodeEncodeError in the path-order check) that can crash the script and violate the stated exit-code contract.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new carve-manifest validator and a comprehensive pytest suite to enforce the “§ 3.1 carve manifest” floor for the upcoming openDox/openXdox extraction, including ordered refusal semantics, stable refusal codes, and a seat-holding “no manifest yet” pass.

Changes:

  • Introduces scripts/validate-carve-manifest.py, implementing six ordered validation checks with refusal-code reporting (human and --json).
  • Adds tests/carve_manifest/test_carve_manifest.py, generating a scratch git repo/manifest and pinning every refusal code + ordering constraints via subprocess-driven tests.
File summaries
File Description
scripts/validate-carve-manifest.py New CLI validator implementing the ordered carve-manifest checks and refusal semantics.
tests/carve_manifest/test_carve_manifest.py New pytest suite that builds hermetic scratch repos/manifests and asserts each refusal code and check ordering.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/validate-carve-manifest.py Resolved
Comment thread scripts/validate-carve-manifest.py Resolved
…annot hold, and say what renders the refusal

Two factual findings, both accepted.

(1) The bytewise sort key encoded STRICTLY while `tree_at()` decodes git's
paths with `surrogateescape` two functions away. A path is bytes, and the
strict encode would raise `UnicodeEncodeError` out of the comparison and end
the run with a traceback and exit 1 — the exit code this file's docstring says
does not exist. The key now encodes with `surrogateescape` too. Following the
same reasoning to the input side found a hole that IS reachable today:
`read_manifest` caught `OSError` and `yaml.YAMLError`, and a manifest file that
is not valid UTF-8 raises `UnicodeDecodeError`, which is a `ValueError` and was
caught by neither — so the one input class Copilot's finding is about was
crashing rather than refusing. `ValueError` is now caught and the file reports
`carve-unreadable`, exit 2. Both are pinned:
`test_a_manifest_that_is_not_utf8_refuses_rather_than_crashing` and
`test_the_path_order_key_survives_a_path_utf8_cannot_hold`.

(2) `CarveRefusal`'s docstring was inherited from
`validate-openreposhape-pin.py`, where the message IS `str(exc)`. Here it is
`render(manifest)`, because the message names the manifest that failed and the
exception does not carry it — every check can be raised from a nested helper
that has no idea which file it is reading. The docstring now says that, and
says why it is a method rather than `__str__`, so the next refactor does not
reach for `str(exc)` semantics that are not there.

53 tests pass (was 51).

Refs #656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0139swz8Tq3FjNveDRR2SNPv
Copilot AI review requested due to automatic review settings September 9, 2026 12:19

Copilot AI 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.

🔵 Needs a closer look

The test fixture helper Scratch.blobs() documents that it parses the tree “the way the validator reads it” but currently uses different git ls-tree flags/decoding, making the docstring inaccurate and allowing fixture parsing semantics to drift from the validator.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

tests/carve_manifest/test_carve_manifest.py:160

  • Scratch.blobs() claims it reads the carve surface “the way the validator reads it”, but it calls git ls-tree without -z and relies on text=True decoding/splitting by lines. The validator uses ls-tree -z and surrogateescape decoding to correctly handle unusual/non-UTF-8 paths; keeping this mismatch can let the test fixture generator drift from the validator’s parsing semantics (and makes the docstring incorrect).
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)
INDEPENDENT VERIFICATION of head 122ec3fe1f9cfe2ad378e0dbe9ac76fa14daca1f — PASS WITH NOTES

VERDICT: PASS WITH NOTES at head 122ec3fe1f9cfe2ad378e0dbe9ac76fa14daca1f (pinned via headRefOid; unmoved through the whole run). I did not author this and built my own throwaway fixtures rather than reusing the author's. 81 adversarial runs: 72 RIGHT, 9 WRONG, 0 BLOCKING. Not one attack got a wrong DIGEST, a wrong MODE, a missing file, a duplicated row, an unknown vocabulary word, an inconsistent disposition, a misordered file or a wrong revision past the validator; not one right manifest was refused. The nine wrong outcomes are all permissiveness at the edges of the row grammar — six SHOULD-FIX, and the carve's guarantee stands without them.

Items

# item verdict evidence
1 Scope PASS git diff --name-status 56e69a11...HEAD = exactly two A lines (scripts/validate-carve-manifest.py, tests/carve_manifest/test_carve_manifest.py), 1597 insertions, 0 deletions. Nothing under openspec/, contracts/, .github/; docs/opendox-carve-manifest.yaml absent. merge-base --is-ancestor 56e69a11 HEAD true, 0 merges in range — a clean fast-forward of the 56e69a11 the body declares.
2 Spec conformance PASS All six memo § 1.3 checks implemented, and validate() runs them in the memo's exact order: shape → revision → digest → surface → vocabularies → consistency. Codes match the memo where the memo names one; EDIT_CLASSES/DISPOSITIONS/KNOWN_NOT_MOVED_REASONS are design.md § D6 + tasks § 3.1 + memo § 1.2 verbatim. Detail below.
3 Adversarial PASS w/ notes 81 runs over 4 self-built fixture repos. Tables below.
4 Exit codes PASS Only return 0 (×2) / return 2 reachable in main(); the sole sys.exit(2) is the PyYAML-absent guard. No traceback on any of the 81 runs. --repo <missing dir> and --repo <non-git dir> → exit 2 carve-unreadable. A carve_commit unknown to the repo cannot reach tree_at(): check 2 refuses first. Argparse's own error also exits 2, so the two-valued contract holds for bad flags too.
5 Digest semantics PASS Digest is hashlib.sha256(git cat-file blob <carve_commit>:<path>). Proved the tree and not the checkout is the referent: with HEAD == carve_commit, I overwrote a moved file in the working tree with different bytes and the verdict stayed OK/exit 0. A digest recorded from the OTHER commit's version of the same path refuses (carve-digest-mismatch). Shape chosen = sha256: <raw 64 lowercase hex> — see NOTE N5 on the precedent.
6 Tests PASS pytest -q tests/carve_manifest → 53 passed (as claimed). pytest -q tests/manifest_digests tests/openspec_cli_pin tests/openreposhape_pin → 177 passed at HEAD and 177 at base 56e69a11, identical. Driver runs the script as a subprocess ([sys.executable, SCRIPT, "--repo", …], check=False) and loads it by path once for constants only. All nine REFUSAL_CODES asserted by name (refuses() asserts f": {code} —" and "Remediation:"); per-code test counts 2–18. The real-repo branch test exists and is a branch, never a skip. pytest.ini declares no testpaths (and no pyproject/setup.cfg pytest section exists), the required job runs python3 -m pytest tests/ -q -m "not postgres" (pytest-suite.yml:462) → collected; nothing skips, so EXPECT_SKIPPED: "21" is unmoved and MIN_SELECTED/MIN_PASSED are floors 53 passes only raise.
7 Code quality PASS w/ notes 810 lines read end to end. Closed nine-code REFUSAL_CODES; stdlib + PyYAML only; every one of the 17 top-level defs return-annotated; argparse conventions match validate-openreposhape-pin.py line for line. No dead code. Module docstring records OQ-E (docs/ convention break "honoured, not corrected"), RULED OQ-C and RULING OQ-1 with the #656 comment id. Notes N4/N7/N8 below.
8 Hygiene PASS w/ one open finding Body first line is the required lane line; no closing keyword; closingIssuesReferences totalCount 0; autoMergeRequest null; five reviews, all COMMENTED, no approval. Both commits carry Lane: openxfactory-4-opendox-extraction + Co-Authored-By: Claude Fable 5.1 + Claude-Session: …session_0139swz8Tq3FjNveDRR2SNPv (the previous window's guidance — expected). Both Copilot threads resolved, replies accurate, both fixes real (judged below). But the SECOND Copilot review, submitted 12:23:07Z after 122ec3fe, raises a THIRD finding that is unaddressed and has no thread — see S6.
9 doc-health parity PASS doc-health.py --single-repo . at HEAD and at base: 92 findings each, and the two finding sets are identical after normalising the repo= token (diff empty). 10 critical / 9 error / 57 warning / 16 info at both; "New regressions vs previous report: 0". Matches the body's claim.

CI at head: all 9 required checks pass, including pytest-suite (25m02s) and lane-line.

Check-by-check (item 2)

memo § 1.3 implemented code order
1 shape yes, incl. the edits[] entry grammar moved forward from check 6 (declared as a decision, and correct: check 5 must read edits[].class) carve-shape-invalid 1st
2 revision yes; HEAD or --at, must resolve to carve_commit carve-revision-mismatch 2nd
3 digest yes; raw blob re-hashed and git_mode compared against ls-tree carve-digest-mismatch / carve-path-absent 3rd
4 surface completeness yes; segment-aware prefix match, exactly-one-row carve-file-undeclared / carve-file-duplicated 4th
5 closed vocabularies yes carve-vocabulary-unknown — memo names the check, not a code; the invention is warranted ("you used a word outside the closed list" is a different act from "the document is malformed") 5th
6 disposition consistency yes; the memo's two cases plus not_moved with edits (a defensible addition, same code) carve-disposition-inconsistent 6th
row order an addition beyond the memo's six — § 1.3 lists no ordering check; the const path_order: bytewise_utf8 is § 1.2's carve-path-order-violation — warranted: a const nothing enforces is a comment, and the remedy ("re-sort") is not the remedy for an inconsistent disposition last, inside check 6
— carve-unreadable, deliberately OUTSIDE REFUSAL_CODES see S5: defensible for the environment cases, wrong for the malformed-YAML case —

Nothing the memo names is missing. edit_classes: asserted equal to the ruled three (not merely read) is the right reading of "the ruling's own, verbatim"; not_moved_reasons: declared-AND-subset-of-five matches RULED OQ-C; MANIFEST_RELPATH is OQ-E verbatim.

Attacks (own fixtures: 4 throwaway repos, 7 blobs / 4 dirs / 2 commits / one 100755 / one 120000 symlink / one pkg_old/ sibling / two non-UTF-8 filenames)

attack exit code right?
a correct manifest (--at, and HEAD==carve_commit with no --at, and --json) 0 — ✅
b carve_commit UPPERCASE hex / 39 chars / tag name / branch name 2 carve-shape-invalid ×4 ✅
c HEAD ≠ carve_commit, no --at 2 carve-revision-mismatch ✅
c --at <carve_commit> 0 — ✅
c --at <other commit> / --at <unresolvable> 2 carve-revision-mismatch ×2 ✅
d git_mode 100755→100644 on a real 0755 blob; 100644→100755 2 carve-digest-mismatch (MODE DRIFT) ×2 ✅ mode is compared, both directions
e row for a path added in commit 2, carve_commit = commit 1 (two constructions) 2 carve-path-absent ×2 ✅
f a surface file in no row 2 carve-file-undeclared ✅
f one path in two rows 2 carve-file-duplicated ✅
f row whose source_path is outside every moved_paths: prefix 2 carve-shape-invalid ✅ it refuses (see N-code remark)
f pkg_old/z.py beside prefix pkg 0 — ✅ not swallowed
g moved_verbatim + edits; moved_with_declared_edit with edits: []; with no edits key; not_moved + edits 2 carve-disposition-inconsistent ×4 ✅
g edits[].lines: [] / lines: ["1"] 2 carve-shape-invalid ×2 ✅
h a 4th edit class / the three reordered / only two 2 carve-shape-invalid ×3 ✅
h class: import-rewrites (hyphen) 2 carve-vocabulary-unknown ✅
i destination: opendox_kode 2 carve-vocabulary-unknown ✅
i reason: replicated_at_destinaton (typo, and declared) 2 carve-shape-invalid ✅
i a 6th not_moved_reasons: entry 2 carve-shape-invalid ✅
i a KNOWN reason the file does not declare 2 carve-vocabulary-unknown ✅ (declared-AND-known both bite)
i a 4th disposition 2 carve-vocabulary-unknown ✅
i not_moved row carrying sha256 2 carve-shape-invalid ✅
i not_moved row carrying destination + destination_path 0 — ❌ S2
j pkg/b.py before pkg/a.py 2 carve-path-order-violation ✅
j non-ASCII paths (U+FF01 vs U+E000) misordered 2 carve-path-order-violation ✅
j the byte-vs-codepoint divergence: real filenames pkg/\xff.py and pkg/\xee\x80\x80.py (surrogateescape → U+DCFF, U+E000, whose CODEPOINT order is the REVERSE of their BYTE order), expressed in the YAML via \udcff escapes 2 carve-path-order-violation ✅ the const's distinguishing claim is enforced — a codepoint sort would have accepted this file. Byte-ordered variant → exit 0. No shipped test covers this — see S7.
k top-level YAML list / empty file / a bare scalar 2 carve-shape-invalid ×3 ✅
k non-UTF-8 bytes / unclosed YAML 2 carve-unreadable ×2, no traceback ✅ exit 2 (code classification → S5)
l schema_version: 2 / wrong kind / digest_source: working_tree / path_order: flipped / unquoted git_mode / empty moved_paths / empty destinations / unknown ROW key / destinations entry missing leg / carve_tag with a space / blank carve_tag / whitespace-only evidence 2 carve-shape-invalid ×12 ✅
l schema_version: true / schema_version: 1.0 0 — ❌ S3 (True == 1, 1.0 == 1)
m default path absent 0 NO MANIFEST … (nothing to validate) ✅ intended
m --manifest <path that does not exist>, plain and --json 0 no-manifest ❌ S1
n --json on a refusal 2 valid JSON, result/code/detail/manifest ✅ exit code unchanged
n --json on a pass 0 valid JSON, 9 keys ✅
env --repo <missing dir> / --repo <plain dir> 2 carve-unreadable ×2 ✅
extra not_moved row for a path absent at carve_commit 2 carve-path-absent ✅
extra symlink row (git_mode: '120000') 0 — ✅
extra digest recorded from the WRONG revision 2 carve-digest-mismatch ✅
extra working-tree modification with HEAD == carve_commit 0 — ✅ the tree, not the checkout
extra duplicate YAML key rows: (PyYAML last-wins) 2 carve-digest-mismatch ⚠️ refuses, but downstream — N9
extra edits[].lines: [999999] on a 3-line file 0 — ❌ N1
extra two rows sharing one destination+destination_path 0 — ❌ N2
extra destination_path: ../../etc/passwd 0 — ❌ N3
extra a moved_paths: prefix matching no blob at all 0 — ❌ S4
extra surface shrunk to one named file 0 — ⚠️ by design (moved_paths is the surface)
extra unknown TOP-LEVEL key 0 — ⚠️ by design (permits header:) — N4
extra trailing-slash prefixes (pkg/, lib/) 0 — ✅

Defects

No BLOCKING defect. Every guarantee the four-part floor's part 1 exists to give — a file in no row refuses, a drifted digest refuses, a flipped mode refuses, an edit in no class refuses, a moved tree refuses — held under all 81 attacks.

S1 — SHOULD-FIX. An explicitly named missing --manifest exits 0. main()'s seat-holding pass keys off manifest_path.is_file() and never asks whether the caller named the path. The pass is right for the default and wrong for a named one: the memo's own "one-shot step in the carve PR" (§ 1.3), or any later job that typos --manifest docs/carve-manifest.yaml, goes green forever — the single not-fail-closed branch in the file becomes the branch a typo selects. Repro: python3 scripts/validate-carve-manifest.py --manifest /tmp/nope.yaml --repo <any repo> → NO MANIFEST, exit 0. Fix: if args.manifest is None and not manifest_path.is_file(): …return 0, and refuse a named absent file as carve-unreadable.

S2 — SHOULD-FIX. A not_moved row may carry destination and destination_path. _check_row_shape() forbids sha256/git_mode on a not_moved row, on the stated reason that "a digest … is the claim that these bytes arrive somewhere, and nothing arrives" — which condemns a destination just as squarely. The memo's § 1.2 not_moved row is source_path + disposition + reason + evidence and nothing else, and the body calls the row grammar closed. Today such a row passes and its destination is even validated against destinations:, so it reads at the destination as "this file goes there" while its disposition says it does not. Repro: clean manifest, add destination: opendox_code + destination_path: lib/d.py to the not_moved row → exit 0. Fix: add both keys to that row's forbidden set.

S3 — SHOULD-FIX. schema_version is type-blind. doc.get("schema_version") != SCHEMA_VERSION accepts true and 1.0 (Python True == 1, 1.0 == 1). Harmless to the carve, but the first assertion of a fail-closed chain should not admit a bool. Fix: if not isinstance(v, int) or isinstance(v, bool) or v != SCHEMA_VERSION — the same guard _check_edits_shape already applies to line numbers, correctly.

S4 — SHOULD-FIX. A moved_paths: entry that matches nothing at the carve commit passes silently, and no test covers it. The completeness check is only as good as the prefix list, and a mistyped prefix (scripts/ideation_dashbord) contributes an empty surface while looking like coverage in review. The tree is already in hand (tree_at() runs before check_surface), so refusing a vacuous prefix is free. (Fairness: a typo'd prefix whose rows are still present does refuse, as carve-shape-invalid per row; the silent case is the typo and its rows dropped together — which is exactly the hand-editing error a ~430-row manifest invites.) Repro: append nowhere/at/all to moved_paths: on a clean manifest → exit 0.

S5 — SHOULD-FIX. carve-unreadable's stated rationale does not cover the case it is most often raised for. The tuple comment says the excluded code "describes an environment in which no finding can be reached at all". Four of its five raise sites are environments; the fifth is read_manifest's yaml.YAMLError / UnicodeDecodeError branch, and an unparseable manifest is not an environment — it is a document defect a reviewer acts on. The result is that two adjacent document defects get codes from two different vocabularies: an EMPTY manifest (parses to None) is carve-shape-invalid, a manifest with one unclosed bracket is carve-unreadable, a code the body's own nine-code table says does not exist. Both exit 2, so nothing is unsafe — but a caller branching on the code, which the comment says is the reason the vocabulary is closed, meets an undocumented value. Fix: route the manifest-parse failures to carve-shape-invalid, or admit carve-unreadable to the tuple and state the environment/document split there.

S6 — SHOULD-FIX (and it is an OPEN review finding at this head, not mine). Copilot's second review (2026-09-09T12:23:07Z, after 122ec3fe) raises a third finding with no thread to resolve, so it is easy to miss: Scratch.blobs() claims it reads the tree "the way the validator reads it" but calls git ls-tree without -z, decodes with text=True and splits on lines, and filters with a bare path.startswith(SURFACE) where the validator uses -z, surrogateescape and segment-aware in_surface(). The finding is correct. Impact today is nil — the fixture's paths are ASCII and SURFACE carries a trailing slash, so the two agree — but the docstring is false, and a fixture path with a space or a quote would be git-quoted and silently mis-parsed. My repo-4 fixture shows the divergence is not hypothetical: -z + surrogateescape is exactly what it takes to see those two filenames at all.

S7 — SHOULD-FIX. The Copilot round's second test does not test what it names. test_the_path_order_key_survives_a_path_utf8_cannot_hold calls MODULE.check_disposition_consistency() in process (the only test that bypasses the subprocess the suite otherwise uses), asserts nothing, and its two paths — scripts/pkg/alpha.py and scripts/pkg/\udcffzeta.py — are in the same order bytewise and by code point. So it pins "the encode does not raise", not the ordering semantics. Combined with test_rows_out_of_bytewise_order_refuse using reversed() over ASCII paths, no test in the suite distinguishes bytewise_utf8 from a code-point sort. The other Copilot fix is genuinely pinned (test_a_manifest_that_is_not_utf8_refuses_rather_than_crashing writes real non-UTF-8 bytes, runs the subprocess, asserts exit 2 + carve-unreadable + no traceback — I reproduced it independently). Fix: replace the doc with a divergent pair; the construction is in this report's row j and the validator already passes it.

NOTES (no action asked, recorded so the next reader does not re-derive them)

  • N1 edits[].lines are never bounded against the blob, which check_digests has already read: lines: [999999] on a 3-line file passes. The memo carries line numbers because they make the claim "falsifiable at the destination" — a line past EOF at the carve commit is falsifiable here, for nothing.
  • N2 Nothing checks destination+destination_path uniqueness, so two source files may claim one destination path; the surface check guarantees completeness on the source side only.
  • N3 destination_path is wholly unvalidated: ../../etc/passwd passes.
  • N4 The top-level grammar is OPEN (only rows and edits are closed) — which is what permits the header: prose the body describes, and also means a stray or mistyped top-level key is silently ignored. The precedent the consts are borrowed from (release-digest-inventory.schema.yaml) is additionalProperties: false.
  • N5 Digest field shape: this manifest is sha256: <raw 64 hex>; the release-digest inventory whose three consts it cites by file:line is digest: sha256:<hex>. The validator faithfully implements the memo's § 1.2 example, so the divergence originates upstream of this PR — but SHA256_RE would reject the precedent's prefixed form, so the two documents' digest fields are not interchangeable and a reader of one does not already know how to write the other.
  • N6 destinations.<key>.leg is a free non-empty string; the memo's example uses code | spec | assembly. leg: kode passes.
  • N7 --help does not name the six checks (they live in the module docstring), and formatter_class=RawDescriptionHelpFormatter is inert with a one-paragraph description and no epilog. validate-openreposhape-pin.py does exactly the same, so this matches the precedent rather than deviating from it.
  • N8 REFUSAL_CODES is referenced nowhere in the script — the closure is asserted only by the test's literal, and nothing stops a future check raising a code outside the tuple. carve-unreadable already does (deliberately). One assert code in REFUSAL_CODES + ("carve-unreadable",) in CarveRefusal.__init__ would make the closure real rather than documentary.
  • N9 PyYAML accepts duplicate keys silently (last wins); a manifest with two rows: keys is read as the last. Contained today — the surface/digest checks refuse it for a downstream reason.
  • N10 The shipped fixture has no 100755 blob, so the tree side of the mode comparison is only ever exercised against 100644. I tested both directions against a real 0755 file and both refuse.
  • N11 The body's file table says 802/783 lines; the files at this head are 810/787 (the Copilot round). Body prose otherwise matches what I measured, including 53 / 177 / 92-and-92 / proposal support verification ok (all re-run and confirmed).
  • N12 test_the_real_repository_answers_at_the_ruled_path passes cwd=REPO_ROOT, but --repo defaults to Path(__file__).resolve().parents[1], so the cwd is decorative.
  • N13 The memo's optional "one-shot step in the carve PR the way openreposhape-pin-gate.yml:93 does" is not present. The memo itself says the pytest seat alone satisfies § 8.2, so this is owed at the carve, not here.
  • N14 Two stale worktrees from a previous, dead verifier (wt-verify-839, wt-verify-839-base, under another session's scratchpad) are still registered in the shared checkout. Not mine; left untouched. I worked in wt839/wt839-base under my own scratchpad and removed them.

Shared checkout

/home/brett/projects/xFactory/openxFactory — start: rev-parse --short HEAD = 6612d323, diff --cached --name-only | wc -l = 0. End: 6612d323, 0. Unchanged; only fetch / worktree prune / worktree add --detach / worktree remove --force (mine) were run against it. Fixtures were four throwaway git init repos under my scratchpad, never inside a worktree. No merge, approve, push, auto-merge, ruleset, workflow-dispatch or thread act; this is my one and only comment.

…ses, strict row and top-level grammar, integer schema_version, dead or leaky surface prefixes refuse, YAML errors are shape defects, a real bytewise-order test

The independent verification of `122ec3fe` was PASS WITH NOTES over 81
adversarial runs: no attack got a wrong digest, a wrong mode, a missing file, a
duplicated row, an unknown vocabulary word or a misordered file past the
validator. The nine wrong outcomes were all permissiveness at the edges of the
row grammar. All seven should-fixes are taken, with three of the recorded notes,
and each one is pinned by a test that FAILS against `122ec3fe` and passes here
(14 of the new cases fail against the old script; the two fixture-side ones fail
against the old `Scratch.blobs()`).

S1 — a `--manifest` the caller NAMED and that does not exist exited 0. The
seat-holding pass now keys off `args.manifest is None`, so it covers the DEFAULT
path only; a named absent path refuses `carve-unreadable`, exit 2, and `--json`
says `refused` rather than `no-manifest`. The one branch in this file that is
not fail-closed must not be the branch a typo selects.

S2 — the row grammar is now stated PER DISPOSITION in one place
(`ROW_KEYS_BY_DISPOSITION`), so a `not_moved` row carrying `destination` or
`destination_path` refuses as its `sha256`/`git_mode` already did: the memo's
§ 1.2 `not_moved` row is `source_path + disposition + reason + evidence`, and
such a row used to pass with its destination validated against `destinations:`
on the way — arriving as "this file goes there" over a disposition saying it does
not. `edits` stays legal on every disposition BY DESIGN, because whether an edit
list agrees with the disposition is check 6's question and
`carve-disposition-inconsistent` is the more precise finding. The TOP level is
closed too (`TOP_LEVEL_KEYS`, `header:` optional), so a mistyped `moved_path:`
refuses instead of being ignored in silence.

S3 — `schema_version` must be the INTEGER 1: `true` and `1.0` are both equal to
1 in Python and used to verify a whole manifest.

S4 — a `moved_paths:` prefix matching NO file at the carve commit refuses, with
its own code `carve-surface-vacuous`. A new code rather than
`carve-shape-invalid` because the document is well formed: the finding is a claim
about the TREE, which is why check 1 cannot make it, and the remedy is to
re-derive the prefix rather than to fix a grammar. (A row whose `source_path` is
outside every prefix already refused; the shipped test for it stands.)

S5 — an unparseable manifest is a DOCUMENT defect: `carve-shape-invalid` with
the parser's own line and column. `carve-unreadable` now means the environment
and the encoding only — and it is IN `REFUSAL_CODES`, because a closed
vocabulary whose purpose is that callers branch on the code may not have a value
outside itself. `test_every_code_the_validator_can_emit_is_in_the_vocabulary`
scans this file's own raise sites, so the tuple cannot drift in either
direction — the closure is asserted rather than documentary.

S6 — Copilot's second review (12:23:07Z, no thread) was right:
`Scratch.blobs()` claimed to read the tree "the way the validator reads it" and
used neither `-z` nor `surrogateescape` nor a segment-aware prefix test. Without
`-z` git QUOTES a path it cannot print, so the helper silently DROPPED exactly
the filenames S7 needs. Fixed rather than re-documented, and duplicated rather
than importing `in_surface`, so the fixture cannot agree with a broken
`in_surface`.

S7 — `test_the_path_order_key_survives_a_path_utf8_cannot_hold` asserted nothing,
ran in process, and used two paths that agree under both orders. Replaced by a
subprocess test over two REAL files whose bytewise order is the REVERSE of their
code-point order (`\xff` decodes to U+DCFF = 56575; `\xee\x80\x80` is U+E000 =
57344): the bytewise order passes, the code-point order — which a `sorted()`
implementation would have accepted — refuses `carve-path-order-violation`. The
test asserts the fixture is actually divergent, so it cannot go vacuous again.

Notes taken: `edits[].lines` are bounded by the line count of the blob the digest
check has already read (a line past EOF is not the falsifiable claim the numbers
are recorded for); two moved rows arriving at one `(destination,
destination_path)` refuse `carve-file-duplicated`, since completeness was
guaranteed on the source side only; and the module docstring records in one
sentence that this manifest's `sha256: "<hex>"` diverges from the precedent's
`digest: sha256:<hex>` because the memo's § 1.2 example does.

Not taken: N3 (`destination_path` unvalidated), N6 (`leg` free-form), N7, N9
(PyYAML duplicate keys), N10, N12 — none is a hole in the floor and each needs a
shape decision that is the memo's to make.

73 tests pass in tests/carve_manifest (was 53); manifest-digests,
openspec-cli-pin and openreposhape-pin unchanged at 177; the documented
invocation at the repository root still prints the NO MANIFEST line and exits 0.

Refs #656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 9, 2026 13:34
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)

Verifier round 1 applied — 2bf3764c7f3ea291f152fab3035fd709ded70e8c. All seven should-fixes from the independent verification of 122ec3fe, plus three of the recorded notes. Body updated (refusal-code table, test count, a "Verifier round 1" section). Two files, no other surface.

Every item is pinned by a test that FAILS against 122ec3fe and passes here — proved by running the new suite against git show HEAD:scripts/validate-carve-manifest.py (14 failures: S1 ×2, S2 ×3, S3 ×2, S4, S5 ×3, N1, N2, N5) and, for the two fixture-side items, against the pre-fix Scratch.blobs() (2 failures: S6, S7).

  • S1 — the seat-holding pass now keys off args.manifest is None, so it covers the DEFAULT path only; a named absent --manifest refuses carve-unreadable, exit 2, and --json says refused rather than no-manifest. The one branch here that is not fail-closed must not be the branch a typo selects.
  • S2 — the row grammar is stated PER DISPOSITION in one place (ROW_KEYS_BY_DISPOSITION), so not_moved + destination/destination_path refuses as its sha256/git_mode already did; the TOP level is closed too (TOP_LEVEL_KEYS, header: optional). edits stays legal on every disposition by design: check 6 owns the contradiction, and carve-disposition-inconsistent is the more precise finding for a row whose keys are all real ones.
  • S3 — schema_version must be the integer 1; true and 1.0 no longer verify a manifest.
  • S4 — a dead moved_paths: prefix refuses, with its own code carve-surface-vacuous (raised in check 4: the finding is a claim about the tree, which is why check 1 cannot make it, and the remedy is to re-derive the prefix rather than fix a grammar). The leaky direction already refused; that test stands.
  • S5 — a YAML parse error is now carve-shape-invalid with the parser's line and column; carve-unreadable means the environment and the encoding only, and it is IN REFUSAL_CODES. test_every_code_the_validator_can_emit_is_in_the_vocabulary scans the script's own CarveRefusal(...) sites, so the closure is asserted rather than documentary, in both directions (N8 answered this way rather than with an assert inside an exception constructor, which could itself end a run at exit 1).
  • S6 — @copilot, your second review is right and is fixed rather than re-documented, in 2bf3764c: Scratch.blobs() now reads git ls-tree -r -z --full-tree, decodes with surrogateescape, and matches the prefix segment-aware. Your review had no thread to reply on (the finding came through as a suppressed comment), so this sentence is the record. The impact was not nil, which is worth stating: without -z git quotes a path it cannot print, so the helper silently DROPPED the two non-UTF-8 filenames the new ordering test needs — the fixture could not generate a row for a file it could not see. The reading is duplicated rather than importing the validator's in_surface, so a fixture cannot agree with a broken in_surface. Pinned by test_the_fixture_reads_the_tree_the_way_the_validator_does.
  • S7 — the assertion-free in-process test is gone. Its replacement runs the subprocess over two REAL files whose bytewise order is the reverse of their code-point order (\xff decodes to U+DCFF = 56575; \xee\x80\x80 is U+E000 = 57344): the bytewise order passes, the code-point order refuses carve-path-order-violation. It asserts the fixture is actually divergent, so it cannot go vacuous again.
  • Notes taken — N1 (edits[].lines bounded by the blob's line count, with an inclusive-bound test), N2 (two rows arriving at one (destination, destination_path) refuse carve-file-duplicated), N5 (the module docstring records the sha256: vs digest: sha256: divergence and that it originates in the memo).
  • Not taken — N3, N6, N7, N9, N10, N12, N13, N14: none is a hole in the floor, and each needs a shape decision that is the memo's to make (details in the body).

73 passed in tests/carve_manifest (was 53); manifest_digests + openspec_cli_pin + openreposhape_pin unchanged at 177 passed; python3 scripts/validate-carve-manifest.py at the repository root still prints the NO MANIFEST line and exits 0. Nothing merged, approved, auto-merged or resolved; no thread touched.

Copilot AI 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.

🟡 Changes recommended

There are a couple of concrete input/contract gaps in the validator (notably --manifest path resolution vs --repo, and “closed map” enforcement for destinations.*) that should be fixed before relying on it as a gate.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread scripts/validate-carve-manifest.py Resolved
Comment thread scripts/validate-carve-manifest.py Resolved
…eg} map; a relative --manifest resolves against --repo

Two factual findings, both accepted.

(1) `destinations.<key>` entries silently accepted extra keys despite the
module docstring's "closed maps" claim. An entry is now closed to exactly
`repository` (must match `owner/name`) and `leg` (one of the RULED
`openRepoShape` legs — `code`, `spec`, `assembly`, declared as `LEGS`); an
unknown or missing field refuses `carve-shape-invalid` naming the destination
key and the offending field. Pinned by
`test_a_destination_entry_with_an_unknown_key_refuses`.

(2) A relative `--manifest` resolved against the caller's CWD rather than
`--repo`, so `--repo <other-tree> --manifest docs/....yaml` pointed at the
wrong file unless CWD happened to be the repo, despite the help text's
"default: <repo>/...". A relative `--manifest` now resolves against `--repo`
(an absolute one is untouched), and the result is always `.resolve()`d so
every message — `NO MANIFEST`, `OK`, a refusal's render, `--json` — prints
the absolute path actually read. Pinned by
`test_a_relative_manifest_resolves_against_repo_not_cwd`.

Both regression tests proven to fail against the pre-fix script
(`git show HEAD:scripts/validate-carve-manifest.py`) and pass against the
fix. 75 tests pass in tests/carve_manifest (was 73); tests/manifest_digests,
tests/openspec_cli_pin and tests/openreposhape_pin unchanged at 177 passing.
`python3 scripts/validate-carve-manifest.py` at the repo root still prints
`NO MANIFEST ... (nothing to validate)`, exit 0.

Refs #656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 9, 2026 13:59
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-4-opendox-extraction

Copilot round 3 taken: d97371d1. destinations.<key> entries are now a closed {repository, leg} map (repository must match owner/name, leg ∈ {code, spec, assembly}); a relative --manifest now resolves against --repo rather than the caller's CWD, and the resolved absolute path is what every message prints. Both pinned by regression tests proven to fail against the pre-fix script and pass against the fix. tests/carve_manifest now passes 75 (was 73); tests/manifest_digests, tests/openspec_cli_pin, tests/openreposhape_pin unchanged. Both threads replied on and resolved.

Copilot AI 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.

🔵 Needs a closer look

A refusal message can still become unprintable for non-UTF-8 git paths (surrogateescape) and potentially violate the “no exit 1” contract unless the rendered output is sanitized.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

scripts/validate-carve-manifest.py:280

  • tree_at() decodes git ls-tree -z paths using surrogateescape, so any refusal detail that interpolates a path from the tree can contain surrogate code points (e.g., filenames with raw bytes like 0xff). Printing such a refusal via render() can raise UnicodeEncodeError on UTF-8 stdio with strict error handling, breaking the documented “no exit 1” contract. Consider sanitizing the rendered human message so it is always printable (e.g., escaping non-encodable code points).
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)
RE-VERIFICATION of head d97371d1d2deefe0eee61e17a72b1d8b1df2c798 — PASS WITH NOTES

VERDICT: PASS WITH NOTES at head d97371d1d2deefe0eee61e17a72b1d8b1df2c798 (pinned via headRefOid; unmoved through the run). I am the SECOND independent verifier, did not author this, and built my own fixtures (ten throwaway git repos plus an empty one, a non-git dir and two submodule sources: 8+ blobs / 4 dirs / 2–4 commits / a real 100755 / a 120000 symlink / a src/mod_old/ sibling / a gitlink / two non-UTF-8 filenames / an empty blob / a no-trailing-newline blob / a CRLF blob) rather than reusing the author's or the first verifier's. 134 adversarial runs: 130 RIGHT, 4 WRONG (2 distinct issues), 0 BLOCKING. Two further runs came back "wrong" and were MY errors, not the validator's — one a regex in my own harness, one a 37-row fixture in which 30 files named f.py all arrived at src/dox/f.py, which the validator was right to refuse.

All eleven items the two fix rounds claim to close are closed, each proved by its own attack — and every one of them fails against the pre-fix behaviour the first verifier reported. One NEW defect (SHOULD-FIX) that the round-1 fix left reachable, one declared not-taken item re-measured, and one OPEN Copilot finding on this head which I judge NOT to be a defect, with the mechanism named.

Items

# item verdict evidence
1 Scope PASS git diff --stat 56e69a11...HEAD = exactly two files, 1042 + 1107 = 2149 insertions, 0 deletions, 0 existing files touched. Nothing under openspec/, contracts/, .github/; docs/opendox-carve-manifest.yaml absent at HEAD. merge-base HEAD origin/main = 56e69a11, exactly the base the body declares; --is-ancestor true; 0 merges in the range. (main is 22 commits ahead — see N-a.)
2 Spec conformance PASS All six memo § 1.3 checks present, and validate() runs them in the memo's order. I proved the order rather than reading it — five ordering attacks, each a document with TWO defects, each answering with the earlier check's code: shape→revision, revision→digest, digest→surface, surface(vacuous)→vocabularies, vocabularies→order-violation. Detail below.
3 Adversarial PASS w/ notes 134 runs over 10 fixture repos. Tables below.
4 Exit codes PASS grep gives five sites only: sys.exit(2) (PyYAML guard), return 0 ×2, return 2 ×1, sys.exit(main()). Only 0 and 2 are reachable and no run of the 134 produced a traceback, including a missing --repo, a non-git --repo, a repo with no commits, a --manifest naming a directory, a --manifest at mode 000, and non-UTF-8 manifest bytes (all exit 2 carve-unreadable). An unknown flag exits 2 via argparse, so the two-valued contract holds for bad flags too.
5 Digest semantics PASS hashlib.sha256(git cat-file blob <carve_commit>:<path>). The tree and not the checkout is the referent, re-proved independently: with HEAD == carve_commit I overwrote a moved file in the working tree and the verdict stayed OK/exit 0. git_mode is compared against ls-tree in both directions against a real 0755 blob (100755→100644 and 100644→100755 both refuse carve-digest-mismatch / MODE DRIFT), and a 120000 symlink's mode flip refuses too. Field shape chosen = sha256: <64 lowercase hex> (SHA256_RE = ^[0-9a-f]{64}$). I checked the cited precedent rather than taking it on trust: the three CONSTS really are borrowed verbatim (release-digest-inventory.schema.yaml:19-22,41-42 — digest_algorithm: sha256, digest_source: raw_git_blob, path_order: bytewise_utf8) and the quoted git_mode: '100644' convention matches too, but the DIGEST FIELD diverges: the schema's $defs/sha256_digest is pattern: "^sha256:[0-9a-f]{64}$" on a field named digest, as the real files show (contract-v1.11.digests.yaml: digest: sha256:41697f1d…). So SHA256_RE would reject the precedent's form and the two documents' digest fields are NOT interchangeable. The divergence originates in memo § 1.2, whose row example this implements, and the module docstring now records exactly that (N5 taken) — the right disposition for a shape that is the memo's to change.
6 Tests PASS pytest -q tests/carve_manifest → 75 passed in 15.7s. pytest -q tests/manifest_digests tests/openspec_cli_pin tests/openreposhape_pin → 177 passed at HEAD and 177 at 56e69a11, identical. Driver runs the script as a subprocess throughout; the module is loaded by path for constants only. All eleven REFUSAL_CODES asserted by name, each in ≥2 places (23/5/6/3/2/3/2/5/5/3/3 literal occurrences). The real-repo test is a BRANCH, never a skip. pytest.ini declares no testpaths (it is the option-free rootdir anchor); the required job runs python3 -m pytest tests/ -q -m "not postgres" (pytest-suite.yml:462), so the directory is collected; MIN_SELECTED/MIN_PASSED are floors 75 passes only raise and nothing here skips.
7 Code quality PASS w/ notes 1042 lines read end to end. Closed eleven-code REFUSAL_CODES with carve-unreadable now IN it. stdlib + PyYAML only. All 20 defs return-annotated (one test helper, _load, is not — cosmetic). argparse matches validate-openreposhape-pin.py line for line (prog=, description=, RawDescriptionHelpFormatter). Compiles clean; no dead code found. Docstring records RULED OQ-E, RULING OQ-1 and RULED OQ-C (10 hits). Notes N-b…N-f below.
8 Hygiene PASS w/ one open review finding Body first line is the required lane line; **Refs #656**, no closing keyword anywhere; closingIssuesReferences = []; autoMergeRequest null; nine reviews, all COMMENTED, no approval; all four Copilot review threads resolved with accurate replies. Trailers: d97371d1 and 2bf3764c carry the two-line form (Lane: + Co-Authored-By: Claude Fable 5.1), 122ec3fe and c212f2f5 additionally carry Claude-Session: — both forms expected. But a FIFTH Copilot review landed at 14:03:37Z ON THIS HEAD with a suppressed comment and no thread — see O1; this is the third time a Copilot finding has arrived thread-less on this PR.
9 doc-health parity PASS doc-health.py --single-repo . at HEAD and at the true merge-base 56e69a11: 92 findings each (10 critical / 9 error / 57 warning / 16 info), and the normalised outputs diff to zero bytes. "New regressions vs previous report: 0" at both. Confirms the body's claim exactly.

Check-by-check, and the invented codes judged (item 2)

I read the sources rather than the author's summary of them. Memo § 1.3 declares "Five ordered checks" plus "a sixth check belongs here and § 3.1's text does not have it", and exit 0/2 — so six is right and the two-valued exit is the memo's. The memo names a code for checks 1-4 only (carve-shape-invalid; carve-revision-mismatch; carve-digest-mismatch + carve-path-absent; carve-file-undeclared + carve-file-duplicated) and for the sixth (carve-disposition-inconsistent); it names check 5 without a code, and names no ordering check and no prefix-liveness check at all — which is exactly the boundary between the codes the memo owns and the three the validator invents. design.md § D6 carries the vocabularies verbatim: moved_verbatim / moved_with_declared_edit / not_moved (:527-528) and "import rewrites, path constants, adapter calls. Three classes, not four" (:530), matching RULING OQ-1's own line (:36). The five not_moved reasons are the memo's lines 41-45, character for character. tasks.md:757 carries docs/opendox-carve-manifest.yaml. All three tuples and MANIFEST_RELPATH match. The memo's own § 1.1 cites the precedent as digest: sha256:… while its § 1.2 row example writes sha256: raw — so the digest-field divergence demonstrably originates upstream of this PR, as the docstring claims.

memo § 1.3 code order proved judgment
1 shape carve-shape-invalid 1st Now also closes the TOP level (TOP_LEVEL_KEYS, header: optional) and the row grammar PER DISPOSITION (ROW_KEYS_BY_DISPOSITION) and a destination ENTRY (DESTINATION_KEYS).
2 revision carve-revision-mismatch 2nd —
3 digest carve-digest-mismatch / carve-path-absent 3rd edits[].lines upper bound now applied here (N1 taken) under check 1's code; the author's reason — same predicate, same reader action — is sound.
4 surface carve-file-undeclared / carve-file-duplicated / carve-surface-vacuous 4th See A1: the destination half of carve-file-duplicated is keyed on the wrong tuple.
5 vocabularies carve-vocabulary-unknown 5th Warranted. "You used a word outside the closed list" has a different remedy from "the document is malformed".
6 consistency + order carve-disposition-inconsistent, then carve-path-order-violation 6th The memo names two cases; the validator adds not_moved+edits under the same code — a defensible addition. carve-path-order-violation warranted — a const nothing enforces is a comment, and "re-sort" is not the remedy for an inconsistent disposition.
— carve-surface-vacuous (new in round 1) in check 4 Warranted. It is a claim about the TREE, which check 1 cannot make, and it is the OPPOSITE direction from carve-file-undeclared (dead prefix vs unlisted file). The tree-vs-document line it is drawn on is the same line the carve-unreadable correction was drawn on, so the vocabulary is now internally consistent.
— carve-unreadable environment + encoding only The S5 correction is right. A malformed manifest is now carve-shape-invalid with the parser's line and column; carve-unreadable is in the tuple, so no caller branching on the code meets a value the vocabulary denies.

The author's two "not taken" calls, judged.

  • edits legal on every disposition — sound. ROW_KEYS_BY_DISPOSITION lists edits in all three sets, so the grammar is honest about it, and check 6 answers carve-disposition-inconsistent for all three contradictions (moved_verbatim+edits, moved_with_declared_edit+[], not_moved+edits) — a more precise finding than "unknown key", exactly as claimed. One wrinkle, N-b.
  • N8 answered by a source-scanning test rather than an assert in CarveRefusal.__init__ — sound, and the reason given (an assert inside an exception constructor could itself end a run at exit 1) is correct. I verified the scan really scans: the file holds 64 CarveRefusal( occurrences, of which 1 is a comment and 1 the class statement, leaving 62 raise sites — and the regex matches all 62, across 11 distinct codes, asserted bidirectionally (sorted(REFUSAL_CODES) == raised). Limit in N-c.

Attacks (134 runs; one per item the fix rounds claim, plus the brief's full list, plus my own)

attack exit code right?
a correct manifest — plain, --json, --at head 0 — ✅
S1 --manifest <missing> plain / --json 2 carve-unreadable / refused+code in JSON ✅ closed
m DEFAULT path absent → seat pass 0 NO MANIFEST … (nothing to validate) ✅ intended
R2 relative --manifest from a foreign CWD resolves against --repo, prints the ABSOLUTE path 0 — ✅ closed
R2 relative --manifest present only in CWD → not found 2 carve-unreadable ✅
S3 schema_version 2 / true / 1.0 / "1" / null 2 carve-shape-invalid ×5 ✅ closed (true and 1.0 both refuse now)
S2 not_moved + destination+destination_path / + sha256 2 carve-shape-invalid ×2 ✅ closed
S2 unknown TOP-LEVEL key (a mistyped moved_path:) 2 carve-shape-invalid ✅ closed
S2 header: still accepted 0 — ✅
R2 destination entry: unknown key / leg: kode / missing leg / repository not owner/name 2 carve-shape-invalid ×4 ✅ closed
S4 dead moved_paths: prefix 2 carve-surface-vacuous ✅ closed
S4/f row whose source_path is OUTSIDE every prefix 2 carve-shape-invalid ✅ closed
f src/mod_old/ beside prefix src/mod not swallowed 0 — ✅
S5 unparseable YAML 2 carve-shape-invalid with line+column ✅ closed
k non-UTF-8 bytes / empty / top-level list / bare scalar / !!python/object/apply 2 carve-unreadable, then carve-shape-invalid ×4 ✅ (safe_load: no exec)
S6 -z + surrogateescape sees BOTH non-UTF-8 filenames; one left out of the rows 2 carve-file-undeclared ✅ closed — not invisible any more
S7 REAL divergent pair (\xee\x80\x80=U+E000 vs \xff→U+DCFF): bytewise order passes… 0 — ✅ fixture is divergent
S7 …and the CODE-POINT order refuses 2 carve-path-order-violation ✅ closed — a sorted() implementation would have accepted this file
N1 edits[].lines [1, 999999] on a 3-line blob / [3] on line 3 / [0] / [] / ["1"] / [true] 2,0,2,2,2,2 carve-shape-invalid ×5, bound named "3 line(s)" ✅ closed, inclusive and off by nothing
N2 two rows → one (destination, destination_path) 2 carve-file-duplicated ✅ closed for the same-key case
A1 two destination KEYS with identical {repository, leg} → one real arrival file 0 — ❌ S8 (NEW)
b carve_commit uppercase / 39 chars / tag name / carve_tag with a space 2 carve-shape-invalid ×4 ✅
c HEAD≠carve_commit / --at other / unresolvable sha / unresolvable ref / "" / arg-injection 2 carve-revision-mismatch ×6 (no injection) ✅
c --at <carve_commit> 0 — ✅
d mode drift both directions on a real 0755 blob; git_mode: '100666' 2 carve-digest-mismatch ×2, carve-shape-invalid ✅
digest all-zero / another file's real digest / UPPERCASE hex 2 carve-digest-mismatch ×2, carve-shape-invalid ✅
e row for a path added in commit 2 with carve_commit = commit 1; not_moved row for an absent path; source_path naming a DIRECTORY 2 carve-path-absent ×3 ✅
f a surface file in NO row / one path in TWO rows 2 carve-file-undeclared, carve-file-duplicated ✅
g moved_verbatim+edits / mwde+[] / mwde no key / not_moved+edits 2 carve-disposition-inconsistent ×4 ✅
h a 4th edit class / the three reordered / only two / class: import-rewrites 2 carve-shape-invalid ×3, carve-vocabulary-unknown ✅
i destination typo / reason typo / 6th declared reason / a KNOWN-but-undeclared reason / a 4th disposition 2 carve-vocabulary-unknown ×4, carve-shape-invalid ✅ declared-AND-known both bite
j two rows swapped / fully reversed (ASCII) 2 carve-path-order-violation ×2 ✅
n --json on a pass and on a refusal 0 / 2 valid JSON, result/code/detail/manifest ✅ exit code unchanged
digest: working-tree edit with HEAD == carve_commit 0 — ✅ the tree, not the checkout
env --repo missing / non-git / no commits / --manifest a directory / mode 000 / unknown flag 2 carve-unreadable ×5, argparse 2 ✅ no traceback
O1 surrogate-bearing tree path in the refusal DETAIL — 3 refusal paths × 5 stdio configs (PYTHONIOENCODING=utf-8, utf-8:strict, ascii, LC_ALL=C, default), plain and --json 2 ×14 no traceback ×14 ✅ Copilot's newest finding is not reachable — see O1
A2/A3 destination_path: ../../etc/passwd / /etc/passwd 0 — ❌ N3, declared not-taken
a destinations key NO row uses (dead destination) 0 — ⚠️ N-d
duplicate top-level rows: key (PyYAML last-wins) 2 carve-file-undeclared ⚠️ refuses, downstream — N-e
--repo <missing dir> with the DEFAULT manifest 0 NO MANIFEST ⚠️ N-f — S1's argument on the other flag
--manifest '' (falsy) falls back to the default path 0 — ⚠️ N-g
a GITLINK inside the surface / duplicated-equivalent prefixes / source_path: './…' / symlink row 0,0,2,0 carve-shape-invalid for ./ ✅
surface shrunk to one prefix 0 — ⚠️ by design (moved_paths IS the surface)
line bound on edge blobs: an EMPTY blob's lines: [1]; a no-trailing-newline 2-line blob's [2] then [3]; a CRLF 2-line blob's [2] then [3] 2,0,2,0,2 carve-shape-invalid ×3 ✅ no off-by-one — empty = 0 lines, CRLF and missing-final-newline both counted right
--at an ABBREVIATED sha that resolves to carve_commit; digest of an empty blob = sha256(b"") 0 — ✅
false-refusal hunt paths with a space, a ", a \, a #, and a UTF-8 accent — names git WOULD quote without -z 0 — ✅ no right manifest refused
false-refusal hunt one of those quoted-name files left out of the rows 2 carve-file-undeclared ✅ the -z reading holds end to end
false-refusal hunt a 37-row manifest, src/mod/deep/nNN/ nesting, unique arrivals; then one arrival collision among the 37 0 then 2 carve-file-duplicated ✅ scales, and still finds one collision in 37
false-refusal hunt a moved_paths prefix whose only tree entry is a GITLINK 2 carve-surface-vacuous ⚠️ defensible — see N-j

Defects

No BLOCKING defect. Every guarantee floor part 1 exists to give held under all 134 attacks: a file in no row refuses, a drifted digest refuses, a flipped mode refuses (both directions, on a real executable and on a symlink), an edit in no class refuses, a moved tree refuses, a dead surface prefix refuses, a misordered file refuses bytewise-and-not-by-code-point, and no right manifest was refused.

S8 — SHOULD-FIX (NEW; a hole left inside the round-1 N2 fix). The destination-arrival uniqueness check is keyed on the manifest's own destination ALIAS, not on the real arrival. check_surface builds arrivals[(row["destination"], row["destination_path"])], where row["destination"] is a KEY of destinations:. Declare two keys with an identical {repository, leg} body and two source files may claim one real destination file — the exact outcome carve-file-duplicated was added in round 1 to prevent ("one of them overwrites the other, and the manifest does not say which"), reached by a route the check cannot see. Repro (isolated, minimal): on a clean manifest add destinations: {dox_code_2: {repository: opensoft/openDox-code, leg: code}} duplicating dox_code's body, then set c.py's destination: dox_code_2 and its destination_path to a.py's → exit 0, OK. Same manifest with the same KEY on both rows → exit 2 carve-file-duplicated (the control passes, so the check is live; only its key is wrong). Not blocking: it takes a deliberate duplicate destinations entry, and round 2's own closed {repository, leg} grammar makes that duplication visible in review. Round 2 also makes the fix a one-liner: key arrivals on (destinations[dest]["repository"], destinations[dest]["leg"], destination_path) — the entry is now closed to exactly those two fields, so the real arrival is computable, which it was not before d97371d1. A second, cheaper half: refuse two destinations keys with identical bodies as carve-shape-invalid (an alias for one repository+leg is a document defect on its own).

O1 — an OPEN Copilot finding on THIS head, which I judge NOT to be a defect. Copilot's fifth review (5155397957, 2026-09-09T14:03:37Z, on d97371d1) carries a suppressed comment with no thread to resolve, so nothing on the PR records it: "tree_at() decodes git ls-tree -z paths using surrogateescape, so any refusal detail that interpolates a path from the tree can contain surrogate code points… Printing such a refusal via render() can raise UnicodeEncodeError on UTF-8 stdio" — i.e. the exit-1 crash the module docstring says cannot happen. It is not reachable at this head, and the mechanism is structural rather than lucky: refusals print to sys.stderr, and CPython ignores the :errorhandler part of PYTHONIOENCODING for stderr and pins it to backslashreplace — measured: PYTHONIOENCODING=utf-8 → stderr=utf-8/backslashreplace; utf-8:strict → still backslashreplace; ascii → ascii/backslashreplace; and print('x\udcffy', file=sys.stderr) succeeds under all of them while the same print to stdout raises under utf-8:strict. The --json branch does go to stdout, but json.dumps defaults to ensure_ascii=True and escapes the surrogate to \udcff before it gets there; and no stdout branch (OK, NO MANIFEST) interpolates a row or tree path at all. 14 runs — three different refusal paths that each name a non-UTF-8 tree path in the detail (carve-file-undeclared, carve-path-order-violation, carve-digest-mismatch) × five stdio configurations × plain and --json — all exit 2, none a traceback. Recommendation: no code change; but the finding deserves the same one-sentence written answer 2bf3764c gave the thread-less 12:23Z review, because a thread-less Copilot comment is now a recurring failure mode on this PR (12:23Z → the first verifier's S6, and now 14:03Z), and the reason it is safe (stderr's pinned handler) is worth a line in the module docstring so a future refactor does not move a refusal to stdout.

NOTES (no action asked)

  • N-a The branch is a clean fast-forward of 56e69a11 with 0 merges, but main is now 22 commits ahead. doc-health at HEAD reports 9 errors and current main 8 — main fixed one this branch still inherits from its base, so a merge takes main's fix and nothing regresses. Parity against the true merge-base is exact (0-byte diff), which is the comparison that judges this PR.
  • N-b Because edits is legal on a not_moved row and check 5 runs before check 6, a not_moved row whose edit has a bogus class answers carve-vocabulary-unknown — the shallower finding for the deeper defect (the row should not have edits at all). Contained; both exit 2.
  • N-c The closure scan is a regex over CarveRefusal(\s*"…". It matches all 62 current raise sites, but a future CarveRefusal(code, …) with a variable, or a single-quoted literal, would be invisible to it. Worth a sentence in the test's docstring.
  • N-d A destinations: key that no row uses passes silently — the mirror of carve-surface-vacuous, not applied to the destination side. Cheap to add alongside S8.
  • N-e PyYAML still accepts duplicate keys silently (last wins); a manifest with two rows: keys refuses, but for a downstream reason (carve-file-undeclared).
  • N-f S1's argument, unapplied to the other flag. The seat-holding pass fires before any check that the repository is real, so --repo <typo> with the default --manifest prints NO MANIFEST and exits 0 — green for a manifest nobody validated, which is the sentence S1 was written on. Reasonable to leave (today --repo has no production caller and the documented invocation is argument-free), but it is the natural companion fix: refuse when --repo was NAMED and is not a git repository.
  • N-g if args.manifest: is falsy for --manifest '', so an empty value silently falls back to the default path. Fail-closed either way (absent default → carve-unreadable naming --manifest ''); cosmetic.
  • N-h Body staleness, recurring. The file table says 1000 / 1068 lines; the files at this head are 1042 / 1107. The evidence block still says "73 passed" and "73 new passing tests" while the round-3 section below it correctly says "75 (was 73)" — actual is 75. The first verifier reported the same class (N11: 802/783 claimed, 810/787 actual). Everything else in the body I re-measured matches: 177, 92-and-92, base 56e69a11, the eleven-code refusal table, pytest.ini and the required job's invocation.
  • N-j A moved_paths: prefix whose only tree entry is a gitlink (a submodule) refuses carve-surface-vacuous, because tree_at() keeps blobs only. Defensible — there are no bytes to move and no digest to record — but the message says the prefix "matches NO file", which is not what a reader of a real, populated directory expects. Cannot bite the declared openDox surface; worth one clause in the refusal text if a vendored path ever enters a carve.
  • N-i --help still does not name the six checks (they live in the module docstring) — unchanged, and it matches validate-openreposhape-pin.py rather than deviating from it. destination_path remains wholly unvalidated (N3, declared not-taken): ../../etc/passwd and /etc/passwd both pass. The author's reason — the shape is the memo's to set — is defensible, though with repository and leg now closed, "relative, no .., no leading /" reads less like a shape decision and more like the same fail-closed hygiene applied to the destination side. Owed at the carve, not here.

CI at this head — RED, estate-freeze class, not this PR's

Seven of the eight non-pytest-suite checks pass, including four of the five other required ones (lane-line, openspec-cli-pin, release-tag-gate, signed-execution-chain-gate, wallet-validation — all SUCCESS) plus clearing-dispatch-gate and openreposhape-pin.

  • pytest-suite — CANNOT-VERIFY for this head's own summary line, RED by class. Run 34360675800 was still inside step 12 (python3 -m pytest tests/ -q -m "not postgres") when I finished, with step 13 (Pin the triple…) pending, so its summary line does not exist yet. The class is established from main's own run 34358102328 (6df21737, 13:35Z), whose summary line is:

    selected=10606 passed=10583 skipped=23 failures=0 errors=0 … floors: selected>=7090 (margin 3516) passed>=7070 (margin 3513) skipped==21

    failures=0 errors=0. Every ::error on that run is the pinned-core checkout's consequence and nothing else: skipped 23, pinned exactly 21, plus the two named testcases the pin exists to protect — tests.review_lane_pin.test_floor_snapshot.TheFreshnessVerifier::test_the_snapshot_is_byte_identical_to_the_pinned_core and tests.review_lane_pin.test_floor_snapshot.TheVectorReplay::test_every_vector_replays, each reported 'skipped' in pytest-report.xml, wanted 'passed'. That is the codexFactory org-transfer freeze exactly, red on every openxFactory PR until GATED (runbook Phase 1 COMPLETE, step 1.6 INCLUDED) — slice B1: the decision-core pin, the workflows, the operator tools (42/15) #801 lands.

  • I proved those two skips are environmental and not this PR's, which is the part a class argument still owes: pytest -q tests/review_lane_pin/test_floor_snapshot.py -k '…' -rs gives 2 skipped at THIS head and 2 skipped at the merge-base 56e69a11, with the identical reason — no pinned decision core on disk … In CI this skip means the cross-repository checkout FAILED. Two skips, present before this branch existed, unmovable by a diff that adds two files under scripts/ and tests/carve_manifest/. (The Check out the pinned decision core STEP reports success on both runs, so the step conclusion is not the signal — it warns rather than fails; the skips are.)

  • merge-master-approval FAILURE — the same freeze, and not a required check. Its own log: Decision core unreadable — opensoft/codexFactory@4b12ba83… could not be checked out with the repo identity. **Advisory check: this blocks no merge.** It is absent from the required list (lane-line, openspec-cli-pin, pytest-suite, release-tag-gate, signed-execution-chain-gate, wallet-validation).

  • Local evidence standing in for the pending job: pytest -q tests/carve_manifest → 75 passed; pytest -q tests/manifest_digests tests/openspec_cli_pin tests/openreposhape_pin → 177 passed at HEAD and 177 at the merge-base, identical; 75 collected with no per-directory conftest.py (which pytest.ini's header forbids) and tests/conftest.py in the chain, so the FR-043 hermeticity guard reaches the new directory. The suite makes no network/gh/nlm/omp call. Nothing in this diff can move EXPECT_SKIPPED (nothing here skips — the real-repo test is a branch), and MIN_SELECTED/MIN_PASSED are floors that 75 new passes only raise. This PR is neutral to every pin the required job enforces.

Shared checkout

/home/brett/projects/xFactory/openxFactory — start: rev-parse --short HEAD = 6612d323, diff --cached --name-only | wc -l = 0. End: 6612d323, 0 — re-checked after removing my worktrees. Only fetch / worktree prune / worktree add --detach / worktree remove --force (mine) were run against it. I worked in wt-verify-839b and wt-verify-839b-base under my own scratchpad and removed both; fixtures were throwaway git init repos under $SP/verify-839b-fixtures/, never inside a worktree. The two stale worktrees from the FIRST, dead verifier (wt-verify-839, wt-verify-839-base, under another session's scratchpad) are still registered and were left untouched — not mine. No merge, approve, push, auto-merge, ruleset, workflow-dispatch or thread act; this is my one and only comment.

…pository, leg, destination_path), not the alias

The check_surface() duplicate-arrival check (`carve-file-duplicated`) keyed on
the manifest's own `destination` ALIAS — `(destination, destination_path)` —
rather than the real arrival. `destinations:` may legally carry two keys
sharing one `{repository, leg}` body, so two rows naming the two different
keys with one shared `destination_path` passed silently: keyed on the alias
they look like two different destinations, but they are one real file, and
one of them overwrites the other with the manifest not saying which — exactly
the outcome `carve-file-duplicated` exists to refuse.

Now keyed on `(destinations[key].repository, destinations[key].leg,
destination_path)`. A `destination` naming no key of `destinations:` falls
back to keying on the alias itself, in a shape (a 1-tuple) that can never
collide with a resolved 3-tuple: that case is check 5's
`carve-vocabulary-unknown` and check 4 must not crash ahead of it.

Decided, and recorded in the module docstring: two `destinations:` keys
sharing one body do NOT themselves refuse at check 1 (`carve-shape-invalid`).
Whether two rows actually collide at a real destination is check 4's
question, not check 1's — the document alone cannot answer it — and refusing
the alias regardless of row usage would make check 4's own fix permanently
unreachable by any subprocess run of this file (check 1 always runs first),
which is how every behavioural test in this suite is required to run.

Regression test added: two destination aliases with an identical
{repository, leg} body, two rows sharing a destination_path across them.
Proved against the pre-fix validator (`git show
HEAD:scripts/validate-carve-manifest.py` at d97371d): the fixture exits 0
there and exit 2 `carve-file-duplicated` under the fix.

One docstring sentence added at CarveRefusal.render(), the refusal-rendering
site Copilot's fifth review (5155397957, 14:03:37Z) named: a refusal detail
can interpolate a surrogateescape-decoded tree path, and this is safe printed
to stderr because CPython pins stderr's error handler to `backslashreplace`
regardless of PYTHONIOENCODING — reproving the re-verifier's 14-run finding
that this is unreachable rather than a defect. No code change for that item;
the review carries no comment thread, so this PR's comment is the record.

tests/carve_manifest: 76 passed (was 75). tests/manifest_digests,
tests/openspec_cli_pin, tests/openreposhape_pin: 177 passed, unchanged.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 9, 2026 14:37
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-4-opendox-extraction

Fix round 3 taken — a1205ef1, exactly-scoped to scripts/validate-carve-manifest.py and tests/carve_manifest/test_carve_manifest.py, responding to the RE-VERIFICATION of head d97371d1.

  1. S8 taken. check_surface()'s duplicate-arrival check (carve-file-duplicated) keyed on the manifest's own destination ALIAS, so two destinations: keys sharing an identical {repository, leg} body let two rows arrive at one real destination file undetected. Now keyed on (destinations[key].repository, destinations[key].leg, destination_path). Regression test test_two_destination_aliases_sharing_a_body_still_refuse_a_duplicate_arrival proved to exit 0 (OK) against the pre-fix script at d97371d1 and exit 2 carve-file-duplicated against the fix.
    Decided, and recorded in the module docstring: two destinations: keys sharing one body do not themselves refuse as carve-shape-invalid at check 1. Whether two rows actually collide at a real destination is check 4's question, not check 1's, and refusing the alias regardless of row usage would make check 4's own fix permanently unreachable by any subprocess run of this file (check 1 always runs first), which is how every behavioural test in this suite is required to run.
  2. Copilot's suppressed comment (5155397957, 14:03:37Z, no thread) — a refusal detail interpolating a surrogateescape-decoded tree path could crash the "no exit 1" contract on unprintable bytes. Answered as unreachable, not fixed, per the re-verifier's 14-run proof: CPython pins sys.stderr's error handler to backslashreplace regardless of PYTHONIOENCODING. One sentence recording that guarantee is now in CarveRefusal.render()'s own docstring; no code change. This comment is the record — the review carries no comment thread to reply on.
  3. PR body refreshed — line-count table (1099 / 1133), evidence test count (76, was 75), refusal-code coverage table's carve-file-duplicated row (3, was 2), and a new "Verifier round 2 — a1205ef1" section covering all of the above plus the two items left standing: N3 (destination_path shape, declared not-taken) and the --repo <typo> + default-manifest exit-0 note (S1's argument applied to the sibling flag).

python3 -m pytest -q tests/carve_manifest → 76 passed (was 75).
python3 -m pytest -q tests/manifest_digests tests/openspec_cli_pin tests/openreposhape_pin → 177 passed, unchanged.
python3 scripts/validate-carve-manifest.py at the repository root → NO MANIFEST …/docs/opendox-carve-manifest.yaml (nothing to validate), exit 0.

Diff: 2 files changed, 88 insertions(+), 5 deletions(-). All 4 review threads resolved; 0 unresolved. No merge, approve, auto-merge, ruleset, workflow or openspec/**/contracts/** touch; pushed fast-forward only (d97371d1..a1205ef1).

🤖 Generated with Claude Code

Copilot AI 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.

🟢 Approval recommended

The new validator’s behavior is extensively pinned by subprocess-based tests (including vocabulary closure and edge cases) and the PR is additive-only with no modifications to existing code paths.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 9, 2026 15:43

Copilot AI 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.

🟡 Changes recommended

The validator can crash (TypeError) when destinations: contains non-string keys because check_shape() doesn’t validate destination keys before later sorted(destinations) formatting.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread scripts/validate-carve-manifest.py Resolved
…sure test reads CarveRefusal calls by AST, not by quote style

PRRT_kwDOTAvnrs6guuUN: a non-string `destinations:` key (PyYAML parses an
unquoted `1:` as the int 1) passed check_shape() in silence and reached
check_vocabularies' `sorted(destinations)` the moment a row's destination
failed to match it, raising a raw TypeError and exiting 1 -- not one of the
two exit codes this file's docstring promises. check_shape() now requires
every destinations: key to be a non-empty string matching a label pattern
(`^[a-z][a-z0-9_]*$`), refusing carve-shape-invalid and naming the
offending key's repr, checked before descending into the entry's own
shape (same first-failure-wins discipline as every other check here).
Regression test proves the pre-fix crash against a25a323 (this round's
base commit) and the post-fix refusal.

PRRT_kwDOTAvnrs6guuUv: the refusal-code closure test's regex matched only
a double-quoted CarveRefusal("...") first argument, so a single-quoted
raise site would silently miss its own code -- the exact blind spot the
test exists to close. Replaced the regex with an ast walk over Call nodes
named CarveRefusal whose first argument is a string constant, which reads
either quote style alike and fails loudly on a call whose first argument
is not a literal, rather than skipping it. Kept the test's bidirectional
contract (every raised code is ratified, every ratified code is raised).

Swept the validator for every other sorted()/comparison/membership site a
manifest-supplied value reaches: each is already isinstance(str)-gated in
check_shape before use (source_path via _require_str, edits[].lines via
an explicit int check, destination/reason/edit class all validated before
their vocabulary checks run), except check_vocabularies' own
sorted(destinations) -- which this same fix closes at its source, since
check_shape always runs first. No other independent fix was needed.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 9, 2026 16:14
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-4-opendox-extraction

Copilot round 4 taken, 3544d07e, on top of a25a3235.

  • PRRT_kwDOTAvnrs6guuUN — a non-string destinations: key (PyYAML parses an unquoted 1: as the int 1) passed check_shape() in silence and reached check_vocabularies()'s sorted(destinations) the moment a row's destination failed to match it, raising a raw TypeError and exiting 1 — not one of the two exit codes this file's docstring promises. check_shape() now requires every destinations: key to be a non-empty string matching ^[a-z][a-z0-9_]*$, refusing carve-shape-invalid and naming the offending key's repr, checked before the entry's own shape. Regression test test_a_non_string_destination_key_refuses proves the pre-fix crash (exit 1, TypeError) against this round's base commit a25a3235 and the post-fix refusal (exit 2, no traceback).
  • PRRT_kwDOTAvnrs6guuUv — the refusal-code closure test's regex matched only a double-quoted CarveRefusal("...") first argument. Replaced with an ast walk over Call nodes named CarveRefusal whose first argument is a string constant — quote-style-agnostic, and fails loudly rather than silently skipping a call whose first argument isn't a literal. The bidirectional contract is unchanged.
  • Swept the validator for every other sorted()/comparison/hash site a manifest-supplied value reaches: all others are already isinstance(str)-gated in check_shape() before use (source_path, edits[].lines, destination/reason/edit class), so no other independent fix was needed.

tests/carve_manifest 77 passed (was 76); tests/manifest_digests, tests/openspec_cli_pin, tests/openreposhape_pin unchanged at 177. Root python3 scripts/validate-carve-manifest.py → NO MANIFEST … (nothing to validate), exit 0. Both threads replied and resolved.

🤖 Generated with Claude Code

Copilot AI 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.

🔵 Needs a closer look

The new tests hard-code /dev/null (a host-absolute path) instead of using os.devnull, conflicting with the repo’s “no host-absolute paths in committed files” rule and reducing portability.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

tests/carve_manifest/test_carve_manifest.py:127

  • This hard-codes a host-absolute path ("/dev/null"), which conflicts with the repo constitution’s “no host-absolute paths in committed files” rule and also makes the test non-portable on non-POSIX platforms. Prefer os.devnull (already imported) to express the null device without embedding an absolute path literal.
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap
brettheap merged commit 6ef5d02 into main Sep 9, 2026
11 checks passed
brettheap added a commit that referenced this pull request Sep 9, 2026
… satisfiable on a merge ref and on main after the manifest lands (split-opendox § 3.1, part 1b) (#864)

split-opendox-two-layer-product § 3.1, part 1b — the carve-manifest validator's revision semantics, on Brett Heap's word "merge 1b when green, then the manifest" (2026-09-09). Validator + driver only; no other file.

Why: as landed by #839 (a faithful reading of the memo's § 1.3 text), check 2 refused unless HEAD resolved to `carve_commit` — unsatisfiable on a pull request's synthetic merge ref and on main after the manifest's own squash; the driver's real-repo test would have turned the suite red for every lane the moment the manifest landed. The memo's intent (§ 6 step 3) is realized instead:
- Check 2: `carve_commit` must be a commit the repository carries and an ANCESTOR of the tested revision (`HEAD` or `--at`); identity is the trivial case; an annotated tag's object id peels and refuses.
- Check 3: two passes — the referent's blob/mode must match the recorded digest (a manifest lying about its referent), then the tested revision's blob/mode must equal the referent's (`carve-digest-mismatch` "changed since the carve", "mode drift"; `carve-path-absent` "deleted since the carve").
- Check 4: the surface walk runs at the referent (vacuity) and at the tested revision (a file added under `moved_paths:` since the carve → `carve-file-undeclared`).
- `OK … verified at <12>` when the revisions differ; `--json` gains `verified_at`; eleven refusal codes unchanged; exit 0/2 only; `docs/` lies outside every surface prefix, so the manifest's own landing never trips the walk.
- 88 tests (14 proven discriminating against the pre-amendment validator); one Copilot round taken; independent verification on the PR.

Refs #656 (stays OPEN).

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 9, 2026
…865)

split-opendox-two-layer-product § 3.1, part 2 — the openDox carve manifest at carve_commit b075fd9 (tag `opendox-carve-0`, a label beside the commit), on Brett Heap's word "merge 1b when green, then the manifest" (2026-09-09).

- `docs/opendox-carve-manifest.yaml` (RULED OQ-E path; the first machine-validated YAML under `docs/` here): 454 rows, one per file in the declared surface, none undeclared — 172 `moved_verbatim`, 146 `moved_with_declared_edit` (edit classes `import rewrites` / `path constants` / `adapter calls`, RULING OQ-1 verbatim; every edit's line numbers statement-anchored at the carve commit, 782 lines checked), 136 `not_moved` (`stays_openxfactory_adapter` 103, `replicated_at_destination` 18 incl. the Q4 corpus-adapter interface, `stays_openxfactory_governance` 14, `deleted_at_carve` 1). Destinations: openDox-code 123, openXdox-code 92, openDox-spec 56, openXdox-spec 47; the assembly root carries release identity only (§ 3.8).
- Rows follow the RULINGS: OQ-A..G as recommended, B-2 (i′), B-4 (a); mixed openDox+openXdox tests → openXdox (OQ-G), with the recorded refinement that a test importing the adapter column stays in openxFactory, applied transitively through test helpers. Ten memo-vs-tree disagreements plus the memo's omission of the Q4 interface are listed in the PR body; the tree at the carve commit wins.
- Validated by `scripts/validate-carve-manifest.py` (#839 + #864): `OK` at the carve commit, at this head via `--at`, and at this head plainly ("verified at"); 318 digests recomputed. Independent verification FAIL → one fix round (two test rows re-filed as adapter-column; the stays rule applied transitively; statement-anchored citations) → re-verification PASS. One Copilot round taken.

Refs #656 (stays OPEN).

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
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.

2 participants