Skip to content

docs(ci): guard file.rs:NNN citations and repair doc/ - #1371

Merged
FlorentinDUBOIS merged 2 commits into
mainfrom
docs/citation-resolver
Sep 20, 2026
Merged

FlorentinDUBOIS merged 2 commits into
mainfrom
docs/citation-resolver

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Closes #1335, implementing option 3: symbols where an item is named, line ranges only where a
specific branch is meant, with a CI resolver guarding the survivors.

Scope is doc/, the tracked CLAUDE.md, stale citations in source comments, and the resolver.
The five module LIFECYCLE.md files are repaired by #1366, which lands first.

The issue's own numbers were measured with the broken instrument

[A-Za-z_/.-]+\.rs:[0-9]+ has no digit in its character class, so it silently skips every citation
naming a file with a digit — h1.rs:NNN, h2.rs:NNN.

measure corrected pattern issue's pattern
doc/ occurrences 109 102
doc/ files 8 7
mux/LIFECYCLE.md 171 lines / 201 occ 75 / 78

The issue publishes "113 across 7 files"; it is 109 across 8. The eighth file,
doc/h2_mux_internals.md, is invisible to that pattern entirely — both its citations name
digit-bearing files. Its "7 pointing at a blank line" re-derives to 5.

The resolver

.github/scripts/check_doc_citations.py, stdlib-only, wired as the non-experimental Doc citations
cell. Scans doc/** and **/LIFECYCLE.md; fails on missing file, ambiguous basename, line past EOF,
blank line, inverted range, and a repeated line inside one citation group.

Three things a naive version gets wrong, all handled:

  • the corrected pattern;
  • slash/comma continuations parsed as one group, including across a wrapped prose line. This is the
    trap case: answers.rs:209/224 renumbered on one half yields 224/224, which resolves perfectly and
    is otherwise invisible;
  • a cited path resolves against the document's own directory first. Without that the repaired
    LIFECYCLE.md files produced 121 spurious "ambiguous basename" failures (h2.rs:2620 inside
    lib/src/protocol/mux/ matching bin/src/ctl/top/panes/h2.rs).

It flags exactly 27 of the 517 LIFECYCLE.md anchors on origin/main, independently matching the
number #1366 reports.

It is a floor, and says so

On origin/main it flags 5 of the 109 doc/ citations. The hand audit found roughly 75 more
pointing at a valid line in the wrong place — config.rs:998 is the doc comment of to_http, not
FileClusterConfig::http2; request_builder.rs:214-238 is off by ~170; five kawa_h1/mod.rs
backend-connection anchors by 170–214.

A green run means "no citation is obviously dead", nothing more. The header comment states that
verbatim and doc/README.md repeats it. A guard that oversells itself licenses skipping the read.

Red, green, and a negative test

RED   resolver on an origin/main snapshot -> exit 1
      ::error::32 of 626 citations do not resolve   (5 in doc/, 27 in LIFECYCLE.md)

GREEN this branch      -> doc/ failures 0; LIFECYCLE failures 27, identical to origin/main
      merged with #1366 -> exit 0, "all 236 citations resolve to a non-blank line"

NEGATIVE resolver mutated so check() returns no failures:
      --self-test -> exit 1, "expected 4 failures from the broken fixture, got 0"
      committed resolver --self-test -> exit 0

The merged run caught a live regression of this branch's own making. A first h2.rs comment edit
was one line longer, shifting h2.rs:3675-3685 and h2.rs:6751 — two anchors #1366 deliberately kept —
onto blank lines. Both were flagged; the comment was rewritten to the original 5 lines, net 0. That is
exactly the cross-branch drift #1335 describes, caught by the guard on its own author.

Repairs

doc/ — all 109 citation groups read against the code. 109 groups / 147 line references / 8 files
became 29 / 39 / 4: 80 are now symbol anchors, and of the 29 survivors 24 were renumbered.

