Skip to content

cited_to byte reader binds citations to their disposition blocks and applies the production unquoting rule (#851) - #863

Merged
brettheap merged 7 commits into
mainfrom
fix/cited-to-reader-nesting-unquote
Sep 9, 2026
Merged

brettheap merged 7 commits into
mainfrom
fix/cited-to-reader-nesting-unquote

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

Lane: openxfactory-1 (openXfactory-1)

The two Codex P2 findings recorded on issue #851, plus Copilot's log-label nit
from the same bench, and the two owed docstring repairs Brett's "do 1, then 2"
queued behind #862.

1. The cited_to: byte reader binds each line to its disposition block

Finding (Codex, #842 review thread on scripts/validate-pin-registrations.py
~L285). citation_lines_in matched a cited_to: key line ANYWHERE in the pin's
bytes — a folded why: >- that quotes the field's own grammar included — and
stopped a list at the first line that was not an item, so a # comment between
two real items ENDED the real list. Equal GLOBAL counts were the alignment proof
(scripts/validate-pin-registrations.py:540, len(lines) != len(parsed) → FAIL,
then zip(parsed, lines)), and the two errors CANCEL: the counts agree, zip
pairs the wrong lines, and a dangling citation after the comment is never
classified while the run exits 0 — this arm's own silence, in the shape it exists
to end.

What changed. citation_lines_by_entry
(scripts/validate-pin-registrations.py:250) replaces it with a structural walk:

  • a BLOCK SCALAR's body is skipped whole (blank lines and every line indented
    past the key's own column), so nothing written inside a disposition's prose is
    ever read as the pin's structure;
  • a COMMENT or a BLANK line inside a list is skipped and does not end it, which
    is what neither is in YAML either;
  • the walk stays inside dispositions: and counts its entries, so every line
    comes back BOUND to the entry whose block carries it.

check_citations now compares the SEQUENCE OF ENTRY NUMBERS the two readers
produce, not two totals: a per-entry disagreement that cancels in the total
refuses the field with its own finding (… do not fall in the same dispositions[] entries (bytes 1x2, structure 1x1, 2x1) …) instead of
classifying anything. The count-mismatch finding and its wording are unchanged.
citation_lines_in survives as the unbound view for a caller that needs only the
text. The production grammar is untouched — ^ - (\S.*)$, the line IS the
citation — and citation_lines_by_entry's docstring carries the original
reasoning with the three new rules stated beside it.

2. The production unquoting rule, applied to the line

Finding (Codex, #842 ~L297). scripts/validate-openspec-cli-pin.py passes
every _SEQ_MAP_LIST_ITEM through _unquote (:449, :464), so a QUOTED
citation scalar carries no quotes in the text the pin's own verifier prints and
compares. This byte reader returned them — so the repair the arm NAMES for a
successor (quoting the live # / : scalars, the ambiguity it measures) would
have left a permanent divergence WARN behind instead of clearing it. A repair
that cannot clear the warning it was made for is not a repair.

What changed. _unquote is restated in
scripts/validate-pin-registrations.py:250 and applied to every citation line
before comparison and classification. Restated rather than imported —
validate-openspec-cli-pin.py is hyphenated and unimportable, and this checker is
a standalone script — on exactly the discipline OWN_REPOSITORY_SPELLINGS
already lives under here, with
test_the_unquoting_rule_is_the_production_readers_own_rule loading the
production module by path and pinning the two equal over fifteen inputs.

The live pin is NOT quoted, so
test_the_live_pin_carries_lines_the_two_readers_read_differently — which pins
the divergence WARN on the live pin's unquoted # / : citations, and which
reds if a successor's re-vendor ever makes the class vacuous — stays green
unchanged. What is new is that quoting a scalar now clears the warning.

3. A failing row is never labelled OK

Finding (Copilot, #842 scripts/validate-pin-registrations.py:730). The
branch for a pin naming no consumer_entrypoint: returns citations_ok but
printed an unconditional OK … line, so a row failing on a dangling citation
carried an OK label about the assertions that did not apply.

What changed. The line reads MEASURED where citations_ok is false. The
inapplicability is still said, which is what the branch is for.

Test evidence

python3 -m pytest tests/pin_registrations -q: 51 passed before, 59 passed
after
— eight new tests, and every one of them is RED on the arm as it stood
(measured by swapping origin/main's checker back in: 8 failed, 51 deselected).

new test what it pins
test_a_folded_decoy_and_a_comment_no_longer_cancel_each_other_out Codex's scenario end to end. The decoy inside why: >- names a path that EXISTS, so the old arm exits 0 on this tree; the dangling citation after the comment is now reported at dispositions[1] and the decoy is never named.
test_the_folded_decoy_case_is_bound_line_by_line_to_its_entry the same fixture's binding asserted directly against parsed_citations_of
test_the_reader_walks_the_structure_and_binds_every_line_to_its_entry the three rules stated directly, including a folded field AFTER the section
test_equal_totals_that_fall_in_different_entries_refuse_the_field equal totals are not an alignment: 2 lines vs 2 citations, 1x2 against 1x1, 2x1, field refused
test_a_quoted_citation_scalar_no_longer_diverges a quoted scalar emits no WARN and its path still resolves
test_the_reader_unquotes_the_line_the_way_the_production_reader_does "…" and '…' unquoted; a backquoted span left alone
test_the_unquoting_rule_is_the_production_readers_own_rule parity with validate-openspec-cli-pin.py's _unquote
test_a_row_failing_on_a_citation_is_not_labelled_ok_where_it_names_no_entrypoint the OK/MEASURED label

python3 -m pytest tests/proposal-support -q: 106 passed, 46 subtests passed.
python3 -m pytest tests/doc-health/test_modified_block_currency.py -q: 139 passed.

The live pin's verdict is unchanged, byte for byte. python3 scripts/validate-pin-registrations.py before and after this branch produce
IDENTICAL output (diff clean): exit 0, 4 dispositions, 21 citations, 17
referents, 9 in-tree paths, and the same 7 measured divergences (5 truncated at a
#, 2 read as a single-key mapping).

The two owed docstring nits

refs #842 (the arm and the bench round), refs #840 (the arm's origin).

Closes #851

🤖 Generated with Claude Code

Brett Heap and others added 3 commits September 9, 2026 15:32
…block and unquotes it like the production reader (#851)

Two P2 findings Codex posted on PR #842's frozen head 5ab762c, deferred to
#851 because neither bites on the live pin today, and neither does now.

BINDING, NOT EQUAL TOTALS. `citation_lines_in` matched a `cited_to:` key line
ANYWHERE in the pin's bytes and stopped a list at the first line that was not an
item, with equal GLOBAL counts as its proof of alignment. So a `cited_to:`/`- …`
pair quoted inside a folded `why: >-` was admitted as structure while a `#`
comment between two real items ENDED the real list — and the two errors cancel:
the counts agree, `zip` pairs the wrong lines, a dangling citation after the
comment is never opened, and the run exits 0. `citation_lines_by_entry` replaces
it: a block scalar's body is skipped whole, a comment or a blank line inside a
list is the non-member YAML says it is, the walk stays inside `dispositions:`
and counts its entries, and every line comes back BOUND to the entry whose block
carries it. `check_citations` compares the SEQUENCE OF ENTRY NUMBERS the two
readers produce, so a per-entry disagreement that cancels in the total refuses
the field with its own finding instead of classifying anything.
`citation_lines_in` survives as the unbound view, for a caller that needs only
the text.

THE PRODUCTION UNQUOTING RULE. `scripts/validate-openspec-cli-pin.py` passes
every `^      - (\S.*)$` item through `_unquote`, so a QUOTED citation scalar
carries no quotes in the text the pin's own verifier prints and compares. This
reader kept them — which would have made the repair the arm NAMES for a
successor (quoting the ` #` and `: ` scalars) leave a permanent divergence WARN
behind instead of clearing it. The rule is restated here rather than imported,
that file being hyphenated and unimportable, on the same discipline
`OWN_REPOSITORY_SPELLINGS` is held to, and a test pins the two equal.

AND A FAILING ROW IS NEVER LABELLED OK (Copilot, same PR): the branch for a pin
naming no `consumer_entrypoint:` returns the citation arm's verdict, so its line
now reads MEASURED where that verdict is False.

Eight tests, every one of them RED on the arm as it stood: the bench's decoy +
comment case end to end (the decoy names a path that EXISTS, so the old arm
exits 0 on it), the same fixture's binding asserted line by line, the three
walk rules stated directly, equal totals falling in different entries, a quoted
scalar no longer diverging, the unquoting applied to the line, parity with the
production `_unquote`, and the OK/MEASURED label. The live pin's verdict is
byte-for-byte what it was: exit 0, 21 citations, 7 measured divergences.

Refs #842, #840.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…sing clause restored

Neither changes behaviour; both are prose a reader relies on.

`scripts/proposal-support.py` — `OriginRetentionError`'s docstring broke mid
sentence ("… could not be read. What / they share is …"), so the paragraph reads
as a truncated clause. Rejoined and rewrapped, no word changed.

`scripts/doc_health/modified_block_currency.py` — the module summary of
marker-defect GROUND TWO stated the quoted-span predicate without the half that
keeps a correct marker quiet. `suppression()` skips a span the marker ALSO NAMES
("a span the marker also names is a repeat, not a defect"), and the summary said
only that the span matches a promoted unit the block leaves out — so a reader of
the summary alone would expect a finding on a marker that declares the unit
properly and quotes it again in its reason. The clause is restored.

Refs #846, #850.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 9, 2026 19:34

@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 ✨

@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1 (openXfactory-1)

@codex review

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 new block-scalar opener regex is narrower than its own stated intent, which can let some block scalar bodies be scanned as structure and reintroduce the decoy class of misbinding.

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

Pull request overview

This PR hardens the pin-registration citation checker by making the cited_to: byte reader structural (binding each citation line to its dispositions[] entry), applying the production unquoting rule before comparison/classification, and correcting an output label so failing rows are not printed as OK.

Changes:

  • Replace global cited_to: line scanning with a structural walk that skips block scalar bodies, ignores comments/blank lines inside lists, and binds lines to disposition entries.
  • Apply the production reader’s _unquote behavior to citation lines and add parity tests against validate-openspec-cli-pin.py.
  • Fix the “OK” label emitted for rows without consumer_entrypoint: so it reflects the citation-arm verdict.
File summaries
File Description
tests/pin_registrations/test_pin_registration_sweep.py Adds regression and parity tests covering structural binding, cancellation cases, unquoting, and corrected row labeling.
scripts/validate-pin-registrations.py Implements citation_lines_by_entry, restates/applies _unquote, tightens alignment to per-entry binding, and updates output labeling.
scripts/proposal-support.py Rewraps OriginRetentionError docstring to remove a broken mid-sentence line break.
scripts/doc_health/modified_block_currency.py Repairs the module summary for marker-defect ground two to reflect the “marker also names the span” suppression rule.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread scripts/validate-pin-registrations.py Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 97dc2d643f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…e house's (#863 bench)

Copilot on PR #863: `_BLOCK_SCALAR_KEY` took an identifier-shaped key
(`[A-Za-z_][A-Za-z0-9_]*`), which is this corpus's house style and not YAML's. A
hyphenated `INV-2: >-` or a quoted `"a: b": >-` opens a folded scalar just as
well, and its body would have been walked as STRUCTURE — the decoy class this
change exists to close, reintroduced through the key spelling.

The key is now any plain scalar up to the `: ` separator or a quoted one, every
chomping/indent indicator is admitted in either order, and a trailing comment on
the header line is admitted because YAML admits it. ONE BOUNDARY IS DELIBERATE
and is stated where the pattern is: a KEYLESS block scalar (`- >-` as a whole
sequence entry) is not matched, because a line of that shape inside an open
`cited_to:` list is a CITATION under the pin's own production and must be read as
one. Such an entry cannot hide a decoy either — it is not a mapping, so it
contributes no parsed citation while its body's lines bind to its entry index,
and the per-entry comparison refuses the field.

Copilot's second half — `key:>-` with no space — is not taken: without a space
after the colon YAML reads the whole thing as a plain scalar, so there is no
block scalar there to skip.

`test_a_block_scalar_is_recognised_by_yamls_key_spellings_not_one_houses` pins
the table in both directions and the hyphenated decoy end to end. 60 passed; the
live pin's verdict is still byte-for-byte unchanged.

Refs #842.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 9, 2026 19:50

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

_BLOCK_SCALAR_KEY still fails to recognise some YAML-legal quoted key spellings (embedded quotes), which can prevent block-scalar bodies from being skipped and risks reintroducing the decoy-as-structure class of bug.

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

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

Comment thread scripts/validate-pin-registrations.py Resolved
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1 (openXfactory-1)

Head has advanced since your last round (97dc2d64) — 7bf26b9b broadens the block-scalar opener's key spelling on Copilot's finding, and aef53f79 merges main after #862 landed. All nine checks are green at aef53f79 (pytest-suite 24m42s) and both bench threads are answered and resolved.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aef53f797c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/validate-pin-registrations.py Resolved
…here YAML ends it (#863 bench)

Codex on PR #863, and it is the correct half of the thread Copilot opened. The
previous cut spelled the key as "anything up to a colon", and that is not the
separator YAML uses: a key ends at a colon FOLLOWED BY WHITESPACE, so `a:b: >-`
is one key carrying an internal colon and `"a\"b: c": >-` is one quoted key
carrying both. Neither was recognised as an opener, so a folded body under either
would have been walked as STRUCTURE — the decoy class this reader exists to
close, reached through the key spelling for the second time.

The key is now read NON-GREEDILY up to the first `: ` that is followed by a
block-scalar header, which is exactly where YAML ends it, and the quoted
alternatives are gone because they were only ever a partial spelling of the same
rule. The refusals are unchanged and asserted: `- >-` inside an open list is a
CITATION under the pin's own production, `finding: 'x: y'` is a plain scalar, and
a citation whose gloss ends in `>` is not an opener.

`test_a_block_scalar_is_recognised_by_yamls_key_spellings_not_one_houses` carries
the three new spellings, two new refusals, and the hyphenated decoy re-run under
`a:b:`. 60 passed; the live pin's verdict is still byte-for-byte unchanged.

Refs #842.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 9, 2026 20:32
Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1 (openXfactory-1)

Head frozen at 0f081ad9 (e2b5a699 takes Codex's P2 on the block-scalar key separator, then a merge from main). Both bench rounds are answered and every thread is resolved.

@codex review

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 behavioral changes are narrowly scoped, thoroughly regression-tested (including production parity for unquoting), and the updated alignment/refusal logic eliminates the previously silent misclassification path.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 0f081ad906

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1 (openXfactory-1)

FROZEN + LANDING PROVENANCE — 2026-09-09T21:22:44Z. Head 0f081ad9 (reader fix d0db4b60, docstring repairs dd789897, two bench rounds taken 7bf26b9b + e2b5a699, merges from main). Brett's words: "do 1, then 2" / "land 862 when green, then do 2" / "land the 851 pr when green" (2026-09-09). Guard on live values: six required checks SUCCESS on 0f081ad9; merge-master-approval = SUCCESS; unresolved review threads 0; closingIssuesReferences = #851 and the body's only closing keyword names exactly that; no openspec/changes/ file touched (Rule 6 window not required); no other lane's LANDING open on openxFactory main; main 95e67ab0 (decided=success@95e67ab pending=0). Bench: Codex REAL PASS on 0f081ad9 ("Didn't find any major issues") after its P2 on the block-scalar key separator was taken; Copilot rounds 1–2 "Changes recommended" taken, round 3 on 0f081ad9 "Approval recommended". Admin merge with provenance: authored as brettheap, self-approval cannot clear the review requirement (B2 pattern).

@brettheap
brettheap merged commit 424e291 into main Sep 9, 2026
9 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1 (openXfactory-1)

LANDED — lane openxfactory-1, 2026-09-09T21:22:56Z, PR #863 → 424e2913 on opensoft/openxFactory main. Origin #851: CLOSED.

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.

cited_to byte reader: bind citation lines to their disposition blocks and apply the production unquoting rule (Codex P2 ×2 on #842)

2 participants