Skip to content

refactor(kawa_h1): remove the unreachable Http session state machine - #1370

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
refactor/drop-kawa-h1-http
Sep 20, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
refactor/drop-kawa-h1-http

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Closes #1346 and closes #1347.

The mux migration replaced kawa_h1's Http session state machine, and it has been unreachable since.
This removes it: −2,564 lines of lib/src Rust (87,973 → 85,409), kawa_h1/mod.rs 2,655 → 129.

Reachability — the proof, since a deletion cannot be regression-tested

protocol/mod.rs re-exports kawa_h1 as http, so consumers appear under both spellings and a grep
on one undercounts. Swept both, repo-wide, no file-type filter, including fuzz/, sim/, lib/benches/:

  • Exactly one constructor, Http::new, whose sole struct literal was Ok(Http { … }). Repo-wide
    call sites in code: zero. Three hits, all prose.
  • No enum variant can hold one. HttpStateMachine = Expect | Mux(MuxClear) | WebSocket;
    HttpsStateMachine = Expect | Handshake | Mux(MuxTls) | WebSocket; TcpStateMachine is TCP-only.
  • Outside kawa_h1/, the only compiled references were the pub use … http::Http and two
    commented-out assert_size! lines. kawa_h1: is the Http session state machine still reachable in any binary? #1346 cites those as live references; they are inside /* */
    and were never compiled. They are removed too.

This is a breaking change for library consumers

lib/src/lib.rs pub mod protocol; plus pub struct Http plus the re-export made
sozu_lib::protocol::Http, ::protocol::http::Http and ::protocol::kawa_h1::Http all reachable, with
Http::new public. sozu-lib 2.2.1 is published. So a downstream crate could construct it even though
no binary did.

Recorded under a new ### ➖ Removed with a BREAKING (library API) marker naming every removed path and
stating there is no migration target. RELEASE.md contains no semver policy (zero hits for
semver/major/breaking); the only precedent is the 1.1.x → 2.0.0 section and inline BREAKING —
markers. The version-number call is left to a maintainer.

What went, and what stayed

Removed as transitively dead: both inherent impls and SessionState for Http, TimeoutStatus,
ResponseStream, save_http_status_metric, kawa_h1's handle_connection_result (tcp.rs keeps its own
copy), the module-local log_context! macro — and with it the KAWA-H1 log tag, now emitted by nothing —
and the whole diagnostics module (mux fills parse-detail answer fields with neutral placeholders, so the
hex-dump renderer had no live consumer).

Kept: type GenericHttpStream, impl kawa::AsBuffer for Checkout (orphan rule — mux's
kawa::Kawa<Checkout> depends on this single impl), DefaultAnswer and its u16 mapping, and all of
editor.rs / parser.rs / answers.rs.

answers.rs (1,963 lines) lost nothing. Assessed item by item: HttpAnswers::get has two callers and
mux keeps it; DefaultAnswerStream/SharedBuffer live via mux/answers.rs; legacy_to_map lives via
merge_legacy_into_map. (render_inline_301 has zero callers but was already dead before this change —
a deliberate back-compat wrapper — and is left alone as unrelated.)

The one orphaned test was ported, not deleted

a_backend_status_line_below_100_is_bucketed_not_asserted guarded sozu#1279: a backend status line
outside 100..=999, reaching the bucketer through the real kawa parser, must land in http.status.other
and never trip a range debug_assert! that would panic the worker on network input in every
debug/test/e2e/fuzz build.

The live mux::stream::generate_access_log has the identical _ => STATUS_OTHER catch-all but had no
assertion on it
. Deleting the test would have silently removed the only coverage of a live NO-PANIC
guarantee. It now lives at protocol::mux::stream::tests, with an in-file note on where it came from.

Proven red by planting the very assertion it exists to prevent:

debug_assert!((100..=999).contains(&status), "generate_access_log got a non-3-digit status: {status}")
  -> panicked at lib/src/protocol/mux/stream.rs:354:13:
     generate_access_log got a non-3-digit status: 0

#[test] count in lib/src 899 → 897 (−1 real, −2 inside /* */, +1 ported);
cargo test -p sozu-lib --lib 863 → 863.

#1347 closes by obsolescence, not by a fix

#1347 — a frontend timeout consumed without re-arming, leaving a session to the 30-minute zombie_check —
lives at kawa_h1/mod.rs:2388, inside impl Http. After this change there is no code to redden, so it
gets no regression test. The compiling, green removal is the stronger proof.

One non-obvious break

editor.rs resolved Method through crate::protocol::http::Method, a private use binding in
kawa_h1/mod.rs visible to the child module. Deleting the imports broke it (E0432, cascading to E0282 in
mux/router.rs). Repointed to parser::{Method, compare_no_case}.

