A0: review round 1 peer entry defaults and class strings

This commit is contained in:
ari committed 2026-10-19 20:02:17 -04:00
1 parent 4bfb097be6
commit 0dbaf58c8c
10 files changed
+276 -32

No files matched your search

+13
View File
@@ -48,6 +48,7 @@ Unit tests for validation and loader; a peer-less default config is byte-identic
- A0 merged: C, D, E, B compile against the stubs; post in all their Logs.
- `PeersConfig`/`PeerConfig`, the secrets loader (`Secret`, `load_token(&PeerConfig) -> Result<Secret, PeerError>`) and `config.example.toml` `[peers]` block for B and F.
- The `peer` subcommand for the docs (F4).
- 2026-10-19 (review round 1): `[[peers.peer]]` deserializes with `enabled` defaulting to true and `allow_plain_http` / `ca_file` optional, so the VM entry shape loads. `PeerRegistry::reload` returns `PeerConfigError` (alias of `config::ConfigError`). `class_str` no longer copies a peer's `BadRequest` text into `last_error`.
## Log
@@ -57,3 +58,15 @@ Unit tests for validation and loader; a peer-less default config is byte-identic
- Contract discrepancy: section 3 declares `reload(&self, new: PeersConfig) -> Result<(), PeerConfigError>` but no `PeerConfigError` type exists in the contract or the tree. Implemented as `Result<(), crate::config::ConfigError>` (the existing error for invalid configuration). Please fix the name in contracts.md if that is not the intent.
- `Cargo.toml`: added `url` (needed for the contract's `url::Url` field, already in `Cargo.lock` via reqwest) and `bytes` (contract's `Bytes` body type, already in the lock). `cargo tree -i openssl` still empty.
- Logged in WS-C, WS-D and WS-E: stubs are available, compile against them.
- 2026-10-19 A0 review round 1: addressed `loop/A0/review-1.md`.
- Blocking: `PeerConfig` field defaults. `enabled` defaults to true, `allow_plain_http` to false, and `ca_file` may be omitted (the VM entry lists it as optional; without a default, beta's entry fails the same way `enabled` did). `Config::load` of that shape is `vm_peer_entries_load_when_enabled_and_ca_file_are_omitted` in `tests/peers_config.rs`; a toml parse of the same omission sits next to the type.
- `proxy.rs` module comment now says the allowlist, `..` / encoded-slash rejection and the query allowlist belong in that module and are not implemented yet. REST and MCP still share `proxy::get`.
- `reload` returns `peers::PeerConfigError`, a public alias of `config::ConfigError`. contracts.md already names that type, so it was not edited (not an owned file, and the name there is already the one the review asked the code to match). The earlier log line asking for a contracts.md rename is superseded by this alias.
- `PeerError::class_str` returns the fixed token `bad_request` for `BadRequest`. The peer's message stays only in `peer_error_to_app` (D9). `check_once` stores `class_str()` in `last_error`, covered by `bad_request_last_error_is_a_class_string`.
- `status` and `contains` parse the name and use `BTreeMap::get`; an unparseable name is an unknown peer. `get` parses and compares `PeerName` against `config.peer`. That field stays a `Vec` (serde order, contract section 1), so it is not a second map; a key compare is the lookup `.get` would do.
- `FakeTransport` delay is asserted with a paused clock (`per_peer_isolation_and_delay`). That needs tokio's `test-util` feature, added as a dev-dependency only (`full` does not include it, and `cargo build` does not turn it on). `/api/v1/ping` without a bearer token is 401 on `server::build_router`, and 200 with one (`ping_without_a_token_is_unauthorized`). The handler's exact version assertion stays in `src/api/ping.rs`. `tests/integration.rs` was not edited: it is outside the owned files, and finding 7 allows this test to carry the 401 case.
- `check_once` still leaves API `latency_ms` unset. A comment says the probe that replaces the stub is what measures it for `peer check`.
- For WS-C: when `peers::routes()` is filled, assert `GET /api/v1/peers` is 404 when `state.peers` is `None`. The merge in `api/mod.rs` cannot be observed while `routes()` is empty, so no test was added here.
- Not changed, on purpose:
- `TODO.md` A0 box stays unticked. This round says the merger ticks it, and `TODO.md` is not an owned file. AGENTS.md's definition-of-done item 4 is the merger's step.
- The direct `bytes` dependency stays. The body type in the transport contract is `bytes::Bytes`; axum only re-exports the same crate. Dropping the direct dep would not change the graph, and the 2026-10-19 log already records why it was added.