Repository navigation
docs(mux): complete the module layout and stop stating line counts (#1520) - #1522
Merged
Merged
Conversation
…1520) doc/architecture.md's "Module layout" block is the only place under doc/ that says what each file in lib/src/protocol/mux/ is for. It listed 13 of the directory's 26 modules and hardcoded a size beside each one. Re-measured at 5355cec with `wc -l`, twelve of the thirteen were wrong: h2.rs stated 7562 against 15360, router.rs 678 against 2192, stream.rs 290 against 1274, shared.rs 93 against 646. debug.rs at 80 was right only because that file has not changed. The closing "18 666 lines of Rust across 13 modules" reads 43 092 across 26 — a total off by 24 426 lines. Take the first of the issue's two options: keep the module list and the descriptions, which a reader cannot cheaply re-derive, and delete every parenthesised count and the total. The block already told the reader to run `wc -l lib/src/protocol/mux/*.rs`; that sentence now is the whole answer rather than a footnote to a snapshot of it. Making the counts checkable was the alternative. The only gate that reads these documents is .github/scripts/check_doc_citations.py, so a count check is a new gate whose sole job is to guard an ornament; it would fire on nearly every changeset that touches this directory, with the fix always "re-run wc -l and paste"; and it would not have caught what actually went wrong, which is thirteen modules with no row at all. A membership check would catch that and would fire only on an add, a remove or a rename — it is worth its own changeset, and is deliberately not bundled here because it is a CI change and #1447 is open on that script. Until then the obligation is written into the block: adding a module means adding its row, and no gate enforces that either. All 26 modules are now listed, in the order the file had, with the extracted h2_* siblings and hpack_state.rs grouped under h2.rs. Every description is read off the module it names. The two stale ones the issue called out are corrected — mod.rs no longer claims Router and Stream, which live in router.rs and stream.rs, and h2.rs no longer claims flood detection or shutdown handling, which are h2_flood_detector.rs and h2_close.rs/h2_drain.rs. Two more clauses in that same h2.rs row were stale for the same reason and go with them: flow control is h2_flow_control.rs and the RFC 9218 priorities are h2_scheduler.rs. Four further rows were re-earned rather than re-typed: shared.rs held no state at all (it is four helper functions and an enum shared by the two write paths), serializer.rs also emits PING and WINDOW_UPDATE, connection.rs names the Connection enum and the two Endpoint adaptors, and debug.rs is a bounded event ring that compiles to a no-op without debug_assertions. One further correction, found sweeping doc/ for the same defect and checked against router.rs's own declaration: the Mux session diagram above the block declared `backends: HashMap<Token, Connection<TcpStream>>`. The field is a BTreeMap over SessionTcpStream. It became a BTreeMap in #1500 precisely so that which backend serves a request stops depending on per-HashMap RandomState seeding, so naming a HashMap there contradicted the guarantee that change exists to provide. Documentation only; no production code, test, dependency or Cargo.lock change. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 25, 2026 10:08
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 #1520.
Which option, and why
Option 1 — keep the module list and the descriptions, delete every parenthesised
count and the total, and let the
wc -lsentence the block already carried be the wholeanswer.
What moved me was not that the numbers were wrong — that is repairable — but what they
turned out to be measuring.
h2.rsis stated at 7562 and is 15360; its#[cfg(test)] mod testsopens at line 7784, so 7577 of those 15360 lines — just under half the file — areits own test module. The
number a reader takes as "how much implementation is in here" was, for the largest module
in the directory, mostly a test suite. A count that has to be explained before it can be
read is not carrying information the list needs, and the list is not the place to explain
it. Meanwhile the column the block exists for — what each file is for — is the one thing
wc -lcannot print, and it is also the one that had rotted furthest: thirteen modules hadno row at all, and four of the six clauses describing
h2.rsnamed code that now lives insibling files.
The argument against option 2, stated fairly. Line counts are a crude "where is the
complexity" signal, and a newcomer does want one; deleting them removes it. That is real,
and it is why the
wc -lsentence stays rather than going with them — the signal isavailable live, one command, already printed in the document.
What tips it is the cost of the gate. The only gate that reads these documents is
.github/scripts/check_doc_citations.py, so a count check is a new gate whose sole jobis to guard an ornament. It would fire on nearly every changeset that touches
lib/src/protocol/mux/, and that is measurable:git log -40 --format='%H' 5355cec0 -- lib/src/protocol/mux/ | wc -lreturns 40 of the last 40 commits onmain. Its fix isalways the same mechanical "re-run
wc -land paste", which is drift maintenance dressed upas a check. And it would not have caught what
actually went wrong here: a module with no row at all passes a count check trivially,
because a row that does not exist has no number to compare.
What neither option fixes, said out loud. Whoever adds a module still has to remember
to add its row. That is the obligation that actually rotted — thirteen times — and no gate
enforces it in either design. It is now written into the block itself rather than left
implicit. The check that would pay is a membership comparison between the rows and
lib/src/protocol/mux/*.rs: it fires only on an add, a remove or a rename, and its fix isexactly the thing a reader needs written. I have deliberately not built it here — it is a
CI change, #1447 is open on that script, and it deserves its own review rather than riding
in on a documentation fix.
Before / after
Measured on this branch's base
5355cec0withwc -l lib/src/protocol/mux/*.rs, so areviewer can re-run it rather than take my word.
The thirteen rows that existed
mod.rsStreamandRouter, which arestream.rsandrouter.rsh1.rsConnectionH1's single active streamh2.rsparser.rsserializer.rsconverter.rspkawa.rsconnection.rsConnectionenum and the twoEndpointadaptorsrouter.rsstream.rsStreamState,StreamParts, the bounded replay captureanswers.rsshared.rsdebug.rsdebug_assertionsdebug.rsis right by coincidence, and the coincidence is checkable: the file was createdat
11fa65c3(2026-04-15) and7ff6b8b2(2026-04-26) wrote the number, sogit log 7ff6b8b2..5355cec0 -- lib/src/protocol/mux/debug.rsreturns nothing — it has notbeen touched since.
h2.rs's description read "state machine, flow control, flood detection, RFC 9218priorities, shutdown handling". The issue named two of those as stale; four are, for
the same reason — flow control is
h2_flow_control.rs, flood detection ish2_flood_detector.rs, the RFC 9218 priorities areh2_scheduler.rs, and shutdownhandling is
h2_close.rs/h2_drain.rs.ConnectionH2still holds those states, but asnamed fields of those types, and the row now says what is left in the file itself: frame
dispatch, settings and connection state, and the edge-trigger discipline the module doc
calls itself the canonical home of.
The thirteen rows that were missing
Each description is read off the module — its
//!header where that header is stillaccurate, and its item inventory where it is not.
auth.rsbuffer_source.rsBufferSourcetrait andPoolBufferSource: where the core takes its buffers, and that a source may refuseh2_close.rsh2_control_tx.rsh2_drain.rsh2_flood_detector.rsh2_flow_control.rsh2_header_reassembly.rsh2_scheduler.rsh2_stream_table.rsStreamId→GlobalStreamIdmap, RST dedupe, per-stream liveness and stall cachesh2_transmit.rsh2_write_pass.rswrite_streamspasshpack_state.rsNo description is a guess. Where a module resisted one line I took the narrowest true
statement rather than padding it:
h2_control_tx.rssays "its lifetime cap" instead ofnaming the CVE, because the row is not the place to argue which of three mitigations that
cap belongs to, and the module doc does that at length.
The rows are verified against the tree as a set — 26 rows, 26 files, no extras, no
duplicates — rather than by eye.
doc/sweepgrep -rnE '\([0-9]{2,5} lines\)' doc/returns 13 hits, all in the block above. That wasthe starting point; I also swept
[0-9]+ linesin any form,[0-9]+ (modules|files|tests| crates|…), tree glyphs (├──/└──) across every file underdoc/, and bullet lists of*.rsfilenames.doc/architecture.md:301-315— thirteen(N lines)doc/architecture.md:318— "Total: 18 666 lines of Rust across 13 modules"doc/architecture.md:85—backends: HashMap<Token, Connection<TcpStream>>BTreeMap<Token, Connection<SessionTcpStream>>. It became aBTreeMapin #1500 precisely so that which backend serves a request stops depending on per-HashMapRandomStateseeding, so "HashMap" there contradicted the guarantee that change exists to providedoc/architecture.md:80-95— rest of the Mux session diagramfrontend: Connection<FrontRustls>,streams: Vec<Stream>,buffers: Box<dyn BufferSource>,listener: Rc<RefCell<L>>all matchmod.rs'sContextdeclarationdoc/README.md:97— "a range that drifts 46 lines"doc/README.md:112— "90 citation tokens across 25 files, 113 line targets, 68 drifted"19fd5d8c"; pinneddoc/README.md:171— "48 code spans here begin with a colon and 45 are…", "lists that run 15, 16 and 101 lines"check_doc_citations.py, which #1447 has open and this branch must not touch. Left for whoever lands thatdoc/README.md:263— "greweditor.rsby 21 lines… moved 24 citations, reported 2"doc/README.md:542— "195 citations across 190 files and 50 pre-existing failures"265d895d"; pinneddoc/benchmark.md:64— "8 lines of javascript"doc/h2_mux_internals.md:1111— "once that queue holds 200 entries"MAX_PENDING_RST_STREAMS: usize = 200inh2_control_tx.rs, and the prose names that constant in the same sentence, so the number has a named source a reader can followdoc/h2_mux_internals.md:1298— "LIFECYCLE.md invariant 25"doc/testing.md:97— the e2e module liste2e/src/tests/mod.rs"for the full module list" and ends in an ellipsisdoc/testing.md:537,541—udp_simulation.rs/tcp_preread_sim.rsdoc/health_checks.md:145-148— box-drawing glyphsFound outside
doc/, deliberately not fixed herelib/src/protocol/mux/LIFECYCLE.md§1.1 "Module layout" carries the same defect inits other half: its table names 11 of the 26 modules across 9 rows and omits 15,
including every extracted
h2_*excepth2_scheduler.rs. It states no counts, sodoc/architecture.md hardcodes mux line counts that nothing checks: 12 of 13 wrong, 13 modules missing, total off by 24k lines #1520's specific defect is absent, and it is outside the swept tree. It is also a
guarded document carrying 108 resolved citations of its own, so completing it means
moving those spans — a citation-remap changeset rather than a table edit. Worth its own
issue.
h2.rs's andmod.rs's own//!headers have rotted the same way the block had.h2.rs:3-6still says it owns "HPACK encoder/decoder, peer settings, flow window" —it holds those as
hpack_state/h2_flow_controlfields now — andmod.rs:8-11listsConnectionandStreamamong its key types, which areconnection.rsandstream.rs. Not fixed: 43 resolved citations targetmux/h2.rs, so editing it movesspans, and a documentation-only PR is the wrong place to take that risk.
lib/src/protocol/kawa_h1/LIFECYCLE.md§1.2 — checked, complete (4 rows, 4.rsfiles). Unaffected.
CHANGELOG
Entry added under
### 🐛 Fixed, following #1461 (docs(mux-h2): repoint H2DrainState field narration at h2_drain.rs), which is the nearest precedent: a documentation-onlychange that corrected wrong statements and carried a CHANGELOG entry under
Fixed. #1510and #1452 are documentation-led changes that did the same. The one recent doc change that
carried no entry, #1480, was a mechanical citation-form sweep across 29 source files, which
is a different kind of thing. The entry is placed further down the section rather than at
its head, to avoid colliding with the other branches in flight.
Citation-remap evidence
doc/architecture.mdcontains nofile.rs:NNNcitation and nothing cites into it —verified before editing and again after:
So the remap ledger is: 0 spans drifted, 0 remapped, 0 went exempt. That is not an
assumption —
--basereports it explicitly:Two-key EXEMPT audit: vacuous, because the set is empty. Audited via the script's
--showoutput rather thangrep -c EXEMPT(the script writes "exempt" in lowercaseprose, so a naive count returns a false zero and skips the audit):
--showemits 0 lines containing the tokenEXEMPT, and--baseindependentlyreports
0 re-anchored spans. Both agree, so there is no span to audit on either key(byte-identical line text, identically-named enclosing
fn). The totals are unchangedfrom the pre-edit baseline on every rule: 186 citations resolved, 297 cited lines compared,
578 test names, 16 pinned blocks. The candidate-identifier count moved 5598 → 5614 (words
this PR's CHANGELOG entry adds); the checked count did not, i.e. the entry introduces no
test-name citation.
CHANGELOG.mdis read only by the test-name rule, which is position-independent(
doc/README.md:542), so inserting into it moves no citation.Verification battery
Every command below was run against the tree at
470ba2f4, exit code read directly ratherthan through a pipe.
cargo build --locked --no-default-features --features crypto-ring,opentelemetry,splice,simdFinished dev profile [unoptimized + debuginfo] target(s) in 16.56scargo +nightly fmt --all -- --checkcargo build, and aftercargo +nightly fmt --allapplied — which changed nothing, no Rust was touched)cargo clippy --all-targets --locked --no-default-features --features crypto-ring,opentelemetry,splice,simd -- -D warningsFinished dev profile … in 13.22scargo test -p sozu-lib --locked --no-default-features --features crypto-ring,opentelemetry,splice,simd1120 passed; 0 failed; 0 ignored(+1,1, and5 passed; 5 ignoredsuites)cargo test -p sozu --locked --no-default-features --features crypto-ring,opentelemetry,splice,simd113 passed; 0 failed; 0 ignored(×2)cargo test -p sozu-e2e --locked --no-default-features --features crypto-ring,opentelemetry,splice,simd -- --skip tests::fuzz_tests::447 passed; 0 failed; 0 ignored; 4 filtered out; finished in 379.13sRUSTFLAGS="--cfg tokio_unstable" cargo test -p sozu-sim --locked12,6,6,6 passed; 0 failedRUSTFLAGS="--cfg tokio_unstable" cargo clippy -p sozu-sim --all-targets --locked -- -D warningsFinished dev profile … in 8.56spython3 .github/scripts/check_doc_citations.py --self-testOK self-test: 48 fixture line citations, 39 … compared …python3 .github/scripts/check_doc_citations.py --root .OK: all 186 … citations … resolve to a non-blank line.python3 .github/scripts/check_doc_citations.py --base 5355cec0185c07c81e2334fca73ec290749d1daeOK: none of the 297 cited lines … changed their text./0 re-anchored spans were exemptpython3 .github/scripts/check_doc_citations.py --audit --root .7 of 90 examined citations do not plainly match the prose citing them— advisory, pre-existing, none in a file this changeset touches (grep -c architecture.mdover the audit output → 0)RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --lockedGenerated target/doc/sozu/index.html and 4 other filescargo bench -p sozu-lib --bench h2_stream_table -- --testSuccesson every benchmarkNo check was weakened, skipped, newly ignored, or given a lint escape to reach green.
Scope
Documentation only:
doc/architecture.md(+73/−18) andCHANGELOG.md(+36). Noproduction code, test, dependency or
Cargo.lockchange. Does not touch.github/scripts/check_doc_citations.py,lib/src/protocol/mux/router.rs,lib/src/udp.rs,sim/, or the### 🔄 Changedsection head.