Repository navigation
docs(mux-h2): repoint H2DrainState field narration at h2_drain.rs and pin its arming invariant - #1461
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 22, 2026 21:24
FlorentinDUBOIS
force-pushed
the
fix/drain-state-narration
branch
from
September 23, 2026 01:27
70d236e to
160894d
Compare
#1425 moved the RFC 9113 §6.8 GOAWAY/drain state machine into h2_drain.rs and made all five H2DrainState fields private. Five sentences outside that module still described them as reachable from h2.rs; two were false rather than merely loose. mux/LIFECYCLE.md §8.3 attributed `drain.started_at = Some(now)` to ConnectionH2::graceful_goaway, which reads and writes none of the five and delegates to H2DrainState::begin_graceful_drain. The passage now names that method and PINS the debug_assert guarding the assignment as a fenced quote of h2_drain.rs:234-237, so the invariant it encodes — the budget arms exactly once, on the first call — is carried verbatim by the source instead of paraphrased beside it. #1432 added that mechanism for exactly this case; quoted unpinned, the sentence drifts silently the moment the message is reworded. Seen red: rewording the message to "on the very first call" exits 1 naming the block, and restoring it exits 0. The same attribution sat in production source: the RFC 9113 §6.8 comment guarding new peer-initiated streams said graceful_goaway sets `drain.draining = true`. Only that mechanism clause changed; the argument around it is correct and is kept. The comment keeps its exact line count so the 88 h2.rs citations below it and the pinned code blocks do not drift. doc/h2_mux_internals.md's priority-cleanup list cited close_all_streams, which has never existed under lib/ at any revision. ConnectionH2::goaway is the nearest-sounding real function and is the wrong target: it touches neither the prioriser nor the stream map. GOAWAY-time removal is handle_goaway_frame plus prune_inactive_streams_while_closing, both reaching remove_dead_stream once per retired stream, and neither clears the map wholesale. Two further hits from the same sweep: doc/lifetime_of_a_session.md placed H2DrainState::draining in h2.rs, and doc/architecture.md credited H2DrainState with "pending RST streams", which are H2StreamTable's pending_rst_streams. That bullet names the struct's role and its module and enumerates nothing: replacing a wrong five-field list with a right one keeps the restated copy that drifted in the first place. Sweep, read against c359eaf: git grep -En 'drain\.|draining|started_at|graceful_shutdown_deadline|peer_last_stream_id|initial_goaway_pending' \ c359eaf -- lib/ doc/ | grep -v h2_drain.rs 338 hits across 36 files read. 3 of those hit lines changed, across 2 files: LIFECYCLE.md twice and h2.rs once. A 4th hit had the module path beside it corrected (lifetime_of_a_session.md), and 2 further sites carry no pattern token and so sit outside the hit set altogether — h2_mux_internals.md's close_all_streams and architecture.md's sub-struct bullet. Five sites in all. The trailing `.` above is escaped and means a literal field access; as an unescaped regex any-char the same sweep returns 933 hits across 52 files. doc/h2_mux_internals.md:617 and :621 are among the hits read and deliberately left: they narrate module-internal state in the register h2_drain.rs's own doc comments use and claim nothing about reachability. No rule in check_doc_citations.py reached any of these when written: the drift rule compares a cited line at two revisions and these documents do not modify h2.rs; the dead-name rule resolves test names only; a code comment is in no rule. The pinned debug_assert is the one that need not stay that way. Refs: #1446 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/drain-state-narration
branch
from
September 23, 2026 02:25
160894d to
b4dc2b6
Compare
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 #1446.
#1425 moved the GOAWAY/graceful-drain state into
lib/src/protocol/mux/h2_drain.rsand made its fields private to that module. Five places still described those
fields as reachable from
h2.rs, and one of them was not merely stale but wrong.What was wrong
doc/architecture.mdenumerated all fiveH2DrainStatefields in prose, and theenumeration had already drifted into naming "pending RST streams" — which belong
to
H2StreamTable, not toH2DrainState.LIFECYCLE.mddescribedConnectionH2::graceful_goawayas reading and writingH2DrainStatefields. It does neither: its body isself.header_block_reassembly_in_progress()followed bymatch self.drain.begin_graceful_drain(...).close_all_streamsthat exists nowhere. The realsubstitutes are
handle_goaway_frameandprune_inactive_streams_while_closing,which each reach
remove_dead_streamonce per retired stream; neither clearsthe map, which is the property the prose was reaching for.
The fix removes the copy rather than correcting it
doc/architecture.mdno longer enumerates fields. It now names the struct and themodule that owns them:
A restated five-field list is guaranteed to drift again; a role description
cannot. The sibling bullets do enumerate, so this is slightly off-register for the
file — that is a deliberate trade, not an oversight.
The invariant is now pinned, and the pin was seen red
LIFECYCLE.mdquoted the tail of adebug_assert!message — "armed exactlyonce, on the first call" — as free prose, so it would drift silently if the
message were reworded. It is now a pinned block against
lib/src/protocol/mux/h2_drain.rs:234-237, copied verbatim from source, whichrule 4 compares byte-for-byte. Pin count 18 → 19.
Proof it detects anything: rewording the assert message to "on the very first
call" makes the gate exit 1 naming that block; restoring it returns exit 0. The
prose paraphrase that sat beside the quote was removed — a pin plus a
paraphrase is the same two-copies defect this changeset is about.
The claim the pin guards is exact:
begin_graceful_drainarmsstarted_atbehinddebug_assert!(self.started_at.is_none(), ...), and theGracefulDrainDecision::AlreadyDrainingarm returns before the assignment.Sweep, as the issue asked
The issue asks for hits read alongside hits changed, so both are recorded in the
commit body: 338 hits across 36 files read, 5 sites changed. (Note
drain\.is a literal field access — as a regex
.it matches 933 hits across 52 files,which is the wrong number to quote.)
doc/h2_mux_internals.md:617,621are leftalone; the issue puts them out of scope.
Two CHANGELOG sentences that the fixes themselves falsified were corrected in the
same pass: one still said the doc "names the five fields", and a blanket "reachable
by no rule" was no longer true once the pin put one of them under rule 4.
Verification
lib/src/protocol/mux/h2.rsis 8802 lines before and after — the comment editis deliberately -4/+4, so none of the 88 h2.rs citation groups below it move.
CI's own per-crate commands with
FLAGS='--no-default-features --features crypto-ring,opentelemetry,splice,simd':cargo +nightly fmt --all -- --check,build,clippy -D warnings,test -p sozu-lib(992 passed),test -p sozu,test -p sozu-e2e(445 passed),both
sozu-simtargets — all exit 0, zero failures.Citation gate
--root .,--base, and--self-testall exit 0; 241 citations,369 test names, 19/19 pinned blocks verbatim.
git merge-treeagainstmainexits 0 and the gate re-run inside the extracted merged tree also exits 0.
CHANGELOG: one entry added, no duplicates, no heading drift.