Repository navigation
ci(doc): forbid a file.rs:NNN citation in a Rust comment, and convert the live ones to symbols - #1493
Merged
Conversation
check_doc_citations.py resolved citations in doc/** and every **/LIFECYCLE.md only, so the same citation written in a //, /// or //! comment was outside all four of its rules: never extracted, never resolved, never drift-compared, and never reported as unresolvable either. sozu#1473 measured the cost on the worst shape — two SAFETY: comments justifying from_utf8_unchecked whose claim was true and whose proof path pointed at a Method match arm instead of the function they named. sozu#1466 found the same defect frozen: a citation already wrong when the drift rule first saw it is exempt forever, because "unchanged" is the condition for being exempt. A fifth rule now FORBIDS the form rather than resolving it. Extending the resolver over **/*.rs was measured and rejected: at 19fd5d8 the tree held 90 such tokens and 68 had already drifted, so the resolver would have failed on most of the population it guarded, and it would have widened the drift rule across a codebase where line shifts are constant and legitimate. Forbidding imports no pre-existing failure and has nothing to renumber. It reads every *.rs — not lib|command|bin|e2e/src alone — and resolves sibling-first through the resolver's own resolve_path, which is what reaches a bare h1.rs:361-368 written from mux/h2.rs; the finder grep in #1473, keyed on a lib/src/-style prefix, walks past that shape, and a rule built on the same prefix would have shipped green over it. A citation naming no file here — the two into the pinned kawa dependency — is skipped and counted beside what was checked. CHANGELOG.md is not read: it is an append-only record carrying quoted tool transcripts, and a rule that failed on one would be asking for the record to be rewritten. Five citations converted, every one re-derived against the tree rather than renumbered. Three were wrong. mux/h2.rs's module preamble cited lib/src/lib.rs:1006-1010 for "arm writable / signal pending write" and landed on pub enum RequiredEvents, ~220 lines from Readiness::arm_writable and Readiness::signal_pending_write. Both mux/mod.rs shutdown sites cited lib/src/https.rs:650-655 for a write-up about SHUT_RD and TCP RST and landed on an Arc::new(snapshot) block, ~370 lines from the comment inside HttpsSession::close. The fourth, mux/stream.rs's lib/src/metrics/mod.rs:44, was correct and still converts — it keeps its claim and loses the number. The fifth is the one no prefix-keyed grep reports: mux/h2.rs:5233's bare h1.rs:361-368, now ConnectionH1::readable's close-delimited EOF branch. All five edits are line-count neutral, so no citation in doc/** or any LIFECYCLE.md moved and the drift rule compares 327 cited lines unchanged. One citation is declared historical rather than converted: h2_flood_detector.rs cites h2.rs:6946 for H2FloodDetector::default()'s test call sites AT THE PRE-EXTRACTION REVISION, which the same sentence says out loud. That extraction deleted the impl Default it describes, so there is no symbol to cite and no line to renumber onto — renumbering would falsify a record. HISTORICAL_CITATIONS holds it, keyed on the citing file and the exact citation text, with the reason; an entry without a reason is an unreviewed silencing of the rule, as for NOT_A_TEST. Seen red: planting one lib/src/metrics/mod.rs:44 in a comment in lib/src/metrics/mod.rs takes the run to exit 1 naming that file, that text and the file it resolves to; removing it restores exit 0 with the file byte-identical. Narrowing rust_files to lib|command|bin|e2e also turns --self-test red, on four assertions, so the scope decision is asserted rather than described. The self-test gains a fixture per shape — single line, range, / group, bare sibling binding to mod/h2.rs rather than the root h2.rs, and an external citation that must stay silent — with both totals asserted, and a fixture exemption table whose one entry moves a verdict. doc/README.md records the convention, the rejected alternative and the escape hatch; its worked example is re-tensed to the revision it was measured at, since sozu#1479 has inverted that write path since. The ci.yml box gains one clause, per its own instruction that an ADDED rule gets one. Refs #1466 Refs #1473 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 24, 2026 03:34
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 24, 2026
…saw it (#1495) 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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1473, refs #1466.
A
file.rs:NNNcitation written in a Rust comment is outsidecheck_doc_citations.py's scope entirely — it resolves onlydoc/**and**/LIFECYCLE.md. So those citations drift with no signal, and nothing stops a new one being written.#1473 asked which way to close that, and its author stated an inclination:
That is what ships here: convert the live ones to symbols, then forbid the form rather than resolve it. Forbidding is the cheaper rule — extending the resolver to
**/*.rswould widen the drift comparison across a codebase where line shifts are constant and legitimate.The population is 8, not 4
A prefix grep for
(lib|command|bin|e2e)/src/…\.rs:[0-9]+finds four. Driving the script's ownPATHregex finds eight — the extra live one is unbackticked and sibling-relative:// Mirror of h1.rs:361-368 for the H2-backend → H2-frontendA prefix-keyed extractor walks straight past it. That is the same shape as #1459, and it is why rule 5 fires through rule 1's own
resolve_path(sibling-first) rather than a fresh pattern: the rule and the resolver cannot disagree about which file a citation names.h2.rsheader →lib/src/lib.rs:1006-1010pub enum RequiredEvents; real targets ~220 lines offmux/mod.rs×2 →lib/src/https.rs:650-655Arc::new(snapshot)block; real write-up 367 lines offh2.rs→h1.rs:361-368if status == SocketResult::Closed, 2–8 lines above thearm_writable()mirror the prose describesmux/stream.rs→lib/src/metrics/mod.rs:44h2_flood_detector.rs→h2.rs:6946mux/stream.rs×2 →kawa/…Symbols were chosen by reading the real target and walking back to its enclosing item, not guessed:
Readiness::arm_writable/Readiness::signal_pending_write,HttpsSession::close,ConnectionH1::readable's close-delimited EOF branch.All five edits are line-count neutral (10 insertions, 10 deletions), deliberately — rule 2 compares cited-line text, and a shifted line is a false drift report. Confirmed after the fact: 327 compared, zero drifted.
Rule 5's scope
Every
*.rsin the tree, not a directory list. The defect is a property of the form, not of the citing directory; scoping tolib|command|bin|e2e/srcwould leavesim/,fuzz/,lib/benches,lib/examples, integration tests and everybuild.rsfree to reintroduce it while reading as a rule that covers Rust comments.That it is not narrowed to nothing is proven rather than asserted: restricting
rust_filesto those four directories turns--self-testred on four separate assertions.CHANGELOG.mdand other historical.mdrecords cannot trip it — the rule reads*.rs.doc/README.md's own "One surface gap" paragraph is the precedent for that.Historical in-comment anchors follow
NOT_A_TEST's existing precedent rather than a new mechanism:HISTORICAL_CITATIONS = {(citing file, exact citation text): reason}, with one entry and its reason spelled out. The comment states that an entry without a reason is an unreviewed silencing, and that a live pointer does not belong there.Seen red, then green
Planting one citation in
lib/src/metrics/mod.rs:Removed:
Both CI self-test modes stay green:
--self-testexit 0, and the deliberately-broken fixture tree exits 1 withdo not resolvepresent, which is whatci.ymlasserts.Verification
Comments-only in Rust, so
sozu-libstays at 1100 exactly. Every pre-existing checker count preserved. Zero new#[allow],#[ignore], orasync fn; Cargo manifests and the generated proto untouched.doc/README.mdFour stale scope statements corrected, not one: the "a citation inside a comment is outside its scope entirely" sentence, the "Nothing mechanical enforces this yet" paragraph, the local-run section, and the "One surface gap" paragraph.
Its worked example is still symbol-accurate after #1479 — both symbols exist — but "now lands" was re-tensed to "landed, at that revision", because #1479 has since inverted that write path and the present tense named a tree nobody can check it against.
What this does and does not close
#1473 is fully addressed. Its part 1 was already done by #1480; its part 2 asked for the scope decision, and the author's stated preference is what shipped, now mechanically enforced rather than a review convention.
#1466 is not closed by this, and is marked
Refsrather thanCloses. Its fourh2.rscitations lived in the doc surface, not Rust comments — which is exactly why rules 1 and 2 were each "individually satisfied" by them — and they are already gone frommain, converted to symbol form inLIFECYCLE.mdwhen #1479 landed. What remains is #1466's structural ask: a--auditmode, because a change detector cannot find a defect that predates its first observation. Rule 5 does not deliver that — it leavesdoc/**and**/LIFECYCLE.mdfree to carry line numbers, where a frozen-wrong citation is still invisible.