Docs

kawa_h1/LIFECYCLE.md is rewritten wholesale — its old §1, §2 and §5 described only deleted code.
doc/lifetime_of_a_session.md §6.1 rewritten to the mux path; doc/observability.md drops the KAWA-H1
row; doc/benchmark.md's pre-mux profiler paste is kept verbatim with a note, because it is recorded
output rather than prose. Also doc/testing.md, doc/configure.md, e2e/COVERAGE.md, lib/README.md,
proxy_protocol/LIFECYCLE.md, CLAUDE.md, CHANGELOG.md.

Validation

BUILD=0 CLIPPY=0 TEST=0 FMT=0; -p sozu-lib --lib 863 passed, -p sozu-command-lib 153, -p sozu 97,
plus log_layout and metric_names.

`kawa_h1::Http<Front, L>` was constructible by nothing. `HttpStateMachine`
(`lib/src/http.rs`) is `Expect | Mux | WebSocket` and `HttpsStateMachine`
(`lib/src/https.rs`) is `Expect | Handshake | Mux | WebSocket`; neither holds
one, and `Http::new` had zero code callers under either module spelling —
`lib/src/protocol/mod.rs` re-exports `kawa_h1 as http`, so a grep on one
spelling undercounts. Measured, not inferred: a planted
`panic!("PROBEALWAYS ...")` at the top of `Http::new` and
`save_http_status_metric` fired 0 times across four real proxied e2e sessions
while the same binary panicked immediately under the function's own unit test.
H1 has run through `protocol/mux` in H1 mode since the mux migration.

Removed with it, because nothing else reached them: the `SessionState` impl,
`TimeoutStatus`, `ResponseStream`, `save_http_status_metric`, this module's
`handle_connection_result` (`tcp.rs` keeps its own), the module-local
`log_context!` macro and with it the `KAWA-H1` log tag, and the whole
`kawa_h1::diagnostics` module — the mux fills the parse-detail answer fields
with neutral placeholders, so its hex-dump renderer had no live consumer. The
two commented-out `size_test` blocks in `http.rs` / `https.rs` that
`assert_size!`d `Http<..>` go too.

BREAKING for `sozu-lib` consumers, not for operators: nothing on the wire, no
metric, log line, configuration key or CLI flag changes, but
`sozu_lib::protocol::Http`, `::protocol::http::Http`,
`::protocol::kawa_h1::{Http, TimeoutStatus, ResponseStream}` and
`::protocol::kawa_h1::diagnostics::*` no longer exist. There is no migration
target; the type implemented a session state machine no binary instantiated.

Closes #1346. Closes #1347 by obsolescence: the frontend timeout consumed
without re-arming lived inside this `impl`, so there is no code left to redden
and it gets no regression test. The mux already re-arms explicitly on the live
path.

Exactly one test was orphaned and it was ported, not deleted:
`kawa_h1::tests::a_backend_status_line_below_100_is_bucketed_not_asserted`
becomes
`mux::stream::tests::a_backend_status_line_below_100_is_bucketed_not_asserted`,
guarding the live `Stream::generate_access_log` bucketer, which had no such
assertion. Seen red by planting the forbidden
`debug_assert!((100..=999).contains(&status))` in its bucket arm.

`answers.rs` was assessed item by item: nothing in it became dead.
`HttpAnswers`, `DefaultAnswerStream`, `merge_legacy_into_map`, `HttpContext`,
`HeaderEditMode`, `HeaderEditSnapshot`, `Method`, `hostname_and_port`, the
`DefaultAnswer` enum and the crate's only `impl kawa::AsBuffer for Checkout`
all stay.

`lib/src/protocol/kawa_h1/LIFECYCLE.md` is rewritten from "H1 session
lifecycle" to "the H1 vocabulary the mux builds on", with its citations
refreshed. `doc/lifetime_of_a_session.md`, `doc/testing.md`,
`doc/observability.md`, `doc/configure.md`, `doc/benchmark.md`,
`e2e/COVERAGE.md`, `lib/README.md`,
`lib/src/protocol/proxy_protocol/LIFECYCLE.md`, `CLAUDE.md` and `CHANGELOG.md`
are updated in the same changeset.

lib/src: 87 973 -> 85 415 lines of Rust (2 712 removed, 154 added).

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the refactor/drop-kawa-h1-http branch from c64bceb to af6a2f5 Compare September 20, 2026 12:13
@FlorentinDUBOIS
FlorentinDUBOIS merged commit ba7fa5f into main Sep 20, 2026
23 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the refactor/drop-kawa-h1-http branch September 20, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant