diff --git a/plan/phase-5-consolidator/ws-a-config.md b/plan/phase-5-consolidator/ws-a-config.md index 353767d..f4083b2 100644 --- a/plan/phase-5-consolidator/ws-a-config.md +++ b/plan/phase-5-consolidator/ws-a-config.md @@ -81,3 +81,14 @@ Unit tests for validation and loader; a peer-less default config is byte-identic - 2026-10-20 Gate round 1 (`loop/A/gate-2.log`): - Duplication: the `tracing` capture layer both peer test modules used now lives once in `src/peers/testing.rs` as `capture::logged` (test-only, `#[cfg(test)]`), so `config.rs` and `secrets.rs` tests share it instead of each carrying `Capture`/`FieldVisit`. `tests/peers_config.rs` uses one `PeerFixture` (private token file plus the single-`beta` config, with a `scalars` argument for the timeout lines) instead of writing the same TOML three times. - `Cargo.toml`: `ipnet` is the one dependency this workstream adds, and the plan allows it for A2 `deny_cidrs` (see the A2 entry above). No other dependency changed; `cargo tree -i openssl` is still empty. The gate's ownership step flags `Cargo.toml`, which the plan authorises; the file is listed in the shared-file seam for exactly this case. +- 2026-10-19 Review round 2 (`loop/A/review-n.md`): every Blocking and Important item addressed; minors fixed except where noted. Rebased onto `main` (B merged): the only textual conflict was the import list in `src/main.rs` (both sides kept), and `Cargo.toml` gained `ipnet` twice (B's pin `2.11.0` in the dependency block was kept, this workstream's line removed, same lock entry). + - **Blocking 1 (token files read by every subcommand) — fixed by splitting the check.** `peers::config::validate` is structural only (names and uniqueness, the 64 cap, URL rules, deny CIDRs, absolute `token_file`/`ca_file`, timeouts below intervals, the enabled-with-no-peers warning) and never opens a file. `peers::config::validate_tokens` opens the files of the peers this process would contact, `validate_peer_token` does it for one peer, and `Config::validate_token_readiness` exposes the former. `Config::load` calls only the structural part, so `token create|list`, `peer list`, `--print-config` and an unknown-name `peer check` work where the credential is absent. `serve()` runs `validate_token_readiness` before telemetry, the database or the listener; `peer check` runs `validate_peer_token` on the probed peer only. Binary tests: `commands_that_do_not_contact_a_peer_work_without_the_token_file` (print-config, peer list, token create and list with a nonexistent `token_file`), `serve_refuses_to_start_and_names_the_peer_with_the_unreadable_token`, `peer_check_reports_the_missing_token_before_the_missing_transport`. Unit tests `token_file_must_be_absolute_but_is_not_opened_by_structural_checks` and `token_readiness_is_checked_only_for_peers_that_are_contacted`. This also fixes the reload path for free: B's SIGHUP reload goes through `Config::load`, so a rotated or not-yet-installed credential cannot block a reload. + - **Important 2 (byte-identical print-config not tested) — fixed with a committed snapshot.** `tests/peers_config.rs` holds `PRE_PEERS_DEFAULT` (the full pre-peers `--print-config` text) and `PEERS_DEFAULT` (the peer-less `[peers]` table). The default output must equal the two concatenated; a config with a peer must leave everything before `[peers]` byte-identical. Any change to another section now fails and has to be explained. + - **Important 3 (tests that could not fail) — fixed.** The bad-name assertion now matches `must match ^[a-z0-9][a-z0-9_-]{0,31}$` instead of accepting any message containing the input. `list_report` is fed a `token_file` that does not exist, which proves the report renders from config alone (writing a secret and asserting its absence proved nothing, and the duplicated `gamma` assertion is gone). New loader tests: `a_directory_is_not_a_token_file` and `a_symlink_cannot_borrow_the_credentials_directory_exemption` (a link under `$CREDENTIALS_DIRECTORY` to a 0644 file outside it is rejected, because the target's mode decides). + - **Important 4 (A4 overstated API latency) — resolved rather than deferred.** B is merged in this rebase, so `cli::real_transport` now builds `ReqwestTransport` from `[peers]` (limits and deny list included) instead of bailing. `check_once` is B's probe, which times the API request, so `peer check` now really prints classification and latency: `peer_check_binary_probes_a_real_peer_and_prints_latency` asserts `server up (...)`, `api up, auth ok` and a `ms` value against a real loopback server, plus rejected-credential, unreachable-peer and unknown-name binary tests. The earlier log line ("prints the classification and latency") was true of the injection point but not of the binary until now; no B2 obligation is left. `server up` latency is a connect time, so it can read `0 ms`; only the API latency is the probe's measured round trip. + - **Minor 5 (duplicated test helpers, flaky temp names) — fixed.** `peers::testing::TempDir` is now the single scratch-directory fixture (`new(prefix)`, `path`, `write(name, bytes, mode)`, `write_token(contents)`), used by the `config.rs` and `secrets.rs` unit tests and by `tests/peers_config.rs`; the three copies and the ad-hoc temp paths are gone, and the name is `pid + sequence + nanos` with a retry on `AlreadyExists`. + - **Minor 6 (IPv4-mapped literals) — fixed here, not deferred.** `host_ip` canonicalises with `IpAddr::to_canonical`, so `http://[::ffff:169.254.169.254]` is matched against the IPv4 deny list (test `ipv4_mapped_ipv6_literals_match_the_v4_deny_list`); the same canonicalisation makes `[::ffff:127.0.0.1]` count as loopback. Connect-time enforcement stays B5's. + - **Minor 7 (blocking loader) — recorded in WS-B's Log.** `load_token` is unchanged: it is called once at startup and once per API check by B's transport, inside its request deadline. B's transport already reads the file per check; the note asks for `spawn_blocking` or a bounded `tokio::fs` read if that ever moves to a hot path. + - **Minor 8 (host in the plain-http error) — fixed.** The error no longer names the host, matching the warning that deliberately omits the address. + - **One edit outside the owned list, on purpose:** `src/peers/registry.rs` (B's file) had two fixtures with `api_interval_secs = 2` and the default `api_timeout_secs = 5`, which the A2 timeout rule rejects; the reload and SIGHUP tests failed as soon as the branches met. One line, `api_timeout_secs = 1`, added to the reload test's inline TOML; the other test's reload now passes because `Config::load` no longer opens token files. + - **Scope note (for the merger):** wiring `real_transport` in this workstream is the plan's "A4 is wired when B1/B2 land" condition, taken now because B is merged and `cli.rs` is A's file. The seam paragraph in B's Log is updated to point here. diff --git a/plan/phase-5-consolidator/ws-b-registry.md b/plan/phase-5-consolidator/ws-b-registry.md index f38d5f1..97410b7 100644 --- a/plan/phase-5-consolidator/ws-b-registry.md +++ b/plan/phase-5-consolidator/ws-b-registry.md @@ -79,3 +79,9 @@ Responses to `loop/B/review-r.md`; every Blocking and Major item is addressed, M - **Minor 15 (scope).** `src/tls.rs` changes the SIGHUP handler's signature and imports `PeersReloader`; that is the minimum for one handler to reload TLS and peers with independent failures. `main()` changes only the arguments to `serve()`, as logged under B4. The handoff to the C/D/E/F logs still has to be posted by the orchestrator; this worktree does not own those files. - 2026-10-19 verification: `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo test` and `cargo tree -i openssl` (empty) are clean after the round-1 fixes. + +## Round 2 note from WS-A (2026-10-19) + +- **`real_transport()` seam (for `slinuxm peer check`) — consumed by WS-A.** B1/B2 being merged was the condition for wiring A4, and `src/peers/cli.rs` is A's file, so WS-A now builds `ReqwestTransport::new(&config.peers)` there (limits and deny list included) instead of bailing. No change is needed in B's files; the binary test now probes a real loopback server (`tests/peers_config.rs`, `peer_check_binary_probes_a_real_peer_and_prints_latency`). +- **Token reads are blocking (A3 loader).** `peers::secrets::load_token` is synchronous file I/O. Today the only per-check caller is B's transport, which reads inside its request deadline, so a slow read is bounded but still occupies an async worker. If that path gets hotter (many peers, short intervals), move the read to `spawn_blocking` or a size-bounded `tokio::fs` read; the loader stays A's contract. +- **Test fixture fix in this workstream's file.** On the rebase with WS-A, `reloader_rereads_the_peers_block_and_keeps_the_old_set_on_error` failed because its inline `[peers]` used `api_interval_secs = 2` with the default `api_timeout_secs = 5`, which A2's "timeout below interval" rule rejects. WS-A added `api_timeout_secs = 1` to that fixture; the SIGHUP test needed no change once `Config::load` stopped opening token files.