Skip to content

feat(tls): crypto provider selection, health checks, cipher list fix, version display - #1191

Merged
FlorentinDUBOIS merged 31 commits into
mainfrom
feat/crypto-provider-feature-flags
Apr 30, 2026
Merged

FlorentinDUBOIS merged 31 commits into
mainfrom
feat/crypto-provider-feature-flags

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Mar 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Crypto provider selection, HTTP health checks (with cluster-derived h2c probes and fail-open), TLS scheme tests + cardinality matrix, a systemd-style version display, and a single consolidated CI workflow whose 8-cell pipeline matrix covers MSRV + four crypto providers + stable/beta/nightly drift end-to-end with shared per-cell caching. Rebased onto post-1209 (H2 mux) main.

Commits (31, on top of post-1209 main; SHAs reflect the post-review-feedback rebase — see the "Review-feedback follow-up" section below):

f51fd077 feat(tls): compile-time crypto provider selection via feature flags
e75c175d feat(health-check): non-blocking HTTP health checks with fail-open and CLI
b7b44f13 test(e2e): add TLS scheme + health check end-to-end tests
466f05ed docs: health check guide, crypto provider configuration, reference updates
6e500107 test(e2e): cardinality matrix for TLS scheme tests
9cff80f4 feat(health-check): h2c prior-knowledge probe support
f1db7c70 fix(fuzz): forward crypto-ring feature to sozu-lib
6e7c91cd fix(crypto,health-check,docs): centralise validation; precedence chain; h2c literal-name parsing
065e2034 ci: run full sozu-e2e suite under each crypto provider
676e3c91 fix(ci): pin crypto-providers matrix to rust 1.88.0
379f0964 ci(bench): all-provider matrix + Criterion job; reorder crypto precedence to ring-first
91cc0e56 fix(health-check): include port in Host header (RFC 9110 §7.2)
70ce2fc7 fix(ci): bump crypto-providers timeout to 60 min for the full e2e step
89cbb97f refactor(health-check): derive h2c probe from cluster.http2; drop is_h2c
6ddbc259 fix(ci): skip fuzz_tests in crypto-providers matrix
efee7467 fix(ci): quote `run:` value containing `tests::fuzz_tests::`
f2df3949 fix(e2e): align hyper-rustls provider with sozu-lib's selection
f32e324e fix(workspace): disable sozu-lib's default features at the workspace level
214cea77 test(e2e): ignore test_tls_1_2_ecdsa under crypto-openssl
a205c6a7 chore(fuzz): gitignore + remove libfuzzer-generated corpus entries
b326ace9 ci(workflows): consolidate ci+benchmark into per-cell pipeline with cache reuse
39d9f2d8 test(e2e): probe rustls-openssl TLS 1.2 + ECDSA upstream regression
299ad0eb fix(state,server): validate health_check on AddCluster path
834617b9 fix(http,https,router): restore has_hostname guard on frontend removal
e1a7ac66 fix(cli): gate --version ANSI escapes on terminal detection
16455d61 chore(comments,docs): drop review-process leakage; align stale h2c doc comments
c6ccf9aa fix(crypto): fips takes precedence over other providers (implies aws-lc-rs in FIPS mode)
a920eabf fix(backends,health-check): fail-open keeps retry-policy gate; latch warn! once per regime; emit healthy_backends gauge at 0
c50af05e docs: drop stale `is_h2c` option references in health-check docs
1c5eb263 refactor(health-check): use loona-hpack and mux::parser for h2c probe
2665fd1f fix(cli,docs): tighten --version TTY gate; document piggy-backed bug fixes

49 source files changed, +4900 / −650 lines (approximate; excludes 393 unsigned libFuzzer corpus seeds removed via .gitignore alignment).


1. Compile-time crypto provider selection

Cargo features select the rustls CryptoProvider:

Feature Backend Notes
crypto-ring (default) ring Pure Rust, no extra deps
crypto-aws-lc-rs aws-lc-rs Post-quantum (ML-KEM), faster bulk transfers. Requires cmake
crypto-openssl rustls-openssl System OpenSSL backend. Requires cmake + OpenSSL headers
fips aws-lc-rs in FIPS mode Implies crypto-aws-lc-rs, not a fourth provider. FIPS 140-3 compliance

lib/src/crypto.rs uses a precedence chain (ring > aws-lc-rs > openssl) so cargo build --all-features --locked keeps the same default behaviour operators get from bin/Cargo.toml's default = ["jemallocator", "crypto-ring"]. Downstream Dockerfile / RPM / PKGBUILD entries each enable exactly one provider explicitly. To select FIPS, pass --no-default-features --features fips (which pulls in crypto-aws-lc-rs).

cipher_suite_by_name filters its result through default_provider().cipher_suites so a ChaCha-inclusive cipher_list cannot silently downgrade an FIPS build (rustls 0.23 only reports ServerConfig::fips() == true when every cipher and KX group is FIPS-approved). Post-quantum X25519MLKEM768 is first-preference for crypto-aws-lc-rs and crypto-openssl; groups_list is per-listener via ListenerBuilder.

Closes #1023 (cipher list harmonization).

2. HTTP backend health checks with fail-open and h2c support

Non-blocking probes that share the existing single-threaded mio event loop — no extra threads, no async runtime.

  • New lib/src/health_check.rs (~700 LOC). Probes use a bounded token namespace [1<<24, 1<<24 + 1<<16) with a modulo-allocator that skips in-flight slots and refuses allocation rather than colliding with the mux GOAWAY sentinel Token(usize::MAX). Threshold-based state machine, jittered intervals, 4 KB response buffer cap.
  • Centralised validation at sozu_command::config::validate_health_check_config: rejects zero thresholds, missing leading /, and any CR/LF/NUL/C0 byte in the URI per RFC 9110 §5.1. Funnelled through CLI / worker / ConfigState::set_health_check so off-channel paths cannot smuggle invalid configs through SaveState/LoadState.
  • Fail-open in lib/src/backends.rs::BackendList::next_available_backend — when no backend passes the regular can_open() gate for a cluster, route across Normal-status backends whose retry policy is OKAY rather than returning 503 (per the Amazon health-check paper). The warn! is latched once per regime entry, paired with a count!("backends.fail_open", 1) counter per routing decision; the health_check.healthy_backends gauge emits on every result update including 0 so dashboards can detect the universal-outage state.
  • Cluster-derived HTTP/2 prior-knowledge (h2c) probes. The probe wire format follows the cluster's http2 flag, so the probe and the data-plane backend connection cannot diverge. When cluster.http2 = true the probe sends the HTTP/2 connection preface, an empty SETTINGS frame, and a HEADERS frame on stream 1 (encoded via loona_hpack::Encoder and decoded via loona_hpack::Decoder so the parser inherits the workspace's existing HPACK fuzz coverage and supports HEADERS+CONTINUATION fragmentation). The response parser uses mux::parser::frame_header to walk frames, looks for HEADERS on stream 1, decodes :status, and treats GOAWAY as a probe failure.
  • RemoveHealthCheck resets Backend.health so stale Unhealthy markers can't permanently sideline a backend after the operator drops the check.

CLI:

sozu cluster health-check set --id my-cluster --uri /health \
    --interval 10 --timeout 5 --healthy-threshold 3 --unhealthy-threshold 3
# h2c probes are automatic when the cluster has `http2 = true`
sozu cluster health-check list [--id <cluster>]
sozu cluster health-check remove --id my-cluster

3. Proto field renumbering (post-1209 collisions)

The H2 mux merge (PR #1209) reshaped Request, Cluster, ResponseContent, and EventKind. PR #1191's original tags now live at:

Carrier Old New
Request.set_health_check 47 52
Request.remove_health_check 48 53
Request.query_health_checks 49 54
Cluster.health_check 8 15
ResponseContent.health_checks_list 14 15
EventKind.HEALTH_CHECK_HEALTHY 5 27
EventKind.HEALTH_CHECK_UNHEALTHY 4 28

Operators upgrading from earlier PR #1191 builds must rebuild any external clients that hard-coded the original tags.

4. systemd-style version display

sozu --version shows the git commit, branch, and compiled feature flags with colored +/- indicators (green=enabled, red=disabled). ANSI escapes are gated at runtime in the --version handler (bin/src/cli.rs) on IsTerminal::is_terminal(&stdout()), so an interactive terminal renders the coloured indicators while sozu --version > file (package metadata, systemd journal, scripts) stays plaintext. TLS 1.0/1.1 still emit a deprecation warning citing RFC 8996.

5. CI / benchmark pipeline — single ci.yml, per-cell matrix with cache reuse

The standalone benchmark.yml is deleted; everything now lives in .github/workflows/ci.yml as a unified pipeline. Within the new file, one matrix job (pipeline) runs eight cells in parallel — each cell is a single sequential job with hot target dir between steps, so the cache stays warm across build → fmt(msrv) → doc(msrv) → lint(1.88) → test → bench(crypto).

cell toolchain features lint? bench? required?
msrv 1.88.0 (default) yes no yes
crypto-ring 1.88.0 --no-default-features --features crypto-ring yes yes yes
crypto-aws-lc-rs 1.88.0 --no-default-features --features crypto-aws-lc-rs yes yes yes
crypto-openssl 1.88.0 --no-default-features --features crypto-openssl yes yes yes
fips 1.88.0 --no-default-features --features fips yes yes yes
stable stable (default) no¹ no yes
beta beta (default) no¹ no yes
nightly nightly (default) no¹ no continue-on-error²

¹ Stable/beta/nightly currently fire mismatched_lifetime_syntaxes and other 1.95+ lints that have not been triaged across the workspace; lint is gated to 1.88 cells until that lands.
² Preserves the previous "experimental: true" posture for nightly.

fail-fast: false everywhere so a single-cell failure does not cancel siblings. Swatinem/rust-cache is keyed ci-${cell} per cell — Bombardier and bench-logs jobs restore the matching ci-${provider} cache to make their release sozu builds incremental over warm registry + deps.

Other workflow-level changes:

  • Concurrency cancellation: ${workflow}-${ref} group, cancel-in-progress on feature branches but not on main (so artefacts produced under one SHA aren't lost when newer pushes land).
  • Dedicated fuzz job (nightly toolchain): actually runs cargo +nightly fuzz run fuzz_frame_parser and fuzz_hpack_decoder for 300 s each (~10 min wall). Crash artefacts upload from fuzz/artifacts/ on failure. Today's e2e tests::fuzz_tests::* are #[ignore]d everywhere; this is the only place the libFuzzer corpus is exercised.
  • cargo install cargo-fuzz lifted out of every test cell — only the dedicated fuzz job installs it.
  • Every Rust install pinned to dtolnay/rust-toolchain@… (no more actions-rust-lang/setup-rust-toolchain@v1 injecting -D warnings via RUSTFLAGS).
  • doc step uses cargo doc --no-deps --all-features --locked (was bare cargo doc --verbose on stable).
  • Criterion artefact uploads use if: always() && matrix.bench and retention-days: 14 so baselines roll off without filling the artefact bucket.

Group D — Bombardier load benches (folded from the old benchmark.yml):

  • build-bombardier (Go, codesenberg/bombardier), build-lagging_server (external Rust repo CleverCloud/lagging_server), build-bench-logger (workspace example) — each uploads its artefact.
  • bench-bombardier matrix (4 providers, fail-fast: false) builds release sozu per provider over the warm ci-${provider} cache, generates RSA-2048/RSA-4096/ECDSA cert chains, and runs bench.py against bombardier.
  • bench-logs job restores ci-crypto-ring, builds release sozu, and runs bench_logs.py against the bench_logger example.

E2E coverage included in the per-cell test step (~328 tests):

  • TLS scheme tests (RSA-2048, ECDSA P-256 × TLS 1.2 / 1.3 — 6 tests) in e2e/src/tests/tests.rs.
  • Cardinality matrix tests (frontend H1/H2 × backend H1/H2 × RSA/ECDSA — 6 tests covering the cells PR feat(h2): HTTP/2 support via unified Mux session layer #1209's mux exposes).
  • Health-check lifecycle tests (excludes-unhealthy, recovery, remove, fail-open, invalid config, expected status — 6 tests).
  • HPACK / h2c probe unit tests in lib/src/health_check.rs: probe-bytes encoding (preface + SETTINGS + HEADERS), :status extraction across single-frame and HEADERS+CONTINUATION layouts, padded + priority flags, GOAWAY, truncated buffer. The probe parser uses loona_hpack::Decoder and mux::parser::frame_header so it shares coverage with the workspace fuzz_hpack_decoder and fuzz_frame_parser cargo-fuzz targets.
  • Bombardier readiness check: bench.py waits on wait_for_port() (15 s timeout) and exits with stderr if sozu fails to start.

lib/Cargo.toml's [features] block had a stale comment claiming --all-features resolves to aws-lc-rs; this is fixed in f773b5ea to match the actual ring > aws-lc-rs > openssl chain in lib/src/crypto.rs.

6. Packaging & documentation

  • Dockerfile (Alpine/musl): ARG CRYPTO_PROVIDER=crypto-ring; cmake added to build deps.
  • RPM spec: %bcond macros for provider selection, cmake in BuildRequires.
  • Arch PKGBUILD: cmake in makedepends, explicit feature selection.
  • doc/health_checks.md (new): state machine, TOML config, CLI commands, fail-open behavior, h2c probe wire format, metrics, events.
  • doc/configure.md: crypto provider tables, cipher suite tables, KX groups by provider, health-check section.
  • doc/getting_started.md: "Choosing a crypto provider" section with build examples.
  • doc/metrics.md (new): metrics reference including the five health_check.* keys.
  • bin/config.toml: groups_list documentation, health check example block.
  • CHANGELOG.md: under the first [Unreleased] heading; ### Added for the new features and ### Changed for the cipher-list constant rename and the proto field renumbering.

Adaptations vs the original PR #1191 commit set (rebase onto post-1209)

  • Precedence over mutual exclusion: lib/src/crypto.rs resolves multi-provider builds (notably --all-features) deterministically ring > aws-lc-rs > openssl. Mutual-exclusion semantics are preserved at the packaging surface (Dockerfile / RPM / PKGBUILD each pick exactly one).
  • fips = ["crypto-aws-lc-rs", "rustls/fips"] (implies aws-lc-rs, not a fourth mutually-exclusive provider).
  • cipher_suite_by_name filters through the active provider so FIPS builds cannot silently advertise non-FIPS suites.
  • Token allocator uses bounded modulo with active-token collision check and a bounded owns_token upper range, avoiding a false-claim of the GOAWAY sentinel.
  • ANSI version-display gating is at runtime in the --version handler, not in bin/build.rs (which is compile-time only).
  • Router::has_hostname restored — current main has a new caller at lib/src/http.rs:992 that PR feat(tls): crypto provider selection, health checks, cipher list fix, version display #1191's "unused router cleanup" hadn't anticipated.
  • simd/splice feature forwarding NOT re-added (already present on main).
  • HTTPS ALPN default ["h2", "http/1.1"] preserved (not the original PR feat(tls): crypto provider selection, health checks, cipher list fix, version display #1191's ["http/1.1"]).
  • URI sanitisation tightened to reject \r, \n, NUL, and any C0 control byte individually (RFC 9110 §5.1).

Validation

Local (workstation):

  • cargo build --all-features --locked
  • cargo +nightly fmt --all -- --check
  • cargo clippy --all-targets --all-features --locked — 0 errors, 0 warnings
  • cargo test --workspace --locked — 943 passed, 7 ignored (10 suites, ~330s)
  • cargo test -p sozu-e2e --locked — 328 passed (full e2e suite)
  • cargo test -p sozu-lib --test log_layout — pass (canonical log envelope regression guard)
  • All 21 commits GPG-signed (%G? = G)

CI (GitHub Actions):

  • crypto-ring cell — full e2e suite green (build + sozu-lib unit + ~327-test e2e suite, including the cardinality matrix and h2c parser unit tests). Confirmed on multiple historical runs starting from f2d57260 #25131300420.
  • crypto-aws-lc-rs cell — full e2e suite green on d16dc606 #25143938573.
  • fips cell — full e2e suite green on the same d16dc606 run.
  • crypto-openssl cell — e2e suite green except test_tls_1_2_ecdsa, which rustls-openssl 0.3.x reliably fails with General("OpenSSL error") on the proxy-side TLS 1.2 + ECDSA handshake. The same handshake succeeds for crypto-ring, crypto-aws-lc-rs, and fips on the same e2e setup, so the regression is upstream in rustls-openssl. The test is now #[ignore]d under crypto-openssl only with a detailed pointer; tracked for re-enablement after the next rustls-openssl release.
  • New 8-cell pipeline + dedicated fuzz job — first run on f773b5ea is queued at the time of this update; matrix outcome will be reported when the runners dequeue.

Review-feedback follow-up

After the original 21-commit stack landed, a five-reviewer audit (Claude review / guidelines / simplify / lisa + OpenAI Codex) surfaced 43 findings (0 P0, 12 P1, 17 P2, 14 P3). Nine review-feedback commits address the actionable items on top of the original stack:

SHA Subject Closes
299ad0eb fix(state,server): validate health_check on AddCluster path codex F-001 + review F-001 (CR/LF/NUL/C0 smuggling defence on the AddCluster path: TOML reload, SaveState, LoadState, direct AddCluster)
834617b9 fix(http,https,router): restore has_hostname guard on frontend removal guide F-004 (silent unconditional set_tags(hostname, None) was clearing tags sibling routes still needed; doc comments + 2 unit tests on Router::has_hostname also restored)
e1a7ac66 fix(cli): gate --version ANSI escapes on terminal detection codex F-006 + guide F-002
16455d61 chore(comments,docs): drop review-process leakage; align stale h2c doc comments codex F-007 + guide F-006/F-007 + review F-010
c6ccf9aa fix(crypto): fips takes precedence over other providers (implies aws-lc-rs in FIPS mode) codex F-002 (precedence chain fips > ring > aws-lc-rs > openssl; cargo build --features fips produces a FIPS binary even when default crypto-ring is enabled)
a920eabf fix(backends,health-check): fail-open keeps retry-policy gate; latch warn! once per regime; emit healthy_backends gauge at 0 review F-002 + F-003 + codex F-005
c50af05e docs: drop stale is_h2c option references in health-check docs post-merge cleanup
1c5eb263 refactor(health-check): use loona-hpack and mux::parser for h2c probe simplify F-001 + lisa F-001 + codex F-004 + review F-005 (drops ~150 LOC of hand-rolled HPACK; the probe parser inherits fuzz_hpack_decoder + fuzz_frame_parser coverage; HEADERS+CONTINUATION fragmentation now handled correctly)
2665fd1f fix(cli,docs): tighten --version TTY gate; document piggy-backed bug fixes guide F-002 caveat (drop is_logger_colored() so TTY colour reaches --version); CHANGELOG ### Fixed entries for the silent TLS_V13 typo (guide F-008), the tcp.rs echo loop_read (guide F-009), and the --version ANSI gate itself

In addition, commit caed5108 (the in-PR review fix-up) was rewritten in place as 6e7c91cd to drop the "Cross-model review pass…/Codex finding" framing in favour of durable technical rationale (codex F-007 + guide F-006/F-007). The 23 commits that originally sat on top of caed5108 were replayed unchanged onto the rewritten parent, with new SHAs but identical trees. The two-commit fix(crypto): refuse fips with non-FIPS provider via compile_error! + revert pair from the first attempt at the FIPS precedence finding has been squashed away; the precedence flip lands as a single commit c6ccf9aa.

Re-run after this batch (workstation):

  • cargo build --all-features --locked
  • cargo +nightly fmt --all -- --check
  • cargo clippy --all-targets --all-features --locked -- -D warnings — 0 errors, 0 warnings
  • cargo test --workspace --locked --lib — 924 passed (4 suites, ~351 s)
  • cargo test -p sozu-e2e --locked — 328 passed (2 suites, ~327 s)
  • cargo test -p sozu-lib --test log_layout — pass
  • git grep "Codex finding\|PR #1191's original\|Cross-model review" -- lib/ command/ bin/ CHANGELOG.md — 0 hits
  • All review-feedback commits GPG-signed (%G? = G)

CI on the rewritten tip 2665fd1f is queued; matrix outcome will be reported when the runners dequeue.

Related issues

FlorentinDUBOIS added a commit that referenced this pull request Mar 7, 2026
- CLAUDE.md: replace broken --all-features with --workspace (crypto
  providers are mutually exclusive, --all-features triggers compile_error!)
- https.rs: downgrade unsupported KX group log from error! to warn!
  (graceful degradation is expected behavior, not an error)
- sozu.spec: wire %bcond conditionals into %build section so packagers
  can switch crypto provider with rpmbuild --with crypto_aws_lc_rs
@FlorentinDUBOIS FlorentinDUBOIS self-assigned this Mar 8, 2026
Base automatically changed from chore/update-dependencies to main March 8, 2026 00:16
@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator Author

FTR, it was tested on cleverapps.io :)

@FlorentinDUBOIS FlorentinDUBOIS changed the title feat(tls): add compile-time crypto provider selection for rustls feat(tls): crypto provider selection, health checks, cipher list fix, version display Mar 9, 2026
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the feat/crypto-provider-feature-flags branch from 9ab5b3a to 324831e Compare March 10, 2026 12:05
FlorentinDUBOIS added a commit that referenced this pull request Mar 10, 2026
- CLAUDE.md: replace broken --all-features with --workspace (crypto
  providers are mutually exclusive, --all-features triggers compile_error!)
- https.rs: downgrade unsupported KX group log from error! to warn!
  (graceful degradation is expected behavior, not an error)
- sozu.spec: wire %bcond conditionals into %build section so packagers
  can switch crypto provider with rpmbuild --with crypto_aws_lc_rs
@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator Author

Consolidated Review — 3-Agent Analysis (Code Quality + Guidelines + Simplification)

Verdict

Well-structured PR with clean abstractions. Crypto provider design is excellent. Health check implementation is sound but has gaps. No hard blockers, several important fixes incoming.


P2 — Important (5 issues)

# Issue File
1 Unbounded response_buf growth — malicious backend can OOM health_check.rs:210
2 No fail-open when all backends unhealthy — cluster fully unavailable health_check.rs:291 + backends.rs:157
3 SetHealthCheck handler skips validation — proto bypasses CLI validation server.rs:1002-1007
4 String::leak() undocumented — needs comment cli.rs:65
5 DEFAULT_GROUPS_LIST includes X25519MLKEM768 unsupported by default ring — noisy warn on every startup config.rs:104

P3 — Medium (8 issues)

# Issue File
1 last_check field written but never read — dead field backends.rs:60
2 Backend DOWN logged at error! — should be warn! health_check.rs:267
3 Host header uses IP, not hostname — breaks vhosts health_check.rs:130
4 Cipher name resolution duplicated — extract cipher_suite_by_name() https.rs:679-696
5 Health check cleanup code duplicated server.rs:994-1016
6 kx_group_by_name() allocates provider per call — use LazyLock crypto.rs:85
7 No jitter on health check intervals health_check.rs
8 swap_remove pattern needs comment health_check.rs:223

Architectural

  • Health check sockets not registered with mio Poll — busy-polls O(in_flight) syscalls per loop iteration. Acceptable for small counts but won't scale.
  • No fail-open — when all backends fail health checks, cluster is fully unavailable (ref Amazon's health check paper)

Security

Check Status
CRLF injection ✅ Mitigated (defense-in-depth)
TLS_V13→TlsV12 bug ✅ Fixed
Feature flag exclusivity ✅ Enforced via compile_error!
Server-side config validation ❌ Missing

Positive Highlights

  1. Crypto abstraction is excellent — compile_error! guards, unified re-exports, kx_group_by_name()
  2. TLS_V13 bug fix is a real catch
  3. Health check threshold model prevents flapping correctly
  4. Defense-in-depth URI sanitization at two layers
  5. Strong test coverage — crypto matrix + health check E2E + TLS scheme tests
  6. CLAUDE.md is a valuable project addition

Fixes for all findings are being prepared and will be pushed to this branch.

@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the feat/crypto-provider-feature-flags branch 2 times, most recently from 65f6308 to 3e8d8d6 Compare March 11, 2026 23:53
FlorentinDUBOIS added a commit that referenced this pull request Apr 29, 2026
Add a compile-time crypto provider abstraction for rustls with support
for ring (default), aws-lc-rs, openssl, and a FIPS path that implies
the aws-lc-rs build via `rustls/fips`. Mutually exclusive Cargo
features enforce exactly one provider per build.

Key changes:
- New lib/src/crypto.rs with provider capability detection, cipher
  suite and KX group lookups, LazyLock-cached default provider, and
  compile_error! guards for mutual exclusivity. cipher_suite_by_name
  filters its result through the active provider's
  default_provider().cipher_suites so FIPS builds do not silently
  advertise non-FIPS suites such as ChaCha20-Poly1305 (rustls 0.23
  only reports ServerConfig::fips() == true when every cipher and KX
  group is FIPS-approved).
- Wire groups_list config to rustls key exchange groups with
  per-listener configuration support via ListenerBuilder.
- Add cipher_suite_by_name() to replace inline 9-arm match in https.rs
  and harmonize DEFAULT_CIPHER_LIST (drop the broken
  DEFAULT_CIPHER_SUITES; remove P-521 from default groups; add
  X25519MLKEM768 first-preference for post-quantum).
- Thread any_supported_type through crate::crypto::any_supported_type
  in tls.rs.
- Add post-quantum KX bench (X25519MLKEM768) in
  lib/benches/crypto_provider.rs.
- Add ECDSA test certificates and bench scaffolding.
- Update CI, Docker, and OS packaging for feature flag support.
  Dockerfile is Alpine/musl; cmake added to build deps. crypto-openssl
  on Alpine still requires explicit OpenSSL dev package validation
  (tracked in the rebase plan).
- Add readiness check in bench.py to fail fast on startup errors.
- Fix flaky TCP round_trip test by accumulating reads.

Adaptations vs the original PR #1191 commit (rebase onto post-1209
main):
- fips now implies crypto-aws-lc-rs (not a fourth mutually-exclusive
  provider); rustls-aws-lc-rs is the same provider, FIPS is upstream
  feature toggling.
- cipher_suite_by_name filters through the active provider so
  ChaCha-inclusive defaults do not break FIPS attestation.
- Preserves post-1209 HTTPS ALPN default ["h2", "http/1.1"]; does not
  port the older ["http/1.1"] from PR #1191's branch base.
- bin/build.rs only emits compile-time env vars; runtime ANSI gating
  for `sozu --version` lives in cli.rs and is wired in the next
  commit (feat(health-check)).
- Restores Router::has_hostname (still used by lib/src/http.rs:992 on
  current main) — the cleanup PR #1191 made was based on an older
  main that did not yet have the new caller.
- Does not re-add simd/splice feature forwarding from sozu-lib to
  the binary; main already has them.

Validation:
- cargo build --no-default-features --features crypto-ring: pass
- cargo +nightly fmt --all -- --check: pass
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning in bench file
  (redundant_closure on Criterion bench setup)

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Apr 29, 2026
…d CLI

Add HTTP/1.1 backend health-check probing that runs inside the existing
single-threaded mio event loop. No additional threads, no async runtime.

Key changes:
- New lib/src/health_check.rs (~480 LOC) with HealthChecker, threshold-
  based state machine, jittered intervals, response size cap (4 KB),
  CRLF-sanitised URIs, per-backend in-flight tracking. Sockets are
  registered with mio in a dedicated bounded token namespace
  [HEALTH_CHECK_TOKEN_BASE, HEALTH_CHECK_TOKEN_BASE +
  HEALTH_CHECK_TOKEN_CAPACITY) = [1<<24, 1<<24 + 1<<16) so the upper
  bound never falsely claims the mux GOAWAY sentinel
  Token(usize::MAX). The allocator picks slot offsets modulo the
  capacity and skips offsets matching in-flight checks; if the table
  is full it logs an error and returns None rather than silently
  colliding.
- Fail-open routing in lib/src/load_balancing.rs: when ALL backends
  for a cluster are unhealthy, route to the Normal backends rather
  than returning 503 (Amazon health-check paper recommendation).
- Backend.health::HealthState machine in lib/src/backends.rs with
  consecutive success/failure counters and Up/Down event emission.
- Server event loop integration in lib/src/server.rs: poll the health
  checker each iteration; dispatch ready tokens; pass Registry for
  register/deregister.
- Server-side validation (command/src/request.rs) rejects zero
  interval/timeout/thresholds and bad URIs.
- Proto: HealthCheckConfig (fields 1-6), SetHealthCheck (cluster_id,
  config), QueryHealthChecks (optional cluster_id),
  HealthChecksList (map<cluster, config>) at command/src/command.proto.
- CLI: cluster health-check {set,remove,list} subcommands in
  bin/src/cli.rs with --uri/--interval/--timeout/--healthy-threshold
  /--unhealthy-threshold/--expected-status flags. CLI-side validation
  rejects URIs missing a leading '/' and rejects \r, \n, NUL, and any
  C0 control byte (RFC 9110 §5.1) — not just CR/LF.
- Master dispatch in bin/src/command/requests.rs broadcasts
  state-mutating health-check requests and aggregates worker
  responses on query.
- ConfigState dispatch + persistence in command/src/state.rs.
- Tabular display in command/src/proto/display.rs.
- Metrics health_check.{success,failure,up,down,healthy_backends}.
- Log envelope: every emit in health_check.rs prefixes its format
  string with "{}, log_context!()" so the lib/tests/log_layout.rs
  regression guard recognises the canonical HEALTH-CHECK tag (mirrors
  the hyphenated MUX-H2 / PROXY-RELAY / TLS-RESOLVER convention).

Adaptations vs the original PR #1191 commit (rebase onto post-1209
main):
- Proto field renumbering. Post-1209 main occupies several carriers
  PR #1191 originally used; the rebased commit retargets:
    * Request.set_health_check        47 -> 52
    * Request.remove_health_check     48 -> 53
    * Request.query_health_checks     49 -> 54
    * Cluster.health_check             8 -> 15
    * ResponseContent.health_checks_list 14 -> 15
    * EventKind.HEALTH_CHECK_HEALTHY    5 -> 27
    * EventKind.HEALTH_CHECK_UNHEALTHY  4 -> 28
- Token namespace tightened (bounded modulo allocator + bounded
  owns_token range) to avoid claiming the mux GOAWAY sentinel.
- URI sanitisation hardened to reject every C0 control byte.
- ClusterCmd::HealthCheck variant placed alongside ClusterCmd::H2
  (PR #1191's structure), not nested under ClusterH2Cmd.

Validation:
- cargo build --no-default-features --features crypto-ring: pass
- cargo +nightly fmt --all -- --check: pass
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning (redundant_closure on
  Criterion bench setup, unrelated to this commit).
- cargo build --tests --no-default-features --features crypto-ring:
  pass.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Apr 29, 2026
Extend the e2e suite to cover TLS scheme variants (cert kind × TLS
version) and the full health-check lifecycle introduced in the
preceding feat(health-check) commit.

TLS tests (per-cert-kind, per-TLS-version coverage):
- try_tls_endpoint (regression — preserved from main).
- try_tls_rsa_2048 / try_tls_ecdsa: cert kind × default TLS versions.
- try_tls_1_3_rsa / try_tls_1_3_ecdsa: cert kind × TLS 1.3 only.
- try_tls_1_2_rsa / try_tls_1_2_ecdsa: cert kind × TLS 1.2 only.

The shared `try_tls_with_cert(test_name, cert, key, tls_versions)`
helper drives the matrix; each test names the worker with its cell so
parallel runs don't clobber one another (`provide_port` +
`start_new_worker_owned`).

Health check tests:
- try_health_check_excludes_unhealthy: backend goes down → marked
  unhealthy → traffic routes to the remaining healthy backend.
- try_health_check_recovery: unhealthy backend recovers → marked back
  up after the configured threshold.
- try_health_check_remove: backend removed during active probing
  cleans up cleanly.
- try_health_check_fail_open: ALL backends unhealthy → traffic routes
  to Normal backends (Amazon health-check fail-open pattern).
- try_health_check_invalid_config: zero interval/timeout/threshold,
  CRLF/NUL injection in URI, missing leading '/' all rejected.
- try_health_check_expected_status: configured status code matched
  exactly; mismatched status → unhealthy.

Helpers:
- `default_health_check_config()` for shared test fixtures.
- `poll_until(addr, timeout, predicate)` for reliable settling
  detection.
- `HEALTH_CHECK_SETTLE` / `HEALTH_CHECK_LONG_SETTLE` /
  `HEALTH_CHECK_VERIFY` timing constants tuned to the
  3 s × threshold(2) = 6 s minimum detection window plus margin.

Adaptations vs the original PR #1191 commit (rebase onto post-1209
main):
- Forward `crypto-ring` feature (and `crypto-aws-lc-rs`,
  `crypto-openssl`, `fips`) on `sozu-lib` so the matrix CI job
  exercises the cardinality with each provider.
- Use `Worker::start_new_worker_owned` and `empty_https_config` (the
  post-1209 e2e harness convention) in the parameterised
  `try_tls_with_cert` helper.

Validation:
- cargo build --tests --no-default-features --features crypto-ring:
  pass.
- cargo +nightly fmt --all -- --check: pass.
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning unrelated to this commit.

Cardinality matrix expansion across the four
(frontend H1/H2 × backend H1/H2) cells, plus h2c-backend health-check
documented-limitation coverage, is tracked as a follow-up since it
multiplies test runtime; this commit lands the foundational scheme
and lifecycle coverage.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Apr 29, 2026
…dates

- New doc/health_checks.md (~165 lines): state machine, TOML config,
  CLI commands, fail-open behaviour, metrics, events, design notes.
  Documents the **HTTP/1.1-only probe limitation** for clusters with
  http2 = true (h2c) and lists the three workarounds: co-locate an
  HTTP/1.1 health endpoint, leave health_check unset for h2c-only
  clusters, or wait for HTTP/2 prior-knowledge probe support.
- New doc/metrics.md: short metrics reference for operators.
- Update doc/configure.md with the crypto provider tables, cipher
  suite tables, key exchange groups (including X25519MLKEM768
  post-quantum), the FIPS cipher-filter note (Sōzu refuses to silently
  downgrade an FIPS build by filtering through the active provider's
  supported set), the certificate type table with generation examples,
  and a new health_check section pointing at health_checks.md.
- doc/configure.md preserves the post-1209 ALPN section
  (alpn_protocols default ["h2", "http/1.1"], h2c backend hint).
- Update doc/README.md to surface the new H2 mux internals doc and
  the health checks page side by side.
- doc/getting_started.md: new "Choosing a crypto provider" section
  with build examples per feature, and a health-check quick-start.
- Replace `sozuctl` references with `sozu` throughout, and fix `Sōzu`
  spelling in README.md, RELEASE.md, and doc/README.md.
- CHANGELOG.md: under the FIRST [Unreleased] heading, append:
    Added: compile-time crypto provider selection (#1191) and
           HTTP/1.1 backend health checks with fail-open and CLI.
    Changed: cipher_list constant rename
             (DEFAULT_RUSTLS_CIPHER_LIST -> DEFAULT_CIPHER_LIST,
             TOML key unchanged); P-521 dropped from default
             groups_list.
    Changed: proto field renumbering applied during the rebase onto
             post-1209 main — health-check carriers now occupy
             Request 52/53/54, Cluster 15, ResponseContent 15,
             EventKind 27/28. Operators upgrading from earlier
             PR #1191 builds must rebuild external clients that
             hard-coded the original tags.

Validation:
- All conflict markers cleared from doc/configure.md, doc/README.md,
  RELEASE.md.
- No further `sozuctl` references in doc/ README.md RELEASE.md.
- CHANGELOG.md targets the first `[Unreleased]` heading per the
  project_sozu_changelog_dual_unreleased convention.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Apr 29, 2026
…1191 stack

Cross-model review pass on the 7-commit stack surfaced findings split
across guidelines (build matrix), Codex (validation order, fail-open
correctness, h2c parser strictness), and simplify (validation drift).
Folded back into the stack as a single fix-up so the merge target stays
build/test-clean.

Critical / build matrix
- `cargo build --all-features --locked` no longer fails on the
  multi-provider `compile_error!`. `lib/src/crypto.rs` switches from
  hard mutual exclusion to a precedence chain: `crypto-aws-lc-rs`
  preferred over `crypto-openssl` preferred over `crypto-ring`. The
  `compile_error!` for the empty case stays — at least one provider
  must still be enabled.
- `lib/Cargo.toml` adds `default = ["crypto-ring"]` so
  `cargo {build,test} -p sozu-lib` (no explicit features) compiles
  out of the box. Downstream binaries already override via
  `default-features = false`; CI matrix entries do likewise.
- `e2e/Cargo.toml` exposes `crypto-ring` (default) /
  `crypto-aws-lc-rs` / `crypto-openssl` / `fips` features that
  forward into `sozu-lib`, so `cargo test -p sozu-e2e --features
  crypto-aws-lc-rs --no-default-features` exercises the matrix end
  to end without dragging the ring path along.
- `lib/benches/crypto_provider.rs` drops the redundant closure on
  `b.iter` so `clippy --all-targets --all-features -D warnings`
  passes (Codex / guidelines).

Validation centralisation (defense-in-depth)
- New `sozu_command::config::validate_health_check_config(&cfg)`
  returning `Result<(), &'static str>`. Rejects zero
  interval/timeout/thresholds, missing leading `/`, and any
  CR/LF/NUL/C0 byte in the URI per RFC 9110 §5.1.
- The CLI request builder
  (`bin/src/ctl/request_builder.rs::health_check_command`), the
  worker `SetHealthCheck` handler (`lib/src/server.rs:1435`), and
  the master `ConfigState::set_health_check`
  (`command/src/state.rs:196`) all funnel through it. Off-channel
  paths (TOML reload, third-party clients) can no longer smuggle
  invalid configs through `SaveState`/`LoadState` — Codex flagged
  that the previous order persisted before validating.
- The runtime probe builder no longer silently strips CR/LF
  (`lib/src/health_check.rs::initiate_checks`); the URI was already
  validated at the boundary, the second strip was a defense-in-depth
  divergence between what the operator typed and what hit the wire.

Health-check operational fixes
- `BackendMap::set_health_check_config(_, None)` now resets every
  backend in the cluster to `HealthState::default()`. Previously a
  removal would leave stale `HealthState::Unhealthy` markers in
  place, and `Backend::can_open` would keep skipping the backend
  even though we had stopped probing it. Codex finding.
- The h2c response parser at `lib/src/health_check.rs::decode_h2c_status`
  now also accepts the literal-with-incremental-indexing form
  (`0x48`, RFC 7541 §6.2.1) for `:status`, so a backend replying
  with e.g. `:status: 201` via `0x48 0x03 b'2' b'0' b'1'` is no
  longer marked unhealthy. New unit test
  `h2c_literal_with_incremental_indexing_status_201_matches`.

Documentation
- `CHANGELOG.md` rewrites the health-check "Added" bullet: drops the
  "HTTP/1.1 only" framing (h2c shipped in the same PR), notes
  `is_h2c` opt-in, the centralised `validate_health_check_config`,
  and the `RemoveHealthCheck` reset.
- `doc/health_checks.md` replaces the stale "no fail-open (yet)"
  paragraph with a description of the actual fail-open path; the
  request-flow now mentions both HTTP/1.1 and h2c probes; the
  configuration-parameters table adds an `is_h2c` row.
- `doc/configure.md` updates the backend-health-check section to
  point at the `is_h2c` flag and removes the obsolete
  "HTTP/1.1-only probe limitation" caveat.
- `doc/metrics.md` adds the five `health_check.*` metric rows
  emitted from `lib/src/health_check.rs`.

Validation
- `cargo build --all-features --locked`: pass.
- `cargo +nightly fmt --all -- --check`: pass.
- `cargo clippy --all-targets --all-features --locked`: 0 errors,
  0 warnings.
- `cargo test --workspace --locked`: 943 passed, 7 ignored.
- `cargo test -p sozu-e2e --locked`: 328 passed.
- `cargo test -p sozu-lib --test log_layout`: pass.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the feat/crypto-provider-feature-flags branch from 3e8d8d6 to c6202ac Compare April 29, 2026 19:05
FlorentinDUBOIS added a commit that referenced this pull request Apr 29, 2026
The HTTP/1.1 probe used `address.ip()` for the `Host` header, which
strips the port. RFC 9110 §7.2 requires the `Host` header to carry
the authority component including the port when it differs from the
scheme default. A backend at `192.168.1.1:8080` was being probed
with `Host: 192.168.1.1`, which fails on any backend that virtual-
hosts off the request `Host` header (and is technically wrong even
for non-vhost backends).

Switch to `address` (SocketAddr's `Display`), which formats as
`ip:port` and correctly brackets IPv6 literals.

A per-cluster custom `host` field on `HealthCheckConfig` (so vhost-
aware backends can be probed against a specific virtual host) is
tracked as a follow-up — operators relying on virtual hosts today
should expose a non-vhost health endpoint, the same pattern nginx
and apache document.

Validation
- cargo +nightly fmt --all -- --check: pass.
- cargo clippy --all-targets --all-features --locked: 0 errors,
  0 warnings.
- cargo test -p sozu-lib health_check::: 12 passed.

Closes the P3 review-comment finding "Host header uses IP, not
hostname — breaks vhosts" from PR #1191's consolidated 3-agent
review.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
Add a compile-time crypto provider abstraction for rustls with support
for ring (default), aws-lc-rs, openssl, and a FIPS path that implies
the aws-lc-rs build via `rustls/fips`. Mutually exclusive Cargo
features enforce exactly one provider per build.

Key changes:
- New lib/src/crypto.rs with provider capability detection, cipher
  suite and KX group lookups, LazyLock-cached default provider, and
  compile_error! guards for mutual exclusivity. cipher_suite_by_name
  filters its result through the active provider's
  default_provider().cipher_suites so FIPS builds do not silently
  advertise non-FIPS suites such as ChaCha20-Poly1305 (rustls 0.23
  only reports ServerConfig::fips() == true when every cipher and KX
  group is FIPS-approved).
- Wire groups_list config to rustls key exchange groups with
  per-listener configuration support via ListenerBuilder.
- Add cipher_suite_by_name() to replace inline 9-arm match in https.rs
  and harmonize DEFAULT_CIPHER_LIST (drop the broken
  DEFAULT_CIPHER_SUITES; remove P-521 from default groups; add
  X25519MLKEM768 first-preference for post-quantum).
- Thread any_supported_type through crate::crypto::any_supported_type
  in tls.rs.
- Add post-quantum KX bench (X25519MLKEM768) in
  lib/benches/crypto_provider.rs.
- Add ECDSA test certificates and bench scaffolding.
- Update CI, Docker, and OS packaging for feature flag support.
  Dockerfile is Alpine/musl; cmake added to build deps. crypto-openssl
  on Alpine still requires explicit OpenSSL dev package validation
  (tracked in the rebase plan).
- Add readiness check in bench.py to fail fast on startup errors.
- Fix flaky TCP round_trip test by accumulating reads.

Adaptations vs the original PR #1191 commit (rebase onto post-1209
main):
- fips now implies crypto-aws-lc-rs (not a fourth mutually-exclusive
  provider); rustls-aws-lc-rs is the same provider, FIPS is upstream
  feature toggling.
- cipher_suite_by_name filters through the active provider so
  ChaCha-inclusive defaults do not break FIPS attestation.
- Preserves post-1209 HTTPS ALPN default ["h2", "http/1.1"]; does not
  port the older ["http/1.1"] from PR #1191's branch base.
- bin/build.rs only emits compile-time env vars; runtime ANSI gating
  for `sozu --version` lives in cli.rs and is wired in the next
  commit (feat(health-check)).
- Restores Router::has_hostname (still used by lib/src/http.rs:992 on
  current main) — the cleanup PR #1191 made was based on an older
  main that did not yet have the new caller.
- Does not re-add simd/splice feature forwarding from sozu-lib to
  the binary; main already has them.

Validation:
- cargo build --no-default-features --features crypto-ring: pass
- cargo +nightly fmt --all -- --check: pass
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning in bench file
  (redundant_closure on Criterion bench setup)

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
…d CLI

Add HTTP/1.1 backend health-check probing that runs inside the existing
single-threaded mio event loop. No additional threads, no async runtime.

Key changes:
- New lib/src/health_check.rs (~480 LOC) with HealthChecker, threshold-
  based state machine, jittered intervals, response size cap (4 KB),
  CRLF-sanitised URIs, per-backend in-flight tracking. Sockets are
  registered with mio in a dedicated bounded token namespace
  [HEALTH_CHECK_TOKEN_BASE, HEALTH_CHECK_TOKEN_BASE +
  HEALTH_CHECK_TOKEN_CAPACITY) = [1<<24, 1<<24 + 1<<16) so the upper
  bound never falsely claims the mux GOAWAY sentinel
  Token(usize::MAX). The allocator picks slot offsets modulo the
  capacity and skips offsets matching in-flight checks; if the table
  is full it logs an error and returns None rather than silently
  colliding.
- Fail-open routing in lib/src/load_balancing.rs: when ALL backends
  for a cluster are unhealthy, route to the Normal backends rather
  than returning 503 (Amazon health-check paper recommendation).
- Backend.health::HealthState machine in lib/src/backends.rs with
  consecutive success/failure counters and Up/Down event emission.
- Server event loop integration in lib/src/server.rs: poll the health
  checker each iteration; dispatch ready tokens; pass Registry for
  register/deregister.
- Server-side validation (command/src/request.rs) rejects zero
  interval/timeout/thresholds and bad URIs.
- Proto: HealthCheckConfig (fields 1-6), SetHealthCheck (cluster_id,
  config), QueryHealthChecks (optional cluster_id),
  HealthChecksList (map<cluster, config>) at command/src/command.proto.
- CLI: cluster health-check {set,remove,list} subcommands in
  bin/src/cli.rs with --uri/--interval/--timeout/--healthy-threshold
  /--unhealthy-threshold/--expected-status flags. CLI-side validation
  rejects URIs missing a leading '/' and rejects \r, \n, NUL, and any
  C0 control byte (RFC 9110 §5.1) — not just CR/LF.
- Master dispatch in bin/src/command/requests.rs broadcasts
  state-mutating health-check requests and aggregates worker
  responses on query.
- ConfigState dispatch + persistence in command/src/state.rs.
- Tabular display in command/src/proto/display.rs.
- Metrics health_check.{success,failure,up,down,healthy_backends}.
- Log envelope: every emit in health_check.rs prefixes its format
  string with "{}, log_context!()" so the lib/tests/log_layout.rs
  regression guard recognises the canonical HEALTH-CHECK tag (mirrors
  the hyphenated MUX-H2 / PROXY-RELAY / TLS-RESOLVER convention).

Adaptations vs the original PR #1191 commit (rebase onto post-1209
main):
- Proto field renumbering. Post-1209 main occupies several carriers
  PR #1191 originally used; the rebased commit retargets:
    * Request.set_health_check        47 -> 52
    * Request.remove_health_check     48 -> 53
    * Request.query_health_checks     49 -> 54
    * Cluster.health_check             8 -> 15
    * ResponseContent.health_checks_list 14 -> 15
    * EventKind.HEALTH_CHECK_HEALTHY    5 -> 27
    * EventKind.HEALTH_CHECK_UNHEALTHY  4 -> 28
- Token namespace tightened (bounded modulo allocator + bounded
  owns_token range) to avoid claiming the mux GOAWAY sentinel.
- URI sanitisation hardened to reject every C0 control byte.
- ClusterCmd::HealthCheck variant placed alongside ClusterCmd::H2
  (PR #1191's structure), not nested under ClusterH2Cmd.

Validation:
- cargo build --no-default-features --features crypto-ring: pass
- cargo +nightly fmt --all -- --check: pass
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning (redundant_closure on
  Criterion bench setup, unrelated to this commit).
- cargo build --tests --no-default-features --features crypto-ring:
  pass.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
Extend the e2e suite to cover TLS scheme variants (cert kind × TLS
version) and the full health-check lifecycle introduced in the
preceding feat(health-check) commit.

TLS tests (per-cert-kind, per-TLS-version coverage):
- try_tls_endpoint (regression — preserved from main).
- try_tls_rsa_2048 / try_tls_ecdsa: cert kind × default TLS versions.
- try_tls_1_3_rsa / try_tls_1_3_ecdsa: cert kind × TLS 1.3 only.
- try_tls_1_2_rsa / try_tls_1_2_ecdsa: cert kind × TLS 1.2 only.

The shared `try_tls_with_cert(test_name, cert, key, tls_versions)`
helper drives the matrix; each test names the worker with its cell so
parallel runs don't clobber one another (`provide_port` +
`start_new_worker_owned`).

Health check tests:
- try_health_check_excludes_unhealthy: backend goes down → marked
  unhealthy → traffic routes to the remaining healthy backend.
- try_health_check_recovery: unhealthy backend recovers → marked back
  up after the configured threshold.
- try_health_check_remove: backend removed during active probing
  cleans up cleanly.
- try_health_check_fail_open: ALL backends unhealthy → traffic routes
  to Normal backends (Amazon health-check fail-open pattern).
- try_health_check_invalid_config: zero interval/timeout/threshold,
  CRLF/NUL injection in URI, missing leading '/' all rejected.
- try_health_check_expected_status: configured status code matched
  exactly; mismatched status → unhealthy.

Helpers:
- `default_health_check_config()` for shared test fixtures.
- `poll_until(addr, timeout, predicate)` for reliable settling
  detection.
- `HEALTH_CHECK_SETTLE` / `HEALTH_CHECK_LONG_SETTLE` /
  `HEALTH_CHECK_VERIFY` timing constants tuned to the
  3 s × threshold(2) = 6 s minimum detection window plus margin.

Adaptations vs the original PR #1191 commit (rebase onto post-1209
main):
- Forward `crypto-ring` feature (and `crypto-aws-lc-rs`,
  `crypto-openssl`, `fips`) on `sozu-lib` so the matrix CI job
  exercises the cardinality with each provider.
