Skip to content

test(mux-h2): drive a real rustls frontend through the write path - #1484

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
test/h2-rustls-write-coverage
Sep 24, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
test/h2-rustls-write-coverage

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Closes #1454.

No test instantiated ConnectionH2<FrontRustls>, leaving 15 socket_wants_write branches unexercised — including the truncation vector. git grep -cE 'ConnectionH2<FrontRustls>' -- '*.rs' returned 0 on every revision checked. Six tests now drive a real rustls frontend through the write path.

The six, each seen red on its own mutation

test mutation measured
a_real_rustls_frontend_reports_bytes_taken_and_would_block_together socket_write_vectored's !can_write arm returns (0, WouldBlock) 1092 passed; 6 failed
an_empty_flush_drains_the_records_a_blocked_write_left_behind delete socket_write's post-loop flush block 1093 passed; 5 failed
a_blocked_rustls_frontend_delivers_every_queued_byte_across_passes over-report (total_len, WouldBlock) — the truncation class 1095 passed; 3 failed, "truncated at 65536 of 262144 bytes after 4096 passes"
force_disconnect_over_a_real_rustls_frontend_waits_for_the_records_to_drain let tls_wants_write = false; 1096 passed; 2 failed
a_rustls_frontend_in_error_state_re_arms_until_its_records_drain h2_close::error_close_action(false) 1097 passed; 1 failed
a_rustls_frontend_in_goaway_re_arms_until_its_records_drain goaway_close_action(AfterFlush, false, false) 1096 passed; 2 failed

Every recipe lives in the test's own doc comment with its measured counts and failure text. sozu-lib goes 1092 → 1098, exactly the six added.

Implementation-shape check: no assertion string and no distinctive literal of the new block appears in production — PINNED_SOCKET_QUEUE, QUEUED_RESPONSE_LEN, MAX_DRIVE_TICKS, queued_response_body, 262144, 251, lolcatho.st all return 0 production hits.

Two findings

FrontRustls::socket_write's post-loop empty-flush block had no unit coverage at all. Its own comment says that without it "the main loop above exits immediately for empty buffers and write_tls is never called". Deleting it fails five of the six new tests and none of the 1092 that predate them. Only e2e guarded it.

The WouldBlock half of (size > 0, WouldBlock) is guarded twice in production. The first red attempt — deleting can_write = false; from the partial-absorb draining loop — left the suite fully green, because the post-loop flush block sets the same flag moments later. Recorded in the test's comment as a non-recipe so nobody re-derives it.

Which of the 15 sites are now covered

Covered, each measured by planted probe rather than inferred: ensure_tls_flushed, finalize_write's pre-flush query, writable's preamble flush, writable's (Error, Server) arm, writable's GoAway pre- and post-flush, and force_disconnect's server arm. All three query / socket_write(&[]) / query triples now have a production-handler witness.

Not covered, each measured at 0 across all six tests rather than assumed: initiate_close_notify (needs a driven close_notify, not on the write path), both flush_pending_control_frames guards (sit behind a parked zero-buffer write), has_pending_write's TLS disjunct (only Mux calls it), flush_zero_to_socket and flush_zero_buffer (need expect_write == Some(Zero)), close's tls_pending_before (needs a full teardown with a live Endpoint), plus shared.rs's two in drain_tls_close_notify, which nothing calls at all.

The fourth socket_write(&[]) site, flush_zero_buffer, is deliberately not targeted: it keeps the returned status instead of re-querying, so it is not this shape.

Verified against the write-path inversion

These tests were written against main and then run on top of the poll_write_target/handle_write inversion: cherry-picked onto it, 0 conflicts, 1098 passed, 0 failed. No test names a deleted symbol — none references write_streams, flush_stream_out or FlushOutcome.

Probes planted on the inverted path measured the specific failure the inversion could have introduced: handle_write answers stalled = false for 33 writes that moved bytes and reported WouldBlock, and stalled = true for 31 that moved none. update_readiness_after_write remains the only writer of pass.stalled, so status did not become a pass terminator. Counts identical to main: 30 resume-path stalls, 1 main-loop stall, 42 writable preamble flushes, 12 ensure_tls_flushed.

The two FlushOutcome::Stalled consumers previously reached by zero tests are now reached on both trees.

Verification

cargo +nightly fmt --all -- --check                                   exit 0
cargo build  --locked --no-default-features --features crypto-ring,…  exit 0
cargo clippy --all-targets --locked … -- -D warnings                  exit 0, 0 diagnostics
cargo test -p sozu-lib --locked …    test result: ok. 1098 passed; 0 failed; 0 ignored
cargo test -p sozu     --locked …    test result: ok. 113 passed; 0 failed
check_doc_citations.py --root .      211 citations, 515 test names, 16 pinned blocks
check_doc_citations.py --base c0f01021   0 re-anchored spans exempt
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps …   exit 0, all five crates fresh

No production code changed. No dependency added, Cargo.lock unchanged. No test deleted or ignored, no assertion loosened, no lint escape. One real clippy failure during development (explicit_auto_deref) was fixed in the test code, not silenced.

Reaching the stalled branch needs a non-empty socket_write answering (0, WouldBlock), which a loopback socket never does for 13 bytes — so BackpressuredTlsSocket gains a write_script mirroring its existing vectored_script. The empty script stays the default and delegates to the real socket, so every earlier test is byte-for-byte unaffected.

No test in the tree ever instantiated `ConnectionH2<FrontRustls>`:
`git grep -cE 'ConnectionH2<FrontRustls>' -- '*.rs'` answers 0 at
c0f0102 and on every commit before it. Every `socket_wants_write()`
branch that had coverage had it over `BackpressuredTlsSocket`, a TCP
handler with a modelled answer, which #1454 rules out for
closing itself.

`handshaken_front_rustls` settles a real TLS 1.3 session in memory
between a rustls server and client, then attaches the settled server
session to a loopback socket whose kernel queues are pinned to a few
KiB. The surviving client session decrypts what the frontend wrote, so
the oracle is bytes the peer received rather than a call count.

Six tests: the `(size > 0, WouldBlock)` pair taken from the production
handler and its not-stalled classification; both answers of the flush
triples' `socket_write(&[])`; 256 KiB delivered in full through
`writable()` across as many passes as backpressure imposes; and
`force_disconnect`'s server arm plus `writable`'s Error and GoAway arms,
each asserting both outcomes on one connection. All three
query/flush/query triples now have a witness over the production
handler.

Both `FlushOutcome::Stalled` consumers in `write_streams`, previously
measured as reached by zero tests, are now reached: 30 resume-path and
one main-loop entry in a single run of the byte-conservation test.

