Repository navigation
fix(ci): key the drifted-citation exemption on the cited line, not its number (#1447) - #1523
Merged
Merged
Conversation
…s number (#1447) `check_doc_citations.py`'s rule 2 compares a citation this changeset did not touch against the text it named at the base revision, and exempts one the changeset re-anchored. That exemption asked whether the SPAN was present at the base, and a span number is not stable under the edits the rule exists to police. Renumbering a citation onto a line whose number the base revision spent on something else leaves the span not-new, so the exemption does not apply and a CORRECT citation is reported as drift with no edit to the document that removes the report. #1447 found it at `595920e9`: the mux `LIFECYCLE.md` cited an `h2.rs` line for the `handle_goaway_frame` retry loop, and a branch that renumbered after a large `h2.rs` edit landed the `StreamState::Link` transition on that very line. THE IDENTITY IS THE CITED LINE. `reanchored_claims` reads both revisions and returns every cited line TEXT whose claim this changeset carried onto a new number; `check_drift` declines a span whose base text is one of them, because what the base document named at that number is alive elsewhere and the span under test is a different citation that inherited the number rather than the base one left behind. NOTHING GUESSES, and two counted conditions keep it that way. A RECEIVER is only a head-cited end whose number this document did not cite at the base at all: a number the base already carried explains nothing, being as likely to be a second stale citation, which is exactly what two adjacent citations do when their file loses a line and each lands on its neighbour's old text. And the receivers for a text must be AT LEAST AS MANY as the base citations that named it, so a document that named one line twice and re-anchored one of the two has left the other behind and it is still reported — which is #1457's half-applied renumbering, and the reason the widening cannot swallow it. Measured on `refactor/h2-goaway-drain` against `921c13673616`, which re-anchors 72 spans: the number-keyed rule reported one mux `h2.rs` citation as drift because the base had spent that number on `context.unlink_stream(stream_id);`, while that line is cited, correctly and by the same changeset, 39 lines earlier. Measured on `06fc2708`, the 92-span re-anchoring #1457 was measured on, both rules report the identical six drifts and nothing is declined: the exemption is inert where no number was reused. Across 30 branches and 40 merged commits it changes exactly one verdict. DECLINED, NEVER SILENT. Every declined span is printed with the text that was matched and the number the claim moved to, and `--show` tags it `|reused-number`. It is a comparison the rule did not perform, so it lowers the compared total instead of hiding inside it, and it is listed apart from the re-anchored exempt count. Two residuals are stated in the report rather than left to the issue tracker: a base citation this changeset DELETED instead of re-anchoring leaves no receiver, so a correct citation landing on its line is still reported; and a cited line carrying little text, a lone `}` or a bare `where`, can match by coincidence and decline a real drift, with the matched text on screen so a reviewer sees it for what it is. Declining a span says the base's claim moved, never that the number the changeset wrote is a sensible place to point at; that stays `--audit`'s question, and a symbol's. `doc/keyed.md`'s reused number moves out of FIXTURE_DRIFT_EXPECTED into the new FIXTURE_DRIFT_REUSED_EXPECTED, pinned by its exact reported text rather than by a count: an exemption a reviewer cannot read is a heuristic with no audit trail, and a build that stopped naming the matched text would emit the same count. FIXTURE_DRIFT_COMPARED drops 39 -> 38 in the same direction, because a declined span is one fewer comparison. `doc/drift.md` is the guard from the other side and keeps `drift.rs:12` in FIXTURE_DRIFT_EXPECTED: its base cites that span twice and the head re-anchors only one of them. Seen red four ways, each change reverted alone against `--self-test`: A fixture verdict flipped, rule unmodified expected 4 drifted citations from the fixtures, got 5 compared 39 cited lines against the base revision, expected exactly 38 B identity reverted to the number key expected 1 cited line(s) declined as a reused number, got 0 C claim counting dropped from reanchored_claims expected 1 cited line(s) declined as a reused number, got 2 (drift.rs:12 swallowed — #1457's half-applied renumbering) D one word of the declined report's wording changed MISSING: doc/keyed.md:16: `keyed.rs:16` — ... the base named ... there The header section is retitled and rewritten, `doc/README.md`'s drift chapter with it. No production code changes. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 25, 2026 10:21
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.
Rule 2 of
check_doc_citations.pycompares a citation this changeset did not touch against the text it named at the base revision, and exempts one the changeset re-anchored. That exemption asked whether the span was present at the base — and a span number is not stable under the edits the rule exists to police.The identity I chose, and the one I rejected
Chosen: the cited LINE, tracked through the re-anchoring this changeset performed.
reanchored_claimsreads both revisions and returns every cited line text whose claim this changeset carried onto a new number.check_driftdeclines a span whose base text is one of them: what the base document named at that number is alive elsewhere, so the span under test is a different citation that inherited the number rather than the base one left behind.Nothing guesses, and two counted conditions keep it that way:
Rejected: the enclosing symbol resolved at both revisions. It needs a Rust item parser inside a script whose whole design is dependency-free and language-agnostic (it resolves
.mdtargets too, which have no symbols at all), it is heuristic by construction, and it still cannot separate two citations that point inside the same function — which is the case the issue itself names as having no symbol to cite. Text equality across two revisions is a fact; an enclosing-construct resolver would be a guess with a parser in front of it.What the script now says about its own limits
The two residuals are printed, not left in the issue tracker. Verbatim, from the report:
And, from the header: declining a span says the base's claim moved, never that the number the changeset wrote is a sensible place to point at. That stays
--audit's question, and a symbol's.mod.rs:2152— a number that moved between two identical lines — is out of reach of the text key for the same reason it was out of reach of the number key.The exemption count of the 2026-09-22 addendum already exists
Checked before building anything. At
5355cec0the unmodified script already prints the exempt count on every run that has a base. Measured here,--base 5355cec0185c07c81e2334fca73ec290749d1daeon this branch:(A zero here is the honest reading, not a missing instrument: this changeset re-anchors nothing. The same line reads
66 re-anchored spans were exempton a branch that does — reported to me from another branch's run against the same base, not reproduced here.)It landed in #1478 (
54dcacf5, "Refs #1447"), on both report shapes — inline in the::error::line when something drifted, on its own line when nothing did — with--showtagging each span|re-anchored. So it is not reimplemented here. It is also genuinely tested rather than merely emitted:FIXTURE_DRIFT_EXEMPTis movable by a fixture, not only by reverting production code — adding one head-only citation todoc/keyed.mdgivesWhat this changeset adds beside it is the second declined class, kept separate on purpose: a reuse exemption is a comparison the rule no longer performs, so it lowers the compared total and is listed line by line rather than folded into the re-anchored count. Folding it in would have reproduced, one level down, the exact defect the addendum reported.
Before/after on a real changeset
refactor/h2-goaway-drainagainst its merge base921c13673616— a changeset that re-anchors 72 spans.Before (
origin/main's script):After:
Verified by hand, both revisions: the base document cited
h2.rs:5994for the unlink site, andcontext.unlink_stream(stream_id);is at5955at head, where this changeset cites it. The old report'swashalf named a claim that is alive and correct 39 lines up; the span it fired on belongs to a group the changeset rewrote wholesale (5994/6053→6060/5994/6012). Note what the new line does not claim: whether5994is a good place to point at is a separate question, and the report hands the reviewer both halves of the evidence to ask it.It does not widen anything it should not. On
06fc2708— the 92-span re-anchoring #1457 was measured on — the two rules report the identical six drifts and decline nothing:Swept over 40 merged commits and 30 local branches that touch both documents and code: one verdict changes in total.
refactor/h2-stream-slots's genuine drift andpr1300's thirty are all preserved.Red, then green
The fixture asserts the correct verdict and was seen red against the unmodified rule first.
RED A —
doc/keyed.md's reused number asserted as correct, rule untouched (origin/main's script, onlyFIXTURE_DRIFT_EXPECTEDandFIXTURE_DRIFT_COMPAREDedited):GREEN — the fix in place:
RED B — the identity reverted to the number key (
moved_claims = {}):RED C — the claim counting dropped from
reanchored_claims(len(numbers) >= claimed→claimed). This is the one that matters: the exemption widens and swallows #1457's half-applied renumbering.doc/drift.mdis that guard: its base citesdrift.rs:12twice, the head re-anchors only one of them to:16, so one claim stays unaccounted for and the span left behind is compared. Widening the exemption past its counting turns--self-testred instead of turning the rule off.RED D — one word of the declined report's wording changed (
there→here), which is why that list is pinned by exact text and not by a count:The pre-existing shape assertions still bite, checked by perturbation rather than by assuming — the declined lines go into their own returned list precisely so
REPORTED_PAIRkeeps matching the drift lines. Changing the drift report's separator (, now→, and now):On removing an assertion
keyed.rs:16leavesFIXTURE_DRIFT_EXPECTED, which reads like a deleted assertion and is not one: it moves intoFIXTURE_DRIFT_REUSED_EXPECTED, pinned by its exact reported text, andFIXTURE_DRIFT_COMPAREDdrops 39 → 38 in the same direction. One pinned-defect verdict becomes one pinned-correct verdict plus a new list and a lower counter — net assertions grow, anddrift.rs:12is now the guard against widening, in this list and named in the header for it.Verification
cargo buildis run beforecargo fmtdeliberately: on a fresh worktreefmtexits 1 withfailed to resolve mod 'command'until the build script has generatedcommand/src/proto/command.rs.The first
sozu-e2erun reportedtests::tests::test_asyncandtests::tls_tests::test_wss_server_speaks_first_after_upgradeas FAILED. That was port contention, not this changeset —pgrep sozu_e2eshowed a second binary holding the process-wide registry fromPORT_SEARCH_START. Both passed in isolation immediately afterwards, and the full suite is the green line above, re-run withpgrep sozu_e2e | wc -lat 0 and the 1-minute load below 8. This changeset contains zero.rsfiles, so the test binaries are byte-identical to5355cec0.Scope
.github/scripts/check_doc_citations.py,.github/scripts/testdata/citations/doc/keyed.md(one sentence of fixture prose that asserted the old verdict; its citations are unchanged, and its line numbering is preserved becausedoc/keyed.md:16is pinned),doc/README.mdandCHANGELOG.md. No production code, no dependency change,ci.ymluntouched — its own comment says that when a rule changes, the script changes and the workflow does not.CHANGELOG.mdanddoc/README.mdfollow the precedent every previous change to this script set: #1458, #1467, #1468, #1478, #1493 and #1495 each touchedCHANGELOG.md, and all but #1467 also toucheddoc/README.md. The entry sits below the first entry of### 🔄 Changedrather than at the top of the section, so it does not collide with every other open PR's entry.One thing the gate caught on its author, worth recording: the first draft of the
doc/README.mdparagraph quoted the measured example ash2.rs:5994, and--root .reported it as an ambiguous unresolvable citation. Rewritten without a citation-shaped literal.Closes #1447