CLAUDE.md — all eleven macro_rules! sites had moved (mux/mod.rs:49/87/118 vs 51/78/111;
rustls.rs:23 vs 32; tcp.rs:68 vs 76; …), plus kawa_h1/editor.rs:587 (the real
HttpContext::log_context is 1257). All converted to symbol anchors. socket.rs:86/133 is left
byte-identical, because fix/tls-socket-log-peer corrects it.

Source comments — mux/h2.rs's 3887-3895 / 4026-4031, and command/src/channel.rs +
bin/README.md's state.rs:1613, 1630 (the real write_requests_to_file is state.rs:2877) and
channel.rs:71. All converted to symbols.

Four stale prose claims reported, not rewritten

doc/lifetime_of_a_session.md §2.2 names mux::connection as the home of the
signal_pending_write/arm_writable invariant where that module delegates to mux::h2, and attributes
the "invariant-15 pair" to module documentation where the phrase only appears on a test; its §9 lists
mux::router among the per-stream backend.pool.size decrements where Router::connect only
increments; doc/configure_admin_ops.md §5.5 cross-references the wrong doc/configure.md section.

Landing order

This branch exits 1 on its own — 27 LIFECYCLE.md failures identical to origin/main, none introduced,
all owned by #1366. git merge-tree of the two is clean and the merged tree is green. Land #1366
first.

CLAUDE.md's logging bullet is one physical line, so a textual conflict with #1364 is certain even
though the two touch different citations.

Validation

BUILD=0 CLIPPY=0 TEST=0 FMT=0; -p sozu-lib --lib 863 passed, -p sozu-command-lib 153. Only two
Rust files change and both are comment-only. No production dependency added — the resolver is Python.

517 `file.rs:NNN` anchors across `bin/src/command/LIFECYCLE.md`,
`lib/src/protocol/kawa_h1/LIFECYCLE.md`, `lib/src/protocol/mux/LIFECYCLE.md`,
`lib/src/protocol/proxy_protocol/LIFECYCLE.md` and
`lib/src/protocol/udp/LIFECYCLE.md` were read against the code they point at.
310 did not need a line number and are now symbol anchors; of the 207 that
name a specific statement or branch, 171 had to be renumbered and 36 were
already right.

A line number has no anchor, so it rots the moment anyone edits above it, and
nothing resolves it: a mechanical scan for a missing target, a line past EOF or
a blank line flagged only 27 of the 517. The two drift patterns measured in
issue #1335 account for nearly all of the rest — single-line anchors off by +1
from the `//!` module-doc line added at the top of each source file after the
documents were written, and ranges off by tens to thousands of lines from the
TigerStyle `debug_assert!` campaign and the growth of
`lib/src/protocol/mux/h2.rs`, where the drift reaches +2165.

The convention now matches `lib/src/protocol/tcp_preread/LIFECYCLE.md`, which
was already written this way and is why it needed no repair. Where the prose
names an item the anchor is that item plus its file, with a method qualified
`Type::method` so it is greppable; a line or range survives only where the
claim is about a statement or a branch inside an item. Bare basenames that were
ambiguous repo-wide (`server.rs`, `backends.rs`, `upgrade.rs`) are now
repo-root-relative. Each of the five preambles states the convention and the
date the surviving numbers were refreshed.

No prose claim was rewritten to match code. Four stale claims surfaced on the
way — `Server::run`, `upgrade_main`'s file, `ListenerAnswers` / `ClusterAnswers`
and the mux "inline removal" list — and are anchored correctly but left for a
separate pass. `doc/` is untouched.