- Use `Worker::start_new_worker_owned` and `empty_https_config` (the
  post-1209 e2e harness convention) in the parameterised
  `try_tls_with_cert` helper.

Validation:
- cargo build --tests --no-default-features --features crypto-ring:
  pass.
- cargo +nightly fmt --all -- --check: pass.
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning unrelated to this commit.

Cardinality matrix expansion across the four
(frontend H1/H2 × backend H1/H2) cells, plus h2c-backend health-check
documented-limitation coverage, is tracked as a follow-up since it
multiplies test runtime; this commit lands the foundational scheme
and lifecycle coverage.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
…dates

- New doc/health_checks.md (~165 lines): state machine, TOML config,
  CLI commands, fail-open behaviour, metrics, events, design notes.
  Documents the **HTTP/1.1-only probe limitation** for clusters with
  http2 = true (h2c) and lists the three workarounds: co-locate an
  HTTP/1.1 health endpoint, leave health_check unset for h2c-only
  clusters, or wait for HTTP/2 prior-knowledge probe support.
- New doc/metrics.md: short metrics reference for operators.
- Update doc/configure.md with the crypto provider tables, cipher
  suite tables, key exchange groups (including X25519MLKEM768
  post-quantum), the FIPS cipher-filter note (Sōzu refuses to silently
  downgrade an FIPS build by filtering through the active provider's
  supported set), the certificate type table with generation examples,
  and a new health_check section pointing at health_checks.md.
