Skip to content

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

Closed

Description

@FlorentinDUBOIS

Summary

doc/ and the module LIFECYCLE.md files cite code as file.rs:NNN. A line number has no anchor,
so every one of these rots the moment anyone edits the file it points into — silently, because
nothing resolves them.

Auditing one such file while fixing #1334 found 29 of its 35 pre-existing citations wrong.

Evidence

In lib/src/protocol/proxy_protocol/LIFECYCLE.md, on e16b51ca, the drift falls into two exact
patterns:

  • Single-line citations were uniformly off by +1. expect.rs:53→54, relay.rs:44→45,
    send.rs:46→47, expect.rs:79→80, :117→118, :82→83, relay.rs:62→63,
    send.rs:64→65, :109→110. A uniform +1 across three files means one line was inserted near
    the top of each — the //! module docs — after the document was written.
  • Range citations were off by +38 to +57. expect.rs:163-175→201-214,
    expect.rs:203-212→249-259, expect.rs:217-225→263-272, relay.rs:131-135→159-160,
    relay.rs:158→199, send.rs:135-159→145-192, send.rs:116-131→117-140. That is the
    TigerStyle debug_assert! campaign growing the functions. A range that drifts 46 lines does not
    mislead slightly — it lands the reader in a different branch.

The rest of doc/ is not audited, but a mechanical scan of the 79 resolvable file.rs:NNN
citations there finds 7 pointing at a blank line, which is a lower bound on breakage since a
citation can land on the wrong construct while still hitting code:

doc/configure_admin_ops.md:130    request_builder.rs:222-240
doc/lifetime_of_a_session.md:42   lib/src/protocol/mux/connection.rs:200
doc/lifetime_of_a_session.md:212  lib/src/http.rs:141
doc/lifetime_of_a_session.md:213  lib/src/protocol/proxy_protocol/expect.rs:117
doc/lifetime_of_a_session.md:239  lib/src/protocol/kawa_h1/mod.rs:1340
doc/lifetime_of_a_session.md:276  lib/src/protocol/mux/stream.rs:35
doc/lifetime_of_a_session.md:491  lib/src/protocol/mux/mod.rs:1650

113 file.rs:NNN occurrences exist across 7 files in doc/.

Why it matters beyond tidiness

A reader who follows one citation and lands on an unrelated line stops trusting the whole document.
These files are how a new contributor learns the session lifecycle and how an operator reasons about
max_connections_per_ip — the two audiences least able to tell a stale line number from a real one.

Options

  1. Cite symbols, not lines — ExpectProxyProtocol::readable instead of expect.rs:118. Cannot
    drift; costs nothing at write time; loses precision for a citation that names a specific branch
    rather than an item.
  2. A CI resolver. Extract every file.rs:NNN(-MMM)? from doc/** and **/LIFECYCLE.md, fail if
    the target file is missing, the line is past EOF, or the line is blank. That is cheap, catches the
    +1 class immediately, and would have caught all 7 above. It does not catch a citation that
    drifted onto a different non-blank line, so it is a floor, not a guarantee.
  3. Both — symbols where an item is named, line ranges only where a specific branch is meant, with
    the resolver guarding the survivors.

Happy to implement whichever the maintainers prefer; option 2 is a self-contained script plus one CI
cell.

Already fixed

The 25 corrections to lib/src/protocol/proxy_protocol/LIFECYCLE.md ship in #1334, because that file
is the module lifecycle document for the behaviour that PR changes. Nothing else was touched — this
issue covers the rest.

Activity

  1. FlorentinDUBOIS commented on Sep 18, 2026

    @FlorentinDUBOIS
    CollaboratorAuthor

    Concrete evidence that review alone cannot catch this class, observed while #1334 was open.

    #1334 corrected a stale citation in doc/lifetime_of_a_session.md to
    lib/src/tcp.rs:1530-1534, 1797-1802, verified to span comment-and-call at both Shutdown::Both
    sites. It was correct when written, correct when a reviewer checked it, and correct when committed.

    Then #1333 merged. It added 15 lines to lib/src/tcp.rs, and those two sites moved to
    1563-1567 and 1830-1835 — a +33/+34 drift. The citation was wrong before #1334 merged, without
    anyone touching doc/lifetime_of_a_session.md or the citation itself.

    It was caught only because the base drift was checked by hand before merging, and re-resolved to
    1563-1567, 1830-1835 in the landed version. Nothing in the process would have caught it otherwise:
    the file that broke the citation is not the file that contains it, so no diff shown to a reviewer of
    either PR contains both halves.

    This is the argument for option 2 (a CI resolver) over option 1 (symbol citations) alone: a resolver
    runs on the merge result, so it sees a citation invalidated by an unrelated PR. Symbol citations fix
    it more fundamentally where an item is being named, but a citation that deliberately points at a
    specific branch or range still needs a line span, and those are exactly the ones that drifted +38 to
    +57 here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions