Skip to content

ci(doc): audit a citation that was already wrong when the gate first saw it - #1495

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
ci/citation-audit-mode
Sep 24, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
ci/citation-audit-mode

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Refs #1466.

Rule 2 compares a citation's text between base and head, so a citation that was already wrong the first time the rule saw it is frozen in that state permanently — "unchanged" is exactly the condition for being exempt. The gate is a change detector, and a change detector cannot find a defect that predates its first observation.

#1493 closed the Rust-comment half by forbidding the form. doc/** and **/LIFECYCLE.md deliberately keep line numbers, because there a number is sometimes the only way to point at a span with no symbol. That surface needs an audit, which is #1466's option 1.

It catches 4 of the 4 citations #1466 was filed about

Measured at 5d5191e8, the revision the issue names, with the final committed script:

#1466 citation prose caught by
h2.rs:2567 pre-prepare rst_sent insert comment signal
h2.rs:2668 post-prepare HPACK over-budget insert comment signal
h2.rs:2775 mid-loop completed_streams.push path comment signal
h2.rs:710 self.stream_table.rst_sent_contains(sid) symbol signal

The issue predicted the comment heuristic alone would catch three; the orthogonal symbol signal takes the fourth.

  • Comment signal — the target line is a comment while the prose names a statement, call, insert or push. Single-line citations only: a range starting on a comment is how this tree covers a branch together with its introducing comment. Reading ranges too takes findings 13 → 26, and all 13 additions were hand-audited as correct — the guard is a deliberate precision trade, not an oversight.
  • Symbol signal — the prose's attached symbol occurs neither within ±8 lines of the target nor as an item enclosing it. h2.rs:710's rst_sent_contains is over 1800 lines away.
  • The prose fragment is the citation's own line plus the line above when the citation begins the line. That is load-bearing: own-line-only drops Four h2.rs citations on main point at unrelated lines, and the drift rule cannot see them because they never change #1466 from four findings to three.

Every constant carries its ablation, measured on real trees — window 3/8/16/32 → 14/13/8/6 findings; minimum symbol segment 4/6/8/12 → 19/16/13/9; enclosing-item awareness 29 → 13; attached-vs-any symbol 24 → 13.

The first audit, triaged — 6 wrong, 7 false positives

--audit --root . at 6172929e reported 13 of 108 examined. Every finding was triaged rather than counted:

Genuinely wrong and fixed in this changeset:

citation what was there
testing.md → redirect_rewrite_auth_tests.rs:264 middle line of a comment; the prefix check is :266-267
testing.md → h2_security_tests.rs:2440 a comment; the 0x20 byte is at :2444
kawa_h1/LIFECYCLE.md → tcp.rs:2426 a bare }; converted to a symbol citation, since the prose already names handle_connection_result
mux/LIFECYCLE.md ×3 → mod.rs:2376, :2382-2383, :2383 name mismatch — see below

Be precise about those three: they point at exactly the code the prose describes, but inside shutting_down_inner, while Mux::shutting_down is the four-line SessionState wrapper elsewhere. A reader following them finds the right code. Renamed to Mux::shutting_down_inner; the document already distinguishes wrappers from *_inner bodies elsewhere.

One was found by hand, not by the mode, and is fixed with them: Mux::timeout (mod.rs:2001) has the identical defect and sat one bullet above one of the findings. The audit misses it because timeout appears in a trace! and a comment inside the window — proximity cannot distinguish "the name is nearby" from "the item is here". That limitation is written into the mode's header, doc/README.md and the CHANGELOG rather than left implicit.

False-positive ratio: 7 of 13, 54% — printed in the mode's own output rather than tuned away. Two FP classes were tightened because the heuristic was wrong about a shape; the other five are left reporting with their reason documented, because narrowing further starts costing real findings. After the six repairs, --audit --root . still reports 7 of 107 — all seven the documented false positives. Nothing was tuned toward silence.

Advisory, not a gate

--audit is not wired into ci.yml and exits 0 even when it reports. A heuristic that fails the build teaches people to silence it. The self-test asserts this in the inverse direction from every other rule: the same broken fixture tree that exits 1 for rules 1–5 must exit 0 under --audit, with the banner and both findings present.

