From 92ecaabd7c62d029eba239e95cc8a7d2520fe4a9 Mon Sep 17 00:00:00 2001 From: aur-build Date: Fri, 20 Nov 2026 22:13:44 +0000 Subject: tools: the test-surface detector credited four items with callers they lack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An audit found that `internal` — the check deciding whether a test-only item has a real production caller — was crediting non-calls. Four items were sorted into `residue` on false evidence, and each false credit was a different mistake: db::cas_accepted_release a `pub use` continuation line at db/mod.rs:55. Production does this CAS through `cas_accepted_release_in` inside a transaction; the two names differ by three characters. shims::invocations the string "invocations.jsonl", plus a call from `called_with`, which is itself test-support gated. A test-only function cannot be evidence that another function is production-used. sandbox::LocalAgentProvisioner its own struct and impl headers. Production selects `K8sSandboxProvisioner`. sandbox::local_addr `listener.local_addr()` — std's method on a TcpListener, in sibling files. The census treats all of src/sandbox as one module, and a name match cannot tell a receiver's type. All four are gated now. `KataBackend::local_addr` had zero callers in src and zero in tests — `tests/remote_agent.rs` calls `RemoteBackend::local_addr`, a different type — so it is deleted rather than gated. The detector now strips string literals and comments, skips `use` statements including the continuation lines of a brace-delimited block, skips an item's own impl headers, and refuses to count a call made inside a `#[cfg(test)]` module or a `test-support`-gated item. The case a regex cannot resolve is `self.store_dir()` versus `listener.local_addr()`: identical to a name match. Rows whose only evidence is a call in method position are flagged `⚑`, listed in `tools/test-surface-confirmed.json` only after a human read the cited line, and `the_test_surface_is_disposed_of` fails on any unconfirmed one. Four rows are confirmed that way — `config.store_dir`, `http.cookie`, `ops.build_success_rate`, `watch.needs_stage_b`. The table now prints each item's in-module call sites as its own column, because the residue count is the one number this work cannot eliminate and the claim underneath it has to be checkable rather than asserted. Suite: 284 passed, 0 failed. Clippy clean. Release build clean. --- src/sandbox/kata.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/sandbox/kata.rs') diff --git a/src/sandbox/kata.rs b/src/sandbox/kata.rs index 26e9acc..27005bd 100644 --- a/src/sandbox/kata.rs +++ b/src/sandbox/kata.rs @@ -1,7 +1,9 @@ use std::collections::HashMap; use std::io::BufReader; use std::net::{TcpListener, TcpStream}; +#[cfg(feature = "test-support")] use std::path::PathBuf; +#[cfg(feature = "test-support")] use std::process::{Child, Command}; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Arc, Mutex, OnceLock}; @@ -121,17 +123,27 @@ impl Provisioner for K8sSandboxProvisioner { } } +/// Provisions sandboxes by running the local `sandbox-agent` binary. +/// +/// Test-tier only. Production selects `K8sSandboxProvisioner` when the config +/// names an agent-sandbox backend (kata.rs:193); nothing in the crate ever +/// constructs this type. It exists so tests can drive the real agent protocol +/// against the shim binary without a cluster, which is a more valuable test +/// than the absence of one — so it is gated rather than deleted. +#[cfg(feature = "test-support")] pub struct LocalAgentProvisioner { pub bin: PathBuf, children: Mutex>, } +#[cfg(feature = "test-support")] impl LocalAgentProvisioner { pub fn new(bin: impl Into) -> Self { Self { bin: bin.into(), children: Mutex::new(HashMap::new()) } } } +#[cfg(feature = "test-support")] impl Provisioner for LocalAgentProvisioner { fn provision(&self, req: &ProvisionRequest) -> Result<()> { let child = Command::new(&self.bin) @@ -238,18 +250,12 @@ impl KataBackend { }) } - /// NOTE: `KataBackend::reclaim` used to sit here and called nothing but - /// `self.provisioner.reclaim`, which the pool already calls itself at the - /// reaping site. Nothing — not a test — ever called the wrapper, so it is - /// gone rather than gated. The census had credited it to `tests/kata.rs`, - /// where the TTL test implements the *trait's* `reclaim` on a null - /// provisioner: same word, different function. - /// Test-tier in practice — `tests/remote_agent.rs` drives a real agent - /// through it — but it is a plain accessor on a public type, so it is - /// left public rather than gated behind a feature. - pub fn local_addr(&self) -> &str { - &self.addr - } + // NOTE: `KataBackend::reclaim` used to sit here and called nothing but + // `self.provisioner.reclaim`, which the pool already calls itself at the + // reaping site. Nothing — not a test — ever called the wrapper, so it is + // gone rather than gated. The census had credited it to `tests/kata.rs`, + // where the TTL test implements the *trait's* `reclaim` on a null + // provisioner: same word, different function. fn nonce(&self) -> String { let n = self.counter.fetch_add(1, Ordering::SeqCst); -- cgit v1.2.3