Repository navigation
refactor(mux-h2): extract the RFC 9218 scheduling decision into h2_scheduler.rs - #1465
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 23, 2026 03:27
…heduler.rs
`ConnectionH2::write_streams` built the write pass's stream order, its
same-urgency ready-incremental census and its round-robin cursor inline, over
state scattered across three owners: `Prioriser` on the connection, the pass
order buffer on `HpackState` as `priorities_buf` — where the first extraction
step had parked a buffer that holds priority-sorted stream ids and never HPACK
bytes — and a `HashMap<u8, usize>` census rebuilt per pass as a local.
Give that decision its own module, behind the closed API the `hpack_state` /
`h2_flow_control` / `h2_stream_table` / `h2_drain` / `h2_flood_detector` /
`h2_header_reassembly` steps established. `H2Scheduler` owns `Prioriser`
(moved verbatim, tests included) and the order buffer; `begin_pass` returns
the pass order and a `ReadyIncrementalCensus`; `end_pass` takes the buffer
back and commits the cursor. It runs at exactly the point `write_streams`
used to call `put_priorities_buf` and `advance_incremental_cursor`, so a
MadeYouReset cap trip that returns a GOAWAY early still skips both.
The one fact the scheduler cannot own is whether a stream has anything to
send: that reads `Context.streams[gid].{front,back}` and
`H2StreamTable::rst_sent`, live stream storage this module has no business
holding. `begin_pass` takes it as data — a `FnMut(StreamId) -> bool`
projection the caller computes — and calls it for incremental streams only,
the same streams the inline census evaluated. There is no `&mut Context`, no
`Kawa`, no socket and no clock anywhere in the new module.
No behaviour change on the wire. The per-pass `HashMap<u8, usize>` becomes a
fixed `[usize; 8]`: RFC 9218 §4.1 urgency is `[0, 7]` and
`Prioriser::push_priority` already clamps to it. State that saving exactly,
because it is conditional. `HashMap::new()` allocates nothing; the FIRST
`entry().or_insert()` allocates and a fifth distinct bucket allocates again on
the grow. So it is one heap allocation fewer on every write pass carrying at
least one ready incremental stream, two when five or more buckets are
populated, and nothing at all on a pass with no ready incremental stream —
the common case, since RFC 9218's default is `i=0`. The pass still allocates
once inside `sort_by_cached_key` for two or more streams, before and after
alike. What is unconditional is an array index in place of a hash lookup at
each of the four sites that read or decrement the census. The only visible
difference is the `PRIORITIES` `trace!` line, which now prints eight buckets
in a fixed order instead of a `HashMap`'s per-process-seeded one. The three
mid-pass decrements of LIFECYCLE.md invariant 17 become one
`ReadyIncrementalCensus::note_ineligible`, so the non-incremental guard and
the `saturating_sub` exist once rather than three times.
`converter.rs` is untouched — byte-identical to its parent. Collapsing
`incremental_mode && incremental_peer_count > 1` into one scheduler-computed
`may_interleave` is sound: only `next_closes_stream` needs
`kawa.blocks.front()` and it would stay put, leaving
`may_interleave && !next_closes_stream` in the DATA arm. It is deferred
because editing that file forfeits the byte-identity that is this step's
evidence for its no-new-copy claim on the write path, not because the
collapse is unsound.
Docs: LIFECYCLE.md gains invariant 26 — RFC 9218 §4 incremental leadership
rotates inside the bucket that leads the pass: rotate AND commit, or a stream
starves, and no further. It names scheduler fairness as a checkable rule for
the first time, WITH its boundary. `incremental_cursor` is one
connection-global stream id, so only the lowest-numbered urgency bucket with
a firing incremental stream rotates; `apply_incremental_rotation` applies
that cursor to every bucket's tail, but a foreign id range makes
`partition_point` return a constant. Measured: u=0 incremental {1, 3} beside
u=3 incremental {5, 7}, all ready and consuming, six passes — u=0 alternates
1, 3, 1, 3 while u=3 is 5, 7 in every pass and stream 7 never leads. That is
positional starvation and a `FlushOutcome::Stalled` at 5 turns it into byte
starvation for 7. It is pre-existing — `Prioriser` is byte-identical and its
field doc always scoped the cursor this way — and it is now pinned as
observed behaviour by
`the_round_robin_cursor_is_connection_global_so_only_the_leading_bucket_rotates`
rather than left for a later step to assume away. Per-bucket rotation needs
`incremental_cursor: [StreamId; 8]`, a per-bucket leader in the census and a
matching `end_pass`; it changes wire ordering on multi-bucket connections and
belongs in its own changeset. Invariants 15 and 17 are rewritten against the
new home. `doc/h2_mux_internals.md`'s `apply_incremental_rotation` exposition,
and the two pinned blocks quoting the inline sort and the rotation call,
describe an implementation this step moves out of `h2.rs`; they are replaced by
what `begin_pass` actually does, which is an API the document can state without
quoting a body that no longer lives there. Citation endpoints across
LIFECYCLE.md and `doc/testing.md` are re-derived by ALIGNING the base and head
files line by line — the offsets in `h2.rs` are not uniform, so matching on
line text lands on whichever identical occurrence is nearest — and five
anchors whose cited text is not unique in the file now name their enclosing
symbol as well.
Tests: `Prioriser`'s unit tests and the nine rotation tests move with the
type. The three scalar `ready_incremental_bucket_decrement_*` tests are
replaced by `note_ineligible_reduces_only_its_own_bucket` / `_saturates_at_zero`
/ `note_ineligible_is_a_no_op_for_a_non_incremental_stream`, which drive the
production method — the ones they replace re-implemented the `saturating_sub`
inline in the test body and could not have caught the scheduler getting it
wrong. Fairness gets `incremental_leadership_rotates_one_position_per_pass`,
`no_incremental_peer_is_starved_over_a_full_cycle` (five peers, not two: a
rotation bug that swaps a pair still looks fair on two streams and starves the
fifth), `a_window_blocked_stream_does_not_take_the_lead`,
`a_pass_with_no_incremental_progress_leaves_the_cursor_alone`, and the
`quickcheck` property
`fairness_property::qc_incremental_leadership_visits_every_peer_once_per_cycle`
over 2..=8 peers, their ids and gaps, the shared urgency bucket, 1..=4 cycles
and a distractor set that must not perturb the rotation. Its oracle is the
cyclic successor in the generated plan's own ascending id list, computed from
the plan and never from anything the scheduler returned — a sibling of
`write_pass_property` and `reassembly_property`, not a case inside either. Its
distractors sit in strictly lower-priority buckets, so its main bucket is
always the pass leader, which is the scope invariant 26 claims.
What these tests close is the composition, not the primitive. At the parent
commit, deleting the `advance_incremental_cursor` call site from
`write_streams` leaves the whole `protocol::mux` suite green — 402 passed, 0
failed. The rotation was pinned; the rotate-and-commit pair was not. Every
test carries a TO SEE THIS RED recipe naming the statement to delete and the
panic it produces; all six were executed.
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
refactor/h2-stream-scheduling
branch
from
September 23, 2026 04:52
d157222 to
7f166ba
Compare
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 23, 2026
`check_doc_citations.py`'s `CITATION` pattern requires a path, so the idiom that names a file once and continues with a bare line number — `lib/src/tcp.rs:183` and `:305` — produced a second citation that no rule in the file could see. Not rule 1, not rule 2, not rule 3, not rule 4: it was never extracted, so it was never resolved, never drift-compared, and never reported as unresolvable either. The first half of every pair was checked on every CI run and the second half had never been checked once. #1465 is the worked case, and it is why this tree carried a wrong citation rather than three correct ones. `3e9c271c` moved both call sites of `h2_handshake_chromium_146` down one line; it bumped the half a rule could see and left the half no rule could: - `h2_correctness_tests.rs:3604` and `:3708`. No test that decodes … + `h2_correctness_tests.rs:3605` and `:3708`. No test that decodes … Both numbers were right at `3e9c271c^` and only the first was right after, with the `Doc citations` job green throughout. Run this changeset's gate over that commit and it reports the other half: $ git worktree add --detach /tmp/repro 3e9c271 $ python3 .github/scripts/check_doc_citations.py --root /tmp/repro \ --base 3e9c271^ ::error::1 of 215 compared citations drifted since 970b92c: doc/testing.md:680: `h2_correctness_tests.rs:3708` — …:3708 moved: was `let _server_settings = h2_handshake_chromium_146(&mut tls);`, now `let mut tls = raw_h2_connection(front_addr);` Extract the form and bind it. A bare `:NNN` is ordinary prose, so both discriminators were measured on this tree rather than guessed. It must be a CODE SPAN OF ITS OWN: the guarded surface holds 154 bare `:NNN` that are not, and not one is a citation — TOML listen addresses, `curl` URLs, statsd lines, log timestamps, a `1:100` ratio, `--ulimit nofile=262144:262144`. And it must hold A COLON, ONE SPAN GROUP AND NOTHING ELSE: 48 code spans begin with a colon and 45 are HTTP/2 pseudo-headers or prose, most of them `:authority` and `:status`. Together they take the tree from 232 extracted citations to 235: the three that exist, and no others. Both counts are read at `ce80b00c`; this changeset's own prose adds seven colon-leading code spans, so the second re-measured here reads 55. The span group is `CITATION`'s own, so `:3/5` and `:3, 5` are extracted exactly as `:3` and `:3-5` are. A single span there reads as the narrower, safer choice and is the opposite: this tree uses `/` groups heavily (`answers.rs:209/224`, `mod.rs:1218/1233/1311/1321`), so a bare one is a form an author reaches for, and a pattern that does not match it puts that citation back where #1459 found it. A bare group goes through the repeated-line check like any other, so `:3/3` — a group renumbered on one half only with its path dropped — is now reported. The path is inherited from the nearest written-out citation EARLIER ON THE SAME SOURCE LINE, the tightest scope covering all three sites. Wider is not free: all three sit inside bullet lists that run 15, 16 and 101 lines without a blank line, so a paragraph-scoped carry would search a hundred lines back in `doc/testing.md` and bind a stray port number to whatever path it found there. A wrong binding is worse than none, because rule 1 then confirms it lands on a non-blank line and it reads as resolved. A bare span that finds nothing on its own line is REPORTED, never skipped. That scope is asserted rather than described, which it was not at first. Three ways the sentence above can be weakened, each with a fixture whose verdict changes under it: binding to the FIRST citation on the line instead of the nearest (`doc/bad.md:22` puts two paths on one line, so a first-binding report names `h2.rs` instead of `sample.rs`), carrying over the PARAGRAPH (`doc/bad.md:30` is a bare span one line below a citation in its own paragraph, and a paragraph carry binds it to a real non-blank line so the failure vanishes) and carrying over the DOCUMENT (`doc/bad.md:33`). All three exit 1 now. The first two exited 0 against the first version of these fixtures, and on the real tree the paragraph widening produced byte-identical `--show` output, so nothing anywhere would have reported it. One of the three continuations was wrong the day it became visible, in two places. `doc/testing.md:680` cited `h2_correctness_tests.rs:3605` and `:3708` for the two call sites of `h2_handshake_chromium_146`, and `:3708` was `let mut tls = raw_h2_connection(front_addr);` — the line above the one the prose means. `grep -n` puts the sites at 3605 and 3709; the citation is now `:3709`, re-derived from that grep. `e2e/src/tests/h2_utils.rs`'s `decode_status` doc comment carries a near-duplicate of that paragraph, outside the guarded surface where no rule reaches it, and it had drifted further: its own bare continuation read `:3663` (a bare `}`), its written-out half `:3559` (a `use` list) and its arming site `lib/src/protocol/mux/h2.rs:5838` (a bare `}`) against a real site at `:5254`. All three repaired by grep; `converter.rs:112`, `h2_utils.rs:721` and `h2_security_tests.rs:2440` were verified correct and left alone. Repairing one copy of a fact and knowingly leaving the other is the defect this changeset is about. The remaining two continuations are exact and stay as written, both verified by grep rather than by trusting the issue's list: `lib/src/tcp.rs:183`/`:305` are that file's only two `let frontend_address = socket.peer_addr().ok();` lines, and `mux/router.rs:394`/`:574` its only two `context.link_stream(stream_id, token);` calls. Rules 1 and 2 read every document through one `citations()` generator, base revision included, so a bare span's drift identity is its inherited `(path, spans)` exactly as a written-out one's is. What that buys on THIS changeset, rather than in general: the two correct continuations are compared and read unmoved — `--base` goes from 358 compared line ends to 360 — and the repaired one is exempt as re-anchored, so it carries rule 1 alone here. Nothing is retroactively drift-checked. #1457's identity gap is untouched: a bare GROUP is now caught by the repeated-line check, but `x.rs:3` followed by a SEPARATE bare `:3` is two citation groups and that check only ever looks inside one. Seen red before green: with the extraction deleted and the fixtures, the named assertions and the new constants kept, `--self-test` exits 1 reporting that the bare continuation on `doc/bad.md:9` was not reported. `doc/bad.md` carries six continuations now — two bound and wrong, one bound group, one unbindable group and two unbindable spans that pin the scope — and `doc/drift.md` and its base revision carry one whose inherited line moved, so rule 2 must report it through the same extractor instead of merely counting it. `FIXTURE_TOTAL` 30 -> 41, `FIXTURE_DRIFT_COMPARED` 31 -> 32, `FIXTURE_EXPECTED` 9 -> 15 entries, `FIXTURE_DRIFT_EXPECTED` 2 -> 3, plus `FIXTURE_BARE_EXPECTED`, `FIXTURE_BARE_NEAREST_EXPECTED`, `FIXTURE_BARE_SAME_LINE_EXPECTED` and `FIXTURE_BARE_GROUP_EXPECTED`, each naming the citation a count assertion can only report as missing. Every other fixture constant is unchanged. `doc/README.md` gains the form, its three constraints and the measurement behind each, written without a real line number because that document is inside the guarded surface; it also names the one rule the bare form does not reach. `lib/src/protocol/mux/LIFECYCLE.md` names the form in its own anchoring preamble, which uses it once. The `[Unreleased]` entry that described this form as one the regex "cannot see" gains a clause saying #1459 closed it. The job box in `.github/workflows/ci.yml` is deliberately untouched: it asks for one clause per RULE, and this changes rule 1's extraction rather than adding a fifth. Closes #1459. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 23, 2026
`check_doc_citations.py`'s `CITATION` pattern requires a path, so the idiom that names a file once and continues with a bare line number — `lib/src/tcp.rs:183` and `:305` — produced a second citation that no rule in the file could see. Not rule 1, not rule 2, not rule 3, not rule 4: it was never extracted, so it was never resolved, never drift-compared, and never reported as unresolvable either. The first half of every pair was checked on every CI run and the second half had never been checked once. #1465 is the worked case, and it is why this tree carried a wrong citation rather than three correct ones. `3e9c271c` moved both call sites of `h2_handshake_chromium_146` down one line; it bumped the half a rule could see and left the half no rule could: - `h2_correctness_tests.rs:3604` and `:3708`. No test that decodes … + `h2_correctness_tests.rs:3605` and `:3708`. No test that decodes … Both numbers were right at `3e9c271c^` and only the first was right after, with the `Doc citations` job green throughout. Run this changeset's gate over that commit and it reports the other half: $ git worktree add --detach /tmp/repro 3e9c271 $ python3 .github/scripts/check_doc_citations.py --root /tmp/repro \ --base 3e9c271^ ::error::1 of 215 compared citations drifted since 970b92c: doc/testing.md:680: `h2_correctness_tests.rs:3708` — …:3708 moved: was `let _server_settings = h2_handshake_chromium_146(&mut tls);`, now `let mut tls = raw_h2_connection(front_addr);` Extract the form and bind it. A bare `:NNN` is ordinary prose, so both discriminators were measured on this tree rather than guessed. It must be a CODE SPAN OF ITS OWN: the guarded surface holds 154 bare `:NNN` that are not, and not one is a citation — TOML listen addresses, `curl` URLs, statsd lines, log timestamps, a `1:100` ratio, `--ulimit nofile=262144:262144`. And it must hold A COLON, ONE SPAN GROUP AND NOTHING ELSE: 48 code spans begin with a colon and 45 are HTTP/2 pseudo-headers or prose, most of them `:authority` and `:status`. Together they take the tree from 232 extracted citations to 235: the three that exist, and no others. Both counts are read at `ce80b00c`; this changeset's own prose adds seven colon-leading code spans, so the second re-measured here reads 55. The span group is `CITATION`'s own, so `:3/5` and `:3, 5` are extracted exactly as `:3` and `:3-5` are. A single span there reads as the narrower, safer choice and is the opposite: this tree uses `/` groups heavily (`answers.rs:209/224`, `mod.rs:1218/1233/1311/1321`), so a bare one is a form an author reaches for, and a pattern that does not match it puts that citation back where #1459 found it. A bare group goes through the repeated-line check like any other, so `:3/3` — a group renumbered on one half only with its path dropped — is now reported. The path is inherited from the nearest written-out citation EARLIER ON THE SAME SOURCE LINE, the tightest scope covering all three sites. Wider is not free: all three sit inside bullet lists that run 15, 16 and 101 lines without a blank line, so a paragraph-scoped carry would search a hundred lines back in `doc/testing.md` and bind a stray port number to whatever path it found there. A wrong binding is worse than none, because rule 1 then confirms it lands on a non-blank line and it reads as resolved. A bare span that finds nothing on its own line is REPORTED, never skipped. That scope is asserted rather than described, which it was not at first. Three ways the sentence above can be weakened, each with a fixture whose verdict changes under it: binding to the FIRST citation on the line instead of the nearest (`doc/bad.md:22` puts two paths on one line, so a first-binding report names `h2.rs` instead of `sample.rs`), carrying over the PARAGRAPH (`doc/bad.md:30` is a bare span one line below a citation in its own paragraph, and a paragraph carry binds it to a real non-blank line so the failure vanishes) and carrying over the DOCUMENT (`doc/bad.md:33`). All three exit 1 now. The first two exited 0 against the first version of these fixtures, and on the real tree the paragraph widening produced byte-identical `--show` output, so nothing anywhere would have reported it. One of the three continuations was wrong the day it became visible, in two places. `doc/testing.md:680` cited `h2_correctness_tests.rs:3605` and `:3708` for the two call sites of `h2_handshake_chromium_146`, and `:3708` was `let mut tls = raw_h2_connection(front_addr);` — the line above the one the prose means. `grep -n` puts the sites at 3605 and 3709; the citation is now `:3709`, re-derived from that grep. `e2e/src/tests/h2_utils.rs`'s `decode_status` doc comment carries a near-duplicate of that paragraph, outside the guarded surface where no rule reaches it, and it had drifted further: its own bare continuation read `:3663` (a bare `}`), its written-out half `:3559` (a `use` list) and its arming site `lib/src/protocol/mux/h2.rs:5838` (a bare `}`) against a real site at `:5254`. All three repaired by grep; `converter.rs:112`, `h2_utils.rs:721` and `h2_security_tests.rs:2440` were verified correct and left alone. Repairing one copy of a fact and knowingly leaving the other is the defect this changeset is about. The remaining two continuations are exact and stay as written, both verified by grep rather than by trusting the issue's list: `lib/src/tcp.rs:183`/`:305` are that file's only two `let frontend_address = socket.peer_addr().ok();` lines, and `mux/router.rs:394`/`:574` its only two `context.link_stream(stream_id, token);` calls. Rules 1 and 2 read every document through one `citations()` generator, base revision included, so a bare span's drift identity is its inherited `(path, spans)` exactly as a written-out one's is. What that buys on THIS changeset, rather than in general: the two correct continuations are compared and read unmoved — `--base` goes from 358 compared line ends to 360 — and the repaired one is exempt as re-anchored, so it carries rule 1 alone here. Nothing is retroactively drift-checked. #1457's identity gap is untouched: a bare GROUP is now caught by the repeated-line check, but `x.rs:3` followed by a SEPARATE bare `:3` is two citation groups and that check only ever looks inside one. Seen red before green: with the extraction deleted and the fixtures, the named assertions and the new constants kept, `--self-test` exits 1 reporting that the bare continuation on `doc/bad.md:9` was not reported. `doc/bad.md` carries six continuations now — two bound and wrong, one bound group, one unbindable group and two unbindable spans that pin the scope — and `doc/drift.md` and its base revision carry one whose inherited line moved, so rule 2 must report it through the same extractor instead of merely counting it. `FIXTURE_TOTAL` 30 -> 41, `FIXTURE_DRIFT_COMPARED` 31 -> 32, `FIXTURE_EXPECTED` 9 -> 15 entries, `FIXTURE_DRIFT_EXPECTED` 2 -> 3, plus `FIXTURE_BARE_EXPECTED`, `FIXTURE_BARE_NEAREST_EXPECTED`, `FIXTURE_BARE_SAME_LINE_EXPECTED` and `FIXTURE_BARE_GROUP_EXPECTED`, each naming the citation a count assertion can only report as missing. Every other fixture constant is unchanged. `doc/README.md` gains the form, its three constraints and the measurement behind each, written without a real line number because that document is inside the guarded surface; it also names the one rule the bare form does not reach. `lib/src/protocol/mux/LIFECYCLE.md` names the form in its own anchoring preamble, which uses it once. The `[Unreleased]` entry that described this form as one the regex "cannot see" gains a clause saying #1459 closed it. The job box in `.github/workflows/ci.yml` is deliberately untouched: it asks for one clause per RULE, and this changes rule 1's extraction rather than adding a fifth. Closes #1459. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 23, 2026
`check_doc_citations.py` resolves `doc/**` and `**/LIFECYCLE.md`, so a `path.rs:NNN` inside a `//`, `///` or `//!` comment was read by no rule at all — not the existence floor, not the drift comparison, not once. The two `SAFETY:` comments justifying `from_utf8_unchecked` in `lib/src/http.rs` and `lib/src/https.rs` are how it surfaced (#1473): both cited a `Method` match arm for `hostname_and_port`, and drifted there with CI green throughout, until #1474 re-pointed them at the function. The population was measured before the form was chosen, at main `19fd5d8c`: 90 citation tokens across 29 files, holding 113 line targets. Sixty-eight of the 90 had drifted from the text they named at the commit that last wrote or re-anchored them, and only 16 still land on a line that is neither a bare delimiter, a blank, nor past end-of-file. The half-life decided it: 43 of those 68 broke on the very NEXT commit that touched the file they point into, the median citation survived ONE such commit and zero days, and 65 of 68 were wrong inside a week. All 18 `h2.rs:NNN` tokens had drifted. Extending the resolver over `**/*.rs` was the alternative, and it was measured rather than argued: switched on at that revision it would have had to reject those 68, plus 14 naming a basename that is ambiguous here — four files are called `h2.rs`, nineteen `mod.rs` — plus two pointing into the `kawa` dependency, which is not in this repository. A gate that fails on most of the population it guards gets bypassed rather than satisfied, which is the argument the script's own header makes about `--all-features`. So `doc/README.md`'s three forms now govern Rust comments too, with one narrowing: the symbol form only, and a comment that means one branch names that branch in words. All 82 citations outside `lib/src/protocol/mux/` are converted, across 25 files, each re-pointed at the symbol recovered by reading the cited file AT THE COMMIT THAT WROTE THE CITATION rather than at HEAD. The rule is also in `CLAUDE.md`'s code-style list. Rewrapping the comments shifted lines in `e2e/src/tests/h2_correctness_tests.rs`, and the drift rule caught two `doc/testing.md` citations pointing into it — the guarded half of exactly the pair #1465 was about. They now name `try_h2_large_gzipped_chunked_drains_fully` and `try_h2_large_chunked_7mb_drains_fully`. Two corrections fell out of recovering intent rather than trusting HEAD: `h2_log_context_tests.rs` named `log_context_lite!` for a line that is inside `log_module_context!` — only the latter renders the bare `MUX-H2` tag the comment claims — and `e2e/src/tests/mod.rs` named two tests by a line holding their `#[serial_test::serial]` attribute. Comments and documentation only; no code, literal, attribute, assertion or test name changed. The eight sites under `lib/src/protocol/mux/` are left for a separate pass to keep this off a module under concurrent change; two of them, into pinned `kawa` 0.7.1, are the one class here where a line number genuinely cannot rot. Refs #1473 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 23, 2026
`check_doc_citations.py` resolves `doc/**` and `**/LIFECYCLE.md`, so a `path.rs:NNN` inside a `//`, `///` or `//!` comment was read by no rule at all — not the existence floor, not the drift comparison, not once. The two `SAFETY:` comments justifying `from_utf8_unchecked` in `lib/src/http.rs` and `lib/src/https.rs` are how it surfaced (#1473): both cited a `Method` match arm for `hostname_and_port`, and drifted there with CI green throughout, until #1474 re-pointed them at the function. The population was measured before the form was chosen, at main `19fd5d8c`: 90 citation tokens across 29 files, holding 113 line targets. Sixty-eight of the 90 had drifted from the text they named at the commit that last wrote or re-anchored them, and only 16 still land on a line that is neither a bare delimiter, a blank, nor past end-of-file. The half-life decided it: 43 of those 68 broke on the very NEXT commit that touched the file they point into, the median citation survived ONE such commit and zero days, and 65 of 68 were wrong inside a week. All 18 `h2.rs:NNN` tokens had drifted. Extending the resolver over `**/*.rs` was the alternative, and it was measured rather than argued: switched on at that revision it would have had to reject those 68, plus 14 naming a basename that is ambiguous here — four files are called `h2.rs`, nineteen `mod.rs` — plus two pointing into the `kawa` dependency, which is not in this repository. A gate that fails on most of the population it guards gets bypassed rather than satisfied, which is the argument the script's own header makes about `--all-features`. So `doc/README.md`'s three forms now govern Rust comments too, with one narrowing: the symbol form only, and a comment that means one branch names that branch in words. All 82 citations outside `lib/src/protocol/mux/` are converted, across 25 files, each re-pointed at the symbol recovered by reading the cited file AT THE COMMIT THAT WROTE THE CITATION rather than at HEAD. The rule is also in `CLAUDE.md`'s code-style list. Rewrapping the comments shifted lines in `e2e/src/tests/h2_correctness_tests.rs`, and the drift rule caught two `doc/testing.md` citations pointing into it — the guarded half of exactly the pair #1465 was about. They now name `try_h2_large_gzipped_chunked_drains_fully` and `try_h2_large_chunked_7mb_drains_fully`. Two corrections fell out of recovering intent rather than trusting HEAD: `h2_log_context_tests.rs` named `log_context_lite!` for a line that is inside `log_module_context!` — only the latter renders the bare `MUX-H2` tag the comment claims — and `e2e/src/tests/mod.rs` named two tests by a line holding their `#[serial_test::serial]` attribute. Comments and documentation only; no code, literal, attribute, assertion or test name changed. The eight sites under `lib/src/protocol/mux/` are left for a separate pass to keep this off a module under concurrent change; two of them, into pinned `kawa` 0.7.1, are the one class here where a line number genuinely cannot rot. Refs #1473 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.
Step 8 of the H2 sans-io extraction.
Stacked on #1463 (step 7). This PR contains step 7's commit as well, because it
was rebased directly onto that branch rather than onto
main— once #1463 merges,this reduces to its own single commit. Review only
refactor(mux-h2): extract the RFC 9218 scheduling decision into h2_scheduler.rs.What changes
The RFC 9218 priority and write-pass scheduling decision moves out of
h2.rsinto
lib/src/protocol/mux/h2_scheduler.rs, which owns:Prioriser, moved byte-identical (sha256 equal at the old and new parent; nodiff hunk touches
Prioriser,incremental_cursor,apply_incremental_rotationor
push_priority),HpackStateaspriorities_buf,ReadyIncrementalCensus.begin_pass(ids, ready)takesready: impl FnMut(StreamId) -> bool— readinessas data, not a
&mut Context, which is the bar step 8 set for what "a decisionover owned state" means here.
HpackStatedrops to exactly three scratch buffers (converter_buf,lowercase_buf,cookie_buf), andhpack_state.rsshrinks 154 → 135 lines.The fairness claim is scoped to what is true
LIFECYCLE invariant 26 is not general RFC 9218 round-robin fairness.
incremental_cursoris one connection-global stream id, andend_passcan onlycommit an id from the lowest-numbered bucket that had a ready incremental stream
fire — so every other bucket's rotation is driven by a foreign cursor and can be
permanently static.
Measured, six passes, u=0
{1,3}+ u=3{5,7}: the u=3 tail is5,7every timeand stream 7 never leads. This is not a regression —
Prioriserisbyte-identical to its pre-extraction form and its field doc always said lowest
urgency bucket. The extraction made it visible by forcing the argument to be
written down. Invariant 26 is scoped to the leading bucket, a test pins the frozen
trailing bucket as observed behaviour, and the fix is tracked as #1456.
It is positional starvation while every stream still gets its frame, and
becomes byte starvation the moment a pass is cut short: a stalled flush partway
through the order leaves the same trailing streams unwritten, pass after pass.
The rotation test was re-measured under this parent, and it reddens
Deleting the rotate-and-commit statement from
H2Scheduler::end_passfails 5tests, with the panic text the doc comment predicts verbatim:
Restored:
414 passed; 0 failed. The counts reconcile — 414 at head, 5 detectingthe mutation, 409 under it.
Separately, the complementary claim the commit message makes — that deleting
advance_incremental_cursorfromwrite_streamsleaves the suite green, i.e.the rotation primitive was pinned but the rotate-and-commit pair was not — was
re-run at the new parent:
402 passed, 0 failed, unchanged by the deletion. Thatfigure was
395against the old parent and is corrected in all three places itappears (commit message,
LIFECYCLE.md,CHANGELOG.md).Pinned blocks drop 17 → 15, deliberately
h2.rs:2511-2520and:2521-2527quoted code this step deletes fromh2.rs.The subsection is replaced by a
begin_passAPI illustration carrying an elisioncomment, which rule 4 cannot pin. No literal successor exists, so keeping them
would have been a false citation with a passing gate — rule 4 only compares what
is pinned. 15/15 verbatim is the honest number.
Prose the rebase falsified, rewritten
h2_mux_internals.mdstill listedpriorities_bufamongHpackState's scratchbuffers. It has moved; dropped.
h2_mux_internals.mdclaimedreclaim_idle_buffers"tests all fourindependently". It tests three — the order buffer is reclaimed beside it by
H2Scheduler::reclaim_idle_buffer. Rewritten to name both. (Swept for siblings:the other "all four" hits are unrelated.)
doc/README.md's pinning-syntax example itself citedhpack_state.rs:122-132and
:140;:140went past EOF after the shrink. Re-anchored to106-116and:124— same symbol,reclaim_idle_buffers.Verification
CI's own per-crate commands, flags inlined:
cargo +nightly fmt --all -- --checkcargo build/clippy --all-targets -- -D warningscargo test -p sozu-libcargo test -p sozucargo test -p sozu-e2e -- --skip tests::fuzz_tests::sozu-simudp + tcp,RUSTFLAGS='--cfg tokio_unstable'--ignoredcells (ci.yml:182-184)check_doc_citations.py --root ./--basegit merge-tree --write-tree+ gate inside the extracted treeCitation work: a fresh
difflib.SequenceMatchermap overh2.rs9380 → 9764lines gave 29 equal blocks with 20 distinct shifts — no uniform offset exists.
Every mapped target was asserted text-identical to its source line, 0 failures,
across 62 endpoints inside conflicts plus 18 inherited from step 7.
grep -rn "async fn" lib/src bin/src→ no hits. NoCargo.toml/Cargo.lockchange. No test deleted or newly ignored, no assertion loosened, no lint escape,
no citation-script exemption.