It also counts what it declines to check, in rule 5's style: 111 prose naming nothing this heuristic can test — more than half the surface — plus 2 prose-to-prose citations and the bare/unresolvable spans. Silence about skipped work is the defect that produced #1457 and #1447.

Seen red

Four mutations, each producing the FAIL line, each restored: range guard removed → the comment-started range is reported; enclosing_names removed → the line-14-below-its-fn case is reported; symbol signal disabled → that finding disappears and examined drops 11 → 10; --audit made to exit 1 → the advisory assertion fires.

New fixtures audit.rs + doc/audit.md carry four citations: one the comment signal must flag, one only the symbol signal can, and two that must stay silent. doc/audit.md is deliberately not in BROKEN_FIXTURES — all four resolve, so rules 1–5 stay silent and the clean-tree exit-0 assertion holds.

Verification

cargo +nightly fmt --all -- --check                     exit 0
cargo build  --locked --no-default-features --features crypto-ring,…   exit 0
cargo clippy --all-targets --locked … -- -D warnings    exit 0
cargo test -p sozu-lib --locked …    ok. 1106 passed; 0 failed    (= main's, zero workspace Rust changed)
check_doc_citations.py --root .      207 citations resolve   (208 at base; one number removed by the symbol conversion)
check_doc_citations.py --base 6172929e   320 compared, unchanged; 3 exempt spans, all three accounted for by --show
check_doc_citations.py --self-test   exit 0, 48 fixture citations, 39 compared
check_doc_citations.py --root .github/scripts/testdata/citations   exit 1, preserved
check_doc_citations.py --audit --root .   exit 0, 7 of 107
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked   exit 0

Zero workspace Rust changed — git diff --name-only | grep '\.rs$' | grep -v testdata is empty — so the 1106 count is main's. The three exempt spans are exactly the three lines the repairs re-anchored, named by --show; no unintended re-anchor. ci.yml untouched.

This does not close #1466

Marked Refs. Option 1 is delivered, measured, run and triaged, but the structural gap is narrowed rather than closed:

  1. 111 of 221 cited spans — more than half the surface — are prose neither signal can read. A citation that was always wrong inside one of those is still frozen exactly as Four h2.rs citations on main point at unrelated lines, and the drift rule cannot see them because they never change #1466 describes.
  2. The mode demonstrates its own miss in-band: Mux::timeout carried the same defect as three findings and was invisible to proximity.
  3. Option 2, convert-to-symbol, remains the only real remedy for the class, and is unenforceable on doc/** for the reason the issue itself gives.
  4. Nothing schedules the audit. It is a command a human runs — no cadence, no ledger of what was dispositioned. That is a separate, small piece of work, and deliberately not a CI gate.

…saw it

Every rule in check_doc_citations.py either resolves a citation or forbids a
form, and none of them can see a citation that was already wrong the first
time it was seen. The drift rule cannot by construction: it compares a
citation's text between two revisions, so "unchanged" is exactly the condition
for being exempt, and a change detector cannot find a defect that predates its
first observation. #1493 closed that hole for Rust comments by forbidding the
form; doc/** and **/LIFECYCLE.md keep their line numbers, because there a
number is sometimes the only way to name a span with no symbol.

--audit reads every citation's prose against its cited line on two heuristics:
the target is a comment while the prose names a statement, a call, an insert or
a push, or the prose names a symbol that is neither within eight lines of the
span nor an item enclosing it. Measured against #1466's own four citations at
5d5191e, the comment signal reports three and the symbol signal reports the
fourth, which lands on ordinary code. It is advisory: it always exits 0, never
edits a citation, and is deliberately absent from ci.yml, because a heuristic
that fails a build is one people learn to silence.

Its first run at 6172929 examined 108 of the surface's 221 cited spans and
reported 13: six wrong citations and seven false positives, a ratio printed in
its own output rather than engineered down. The six are repaired here, and
every run prints what it declined to check -- 111 citations naming nothing
either heuristic can test, more than half the surface.

Refs #1466

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 4162f17 into main Sep 24, 2026
28 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the ci/citation-audit-mode branch September 24, 2026 07:07
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.

Four h2.rs citations on main point at unrelated lines, and the drift rule cannot see them because they never change

1 participant