Two findings recorded rather than fixed. `FrontRustls::socket_write`'s
post-loop flush block had no unit coverage — deleting it leaves all 1092
pre-existing tests green while five of these six fail. And the
`WouldBlock` half of the pair is guarded twice in production, so
deleting one `can_write = false` is not observable.

Test-only: no production code, no dependency, no lockfile change.
LIFECYCLE invariant 27's coverage paragraph is updated in the same
changeset.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 9615da0 into main Sep 24, 2026
28 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the test/h2-rustls-write-coverage branch September 24, 2026 02:53
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2` asked the TLS layer twenty-one questions and actions spelled
out as raw socket calls: sixteen `socket_wants_write()`, four empty-buffer
`socket_write(&[])` flushes and one `socket_close()`. They now go through
three private methods — `tls_wants_write`, `flush_tls_records` and
`begin_tls_close` — and `self.socket` in `h2.rs` production code drops from
26 occurrences to 8: the three seam bodies, the single `socket_read` of the
read path, the single `socket_write_vectored` of the stream-write path,
`flush_zero_to_socket`'s real write, and the two `socket_ref()` reaches that
the `Debug` impl and the RTT snapshot still own.

No behaviour change. The three bodies are delegations, every answer is
bit-identical, and `sozu-lib` is unmoved at 1107 tests.

The name of the trait method says socket, which is what made this read as an
I/O question for as long as it was written out at every site. It is a question
about a buffer that happens to live behind the socket: `FrontRustls` is the
only production `SocketHandler` that overrides it, the trait default is
`false`, and `Router::backends` is declared `Connection<SessionTcpStream>`
whatever the frontend is — so every backend H2 connection already answers
`false` at all fifteen call sites, statically. The seams are the three inputs
and actions the I/O shell will own; their bodies move there, their call sites
do not.

One local change that is not a substitution: `force_disconnect` reads the
answer once above its `match` rather than inside the `Position::Server` arm.
A method taking `&self` cannot coexist with the `&mut self.position` the
client arm holds for its `status` binding, and the server arm's own comment
already required a single read — the hoist extends that to both arms and to
every `wants_write=` a debug line renders.

Coverage of the new seams was measured rather than assumed, by replacing each
body with a constant and counting `cargo test -p sozu-lib --lib`:

  tls_wants_write() -> false                     1097 passed; 10 failed
  flush_tls_records() -> (0, Continue), no flush 1103 passed;  4 failed
  begin_tls_close() -> {}                        1107 passed;  0 failed

The third is green, and `sozu-e2e` is green under it too at 447 passed — so
nothing in the tree detects it, not only nothing in the unit suite. It is a
pre-existing gap this changeset records rather than creates:
`initiate_close_notify` is reached only from `Mux::shutting_down` and neither
layer drives that path. #1484 independently listed that site among the ones it
could not reach, for the same reason. Closing it needs a driven close_notify
and belongs to its own changeset with its own test.

`h2_close`'s module doc and `doc/h2_mux_internals.md` name the seams where
they described the raw calls, and the latter gains a table of the three.
`LIFECYCLE.md`, `doc/testing.md` and eight pinned blocks in
`doc/h2_mux_internals.md` are re-anchored for the line shift; the drifted-
citation gate exempts 63 re-anchored spans from its comparison, and all 63
were audited against the base blob as byte-identical.

Refs #1339

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2` asked the TLS layer twenty-one questions and actions spelled
out as raw socket calls: sixteen `socket_wants_write()`, four empty-buffer
`socket_write(&[])` flushes and one `socket_close()`. They now go through
three private methods — `tls_wants_write`, `flush_tls_records` and
`begin_tls_close` — and `self.socket` in `h2.rs` production code drops from
26 occurrences to 8: the three seam bodies, the single `socket_read` of the
read path, the single `socket_write_vectored` of the stream-write path,
`flush_zero_to_socket`'s real write, and the two `socket_ref()` reaches that
the `Debug` impl and the RTT snapshot still own.

No behaviour change. The three bodies are delegations, every answer is
bit-identical, and `sozu-lib` is unmoved at 1107 tests.

The name of the trait method says socket, which is what made this read as an
I/O question for as long as it was written out at every site. It is a question
about a buffer that happens to live behind the socket: `FrontRustls` is the
only production `SocketHandler` that overrides it, the trait default is
`false`, and `Router::backends` is declared `Connection<SessionTcpStream>`
whatever the frontend is — so every backend H2 connection already answers
`false` at all fifteen call sites, statically. The seams are the three inputs
and actions the I/O shell will own; their bodies move there, their call sites
do not.

One local change that is not a substitution: `force_disconnect` reads the
answer once above its `match` rather than inside the `Position::Server` arm.
A method taking `&self` cannot coexist with the `&mut self.position` the
client arm holds for its `status` binding, and the server arm's own comment
already required a single read — the hoist extends that to both arms and to
every `wants_write=` a debug line renders.

Coverage of the new seams was measured rather than assumed, by replacing each
body with a constant and counting `cargo test -p sozu-lib --lib`:

  tls_wants_write() -> false                     1097 passed; 10 failed
  flush_tls_records() -> (0, Continue), no flush 1103 passed;  4 failed
  begin_tls_close() -> {}                        1107 passed;  0 failed

The third is green, and `sozu-e2e` is green under it too at 447 passed — so
nothing in the tree detects it, not only nothing in the unit suite. It is a
pre-existing gap this changeset records rather than creates:
`initiate_close_notify` is reached only from `Mux::shutting_down` and neither
layer drives that path. #1484 independently listed that site among the ones it
could not reach, for the same reason. Closing it needs a driven close_notify
and belongs to its own changeset with its own test.

`h2_close`'s module doc and `doc/h2_mux_internals.md` name the seams where
they described the raw calls, and the latter gains a table of the three.
`LIFECYCLE.md`, `doc/testing.md` and eight pinned blocks in
`doc/h2_mux_internals.md` are re-anchored for the line shift; the drifted-
citation gate exempts 63 re-anchored spans from its comparison, and all 63
were audited against the base blob as byte-identical.

Refs #1339

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2`'s `Debug` impl reached `SocketHandler::socket_ref` to hand
`mio::net::TcpStream`'s own `Debug` a `socket` field: a local address, a peer
address and a file descriptor. It now renders `peer_address`, the address the
connection snapshots once at construction and that every `log_context!` line
already carries. That value has no descriptor in it, it survives the peer's
reset where a live `getpeername(2)` answers `ENOTCONN` — which is exactly when
an operator reads the line — and it is a value a byte-in / byte-out core can
produce at all, where `socket_ref` returns a concrete OS type no in-memory
transport can synthesise. The H2 simulator's in-memory `SocketHandler` carries
a connected loopback stream for that signature alone and answers a fixed
`peer_addr`, so no ephemeral port reaches a trace through this impl any more.

`socket_ref()` reaches in the production range of `h2.rs` go 2 to 1 and
`socket_mut()` stays at 0. The survivor is `ConnectionH2::snapshot_rtts`, and
Q11's local half is deliberately NOT taken here: injecting `client_rtt` means
refreshing it once per pass, where today it costs one `getsockopt(TCP_INFO)`
per stream recycle, and `Endpoint` cannot supply it lazily because it is the
other side of the connection. That trade gets measured, not reasoned about,
and it belongs to its own changeset.

Two verbatim copies of `ConnectionH2::ensure_tls_flushed`'s body — the stalled
WINDOW_UPDATE and RST_STREAM drain tails of `flush_pending_control_frames` —
become calls to it. The previous step gave that body a name; a
character-identical copy of a named method is the same fact written twice,
and both copies matched the method body exactly once indentation is removed.

Seen red first: deleting both calls gives 1105 passed; 2 failed, one test per
collapsed site — `a_stalled_window_update_drain_re_signals_the_writable_event`
and `a_stalled_rst_stream_drain_re_signals_the_writable_event` — and restoring
them returns the suite to 1107. No other count moves: `sozu` 113, `sozu-e2e`
447, the four simulators 10/6/6/6.

#1484's six `ConnectionH2<FrontRustls>` tests, which cover the
`size > 0 && WouldBlock` truncation vector, take 0 diff hits and stay green
with their shape unchanged. The TLS `close_notify` path is untouched and stays
uncovered (#1498).

`doc/h2_mux_internals.md` gains the `Debug` contract, names
`ensure_tls_flushed` as the one composite the file builds on the TLS query, and
records one reach that counting `self.socket` misses what it implies:
`ConnectionH2::close` hands `&mut self.socket` whole to
`shared::drain_tls_close_notify`, which runs its own socket_close /
socket_wants_write / socket_write_vectored drain loop on the far side. It adds
no trait method — those are the three seams' own underlying calls plus the
vectored write — but it is a place the socket crosses a function boundary
rather than being asked a question, and it is shared byte-for-byte with
`ConnectionH1::close`. 46 line citations across it, `doc/testing.md` and `LIFECYCLE.md` are re-anchored
for the line shift. The drifted-citation gate exempts 64 re-anchored spans from
its comparison, and all 64 were audited against the base blob as
byte-identical.

Refs #1339

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2`'s `Debug` impl reached `SocketHandler::socket_ref` to hand
`mio::net::TcpStream`'s own `Debug` a `socket` field: a local address, a peer
address and a file descriptor. It now renders `peer_address`, the address the
connection snapshots once at construction and that every `log_context!` line
already carries. That value has no descriptor in it, it survives the peer's
reset where a live `getpeername(2)` answers `ENOTCONN` — which is exactly when
an operator reads the line — and it is a value a byte-in / byte-out core can
produce at all, where `socket_ref` returns a concrete OS type no in-memory
transport can synthesise. The H2 simulator's in-memory `SocketHandler` carries
a connected loopback stream for that signature alone and answers a fixed
`peer_addr`, so no ephemeral port reaches a trace through this impl any more.

`socket_ref()` reaches in the production range of `h2.rs` go 2 to 1 and
`socket_mut()` stays at 0. The survivor is `ConnectionH2::snapshot_rtts`, and
Q11's local half is deliberately NOT taken here: injecting `client_rtt` means
refreshing it once per pass, where today it costs one `getsockopt(TCP_INFO)`
per stream recycle, and `Endpoint` cannot supply it lazily because it is the
other side of the connection. That trade gets measured, not reasoned about,
and it belongs to its own changeset.

Two verbatim copies of `ConnectionH2::ensure_tls_flushed`'s body — the stalled
WINDOW_UPDATE and RST_STREAM drain tails of `flush_pending_control_frames` —
become calls to it. The previous step gave that body a name; a
character-identical copy of a named method is the same fact written twice,
and both copies matched the method body exactly once indentation is removed.

Seen red first: deleting both calls gives 1105 passed; 2 failed, one test per
collapsed site — `a_stalled_window_update_drain_re_signals_the_writable_event`
and `a_stalled_rst_stream_drain_re_signals_the_writable_event` — and restoring
them returns the suite to 1107. No other count moves: `sozu` 113, `sozu-e2e`
447, the four simulators 10/6/6/6.

