Skip to content

fix(ci): bind and check a citation's bare :NNN continuation - #1468

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
fix/citation-bare-span-continuation
Sep 23, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
fix/citation-bare-span-continuation

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Closes #1459.

CITATION required a path, so the natural idiom of naming a file once and continuing with a bare
line number produced a second citation no rule could see — not rule 1, not rule 2, not rule 3,
not rule 4. It was never extracted, so it was never even reported as unresolvable. The first half was
checked on every CI run; the second half had never been checked once.

CITATION = re.compile(rf"(?P<path>{PATH}):(?P<spans>{SPAN}(?:[,/][ \t]*(?:\n[ \t]*)?{SPAN})*)")

Three such citations existed in the guarded surface. One of them was wrong.

The bug this found

doc/testing.md:680 cited h2_correctness_tests.rs:3605 and :3708. Line 3708 is
let mut tls = raw_h2_connection(front_addr); — one line above the call site the prose describes.
h2_handshake_chromium_146(&mut tls) has exactly two call sites tree-wide, 3605 and 3709.

It became wrong in #1465, which moved both call sites 3604/3708 → 3605/3709, re-anchored the
written-out half and left the bare half behind:

$ git show 3e9c271c -- doc/testing.md | grep -E '^[-+].*h2_correctness_tests\.rs:'
-  `h2_correctness_tests.rs:3604` and `:3708`. No test that decodes a `:status`
+  `h2_correctness_tests.rs:3605` and `:3708`. No test that decodes a `:status`

Both citations were correct before that commit. The gate stayed green throughout, because the half
that drifted was invisible to it. Run the new script against that revision and it reports the drift:

$ python3 .github/scripts/check_doc_citations.py --root <3e9c271c worktree> --base '3e9c271c^'
::error::1 of 215 compared citations drifted since 970b92c5678a:
  doc/testing.md:680: `h2_correctness_tests.rs:3708` — …:3708 moved:
    was `let _server_settings = h2_handshake_chromium_146(&mut tls);`,
    now `let mut tls = raw_h2_connection(front_addr);`

The same paragraph is duplicated in a Rust doc comment at e2e/src/tests/h2_utils.rs:1453, outside
the guarded surface, where no rule will ever reach it. Its copy had drifted further — two of its
three anchors pointed at a bare }. Repaired in the same changeset, because repairing one copy of a
fact and leaving the other is the defect this gate exists to catch.

What it does

A bare span binds to the nearest written-out citation earlier on its own source line, then runs
through every rule a full citation gets.

Scope is deliberately one line. The blank-line blocks around the three real sites are 15, 16 and 101
lines, so a paragraph-wide carry would search a hundred lines back in doc/testing.md. A wrong
binding is worse than none: rule 1 would confirm it lands on a non-blank line and it would read as
resolved.

An unbindable bare span is a hard failure, never a skip. That is what keeps the narrow scope
honest — without it, a prose reflow moving :305 onto the next line silently restores the exact hole.

False-positive surface, measured at ce80b00c: requiring a code span of its own rejects 154 bare
:NNN (0.0.0.0:8443, [::1]:8080, statsd …requests:1|c, 14:01:51Z, a 1:100 ratio,
--ulimit nofile=262144:262144); requiring a colon plus one span group and nothing else rejects
45 of 48 colon-leading code spans (:status, :authority, :method, :scheme, :path). Newly
claimed bare spans tree-wide: exactly 3, which are the 3 real ones. Citations 232 → 235.

Verification

