8.2 KiB
WS-H: Phase 5 final-review fixes
| Field | Value |
|---|---|
| Status | Merged |
| Owner | goose |
| Owned files | src/peers/**, src/telemetry/mod.rs, src/main.rs, tests/**, docs/consolidator.md, config.example.toml, README.md |
Log
2026-10-20 Handoff
The review text (loop/final-review.md) is not present in this worktree; the
six items below were taken from the task statement that quotes it. Nothing in
contracts.md was touched and no contract looked wrong.
All items are done, one commit each, dev-level gate green after every commit
(cargo fmt --check, cargo clippy --all-targets -- -D warnings,
cargo test, cargo tree -i openssl empty). No Nix files changed, so no nix
build or VM test was run.
- One token loader, one set of peer helpers (
H: merge token loaders and peer helpers).src/peers/client.rsno longer has a loader: it callssecrets::load_tokenfor every request. The header-validity rule (no CR, LF or NUL, and the value must be a validBearerheader) lives insecrets.rs.secrets::under_credentialscanonicalises both paths and fails closed, so the client's non-canonicalstarts_withis gone withload_token_in. Deny-CIDR parsing (config::deny_networks), the loopback test (config::url_is_loopback), the plain-http rule (plain_http_allowed,plain_http_off_loopback) and its warning wording (warn_plain_http) exist once inconfig.rsand are used by validation, the transport andregistry::reload. Tests:secrets::tokens_that_cannot_be_a_header_value_are_refused,client::a_refused_token_file_sends_nothing(no request reaches the peer),config::deny_networks_rejects_a_bad_cidr_once_for_every_caller,config::loopback_detection_covers_localhost_and_both_families. Deviation: the merged mode check is the stricter union of the two old ones (0o077, message "group or world accessible" instead of the client's "readable"), so a group/world-writable token file stays refused; wording updated insecrets.rsanddocs/consolidator.md. A doubled trailing newline is nowinvalid(it would end the header line) instead of being forwarded with one newline left. denied()canonicalises (H: canonicalise addresses in the deny check).config::deniedcallsIpAddr::to_canonical; config validation and the transport both use it. Tests:config::ipv4_mapped_ipv6_literals_match_the_v4_deny_list(unit) andclient::an_ipv4_mapped_address_is_matched_against_the_v4_deny_list(::ffff:169.254.169.254refused before any connect); both fail if the canonicalisation is removed.- IPv6 deny defaults (
H: deny IPv6 link-local and metadata addresses by default).types::DEFAULT_DENY_CIDRSaddsfe80::/10,::/128andfd00:ec2::254/128; synced inconfig.example.toml,README.md,docs/consolidator.mdandtests/peers_config.rs(PEERS_DEFAULT). Test:config::the_default_deny_list_covers_metadata_in_both_families_but_allows_lans. peer.requestis a client span (H: mark the peer.request span as an OTel client span).otel.kind = "client"on the span, asserted intelemetry::tests::peer_request_span_names_the_peer.- Gauge gating in the docs (
H: correct the peer gauge gating in the docs).docs/consolidator.mdnow namesotel.enabledwithotel.export_unit_metrics(there is nootel.metrics.enabled) and states thatenabled = falsepeers have no series; behaviour was already covered bymetrics_export::tests::disabled_peer_is_not_reported. - Port-stealing flakiness (
H: make the SIGTERM tests immune to a stolen port).tests/tls.rs::try_start_onandtests/integration.rs::sse_stream_then_sigterm_ononly accept a socket that answers as this server (a TLS handshake against the test pair; a200from/healthz) while the child is still running, and report "retry" otherwise;start/the test then retry on a fresh port, up to three times. The SSE exit bound is 10 s. New teststests/tls.rs::a_probed_port_taken_by_someone_else_is_retriedandtests/integration.rs::a_probed_port_taken_by_someone_else_is_retriedfail if the identity check is weakened back to a bareconnect().
2026-10-20 Handoff (review-1)
Every finding in loop/H/review-1.md is answered, one commit each. The full
gate is green after every commit: cargo fmt --check,
cargo clippy --all-targets -- -D warnings, cargo test (run twice; the
SIGTERM tests pass both times), cargo tree -i openssl empty. No Nix files
changed. devenv shell -- dev-test all could not be used in this worktree:
devenv aborts before any command with "To use 'git-hooks', run devenv inputs add git-hooks …" (an environment problem, not a repo change), so the same
cargo commands were run directly.
- Blocking: the SSE SIGTERM test proves identity, not liveness
(
H: prove the SSE test server identity).tests/integration.rsspawns the binary with stderr piped and waits for its ownlistening addr=127.0.0.1:<port>line (spawn_listening/logs_listening, ANSI stripped, the address parsed and compared whole so a neighbouring port cannot match). Only then is the child signalled;sigterm_and_waitnow also refuses to signal a child that has already exited. A port a stranger won makesspawn_listeningreturnNoneand the test retries on a fresh port; the MCPtail_journaltest uses the same helper.healthz_answersis no longer an identity check. New testa_probed_port_held_by_a_lying_squatter_is_retriedstarts a thread that answersHTTP/1.1 200(verified by the test itself) and asserts the helper retries;only_the_childs_own_listening_line_countspins the parser (other port, other address, non-startup line). - Blocking: mode tests for every group/world bit
(
H: pin the token mode check for every group/world bit).secrets::group_or_world_write_and_execute_bits_are_rejected_toocovers 0620, 0602, 0610 and 0601, andtests/peers_config.rs::a_loose_token_fails_startup_and_per_request_checks_alikeasserts thatvalidate_token_readinessandpeers::load_tokengive the same reason, "group or world accessible", for each mode. Both fail with the old0o044mask (checked by reverting the mask locally). - The plain-HTTP warning no longer appears twice
(
H: warn once about plain http). The transport warning and itsplain_warnedset are gone: every peer set is validated before the registry uses it (startup and reload both go throughConfig::load), andplain_http_off_loopback_requires_the_flag_and_warns_when_setnow asserts exactly onecleartextline. The remaining helper isconfig::warn_plain_http_peer, named after the peer it reports. Deviation: the duplicated warning survives only for aPeersConfighanded toPeerRegistry::reloaddirectly, bypassing validation; that is test-only andvalidate_targetstill refuses a plain-http peer without the opt-in. - A FIFO token file cannot block a thread
(
H: never open a token path that is not a regular file).load_token_atcallsstd::fs::metadataand refuses non-files before opening, then opens withO_NONBLOCKto close the window before the open, and reads the mode and length from the open descriptor.a_fifo_is_refused_without_waiting_for_a_writer(mkfifo, load on a thread, 5 s timeout) fails on the previous code with "must not wait on a fifo". a_refused_token_file_sends_nothingcovers the whole loop (H: keep the token listener open for the whole loop). The listener is no longer consumed by a 500 ms accept inside a task: it stays open for the four cases and one boundedaccept()after the loop must time out. Making a case reachable (a 0600 token) fails the test.- The span kind is checked where a backend sees it
(
H: assert the exported peer request span kind). A capturingSpanExporterplusSimpleSpanProcessorexports the span;peer_request_span_is_exported_as_a_client_spanrequiresSpanKind::Client, the namepeer.request, and no exportedotel.kindattribute. It fails if the field is changed toserver.
No contract looked wrong and contracts.md was not touched.