Repository navigation
fix(ci): clip a drift report's quoted pair around its first difference - #1467
Merged
Merged
Conversation
`check_doc_citations.py` rendered every quoted line through one left-anchored window — `line[:71]` plus an ellipsis, always from column 0 — and both halves of a before/after pair went through it independently. A markdown table row is wide by construction and carries its meaning in the last column, so a row whose text changed past character 71 was reported with the same 72 characters printed twice: the rule fired correctly and the report named nothing that had moved. `doc/configure_admin_ops.md:158` cites exactly such a row, `doc/configure.md:1219` — 610 characters wide, its description column beginning at character 70. Pre-existing, and low-impact while the guarded surface was source files only; #1458 made the class reachable by teaching the resolver to read `.md` targets, because the citations that point at prose disproportionately point at table rows. Move the window instead of widening it. `quote_pair` finds the first offset at which the two stripped lines diverge and, when that offset falls outside the anchored window, clips BOTH from `offset - QUOTE_WIDTH // 2` with an ellipsis on whichever side is truncated. `QUOTE_WIDTH` stays 72 and stays a hard ceiling on every rendered quote, ellipses included: raising it would fix the table row by making every long Rust line wrap a CI log, which is what the constant was chosen against. No rule learns about file types — a Rust line whose only edit sits far to the right is served by the same window. Both quote sites take a pair and neither ever quotes a line alone, so rule 2's drifted line and rule 4's stale pinned-block line both go through it. `doc/wide.md` is the fixture: a 151-character catalogue row whose only edit sits at character 147, cited as `wide.md:11` from the drift fixture at both revisions so the rule compares rather than exempts it. The assertion is a property and not a string — the two reported halves must differ from each other, and neither may exceed `QUOTE_WIDTH` — so it survives a later change of window strategy, and its second half makes "do not fix this by removing the clip" mechanical. Seen red: with this commit's production change reverted and the fixture kept, `--self-test` exits 1 printing the two identical clipped strings. `FIXTURE_TOTAL` 29 -> 30 for the citation the drift fixture gains, and `FIXTURE_DRIFT_COMPARED` 30 -> 31 for the one compared line end behind it. Every other fixture constant is unchanged; `FIXTURE_TEST_EXAMINED` deliberately stays at 6, because the new document carries no backticked identifier long enough to be a rule 3 candidate. `doc/README.md` is unaffected: its citation section describes the rule and its command line, never the width or the anchoring of a quoted line. Closes #1448. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 23, 2026 06:22
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.
Closes #1448.
check_doc_citations.py's drift report clipped quoted lines atQUOTE_WIDTH = 72from column 0. When the difference between the two lines falls past that clip,
was:andnow:print identically — the rule fires correctly and the operatorlearns nothing:
That is a markdown table row — wide by construction, with its meaningful content
well right of column 72. The class became reachable when #1458 taught the resolver
to read
.mdtargets, because markdown citations disproportionately point at tablerows: configuration catalogues, metrics tables, threshold listings.
The fix: move the window, don't widen it
quote(line)becomesquote_pair(was, now). It finds the first differing offsetd; ifd < QUOTE_WIDTH - 1the window starts at 0, otherwise atd - QUOTE_WIDTH // 2. Both lines are clipped from that same start, with…on each truncated side.
QUOTE_WIDTHstays 72 and stays a hard ceiling, ellipses included. The issuewas explicit that removing or raising the clip is a different failure, and the
constant exists for a reason — an unbounded quote in a CI log.
The left anchor turned out not to be load-bearing. For any pair diverging
inside the first window, the new code returns start 0 and renders byte-identically
to the old
line[:71] + "…". That is whyFIXTURE_DRIFT_EXPECTED,FIXTURE_PINNED_EXPECTEDand all 16 real pinned blocks needed no change.The same defect had a second call site
Rule 4's stale-pinned-block report also passed a pair through
quote()(
check_doc_citations.py:1058-1059), so it carried the identical bug. Both callsites now use
quote_pair, andquote()is removed with no callers left.The issue named only the drift report. Fixing one of the helper's two users would
have left the same defect live in the other, so this treats the helper as the root
cause — which is also this repository's usual remedy: remove the second copy rather
than patch one of them.
Verification
Red then green, with the production change reverted in a scratch copy while the
fixture and assertion were kept:
Acceptance on the real tree — scratch clone,
doc/configure.md:1219(theh2_stream_shrink_ratiorow, 610 chars, description column starting at char 70)edited in place
Minimum: 2.→Minimum: 4.:Both halves measured at exactly 72 characters.
--self-test--root .--base 3e9c271c--root .github/scripts/testdata/citations(CI's broken-fixture step)python3 -m py_compileSelf-test constants
FIXTURE_TOTALdoc/drift.mdgains one citation group (wide.md:11);doc/wide.mdis a target and cites nothingFIXTURE_DRIFT_COMPAREDUnchanged and asserted green:
FIXTURE_EXPECTED(9),FIXTURE_DRIFT_EXPECTED(still 2 — the wide drift is asserted separately),
FIXTURE_TEST_EXAMINED/CHECKED(6/4; the new document carries no backticked identifier ≥13 chars, so rule 3 does
not leak into it),
FIXTURE_PINNED/UNPINNED(3/1).The new assertion is deliberately a property, per the issue: the two reported
halves must differ from each other, and neither may exceed
QUOTE_WIDTH. It pinsno formatting, so it survives someone later changing the window strategy — and its
second half makes "do not remove the clip" mechanical rather than a comment.
Checked not test-shaped: tokens shared between the production hunk and the four
fixture files are English prose only (
clip,line,report); noknob,Minimum,Shrink,wide,147or151.doc/README.mdis unaffected — it describes the rule and its command line, neverthe quote width or anchoring (grepped for
clip|72|width|truncat|ellips|…: empty).