--self-test                                          exit 0   41 fixtures, 32 compared
--root .                                             exit 0   235 citations, 428 test names, 16/16 pins
--base ce80b00c                                      exit 0   360 cited lines, none drifted
--root .github/scripts/testdata/citations            exit 1   'do not resolve' present (the CI job's 3rd step)
cargo +nightly fmt --all -- --check                  exit 0
cargo build  --locked …                              exit 0
cargo clippy --all-targets --locked … -D warnings    exit 0
cargo test -p sozu-lib --locked …                    exit 0   1029 passed, 0 failed
cargo test -p sozu-e2e --locked … --skip fuzz_tests  exit 0   446 passed, 0 failed

The only Rust in this changeset is a four-line doc comment; git diff against the merge base shows
zero non-comment .rs lines.

Seen red with the extraction deleted and the fixtures, assertions and constants kept — four named
assertions fire, each naming its own citation, plus the count assertions at the parent's numbers.

Four fixtures discriminate the design decisions, and each was proven by mutation:

mutation before after
paragraph scope instead of same-line exit 0 exit 1
bind to first citation on the line, not nearest exit 0 exit 1
document-wide carry exit 1 exit 1
narrow BARE_CITATION back to a single span — exit 1

The first two passed every gate before this changeset, which is why the scope needed fixtures rather
than a comment claiming it was asserted.

Coverage of the newly-visible citations

Rule 1 covers all three from this commit onward. Rule 2 covers two — tcp.rs:305 and router.rs:574
keep the same (path, spans) identity, so they are compared and read unmoved. The repaired
h2_correctness_tests.rs:3709 is exempt as re-anchored, because the base carries :3708, so it
carries rule 1 alone on this changeset. Nothing is retroactively drift-checked.

#1457's group-identity gap is untouched: a bare group like `:3/5` is now extracted and
reaches the repeated-line check, but x.rs:3 followed by a separate bare `:3` remains two
citation groups that check cannot see.

`check_doc_citations.py`'s `CITATION` pattern requires a path, so the idiom
that names a file once and continues with a bare line number —
`lib/src/tcp.rs:183` and `:305` — produced a second citation that no rule in
the file could see. Not rule 1, not rule 2, not rule 3, not rule 4: it was
never extracted, so it was never resolved, never drift-compared, and never
reported as unresolvable either. The first half of every pair was checked on
every CI run and the second half had never been checked once.

#1465 is the worked case, and it is why this tree carried a wrong citation
rather than three correct ones. `3e9c271c` moved both call sites of
`h2_handshake_chromium_146` down one line; it bumped the half a rule could see
and left the half no rule could:

    -  `h2_correctness_tests.rs:3604` and `:3708`. No test that decodes …
    +  `h2_correctness_tests.rs:3605` and `:3708`. No test that decodes …

Both numbers were right at `3e9c271c^` and only the first was right after,
with the `Doc citations` job green throughout. Run this changeset's gate over
that commit and it reports the other half:

    $ git worktree add --detach /tmp/repro 3e9c271
    $ python3 .github/scripts/check_doc_citations.py --root /tmp/repro \
        --base 3e9c271^
    ::error::1 of 215 compared citations drifted since 970b92c:
      doc/testing.md:680: `h2_correctness_tests.rs:3708` — …:3708 moved:
      was `let _server_settings = h2_handshake_chromium_146(&mut tls);`,
      now `let mut tls = raw_h2_connection(front_addr);`

Extract the form and bind it. A bare `:NNN` is ordinary prose, so both
discriminators were measured on this tree rather than guessed. It must be a
CODE SPAN OF ITS OWN: the guarded surface holds 154 bare `:NNN` that are not,
and not one is a citation — TOML listen addresses, `curl` URLs, statsd lines,
log timestamps, a `1:100` ratio, `--ulimit nofile=262144:262144`. And it must
hold A COLON, ONE SPAN GROUP AND NOTHING ELSE: 48 code spans begin with a
colon and 45 are HTTP/2 pseudo-headers or prose, most of them `:authority`
and `:status`. Together they take the tree from 232 extracted citations to
235: the three that exist, and no others. Both counts are read at `ce80b00c`;
this changeset's own prose adds seven colon-leading code spans, so the second
re-measured here reads 55.

The span group is `CITATION`'s own, so `:3/5` and `:3, 5` are extracted
exactly as `:3` and `:3-5` are. A single span there reads as the narrower,
safer choice and is the opposite: this tree uses `/` groups heavily
(`answers.rs:209/224`, `mod.rs:1218/1233/1311/1321`), so a bare one is a form
an author reaches for, and a pattern that does not match it puts that citation
back where #1459 found it. A bare group goes through the repeated-line check
like any other, so `:3/3` — a group renumbered on one half only with its path
dropped — is now reported.

The path is inherited from the nearest written-out citation EARLIER ON THE SAME
SOURCE LINE, the tightest scope covering all three sites. Wider is not free:
all three sit inside bullet lists that run 15, 16 and 101 lines without a blank
line, so a paragraph-scoped carry would search a hundred lines back in
`doc/testing.md` and bind a stray port number to whatever path it found there.
A wrong binding is worse than none, because rule 1 then confirms it lands on a
non-blank line and it reads as resolved. A bare span that finds nothing on its
own line is REPORTED, never skipped.

That scope is asserted rather than described, which it was not at first. Three
ways the sentence above can be weakened, each with a fixture whose verdict
changes under it: binding to the FIRST citation on the line instead of the
nearest (`doc/bad.md:22` puts two paths on one line, so a first-binding report
names `h2.rs` instead of `sample.rs`), carrying over the PARAGRAPH
(`doc/bad.md:30` is a bare span one line below a citation in its own paragraph,
and a paragraph carry binds it to a real non-blank line so the failure vanishes)
and carrying over the DOCUMENT (`doc/bad.md:33`). All three exit 1 now. The
first two exited 0 against the first version of these fixtures, and on the real
tree the paragraph widening produced byte-identical `--show` output, so nothing
anywhere would have reported it.

One of the three continuations was wrong the day it became visible, in two
places. `doc/testing.md:680` cited `h2_correctness_tests.rs:3605` and `:3708`
for the two call sites of `h2_handshake_chromium_146`, and `:3708` was
`let mut tls = raw_h2_connection(front_addr);` — the line above the one the
prose means. `grep -n` puts the sites at 3605 and 3709; the citation is now
`:3709`, re-derived from that grep. `e2e/src/tests/h2_utils.rs`'s
`decode_status` doc comment carries a near-duplicate of that paragraph, outside
the guarded surface where no rule reaches it, and it had drifted further: its
own bare continuation read `:3663` (a bare `}`), its written-out half `:3559`
(a `use` list) and its arming site `lib/src/protocol/mux/h2.rs:5838` (a bare
`}`) against a real site at `:5254`. All three repaired by grep;
`converter.rs:112`, `h2_utils.rs:721` and `h2_security_tests.rs:2440` were
verified correct and left alone. Repairing one copy of a fact and knowingly
leaving the other is the defect this changeset is about. The remaining two
continuations are exact and stay as written, both verified by grep rather than
by trusting the issue's list: `lib/src/tcp.rs:183`/`:305` are that file's only
two `let frontend_address = socket.peer_addr().ok();` lines, and
`mux/router.rs:394`/`:574` its only two `context.link_stream(stream_id,
token);` calls.

Rules 1 and 2 read every document through one `citations()` generator, base
revision included, so a bare span's drift identity is its inherited
`(path, spans)` exactly as a written-out one's is. What that buys on THIS
changeset, rather than in general: the two correct continuations are compared
and read unmoved — `--base` goes from 358 compared line ends to 360 — and the
repaired one is exempt as re-anchored, so it carries rule 1 alone here. Nothing
is retroactively drift-checked. #1457's identity gap is untouched: a bare GROUP
is now caught by the repeated-line check, but `x.rs:3` followed by a SEPARATE
bare `:3` is two citation groups and that check only ever looks inside one.

Seen red before green: with the extraction deleted and the fixtures, the named
assertions and the new constants kept, `--self-test` exits 1 reporting that the
bare continuation on `doc/bad.md:9` was not reported.

`doc/bad.md` carries six continuations now — two bound and wrong, one bound
group, one unbindable group and two unbindable spans that pin the scope — and
`doc/drift.md` and its base revision carry one whose inherited line moved, so
rule 2 must report it through the same extractor instead of merely counting it.
`FIXTURE_TOTAL` 30 -> 41, `FIXTURE_DRIFT_COMPARED` 31 -> 32,
`FIXTURE_EXPECTED` 9 -> 15 entries, `FIXTURE_DRIFT_EXPECTED` 2 -> 3, plus
`FIXTURE_BARE_EXPECTED`, `FIXTURE_BARE_NEAREST_EXPECTED`,
`FIXTURE_BARE_SAME_LINE_EXPECTED` and `FIXTURE_BARE_GROUP_EXPECTED`, each
naming the citation a count assertion can only report as missing. Every other
fixture constant is unchanged.

`doc/README.md` gains the form, its three constraints and the measurement
behind each, written without a real line number because that document is inside
the guarded surface; it also names the one rule the bare form does not reach.
`lib/src/protocol/mux/LIFECYCLE.md` names the form in its own anchoring
preamble, which uses it once. The `[Unreleased]` entry that described this form
as one the regex "cannot see" gains a clause saying #1459 closed it. The job box
in `.github/workflows/ci.yml` is deliberately untouched: it asks for one clause
per RULE, and this changes rule 1's extraction rather than adding a fifth.

Closes #1459.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit f2082b6 into main Sep 23, 2026
24 checks passed
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.

A bare :NNN continuation citation is invisible to check_doc_citations.py, so the second half of a pair is never checked

1 participant