Repository navigation
ci(doc): report a file.rs:NNN citation whose line moved, not just a blank one - #1391
Merged
Merged
Conversation
…lank one check_doc_citations.py failed a citation only when the cited line was blank. A citation that slid onto a different NON-BLANK line resolved, hit code, and passed. #1389 measured the gap: on #1379's changeset, which added +21 lines to lib/src/protocol/kawa_h1/editor.rs and +14 to lib/src/protocol/mux/router.rs, 24 citations moved and the guard reported 2. The other 22 all landed on code, and lib/src/protocol/kawa_h1/LIFECYCLE.md alone cites editor.rs 21 times. The guard's presence was itself the hazard: a green Doc citations job read as "the citations are right" when it only ever meant "no citation landed on a blank line". --base <revision> closes that with the base revision and no new data. Every citation is resolved by the checker's own resolve_path/CITATION -- a naive basename match reports false positives, because a bare mod.rs in mux/LIFECYCLE.md binds to its sibling -- and the text of the cited line is read at the merge base and at HEAD. Different text is reported whether or not the new line is blank, at both ends of a range, which makes the rule a strict superset of the blank-line rule for every line the changeset touched. Comparison is on the stripped line, so a re-indent is not drift. Re-anchoring is not drift. A citation is compared only when the same path and the same line numbers are also present in the base revision of its own document, so repointing editor.rs:1131 at editor.rs:1152 is accepted silently and only a citation left pointing at text that changed underneath it is reported. Identity is the citation and not its position, so moving a paragraph does not excuse a stale number. It fails closed. The base commit has to be in the object store and the default actions/checkout is shallow, so the Doc citations job now checks out with fetch-depth: 0 -- pull requests here stack on one another, so the base is often not main and no narrower fetch covers every case -- and passes the pull request's base sha through the environment rather than interpolating it into the shell. An unreachable --base is an error and exit 1, never a skip: a guard that answered a missing base with a clean run would be green forever while comparing nothing. A main or tag push carries no changeset, and the run then states on its own line that the rule did not run. The self-test asserts the drift half in BOTH directions. testdata/citations/ gains a document whose five citations all resolve to a non-blank line at both revisions -- so the older rules are green on it either way -- plus a drift.rs, and a <name>.base second revision of each that no walk in the script can see. The self-test commits those base revisions into a throwaway repository, restores the head ones, and requires the SAME tree to exit 0 without --base and 1 with it, the two drifts to be the exact two expected, 17 cited line ends to have been compared, and an unreachable base to be refused rather than skipped. FIXTURE_TOTAL moves 14 -> 19 for the new document's five citations, and the clean-fixture assertion is now stated by excluding doc/bad.md, so a fixture added later is covered the day it lands. On this tree the rule compares 340 cited line ends and reports none. Inserting two lines at the top of editor.rs reddens it with two citations from kawa_h1/LIFECYCLE.md while the blank-line rule stays green on all 229. The scanned surface is unchanged and that is deliberate. #1389's follow-on asked for the line-citation surface to be aligned with the test-name rule's *.rs + CHANGELOG.md. Measured on 265d895 that adds 195 citations across 190 files and 50 pre-existing failures, 27 of them in CHANGELOG.md -- an append-only record of the tree as it stood at each release, which must not be renumbered to satisfy a guard. It is its own changeset, and it would still not reach e2e/COVERAGE.md, which no rule reads. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 21, 2026 03:03
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.
The guard added in #1371 fails a
file.rs:NNNcitation only when the cited line is blank.A citation that drifts onto a different non-blank line passes silently. On one changeset in
this batch, 24 citations moved and the guard reported 2.
--base <revision>now resolves the merge base of<revision>and HEAD, reads the cited lineat both revisions, and reports any citation whose line text changed — blank or not. It is a
strict superset of the existing rule, which is untouched.
Verified against the real tree, independently of the authoring run. Clean:
Then two lines inserted at the top of
lib/src/protocol/kawa_h1/editor.rs:That is the gap, in one frame: the blank-line rule reports everything fine while four citations
point at the wrong code.
Re-anchoring is not flagged. A citation is compared only when the same path and the same
line numbers appear in the base revision of its own document, so repointing
1131 → 1152isaccepted while leaving
1131as the code moves is reported. Identity is the citation, not itsposition.
Fail-closed, not skip. An unreachable base is an error, proved on a real
--depth 1clone.The job checks out with
fetch-depth: 0— PRs stack here, so the base is often notmain— andpasses
github.event.pull_request.base.shathroughenv:, never interpolated into the shell.A push to
mainor a tag has no changeset and says so on its own line rather than passing silently.Self-test totals stay exact, none a floor:
FIXTURE_TOTAL14 → 19, plusFIXTURE_DRIFT_COMPAREDand two exact expected strings. The clean-fixture assertion now excludes
doc/bad.mdinstead ofnaming
doc/good.md, so a fixture added later is covered the day it lands.Follow-on (1) from the issue — measured and deliberately left. Aligning the line-citation
surface with the test-name rule's
*.rs+CHANGELOG.mdadds 190 files, 195 citations, 50failures, 27 of them in
CHANGELOG.md— which is an append-only record of the tree at eachrelease and must not be renumbered to satisfy a guard. That is its own changeset. It also would
still not reach
e2e/COVERAGE.md, which no rule reads. Numbers recorded indoc/README.md.What this does not close, stated in the script header,
doc/README.mdand the commit: acitation already wrong before the PR opened is carried forward unreported. That is Measurement 2
of the issue —
editor.rs:1131, non-blank and wrong across three trees — and it needs thesurface widening above.
SELFTEST=0, real tree--base ba69fd28→ 0, broken-fixture step → 1,TEST=0(917 passed).Closes #1389