Repository navigation
Carve floor: one definition of a line — the arrival verifier numbers lines as the manifest validator does (RULED Q-L8 (c)) - #907
Conversation
…lines as the manifest validator does (RULED Q-L8 (c)) The two halves of FLOOR PART 1 disagreed about what a line IS. `validate-carve-manifest.py` bounded the manifest's 794 declared edit lines with `content.count(b"\n")`; `verify-carve-arrival.py` decided at the destination which lines a diff touched with `str.splitlines()`, which also breaks on U+2028, U+2029, \v, \f, \x1c-\x1e and \x85. Measured over the landed manifest, three rows carry U+2028 inside a line — 521/522, 2364/2367 and 734/738 lines by the two readings — and two of them are `moved_with_declared_edit` rows to `openxdox_code`, so six declared lines (`test_gate_console.py` 870, 1627, 1785, 1786, 1810 and `test_round_trip.py` 728) named one line where they were issued and another where they were checked. Carve leg 3 left all six among its 59 unapplied lines and reported the cause (finding 5), and its independent verification confirmed it. ONE DEFINITION, IN ONE MODULE, IMPORTED BY BOTH: `scripts/carve_lines.py` — a line is a `\n`-terminated record of the raw bytes, line N the Nth such record from 1, a trailing newline closing the last record without opening another, `\r` content and not a terminator. It is the numbering the validator already used, which `git diff` and `grep -n` show, and which the manifest's authors counted in — so the count does not move and no declared line was re-declared. THE COUNT IS PINNED, not asserted: the module is held equal to the validator's old inline expression over a corpus carrying every separator `splitlines()` would have added. `\r` staying content is a widening reported here rather than buried: a CRLF/LF flip is now a change AT a line number, refused by number where the row does not declare it, instead of falling into the "no line number can name" message that told an operator nothing about a file whose every line had moved. That refusal stays, and now names the one change the definition cannot express — a final newline gained or lost. NO MANIFEST CHANGE. Every one of the six lines already names, at b075fd9, exactly the `import rewrites` / `path constants` text its row's class describes under this definition, and unrelated text under `splitlines()`; `tests/carve_manifest` now asserts that line by line against the landed document, plus a census that the disagreeing set is exactly those three rows. Counts unchanged: 456 rows, 318 digests, 794 lines over 147 rows. Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <[email protected]>
Reviewer's GuideThe PR fixes Q-L8(c) by replacing the validator/verifier line-numbering mismatch with one shared raw-byte Sequence diagram for declared edit arrival verificationsequenceDiagram
participant Manifest
participant Validator as validate-carve-manifest.py
participant Shared as carve_lines.py
participant Verifier as verify-carve-arrival.py
participant Arrival as Destination blob
Manifest->>Validator: Validate edits[].lines
Validator->>Shared: count(content)
Shared-->>Validator: Raw-byte newline record count
Validator-->>Manifest: Declared lines are bounded
Manifest->>Verifier: Provide declared lines
Verifier->>Arrival: Read arrived bytes
Verifier->>Shared: text_records(carve)
Verifier->>Shared: text_records(arrived)
Shared-->>Verifier: Identically numbered records
Verifier-->>Manifest: Accept declared changes or refuse undeclared lines
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟡 Changes recommended
The new unconditional sys.path.insert(0, ...) in both scripts should be made idempotent (as in other repo entrypoints) to avoid accumulating duplicate sys.path entries when modules are repeatedly loaded by path in tests/tooling.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR eliminates a long-standing line-numbering mismatch between the carve manifest validator and the carve arrival verifier by centralizing a single “what is a line” definition and updating both tools (plus tests/docs) to use it, ensuring declared edit lines remain applicable even when blobs contain Unicode line-separator characters.
Changes:
- Introduce
scripts/carve_lines.pyas the shared, byte-level\n-record line definition (with helpers for counting and text records). - Update
scripts/validate-carve-manifest.pyandscripts/verify-carve-arrival.pyto use the shared module for bounds checking and diff line attribution/refusals. - Add targeted regression tests for U+2028/CRLF/final-newline edge cases and document the ruled definition in the cutover runbook.
File summaries
| File | Description |
|---|---|
| tests/carve_manifest/test_carve_manifest.py | Adds cross-tool agreement, drift-guard, and “count unchanged” tests around the shared line definition. |
| tests/carve_arrival/test_verify_carve_arrival.py | Adds arrival-side regressions for U+2028 and CRLF/LF flips under the unified numbering. |
| scripts/verify-carve-arrival.py | Switches declared-line checking to shared line records and updates refusal semantics/messages accordingly. |
| scripts/validate-carve-manifest.py | Switches declared-line bound computation to the shared carve_lines.count(). |
| scripts/carve_lines.py | New shared implementation of “line = raw bytes between \n terminators” plus decoded records for diffs. |
| docs/opendox-cutover-runbook.md | Documents the ruled line definition and its operational impact on refusals / declared lines. |
Review details
- Files reviewed: 6/6 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.
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 7 hours and 28 minutes by commenting @sourcery-ai review. Upgrade to get a review now.
Copilot's finding on both entry points, and it is right on this repository's
own idiom: `sys.path.insert(0, <scripts>)` was unconditional, and both files
are loaded by `spec_from_file_location` rather than imported — `tests/carve_
manifest/` loads the validator at import and the arrival verifier in four
cases, `tests/carve_arrival/` loads the verifier again — so each load prepended
another copy of `scripts/` and moved import precedence for everything that ran
after it in the session. Guarded with the `if _SCRIPTS_DIR not in sys.path`
form `scripts/proposal-support.py` carries, whose comment names this exact
case ("covers the case this script is loaded by `spec_from_file_location`
(which the tests do)").
`test_loading_either_tool_by_path_twice_does_not_grow_sys_path` keeps it: three
further loads across both tools must leave the entry count where it was. 198
passed; the manifest validator's five documented modes, both phase-A dry runs
and the leg-1 phase-B run are byte-identical to their output before the guard.
Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
scripts/carve_lines.py’s count() currently allocates full record lists via records() and should avoid that to prevent unnecessary memory churn during manifest validation.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
scripts/carve_lines.py:104
count()currently computes the line count vialen(records(content)), which forces a fullsplit()allocation of all records even when callers (e.g.validate-carve-manifest.py’s_check_edit_lines) only need the numeric upper bound. This can create avoidable memory churn on large blobs and is called repeatedly across manifest rows.
Consider implementing count() as a non-allocating scan over the bytes (still exactly matching the floor’s definition) and keep records() for the cases that truly need the record list.
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
…g before the ratification encode MERGED BEFORE THE ENCODE SO EVERY RATIFICATION FIGURE IS TAKEN ON A TREE THAT ALREADY CARRIES CURRENT MAIN. The branch was frozen at `5dd724f5` when `origin/main` was `e0638f11` — the tree every figure in the pull request body and in `tasks.md` § 5 was measured on. `origin/main` has since advanced by two commits, `40d2f821` (the carve floor's line definition, PR #907) and `bd1c54c6` (the `lane-line` workflow's lane-key character class widened for uppercase, PR #909), so this merge comes FIRST and the ratification commit lands on top of it. The single gate capture `review/verification-2026-09-10.md` is therefore already a post-merge run and no re-measure is owed at landing. NOTHING CONFLICTED AND NOTHING OF THIS PACKET'S IS TOUCHED. Main's two commits move `.github/workflows/lane-line.yml`, `docs/opendox-cutover-runbook.md`, `scripts/carve_lines.py`, `scripts/validate-carve-manifest.py`, `scripts/verify-carve-arrival.py`, `tests/carve_arrival/` and `tests/carve_manifest/` — no `README.md`, nothing under `openspec/`, nothing under `scripts/doc_health/` and nothing under `tests/doc-health/`. So the README `## OpenSpec Records` block had no conflict to resolve, the delta is byte-unmoved, and the `doc-health` corpus this packet measures is unchanged by the merge. Refs #856, refs #860 Lane: openxfactory-1 Co-Authored-By: Claude Fable 5.1 <[email protected]>



Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)
Refs #656
The ruling
Brett Heap, 2026-09-10, verbatim: "rule Q-L8 (a) approve, (b) (b′), (c) approve" — recorded at #656 comment
5621357564:Asked as Q-L8 (c) in the leg-3 memo (comment
5621296616, finding 5): "the two halves of the floor number lines differently —validate-carve-manifest.pycountsb"\n",verify-carve-arrival.pyusesstr.splitlines(), so 2 rows carrying U+2028 have 6 declared lines the leg cannot apply — a tool defect in openxFactory", and confirmed by the independent verification (comment5621719657: "Q-L8 causes all CONFIRMED").The divergence, both code sites
Before.
scripts/validate-carve-manifest.py,_check_edit_lines— the bound a declared line must satisfy at the carve commit:scripts/verify-carve-arrival.py,_check_declared_lines— which lines a phase-B diff touched at the destination:str.splitlines()also breaks onU+2028,U+2029,\v,\f,\x1c,\x1d,\x1eand\x85. One tool issued line numbers; the other read them in a numbering it had never been given.After. One module, imported by both:
The definition adopted is the validator's own, which is what
git diffandgrep -nshow and what the manifest's authors counted in: a line is a\n-terminated record of the raw bytes; line N is the Nth such record, 1-based; a trailing newline closes the last record without opening another;\ris content and not a terminator. So the count does not move — pinned rather than asserted bytest_the_line_count_is_exactly_the_expression_the_validator_carried, which holds the module equal to the old inline expression over a corpus carrying every separatorsplitlines()would have added (\r\n, a lone\r,U+2028,U+2029,\x85,\v,\f,\x1c-\x1e, the empty blob, and a blob that is not UTF-8 at all).Two consequences reported rather than buried:
\rstaying content is a widening. A CRLF/LF flip is now a change AT a line number — refused by number where the row does not declare that line, admitted where it does — instead of falling into the old "a change no line number can name" message, which told an operator nothing about a file whose every line had in fact moved.test_a_flipped_line_terminator_is_named_by_its_line_numberpins it.b"a\nb\n"andb"a\nb"have the same records), and the refusal now says so.test_a_change_no_line_number_can_name_still_refuseswas moved onto that mutation.NO MANIFEST CHANGE — the six lines at
b075fd91A census over all 456 rows' blobs at the carve commit: exactly three carry a blob the two numberings disagree about, and only two of them declare lines.
\n)splitlines()tests/corpus-adapter/test_openxfactory_adapter.pynot_moved / stays_openxfactory_adapter)tests/ideation-dashboard/test_gate_console.pytests/ideation-dashboard/test_round_trip.pyAll six were written in
\nnumbering, so nothing in the manifest is re-declared — measured line by line, class taken from the row, text from the blob atb075fd91dc8fced8e1373825ba80220c33536bae:splitlines()test_gate_console.py:870from ideation_dashboard import cli_fragment(root).parent.mkdir(parents=True, exist_ok=True)test_gate_console.py:1627assert d["command"].startswith("python3 scripts/ideation_dashboard/cli.py gate")r = _run_node(tmp_path)test_gate_console.py:1785assert argv[:1] == ["scripts/ideation_dashboard/cli.py"], argvcommand = _hostile_gate_commands(tmp_path)[action]test_gate_console.py:1786assert argv.count("scripts/ideation_dashboard/cli.py") == 1, argvargv, _output, run_dir = _paste_gate_command(tmp_path, command)test_gate_console.py:1810from ideation_dashboard import clirefuse it — inside the process, which is the layer that can refuse."""test_round_trip.py:728mine = (REPO_ROOT / "scripts/ideation_dashboard/round_trip.py").read_text(def test_the_shared_predicate_is_spelled_the_same_in_all_three():Every left-hand cell is exactly the
import rewrites/path constantstext its row's note describes; every right-hand cell is unrelated code. The U+2028 characters sit attest_gate_console.py\n-lines 795 and 802 (3 occurrences) andtest_round_trip.py\n-lines 113, 115, 507 and 511 (4). No row's blob at the carve commit carries a\rat all, so the CRLF half of the definition changes nothing about the real manifest.test_the_real_manifests_declared_lines_are_the_floors_linesasserts this table AND the census against the landed document, so a fourth disagreeing row appearing later fails a test rather than a leg.Counts unchanged, as the ruling's sequence requires: 456 rows, 318 digests, 794 declared lines over 147 rows, 20 replicas.
The regression tests
Ten new cases; the modified terminator case makes eleven touched.
tests/carve_arrival/— the fixturescripts/pkg/exotic.pycarries U+2028 inside line 2, so it is five lines to the floor and six tosplitlines(), and its appended row declares line 4 (no other case's row or digest count moves):test_a_declared_edit_after_a_u2028_line_verifies— phase A first, because the numbering plays no part in a digest comparison and must not move; then the declared edit applied at line 4 → phase BOK,declared_edits_diffed: 1,declared_edits_unapplied: 1.test_an_undeclared_edit_after_a_u2028_line_names_the_floors_number— an undeclared edit at line 5 →arrival-undeclared-editnaming [5], the number the manifest can declare and the validator will bound. The old code said [6], which no row could declare.test_a_flipped_line_terminator_is_named_by_its_line_number— CRLF/LF, refused at [2, 3] with declared line 1 admitted.test_the_verifier_numbers_lines_with_the_floors_shared_definition— the module rather than a run.tests/carve_manifest/— the two tools agreeing:test_the_two_tools_number_a_u2028_bearing_blob_identically— record by record on one U+2028 blob, with the old reading's line 4 (KEEP = 3) asserted as the non-vacuity.test_both_tools_reach_one_definition_of_a_line—MODULE.carve_lines is arrival.carve_lines: one module object, not two spellings that agree today.test_neither_tool_splits_lines_by_any_other_route— an AST drift guard over both scripts (agrepcannot tell prose from a call, and both docstrings must namesplitlines()to explain what was wrong with it), withscripts/carve_lines.pyasserted as the one file holding a split and both scripts asserted to import it.test_the_bound_is_the_floors_line_count_on_a_u2028_bearing_blob— a row declaring line 6 of a five-line file refusescarve-shape-invalid: "names line 6 … carries 5 line(s)". A line the floor cannot express never reaches a leg as a declaration.test_the_line_count_is_exactly_the_expression_the_validator_carried— the count does not move.test_the_real_manifests_declared_lines_are_the_floors_lines— the table and census above.Proof, verbatim
The suites.
origin/main's baseline is 187 (100 + 87); this branch is 198 (107 + 91) — ten new cases plus the review round'stest_loading_either_tool_by_path_twice_does_not_grow_sys_path.Non-vacuity, by mutation — every new case was proven to fail against the old numbering:
Mutation 1 reproduces the defect on the fixture — a correctly applied declared edit REFUSING, which is what leg 3 met on six real lines:
The manifest validator, every documented mode, exit 0.
Phase A, from a scratch destination materialised from
b075fd91— the numbering must not touch it.56/56 and 123/123, and the control that matters: the same two runs driven by
git show origin/main:scripts/verify-carve-arrival.pyon the same two trees produce byte-identical output (diffempty for both destinations). Phase A does not move.Phase B on leg 1's landed tree —
opensoft/openDox-codeatce53b489(leg 1's merge, PR opensoft/openDox-code#6),--dest-base da2391e0d3a3, with that PR's ten--replica-atdeclarations:Still
OK, with the same 61 declared-edit rows within their lines and 10 of 10 replicas, and again byte-identical toorigin/main's verifier on the same tree (diffempty), which is what makes the numbering change provably invisible to a landed leg.Two disclosures on that line, neither caused by this change (the old-vs-new identity is the proof):
2 unappliedwhere PR Add Omnigent install submodule #6's body recorded1. The extra one is the Q-L7 (a) amendment, which landed after leg 1 and gavetests/ideation-dashboard/conftest.pyits:25declaration; leg 1's copy attests/conftest.pyis byte-identical to the carve blob, so its declared edit is unapplied and counted. The first is leg 1's ownscripts/ideation_dashboard/doxbench_scope_types.py(lines 50, 69, 71 — theadapter callsthe BUILD arc owns). Measured independently of the verifier.10 of 10 declared replica(s) verified (byte-identical, or …)where PR Add Omnigent install submodule #6 recordedbyte-identical— the same Q-L7 amendment's wording change to the summary line, already onmainbefore this branch.openspec.
Identical on
origin/main(96 passed, 4 failed, the same four items), measured in a worktree at92d0367c. No new failure, and nothing underopenspec/is touched by this branch.doc-health (
python3 scripts/doc-health.py --single-repo .), branch againstorigin/main, repo labels normalised:32 critical, 5 error, 47 warning, 16 info. New regressions vs previous report: 0.— none added, none cleared;draftwords 160055 → 160311 (+256: the § 2.1 paragraph, in aStatus: draftrunbook);That is the whole delta — the expected dip from adding words to a draft, no finding either way.
Review round
Copilot, 2 threads, both FACTUAL, both fixed at
adaad35eand resolved. Both said the same thing about the two entry points:sys.path.insert(0, <scripts>)was unconditional, and since both tools are hyphenated and therefore loaded byspec_from_file_locationrather than imported —tests/carve_manifest/loads the validator at import and the arrival verifier in four cases,tests/carve_arrival/loads the verifier again — each load prepended another copy ofscripts/and moved import precedence for everything after it in the session. Now guarded with theif _SCRIPTS_DIR not in sys.pathformscripts/proposal-support.pycarries, whose comment names this exact case, and pinned by a test that loads both tools three further times and asserts the entry count does not move. Re-proved after the guard: 198 passed, and the validator's five documented modes, both phase-A runs and the leg-1 phase-B run are byte-identical to their output before it.Sourcery declined the review ("you've used your own review budget of 250,000 diff characters for the last 7 days") — no threads, and its check reports
SKIPPED.The runbook
§ 2.1 gains the definition where a reader asks for it, immediately after the findings table that says
arrival-undeclared-edit"names the lines": what a line is, thatscripts/carve_lines.pyholds it and both tools import it, the three rows and six declared lines the old reading broke, that no row was re-declared, and the one change the definition cannot express.Lands on Brett Heap's ruling Q-L8 (c) via the lane's gate, sequenced after leg 3 (openXdox-code #5) lands.
🤖 Generated with Claude Code