From 410c7f224ad21ce3db53255f87f47604b9ad1083 Mon Sep 17 00:00:00 2001 From: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz> Date: Sun, 26 Jul 2026 17:41:34 -0400 Subject: [PATCH] test(agents): scope the lazy-pool guard to what a line scanner can enforce MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wren's re-review reproduced a live mutant against the previous test: wrapping the env write in a conditional keeps the trimmed line byte-identical, so a scanner that collects individual lines cannot see control flow — 'unconditional' was an overclaim, and my reported killed mutant was wrong (I mutated the expression on the line, not the shape around it). Renamed to spawn_lazy_pool_env_writes_literal_true_once and rewrote the docs to state exactly what it enforces (literal stays "true"; exactly one write site in runtime.rs) and what it deliberately does not (control flow around the write — the compiler-enforced parameter deletion plus review is the defense there). Both claimed mutants verified red at this head: true->false, and a duplicated write site; clean tree green. Co-authored-by: Tyler Longwell Signed-off-by: Tyler Longwell --- .../src-tauri/src/managed_agents/runtime.rs | 7 ++-- .../src/managed_agents/runtime/tests.rs | 32 ++++++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/desktop/src-tauri/src/managed_agents/runtime.rs b/desktop/src-tauri/src/managed_agents/runtime.rs index 7972bb1aa3..43e473fe1b 100644 --- a/desktop/src-tauri/src/managed_agents/runtime.rs +++ b/desktop/src-tauri/src/managed_agents/runtime.rs @@ -542,9 +542,10 @@ pub fn spawn_agent_child( // slow-starting harness (e.g. a gateway-backed adapter at several // seconds per worker) took minutes — and a mention sent in that window // predated the watermark and could be missed permanently. There is - // deliberately no parameter for this: no Desktop flow may spawn eager - // (see the F1 note in restore.rs; `spawn_lazy_pool_env_is_unconditional` - // pins the env contract). + // deliberately no parameter for this: the compiler is the guard — no + // Desktop flow can express an eager spawn (see the F1 note in + // restore.rs; `spawn_lazy_pool_env_writes_literal_true_once` pins the + // literal and single-write-site residue a scanner can catch). command.env("BUZZ_ACP_LAZY_POOL", "true"); command.env("BUZZ_ACP_AGENT_COMMAND", &resolved_agent_command); command.env("BUZZ_ACP_AGENT_ARGS", agent_args.join(",")); diff --git a/desktop/src-tauri/src/managed_agents/runtime/tests.rs b/desktop/src-tauri/src/managed_agents/runtime/tests.rs index 7515d4c8e5..0bb3bb1b38 100644 --- a/desktop/src-tauri/src/managed_agents/runtime/tests.rs +++ b/desktop/src-tauri/src/managed_agents/runtime/tests.rs @@ -1059,17 +1059,24 @@ fn restart_eligible_false_when_non_orphan_has_no_drift() { // initialize the FULL worker pool before connecting to the relay. For a // slow-starting harness that is minutes of startup, and any mention sent // in that window predates the startup watermark and can be missed -// permanently. The fix removed the `lazy` parameter entirely so eager -// spawning is structurally unrepresentable: `spawn_agent_child` writes -// the env var as an unconditional literal. +// permanently. The fix removed the `lazy` parameter entirely from +// `spawn_agent_child` and `start_pair`, so no Desktop caller can choose +// eager — THAT structural deletion is the primary guard, enforced by the +// compiler, not by this test. // -// This test pins that contract at the source level (the function spawns -// a real OS process, so it cannot run under `cargo test`): the env write -// must be the unconditional literal `"true"` — no conditional, no -// parameter, no second write site. If a future change reintroduces an -// eager mode, it must be deliberate enough to rewrite this test. +// This test pins the two residual regressions a line scanner CAN catch +// (the function spawns a real OS process, so the contract can't be +// exercised under `cargo test`): +// 1. the literal flipping to "false" (or any non-"true" value), and +// 2. a second BUZZ_ACP_LAZY_POOL write site appearing in runtime.rs. +// +// Known, accepted limitation: a scanner that trims single lines cannot +// see surrounding control flow — wrapping the write in a conditional +// while keeping the line byte-identical passes this test. Guarding that +// shape needs syntax-aware analysis, which is disproportionate here; +// the parameter deletion plus review is the defense for it. #[test] -fn spawn_lazy_pool_env_is_unconditional() { +fn spawn_lazy_pool_env_writes_literal_true_once() { let source = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/src/managed_agents/runtime.rs" @@ -1082,8 +1089,9 @@ fn spawn_lazy_pool_env_is_unconditional() { assert_eq!( writes, vec![r#"command.env("BUZZ_ACP_LAZY_POOL", "true");"#], - "BUZZ_ACP_LAZY_POOL must be written exactly once, as the \ - unconditional literal \"true\" — all Desktop spawns are lazy. \ - See this test's doc comment before changing." + "BUZZ_ACP_LAZY_POOL must be written exactly once in runtime.rs, \ + with the literal \"true\" — all Desktop spawns are lazy. See \ + this test's doc comment (and its stated limitation) before \ + changing." ); }