Repository navigation
docs(mux,udp): re-anchor citations that drifted off their code - #1399
Merged
Merged
Conversation
check_doc_citations.py --base b51d9f9 (PR #1372's merge base, a Dependabot actions bump that touches no doc file) reported 9 of 56 compared citations drifted. Sweeping every remaining `file.rs:NNN` citation in both files against origin/main at 610eaa0 found roughly 60 more that the base comparison structurally cannot see, because the checker only compares a citation whose (path, line) pair is unchanged since the base -- and a prior PR (#1397, merged after this fix started) mechanically renumbered many h2.rs citations to track a 200+-line insertion without checking whether they pointed at the right place first. A renumbered-but-still-wrong citation drops out of every future --base comparison forever. STALE LINE NUMBERS (the large majority): each of these named a real construct correctly but the number had drifted, usually because later commits shifted the target file. Renumbered to the current line. Symbol form was not substituted because in every case the prose already names the symbol separately (e.g. "MAX_LOOP_ITERATIONS (mod.rs)") and the line number pins a *specific statement* among several uses of that same symbol (e.g. two separate MAX_LOOP_ITERATIONS comparisons, four separate self.context.now writes, many remove_dead_stream call sites) -- exactly the case doc/README.md's citation-form rule reserves for line citations, since no symbol names "this one occurrence" more precisely than a line does. Representative fixes: the MAX_LOOP_ITERATIONS backstop check (mod.rs:1216 -> 1762), the `counter` declaration above both ready_inner loops (mod.rs:793 -> 1335), the once-per-outer-pass and top-of-Mux::timeout clock samples (mod.rs:841 -> 1383, mod.rs:1430 -> 1965), the top-of-shutting_down sample (mod.rs:1929 -> 2338), frontend-HUP detection and the two MuxResult::CloseSession sites (mod.rs:795/860/1183 -> 1337/1402/1729), every StreamState::Link/Unlinked/Recycle transition site in h1.rs/h2.rs/answers.rs, the backend attach/detach citations (Router::connect, Context::link_stream, Context::unlink_stream), the Recycle-slot pool-clear/metrics-reset/search citations in Context::create_stream, the ConnectionH2.now mirror-assignment sites in readable/writable/cancel_timed_out_streams/start_stream, the outbound-byte and fc-stall-arm liveness refreshes in write_streams, the SETTINGS-ACK-timeout checks in readable and flush_pending_control_frames, the graceful-GOAWAY call chain (Mux::shutting_down -> graceful_goaway -> goaway), the backend-timeout action arm in Mux::timeout, and the flood-window / back-pressure-window fail-closed citations. udp/LIFECYCLE.md needed exactly the one CI-reported fix: armed_deadline's clear-before-reschedule statement (manager.rs:534 -> 535); the file was otherwise untouched by any PR since the merge base and every other citation in it still resolves correctly. A GENUINE PROSE ERROR, not a stale line number: section 4.1 and section 5.4 of mux/LIFECYCLE.md asserted that `handle_continuation_header_state`, `cancel_timed_out_streams`, `handle_rst_stream_frame`, `handle_goaway_frame` and `end_stream` perform `self.streams.remove(...)` inline instead of routing through the canonical `ConnectionH2::remove_dead_stream` helper, and told reviewers to apply its two invalidation checks (`expect_write`, `expect_read`) by hand at each one. That claim is now false: `self.streams.remove(` occurs exactly once in the whole of h2.rs, inside `remove_dead_stream` itself, and all five sites this section named as unsafe now call the helper -- several with a comment explicitly citing this LIFECYCLE.md section by name as the reason. Renumbering any of the five citations would have re-anchored them onto correct-looking but misleading targets, since the code they used to point at no longer exists as a distinct inline removal. Rewrote both sections instead: the "inline" call-site list is gone (there is nothing left to list), the five sites moved into the "goes through remove_dead_stream" list with fresh citations, and the prose now states plainly that the helper is the only removal path and performs both invalidation checks internally. The `close` backend-stream-teardown exception (which never removed at all) is kept and renumbered, since that half of the claim is still true. One citation the sweep missed, found by a separate check: section 8's frontend timeout handling cited `mod.rs:1473` for "`Mux::timeout` inspects each stream's state". That line is a `push_event(EventKind::BackendUp)` inside `ready_inner`, unrelated to timeouts. The state inspection the sentence describes is the `match self.context.streams[stream_id].state` at mod.rs:2018, whose arms are exactly the 408/503/504, forcefully-terminate and keep-draining outcomes the prose lists. Corrected to mod.rs:2018. It escaped both the --base comparison and the symbol sweep because the doc line names `Mux::timeout` while the citation must point inside `timeout_inner`, so a naive "is the cited line inside the named function" test cannot distinguish a correct delegation citation from a wrong one. Verified locally against origin/main at 610eaa0 (this task's second base; PR #1397 landed mid-task and required a full rebase and re-verification of every previously-computed line number): python3 .github/scripts/check_doc_citations.py --self-test # exit 0 python3 .github/scripts/check_doc_citations.py # exit 0 python3 .github/scripts/check_doc_citations.py --base b51d9f9 # red before this commit (matching the 9 CI-reported citations, minus the # 2 that PR #1397's mechanical renumbering had already dropped out of # comparison -- 7/54 reported at 610eaa0), green after (0/47 drifted) Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 21, 2026 11:09
pull Bot
pushed a commit
to jrcribb/sozu
that referenced
this pull request
Sep 21, 2026
The ignore rule's comment claimed a Rust version that existed would have silently raised the MSRV. Verified against the actual job log for `cargo audit` (run 35588449699): `dtolnay/rust-toolchain` runs `rustup default <ref>` and exports no `RUSTUP_TOOLCHAIN`, so the `rust-toolchain` directory override still pins cargo to 1.93.1 for any work inside this checkout. The real exposure is narrower and worth naming precisely: the steps that build outside the checkout — the lagging_server and bench_logger clones and `cargo install cargo-audit` — take the default toolchain, and the release build's own comment promises it matches the pinned MSRV. The reason to ignore the dependency is unchanged; only the description of the damage was wrong, and a wrong claim left in a comment is the failure mode sozu-proxy#1399 just finished repairing elsewhere in this tree. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 22, 2026
Move the wire StreamId -> GlobalStreamId map, highest_peer_stream_id, expect_read/expect_write, rst_sent, and the per-stream activity/flow-control-stall caches into lib/src/protocol/mux/h2_stream_table.rs, behind the same closed-API shape hpack_state.rs and h2_flow_control.rs established in the two prior extraction steps. ConnectionH2 keeps a single private stream_table: H2StreamTable field. create_stream, start_stream, remove_dead_stream and refuse_stream_and_discard stay on ConnectionH2 (they orchestrate Context, logging, metrics, the RFC 9218 prioriser and readiness, none of which the new module has), but their stream-table bookkeeping now delegates to H2StreamTable's narrow API. H2StreamTable::remove is the sole removal chokepoint, including the expect_read/expect_write gid invalidation LIFECYCLE.md SS5.4 documents; streams is now a private field of h2_stream_table.rs, so self.streams.remove(...) cannot be written from h2.rs any more, which was verified by temporarily reintroducing an inline removal and observing E0609 (reverted). This makes SS5.4's "no call site removes inline anymore" claim compiler-enforced instead of prose that can silently go stale, which already happened to it once (#1399). On this branch the claim was independently verified true before the move too: self.streams.remove occurred at exactly one call site, inside remove_dead_stream itself, so no parallel removal site needed eliminating here. Determinism fix: H2StreamTable::collect_timed_out (the reap-candidate union cancel_timed_out_streams drives) used to read stream_last_activity_at and stream_fc_stalled_since as plain HashMaps with `for (&k, &v) in map` loops, so which of several simultaneously-timed-out streams got RST_STREAM'd first was non-deterministic across process restarts -- the same class of leak issue #1338 decided to close, and the same fix step 2 already applied to pending_window_updates. That order flows onto the wire: collect_timed_out's returned order is the order cancel_timed_out_streams calls enqueue_rst in, which pushes onto pending_rst_streams, drained in push order. Both maps are now BTreeMap (stream_fc_stalled_progress converts alongside stream_fc_stalled_since since the two are documented as kept in lockstep), so collect_timed_out walks each guard group in ascending StreamId order. Every other iteration over the wire map itself was enumerated by reading (not only grepping for .iter()/.keys()/.values()/.drain(), which misses a `for (&k, &v) in &map` site) and found not to leak: the priority scheduler's HashMap-order keys() feed is immediately sorted by (urgency, *id), a total order; the GOAWAY retry loop and close()'s backend-teardown loop only affect scheduling order, not the bytes of a fixed frame set; and GOAWAY's own last_stream_id is the incrementally-updated highest_peer_stream_id scalar. H2StreamTable carries debug_assert! pre/post-conditions on every mutating method plus a check_invariants() sweep, matching h2_flow_control::H2FlowControl and protocol::udp::manager::UdpManager. router.rs reaches the wire-map length through a new ConnectionH2::stream_count() accessor, the sole external reader now that the field is private. LIFECYCLE.md citations are re-anchored by content throughout; doc/h2_mux_internals.md, doc/lifetime_of_a_session.md and doc/testing.md follow. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 22, 2026
Move the wire StreamId -> GlobalStreamId map, highest_peer_stream_id, expect_read/expect_write, rst_sent, and the per-stream activity/flow-control-stall caches into lib/src/protocol/mux/h2_stream_table.rs, behind the same closed-API shape hpack_state.rs and h2_flow_control.rs established in the two prior extraction steps. ConnectionH2 keeps a single private stream_table: H2StreamTable field. create_stream, start_stream, remove_dead_stream and refuse_stream_and_discard stay on ConnectionH2 (they orchestrate Context, logging, metrics, the RFC 9218 prioriser and readiness, none of which the new module has), but their stream-table bookkeeping now delegates to H2StreamTable's narrow API. H2StreamTable::remove is the sole removal chokepoint, including the expect_read/expect_write gid invalidation LIFECYCLE.md SS5.4 documents; streams is now a private field of h2_stream_table.rs, so self.streams.remove(...) cannot be written from h2.rs any more, which was verified by temporarily reintroducing an inline removal and observing E0609 (reverted). This makes SS5.4's "no call site removes inline anymore" claim compiler-enforced instead of prose that can silently go stale, which already happened to it once (#1399). On this branch the claim was independently verified true before the move too: self.streams.remove occurred at exactly one call site, inside remove_dead_stream itself, so no parallel removal site needed eliminating here. Determinism fix: H2StreamTable::collect_timed_out (the reap-candidate union cancel_timed_out_streams drives) used to read stream_last_activity_at and stream_fc_stalled_since as plain HashMaps with `for (&k, &v) in map` loops, so which of several simultaneously-timed-out streams got RST_STREAM'd first was non-deterministic across process restarts -- the same class of leak issue #1338 decided to close, and the same fix step 2 already applied to pending_window_updates. That order flows onto the wire: collect_timed_out's returned order is the order cancel_timed_out_streams calls enqueue_rst in, which pushes onto pending_rst_streams, drained in push order. Both maps are now BTreeMap (stream_fc_stalled_progress converts alongside stream_fc_stalled_since since the two are documented as kept in lockstep), so collect_timed_out walks each guard group in ascending StreamId order. Every other iteration over the wire map itself was enumerated by reading (not only grepping for .iter()/.keys()/.values()/.drain(), which misses a `for (&k, &v) in &map` site) and found not to leak: the priority scheduler's HashMap-order keys() feed is immediately sorted by (urgency, *id), a total order; the GOAWAY retry loop and close()'s backend-teardown loop only affect scheduling order, not the bytes of a fixed frame set; and GOAWAY's own last_stream_id is the incrementally-updated highest_peer_stream_id scalar. H2StreamTable carries debug_assert! pre/post-conditions on every mutating method plus a check_invariants() sweep, matching h2_flow_control::H2FlowControl and protocol::udp::manager::UdpManager. router.rs reaches the wire-map length through a new ConnectionH2::stream_count() accessor, the sole external reader now that the field is private. LIFECYCLE.md citations are re-anchored by content throughout; doc/h2_mux_internals.md, doc/lifetime_of_a_session.md and doc/testing.md follow. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 22, 2026
Move the wire StreamId -> GlobalStreamId map, highest_peer_stream_id, expect_read/expect_write, rst_sent, and the per-stream activity/flow-control-stall caches into lib/src/protocol/mux/h2_stream_table.rs, behind the same closed-API shape hpack_state.rs and h2_flow_control.rs established in the two prior extraction steps. ConnectionH2 keeps a single private stream_table: H2StreamTable field. create_stream, start_stream, remove_dead_stream and refuse_stream_and_discard stay on ConnectionH2 (they orchestrate Context, logging, metrics, the RFC 9218 prioriser and readiness, none of which the new module has), but their stream-table bookkeeping now delegates to H2StreamTable's narrow API. H2StreamTable::remove is the sole removal chokepoint, including the expect_read/expect_write gid invalidation LIFECYCLE.md SS5.4 documents; streams is now a private field of h2_stream_table.rs, so self.streams.remove(...) cannot be written from h2.rs any more, which was verified by temporarily reintroducing an inline removal and observing E0609 (reverted). This makes SS5.4's "no call site removes inline anymore" claim compiler-enforced instead of prose that can silently go stale, which already happened to it once (#1399). On this branch the claim was independently verified true before the move too: self.streams.remove occurred at exactly one call site, inside remove_dead_stream itself, so no parallel removal site needed eliminating here. Determinism fix: H2StreamTable::collect_timed_out (the reap-candidate union cancel_timed_out_streams drives) used to read stream_last_activity_at and stream_fc_stalled_since as plain HashMaps with `for (&k, &v) in map` loops, so which of several simultaneously-timed-out streams got RST_STREAM'd first was non-deterministic across process restarts -- the same class of leak issue #1338 decided to close, and the same fix step 2 already applied to pending_window_updates. That order flows onto the wire: collect_timed_out's returned order is the order cancel_timed_out_streams calls enqueue_rst in, which pushes onto pending_rst_streams, drained in push order. Both maps are now BTreeMap (stream_fc_stalled_progress converts alongside stream_fc_stalled_since since the two are documented as kept in lockstep), so collect_timed_out walks each guard group in ascending StreamId order. Every other iteration over the wire map itself was enumerated by reading (not only grepping for .iter()/.keys()/.values()/.drain(), which misses a `for (&k, &v) in &map` site) and found not to leak: the priority scheduler's HashMap-order keys() feed is immediately sorted by (urgency, *id), a total order; the GOAWAY retry loop and close()'s backend-teardown loop only affect scheduling order, not the bytes of a fixed frame set; and GOAWAY's own last_stream_id is the incrementally-updated highest_peer_stream_id scalar. H2StreamTable carries debug_assert! pre/post-conditions on every mutating method plus a check_invariants() sweep, matching h2_flow_control::H2FlowControl and protocol::udp::manager::UdpManager. router.rs reaches the wire-map length through a new ConnectionH2::stream_count() accessor, the sole external reader now that the field is private. LIFECYCLE.md citations are re-anchored by content throughout; doc/h2_mux_internals.md, doc/lifetime_of_a_session.md and doc/testing.md follow. Signed-off-by: Florentin Dubois <[email protected]>
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.
Repairs every
file.rs:NNNcitation inlib/src/protocol/mux/LIFECYCLE.mdandlib/src/protocol/udp/LIFECYCLE.mdthat no longer names the code it claims, and corrects one section whose prose is false rather than merely misnumbered.How this surfaced
PR #1372 is a Dependabot actions bump that touches no documentation at all. That is exactly what made it able to see this: its merge base is
b51d9f9a(2026-09-20), andcheck_driftonly compares a citation whose(path, spans)pair is unchanged since the base (.github/scripts/check_doc_citations.py:456-470). A pull request that edits these files re-anchors their citations, which removes them from comparison. #1372 edits nothing, so nothing was excluded, and it reported 9 drifted citations on a changeset that contains none of the code involved.The drift rule itself only landed today in
07ad3037, and thedoc-citationsjob one day earlier in21296c0b, so these citations went stale before any run could compare them.Two kinds of defect
Stale line numbers (the large majority, ~70 citations). Each named a real construct but the number had drifted as later commits shifted the target. Renumbered against
origin/mainat610eaa04. Representative:MAX_LOOP_ITERATIONSbackstopmod.rs:1216mod.rs:1762counterdeclaration above bothready_innerloopsmod.rs:793mod.rs:1335mod.rs:841mod.rs:1383Mux::timeoutclock samplemod.rs:1430mod.rs:1965Mux::shutting_downclock samplemod.rs:1929mod.rs:2338Context.nowfield declarationmod.rs:465mod.rs:523armed_deadlineclear-before-reschedulemanager.rs:534manager.rs:535Note
mod.rs:465andmod.rs:1430were not among the 9 CI reported: both were added afterb51d9f9a, so the rule treated them as deliberately re-anchored and skipped them. They were wrong anyway.manager.rs:534was an off-by-one that predates the recent churn entirely.The symbol form was not substituted here. In each case the prose already names the symbol separately and the line number pins one specific statement among several uses of it — four distinct
self.context.nowwrites, two distinctMAX_LOOP_ITERATIONScomparisons — which is the casedoc/README.mdreserves line citations for.A false claim, not a stale number. Sections 4.1 and 5.4 asserted that
handle_continuation_header_state,cancel_timed_out_streams,handle_rst_stream_frame,handle_goaway_frameandend_streamperformself.streams.remove(...)inline instead of routing throughConnectionH2::remove_dead_stream, and instructed reviewers to apply its two invalidation checks by hand at each. That is no longer true:One occurrence, inside
remove_dead_streamitself (fn remove_dead_streamath2.rs:3694). All five named sites now call the helper, several carrying a comment that cites this LIFECYCLE section by name as the reason. Renumbering them would have re-anchored a false statement onto correct-looking targets — which is how it survived: PR #1397 shifted these citations mechanically by +42 to track its own insertion, carrying the wrong claim forward intact.Both sections are rewritten. The "inline, unsafe" list is gone because nothing is left to list, the five sites moved into the "routes through the helper" list with fresh citations, and the
closebackend-teardown exception is kept and renumbered because that half is still true — it never removed at all.One further miss, caught by a second check
Section 8 cited
mod.rs:1473for "Mux::timeoutinspects each stream's state". That line is apush_event(EventKind::BackendUp)insideready_inner. The inspection the sentence describes ismatch self.context.streams[stream_id].stateatmod.rs:2018, whose arms are exactly the 408/503/504, forcefully-terminate and keep-draining outcomes the prose lists. Corrected.It escaped both the
--basecomparison and a symbol sweep because the doc line namesMux::timeoutwhile the citation must point insidetimeout_inner— so a plain "is the cited line inside the named function" test cannot separate a correct delegation citation from a wrong one.Mux::ready,Mux::timeoutandMux::shutting_downall delegate to an_innerfunction, and five other citations legitimately rely on that.Verification
Seen red before the fix, on the same command that CI runs:
(7 rather than the 9 CI reported: PR #1397 had already renumbered the two
h2.rs:4571citations, dropping them out of the comparison.)Documentation only — no code, no dependency, no test change.
check_doc_citations.pyis untouched and no citation was deleted to silence a failure.Unblocks the
Doc citationsjob on #1372.