Rebased onto 95c5f37 (#1369), whose H2 timer-ownership move drifted five more
citations in these same documents. Four were caught by the guard landing in
#1371 -- `editor.rs:561-621`, `h2.rs:6045-6047` and `manager.rs:555-567` twice,
each now resolving to a blank line -- and are re-anchored on
`HttpContext::on_request_headers`, the three `ConnectionH2` frame handlers that
decrement `active_requests`, and `UdpManager::handle_timeout`.

The fifth the guard cannot see, and it is the more instructive one:
`shrink_trailing_recycle`'s "single call site at `mod.rs:616`" now lands on
`HttpContext::new`, 58 lines short of the real call at `mod.rs:674`. A citation
that drifts onto a different non-blank line passes the check -- the checker says
so in its own output -- which is why the anchor is now `Mux::create_stream`.

The rebase also took the `mux/LIFECYCLE.md` backend-timeout tracker from
95c5f37, whose description is current, but symbolised its two citations rather
than keeping either side's numbers: `mod.rs:773` had come to land on unrelated
doc prose and `mod.rs:1279` on a `gauge_add!` call.

Refs #1335

Signed-off-by: Florentin Dubois <[email protected]>
A line number carries no anchor, so a `file.rs:NNN` citation rots the moment
anyone edits the file it points into. The pull request that breaks it is almost
never the pull request that contains it, so no reviewer is ever shown both
halves. #1335 measured 29 of 35 citations wrong in one audited
document.

Add `.github/scripts/check_doc_citations.py` and wire it as the
non-experimental `Doc citations` CI cell. It resolves every citation under
`doc/**` and `**/LIFECYCLE.md` and fails on a missing file, an ambiguous
basename, a line below 1 or past end of file, a blank line at either end of a
range, an inverted range, or the same line repeated inside one citation group --
the last being what a `/` or `,` continuation renumbered on one half only looks
like. Its extraction pattern keeps a digit in the character class, without which
every citation naming a file whose name contains one is skipped: on
`lib/src/protocol/mux/LIFECYCLE.md` the digitless class sees 78 of the 201
occurrences that are there. A cited path resolves against the document's own
directory first, so a module `LIFECYCLE.md` keeps citing its siblings by bare
name.

`--self-test` asserts the exact failures a deliberately broken fixture must
produce, and the exact citation total, and -- because classifying a failure and
acting on it are different lines -- runs the real command line in a subprocess
requiring exit 1 on that fixture and exit 0 on a clean one. The cell asserts
that exit code in a step of its own. The fixtures carry a digit-bearing `h2.rs`
and a `mod/LIFECYCLE.md` whose citations resolve only through the
sibling-directory rule, so each of the four one-line ways to make this checker
report a clean run over a quietly smaller surface -- `if failures:` -> `if
False:`, dropping the digit from the pattern, dropping `**/LIFECYCLE.md` from
the scan, dropping sibling-directory resolution -- fails the self-test.

Repair `doc/`: all 106 citation groups across 9 files were read against the code
they point at. 74 became symbol anchors, which cannot drift; of the 32 that
survive as line anchors, 24 were renumbered and 8 were already right. Five
landed on a blank line -- the only class a mechanical scan sees. The rest
resolved to a valid line in the wrong place, which is what actually misleads a
reader and what the checker cannot catch: `doc/README.md` now states that limit,
and the two narrower ones, next to the local run instructions.

Correct three stale citations outside the guarded surface, where nothing will
catch them later: `CLAUDE.md`'s logging bullet cited ten surviving
`macro_rules!` definition sites and every one had moved, `socket.rs:86/133`
included -- a trait method declaration and a line inside a macro body.
`command/src/channel.rs` and `bin/README.md` cited a UDP-frontend invariant
comment and a `ChannelError` variant for the state-file save format and the
`max_buffer_size` ceiling. The comment in `lib/src/protocol/mux/h2.rs` pointing
at the inbound `stream_last_activity_at` refreshes named SETTINGS-ACK tracking
instead of `handle_data_frame` and `handle_headers_frame`; it is rewritten at
its original line count, because two anchors elsewhere name lines below it.

No prose claim was rewritten to match the code; four that have gone stale are
recorded in the changelog entry instead. Line anchors were refreshed against
`main` at `ba7fa5f9` on 2026-09-20.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit e35485a into main Sep 20, 2026
24 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the docs/citation-resolver branch September 20, 2026 20:53
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.

docs: file.rs:NNN citations have drifted; 29 of 35 were wrong in one audited file

1 participant