From 6394100a93bcc70416f351a6ce59f63b0c56349e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 16:51:06 +0200 Subject: [PATCH] B5: pin the idunn expire verb as the CLI parses and runs it Kills three cargo-mutants survivors: the --requested-by arm, run's dispatch, and expire's own-live-transaction filter. Co-Authored-By: Claude Opus 5.5 --- src/control_plane.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/control_plane.rs b/src/control_plane.rs index 7e4f281..247a752 100644 --- a/src/control_plane.rs +++ b/src/control_plane.rs @@ -18472,6 +18472,47 @@ mod tests { Ok(()) } + /// The `expire` verb as the CLI parses and runs it: the options land + /// where they say, and it finds only a live transaction of its own + /// command. + #[test] + fn idunn_expire_parses_its_options_and_asks_only_about_its_own_live_transaction() + -> Result<()> { + let args = |words: &[&str]| words.iter().map(|word| (*word).to_owned()).collect::>(); + assert_eq!( + parse(args(&["expire", "up-service", "--requested-by", "alice", "--state-store", "/s/c.cc"]).into_iter())?, + Command::Expire { + state_store: PathBuf::from("/s/c.cc"), + command_id: "up-service".into(), + requested_by: "alice".into(), + } + ); + let help = parse(args(&["expire", "up-service", "--help"]).into_iter()).unwrap_err(); + assert!(format!("{help}").contains("idunn expire "), "{help}"); + assert!(parse(args(&["expire", "up-service", "--force"]).into_iter()).is_err()); + assert!(parse(args(&["expire"]).into_iter()).is_err()); + + // The verb runs: a store with nothing live refuses. + let empty = TempDir::new()?; + let store = empty.path().join("control.cc").display().to_string(); + let refused = run(args(&["expire", "up-service", "--state-store", &store]).into_iter()) + .expect_err("expired a command with no transaction"); + assert!(format!("{refused:#}").contains("no live transaction"), "{refused:#}"); + + // A finished transaction of the command is not a live one. + let routed = routed_world(Odin::Unreachable, 1, DeploymentPhase::Fencing, false)?; + routed + .world + .engine + .begin_post_fencing_abort(&resident(&routed.world)?, anyhow!("test"))?; + routed.resume_until_terminal()?; + assert!(resident(&routed.world)?.value.is_terminal(), "the record was archived"); + let refused = expire(&routed.world.state_store, "continuity-service", "operator") + .expect_err("expired a finished transaction"); + assert!(format!("{refused:#}").contains("no live transaction"), "{refused:#}"); + Ok(()) + } + /// Q3 at the deadline, through the Engine. A continuity whose candidate /// was granted a lease and never proved it held it fails as /// `lease-not-adopted`; one whose Ready proved it restarts the admitted