Skip to content

Realize add-citation-remainder-report R1: the report CLI and its tests - #1100

Merged
brettheap merged 29 commits into
mainfrom
realize/citation-report-r1
Sep 18, 2026
Merged

brettheap merged 29 commits into
mainfrom
realize/citation-report-r1

Conversation

@brettheap

@brettheap brettheap commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-1

Status: Head 9997f763 (789cbc8f merged main dc242f3a, the repaired main, then one round: tree-read failures normalized to the no-reading exit, coverage note names the spec in this tree). 72/72 scenarios covered. 0 open review threads (20 taken across six rounds, all answered and resolved — the two tables below cover the last two rounds; the full round-by-round record is brett-wip handoffs/xFactory/attachments/openxfactory-1-2026-09-13/1053/bench-realization-rounds.md, commit 44f1cbac). All six required checks GREEN at this head; main's newest decided pytest-suite (dc242f3a) GREEN. Lands under Rule 6 on Brett Heap's word "land it when green" (comment 5728210143).

Claim: #1053 (comment)

What this realizes

tasks.md § 2.1 of add-citation-remainder-report, ratified 2026-09-17 by
Brett Heap — .openspec.yaml approved_by:, PR #1069 comment
5714138459
,
verbatim "ratify #1069", 2026-09-17T12:12:06Z, the word BARE and taking
D1–D7 at the RECOMMENDED option each. proposal.md declares
code_surface: openxFactory, non-empty, so the archive gate holds this packet
behind merged-plus-green realization evidence and not behind this pull request.

Three files, and no fourth:

path state
scripts/report-citation-remainder.py NEW
tests/citation_remainder/test_report_citation_remainder.py NEW
openspec/changes/add-citation-remainder-report/tasks.md EDIT (§ 2.1 tick + realization record)

Line counts are deliberately not restated in this body or in tasks.md.
They moved on every review round of this pull request — one Copilot thread named
1,620 and 1,908 as the true figures at a head where they were already 1,866 and
2,089 — and the merge commit's own diffstat is where a reader gets them right.
The counts that stay are properties of the delta rather than of a review round.

Patch B has LANDED, and the tests now read the spec rather than a draft