#1484's six `ConnectionH2<FrontRustls>` tests, which cover the
`size > 0 && WouldBlock` truncation vector, take 0 diff hits and stay green
with their shape unchanged. The TLS `close_notify` path is untouched and stays
uncovered (#1498).

`doc/h2_mux_internals.md` gains the `Debug` contract, names
`ensure_tls_flushed` as the one composite the file builds on the TLS query, and
records one reach that counting `self.socket` misses what it implies:
`ConnectionH2::close` hands `&mut self.socket` whole to
`shared::drain_tls_close_notify`, which runs its own socket_close /
socket_wants_write / socket_write_vectored drain loop on the far side. It adds
no trait method — those are the three seams' own underlying calls plus the
vectored write — but it is a place the socket crosses a function boundary
rather than being asked a question, and it is shared byte-for-byte with
`ConnectionH1::close`. 46 line citations across it, `doc/testing.md` and `LIFECYCLE.md` are re-anchored
for the line shift. The drifted-citation gate exempts 64 re-anchored spans from
its comparison, and all 64 were audited against the base blob as
byte-identical.

Refs #1339

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2`'s `Debug` impl reached `SocketHandler::socket_ref` to hand
`mio::net::TcpStream`'s own `Debug` a `socket` field: a local address, a peer
address and a file descriptor. It now renders `peer_address`, the address the
connection snapshots once at construction and that every `log_context!` line
already carries. That value has no descriptor in it, it survives the peer's
reset where a live `getpeername(2)` answers `ENOTCONN` — which is exactly when
an operator reads the line — and it is a value a byte-in / byte-out core can
produce at all, where `socket_ref` returns a concrete OS type no in-memory
transport can synthesise. The H2 simulator's in-memory `SocketHandler` carries
a connected loopback stream for that signature alone and answers a fixed
`peer_addr`, so no ephemeral port reaches a trace through this impl any more.

`socket_ref()` reaches in the production range of `h2.rs` go 2 to 1 and
`socket_mut()` stays at 0. The survivor is `ConnectionH2::snapshot_rtts`, and
Q11's local half is deliberately NOT taken here: injecting `client_rtt` means
refreshing it once per pass, where today it costs one `getsockopt(TCP_INFO)`
per stream recycle, and `Endpoint` cannot supply it lazily because it is the
other side of the connection. That trade gets measured, not reasoned about,
and it belongs to its own changeset.

Two verbatim copies of `ConnectionH2::ensure_tls_flushed`'s body — the stalled
WINDOW_UPDATE and RST_STREAM drain tails of `flush_pending_control_frames` —
become calls to it. The previous step gave that body a name; a
character-identical copy of a named method is the same fact written twice,
and both copies matched the method body exactly once indentation is removed.

Seen red first: deleting both calls gives 1108 passed; 2 failed, one test per
collapsed site — `a_stalled_window_update_drain_re_signals_the_writable_event`
and `a_stalled_rst_stream_drain_re_signals_the_writable_event` — and restoring
them returns the suite to 1110. No other count moves: `sozu` 113, `sozu-e2e`
447, the four simulators 10/6/6/6.

#1484's six `ConnectionH2<FrontRustls>` tests, which cover the
`size > 0 && WouldBlock` truncation vector, take 0 diff hits and stay green
with their shape unchanged. The TLS `close_notify` path is untouched and stays
uncovered (#1498).

`doc/h2_mux_internals.md` gains the `Debug` contract, names
`ensure_tls_flushed` as the one composite the file builds on the TLS query, and
records one reach that counting `self.socket` misses what it implies:
`ConnectionH2::close` hands `&mut self.socket` whole to
`shared::drain_tls_close_notify`, which runs its own socket_close /
socket_wants_write / socket_write_vectored drain loop on the far side. It adds
no trait method — those are the three seams' own underlying calls plus the
vectored write — but it is a place the socket crosses a function boundary
rather than being asked a question, and it is shared byte-for-byte with
`ConnectionH1::close`. 46 line citations across it, `doc/testing.md` and `LIFECYCLE.md` are re-anchored
for the line shift. The drifted-citation gate exempts 64 re-anchored spans from
its comparison, and all 64 were audited against the base blob as
byte-identical.

Refs #1339

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2`'s `Debug` impl reached `SocketHandler::socket_ref` to hand
`mio::net::TcpStream`'s own `Debug` a `socket` field: a local address, a peer
address and a file descriptor. It now renders `peer_address`, the address the
connection snapshots once at construction and that every `log_context!` line
already carries. That value has no descriptor in it, it survives the peer's
reset where a live `getpeername(2)` answers `ENOTCONN` — which is exactly when
an operator reads the line — and it is a value a byte-in / byte-out core can
produce at all, where `socket_ref` returns a concrete OS type no in-memory
transport can synthesise. The H2 simulator's in-memory `SocketHandler` carries
a connected loopback stream for that signature alone and answers a fixed
`peer_addr`, so no ephemeral port reaches a trace through this impl any more.

`socket_ref()` reaches in the production range of `h2.rs` go 2 to 1 and
`socket_mut()` stays at 0. The survivor is `ConnectionH2::snapshot_rtts`, and
Q11's local half is deliberately NOT taken here: injecting `client_rtt` means
refreshing it once per pass, where today it costs one `getsockopt(TCP_INFO)`
per stream recycle, and `Endpoint` cannot supply it lazily because it is the
other side of the connection. That trade gets measured, not reasoned about,
and it belongs to its own changeset.

Two verbatim copies of `ConnectionH2::ensure_tls_flushed`'s body — the stalled
WINDOW_UPDATE and RST_STREAM drain tails of `flush_pending_control_frames` —
become calls to it. The previous step gave that body a name; a
character-identical copy of a named method is the same fact written twice,
and both copies matched the method body exactly once indentation is removed.

Seen red first: deleting both calls gives 1111 passed; 2 failed, one test per
collapsed site — `a_stalled_window_update_drain_re_signals_the_writable_event`
and `a_stalled_rst_stream_drain_re_signals_the_writable_event` — and restoring
them returns the suite to 1113. No other count moves: `sozu` 113, `sozu-e2e`
447, the four simulators 11/6/6/6.

#1484's six `ConnectionH2<FrontRustls>` tests, which cover the
`size > 0 && WouldBlock` truncation vector, take 0 diff hits and stay green
with their shape unchanged. The TLS `close_notify` path is untouched and stays
uncovered (#1498).

`doc/h2_mux_internals.md` gains the `Debug` contract, names
`ensure_tls_flushed` as the one composite the file builds on the TLS query, and
records one reach that counting `self.socket` misses what it implies:
`ConnectionH2::close` hands `&mut self.socket` whole to
`shared::drain_tls_close_notify`, which runs its own socket_close /
socket_wants_write / socket_write_vectored drain loop on the far side. It adds
no trait method — those are the three seams' own underlying calls plus the
vectored write — but it is a place the socket crosses a function boundary
rather than being asked a question, and it is shared byte-for-byte with
`ConnectionH1::close`. 46 line citations across it, `doc/testing.md` and `LIFECYCLE.md` are re-anchored
for the line shift. The drifted-citation gate exempts 64 re-anchored spans from
its comparison, and all 64 were audited against the base blob as
byte-identical.

Refs #1339

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
#1501)

`ConnectionH2`'s `Debug` impl reached `SocketHandler::socket_ref` to hand
`mio::net::TcpStream`'s own `Debug` a `socket` field: a local address, a peer
address and a file descriptor. It now renders `peer_address`, the address the
connection snapshots once at construction and that every `log_context!` line
already carries. That value has no descriptor in it, it survives the peer's
reset where a live `getpeername(2)` answers `ENOTCONN` — which is exactly when
an operator reads the line — and it is a value a byte-in / byte-out core can
produce at all, where `socket_ref` returns a concrete OS type no in-memory
transport can synthesise. The H2 simulator's in-memory `SocketHandler` carries
a connected loopback stream for that signature alone and answers a fixed
`peer_addr`, so no ephemeral port reaches a trace through this impl any more.

`socket_ref()` reaches in the production range of `h2.rs` go 2 to 1 and
`socket_mut()` stays at 0. The survivor is `ConnectionH2::snapshot_rtts`, and
Q11's local half is deliberately NOT taken here: injecting `client_rtt` means
refreshing it once per pass, where today it costs one `getsockopt(TCP_INFO)`
per stream recycle, and `Endpoint` cannot supply it lazily because it is the
other side of the connection. That trade gets measured, not reasoned about,
and it belongs to its own changeset.

Two verbatim copies of `ConnectionH2::ensure_tls_flushed`'s body — the stalled
WINDOW_UPDATE and RST_STREAM drain tails of `flush_pending_control_frames` —
become calls to it. The previous step gave that body a name; a
character-identical copy of a named method is the same fact written twice,
and both copies matched the method body exactly once indentation is removed.

Seen red first: deleting both calls gives 1111 passed; 2 failed, one test per
collapsed site — `a_stalled_window_update_drain_re_signals_the_writable_event`
and `a_stalled_rst_stream_drain_re_signals_the_writable_event` — and restoring
them returns the suite to 1113. No other count moves: `sozu` 113, `sozu-e2e`
447, the four simulators 11/6/6/6.

#1484's six `ConnectionH2<FrontRustls>` tests, which cover the
`size > 0 && WouldBlock` truncation vector, take 0 diff hits and stay green
with their shape unchanged. The TLS `close_notify` path is untouched and stays
uncovered (#1498).

`doc/h2_mux_internals.md` gains the `Debug` contract, names
`ensure_tls_flushed` as the one composite the file builds on the TLS query, and
records one reach that counting `self.socket` misses what it implies:
`ConnectionH2::close` hands `&mut self.socket` whole to
`shared::drain_tls_close_notify`, which runs its own socket_close /
socket_wants_write / socket_write_vectored drain loop on the far side. It adds
no trait method — those are the three seams' own underlying calls plus the
vectored write — but it is a place the socket crosses a function boundary
rather than being asked a question, and it is shared byte-for-byte with
`ConnectionH1::close`. 46 line citations across it, `doc/testing.md` and `LIFECYCLE.md` are re-anchored
for the line shift. The drifted-citation gate exempts 64 re-anchored spans from
its comparison, and all 64 were audited against the base blob as
byte-identical.

Refs #1339

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
lib/src/protocol/mux/LIFECYCLE.md carried three `path:NNN` citations that
resolved to real, non-blank, unrelated lines, which is all any rule in
check_doc_citations.py asks of them:

- §4.2 put the `Context.streams` push at `mod.rs:648-649`. Those are
  `listener.get_sticky_name().to_string()` and
  `listener.get_sozu_id_header().to_string()`, arguments of the
  `HttpContext::new(...)` call that opens `Context::create_stream`. The push is
  `self.streams.push(stream)` at `mod.rs:708`.
- §3.1's `Unlinked` bullet read `h1.rs:995-1052`. `995` is a format string in
  `ConnectionH1::end_stream`'s wrong-stream `error!` guard and `1052` is a
  `debug_assert!` argument; the four `StreamState::Unlinked` assignments the
  range is meant to bracket are `h1.rs:1042-1099`. It was exact at fbc83ed
  (`h1.rs:737-772` against assignments at 737, 745, 767 and 772) and successive
  renumberings walked it off them.
- §7.5's arm-site list read `h2.rs:5384`, which is `log_context!(self)` inside
  an `error!` for an out-of-bounds header block fragment. The HEADERS liveness
  refresh is `self.stream_table.touch_activity(stream_id, self.now)` at
  `h2.rs:5418`. #1501 renumbered that one from `h2.rs:5376` in the commit
  directly below this one, faithfully and still onto the wrong statement: a
  re-anchor preserves the pointer, not the claim.

CHANGELOG.md's #1484 entry said `shared::drain_tls_close_notify`'s two
uncovered lines were uncovered "because nothing calls that function at all". It
has two production callers, the `Position::Server` arms of `ConnectionH1::close`
and `ConnectionH2::close`. What #1484 measured is that its own six-test fixture
never reaches them. Only that causal clause changed; every count and probe tally
in that historical entry was true as measured and is left as written.

All three sat in the drift rule's exemption: it keys on the citation tuple as it
stood in the base revision of the citing document, so a renumbered span is
counted exempt and never compared. Measured at 42ed6ba over the window they
were renumbered in, --base f2082b6 --show reported 133 exempt cited ends across
91 doc sites; 11 are fenced blocks the pinned-quote rule already compares
verbatim, and reading the remaining 80 against the code they name found 77
correct and these three wrong. --base 42ed6ba --show on this tree exempts 67
more, the spans #1501's renumbering re-anchored: 15 pinned fences, the 4 repaired
here, and 48 that anchor on byte-identical text before and after it. --audit
reports 7 findings on this tree, all 7 the heuristic pairing a prose symbol with
a line eight or more away from it.

Documentation only: no production code, no test, no dependency and no
Cargo.lock entry changes.

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
…e code

lib/src/protocol/mux/LIFECYCLE.md carried three `path:NNN` citations that
resolved to real, non-blank, unrelated lines, which is all any rule in
check_doc_citations.py asks of them:

- §4.2 put the `Context.streams` push at `mod.rs:648-649`. Those are
  `listener.get_sticky_name().to_string()` and
  `listener.get_sozu_id_header().to_string()`, arguments of the
  `HttpContext::new(...)` call that opens `Context::create_stream`. The push is
  `self.streams.push(stream)` at `mod.rs:708`.
- §3.1's `Unlinked` bullet read `h1.rs:995-1052`. `995` is a format string in
  `ConnectionH1::end_stream`'s wrong-stream `error!` guard and `1052` is a
  `debug_assert!` argument; the four `StreamState::Unlinked` assignments the
  range is meant to bracket are `h1.rs:1042-1099`. It was exact at fbc83ed
  (`h1.rs:737-772` against assignments at 737, 745, 767 and 772) and successive
  renumberings walked it off them.
- §7.5's arm-site list read `h2.rs:5384`, which is `log_context!(self)` inside
  an `error!` for an out-of-bounds header block fragment. The HEADERS liveness
  refresh is `self.stream_table.touch_activity(stream_id, self.now)` at
  `h2.rs:5418`. #1501 renumbered that one from `h2.rs:5376` in the commit
  directly below this one, faithfully and still onto the wrong statement: a
  re-anchor preserves the pointer, not the claim.

§7.2 described all three per-stream reap caches as `ConnectionH2` fields
holding a `HashMap`. Both halves are wrong and have been since #1415's
stream-slot-bookkeeping extraction: `stream_last_activity_at`,
`stream_fc_stalled_since` and `stream_fc_stalled_progress` are private
`BTreeMap` fields of `H2StreamTable`, built by `BTreeMap::new()` in
`H2StreamTable::new`, and `ConnectionH2` declares no field of any of those
names. #1415 converted them for the determinism reason its own CHANGELOG entry
records and updated §4.1's wire-map bullet, but left §7.2 on the pre-extraction
shape, so the section now inverts the ordering guarantee the code provides.
Cited by symbol rather than line: that module is being edited under #1338.

CHANGELOG.md's #1484 entry said `shared::drain_tls_close_notify`'s two
uncovered lines were uncovered "because nothing calls that function at all". It
has two production callers, the `Position::Server` arms of `ConnectionH1::close`
and `ConnectionH2::close`. What #1484 measured is that its own six-test fixture
never reaches them. Only that causal clause changed; every count and probe tally
in that historical entry was true as measured and is left as written.

The three citations sat in the drift rule's exemption: it keys on the citation
tuple as it stood in the base revision of the citing document, so a renumbered
span is counted exempt and never compared. Measured at 42ed6ba over the window
they were renumbered in, --base f2082b6 --show reported 133 exempt cited ends
across 91 doc sites; 11 are fenced blocks the pinned-quote rule already compares
verbatim, and reading the remaining 80 against the code they name found 77
correct and these three wrong. --base 42ed6ba --show on this tree exempts 67
more, the spans #1501's renumbering re-anchored: 15 pinned fences, the 4 repaired
here, and 48 that anchor on byte-identical text before and after it. --audit
reports 7 findings on this tree, all 7 the heuristic pairing a prose symbol with
a line eight or more away from it. The three §7.2 declarations were in no rule's
surface at all: every rule resolves a `path:NNN` or a fenced quote, and a
sentence naming a type and a container carries neither. Sweeping LIFECYCLE.md
for the same shape leaves only the three `ConnectionH2.streams` references that
#1338 already owns.

Documentation only: no production code, no test, no dependency and no
Cargo.lock entry changes.

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2::begin_tls_close` reaches `FrontRustls::socket_close`, which
is `rustls::ServerConnection::send_close_notify`. It had no coverage at
all. Measured at 42ed6ba: replacing its body with `{}` left `cargo test
-p sozu-lib` at `1113 passed; 0 failed` and reddened no `sozu-e2e` test
either, while the same mutation on either of its two siblings from the
same extraction reddens at once. Measured against this changeset's own
`1114 passed` baseline: `tls_wants_write() -> false` gives `1103 passed;
11 failed` and a no-op `flush_tls_records()` gives `1109 passed; 5
failed`, ten and four of those respectively being tests other than the
one added here.

The hole was structural rather than an oversight. Every handler the suite
drove a close over -- `mio::net::TcpStream` and the
`BackpressuredTlsSocket` fixture -- inherits `SocketHandler::socket_close`'s
empty trait default, so the real seam and a no-op are the same thing to
all of them, and `FrontRustls` is the only implementation in the tree that
overrides it. #1484's coverage audit reached the same conclusion from the
other direction, listing `initiate_close_notify` among the
`socket_wants_write` branches its six `ConnectionH2<FrontRustls>` tests
could not reach, for want of a driven close_notify.

`a_frontend_timeout_makes_the_peer_receive_a_tls_close_notify` drives the
production route end to end over the existing `rustls_h2_connection`
fixture: `Mux::timeout` -> `Mux::delay_close_for_frontend_flush` ->
`Connection::initiate_close_notify` ->
`ConnectionH2::initiate_close_notify` -> `begin_tls_close` ->
`send_close_notify`, then flushes through the same
`Connection::flush_zero_buffer` that `Mux::shutting_down_inner` calls for
this purpose. It asserts on what the peer's real
`rustls::ClientConnection` decrypts: `IoState::peer_has_closed()`, and
`Reader::read` answering `Ok(0)` rather than `UnexpectedEof`. That second
witness is the whole point -- rustls answers `Ok(0)` only for a stream
closed with a close_notify and `UnexpectedEof` for a bare FIN, so an
assertion that a FIN had arrived would have passed against the mutant.

Seen red before it was trusted: `1113 passed; 1 failed`, this test and
nothing else, failing on `the peer must decrypt a TLS close_notify alert`.

Test-only. The whole diff lies inside `#[cfg(test)] mod tests`, so
`sozu-lib` built as a dependency is byte-identical to 42ed6ba and no
`sozu-e2e` behaviour can change.

Refs: #1498
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
…e code

lib/src/protocol/mux/LIFECYCLE.md carried three `path:NNN` citations that
resolved to real, non-blank, unrelated lines, which is all any rule in
check_doc_citations.py asks of them:

- §4.2 put the `Context.streams` push at `mod.rs:713-714`. Those are
  `listener.get_sticky_name().to_string()` and
  `listener.get_sozu_id_header().to_string()`, arguments of the
  `HttpContext::new(...)` call that opens `Context::create_stream`. The push is
  `self.streams.push(stream)` at `mod.rs:773`.
- §3.1's `Unlinked` bullet read `h1.rs:995-1052`. `995` is a format string in
  `ConnectionH1::end_stream`'s wrong-stream `error!` guard and `1052` is a
  `debug_assert!` argument; the four `StreamState::Unlinked` assignments the
  range is meant to bracket are `h1.rs:1042-1099`. It was exact at fbc83ed
  (`h1.rs:737-772` against assignments at 737, 745, 767 and 772) and successive
  renumberings walked it off them.
- §7.5's arm-site list read `h2.rs:5387`, which is `log_context!(self)` inside
  an `error!` for an out-of-bounds header block fragment. The HEADERS liveness
  refresh is `self.stream_table.touch_activity(stream_id, self.now)` at
  `h2.rs:5421`. The two commits directly below this one each renumbered that
  citation and neither noticed: #1501 moved it from `h2.rs:5376` to
  `h2.rs:5384`, and #1497 from `h2.rs:5384` to `h2.rs:5387`. Both moves were
  faithful and both landed on `log_context!(self)`: a re-anchor preserves the
  pointer, not the claim.

§7.2 described all three per-stream reap caches as `ConnectionH2` fields
holding a `HashMap`. Both halves are wrong and have been since #1415's
stream-slot-bookkeeping extraction: `stream_last_activity_at`,
`stream_fc_stalled_since` and `stream_fc_stalled_progress` are private
`BTreeMap` fields of `H2StreamTable`, built by `BTreeMap::new()` in
`H2StreamTable::new`, and `ConnectionH2` declares no field of any of those
names. #1415 converted them for the determinism reason its own CHANGELOG entry
records and updated §4.1's wire-map bullet, but left §7.2 on the pre-extraction
shape, so the section now inverts the ordering guarantee the code provides.
Cited by symbol rather than line: that module is being edited under #1338.

CHANGELOG.md's #1484 entry said `shared::drain_tls_close_notify`'s two
uncovered lines were uncovered "because nothing calls that function at all". It
has two production callers, the `Position::Server` arms of `ConnectionH1::close`
and `ConnectionH2::close`. What #1484 measured is that its own six-test fixture
never reaches them. Only that causal clause changed; every count and probe tally
in that historical entry was true as measured and is left as written.

The three citations sat in the drift rule's exemption: it keys on the citation
tuple as it stood in the base revision of the citing document, so a renumbered
span is counted exempt and never compared. Measured at 42ed6ba over the window
they were renumbered in, --base f2082b6 --show reported 133 exempt cited ends
across 91 doc sites; 11 are fenced blocks the pinned-quote rule already compares
verbatim, and reading the remaining 80 against the code they name found 77
correct and these three wrong. --base 42ed6ba --show on this tree exempts 109
more, the spans #1501's and #1497's renumberings re-anchored: 15 pinned fences,
the 4 repaired here, and 90 that anchor on byte-identical text before and after
them. --audit
reports 7 findings on this tree, all 7 the heuristic pairing a prose symbol with
a line eight or more away from it. The three §7.2 declarations were in no rule's
surface at all: every rule resolves a `path:NNN` or a fenced quote, and a
sentence naming a type and a container carries neither. Sweeping LIFECYCLE.md
for the same shape leaves only the three `ConnectionH2.streams` references that

Documentation only: no production code, no test, no dependency and no
Cargo.lock entry changes.

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
…e code (#1504)

lib/src/protocol/mux/LIFECYCLE.md carried three `path:NNN` citations that
resolved to real, non-blank, unrelated lines, which is all any rule in
check_doc_citations.py asks of them:

- §4.2 put the `Context.streams` push at `mod.rs:713-714`. Those are
  `listener.get_sticky_name().to_string()` and
  `listener.get_sozu_id_header().to_string()`, arguments of the
  `HttpContext::new(...)` call that opens `Context::create_stream`. The push is
  `self.streams.push(stream)` at `mod.rs:773`.
- §3.1's `Unlinked` bullet read `h1.rs:995-1052`. `995` is a format string in
  `ConnectionH1::end_stream`'s wrong-stream `error!` guard and `1052` is a
  `debug_assert!` argument; the four `StreamState::Unlinked` assignments the
  range is meant to bracket are `h1.rs:1042-1099`. It was exact at fbc83ed
  (`h1.rs:737-772` against assignments at 737, 745, 767 and 772) and successive
  renumberings walked it off them.
- §7.5's arm-site list read `h2.rs:5387`, which is `log_context!(self)` inside
  an `error!` for an out-of-bounds header block fragment. The HEADERS liveness
  refresh is `self.stream_table.touch_activity(stream_id, self.now)` at
  `h2.rs:5421`. The two commits directly below this one each renumbered that
  citation and neither noticed: #1501 moved it from `h2.rs:5376` to
  `h2.rs:5384`, and #1497 from `h2.rs:5384` to `h2.rs:5387`. Both moves were
  faithful and both landed on `log_context!(self)`: a re-anchor preserves the
  pointer, not the claim.

§7.2 described all three per-stream reap caches as `ConnectionH2` fields
holding a `HashMap`. Both halves are wrong and have been since #1415's
stream-slot-bookkeeping extraction: `stream_last_activity_at`,
`stream_fc_stalled_since` and `stream_fc_stalled_progress` are private
`BTreeMap` fields of `H2StreamTable`, built by `BTreeMap::new()` in
`H2StreamTable::new`, and `ConnectionH2` declares no field of any of those
names. #1415 converted them for the determinism reason its own CHANGELOG entry
records and updated §4.1's wire-map bullet, but left §7.2 on the pre-extraction
shape, so the section now inverts the ordering guarantee the code provides.
Cited by symbol rather than line: that module is being edited under #1338.

CHANGELOG.md's #1484 entry said `shared::drain_tls_close_notify`'s two
uncovered lines were uncovered "because nothing calls that function at all". It
has two production callers, the `Position::Server` arms of `ConnectionH1::close`
and `ConnectionH2::close`. What #1484 measured is that its own six-test fixture
never reaches them. Only that causal clause changed; every count and probe tally
in that historical entry was true as measured and is left as written.

The three citations sat in the drift rule's exemption: it keys on the citation
tuple as it stood in the base revision of the citing document, so a renumbered
span is counted exempt and never compared. Measured at 42ed6ba over the window
they were renumbered in, --base f2082b6 --show reported 133 exempt cited ends
across 91 doc sites; 11 are fenced blocks the pinned-quote rule already compares
verbatim, and reading the remaining 80 against the code they name found 77
correct and these three wrong. --base 42ed6ba --show on this tree exempts 109
more, the spans #1501's and #1497's renumberings re-anchored: 15 pinned fences,
the 4 repaired here, and 90 that anchor on byte-identical text before and after
them. --audit
reports 7 findings on this tree, all 7 the heuristic pairing a prose symbol with
a line eight or more away from it. The three §7.2 declarations were in no rule's
surface at all: every rule resolves a `path:NNN` or a fenced quote, and a
sentence naming a type and a container carries neither. Sweeping LIFECYCLE.md
for the same shape leaves only the three `ConnectionH2.streams` references that

Documentation only: no production code, no test, no dependency and no
Cargo.lock entry changes.

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2::begin_tls_close` reaches `FrontRustls::socket_close`, which
is `rustls::ServerConnection::send_close_notify`. It had no coverage at
all. Measured at 342397d: replacing its body with `{}` left `cargo test
-p sozu-lib` at `1113 passed; 0 failed` and reddened no `sozu-e2e` test
either, while the same mutation on either of its two siblings from the
same extraction reddens at once. Measured against this changeset's own
`1114 passed` baseline: `tls_wants_write() -> false` gives `1103 passed;
11 failed` and a no-op `flush_tls_records()` gives `1109 passed; 5
failed`, ten and four of those respectively being tests other than the
one added here.

The hole was structural rather than an oversight. Every handler the suite
drove a close over -- `mio::net::TcpStream` and the
`BackpressuredTlsSocket` fixture -- inherits `SocketHandler::socket_close`'s
empty trait default, so the real seam and a no-op are the same thing to
all of them, and `FrontRustls` is the only implementation in the tree that
overrides it. #1484's coverage audit reached the same conclusion from the
other direction, listing `initiate_close_notify` among the
`socket_wants_write` branches its six `ConnectionH2<FrontRustls>` tests
could not reach, for want of a driven close_notify.

`a_frontend_timeout_makes_the_peer_receive_a_tls_close_notify` drives the
production route end to end over the existing `rustls_h2_connection`
fixture: `Mux::timeout` -> `Mux::delay_close_for_frontend_flush` ->
`Connection::initiate_close_notify` ->
`ConnectionH2::initiate_close_notify` -> `begin_tls_close` ->
`send_close_notify`, then flushes through the same
`Connection::flush_zero_buffer` that `Mux::shutting_down_inner` calls for
this purpose. It asserts on what the peer's real
`rustls::ClientConnection` decrypts: `IoState::peer_has_closed()`, and
`Reader::read` answering `Ok(0)` rather than `UnexpectedEof`. That second
witness is the whole point -- rustls answers `Ok(0)` only for a stream
closed with a close_notify and `UnexpectedEof` for a bare FIN, so an
assertion that a FIN had arrived would have passed against the mutant.

Seen red before it was trusted: `1113 passed; 1 failed`, this test and
nothing else, failing on `the peer must decrypt a TLS close_notify alert`.

Test-only. The whole diff lies inside `#[cfg(test)] mod tests`, so
`sozu-lib` built as a dependency is byte-identical to 342397d and no
`sozu-e2e` behaviour can change.

Refs: #1498
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2::begin_tls_close` reaches `FrontRustls::socket_close`, which
is `rustls::ServerConnection::send_close_notify`. It had no coverage at
all. Measured at 0dddedf: replacing its body with `{}` left `cargo test
-p sozu-lib` at `1114 passed; 0 failed` and reddened no `sozu-e2e` test
either, while the same mutation on either of its two siblings from the
same extraction reddens at once. Measured against this changeset's own
`1115 passed` baseline: `tls_wants_write() -> false` gives `1104 passed;
11 failed` and a no-op `flush_tls_records()` gives `1110 passed; 5
failed`, ten and four of those respectively being tests other than the
one added here.

The hole was structural rather than an oversight. Every handler the suite
drove a close over -- `mio::net::TcpStream` and the
`BackpressuredTlsSocket` fixture -- inherits `SocketHandler::socket_close`'s
empty trait default, so the real seam and a no-op are the same thing to
all of them, and `FrontRustls` is the only implementation in the tree that
overrides it. #1484's coverage audit reached the same conclusion from the
other direction, listing `initiate_close_notify` among the
`socket_wants_write` branches its six `ConnectionH2<FrontRustls>` tests
could not reach, for want of a driven close_notify.

`a_frontend_timeout_makes_the_peer_receive_a_tls_close_notify` drives the
production route end to end over the existing `rustls_h2_connection`
fixture: `Mux::timeout` -> `Mux::delay_close_for_frontend_flush` ->
`Connection::initiate_close_notify` ->
`ConnectionH2::initiate_close_notify` -> `begin_tls_close` ->
`send_close_notify`, then flushes through the same
`Connection::flush_zero_buffer` that `Mux::shutting_down_inner` calls for
this purpose. It asserts on what the peer's real
`rustls::ClientConnection` decrypts: `IoState::peer_has_closed()`, and
`Reader::read` answering `Ok(0)` rather than `UnexpectedEof`. That second
witness is the whole point -- rustls answers `Ok(0)` only for a stream
closed with a close_notify and `UnexpectedEof` for a bare FIN, so an
assertion that a FIN had arrived would have passed against the mutant.

Seen red before it was trusted: `1114 passed; 1 failed`, this test and
nothing else, failing on `the peer must decrypt a TLS close_notify alert`.

Test-only. The whole diff lies inside `#[cfg(test)] mod tests`, so
`sozu-lib` built as a dependency is byte-identical to 0dddedf and no
`sozu-e2e` behaviour can change.

Refs: #1498
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 24, 2026
`ConnectionH2::begin_tls_close` reaches `FrontRustls::socket_close`, which
is `rustls::ServerConnection::send_close_notify`. It had no coverage at
all. Measured at 0dddedf: replacing its body with `{}` left `cargo test
-p sozu-lib` at `1114 passed; 0 failed` and reddened no `sozu-e2e` test
either, while the same mutation on either of its two siblings from the
same extraction reddens at once. Measured against this changeset's own
`1115 passed` baseline: `tls_wants_write() -> false` gives `1104 passed;
11 failed` and a no-op `flush_tls_records()` gives `1110 passed; 5
failed`, ten and four of those respectively being tests other than the
one added here.

The hole was structural rather than an oversight. Every handler the suite
drove a close over -- `mio::net::TcpStream` and the
`BackpressuredTlsSocket` fixture -- inherits `SocketHandler::socket_close`'s
empty trait default, so the real seam and a no-op are the same thing to
all of them, and `FrontRustls` is the only implementation in the tree that
overrides it. #1484's coverage audit reached the same conclusion from the
other direction, listing `initiate_close_notify` among the
`socket_wants_write` branches its six `ConnectionH2<FrontRustls>` tests
could not reach, for want of a driven close_notify.

`a_frontend_timeout_makes_the_peer_receive_a_tls_close_notify` drives the
production route end to end over the existing `rustls_h2_connection`
fixture: `Mux::timeout` -> `Mux::delay_close_for_frontend_flush` ->
`Connection::initiate_close_notify` ->
`ConnectionH2::initiate_close_notify` -> `begin_tls_close` ->
`send_close_notify`, then flushes through the same
`Connection::flush_zero_buffer` that `Mux::shutting_down_inner` calls for
this purpose. It asserts on what the peer's real
`rustls::ClientConnection` decrypts: `IoState::peer_has_closed()`, and
`Reader::read` answering `Ok(0)` rather than `UnexpectedEof`. That second
witness is the whole point -- rustls answers `Ok(0)` only for a stream
closed with a close_notify and `UnexpectedEof` for a bare FIN, so an
assertion that a FIN had arrived would have passed against the mutant.

Seen red before it was trusted: `1114 passed; 1 failed`, this test and
nothing else, failing on `the peer must decrypt a TLS close_notify alert`.

Test-only. The whole diff lies inside `#[cfg(test)] mod tests`, so
`sozu-lib` built as a dependency is byte-identical to 0dddedf and no
`sozu-e2e` behaviour can change.

Refs: #1498

Signed-off-by: Florentin Dubois <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No test instantiates ConnectionH2<FrontRustls>, so 15 socket_wants_write branches including the truncation vector are unexercised

1 participant