- doc/configure.md preserves the post-1209 ALPN section
  (alpn_protocols default ["h2", "http/1.1"], h2c backend hint).
- Update doc/README.md to surface the new H2 mux internals doc and
  the health checks page side by side.
- doc/getting_started.md: new "Choosing a crypto provider" section
  with build examples per feature, and a health-check quick-start.
- Replace `sozuctl` references with `sozu` throughout, and fix `Sōzu`
  spelling in README.md, RELEASE.md, and doc/README.md.
- CHANGELOG.md: under the FIRST [Unreleased] heading, append:
    Added: compile-time crypto provider selection (#1191) and
           HTTP/1.1 backend health checks with fail-open and CLI.
    Changed: cipher_list constant rename
             (DEFAULT_RUSTLS_CIPHER_LIST -> DEFAULT_CIPHER_LIST,
             TOML key unchanged); P-521 dropped from default
             groups_list.
    Changed: proto field renumbering applied during the rebase onto
             post-1209 main — health-check carriers now occupy
             Request 52/53/54, Cluster 15, ResponseContent 15,
             EventKind 27/28. Operators upgrading from earlier
             PR #1191 builds must rebuild external clients that
             hard-coded the original tags.

Validation:
- All conflict markers cleared from doc/configure.md, doc/README.md,
  RELEASE.md.
- No further `sozuctl` references in doc/ README.md RELEASE.md.
- CHANGELOG.md targets the first `[Unreleased]` heading per the
  project_sozu_changelog_dual_unreleased convention.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
Add 6 new e2e tests covering the (frontend H1/H2 × backend H1/H2)
cardinality cells that the post-1209 mux exposes, parameterised over
RSA-2048 and ECDSA-P256 certificates. The H1/H1 cell is already
covered by `test_tls_rsa_2048` / `test_tls_ecdsa`.

New tests:
- test_tls_cardinality_h1_h2_rsa
- test_tls_cardinality_h1_h2_ecdsa
- test_tls_cardinality_h2_h1_rsa
- test_tls_cardinality_h2_h1_ecdsa
- test_tls_cardinality_h2_h2_rsa
- test_tls_cardinality_h2_h2_ecdsa

Each test drives `try_tls_cardinality_cell(name, cert, key, versions,
frontend_h2, backend_h2)`. The helper:
- Builds an HTTPS listener and per-cluster certificate.
- Sets `cluster.http2 = backend_h2` so backends-pointing-h2c are
  selected via the mux router.
- Spawns either an `H2Backend` mock (h2c) or an `AsyncBackend` running
  the existing HTTP/1.1 handler, with a 100 ms bind delay for h2c.
- Picks the Hyper client to negotiate frontend ALPN: `build_h2_client`
  for H2 frontends, `build_https_client` for H1 frontends.
- Asserts both a successful response status and at least one request
  reaching the backend (catches ALPN-mismatch silent failures).

The TLS version is left at the listener default (rustls negotiates
1.3 first, falls back to 1.2). Per-version expansion (TLS 1.2 × 1.3
matrix) is not in this commit; the existing `test_tls_1_3_*` and
`test_tls_1_2_*` already pin the version dimension on H1/H1.

Validation:
- cargo build --tests --no-default-features --features crypto-ring:
  pass.
- cargo +nightly fmt --all -- --check: pass.
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning (redundant_closure on
  Criterion bench setup, unrelated).

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
Add an opt-in HTTP/2 prior-knowledge (cleartext, h2c) probe path so
operators can health-check backends configured with `cluster.http2 =
true` without co-locating an HTTP/1.1 endpoint.

Wire / API surface:
- `HealthCheckConfig.is_h2c` (proto field 7, optional bool, default
  false). The TOML key on `[clusters.<id>.health_check]` and the
  `FileHealthCheckConfig` struct gain a matching field.
- `sozu cluster health-check set --h2c` flag forwards the bool through
  the request-builder validator.

Probe wire:
- 24-byte connection preface `PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n`.
- Empty client SETTINGS frame (0-byte payload, type 0x04, flags 0,
  stream 0).
- HEADERS frame on stream 1 with END_STREAM | END_HEADERS (flags
  0x05) carrying a hand-rolled HPACK header block:
    * `:method GET` indexed (static idx 2 → 0x82).
    * `:scheme http` indexed (static idx 6 → 0x86).
    * `:path <uri>` literal w/o indexing, name idx 4 (0x04).
    * `:authority <host:port>` literal w/o indexing, name idx 1
      (0x01).
  Length octets use the HPACK 7-bit-prefix integer form, including
  the multi-byte continuation chain for values > 127 bytes.

Response parser (`try_parse_h2c_status`):
- Walks frames in the buffered response, ignoring SETTINGS, SETTINGS
  ACK, DATA, etc. until it finds a HEADERS frame on stream 1.
- Strips PADDED and PRIORITY prefixes correctly.
- Decodes `:status` from either:
    * Static-table indexed forms 0x88..0x8E (200, 204, 206, 304, 400,
      404, 500), or
    * Literal-with-indexed-name forms 0x08 / 0x18 (literal w/o
      indexing or never-indexed for name index 8) followed by
      length + 3-byte ASCII status code.
- A GOAWAY frame is treated as a probe failure.
- Returns `None` while the buffer is truncated mid-frame so the
  caller keeps reading.

Dispatch in `progress_checks`: a single `parse_probe_response` helper
chooses HTTP/1.1 status-line parsing or h2c frame walking based on
`config.is_h2c`. The HTTP/1.1 path is unchanged.

Tests (in `lib/src/health_check.rs::tests`):
- `build_h2c_probe_starts_with_preface_and_settings`
- `h2c_indexed_status_200_is_healthy_for_any_2xx`
- `h2c_indexed_status_500_fails_default_2xx_check`
- `h2c_literal_status_503_matches_expected_503`
- `h2c_goaway_marks_unhealthy`
- `h2c_truncated_buffer_returns_none`
- `h2c_padded_headers_strips_pad_length_octet`

Documentation: `doc/health_checks.md` updates the "HTTP/1.1 only" note
to describe the new `is_h2c` opt-in, the wire shape, and the parser
coverage. HTTPS (h2 over TLS) probes remain a follow-up.

Validation:
- cargo build --no-default-features --features crypto-ring: pass.
- cargo +nightly fmt --all -- --check: pass.
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning unrelated.
- cargo test -p sozu-lib --no-default-features --features crypto-ring
  health_check::: 11 passed (5 prior + 6 new h2c).

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
The `fuzz/` crate is intentionally out-of-workspace, so it does not
inherit the workspace's default crypto provider. Without an explicit
forwarding the `compile_error!` mutual-exclusion guard in
`lib/src/crypto.rs` fires when the fuzz harness builds, breaking
both `fuzz_frame_parser` and `fuzz_hpack_decoder` smoke tests in
`e2e/src/tests/fuzz_tests.rs`.

Pin `default-features = false` and forward `crypto-ring` so the fuzz
harness builds against a deterministic crypto provider. The fuzz
targets exercise the H2 frame parser and HPACK decoder — neither
reaches the rustls crypto path — so the choice is purely a build
artefact, but it has to be unambiguous for `compile_error!` to stay
silent.

Validation:
- cargo test -p sozu-e2e --locked tests::fuzz_tests::: 2 passed.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Apr 30, 2026
…1191 stack

Cross-model review pass on the 7-commit stack surfaced findings split
across guidelines (build matrix), Codex (validation order, fail-open
correctness, h2c parser strictness), and simplify (validation drift).
Folded back into the stack as a single fix-up so the merge target stays
build/test-clean.

Critical / build matrix
- `cargo build --all-features --locked` no longer fails on the
  multi-provider `compile_error!`. `lib/src/crypto.rs` switches from
  hard mutual exclusion to a precedence chain: `crypto-aws-lc-rs`
  preferred over `crypto-openssl` preferred over `crypto-ring`. The
  `compile_error!` for the empty case stays — at least one provider
  must still be enabled.
- `lib/Cargo.toml` adds `default = ["crypto-ring"]` so
  `cargo {build,test} -p sozu-lib` (no explicit features) compiles
  out of the box. Downstream binaries already override via
  `default-features = false`; CI matrix entries do likewise.
- `e2e/Cargo.toml` exposes `crypto-ring` (default) /
  `crypto-aws-lc-rs` / `crypto-openssl` / `fips` features that
  forward into `sozu-lib`, so `cargo test -p sozu-e2e --features
  crypto-aws-lc-rs --no-default-features` exercises the matrix end
  to end without dragging the ring path along.
- `lib/benches/crypto_provider.rs` drops the redundant closure on
  `b.iter` so `clippy --all-targets --all-features -D warnings`
  passes (Codex / guidelines).

Validation centralisation (defense-in-depth)
- New `sozu_command::config::validate_health_check_config(&cfg)`
  returning `Result<(), &'static str>`. Rejects zero
  interval/timeout/thresholds, missing leading `/`, and any
  CR/LF/NUL/C0 byte in the URI per RFC 9110 §5.1.
- The CLI request builder
  (`bin/src/ctl/request_builder.rs::health_check_command`), the
  worker `SetHealthCheck` handler (`lib/src/server.rs:1435`), and
  the master `ConfigState::set_health_check`
  (`command/src/state.rs:196`) all funnel through it. Off-channel
  paths (TOML reload, third-party clients) can no longer smuggle
  invalid configs through `SaveState`/`LoadState` — Codex flagged
  that the previous order persisted before validating.
- The runtime probe builder no longer silently strips CR/LF
  (`lib/src/health_check.rs::initiate_checks`); the URI was already
  validated at the boundary, the second strip was a defense-in-depth
  divergence between what the operator typed and what hit the wire.

Health-check operational fixes
- `BackendMap::set_health_check_config(_, None)` now resets every
  backend in the cluster to `HealthState::default()`. Previously a
  removal would leave stale `HealthState::Unhealthy` markers in
  place, and `Backend::can_open` would keep skipping the backend
  even though we had stopped probing it. Codex finding.
- The h2c response parser at `lib/src/health_check.rs::decode_h2c_status`
  now also accepts the literal-with-incremental-indexing form
  (`0x48`, RFC 7541 §6.2.1) for `:status`, so a backend replying
  with e.g. `:status: 201` via `0x48 0x03 b'2' b'0' b'1'` is no
  longer marked unhealthy. New unit test
  `h2c_literal_with_incremental_indexing_status_201_matches`.

Documentation
- `CHANGELOG.md` rewrites the health-check "Added" bullet: drops the
  "HTTP/1.1 only" framing (h2c shipped in the same PR), notes
  `is_h2c` opt-in, the centralised `validate_health_check_config`,
  and the `RemoveHealthCheck` reset.
- `doc/health_checks.md` replaces the stale "no fail-open (yet)"
  paragraph with a description of the actual fail-open path; the
  request-flow now mentions both HTTP/1.1 and h2c probes; the
  configuration-parameters table adds an `is_h2c` row.
- `doc/configure.md` updates the backend-health-check section to
  point at the `is_h2c` flag and removes the obsolete
  "HTTP/1.1-only probe limitation" caveat.
- `doc/metrics.md` adds the five `health_check.*` metric rows
  emitted from `lib/src/health_check.rs`.

Validation
- `cargo build --all-features --locked`: pass.
- `cargo +nightly fmt --all -- --check`: pass.
- `cargo clippy --all-targets --all-features --locked`: 0 errors,
  0 warnings.
- `cargo test --workspace --locked`: 943 passed, 7 ignored.
- `cargo test -p sozu-e2e --locked`: 328 passed.
- `cargo test -p sozu-lib --test log_layout`: pass.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Apr 30, 2026
The HTTP/1.1 probe used `address.ip()` for the `Host` header, which
strips the port. RFC 9110 §7.2 requires the `Host` header to carry
the authority component including the port when it differs from the
scheme default. A backend at `192.168.1.1:8080` was being probed
with `Host: 192.168.1.1`, which fails on any backend that virtual-
hosts off the request `Host` header (and is technically wrong even
for non-vhost backends).

Switch to `address` (SocketAddr's `Display`), which formats as
`ip:port` and correctly brackets IPv6 literals.

A per-cluster custom `host` field on `HealthCheckConfig` (so vhost-
aware backends can be probed against a specific virtual host) is
tracked as a follow-up — operators relying on virtual hosts today
should expose a non-vhost health endpoint, the same pattern nginx
and apache document.

Validation
- cargo +nightly fmt --all -- --check: pass.
- cargo clippy --all-targets --all-features --locked: 0 errors,
  0 warnings.
- cargo test -p sozu-lib health_check::: 12 passed.

Closes the P3 review-comment finding "Host header uses IP, not
hostname — breaks vhosts" from PR #1191's consolidated 3-agent
review.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
The --version handler in parse_args wrapped the +/- feature-flag indicators
in \x1b[32m / \x1b[31m unconditionally. Redirected output (sozu --version
to file, package-metadata capture, systemd journal) contained raw escape
codes.

Apply IsTerminal::is_terminal(&stdout()) (and is_logger_colored() when
available) so colour is emitted only on a TTY.

Signed-off-by: Florentin Dubois <[email protected]>
…c comments

Inline comments and the proto file referenced PR numbers and 'Codex finding'
from the cross-model review pipeline. Replace each with durable technical
rationale so the committed text stands on its own merit and ages with the
code rather than the review log.

Also realign the doc comments on FileClusterConfig.health_check and
HttpClusterConfig.health_check that still claimed HTTP/1.1-only probes —
this PR adds h2c support, the proto already documents
'probe wire follows cluster.http2', the Rust-side config doc comments
should match.

Signed-off-by: Florentin Dubois <[email protected]>
…lc-rs in FIPS mode)

Previously the cfg arms in lib/src/crypto.rs gated providers as
ring > aws-lc-rs > openssl, which meant cargo build --features fips
left the default crypto-ring active and the precedence chain picked
ring even though the binary advertised +fips in --version. The result:
a non-FIPS provider in a binary the operator believed was FIPS-validated.

Reorder the chain so fips > ring > aws-lc-rs > openssl. fips already
implies crypto-aws-lc-rs and rustls/fips, so when fips is enabled the
resulting binary always links aws-lc-rs in FIPS 140-3 mode regardless
of which other provider features are simultaneously enabled by default
or by --all-features.

Update the lib/src/crypto.rs module doc-comment, the lib/Cargo.toml
feature-block comments, and the CHANGELOG bullet so they accurately
describe the new precedence chain.

Signed-off-by: Florentin Dubois <[email protected]>
…warn! once per regime; emit healthy_backends gauge at 0

Three connected fixes on the fail-open routing path:

1. fail-open filter no longer drops retry_policy.can_try(): backends in
   exponential back-off were being hammered at line rate during their
   back-off window, which is exactly the failure they are protecting
   against.

2. The fail-open warn! now latches once per cluster-regime transition.
   Previously it fired on every routing decision, and under universal
   outage that meant thousands of identical lines per worker per second.
   Pair the latched warn! with a count!('backends.fail_open', 1) counter
   so operators retain a quantitative signal that does not drown logs.

3. health_check.healthy_backends gauge now emits on every result update,
   including when healthy == 0. Previously the gauge only updated when
   healthy > 0, so dashboards retained stale values during fail-open and
   the documented signal was effectively unobservable.

Also folds a small rustfmt fixup in lib/src/server.rs that the formatter
flagged on the AddCluster validation block.

Signed-off-by: Florentin Dubois <[email protected]>
The PR derives the probe wire format from `cluster.http2` and never
exposed an `is_h2c` knob. doc/configure.md still mentioned an
"opt-in is_h2c = true flag" and a TOML example with
`# is_h2c = true   # uncomment for h2c backends`; doc/health_checks.md
still framed h2c support around "there is no separate is_h2c knob".

Trim the stale option references and describe the current behaviour
in positive terms — the wire format follows cluster.http2, end of
story. Also drop the implementation-detail listing of static-table
indexes and HPACK literal forms in the wire-format paragraph;
those bytes are not user-visible configuration.

Signed-off-by: Florentin Dubois <[email protected]>
The hand-rolled HPACK encoder/decoder + manual H2 frame walker in
lib/src/health_check.rs reimplemented behaviour the workspace already
has. Replace it with loona_hpack::Encoder / loona_hpack::Decoder for
header coding (already used by lib/src/protocol/mux/pkawa.rs) and
mux::parser::frame_header / FLAG_PADDED / FLAG_PRIORITY /
FLAG_END_HEADERS / FrameType for frame walking. Use
mux::serializer::H2_PRI for the connection preface.

Side effects:

- The probe parser now handles HEADERS + CONTINUATION fragmentation
  correctly. The hand-rolled walker decoded only the first HEADERS
  frame's payload and returned 'unhealthy' on any END_HEADERS == 0
  case, marking compliant H2 backends unhealthy.

- The eager byte-walk that returned :status 200 on accidental 0x48
  trap bytes (parser-differential finding) is gone — loona_hpack
  decodes complete HPACK blocks correctly and only fields actually
  named :status contribute.

- The probe path inherits the existing fuzz_hpack_decoder and
  fuzz_frame_parser coverage instead of sitting outside it.

Drop the local constants H2_FRAME_TYPE_*, H2_FLAG_*, H2_FRAME_HEADER_LEN,
PREFACE, and the helpers encode_hpack_length / decode_hpack_length. Drop
the unit tests pinned to the byte-walk decoder behaviour and add tests
that build realistic HEADERS payloads with loona_hpack::Encoder.

mux::serializer is exposed as pub(crate) so health_check.rs can reuse
H2_PRI without copying the byte string.

Signed-off-by: Florentin Dubois <[email protected]>
…fixes

Two follow-ups from the multi-reviewer audit of PR #1191:

1. --version ANSI gate: drop the is_logger_colored() conjunct from
   bin/src/cli.rs::parse_args. The logger is initialised after argument
   parsing, so the thread-local LOGGER_COLORED is always false during
   --version handling. With the AND gate, colour was unreachable even on
   an interactive terminal. The IsTerminal::is_terminal(&stdout()) check
   alone keeps the redirected-output path raw ASCII while letting an
   interactive TTY render the +/- feature-flag indicators in green/red.

2. CHANGELOG: add ### Fixed entries for the silent piggy-backed bugs the
   PR shipped without documenting (TLS_V13 → TlsV12 typo in
   bin/src/cli.rs, single-read flake in lib/src/tcp.rs echo test, and
   the now-actually-true --version TTY gate).

   Also refresh the existing health-check ### Added entry to drop the
   stale 'no separate is_h2c knob' phrasing and the byte-walk
   implementation details — the probe parser now uses
   loona_hpack::Decoder so the static-table indexes / literal forms
   are no longer user-visible. Cite lib/src/backends.rs as the actual
   home of fail-open routing (the entry previously pointed at
   lib/src/load_balancing.rs by mistake).

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the feat/crypto-provider-feature-flags branch from a98ecb0 to 2665fd1 Compare April 30, 2026 15:14
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 6260f85 into main Apr 30, 2026
25 of 26 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the feat/crypto-provider-feature-flags branch April 30, 2026 15:50
FlorentinDUBOIS added a commit that referenced this pull request May 2, 2026
…uide

Five fixups in one pass:

1. **Move `doc/upgrade/1.x-to-2.0.md` to its intended path.** A prior
   commit accidentally landed it under
   `.claude/worktrees/docs-migration-1x-to-2.0/doc/upgrade/1.x-to-2.0.md`
   (a global gitignore on `.claude/` plus a relative-path resolution
   confusion in `git worktree add`). The file is now at
   `doc/upgrade/1.x-to-2.0.md` where it can actually be opened by
   operators following the link from the CHANGELOG breaking-changes
   paragraph.

2. **Drop the "Proto field renumbering for health-check carriers"
   line from the CHANGELOG breaking-changes paragraph.** Those tag
   numbers only existed on the unreleased PR #1191 development
   branch; they are not on any released 1.x tag, so the renumber is
   internal to the development line, not a 1.1.x → 2.0.0 break for
   operators consuming a release binary. The CHANGELOG body still
   carries the same fact in the "Changed" subsection where it
   correctly describes the renumber as affecting operators upgrading
   from PR #1191 development builds, not from a 1.x release.

3. **Drop CleverCloud-affiliated project name references** from the
   docs added in this branch (`doc/upgrade/1.x-to-2.0.md`,
   `doc/protocol.md`, `e2e/COVERAGE.md`). The protocol document
   previously listed example client crates by name; it now describes
   the protocol generically and points to `sozu-command-lib` as the
   canonical Rust API surface (which is in-tree, not a separate
   project). Pre-existing references in the historical CHANGELOG
   release entries are left as-is — those are released, immutable
   text.

4. **Drop "week N" / version-specific roadmap labels and internal
   plan-section references** from the same docs. The migration guide
   no longer prefaces the roadmap as "v2.1.0" / "v2.2.0" / "v3.0.0";
   each row reads "follow-up release" or "future" with the issue
   reference for tracking. `e2e/COVERAGE.md` now describes the
   priority-1 backfill list as "follow-up commit" instead of "Week 2
   deliverable" and refers to the in-repo CI workflow file directly.
   `doc/protocol.md` no longer references the internal plan file
   `tasks/todo.md` or its section identifiers.

5. **Add `opentelemetry` and `simd` feature pass-throughs to
   `e2e/Cargo.toml`.** The CI matrix expansion in commit b414da8
   started passing `--features <crypto>,opentelemetry,splice,simd`
   to every `cargo test -p sozu-e2e` invocation, but
   `sozu-e2e/Cargo.toml` only declared `splice` and the crypto
   features. Cargo failed fast with "Package `sozu-e2e` does not
   have feature `opentelemetry`" before any test ran. The two
   pass-throughs forward to `sozu-lib` (where the features actually
   take effect); the e2e suite itself does not observe behaviour
   differences. Verified locally with
   `cargo build -p sozu-e2e --no-default-features
   --features crypto-ring,opentelemetry,splice,simd --locked`.

The build / clippy / unit-test gates remain clean. The CI matrix
should now pass on the four crypto cells + the MSRV cell + the
default-features baseline.

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request May 2, 2026
…uide

Five fixups in one pass:

1. **Move `doc/upgrade/1.x-to-2.0.md` to its intended path.** A prior
   commit accidentally landed it under
   `.claude/worktrees/docs-migration-1x-to-2.0/doc/upgrade/1.x-to-2.0.md`
   (a global gitignore on `.claude/` plus a relative-path resolution
   confusion in `git worktree add`). The file is now at
   `doc/upgrade/1.x-to-2.0.md` where it can actually be opened by
   operators following the link from the CHANGELOG breaking-changes
   paragraph.

2. **Drop the "Proto field renumbering for health-check carriers"
   line from the CHANGELOG breaking-changes paragraph.** Those tag
   numbers only existed on the unreleased PR #1191 development
   branch; they are not on any released 1.x tag, so the renumber is
   internal to the development line, not a 1.1.x → 2.0.0 break for
   operators consuming a release binary. The CHANGELOG body still
   carries the same fact in the "Changed" subsection where it
   correctly describes the renumber as affecting operators upgrading
   from PR #1191 development builds, not from a 1.x release.

3. **Drop CleverCloud-affiliated project name references** from the
   docs added in this branch (`doc/upgrade/1.x-to-2.0.md`,
   `doc/protocol.md`, `e2e/COVERAGE.md`). The protocol document
   previously listed example client crates by name; it now describes
   the protocol generically and points to `sozu-command-lib` as the
   canonical Rust API surface (which is in-tree, not a separate
   project). Pre-existing references in the historical CHANGELOG
   release entries are left as-is — those are released, immutable
   text.

4. **Drop "week N" / version-specific roadmap labels and internal
   plan-section references** from the same docs. The migration guide
   no longer prefaces the roadmap as "v2.1.0" / "v2.2.0" / "v3.0.0";
   each row reads "follow-up release" or "future" with the issue
   reference for tracking. `e2e/COVERAGE.md` now describes the
   priority-1 backfill list as "follow-up commit" instead of "Week 2
   deliverable" and refers to the in-repo CI workflow file directly.
   `doc/protocol.md` no longer references the internal plan file
   `tasks/todo.md` or its section identifiers.

5. **Add `opentelemetry` and `simd` feature pass-throughs to
   `e2e/Cargo.toml`.** The CI matrix expansion in commit b414da8
   started passing `--features <crypto>,opentelemetry,splice,simd`
   to every `cargo test -p sozu-e2e` invocation, but
   `sozu-e2e/Cargo.toml` only declared `splice` and the crypto
   features. Cargo failed fast with "Package `sozu-e2e` does not
   have feature `opentelemetry`" before any test ran. The two
   pass-throughs forward to `sozu-lib` (where the features actually
   take effect); the e2e suite itself does not observe behaviour
   differences. Verified locally with
   `cargo build -p sozu-e2e --no-default-features
   --features crypto-ring,opentelemetry,splice,simd --locked`.

The build / clippy / unit-test gates remain clean. The CI matrix
should now pass on the four crypto cells + the MSRV cell + the
default-features baseline.

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request May 2, 2026
The CHANGELOG previously carried three concurrent Unreleased blocks —
`## [Unreleased]` (main-scoped post-1.1.1 fixes from PRs #1162, #1191, #1192,
#1193, #1194, #1196, #1202, #1223), `## feat/answer-templates-rewrite-auth -
Unreleased` (answer templates, URL rewrite, basic auth), and
`## feat/h2-mux - Unreleased` (the H2 multiplexer rewrite from PR #1209). All
three feature stacks are on `main`; the per-branch dividers were release-
engineering staging that no longer reflects current state.

Changes:
- Drop the `## feat/answer-templates-rewrite-auth - Unreleased` and
  `## feat/h2-mux - Unreleased` dividers; their bodies now appear under
  `## [Unreleased]` with provenance markers (`### Added — Answer templates / ...`,
  `### Added — H2 multiplexer (PR #1209)`).
- Promote the breaking changes (proto-tag renumbers, dashboard metric renames,
  `http.errors` labelling, pattern-trie regex anchoring, empty-val del-header
  semantic, sub-16393 `buffer_size` rejection, cipher-list constant rename) to
  a top-level `### Breaking changes (v1.1.x → v2.0.0)` paragraph at the top of
  the section so operators see them first.
- Drop emoji from top-level subheaders (🌟 → Added, 🔄 → Changed, ⛑️ → Fixed,
  ✍️ → Changed, 📚 → Documentation, 🤖 → CI, ⚠️ → Behaviour-affecting). Per-
  commit-log subsection at depth ≥ 4 keeps minor emoji ornaments where they
  don't conflict with Keep-a-Changelog vocabulary.
- Preserve historical release entries (`## 1.1.1`, `## 1.1.0`, …) verbatim;
  they are released and immutable.

Net effect: a single `## [Unreleased]` block ready for the v2.0.0 release-cut
in §3.4.c of `tasks/todo.md`. Future passes can de-duplicate the multiple
`### Added`/`### Changed`/`### Fixed` sub-blocks into one each per
Keep-a-Changelog strict shape; this commit is the structural collapse only.

Refs: tasks/todo.md §3.1.a; codex M12 amendment (3-way not 2-way collapse).
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request May 2, 2026
…uide

Five fixups in one pass:

1. **Move `doc/upgrade/1.x-to-2.0.md` to its intended path.** A prior
   commit accidentally landed it under
   `.claude/worktrees/docs-migration-1x-to-2.0/doc/upgrade/1.x-to-2.0.md`
   (a global gitignore on `.claude/` plus a relative-path resolution
   confusion in `git worktree add`). The file is now at
   `doc/upgrade/1.x-to-2.0.md` where it can actually be opened by
   operators following the link from the CHANGELOG breaking-changes
   paragraph.

2. **Drop the "Proto field renumbering for health-check carriers"
   line from the CHANGELOG breaking-changes paragraph.** Those tag
   numbers only existed on the unreleased PR #1191 development
   branch; they are not on any released 1.x tag, so the renumber is
   internal to the development line, not a 1.1.x → 2.0.0 break for
   operators consuming a release binary. The CHANGELOG body still
   carries the same fact in the "Changed" subsection where it
   correctly describes the renumber as affecting operators upgrading
   from PR #1191 development builds, not from a 1.x release.

3. **Drop CleverCloud-affiliated project name references** from the
   docs added in this branch (`doc/upgrade/1.x-to-2.0.md`,
   `doc/protocol.md`, `e2e/COVERAGE.md`). The protocol document
   previously listed example client crates by name; it now describes
   the protocol generically and points to `sozu-command-lib` as the
   canonical Rust API surface (which is in-tree, not a separate
   project). Pre-existing references in the historical CHANGELOG
   release entries are left as-is — those are released, immutable
   text.

4. **Drop "week N" / version-specific roadmap labels and internal
   plan-section references** from the same docs. The migration guide
   no longer prefaces the roadmap as "v2.1.0" / "v2.2.0" / "v3.0.0";
   each row reads "follow-up release" or "future" with the issue
   reference for tracking. `e2e/COVERAGE.md` now describes the
   priority-1 backfill list as "follow-up commit" instead of "Week 2
   deliverable" and refers to the in-repo CI workflow file directly.
   `doc/protocol.md` no longer references the internal plan file
   `tasks/todo.md` or its section identifiers.

5. **Add `opentelemetry` and `simd` feature pass-throughs to
   `e2e/Cargo.toml`.** The CI matrix expansion in commit b414da8
   started passing `--features <crypto>,opentelemetry,splice,simd`
   to every `cargo test -p sozu-e2e` invocation, but
   `sozu-e2e/Cargo.toml` only declared `splice` and the crypto
   features. Cargo failed fast with "Package `sozu-e2e` does not
   have feature `opentelemetry`" before any test ran. The two
   pass-throughs forward to `sozu-lib` (where the features actually
   take effect); the e2e suite itself does not observe behaviour
   differences. Verified locally with
   `cargo build -p sozu-e2e --no-default-features
   --features crypto-ring,opentelemetry,splice,simd --locked`.

The build / clippy / unit-test gates remain clean. The CI matrix
should now pass on the four crypto cells + the MSRV cell + the
default-features baseline.

Signed-off-by: Florentin Dubois <[email protected]>
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
Add a compile-time crypto provider abstraction for rustls with support
for ring (default), aws-lc-rs, openssl, and a FIPS path that implies
the aws-lc-rs build via `rustls/fips`. Mutually exclusive Cargo
features enforce exactly one provider per build.

Key changes:
- New lib/src/crypto.rs with provider capability detection, cipher
  suite and KX group lookups, LazyLock-cached default provider, and
  compile_error! guards for mutual exclusivity. cipher_suite_by_name
  filters its result through the active provider's
  default_provider().cipher_suites so FIPS builds do not silently
  advertise non-FIPS suites such as ChaCha20-Poly1305 (rustls 0.23
  only reports ServerConfig::fips() == true when every cipher and KX
  group is FIPS-approved).
- Wire groups_list config to rustls key exchange groups with
  per-listener configuration support via ListenerBuilder.
- Add cipher_suite_by_name() to replace inline 9-arm match in https.rs
  and harmonize DEFAULT_CIPHER_LIST (drop the broken
  DEFAULT_CIPHER_SUITES; remove P-521 from default groups; add
  X25519MLKEM768 first-preference for post-quantum).
- Thread any_supported_type through crate::crypto::any_supported_type
  in tls.rs.
- Add post-quantum KX bench (X25519MLKEM768) in
  lib/benches/crypto_provider.rs.
- Add ECDSA test certificates and bench scaffolding.
- Update CI, Docker, and OS packaging for feature flag support.
  Dockerfile is Alpine/musl; cmake added to build deps. crypto-openssl
  on Alpine still requires explicit OpenSSL dev package validation
  (tracked in the rebase plan).
- Add readiness check in bench.py to fail fast on startup errors.
- Fix flaky TCP round_trip test by accumulating reads.

Adaptations vs the original PR sozu-proxy#1191 commit (rebase onto post-1209
main):
- fips now implies crypto-aws-lc-rs (not a fourth mutually-exclusive
  provider); rustls-aws-lc-rs is the same provider, FIPS is upstream
  feature toggling.
- cipher_suite_by_name filters through the active provider so
  ChaCha-inclusive defaults do not break FIPS attestation.
- Preserves post-1209 HTTPS ALPN default ["h2", "http/1.1"]; does not
  port the older ["http/1.1"] from PR sozu-proxy#1191's branch base.
- bin/build.rs only emits compile-time env vars; runtime ANSI gating
  for `sozu --version` lives in cli.rs and is wired in the next
  commit (feat(health-check)).
- Restores Router::has_hostname (still used by lib/src/http.rs:992 on
  current main) — the cleanup PR sozu-proxy#1191 made was based on an older
  main that did not yet have the new caller.
- Does not re-add simd/splice feature forwarding from sozu-lib to
  the binary; main already has them.

Validation:
- cargo build --no-default-features --features crypto-ring: pass
- cargo +nightly fmt --all -- --check: pass
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning in bench file
  (redundant_closure on Criterion bench setup)

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
…d CLI

Add HTTP/1.1 backend health-check probing that runs inside the existing
single-threaded mio event loop. No additional threads, no async runtime.

Key changes:
- New lib/src/health_check.rs (~480 LOC) with HealthChecker, threshold-
  based state machine, jittered intervals, response size cap (4 KB),
  CRLF-sanitised URIs, per-backend in-flight tracking. Sockets are
  registered with mio in a dedicated bounded token namespace
  [HEALTH_CHECK_TOKEN_BASE, HEALTH_CHECK_TOKEN_BASE +
  HEALTH_CHECK_TOKEN_CAPACITY) = [1<<24, 1<<24 + 1<<16) so the upper
  bound never falsely claims the mux GOAWAY sentinel
  Token(usize::MAX). The allocator picks slot offsets modulo the
  capacity and skips offsets matching in-flight checks; if the table
  is full it logs an error and returns None rather than silently
  colliding.
- Fail-open routing in lib/src/load_balancing.rs: when ALL backends
  for a cluster are unhealthy, route to the Normal backends rather
  than returning 503 (Amazon health-check paper recommendation).
- Backend.health::HealthState machine in lib/src/backends.rs with
  consecutive success/failure counters and Up/Down event emission.
- Server event loop integration in lib/src/server.rs: poll the health
  checker each iteration; dispatch ready tokens; pass Registry for
  register/deregister.
- Server-side validation (command/src/request.rs) rejects zero
  interval/timeout/thresholds and bad URIs.
- Proto: HealthCheckConfig (fields 1-6), SetHealthCheck (cluster_id,
  config), QueryHealthChecks (optional cluster_id),
  HealthChecksList (map<cluster, config>) at command/src/command.proto.
- CLI: cluster health-check {set,remove,list} subcommands in
  bin/src/cli.rs with --uri/--interval/--timeout/--healthy-threshold
  /--unhealthy-threshold/--expected-status flags. CLI-side validation
  rejects URIs missing a leading '/' and rejects \r, \n, NUL, and any
  C0 control byte (RFC 9110 §5.1) — not just CR/LF.
- Master dispatch in bin/src/command/requests.rs broadcasts
  state-mutating health-check requests and aggregates worker
  responses on query.
- ConfigState dispatch + persistence in command/src/state.rs.
- Tabular display in command/src/proto/display.rs.
- Metrics health_check.{success,failure,up,down,healthy_backends}.
- Log envelope: every emit in health_check.rs prefixes its format
  string with "{}, log_context!()" so the lib/tests/log_layout.rs
  regression guard recognises the canonical HEALTH-CHECK tag (mirrors
  the hyphenated MUX-H2 / PROXY-RELAY / TLS-RESOLVER convention).

Adaptations vs the original PR sozu-proxy#1191 commit (rebase onto post-1209
main):
- Proto field renumbering. Post-1209 main occupies several carriers
  PR sozu-proxy#1191 originally used; the rebased commit retargets:
    * Request.set_health_check        47 -> 52
    * Request.remove_health_check     48 -> 53
    * Request.query_health_checks     49 -> 54
    * Cluster.health_check             8 -> 15
    * ResponseContent.health_checks_list 14 -> 15
    * EventKind.HEALTH_CHECK_HEALTHY    5 -> 27
    * EventKind.HEALTH_CHECK_UNHEALTHY  4 -> 28
- Token namespace tightened (bounded modulo allocator + bounded
  owns_token range) to avoid claiming the mux GOAWAY sentinel.
- URI sanitisation hardened to reject every C0 control byte.
- ClusterCmd::HealthCheck variant placed alongside ClusterCmd::H2
  (PR sozu-proxy#1191's structure), not nested under ClusterH2Cmd.

Validation:
- cargo build --no-default-features --features crypto-ring: pass
- cargo +nightly fmt --all -- --check: pass
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning (redundant_closure on
  Criterion bench setup, unrelated to this commit).
- cargo build --tests --no-default-features --features crypto-ring:
  pass.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
Extend the e2e suite to cover TLS scheme variants (cert kind × TLS
version) and the full health-check lifecycle introduced in the
preceding feat(health-check) commit.

TLS tests (per-cert-kind, per-TLS-version coverage):
- try_tls_endpoint (regression — preserved from main).
- try_tls_rsa_2048 / try_tls_ecdsa: cert kind × default TLS versions.
- try_tls_1_3_rsa / try_tls_1_3_ecdsa: cert kind × TLS 1.3 only.
- try_tls_1_2_rsa / try_tls_1_2_ecdsa: cert kind × TLS 1.2 only.

The shared `try_tls_with_cert(test_name, cert, key, tls_versions)`
helper drives the matrix; each test names the worker with its cell so
parallel runs don't clobber one another (`provide_port` +
`start_new_worker_owned`).

Health check tests:
- try_health_check_excludes_unhealthy: backend goes down → marked
  unhealthy → traffic routes to the remaining healthy backend.
- try_health_check_recovery: unhealthy backend recovers → marked back
  up after the configured threshold.
- try_health_check_remove: backend removed during active probing
  cleans up cleanly.
- try_health_check_fail_open: ALL backends unhealthy → traffic routes
  to Normal backends (Amazon health-check fail-open pattern).
- try_health_check_invalid_config: zero interval/timeout/threshold,
  CRLF/NUL injection in URI, missing leading '/' all rejected.
- try_health_check_expected_status: configured status code matched
  exactly; mismatched status → unhealthy.

Helpers:
- `default_health_check_config()` for shared test fixtures.
- `poll_until(addr, timeout, predicate)` for reliable settling
  detection.
- `HEALTH_CHECK_SETTLE` / `HEALTH_CHECK_LONG_SETTLE` /
  `HEALTH_CHECK_VERIFY` timing constants tuned to the
  3 s × threshold(2) = 6 s minimum detection window plus margin.

Adaptations vs the original PR sozu-proxy#1191 commit (rebase onto post-1209
main):
- Forward `crypto-ring` feature (and `crypto-aws-lc-rs`,
  `crypto-openssl`, `fips`) on `sozu-lib` so the matrix CI job
  exercises the cardinality with each provider.
- Use `Worker::start_new_worker_owned` and `empty_https_config` (the
  post-1209 e2e harness convention) in the parameterised
  `try_tls_with_cert` helper.

Validation:
- cargo build --tests --no-default-features --features crypto-ring:
  pass.
- cargo +nightly fmt --all -- --check: pass.
- cargo clippy --all-targets --no-default-features --features
  crypto-ring: 0 errors, 1 cosmetic warning unrelated to this commit.

Cardinality matrix expansion across the four
(frontend H1/H2 × backend H1/H2) cells, plus h2c-backend health-check
documented-limitation coverage, is tracked as a follow-up since it
multiplies test runtime; this commit lands the foundational scheme
and lifecycle coverage.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
…dates

- New doc/health_checks.md (~165 lines): state machine, TOML config,
  CLI commands, fail-open behaviour, metrics, events, design notes.
  Documents the **HTTP/1.1-only probe limitation** for clusters with
  http2 = true (h2c) and lists the three workarounds: co-locate an
  HTTP/1.1 health endpoint, leave health_check unset for h2c-only
  clusters, or wait for HTTP/2 prior-knowledge probe support.
- New doc/metrics.md: short metrics reference for operators.
- Update doc/configure.md with the crypto provider tables, cipher
  suite tables, key exchange groups (including X25519MLKEM768
  post-quantum), the FIPS cipher-filter note (Sōzu refuses to silently
  downgrade an FIPS build by filtering through the active provider's
  supported set), the certificate type table with generation examples,
  and a new health_check section pointing at health_checks.md.
- doc/configure.md preserves the post-1209 ALPN section
  (alpn_protocols default ["h2", "http/1.1"], h2c backend hint).
- Update doc/README.md to surface the new H2 mux internals doc and
  the health checks page side by side.
- doc/getting_started.md: new "Choosing a crypto provider" section
  with build examples per feature, and a health-check quick-start.
- Replace `sozuctl` references with `sozu` throughout, and fix `Sōzu`
  spelling in README.md, RELEASE.md, and doc/README.md.
- CHANGELOG.md: under the FIRST [Unreleased] heading, append:
    Added: compile-time crypto provider selection (sozu-proxy#1191) and
           HTTP/1.1 backend health checks with fail-open and CLI.
    Changed: cipher_list constant rename
             (DEFAULT_RUSTLS_CIPHER_LIST -> DEFAULT_CIPHER_LIST,
             TOML key unchanged); P-521 dropped from default
             groups_list.
    Changed: proto field renumbering applied during the rebase onto
             post-1209 main — health-check carriers now occupy
             Request 52/53/54, Cluster 15, ResponseContent 15,
             EventKind 27/28. Operators upgrading from earlier
             PR sozu-proxy#1191 builds must rebuild external clients that
             hard-coded the original tags.

Validation:
- All conflict markers cleared from doc/configure.md, doc/README.md,
  RELEASE.md.
- No further `sozuctl` references in doc/ README.md RELEASE.md.
- CHANGELOG.md targets the first `[Unreleased]` heading per the
  project_sozu_changelog_dual_unreleased convention.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
…n; h2c literal-name parsing

Several connected fixes to the PR sozu-proxy#1191 stack:

Critical / build matrix
- `cargo build --all-features --locked` no longer fails on a hard
  mutual-exclusion `compile_error!`. `lib/src/crypto.rs` switches to
  a precedence chain (`crypto-aws-lc-rs > crypto-openssl >
  crypto-ring`) so multi-provider builds resolve deterministically.
  The empty-case `compile_error!` stays — at least one provider must
  still be enabled.
- `lib/Cargo.toml` adds `default = ["crypto-ring"]` so
  `cargo {build,test} -p sozu-lib` compiles out of the box.
  Downstream binaries already opt out via
  `default-features = false`; CI matrix entries do likewise.
- `e2e/Cargo.toml` exposes `crypto-ring` (default) /
  `crypto-aws-lc-rs` / `crypto-openssl` / `fips` features that
  forward into `sozu-lib`, so
  `cargo test -p sozu-e2e --features crypto-aws-lc-rs --no-default-features`
  exercises the matrix end-to-end.
- `lib/benches/crypto_provider.rs` drops a redundant closure so
  `clippy --all-targets --all-features -D warnings` passes.

Validation centralisation
- New `sozu_command::config::validate_health_check_config(&cfg)`
  returning `Result<(), &'static str>`. Rejects zero
  interval/timeout/thresholds, missing leading `/`, and any
  CR/LF/NUL/C0 byte in the URI per RFC 9110 §5.1.
- The CLI request builder
  (`bin/src/ctl/request_builder.rs::health_check_command`), the
  worker `SetHealthCheck` handler in `lib/src/server.rs`, and the
  master `ConfigState::set_health_check` in `command/src/state.rs`
  all funnel through it, so off-channel paths (TOML reload,
  third-party clients) cannot smuggle invalid configs through
  `SaveState`/`LoadState`.
- The runtime probe builder no longer silently strips CR/LF: the
  URI is validated at the boundary, the second strip was a
  defence-in-depth divergence between what the operator typed and
  what hit the wire.

Health-check operational fixes
- `BackendMap::set_health_check_config(_, None)` now resets every
  backend in the cluster to `HealthState::default()`. Previously
  removing a health check left stale `HealthState::Unhealthy`
  markers, and `Backend::can_open` kept skipping the backend even
  though probing had stopped.
- The h2c response parser at
  `lib/src/health_check.rs::decode_h2c_status` now also accepts the
  literal-with-incremental-indexing form (`0x48`, RFC 7541 §6.2.1)
  for `:status`, so a backend replying with e.g. `:status: 201`
  via `0x48 0x03 b'2' b'0' b'1'` is no longer marked unhealthy.

Documentation
- `CHANGELOG.md` rewrites the health-check "Added" bullet: drops
  the "HTTP/1.1 only" framing (h2c shipped in the same PR), notes
  the `is_h2c` opt-in, the centralised `validate_health_check_config`,
  and the `RemoveHealthCheck` reset.
- `doc/health_checks.md` replaces the stale "no fail-open (yet)"
  paragraph with a description of the actual fail-open path; the
  request-flow mentions both HTTP/1.1 and h2c probes; the
  configuration-parameters table adds an `is_h2c` row.
- `doc/configure.md` updates the backend-health-check section and
  removes the obsolete "HTTP/1.1-only probe limitation" caveat.
- `doc/metrics.md` adds the five `health_check.*` metric rows
  emitted from `lib/src/health_check.rs`.

Signed-off-by: Florentin Dubois <[email protected]>
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
The HTTP/1.1 probe used `address.ip()` for the `Host` header, which
strips the port. RFC 9110 §7.2 requires the `Host` header to carry
the authority component including the port when it differs from the
scheme default. A backend at `192.168.1.1:8080` was being probed
with `Host: 192.168.1.1`, which fails on any backend that virtual-
hosts off the request `Host` header (and is technically wrong even
for non-vhost backends).

Switch to `address` (SocketAddr's `Display`), which formats as
`ip:port` and correctly brackets IPv6 literals.

A per-cluster custom `host` field on `HealthCheckConfig` (so vhost-
aware backends can be probed against a specific virtual host) is
tracked as a follow-up — operators relying on virtual hosts today
should expose a non-vhost health endpoint, the same pattern nginx
and apache document.

Validation
- cargo +nightly fmt --all -- --check: pass.
- cargo clippy --all-targets --all-features --locked: 0 errors,
  0 warnings.
- cargo test -p sozu-lib health_check::: 12 passed.

Closes the P3 review-comment finding "Host header uses IP, not
hostname — breaks vhosts" from PR sozu-proxy#1191's consolidated 3-agent
review.

Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
…fixes

Two follow-ups from the multi-reviewer audit of PR sozu-proxy#1191:

1. --version ANSI gate: drop the is_logger_colored() conjunct from
   bin/src/cli.rs::parse_args. The logger is initialised after argument
   parsing, so the thread-local LOGGER_COLORED is always false during
   --version handling. With the AND gate, colour was unreachable even on
   an interactive terminal. The IsTerminal::is_terminal(&stdout()) check
   alone keeps the redirected-output path raw ASCII while letting an
   interactive TTY render the +/- feature-flag indicators in green/red.

2. CHANGELOG: add ### Fixed entries for the silent piggy-backed bugs the
   PR shipped without documenting (TLS_V13 → TlsV12 typo in
   bin/src/cli.rs, single-read flake in lib/src/tcp.rs echo test, and
   the now-actually-true --version TTY gate).

   Also refresh the existing health-check ### Added entry to drop the
   stale 'no separate is_h2c knob' phrasing and the byte-walk
   implementation details — the probe parser now uses
   loona_hpack::Decoder so the static-table indexes / literal forms
   are no longer user-visible. Cite lib/src/backends.rs as the actual
   home of fail-open routing (the entry previously pointed at
   lib/src/load_balancing.rs by mistake).

Signed-off-by: Florentin Dubois <[email protected]>
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
…er-feature-flags

feat(tls): crypto provider selection, health checks, cipher list fix, version display
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
The CHANGELOG previously carried three concurrent Unreleased blocks —
`## [Unreleased]` (main-scoped post-1.1.1 fixes from PRs sozu-proxy#1162, sozu-proxy#1191, sozu-proxy#1192,
sozu-proxy#1193, sozu-proxy#1194, sozu-proxy#1196, sozu-proxy#1202, sozu-proxy#1223), `## feat/answer-templates-rewrite-auth -
Unreleased` (answer templates, URL rewrite, basic auth), and
`## feat/h2-mux - Unreleased` (the H2 multiplexer rewrite from PR sozu-proxy#1209). All
three feature stacks are on `main`; the per-branch dividers were release-
engineering staging that no longer reflects current state.

Changes:
- Drop the `## feat/answer-templates-rewrite-auth - Unreleased` and
  `## feat/h2-mux - Unreleased` dividers; their bodies now appear under
  `## [Unreleased]` with provenance markers (`### Added — Answer templates / ...`,
  `### Added — H2 multiplexer (PR sozu-proxy#1209)`).
- Promote the breaking changes (proto-tag renumbers, dashboard metric renames,
  `http.errors` labelling, pattern-trie regex anchoring, empty-val del-header
  semantic, sub-16393 `buffer_size` rejection, cipher-list constant rename) to
  a top-level `### Breaking changes (v1.1.x → v2.0.0)` paragraph at the top of
  the section so operators see them first.
- Drop emoji from top-level subheaders (🌟 → Added, 🔄 → Changed, ⛑️ → Fixed,
  ✍️ → Changed, 📚 → Documentation, 🤖 → CI, ⚠️ → Behaviour-affecting). Per-
  commit-log subsection at depth ≥ 4 keeps minor emoji ornaments where they
  don't conflict with Keep-a-Changelog vocabulary.
- Preserve historical release entries (`## 1.1.1`, `## 1.1.0`, …) verbatim;
  they are released and immutable.

Net effect: a single `## [Unreleased]` block ready for the v2.0.0 release-cut
in §3.4.c of `tasks/todo.md`. Future passes can de-duplicate the multiple
`### Added`/`### Changed`/`### Fixed` sub-blocks into one each per
Keep-a-Changelog strict shape; this commit is the structural collapse only.

Refs: tasks/todo.md §3.1.a; codex M12 amendment (3-way not 2-way collapse).
Signed-off-by: Florentin Dubois <[email protected]>
jrcribb pushed a commit to jrcribb/sozu that referenced this pull request Aug 10, 2026
…uide

Five fixups in one pass:

1. **Move `doc/upgrade/1.x-to-2.0.md` to its intended path.** A prior
   commit accidentally landed it under
   `.claude/worktrees/docs-migration-1x-to-2.0/doc/upgrade/1.x-to-2.0.md`
   (a global gitignore on `.claude/` plus a relative-path resolution
   confusion in `git worktree add`). The file is now at
   `doc/upgrade/1.x-to-2.0.md` where it can actually be opened by
   operators following the link from the CHANGELOG breaking-changes
   paragraph.

2. **Drop the "Proto field renumbering for health-check carriers"
   line from the CHANGELOG breaking-changes paragraph.** Those tag
   numbers only existed on the unreleased PR sozu-proxy#1191 development
   branch; they are not on any released 1.x tag, so the renumber is
   internal to the development line, not a 1.1.x → 2.0.0 break for
   operators consuming a release binary. The CHANGELOG body still
   carries the same fact in the "Changed" subsection where it
   correctly describes the renumber as affecting operators upgrading
   from PR sozu-proxy#1191 development builds, not from a 1.x release.

3. **Drop CleverCloud-affiliated project name references** from the
   docs added in this branch (`doc/upgrade/1.x-to-2.0.md`,
   `doc/protocol.md`, `e2e/COVERAGE.md`). The protocol document
   previously listed example client crates by name; it now describes
   the protocol generically and points to `sozu-command-lib` as the
   canonical Rust API surface (which is in-tree, not a separate
   project). Pre-existing references in the historical CHANGELOG
   release entries are left as-is — those are released, immutable
   text.

4. **Drop "week N" / version-specific roadmap labels and internal
   plan-section references** from the same docs. The migration guide
   no longer prefaces the roadmap as "v2.1.0" / "v2.2.0" / "v3.0.0";
   each row reads "follow-up release" or "future" with the issue
   reference for tracking. `e2e/COVERAGE.md` now describes the
   priority-1 backfill list as "follow-up commit" instead of "Week 2
   deliverable" and refers to the in-repo CI workflow file directly.
   `doc/protocol.md` no longer references the internal plan file
   `tasks/todo.md` or its section identifiers.

5. **Add `opentelemetry` and `simd` feature pass-throughs to
   `e2e/Cargo.toml`.** The CI matrix expansion in commit b414da8
   started passing `--features <crypto>,opentelemetry,splice,simd`
   to every `cargo test -p sozu-e2e` invocation, but
   `sozu-e2e/Cargo.toml` only declared `splice` and the crypto
   features. Cargo failed fast with "Package `sozu-e2e` does not
   have feature `opentelemetry`" before any test ran. The two
   pass-throughs forward to `sozu-lib` (where the features actually
   take effect); the e2e suite itself does not observe behaviour
   differences. Verified locally with
   `cargo build -p sozu-e2e --no-default-features
   --features crypto-ring,opentelemetry,splice,simd --locked`.

The build / clippy / unit-test gates remain clean. The CI matrix
should now pass on the four crypto cells + the MSRV cell + the
default-features baseline.

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.

feat(health-check): implement fail-open when all backends are unhealthy harmonize DEFAULT_CIPHER_LIST and DEFAULT_RUSTLS_CIPHER_LIST

2 participants