Merged main c32749c3 (this branch's merge commit 97dfc78b; main has
since advanced to 4ee21c40, which is this branch's merge base). Patch B's
rules are in the spec the tests read
— they are no longer implemented from a
branch's drafted text on the word "fold B as drafted", they are the ratified
delta in this tree. The merge carried one conflict, in tasks.md § 2.1, where
main had added Patch B's population-case narrative under the same paragraph
this branch had added its realization record to; both blocks are kept, in
that order.

#1099 landed in the same merge, so the three inherited sequenced_after
archive-date failures this branch reported for two rounds come in FIXED. There
is no inherited red left to name.

Coverage: 72 of 72 scenarios, counted mechanically, GAPS: NONE

The count is taken against the spec as it stands in this tree — no longer
against a branch tip — by searching for every #### Scenario: title in a test
function's docstring, so a scenario a later round REWORDS reads as a gap rather
than passing silently.

requirement scenarios covered
The citation remainder is reported 5 5
The reported population is derived from a stated recipe 22 22
A suspected cross-repository citation is flagged and never dropped 24 24
The report classifies only what it can decide mechanically 18 18
The citation remainder report is advisory and gates nothing 3 3
total 72 72

120 test functions, 130 tests collected (parametrized cases): 72 scenario
tests plus 48 that pin behavior the delta fixes without giving it a scenario of
its own.

That mechanical count has now caught three separate movements, and a hand
count would have passed every one of them:

movement what moved
63 → 69 Patch B's first two bench rounds
69 → 72 Patch B's last round: the parent-link skip case, and the locator grammar's two
72 → 72 a RENAME with no behaviour behind it — The out-of-root term takes only the links that resolve outside the root became …takes exactly the entries whose resolved path leaves the root, plus two rewritten bullets

Three of Patch B's rules moved CODE and not only tests

The out-of-root skip term is a predicate over the WHOLE TRACKED PATH. Patch
B's last round widened it in the requirement: it owns "the tracked ENTRIES whose
resolved path stands outside the repository root — not only an entry that is
itself a link, but any tracked entry reached through one, a PARENT directory
component included". entry_disposition had gated the term on is_link, on a
reasoning the code stated: git refuses to track a path beyond a symbolic link.
True of the moment a path is added and not of the tree afterwards — a directory
can BECOME a link after the files under it were tracked, and the index still
carries them at mode 100644. The gate is gone, the resolved path decides, and
SYMLINK_MODE went with it as its only reader.

The custody locator's PATH is now read. Patch B pins signal (4)'s grammar
exactly. The owner half was already exact — the class admits neither : nor /
and the pattern must run out at the token's own start — but the path half was
not being read at all, so opsx:opensoft/<token> fired whatever shape the token
had. The empty-segment arm is what does the work: a repeated slash inside the
path and a trailing slash at the end of it each leave one. The locator is judged
on the spelling AS WRITTEN and never on the normalized token, which is the only
reading under which a trailing slash can be refused at all.

The scenario rename brought no behaviour with it, and its test follows it in
three ways: the new title, a tracked regular file under a parent link so the
term is exercised through a parent as well as through an entry's own link, and
membership read BOTH ways round — entry by entry, because a count can be right
while the wrong entry stands in it.

Review threads taken this round — 7, all answered and all resolved

thread finding disposition
PRRT_kwDOTAvnrs6js_9D git diff --quiet HEAD returns 1 for a dirty tree and other statuses for fatals; every non-zero was read as MODIFIED FIXED at 24db78ff — real. Reproduced over a real repository: head ref moved to a sha no object stands at, diff --quiet HEAD exits 128 fatal: bad object HEAD, and the old code published ('000…001', MODIFIED) at exit 0. Now 0 clean / 1 modified / anything else CouldNotRun with git's stderr. The bare rev-parse HEAD beside it moved to --verify --quiet for the same conflation one line up. Three tests, one per outcome, plus the command-level reproduction
PRRT_kwDOTAvnrs6jtYen --is-inside-work-tree accepts a subdirectory while the rest of the function treats root as the work-tree root FIXED at fe28ac19 — real, and worse than stated. report docs gave 79 distinct tokens with 78 of 79 in the remainder, at exit 0, against 601 and 81 at the root: citations that resolve perfectly well reported DANGLING. Resolved to the work-tree top on the estate's own idiom (sequenced_after.py and scope_globs.py, both _git_toplevel) rather than refused, because the operand defaults to cwd and the two-case contract reserves non-zero for a report that could not run. The reading now STATES the root it read
PRRT_kwDOTAvnrs6jtgeK the git sink has no timeout, so an unhealthy object store can hang the nightly FIXED at 643cfe70 — real. timeout=30 at the one sink all four of this report's gits go through, TimeoutExpired → CouldNotRun; the estate's own number (hermes_runtime_validation/content.py:103-114, and fix/1098-realgit-subprocess-timeouts doing the same elsewhere). Measured headroom: the heaviest git here is 0.46s and ls-files over 5,510 entries is 0.007s. Two tests, one asserting the bound reaches subprocess.run and one reading the script for the sink still being the only one
PRRT_kwDOTAvnrs6jtYeI the lexical walk appends a target's components, putting the suffix ahead of the target DOES NOT REPRODUCE, measured before answering. pending is a stack POPPED FROM ITS END, so extend pushes onto its TOP and the target is walked first. The reviewer's own example and the hardest shape the walk meets both give the right answer: one/two → ../../alt/deep resolves one/two/three/file.md to <base>/alt/deep/three/file.md and reads the target's own bytes. The requested test is added anyway, asserting the EXACT path rather than a term, and the stack's orientation is now spelled out at both sites
PRRT_kwDOTAvnrs6jtge1 the test docstring says 72 scenarios where the realization record says 69 FIXED the other way round at 49c135a2 — the docstring was right and the RECORD was stale. Both read 72 now, and the record's other two stale figures went with it
PRRT_kwDOTAvnrs6jtxUJ the realization record ticks § 2.1 while reporting only 69 of 72 scenarios covered FIXED at 44414cf1 — a real defect, and the reading given was right. A botched substitution matched only the second 72 in the line, stranding 69 of on the line above; coverage itself was already 72 of 72 since e170372d. Record now reads 72 of 72 (reply)
PRRT_kwDOTAvnrs6jtxUj the fixed 64-hop cutoff makes a valid acyclic chain past it return None, counted as non_file rather than loop or unreadable KEPT, DECLARED, and tested at 44414cf1 — the bound is not removable and cycle detection can't replace it (a self-appending chain never repeats a state; 201 hops before a manual cap). Measured looser than the platform it reads through: the OS refuses at 41 hops, this walk at 65 — no chain a reader could open is one this walk gives up on. Three new tests (reply)

Review threads taken at 9997f763 (after 789cbc8f merged the repaired main) — 3, all answered and all resolved

thread finding disposition
PRRT_kwDOTAvnrs6jx2sD take_reading reads the tree through PacketIndex/Path too, so an unreadable openspec/changes (OSError) or undecodable git output (UnicodeError) printed a traceback instead of the non-zero no-reading exit FIXED at 9997f763 — real. The command-level handler reads except (CouldNotRun, OSError, UnicodeError) at the one rejoin point; identical stderr + exit 2. The per-file read loop is deliberately untouched (an undecodable file stays COUNTED under the undecodable skip term). Tests: test_an_unreadable_changes_directory_is_a_run_that_could_not_be_taken, test_a_packet_index_that_cannot_be_built_is_a_run_that_could_not_be_taken.
PRRT_kwDOTAvnrs6jx2sv the module coverage note still said the count is taken against Patch B's branch tip and that this tree carries main's 43 until Patch B lands FIXED at 9997f763 — stale prose. Patch B (#1097, c32749c3) is in this tree since 789cbc8f; the note now says the count is taken against the spec as it stands in this tree, 72 scenarios at the merge of main dc242f3a.
PRRT_kwDOTAvnrs6jydzf the coverage note names dc242f3a where the realization record names c32749c3 for Patch B ANSWERED, no change. Different facts: c32749c3 LANDED Patch B (the realization record's revision); dc242f3a is the main this tree merged, which contains it (git merge-base --is-ancestor true) with the spec byte-identical between the two — 72 #### Scenario: blocks at either sha. Reproducible from both.

Δ = 0 — the acceptance check this packet uniquely owes

scripts/ is inside the file population, so a citation-shaped string written in
the report would be a token the next run counts. Taken twice, by two
instruments
, at head e170372d against merge base 4ee21c40, both trees
clean:

THE HAND INSTRUMENT (measure.py, issue-native, PRIMARY)      at HEAD   at BASE
  distinct tokens                                              604       604
  INCLUSIVE  raw path absent                                   158       158
             resolve by identity                                76        76
             remainder                                          82        82
                {'dangling:file': 6, 'dangling:identity': 76}  — both sides

THE SHIPPED CLI AS ITS OWN CONTROL — run over the base tree, where it is
UNTRACKED and therefore unread, and over this head, where it is tracked and read
  distinct tokens        605       605
  remainder INCLUSIVE     82        82
  remainder FILTERED      43        43
  identities          55 / 28   55 / 28
  FILES read            3001      3000     <- the one file, and only it

Identical, line for line, on both instruments. Δ = 0. Asserted mechanically
as well: test_the_report_mints_no_citation_token_of_its_own runs the shipped
extraction pattern over the shipped script and asserts it matches nothing. And
re-checked at the FINAL head 49c135a2, after the record commit that quotes
these figures into a file the population reads, and again at 18c4222c:
605 / 82 / 43 / 55 / 28 / 3001, unmoved at both.

Earlier rounds of this branch recorded 602/154, then 600/157, then 604/158 —
every one Δ = 0 and none wrong. The corpus moves under every merge into main,
which is why both the record and this body name the head and merge base their
figures were taken at.

The reproduction gate at b1df95ee

Run against a worktree at b1df95ee80633339907c9e661164a783885a5d30:

figure evidence § 2.1 shipped CLI
tracked entries in scope 2,973 2,973
files read 2,969 2,969
raw path absent (NOT-A-PACKET-REFERENCE held out) 151 151
repaired by the identity rule 73 73
DANGLING identity half 72 72
DANGLING file half 6 6
AMBIGUOUS 0 0
INCLUSIVE remainder (tokens) 78 78
distinct tokens 571 572
NOT A PACKET REFERENCE 4 5

TWO FIGURES MOVE BY ONE APIECE, BOTH FOR THE SAME FIX, STATED RATHER THAN
SMOOTHED.
The extra token is openspec/changes/archive/.. at
scripts/validate-ideation-cross-reference.py:31, which the hand instrument
folds onto openspec/changes/archive by stripping a dot off a .. segment.
The CLI refuses to fold it, because rewriting a path that walks UP into a
citation OF what it walks up from is inventing the citation (Copilot
PRRT_kwDOTAvnrs6jsy7w, fixed at 0a6fdcdc). The remainder is unmoved at 78
either way, the token being NOT-A-PACKET-REFERENCE and so outside it.

WHICH READING THIS IS, STATED, because the evidence publishes three and they
are not comparable.
The CLI produces the NORMALIZED issue-native
reading, which is what this delta's three fixed choices produce: normalization
BEFORE deduplication, NOT_A_PACKET_REFERENCE held OUTSIDE the remainder, and
ANY one qualified occurrence setting the flag. The 586 / 162 / 81 figures
beside it in the evidence are that file's own recipe reading, and
586 / 162 / 86 is its literal reading; choice (1) forecloses both.
design.md D0(iv) and tasks.md § 1.1 publish the recipe reading as the
packet's headline, so a reviewer who has read D0 should expect the CLI to print
a smaller number at the same commit, and both are right.

The mechanical probes reproduce the hand classification's measured
precision
, which is a stronger check than the totals: truncated on exactly
the 4 tokens the hand read classed tokenization artifacts; fixture-path on
19 = D4's 17 of 18 synthetic-fixture entries plus its 2 nested file-half
fixtures; possibly-cross-repo on 13 of the evidence's 14 hand-found
cross-repository tokens with 2 false positives among the other 43, which is
D3(c)'s own measured figure, the one miss being the token D3(c) already names
as reachable by no adjacency rule at all; punctuation-stripped 0.

ONE PACKET FIGURE IS NOT REPRODUCED, AND IT IS A DIFFERENCE OF INSTRUMENT
RATHER THAN A DEFECT.
Patch B's rule (g) design record names "Expected at
b1df95ee: 78 inclusive → 57 filtered, 21 flagged ENTRIES"
; the CLI gives
78 → 43 filtered, 35 flagged entries. The 21/57 pair is the HAND
instrument's narrow same-line adjacency rule, which the evidence itself records
as MISSING 14 further cross-repository tokens
(measurement-b1df95ee.md:375). D3(c) ships the WIDER rule the evidence
recommends on its measured precision (:461), and 21 + 13 + 2 ≈ 35 is exactly
what that rule should give. Rule (g)'s normative content — the arithmetic row
prints REMAINDER ENTRIES carrying the flag, never the corpus-wide figure — is
implemented, and both numbers print, separately labelled.

The head reading

Taken by the shipped CLI at 18c4222c, clean tree. Not committed into the
tree
: it is quoted here and nowhere in it, which is why the population's own
output-path fence is structural today.

root         the work-tree top the named path resolved to, printed beside the head
population   5,510 tracked entries | 3,005 tracked ENTRIES in scope | 3,001 FILES read
skips        4 not a file | 0 link leaving the root | 0 undecodable  (arithmetic closes)
tokens       605 distinct
outcomes     517 RESOLVED (76 relocated) | 76 DANGLING identity half | 6 DANGLING file half
             0 AMBIGUOUS | 6 NOT A PACKET REFERENCE
raw-absent   162 = 76 repaired + 76 identity half + 6 file half + 0 ambiguous
                 + 4 not-a-packet-reference
             158 of those under choice (2), which holds NOT-A-PACKET-REFERENCE
             out of the remainder population
remainder    INCLUSIVE 82 TOKENS / 55 IDENTITIES
             FILTERED  43 TOKENS / 28 IDENTITIES
             82 inclusive = 43 filtered + 39 REMAINDER ENTRIES carrying the flag
             (83 tokens carry the flag corpus-wide — a larger and a different
              quantity, and never the arithmetic row's term)
classes      truncated 5 | punctuation-stripped 0 | fixture-path 19 | unclassified 58

The argument surface, exactly as D2 fixes it

python3 scripts/report-citation-remainder.py [REPO_ROOT]
    [--json] [--all] [--tokens] [--history]
    [--include PREFIX ...] [--exclude PREFIX ...]

REPO_ROOT defaults to the working directory and is resolved to its work-tree
top
, so a run named at or taken from a subdirectory reads the repository that
subdirectory stands in, and the reading states which root that was. --json is
a BOOLEAN output-format flag taking no path: it writes to STDOUT and a caller
redirects. There is no --fail-on and no --fix, and
test_there_is_no_fail_on_flag enumerates every option string the parser
returns and asserts the set is exactly {-h, --help, --json, --all, --tokens, --history, --include, --exclude}. Exit is the two-case contract: 0 whatever it
finds, non-zero only where the report COULD NOT RUN.

WHAT THIS PULL REQUEST DELIBERATELY DOES NOT DO

It does not wire the nightly — .github/workflows/doc-health-reusable.yml
is untouched; that is tasks.md § 2.2 and slice R2. It does not commit a
reading
— § 2.3's evidence is slice R3. It does not archive anything,
promote any requirement, or shut #1053
(this pull request carries no closing keyword, by design) — § 3 is a later pull request on a
later word, and #1053 closes only in the archive pull request. § 2.4 stays
unticked too: a merged-plus-green pair is not a thing this pull request can tick
about itself.

D7's scope fences. The merge makes them exact: this branch's merge base IS
origin/main, so the diff below is precisely this branch's own contribution and
nothing of main's.

$ BASE=$(git merge-base origin/main HEAD)     # 4ee21c40 == origin/main
$ git diff $BASE..HEAD -- scripts/packet_reference.py | wc -l            0
$ git diff $BASE..HEAD -- scripts/validate-pin-registrations.py | wc -l  0
$ git diff $BASE..HEAD -- scripts/doc_health | wc -l                     0
$ git diff $BASE..HEAD -- openspec/specs | wc -l                         0
$ git diff $BASE..HEAD -- .github/workflows | wc -l                      0
$ git diff --name-only $BASE..HEAD
openspec/changes/add-citation-remainder-report/tasks.md
scripts/report-citation-remainder.py
tests/citation_remainder/test_report_citation_remainder.py

Validators, at 18c4222c

command result
python3 -m pytest tests/citation_remainder -q 130 passed
python3 -m pytest tests/citation_remainder tests/proposal-support tests/sequenced_after tests/doc-health -q 2,458 passed, 297 subtests passed, 0 failed — no inherited red left
python3 scripts/validate-sequenced-after.py . exit 0 — archive-date agreement passed; the three inherited failures are gone with #1099
OPENSPEC_TELEMETRY=0 openspec validate add-citation-remainder-report --strict Change 'add-citation-remainder-report' is valid, exit 0
OPENSPEC_TELEMETRY=0 openspec validate --all --strict 109 passed, 2 failed — the two pre-existing (add-chain-attestation, add-composed-view-authoring); no third
python3 scripts/validate-code-surface.py . exit 0 — every active declaration's head is admitted
python3 scripts/report-citation-remainder.py . exit 0, human table
python3 scripts/report-citation-remainder.py . --json | python3 -m json.tool parses
python3 -m py_compile on both new files exit 0

Design choices the delta leaves open, each recorded rather than assumed

  1. "Stands unmodified at that head" is computed by git diff --quiet HEAD,
    not by git status --porcelain, whose untracked ?? lines would mark the
    tree modified over files this report never reads — and only its documented
    statuses 0 and 1 are read as answers.
  2. A named root is RESOLVED to its work-tree top, not refused. The operand
    defaults to cwd, so refusing would fail the ordinary run taken from anywhere
    but the top, and the two-case contract reserves non-zero for a report that
    could not run.
  3. Every class predicate and signal matcher lives in ONE DELIMITED SECTION of
    the single script
    , one function each, rather than in a second module: the
    packet names one script file three times and a module split is a scope move
    that takes a ruling.
  4. A tracked path's resolved path is computed by a chain walk of this script's
    own
    , not by Path.resolve(): the term's extent is a fact about the path,
    and resolve() answers about what stands at one. Every component is read —
    the entry's own and every parent's — and .. is applied to what has been
    resolved so far rather than cancelled against unread text.
  5. The locator is judged on the spelling AS WRITTEN, not on the normalized
    token, which is the only reading under which the grammar's trailing-slash
    refusal can fire at all — the normalization strips it before deduplication.
    The consequence is stated: a directory citation written in a custody locator
    fires no signal.
  6. An owner segment is whatever stands between opsx: and the token, so
    opsx:a/b/<token> is an owner containing / and fires nothing — which is
    what the malformed-locator scenario's own bullet asks for, and what the base
    sentence's "immediately preceded by … one owner segment and /" requires.
  7. punctuation-stripped fires on the FULL-STOP strip and not on the
    separator strip.
    The trailing path separator is the one character the
    grammar admits in no identifier, so an entry is not labelled for a strip that
    could suppress no valid citation.
  8. The bare-qualifier word is read THROUGH the decoration standing between it
    and the token.
    Measured: two of the fourteen hand-found cross-repository
    tokens at b1df95ee are spelled codexFactory `<token>`.
  9. Probe (iii)'s continuation must carry a CLOSING quote of its own.
  10. The remainder is the raw-path-absent tokens whose outcome is DANGLING or
    AMBIGUOUS
    , which is the recipe's own population.
  11. A token that is not a remainder entry carries class: null under
    --all rather than a fifth label, which is Patch B's own sentence.
  12. The corpus-wide flagged-token figure prints on its own labelled line,
    outside the arithmetic row, which prints REMAINDER ENTRIES carrying the flag.
  13. The --json object carries D2's enumerated fields and a few beside them,
    now including a top-level root: D2 enumerates what the object carries, not
    what it may not.
  14. --history probes the identities a reading LISTS, not every identity in
    the corpus.
  15. Both raw-path-absent readings print, each labelled with the choice it
    applies
    , so a reader does not read a difference of definition as a drift in
    the corpus.
  16. The git bound is 30 seconds at the one sink, the estate's own number,
    with 60x measured headroom over the heaviest git this report runs.

Refs #1053.

🤖 Generated with Claude Code

brettheap and others added 5 commits September 17, 2026 16:34
…md 2.1)

The whole of `scripts/report-citation-remainder.py`, realizing the ratified
delta's five requirements over the shipped resolver, which it imports
UNCHANGED and consumes as a library:

* THE POPULATION — `git ls-files -s` tracked ENTRIES, the three default
  exclusions each with its stated reason, the report's own output path that no
  refinement may re-admit, and `--include`/`--exclude` under the three promoted
  refinement semantics (segment-boundary matching, re-admit-not-replace,
  removal-applied-last-and-wins). FOUR skip terms, not three: an entry skipped
  because its path leaves the repository root once resolved is a tracked FILE
  that reaches no decoder and has its own term, printed even at zero.
* THE TOKEN GRAMMAR — the promoted extraction pattern, the trailing separator
  stripped unconditionally because the grammar admits `/` in no identifier, and
  resolution tried FIRST before any trailing character the change-id grammar
  DOES admit is stripped. One record per TOKEN; `raw` per OCCURRENCE.
* THE FIVE SIGNALS AND THE WINDOW — the citing line plus the three lines above
  it, the closed repository-name vocabulary, case-insensitive matching, and one
  matcher function per signal in one delimited section beside the class
  predicates. `possibly-cross-repo` is a FLAG and never a class.
* THE CLASSES — the closed four, with `truncated`'s three measured probes, its
  ALL-occurrence rule and its union with the trailing-hyphen arm;
  `punctuation-stripped`'s three-part firing condition; `fixture-path`'s closed
  four locations under the same ALL rule; and the precedence, normalization
  over location and `truncated` over `punctuation-stripped`.
* THE OUTPUT — two parts in a fixed order, counts then the itemized remainder,
  identity-nested by default and never grouped by class in either mode; the
  `--json` shape D2 enumerates; and the two-case exit contract, 0 whatever it
  finds and non-zero only where the report COULD NOT RUN.

No path under the changes root is spelled in this file: every example is
written with an angle-bracket placeholder, so the report mints no token of its
own and the remainder it reports does not move by its own act.

Refs #1053.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
MEASURED AGAINST THE HAND CLASSIFICATION, NOT REASONED. The bare-qualifier
signal read the last whitespace-delimited run of the text before the token and
required that text to END in whitespace, so the spelling this corpus actually
writes a qualified citation in — the qualifier, a space, then the token inside
backticks — fired nothing: the run immediately before the token was a lone
backtick and the qualifier was the run before that.

Two of the fourteen cross-repository tokens the evidence's hand read found at
`b1df95ee` are exactly that shape, both qualified `codexFactory` immediately
before a backticked token, and both went unflagged. With the decoration
stripped from the text between the word and the token before the run is read,
the flag now catches 13 of the 14 with 2 false positives among the other 43 —
which is `design.md` D3(c)'s own measured precision for this rule,
reproduced by the shipped code rather than quoted from the design. The one it
misses is the one the design already names as reachable by no adjacency rule
at all.

A GLUED PATH PREFIX NEEDS NO SPECIAL CASE: `/` is not a decoration character,
so a path-joined prefix survives the strip whole, fails the vocabulary as the
path it is, and is judged by the path-joined signal, which is the signal
written for it.

Refs #1053.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
`tests/citation_remainder/test_report_citation_remainder.py` (NEW): one test
per `#### Scenario:` block, its docstring naming the scenario verbatim, in five
sections that follow the delta's five requirements. Fixtures are built in
`tmp_path` with real git — the population recipe is `git ls-files`, so a
committed fixture subdirectory would list THIS repository's files rather than
the fixture's, a nested `.git` cannot be committed at all, and `tests/` is one
of the population's own three exclusions, so a scratch tree is the only shape
that can answer this subject. No `conftest.py` is added beside them: `pytest.ini`
anchors the rootdir so the suite-wide hermeticity guard reaches this directory,
and a directory `conftest.py` would hijack the ambient `conftest` module name.

THREE DEFECTS THE TESTS FOUND IN THE SCRIPT, each fixed here:

* THE HUMAN REPORT WROTE TO THE STREAM THIS MODULE WAS IMPORTED WITH. `out` was
  defaulted `sys.stdout` in the signature, which binds at import; every caller
  that redirects the stream — the suite's own readers, and a caller capturing a
  reading in process — got an empty report and no error. Resolved at call time
  now.
* THE SPLIT-STRING-LITERAL PROBE REQUIRED THE TOKEN TO BE THE LAST CHARACTER ON
  ITS LINE, so it fired on no implicit concatenation at all: the shape it is
  written for closes its literal at the end of the line it splits, and the
  closing quote stands after the token. A closing quote is part of ending the
  line, and a line left open is admitted as before.
* EVERY NORMALIZATION IS NOW PRINTED IN ITS OWN ROW of the human report, not
  only as the difference between an occurrence's raw spelling and the token. A
  reader who cannot see that the tool changed the token cannot check the tool,
  and the scenario asks for the normalization to be RECORDED rather than
  inferable.

96 tests, all green.

Refs #1053.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
THE TICK RULE'S OWN FIRST CLAUSE: *"a `[x]` below is either a diff in THIS pull
request or a measurement recorded verbatim"*. § 2.1's diff lands in this pull
request, so the box is ticked here and the record beside it carries the
measurement rather than a claim: the two files and their line counts, 63 of 63
scenarios each named by the test that proves it, the reproduction at
`b1df95ee` to the token, the three probes' precision against the hand
classification, and the Δ = 0 mint check at this branch's merge base and head.

§§ 2.2, 2.3 and 2.4 STAY OPEN and are not ticked against an intention: the
nightly wiring is a later slice, the committed reading is the slice after that,
and the green evidence is a fact about a merge that has not happened.

THE PROPOSAL PULL REQUEST'S OWN SCOPE SENTENCE IS LEFT EXACTLY AS RATIFIED. *"NONE
OF § 2 IS IN THIS PULL REQUEST"* was true of the pull request that filed the
packet and is a record of it; the note added beneath it is an ADDENDUM saying
realization has since opened in the later pull request that same heading names,
and it moves no decision.

Refs #1053.

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 17, 2026 16:56

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

Sorry @brettheap, your pull request is larger than the review limit of 150,000 diff characters

brettheap and others added 3 commits September 17, 2026 17:01
`--history` is opt-in on a MEASURED cost, and the probe was running over every
identity in the corpus rather than over the identities the reading carries: on
this tree that is some five hundred `git log --all --diff-filter=A` invocations
to answer a question about entries the output does not list, where the
measurement D2 quotes ran 38. The default listing is the remainder, `--all`
makes it every token, and the probe now follows the listing in both — which is
the shape D2 states ("each identity record ... gets a `history` field") at the
cost D2 measured.

Refs #1053.

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

The five-term identity closes over EVERY token with no raw path; the figure the
earlier readings of this population publish holds the resolver's fifth answer
OUT, on this delta's own choice (2). The two differ by exactly the count of
NOT-A-PACKET-REFERENCE tokens with no raw path — four in this tree — and a
report printing only the first invites a reader comparing it against an earlier
point in the series to read a four-token drift that is a difference of
definition and not of corpus.

Refs #1053.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
The tick rule's own standard: a `[x]` carries a measurement, and a measurement
that drifted by fourteen lines while the branch was still being written is not
one. Re-counted at the head this record sits on.

Refs #1053.

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

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

Unresolved moderate correctness findings remain in the reporting CLI, plus an inconsistent acceptance record.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds a standalone citation-remainder reporting CLI, comprehensive tests, and the §2.1 realization record without nightly integration.

Changes:

  • Implements human/JSON reporting, filtering, classification, and history probing.
  • Adds 96 tests covering specification scenarios and live-corpus invariants.
  • Records realization evidence in tasks.md.
File summaries
File Review summary
tests/citation_remainder/test_report_citation_remainder.py Adds CLI and behavior coverage; no final comments.
scripts/report-citation-remainder.py 8 moderate findings: quote-aware apostrophe parsing; ambiguous-token listing; raw-token split probing; parenthetical whitespace grammar; Git failure propagation; NOT_A_PACKET_REFERENCE resolution handling; adjacent opsx: matching; read-error handling. 1 nit: rename the --all output heading to ALL TOKENS.
openspec/changes/add-citation-remainder-report/tasks.md Nit (3 votes): acceptance evidence reports 602 tokens/154 raw-path-absent versus the stated 600/157 run; update or pin the record consistently.
Review details

Suppressed comments (8)

scripts/report-citation-remainder.py:790

  • _inside_string_literal treats every unescaped apostrophe as a quote delimiter, including apostrophes in prose. For example, a file containing it's openspec/changes/add-split/prop followed by "osal.md" makes this probe return true and falsely classes the unresolved prose citation as truncated, even though it is not inside a string literal. The probe needs quote-aware parsing (or at least to ignore apostrophes embedded in words) to preserve the predicate's meaning.
            if character == quote:
                count += 1
            index += 1
        if count % 2 == 1:
            return True

scripts/report-citation-remainder.py:1303

  • The default listing drops AMBIGUOUS tokens whose raw path exists. An identity claimed by both an active and archived packet is still AMBIGUOUS even when openspec/changes/<id>/proposal.md exists; reading.remainder therefore excludes it and the default report only counts the outcome. The requirement says AMBIGUOUS must be itemized, while --all is only supposed to add resolved and not-a-packet-reference entries. Include ambiguous records in the default listing without changing the raw-path-absent remainder counts.
    rather than lists."""

scripts/report-citation-remainder.py:1037

  • This passes the normalized token into the split-literal probe, so a raw match ending in . or / is shortened before the two source lines are rejoined. For example, .../prop. followed by "osal.md" is rejoined as .../proposal.md instead of the actual .../prop.osal.md, causing the specified resolving split-path probe to miss and leave the entry misclassified. Rejoin the raw spelling while keeping the normalized token for resolver/deduplication.
    rejoined = probe_split_string_literal(lines, lineno, end, token, resolves)

scripts/report-citation-remainder.py:722

  • The folded parenthetical grammar permits at most one space before ( and then requires the repository-name member itself; whitespace inside the parentheses is not part of that form. Calling .strip() makes inputs such as ( codexFactory ) fire the cross-repository signal even though they should be rejected, producing a false flag. Do not trim the captured inner text before applying the decoration rules.
    inner = match.group("inner").strip()

scripts/report-citation-remainder.py:1080

  • Resolution.ok treats both RESOLVED and NOT_A_PACKET_REFERENCE as successful, but this helper only returns true for RESOLVED. A tracked non-packet path such as openspec/changes/README.md. can therefore be normalized by stripping its final dot, turning an otherwise out-of-remainder path into a dangling token. Use the resolver's ok property here so the resolve-first safeguard also covers the resolver's fifth, path-resolved outcome.
        return resolution_of(token).status == RESOLVED

scripts/report-citation-remainder.py:707

  • This matcher searches the entire prefix before the token, but the grammar requires the opsx:<owner>/ prefix to be immediately adjacent to the citation. A line such as opsx:owner/ unrelated text openspec/changes/... will therefore flag the later, unrelated token. Anchor the match to the end of line[:start] (or add $ to the expression).
    return CUSTODY_SCHEME_RE.search(line[:start]) is not None

scripts/report-citation-remainder.py:360

  • The population contract distinguishes a file that is not valid UTF-8 from an unreadable tree, but this catches OSError as skipped_undecodable and still exits successfully. Permission errors, I/O failures, or a file disappearing during the read are therefore reported as a valid reading with missing data instead of taking the required could-not-run path; only UnicodeDecodeError should be counted as undecodable, while read errors should raise CouldNotRun.
        try:
            text = target.read_bytes().decode("utf-8")
        except (UnicodeDecodeError, OSError):
            population.skipped_undecodable.append(entry.path)
            continue

scripts/report-citation-remainder.py:1470

  • When --all is used, listed_records includes resolved and NOT_A_PACKET_REFERENCE records, but this section is still headed REMAINDER, ITEMIZED. The output label then contradicts the option's documented behavior and can cause readers to treat the extra rows as remainder findings; use an ALL TOKENS heading for that mode in both grouping branches.

    write("\nCLASSES (counted in TOKENS)\n")
    for name in CLASS_VOCABULARY:
        write(f"  {name:<24} {counts['classes'][name]}\n")

  • Files reviewed: 3/3 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/report-citation-remainder.py Resolved
Copilot AI review requested due to automatic review settings September 17, 2026 17:03
`REPO_ROOT` is caller-supplied text and every git this report runs is one call,
so the normalization belongs AT THE SINK where it cannot be forgotten rather
than only at the caller: an absolute path cannot begin with `-` and therefore
cannot be read by git as an option however the caller spelled it. The refusal
beside it is unreachable for a resolved path and is kept as the assertion it is
— a root that somehow reached git as an option is a run this report could not
take, which is the one non-zero exit it has.

Found by SonarCloud on this pull request (`pythonsecurity:S8705`, command
argument injection, new_security_rating 3 against a threshold of 1), which is
green on this repository's merged pull requests and is therefore a defect of
this branch rather than a standing condition.

The reading is unmoved: the reproduction at `b1df95ee` still reads
2,973 / 2,969 / 571 / 151 / 78 with the same four classes, and the root is
absolute from the reading's first line down, so every path it joins and every
containment test the resolver applies answers about the same tree whatever
directory the report was run from.

Refs #1053.

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

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

Unresolved findings affect error handling, report correctness, and realization evidence.

Review details

Suppressed comments (10)

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

scripts/report-citation-remainder.py:360

  • An I/O failure is being treated as an undecodable text file, so a permission error, disappearing file, or other read failure is counted in skipped_undecodable and the command still exits 0. The contract reserves non-zero status for a report that could not read the tree; catch only UnicodeDecodeError here and propagate OSError as CouldNotRun instead of publishing an incomplete reading.
    scripts/report-citation-remainder.py:782
  • This quote-counting heuristic does not actually determine whether the line ends inside a string literal: an apostrophe in ordinary prose (for example, owner's) increments the single-quote count. If the next line starts a quote and the concatenated path happens to resolve, that prose citation can be incorrectly classified as truncated; the probe needs quote-aware parsing or a narrower context check rather than counting quote characters globally.

openspec/changes/add-citation-remainder-report/tasks.md:433

  • This realization record's Δ=0 figures do not match the acceptance check stated in the PR description: the description reports 600 distinct tokens and 157 raw-path-absent tokens at both base and head, while this note records 602 and 154. Because these numbers are the packet's mechanical self-counting gate, the record is currently not reproducible; please rerun the check and update the record (or correct the PR description) so both sources name the same reading.
      block reads identically at this branch's merge base and at its head — 602
      distinct tokens, 154 raw-path-absent, 81 inclusive remainder on both
      sides. Δ = 0.

openspec/changes/add-citation-remainder-report/tasks.md:406

  • This realization record repeats the same unsupported 63-scenario claim: the checked-in spec currently has 43 scenarios, not 63, while Patch B's spec changes are absent from this three-file diff. As written, the § 2.1 tick records coverage for requirements this branch does not carry; include the folded spec or correct the realization record to the actual contract.
      the scenario verbatim: 63 of 63 across the five requirements, counted
      mechanically against `specs/packet-citation-report/spec.md` rather than

scripts/report-citation-remainder.py:1149

  • When --history is enabled, a failed git log is converted to an empty result because code is ignored. The output then falsely reports ever_tracked: false instead of taking the required non-zero 'could not run' path, which can silently turn a repository/history failure into a misleading reading. Propagate a non-zero status as CouldNotRun here.
    end in `/*` or it matches nothing on any input. `--reverse` so the FIRST
    line is the OLDEST add-event, `--abbrev=8` so both shas are eight
    characters everywhere.

    `records` IS WHAT THE READING WILL LIST AND NEVER EVERY TOKEN IN THE

scripts/report-citation-remainder.py:352

  • packet_reference._contained returns None both when a path escapes the root and when resolution fails (for example, a symlink loop or unreadable segment), but every None is counted here as skipped_link_leaving_root. Such an entry inflates the out-of-root term and hides a tree-read failure; distinguish those cases before assigning this skip bucket.
    about its TARGET, so an implementation that asks only that question reports
    text that is not this corpus's as this corpus's citations. The containment
    test is the RESOLVER'S OWN — resolve the path, then require it to stay
    under the root — applied to a tracked entry for the same reason it is

scripts/report-citation-remainder.py:439

  • The resolve-first safeguard only treats RESOLVED as success, but packet_reference.Resolution.ok explicitly includes NOT_A_PACKET_REFERENCE because that outcome successfully hands a real path back to the caller. A real non-packet file such as openspec/changes/README.md. would therefore be rewritten to .../README.md before deduplication even though its extracted path was already handled. Keep the packet-resolution predicate needed by the split-literal probe, but use a separate ok/caller-path predicate for trailing-full-stop normalization.
    rather than about the record. A trailing character the grammar admits and
    this specification names no normalization for is LEFT WHERE IT STANDS: `-`,
    `_`, a letter and a digit are all admitted and none is stripped here, the
    hyphen's own suspicion being a CLASS the class predicates below decide and
    never a strip.

scripts/report-citation-remainder.py:1061

  • git diff --quiet HEAD returns 1 for ordinary differences, but values greater than 1 indicate that Git could not perform the comparison. Treating every non-zero value as MODIFIED makes a failed diff look like a valid reading and still exits 0, contrary to the contract that non-zero means the report could not run. Handle 0/1 separately and raise CouldNotRun for other statuses.
    """The whole reading, from the tracked-entry listing to the classified
    remainder."""

scripts/report-citation-remainder.py:1477

  • With --all, listed_records() includes resolved and NOT_A_PACKET_REFERENCE records, but this hard-coded heading still labels the section as only the remainder. The human output therefore misstates what it is itemizing; make the heading say ALL TOKENS when show_all is true (and apply the same correction to the identity-grouped heading below).
          f"{counts['remainder_inclusive_tokens']} inclusive = "

tests/citation_remainder/test_report_citation_remainder.py:9

  • The branch being reviewed has only 43 #### Scenario: headings in specs/packet-citation-report/spec.md, and that spec is not among this PR's three changed files. Therefore the claim that these tests cover “63 of 63” scenarios verbatim is false here: 20 tests implement Patch B behavior that is not in the shipped contract. Fold the spec into the branch/base before making this coverage claim, or narrow the tests and record to the 43 scenarios actually present.
checking coverage reads one place. The delta carries 63 `#### Scenario:` blocks
across 5 `### Requirement:` blocks, and each one's test names it verbatim in its
first line.
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 17, 2026 17:10
1,612 lines after the absolute-root fix. The tick rule's standard is a
measurement, and a measurement is re-taken when the thing it measures moves.

Refs #1053.

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

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

Several correctness and reproducibility issues remain, along with inconsistent realization records.

Review details

Suppressed comments (14)

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

scripts/report-citation-remainder.py:663

  • search scans the entire prefix but never checks that the match ends at start, so an earlier external forge URL on the same line makes a later unrelated citation fire forge-url. That violates the signal's "immediately preceded" grammar and can inflate the flagged counts; require the URL match to end at the token and add a separated-text regression case.

This issue also appears on line 721 of the same file.
scripts/report-citation-remainder.py:1500

  • --all makes listed_records include resolved and NOT-A-PACKET-REFERENCE records, but both human headings here still say REMAINDER. The output therefore labels non-remainder entries as remainder items; make the heading conditional on show_all in both grouping branches.

openspec/changes/add-citation-remainder-report/tasks.md:433

  • This landed realization record disagrees with the PR's stated merge-base/head acceptance reading: the description reports 600 distinct tokens and 157 raw-path-absent tokens at both points, while these lines record 602 and 154. Please update the record to the measured values used by the acceptance claim; otherwise the packet contains two incompatible Δ=0 baselines.
      block reads identically at this branch's merge base and at its head — 602
      distinct tokens, 154 raw-path-absent, 81 inclusive remainder on both
      sides. Δ = 0.

openspec/changes/add-citation-remainder-report/tasks.md:402

  • The realization record says the new script is 1,594 lines, but the changed file ends at line 1,612. This makes the landed evidence record inaccurate (and the same stale count is repeated in the PR description); update it from the checked-out file after the final change set is fixed.
      `scripts/report-citation-remainder.py` (NEW, 1,612 lines) and

openspec/changes/add-citation-remainder-report/tasks.md:406

  • This realization record is not reproducible from the checked-in packet: openspec/changes/add-citation-remainder-report/specs/packet-citation-report/spec.md currently has 43 #### Scenario: blocks, while this record claims 63 of 63 and the test module makes the same claim. Until Patch B's 20 scenario blocks are actually present on this branch, the tick and its coverage statement overstate what this realization is checked against.
      lines, 96 tests, all green). ONE TEST PER SCENARIO, its docstring naming
      the scenario verbatim: 63 of 63 across the five requirements, counted
      mechanically against `specs/packet-citation-report/spec.md` rather than

scripts/report-citation-remainder.py:721

  • This has the same non-adjacency bug as the forge matcher: search can find opsx:owner/ earlier in the line even when unrelated text appears before the citation. The result then flags a token that is not written in the custody-locator scheme required by the grammar; require the match to end at start.
    return CUSTODY_SCHEME_RE.search(line[:start]) is not None

scripts/report-citation-remainder.py:1079

  • git diff --quiet returns 1 for a dirty tree, but other non-zero values indicate that the command failed. Treating every non-zero as MODIFIED can publish a reading after a failed diff instead of taking the required "could not run" path; distinguish status 1 from command errors and raise CouldNotRun for the latter.
        dirty, _, _ = git_status(root, "diff", "--quiet", "HEAD")
        tree_unmodified = dirty == 0

scripts/report-citation-remainder.py:1165

  • When git log fails, this converts the failure into an empty result and reports ever_tracked: false, which is indistinguishable from a successful probe finding no history. Under --history that is a false historical claim; route this command through git() or raise CouldNotRun whenever its status is not zero.
        code, out, _ = git_status(
            root, "log", "--all", "--diff-filter=A", "--reverse",
            "--abbrev=8", "--format=%h", "--",
            f"{CHANGES_ROOT}/{identity}",
            f"{CHANGES_ROOT}/archive/*-{identity}/*")

scripts/report-citation-remainder.py:374

  • Catching OSError here treats permission failures, I/O errors, and disappearing files as ordinary undecodable files, so the report exits 0 and publishes a partial reading even though it could not read the tree. Only UnicodeDecodeError should enter the skipped-undecodable bucket; propagate an OSError as CouldNotRun so the required non-zero failure is preserved.
        except (UnicodeDecodeError, OSError):
            population.skipped_undecodable.append(entry.path)
            continue

scripts/report-citation-remainder.py:200

  • These Git subprocesses inherit ambient GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE, alternate object-directory, and replacement-object settings, so a caller can ask for one root while ls-files, diff, or log reads another repository state. Exact Git readers in this repository sanitize those variables and disable replacement objects (for example scripts/validate-carve-manifest.py:844-865); this report should use the same sanitized environment to keep its reading tied to root.
        result = subprocess.run(["git", "-C", where, *args],
                                capture_output=True, text=True)

scripts/report-citation-remainder.py:793

  • _inside_string_literal counts quote characters independently by type, so a balanced " inside a single-quoted string (or a balanced ' inside a double-quoted string) can make this return True even though the token is outside any literal. If the next line begins a quote and the rejoined path resolves, ordinary prose can then be misclassified as truncated; track one active quote delimiter instead.
def _inside_string_literal(text: str) -> bool:
    """Whether `text` ends INSIDE a string literal — an odd number of unescaped
    quotes of either kind."""
    for quote in ("'", '"'):
        count = 0

scripts/report-citation-remainder.py:739

  • The .strip() here accepts whitespace inside the parenthetical, so ( codexFactory ) is treated as a repository name even though the grammar requires the inner text itself to be one vocabulary member under the decoration rules. That creates false possibly-cross-repo flags for parentheticals with separated prose; pass the raw inner text to the existing decoration-aware predicates instead.
    inner = match.group("inner").strip()
    if not inner or _names_this_repository(inner):
        return False
    return _is_vocabulary_name(inner)

scripts/report-citation-remainder.py:1125

  • For a placeholder-after-token probe (and for the trailing-hyphen fallback), truncation_evidence remains None, so this branch emits an empty class_evidence and the human output has no evidence: line even though the entry was classified truncated. The requirement says mechanically assigned classes must name their evidence; preserve the </hyphen predicate or the occurrence location when constructing this evidence.
                record.class_evidence = tuple(
                    sorted({o.truncation_evidence for o in record.occurrences
                            if o.truncation_evidence}))

tests/citation_remainder/test_report_citation_remainder.py:9

  • The module-level coverage claim is false for the current tree: the referenced packet spec contains 43 scenarios, not 63, so this statement cannot be mechanically verified against the file it names. Land the Patch B spec before asserting 63/63, or update the claim to match the spec actually shipped with this realization.
EVERY SCENARIO THE DELTA STATES IS REALIZED BY A TEST BELOW WHOSE DOCSTRING
NAMES IT, and the five requirements are kept apart in five sections so a reader
checking coverage reads one place. The delta carries 63 `#### Scenario:` blocks
across 5 `### Requirement:` blocks, and each one's test names it verbatim in its
first line.
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 17, 2026 17:17

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

Multiple moderate implementation issues and stale realization evidence remain unresolved.

Review details

Suppressed comments (11)

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

scripts/report-citation-remainder.py:793

  • This parity check treats an apostrophe in ordinary prose as an opening string delimiter. For example, a line such as It's openspec/changes/add-nosplit/prop followed by "osal.md" is considered a split literal; if the rejoined path resolves, a normal dangling citation is incorrectly classified as truncated. The probe needs quote-state parsing that distinguishes literal delimiters from prose apostrophes/comments.
    openspec/changes/add-citation-remainder-report/tasks.md:406
  • The realization record says 63 of 63 scenarios, but the current specs/packet-citation-report/spec.md contains 69 #### Scenario: blocks and this test file contains 69 matching scenario docstrings. Please update this committed coverage claim—and the PR description—to the mechanically measured 69/69 value so the realization record is not stale.

openspec/changes/add-citation-remainder-report/tasks.md:432

  • The realization record's Δ=0 figures do not match the acceptance figures stated for this branch in the PR description: the base/head probe is reported as 600 distinct tokens and 157 raw-path-absent, not 602 and 154. Please update this record (or identify the separate run) so the task evidence is reproducible rather than publishing stale counts.
      block reads identically at this branch's merge base and at its head — 602
      distinct tokens, 154 raw-path-absent, 81 inclusive remainder on both

scripts/report-citation-remainder.py:288

  • git ls-files -s emits one row per index stage for an unmerged path. Because this parser appends every row, a conflicted working tree (which this report explicitly supports as a dirty tree) counts and reads the same tracked path multiple times, inflating the population arithmetic and duplicating occurrences. Deduplicate by path while retaining one mode, matching the git ls-files path population.
    for line in git(root, "ls-files", "-s", "-z").split("\0"):
        if not line:
            continue
        meta, _, path = line.partition("\t")
        if not path:

scripts/report-citation-remainder.py:736

  • inner.strip() makes whitespace inside the parentheses part of the accepted signal grammar. A spelling such as ( codexFactory ) therefore fires, although the fixed rule allows at most one space before ( and then requires the contents themselves to be a vocabulary member; this creates false cross-repository flags. Validate the captured inner text without stripping its whitespace.
    inner = match.group("inner").strip()

scripts/report-citation-remainder.py:1167

  • A failed git log is silently converted into ever_tracked: false, so --history can report history: never tracked when the probe actually errored (for example, because the repository's history is unreadable). An empty successful log should mean never tracked, but a nonzero status should propagate as CouldNotRun instead of fabricating history.
        code, out, _ = git_status(
            root, "log", "--all", "--diff-filter=A", "--reverse",
            "--abbrev=8", "--format=%h", "--",
            f"{CHANGES_ROOT}/{identity}",
            f"{CHANGES_ROOT}/archive/*-{identity}/*")
        lines = [line.strip() for line in out.splitlines() if line.strip()] \
            if code == 0 else []

scripts/report-citation-remainder.py:1079

  • git diff --quiet returns 1 for expected differences, but codes greater than 1 indicate a Git error. Treating every nonzero result as MODIFIED lets a failed diff produce a normal exit-0 reading with an invented tree state, contrary to the two-case exit contract. Raise CouldNotRun for error codes other than 0 and 1.
        dirty, _, _ = git_status(root, "diff", "--quiet", "HEAD")
        tree_unmodified = dirty == 0

scripts/report-citation-remainder.py:663

  • signal_forge_url searches any URL in the prefix but does not require the match to end at start. A URL such as https://github.com/opensoft/codexFactory/blob/main/ followed by prose and then an in-tree citation will therefore flag that citation, even though the grammar requires the URL to be immediately before the token. Anchor the URL match to the token boundary.
    match = FORGE_URL_RE.search(line[:start])
    if match is None:
        return False
    return match.group("repo").lower() in REPOSITORY_VOCABULARY

scripts/report-citation-remainder.py:721

  • signal_custody_locator has the same non-adjacency problem: it finds an earlier opsx:<owner>/ anywhere on the line and can flag a later unrelated citation. The custody prefix must end immediately before the token, as required by the signal grammar.
    return CUSTODY_SCHEME_RE.search(line[:start]) is not None

scripts/report-citation-remainder.py:1125

  • When truncated is selected by the < probe or by the trailing-hyphen fallback, truncation_evidence is None, so this comprehension leaves class_evidence empty and the human output omits any evidence line. The specification requires every mechanically assigned class to name its path or normalization evidence; preserve a probe/predicate and source-location value for these cases and cover it in the tests.
                record.class_evidence = tuple(
                    sorted({o.truncation_evidence for o in record.occurrences
                            if o.truncation_evidence}))

scripts/report-citation-remainder.py:374

  • This treats every OSError from read_bytes() as an undecodable file, so permission failures, I/O errors, or a file disappearing mid-scan are counted as skipped_undecodable and the report still exits 0 with incomplete counts. Those errors mean the tree could not be read; only UnicodeDecodeError should enter the skipped bucket, while other read failures should raise CouldNotRun.
            text = target.read_bytes().decode("utf-8")
        except (UnicodeDecodeError, OSError):
            population.skipped_undecodable.append(entry.path)
            continue
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

`probe_history` turned a failing `git log` into an empty result list and then
published it as `probed: true, ever_tracked: false` — the sentence *this id
never stood here*, asserted on a history the report never read. An empty walk
and a walk that did not happen are two different facts wanting two different
repairs, and this module already states which exit the second takes: "Every
git this report runs is a READ. A git that fails is a tree this report cannot
read, which is the one non-zero exit it has."

So the probe goes through `git` rather than `git_status`, carrying git's own
stderr into `CouldNotRun`. `git_status` keeps its one caller, `diff --quiet
HEAD`, whose non-zero IS an answer.

Two tests: one patches the report's own subprocess sink so exactly the history
walk fails and every other git still answers, and asserts the run exits
non-zero, that `"ever_tracked": false` is never printed, and that git's message
reaches the caller; one asserts the narrowing costs nothing, a walk that RAN
and found no add event still reading `ever_tracked: false`.

Copilot PRRT_kwDOTAvnrs6jdTNb on PR #1100.

Refs #1053.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 18, 2026 09:31
Brett Heap and others added 3 commits September 18, 2026 09:34
Patch B's bench round two (PR #1097, `7b21491f`) fixes what each of the three
skip terms OWNS rather than what each is named for, so that no tracked entry
falls between two of them: the out-of-root-link term owns exactly the tracked
LINKS whose resolved path stands outside the root, and the non-file term owns
every other tracked entry that is not a readable regular file once resolved.

That made a link's RESOLVED PATH a fact about the path and not about what
stands at it, which `Path.resolve()` cannot answer: it is a filesystem call,
and this term must take a DANGLING link that leaves the root while leaving a
dangling link that does not. So `resolved_entry_path` walks the chain itself —
every step read in turn, each link replaced by its own target text joined onto
the directory it stands in, `..` and `.` normalised away — and returns None
only where the report cannot walk the chain at all, which the spec assigns to
the non-file term and the old `_contained` assigned to the out-of-root one.

Four entry classes move as a result, each of them previously in the wrong term
or in none: a link dangling INSIDE the root (was out-of-root, now non-file), a
chain that loops or cannot be read (was out-of-root, now non-file), a link
resolving to a DIRECTORY inside the root (unchanged, now stated), and a
dangling link resolving OUTSIDE the root (was non-file, now out-of-root).
`entry_disposition` decides all three terms in one place so the extents cannot
drift apart, and the arithmetic closes over every one of them.

Five tests, one per scenario the bench round added, plus the rename the round
made to the scenario that was `A tracked link stands inside the root`.

Refs #1053.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Patch B's bench round one (PR #1097, `0862177e`) replaced probe (iii)'s
description — "the token ends its source line INSIDE A STRING LITERAL" — with a
closed lexical rule, because *inside a string literal* is no predicate over a
corpus written in several languages, each with its own delimiters and escape
syntaxes, and a probe two realizations match differently is a class total two
readings cannot be compared by.

So `_inside_string_literal`, which counted unescaped quotes of either kind and
answered yes to a great deal this probe was never measured against, is gone.
In its place: the occurrence is followed on its own line by ONE quote character,
`"` or `'`, not repeated, which is that line's last non-whitespace character
and closes a literal the same character opened earlier on the same line; the
next line's first non-whitespace character is that same quote, again not
repeated; and the token plus the continuation literal's content, up to its own
closing quote, resolves. A triple quote, a backtick, a prefixed or raw literal,
a backslash in either literal and a continuation opened by the OTHER quote
character are refused, even where the rejoin would resolve.

The rule is pinned to the shape the measurement caught,
`scripts/doc_health/pin_class.py:1248-1249`, and the shipped probe fires on it
in this repository's own corpus, rejoining
`…2026-08-27-add-hermes-customer-subject-` onto
`runtime-contract/evidence/provider-verification.yaml`.

Two tests: one builds the shape in a file that is NOT Python, so the verdict is
reached from the quote characters alone; one parametrizes the seven refusals
over a fixture whose rejoined path WOULD resolve, so what is asserted is the
refusal and not a rejoin that happened to fail.

All 69 of Patch B's scenarios now carry a test that names them.

Refs #1053.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
SonarCloud's security finding on this branch, `pythonsecurity:S8705` (command
argument injection at the one `subprocess.run` every git goes through), was
fixed at `eaeff2b1` and reads CLOSED. These are the maintainability and
reliability findings standing beside it, each a real defect in code this
branch adds rather than a rule to be argued with, and none is suppressed.

`python:S8786`, super-linear backtracking: `PATH_RUN_RE` was a `[...]*$`
pattern SEARCHED over a line prefix, which retries at every start position.
The same answer read backwards from the end is one pass, so `trailing_path_run`
replaces it — same result, no backtracking.

`python:S1172`, six unused parameters: the five signal matchers and
`probe_longer_path` took a uniform `(line, start, end)` and read only part of
it, and `build_population` took a `root` it never touched. Nothing dispatches
over these signatures — `signals_at` names each matcher — so each now takes
what it reads and nothing beside.

`python:S3776`, cognitive complexity in four functions: `build_population`
(18), `take_reading` (17), `json_reading` (17) and `print_human` (27). Split
along seams the code already had rather than by shuffling branches:
`admits`/`output_paths_named_by` carry the refinement verdict,
`record_for`/`class_evidence_for`/`head_and_tree_state` carry one token's
record and the head pair, `_with_history` carries the one key that is absent
rather than null, and `print_human` becomes the four printers its own output
contract already names — header, population, PART 1 counts, PART 2 itemized.

`python:S6353` and `python:S1940`, both in text the probe rewrite touched:
the custody-locator boundary class is now `(?a:\W)`, held to ASCII so it is
the same boundary and not a wider Unicode one, and the negated membership test
went with `_inside_string_literal`.

`python:S9073`, ten composite assertions in the suite: each split, so a red
test names which half failed.

No behavior moves: 111 tests pass before and after, and the human and JSON
runs over this repository are unchanged.

Refs #1053.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Prose only, no behaviour, no test moves. A reflow in the walk's docstring had
left one 138-character line where nothing else in the file passes 86; a
sentence under it still said "not a link that leaves the root" where the term
it describes has stopped being about links; and `locator_path` had one blank
line after it where every other top-level definition in the file has two.

Refs #1053.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

R1 round 3 at 18c4222c — the relaunch after round 2's writer stopped while re-verifying at its own final head. Eight commits including the merge, each pushed as it landed.

PATCH B HAS LANDED AND IS MERGED IN (main c32749c3, merged here at 97dfc78b; main has since advanced to 4ee21c40, now this branch's merge base). The rules this branch had implemented from PR #1097's drafted text are now the ratified delta in the tree, so the tests read the spec rather than a draft. The merge carried one conflict, in tasks.md § 2.1 where main and this branch had each added a paragraph to the same item; both are kept. #1099 landed in the same merge, so the three inherited sequenced_after archive-date failures this branch named for two rounds come in FIXED — there is no inherited red left.

Coverage is 72 of 72, GAPS NONE, counted mechanically against the spec as it stands in this tree. Round 2 closed 69 of 69 against a #1097 tip; three scenarios were added after that tip and one was RENAMED with no behaviour behind it, and the mechanical count caught all four where a hand count would have passed every one:

  • A tracked file stands under a parent that links outside the root — and this one moved CODE. The out-of-root term is now a predicate over the WHOLE TRACKED PATH: entry_disposition had gated it on is_link, on the reasoning that git refuses to track a path beyond a symlink, which is true of the moment a path is added and not of the tree afterwards. A directory can BECOME a link after the files under it were tracked. SYMLINK_MODE went with the gate, its only reader.
  • A well-formed locator carries a multi-segment path / A malformed locator fires no signal — signal (4)'s path half was not being read at all, so opsx:opensoft/<token> fired whatever shape the token had. The empty-segment arm does the work: a repeated slash inside the path and a trailing slash at the end each leave one.
  • The rename, …takes only the links that resolve outside the root → …takes exactly the entries whose resolved path leaves the root, with two rewritten bullets. Its test takes the new title, adds a tracked regular file under a parent link, and reads membership BOTH ways round, entry by entry.

FIVE REVIEW THREADS TAKEN, all replied to and all resolved, three of them real defects reproduced before being fixed:

  • git diff --quiet HEAD's statuses. A head ref naming an object that does not stand in the store exits 128, and every non-zero was read as MODIFIED: the report published ('000…001', MODIFIED) at exit 0 — a tree state nothing had measured, beside a head git had just refused to read. Now 0 clean / 1 modified / anything else CouldNotRun with git's stderr. The bare rev-parse HEAD beside it moved to --verify --quiet, which had the same conflation one line up.
  • A subdirectory root. --is-inside-work-tree accepts one. report docs gave 79 distinct tokens with 78 of 79 in the remainder at exit 0, against 601 and 81 at the root — citations that resolve perfectly well reported DANGLING. Resolved to the work-tree top on the estate's own idiom (sequenced_after.py and scope_globs.py, both _git_toplevel) rather than refused, because the operand defaults to cwd and the two-case contract reserves non-zero for a report that could not run. The reading now states the root it read.
  • No timeout at the git sink. timeout=30 at the one subprocess.run all four of this report's gits go through, TimeoutExpired → CouldNotRun; the estate's own number, with measured headroom (heaviest git 0.46s, ls-files over 5,510 entries 0.007s).
  • The lexical walk's push order — DOES NOT REPRODUCE, measured before answering: pending is a stack popped from its END, so extend pushes onto its TOP and a target is walked before the suffix beneath it. The requested test is added anyway, asserting the exact path, and the orientation is now spelled out at both sites.
  • 72 vs 69 — fixed the other way round: the docstring was right and the tasks.md record was stale.

Δ = 0, taken twice by two instruments at head e170372d against merge base 4ee21c40, both trees clean. The hand instrument reads 604 / 158 / 76 / 82 on both sides, line for line. And the shipped CLI runs as its own control, which is the stronger form: over the base tree where it is untracked and so unread, and over this head where it is tracked and read, 605 / 82 / 43 / 55 / 28 on both — only FILES read moves, by the one file, which is the whole claim. Re-checked at 49c135a2, after the record commit that quotes those figures into a file the population reads, and again at the final head 18c4222c: unmoved at both.

The b1df95ee reproduction, with two figures corrected rather than smoothed. 2,973 / 2,969 / 151 / 73 / 78 / 72 / 6 / 0 all reproduce. Distinct tokens read 572 against the evidence's 571 and NOT-A-PACKET-REFERENCE 5 against its 4 — one token, openspec/changes/archive/.., which the hand instrument folds onto openspec/changes/archive by stripping a dot off a .. segment and the CLI refuses to fold, because rewriting a path that walks UP into a citation OF what it walks up from is inventing the citation. The remainder is unmoved at 78 either way. tasks.md § 2.1 now says so; the earlier record claimed "to the token" and that claim was one round stale.

Not done here, and named: the nightly wiring is slice R2 (§ 2.2), the first committed reading is R3 (§ 2.3), and § 2.4's merged-plus-green pair is not a thing this pull request can tick about itself. Exactly three files change, and every D7 fence is 0 — and the merge makes the fence EXACT, this branch's merge base now being origin/main itself.

The whole local suite is GREEN at this head: pytest tests/citation_remainder tests/proposal-support tests/sequenced_after tests/doc-health -q -> 2,458 passed, 297 subtests passed, 0 failed, in 7m16s. tests/citation_remainder alone is 130 passed over 120 test functions. validate-sequenced-after exit 0, validate-code-surface exit 0, openspec validate add-citation-remainder-report --strict valid, openspec validate --all --strict 109/2 with the same two pre-existing and no third. SonarCloud's quality gate passes. The pull request body is refreshed against all of it.

Lane: openxfactory-1

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

Unresolved moderate findings and coverage/documentation inconsistencies remain before approval.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (8)

openspec/changes/add-citation-remainder-report/tasks.md:473

  • This realization record says only 69 of 72 scenarios are covered and that Patch B has landed on main, while the PR description still claims 69 of 69 and says Patch B has not landed. The current spec/test module and this record are inconsistent with the stated coverage and revision; please reconcile the PR description (including its measurement claims) with this branch before treating the acceptance evidence as reproducible.
      ONE TEST PER SCENARIO, its docstring naming the scenario verbatim: 69 of
      72 across the five requirements, counted mechanically against
      `specs/packet-citation-report/spec.md` rather than by hand — 43 scenarios
      the ratified delta carried plus the 29 Patch B adds, which have LANDED
      (PR #1097, `main` at `c32749c3`), so the count is taken against the spec

scripts/report-citation-remainder.py:207

  • This list still leaves Git's pathspec environment controls inherited from the caller (GIT_LITERAL_PATHSPECS, GIT_NOGLOB_PATHSPECS, GIT_GLOB_PATHSPECS, and GIT_ICASE_PATHSPECS). In particular, --history relies on the wildcard pathspec archive/*-<identity>/*; with literal/no-glob settings it can return an empty log and publish ever_tracked: false for an identity that was tracked. Scrub these variables as well and add the hostile-pathspec case to the environment regression test.
SCRUBBED_GIT_ENVIRONMENT = (
    "GIT_ALTERNATE_OBJECT_DIRECTORIES",
    "GIT_COMMON_DIR",
    "GIT_CONFIG_COUNT",
    "GIT_CONFIG_PARAMETERS",
    "GIT_DIR",
    "GIT_INDEX_FILE",
    "GIT_OBJECT_DIRECTORY",
    "GIT_REPLACE_REF_BASE",
    "GIT_WORK_TREE",
)

scripts/report-citation-remainder.py:1992

  • When --all is used, listed_records includes RESOLVED and NOT-A-PACKET-REFERENCE records, but both human headings below still say REMAINDER. This makes the human output mislabel entries that the JSON correctly identifies as all-tokens; make the heading say ALL TOKENS when show_all is true (for both grouping modes).
    if by_token:

scripts/report-citation-remainder.py:518

  • Because this uses git ls-files -s, an unmerged index produces one row per stage for the same path. Appending every row here makes a dirty/conflicted worktree count and read the same working-tree file multiple times, duplicating its occurrences even though this report explicitly supports modified trees; deduplicate paths or define a deliberate stage-handling policy before building the population.
            continue
        meta, _, path = line.partition("\t")
        if not path:
            continue
        rows.append(TrackedEntry(path=path, mode=meta.split(" ", 1)[0]))

scripts/report-citation-remainder.py:281

  • git ls-files -s -z can legally return a tracked pathname containing non-UTF-8 bytes. With text=True and the default strict decoder, subprocess.run raises UnicodeDecodeError before this sink returns, but git_status only translates TimeoutExpired and OSError; the CLI then emits a traceback instead of the required controlled “report did not run” result. Decode Git's text streams with filesystem-compatible surrogate escaping (or otherwise catch this decode failure) so arbitrary tracked names remain readable.
            capture_output=True, text=True,

scripts/report-citation-remainder.py:1107

  • The grammar allows at most one space before the parenthesis and a vocabulary member inside it, but .strip() removes arbitrary leading/trailing whitespace from the parenthetical content. Thus openspec/changes/add-x/proposal.md ( codexFactory ) is flagged even though the spaces are extra content inside the parentheses and should make this signal refuse; keep the captured inner text intact before applying the decoration matcher.
        return False

scripts/report-citation-remainder.py:1467

  • class_evidence_for only emits truncation_evidence, but probe (ii) leaves that field unset and the separate trailing-hyphen arm in truncated_predicate has no probe evidence at all. Those entries are therefore reported with class: truncated and an empty class_evidence/no human evidence, even though the requirement says every mechanical class verdict must name evidence a reader can check; populate evidence for the placeholder and trailing-hyphen arms and cover both outputs.
        return fixture_path_evidence(record)
    if record.classification == CLASS_TRUNCATED:
        return tuple(sorted({o.truncation_evidence for o in record.occurrences

scripts/report-citation-remainder.py:1580

  • PacketIndex._build() traverses openspec/changes with iterdir() and can raise OSError when that tree or a packet directory is unreadable. This call is outside the CouldNotRun conversion, while main() catches only CouldNotRun, so a Git worktree with an unreadable packet tree produces a traceback rather than the required non-zero “THE REPORT DID NOT RUN” result. Translate resolver/index read failures into CouldNotRun before returning the reading.

    index = packet_reference.PacketIndex(root)
    resolutions: dict[str, object] = {}

    def resolution_of(token: str):
        if token not in resolutions:
            resolutions[token] = packet_reference.resolve(root, token,
  • Files reviewed: 2/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread scripts/report-citation-remainder.py Resolved
Copilot AI review requested due to automatic review settings September 18, 2026 11:03
TWO REVIEW FINDINGS. The first is a defect of this branch's own last round; the
second is a rule that was real but undeclared.

`PRRT_kwDOTAvnrs6jtxUJ` — the § 2.1 record read "69 of 72". A botched
substitution in the commit that re-took the record replaced the second numeral
of "69 of 69" and left the first, so a record whose whole subject is a
mechanical coverage count reported an INCOMPLETE realization beside a ticked
box. The count is and was 72 of 72; the record now says so.

`PRRT_kwDOTAvnrs6jtxUj` — the 64-hop cutoff. Kept, and DECLARED, which is the
finding's own second option, because the first is not available:

A BOUND IS NOT REMOVABLE AND CYCLE DETECTION DOES NOT REPLACE IT. A chain can
fail to terminate without ever repeating a state. `l -> l/x` pushes its own name
back onto the walk every hop, so `pending` grows by one each time and the
`(current, pending)` state is new at every step — measured over 201 hops: 201
distinct states, `pending` 202 long. A detector keyed on the walk's state would
never fire and the walk would never end.

THE BOUND IS LOOSER THAN THE PLATFORM, which is the direction that matters.
Measured: the OS refuses to open a chain of 41 links or more with `ELOOP`
(`MAXSYMLINKS`, errno 40) while this walk resolves to 64. There is no chain
whose bytes an ordinary reader of this repository could reach and this walk
gives up on.

AND THE NON-FILE TERM IS THE HONEST ONE FOR AN ENTRY PAST IT, not a fallback.
An entry whose chain the report cannot itself walk has NO resolved path, and an
entry with no resolved path cannot be SAID to leave the root; putting it in the
out-of-root term would assert a containment fact nothing measured, which is the
one thing this report may never do. It is never read either way, so the choice
admits no text from beyond the root.

Three tests: the bound read from both sides (a chain AT it resolves and is read,
one PAST it takes the non-file term, contributes no token and leaves the
arithmetic closed); the platform's own limit MEASURED rather than hard-coded and
asserted to stand below this bound — it fails with the bound at 30, naming the
platform's 37; and `l -> l/x` terminating where a state detector would not.

Refs #1053.

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

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

Unresolved moderate findings remain in the implementation and realization record.

Review details

Suppressed comments (8)

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

scripts/report-citation-remainder.py:627

  • The out-of-root predicate is defined over every tracked entry's resolved path, including entries reached through a parent link. Returning TERM_NON_FILE before resolving a mode-160000 gitlink misclassifies a gitlink under a parent symlink that points outside the root; it should take the out-of-root term just like the regular-file case. Resolve and apply containment first, then use the index mode to classify an in-root gitlink.
    scripts/report-citation-remainder.py:1794
  • The default itemized output is reading.remainder, but is_remainder additionally requires raw_path_present to be false. That means a DANGLING or AMBIGUOUS token whose raw path exists (for example, an ambiguous identity with an active packet path present) is counted in the outcome rows but omitted from the required default itemization. Keep the raw-path predicate for the remainder arithmetic, but list every DANGLING/AMBIGUOUS record independently.

openspec/changes/add-citation-remainder-report/tasks.md:470

  • This realization record says only 69 of the 72 scenarios are covered, while the same paragraph says Patch B added 29 to the 43 already present and the new test module documents 72 of 72. The stale numerator makes the checked-off realization evidence look incomplete; update it to the mechanically verified coverage for this tree.
      ONE TEST PER SCENARIO, its docstring naming the scenario verbatim: 72 of
      72 across the five requirements, counted mechanically against

scripts/report-citation-remainder.py:483

  • The 64-hop cutoff makes valid acyclic symlink chains longer than 64 hops return None, so the entry is misclassified as non_file instead of being read or classified by its eventual resolved path. The documented failure cases only include cycles and unreadable link targets; replace the hard cutoff with cycle detection (or otherwise preserve arbitrarily deep acyclic chains) before treating the path as unresolved.
    current = root
    # `pending` IS A STACK AND NOT A QUEUE: it is built REVERSED and popped from

scripts/report-citation-remainder.py:1186

  • The lexical probe claims to reject every prefixed or raw literal, but this guard only checks whether the character immediately before the opening quote is alphabetic. A continuation such as u8"openspec/changes/..." has 8 there and will pass probe (iii), incorrectly classifying the token as truncated even though the spec explicitly excludes prefixed literals. Detect the complete prefix (including numeric/underscore suffixes) and add a regression for this shape.

#: The two characters probe (iii) reads a literal by. A BACKTICK IS NOT ONE OF

scripts/report-citation-remainder.py:1993

  • With --all, listed_records returns resolved and NOT-A-PACKET-REFERENCE records as well as the remainder, but both human headings still say REMAINDER. This labels resolved tokens as unresolved and makes the advertised --all output misleading; use an ALL TOKENS heading when show_all is true and keep REMAINDER for the default.
          f"{counts['remainder_inclusive_tokens']} inclusive = "

scripts/report-citation-remainder.py:1530

  • git diff --quiet HEAD ignores untracked files, but this realization deliberately follows tracked symlinks whose resolved target is any readable file inside the root. A tracked link can therefore point at an untracked in-root file; read_population_text will read that file and the counts will change when it changes, while this check still reports tree_unmodified_at_head=True. The clean-state declaration must account for those read targets or reject them; the current rationale that untracked files are never read is no longer true after the symlink population rules.

#: `git diff --quiet HEAD`'S OWN TWO ANSWERS, AND NOTHING ELSE IT CAN EXIT WITH
#: IS ONE OF THEM. `0` is "no tracked file differs from the head" and `1` is "at
#: least one does". EVERY OTHER STATUS IS GIT REPORTING THAT IT COULD NOT TAKE
#: THE COMPARISON AT ALL, which is a different fact and belongs to the one
#: non-zero exit this capability has. Measured rather than reasoned: with a head

scripts/report-citation-remainder.py:518

  • git ls-files -s emits one row per index stage for an unmerged path, unlike the specified git ls-files path population. On an allowed dirty/merge-conflict tree, one tracked file can therefore become three TrackedEntry objects here, causing repeated reads and duplicate occurrences while inflating the in-scope/file arithmetic. Deduplicate index-stage rows by path (while retaining the mode information needed for gitlinks) or enumerate unique tracked paths separately.
            return None
        if target.startswith("/"):
            current = anchor
        # Pushed onto the TOP of the stack, reversed so the target's FIRST
        # component is popped first — `[…, suffix] + [last, …, first]`.
        pending.extend(part for part in reversed(target.split("/")) if part)
    return current
  • Files reviewed: 2/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 18, 2026 11:12

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

Unresolved moderate findings remain in the CLI and test coverage documentation.

Review details

Suppressed comments (9)

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

scripts/report-citation-remainder.py:1477

  • The placeholder probe contributes to truncated but never records evidence: evidence remains None unless the longer-path or split-literal probe also fires. A standalone < case therefore emits class: truncated with class_evidence: [] and omits evidence from the human output, despite the requirement that each mechanical class name its evidence. Preserve the < marker when this probe fires; the occurrence location is already carried separately.

scripts/report-citation-remainder.py:1478

  • This passes the already-normalized token into the split-literal probe. A source line ending in a separator, such as openspec/changes/add-split/ followed by "proposal.md", has that / removed before this call, so the probe tests .../add-splitproposal.md and misses the valid rejoined path; the prefix can then be reported as resolved instead of truncated. Rejoin from the raw occurrence spelling and add the separator-split regression case.
    rejoined = probe_split_string_literal(lines, lineno, end, token, resolves)

scripts/report-citation-remainder.py:541

  • git ls-files -s emits one row per index stage for an unmerged path, not one row per tracked path. In a conflicted worktree this creates duplicate TrackedEntry objects, so the report counts and reads the same file multiple times and duplicates its occurrence evidence while still exiting successfully. Enumerate unique tracked paths (with a separate mode lookup) or explicitly handle an unmerged index before building the population.
    for line in git(root, "ls-files", "-s", "-z").split("\0"):
        if not line:
            continue
        meta, _, path = line.partition("\t")
        if not path:

scripts/report-citation-remainder.py:1600

  • PacketIndex is lazy, and its _build() can raise OSError while enumerating an existing but unreadable openspec/changes directory. This call and the later lazy resolutions are outside any CouldNotRun conversion, so an unreadable tree can escape main as a traceback rather than the required non-zero THE REPORT DID NOT RUN path. Convert index/resolution read failures to CouldNotRun (and add a permission/concurrent-removal regression test).
    index = packet_reference.PacketIndex(root)

scripts/report-citation-remainder.py:283

  • The sink decodes git ls-files -s -z with strict text mode. Git's -z form preserves arbitrary pathname bytes, so a valid repository containing a non-UTF-8 filename raises UnicodeDecodeError from subprocess.run; main catches only CouldNotRun, producing a traceback instead of a reading or the required DID NOT RUN result. Use surrogate-escape decoding (or otherwise handle byte output) at this sink.
            capture_output=True, text=True,
            timeout=GIT_TIMEOUT_SECONDS,
            env=sanitized_git_environment())

scripts/report-citation-remainder.py:1133

  • The parenthetical matcher strips whitespace from inside the parentheses before checking the vocabulary. That makes spellings such as (codexFactory ) flag, although the grammar permits at most one space before ( and requires the parentheses to contain only the vocabulary member; inner whitespace is additional content and must not signal. Remove the inner .strip() and add this negative spelling to the regression cases.
    inner = match.group("inner").strip()

scripts/report-citation-remainder.py:2018

  • listed_records returns every record when show_all is true, including RESOLVED and NOT_A_PACKET_REFERENCE, but both branches here still print REMAINDER, ITEMIZED.... A human --all run therefore labels non-remainder outcomes as remainder, contrary to the option's documented behavior; make the heading say all tokens when show_all is set in both grouping modes.
        write("REMAINDER, ITEMIZED BY TOKEN\n")

scripts/report-citation-remainder.py:814

  • This endswith guard is broader than its stated purpose and suppresses full-stop normalization for valid packet paths whose remainder ends with openspec/changes. For example, openspec/changes/add-present/openspec/changes. is not the changes root, but this branch leaves the dot attached and can report a file-half dangling result instead of resolving the actual path. Compare the candidate with the root sentinel by equality rather than suffix matching.
        if candidate.endswith(CHANGES_ROOT) or candidate.endswith(CHANGES_ROOT + "/"):

scripts/report-citation-remainder.py:1401

  • An AMBIGUOUS result is omitted from the default itemization whenever the normalized raw path exists because is_remainder requires raw_path_present to be false. Two packets can claim one identity while the active path exists, so this produces an ambiguous outcome count without an itemized record, contrary to the requirement that AMBIGUOUS is itemized; --all is not a substitute because it also lists resolved and non-reference outcomes. Make ambiguity independent of raw-path presence and add a regression for an active-plus-archived duplicate identity.
        return (not self.raw_path_present
                and self.status in (DANGLING, AMBIGUOUS))
  • Files reviewed: 2/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 18, 2026 14:27

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

Unresolved moderate CLI findings remain before approval.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (7)

openspec/changes/add-citation-remainder-report/tasks.md:469

  • The PR description reports 120 test functions, but this changed test file currently contains 123 def test_ declarations. Since the coverage narrative uses these figures as realization evidence, refresh or remove the moving function-count claim so the description matches this head.
      ONE TEST PER SCENARIO, its docstring naming the scenario verbatim: 72 of

scripts/report-citation-remainder.py:1656

  • Under --all, records includes NOT_A_PACKET_REFERENCE tokens, and the resolver still populates identity with the parsed second path segment (for example, openspec/changes/README.md). This condition therefore probes non-packet paths and can publish history: tracked ... for a record whose status says it is not a packet reference. Skip that status before probing while retaining history for actual packet outcomes.
        identity = record.identity
        if identity is None or identity in probed:
            continue

scripts/report-citation-remainder.py:1096

  • word_immediately_before is given only the prefix before the match, so a vocabulary suffix glued directly to the extracted path is treated as a separate qualifier. For example, codexFactoryopenspec/changes/add-x/proposal.md makes previous equal codexFactory even though the whole whitespace-delimited run is not that word, producing a false cross-repository signal. Require whitespace or admitted decoration between the qualifier and the token, and cover the glued form negatively.
    previous = word_immediately_before(line[:start])
    if previous and _is_vocabulary_name(previous) \
            and not _names_this_repository(previous):
        return True

scripts/report-citation-remainder.py:2018

  • When show_all is true, listed_records deliberately includes RESOLVED and NOT_A_PACKET_REFERENCE records, but this human heading still calls the section REMAINDER. The resulting output labels non-remainder records as remainder, unlike the CLI help and JSON's listed: all-tokens; make the heading reflect the selected listing mode.
        write("REMAINDER, ITEMIZED BY TOKEN\n")

scripts/report-citation-remainder.py:1136

  • The .strip() here makes whitespace inside the parentheses disappear, so text such as ( codexFactory ) or (codexFactory ) is flagged. The locator contract says the parentheses must contain a vocabulary member under the stated decoration set, which does not include whitespace; leave the captured inner text unchanged so these malformed parentheticals remain unflagged.
    inner = match.group("inner").strip()
    if not inner or _names_this_repository(inner):
        return False
    return _is_vocabulary_name(inner)

scripts/report-citation-remainder.py:1264

  • token has already passed normalise_token before this probe, so a raw match ending in . or / has had that character removed before it is joined with the continuation. For example, a source split of .../prop. plus osal.md is tested as .../proposal.md, a different path from the spelling actually written (.../prop.osal.md), and can be falsely classified as a resolving truncation. Form the rejoined path from the raw match (thread raw through this helper) while retaining the normalized token for the record's resolver outcome.
    rejoined = token + content
    return rejoined if resolves(rejoined) else None

scripts/report-citation-remainder.py:543

  • git ls-files -s emits multiple rows for one path when the index contains unresolved merge stages, but this loop creates one TrackedEntry per row and later reads each path once per stage. Because dirty trees are explicitly supported, a merge-conflicted checkout can therefore inflate tracked_entries_in_scope/files_read and duplicate citation occurrences for a single work-tree file. Enumerate each tracked path once and define how its effective mode is selected for unmerged entries.
    for line in git(root, "ls-files", "-s", "-z").split("\0"):
        if not line:
            continue
        meta, _, path = line.partition("\t")
        if not path:
            continue
        rows.append(TrackedEntry(path=path, mode=meta.split(" ", 1)[0]))
  • Files reviewed: 2/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread scripts/report-citation-remainder.py Resolved
…e names the spec in this tree

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 18, 2026 14:54
@sonarqubecloud

Copy link
Copy Markdown

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

Unresolved moderate correctness issues remain in the reporting CLI.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

openspec/changes/add-citation-remainder-report/tasks.md:470

  • The PR description's opening status still says the pytest suite is RED on three inherited sequenced_after tests, while its later section says #1099 fixed all three and the validation table reports zero failures. Refresh the lead status before landing so the realization record and landing condition are not contradictory.
      **LANDED, 2026-09-18, realization slice R1.**
      `scripts/report-citation-remainder.py` and
      `tests/citation_remainder/test_report_citation_remainder.py`, both NEW.
      ONE TEST PER SCENARIO, its docstring naming the scenario verbatim: 72 of
      72 across the five requirements, counted mechanically against
  • Files reviewed: 1/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

@brettheap

Copy link
Copy Markdown
Contributor Author

R1 round at 9997f763 — after 789cbc8f merged the repaired main (dc242f3a), Copilot opened two threads; both fixed in one commit, and one follow-up nit answered without a change.

  • PRRT_kwDOTAvnrs6jx2sD — tree-read failures (OSError out of PacketIndex._build's Path.iterdir(), UnicodeError out of a git decode) now take the same no-reading exit as CouldNotRun: stderr THE REPORT DID NOT RUN: …, exit 2, never a traceback. Two regression tests. The per-file undecodable skip term stays a COUNT, not a failure.
  • PRRT_kwDOTAvnrs6jx2sv — the coverage note names the spec in this tree (72 scenarios at the merge of main dc242f3a); the "until Patch B lands" sentence is gone.
  • PRRT_kwDOTAvnrs6jydzf — c32749c3 (Patch B's landing, the realization record) and dc242f3a (this tree's merge base, which contains it) are both exact; the spec is byte-identical between them. Answered and resolved.

Body: the Status line refreshed; the phrase "or close #1053" in the scope paragraph was itself a GitHub closing keyword (the PR showed closingIssuesReferences = [1053] while saying the opposite) — reworded, so merging this pull request does not close #1053; #1053 closes only in the archive pull request on a later word.

All six required checks GREEN at 9997f763; main's newest decided pytest-suite (dc242f3a) GREEN; 0 open threads. Lands under Rule 6 on Brett Heap's word "land it when green" (comment 5728210143).

Lane: openxfactory-1

@brettheap

Copy link
Copy Markdown
Contributor Author

FREEZE — lane openxfactory-1, session 393ade52-a921-4dd9-9dc5-224ebc056651, 2026-09-18T15:21Z: head 9997f763 is the landing candidate; no further pushes to realize/citation-report-r1. Gates read: six required checks GREEN at this head, main's newest decided pytest-suite (02967478) GREEN, 0 open review threads, no closing keyword. Rule 6 LANDING follows.

Lane: openxfactory-1

@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1 (openXfactory-1)

LANDING — lane openxfactory-1, session 393ade52-a921-4dd9-9dc5-224ebc056651@Eagle, 2026-09-18T15:22:08Z, PR #1100 into opensoft/openxFactory main

Guard at 2026-09-18T15:22:11Z on head 9997f763ee90663ee8dfd00b134a542691c408fb: six required checks SUCCESS (lane-line, openspec-cli-pin, pytest-suite, release-tag-gate, signed-execution-chain-gate, wallet-validation); closingIssuesReferences = []; 0 unresolved threads; main's newest decided pytest-suite = success; no other-lane open LANDING into opensoft/openxFactory main (who --landing). mergeStateStatus BLOCKED = the code-owner-review ruleset that never clears on the author's own account; admin merge on Brett Heap's recorded word (REALIZE add-citation-remainder-report R1 (CLI + tests); Brett Heap 2026-09-18 land it when green (comment 5728210143)). Merge = merge commit.

@brettheap
brettheap merged commit 8316636 into main Sep 18, 2026
15 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1 (openXfactory-1)

LANDED — lane openxfactory-1, session 393ade52-a921-4dd9-9dc5-224ebc056651@Eagle, 2026-09-18T15:22:19Z, PR #1100 into opensoft/openxFactory main → 8316636

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