From 2bf777840af4acd3f265fc1e8d380f0c1881c6cd Mon Sep 17 00:00:00 2001 From: "minimal-foundry[bot]" <327719912+minimal-foundry[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 16:10:43 +0000 Subject: [PATCH 1/2] refactor(minimal): name the CLI's box operations after the box Rename the session-named helpers whose callers all sit in the box verb modules, session.rs and task.rs (destroy_box, destroy_all_boxes, box_delta, box_policy_as_json, attached_box_record and others), and their session parameters to box_name or box_id. Output and wire are unchanged. --- crates/minimal/src/cmd/boxes/attach.rs | 8 +++--- crates/minimal/src/cmd/boxes/create.rs | 2 +- crates/minimal/src/cmd/boxes/lifecycle.rs | 18 +++++++------- crates/minimal/src/cmd/boxes/policy.rs | 30 +++++++++++------------ crates/minimal/src/cmd/boxes/vm_host.rs | 14 +++++------ crates/minimal/src/cmd/session.rs | 22 ++++++++--------- crates/minimal/src/task.rs | 28 ++++++++++----------- 7 files changed, 61 insertions(+), 61 deletions(-) diff --git a/crates/minimal/src/cmd/boxes/attach.rs b/crates/minimal/src/cmd/boxes/attach.rs index 6d70f2ee0e..0336a6fa47 100644 --- a/crates/minimal/src/cmd/boxes/attach.rs +++ b/crates/minimal/src/cmd/boxes/attach.rs @@ -8,7 +8,7 @@ use minimal_client::box_registration::resume_box_row; /// before handing off to the interactive shell. Suppressed under `--no-input` /// and when stderr is not a terminal, so scripted and CI callers — which read /// the session id from stdout — see nothing extra. -pub(crate) fn should_announce_session(global: &GlobalArgs) -> bool { +pub(crate) fn should_announce_box(global: &GlobalArgs) -> bool { !global.no_input && std::io::stderr().is_terminal() } @@ -52,7 +52,7 @@ pub(crate) async fn resolve_attach_target_version_gated( Some(resolved) => { // The operator never chose the VM the way they chose the // session, so tell them which one they're landing in. - if should_announce_session(global) { + if should_announce_box(global) { eprintln!( "Attaching to session {} on VM {}", session_announce_label( @@ -91,7 +91,7 @@ pub(crate) fn resolve_smart_attach( // Unambiguous auto-resolve: the operator never chose this session, // so tell them which one they're landing in. The picker path below // needs no such line — the selection is its own confirmation. - if should_announce_session(global) { + if should_announce_box(global) { eprintln!( "Attaching to session {}{}", session_announce_label(&entry.id, entry.name.as_deref()), @@ -226,7 +226,7 @@ pub(crate) async fn session_via_ssh( // back, and the in-VM daemon's own row check decides the launch. let mut record_unreadable = false; let record = match control_sock_beside(sock).filter(|control| control.exists()) { - Some(_) => match attached_session_record(sock, id).await { + Some(_) => match attached_box_record(sock, id).await { Ok(record) => record, Err(error) => { tracing::warn!( diff --git a/crates/minimal/src/cmd/boxes/create.rs b/crates/minimal/src/cmd/boxes/create.rs index eef46eea4e..e308e8fef5 100644 --- a/crates/minimal/src/cmd/boxes/create.rs +++ b/crates/minimal/src/cmd/boxes/create.rs @@ -1553,7 +1553,7 @@ pub(crate) async fn activate_session( // bare id printed to stdout above is the scripting contract, while this // stderr line tells an interactive operator which session they just // created and are entering. - if should_announce_session(global) { + if should_announce_box(global) { eprintln!( "Created session {}", session_announce_label(&id, config.name.as_deref()) diff --git a/crates/minimal/src/cmd/boxes/lifecycle.rs b/crates/minimal/src/cmd/boxes/lifecycle.rs index 568102dfff..e91bc27491 100644 --- a/crates/minimal/src/cmd/boxes/lifecycle.rs +++ b/crates/minimal/src/cmd/boxes/lifecycle.rs @@ -116,17 +116,17 @@ pub(crate) fn destroy_gate( /// Best-effort fetch of the session's at-risk report for the destroy /// confirm. Any failure — RPC error, timeout, a daemon predating the RPC — /// reads as `None` (unknowable), and the confirm renders without a listing. -pub(crate) async fn session_delta( +pub(crate) async fn box_delta( client: &mut client::Client, id: boxes::SessionId, ) -> Option { /// Client-side ceiling on the fetch. The daemon bounds each of its /// computations at 5 s; this sits just above so a slow-but-healthy /// answer still lands while a wedged daemon cannot stall the confirm. - const SESSION_DELTA_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(6); + const BOX_DELTA_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(6); use minimald_rpc::{SessionDelta, SessionDeltaRequest}; tokio::time::timeout( - SESSION_DELTA_TIMEOUT, + BOX_DELTA_TIMEOUT, client.oneshot_rpc::(SessionDeltaRequest { id }), ) .await @@ -134,7 +134,7 @@ pub(crate) async fn session_delta( .ok() } -pub(crate) async fn destroy_all_sessions( +pub(crate) async fn destroy_all_boxes( global: &GlobalArgs, client: &mut client::Client, force: bool, @@ -175,7 +175,7 @@ pub(crate) async fn destroy_all_sessions( .ok() .and_then(|resp| resp.record) .and_then(|record| record.box_addresses); - if let Err(error) = destroy_session( + if let Err(error) = destroy_box( client, global, session.id, @@ -201,7 +201,7 @@ pub(crate) async fn destroy_all_sessions( Ok(()) } -pub(crate) async fn destroy_session( +pub(crate) async fn destroy_box( client: &mut client::Client, global: &GlobalArgs, id: boxes::SessionId, @@ -534,19 +534,19 @@ mod tests { let global = GlobalArgs::default(); // The first destroy wins the race. - destroy_session(&mut client, &global, id, Some("web"), None, false) + destroy_box(&mut client, &global, id, Some("web"), None, false) .await .expect("the first destroy succeeds"); // The loser is told the session is already gone: under `--force` // that is the goal state, reported and not a failure. - destroy_session(&mut client, &global, id, Some("web"), None, true) + destroy_box(&mut client, &global, id, Some("web"), None, true) .await .expect("a forced destroy of a destroyed session succeeds"); // Without `--force` the same answer is an error — one that names // the session rather than forwarding the daemon's internals. - let err = destroy_session(&mut client, &global, id, Some("web"), None, false) + let err = destroy_box(&mut client, &global, id, Some("web"), None, false) .await .expect_err("an unforced destroy of a destroyed session fails"); assert!( diff --git a/crates/minimal/src/cmd/boxes/policy.rs b/crates/minimal/src/cmd/boxes/policy.rs index 1118646778..4ca9f52710 100644 --- a/crates/minimal/src/cmd/boxes/policy.rs +++ b/crates/minimal/src/cmd/boxes/policy.rs @@ -835,9 +835,9 @@ impl PolicyJsonFailure { /// as a claim that the box published nothing. async fn fetch_live_ingress( client: &mut client::Client, - session: &str, + box_name: &str, ) -> Result, String> { - let live_lookup = match SessionLookup::parse(session) { + let live_lookup = match SessionLookup::parse(box_name) { SessionLookup::Id(id) => minimald_rpc::GetLiveIngressRequest::Id(id), SessionLookup::Name(n) => minimald_rpc::GetLiveIngressRequest::Name(n), }; @@ -863,9 +863,9 @@ async fn fetch_live_ingress( /// the one rendering that may put it there. pub(crate) async fn fetch_live_ingress_degrading( client: &mut client::Client, - session: &str, + box_name: &str, ) -> Vec { - fetch_live_ingress(client, session) + fetch_live_ingress(client, box_name) .await .unwrap_or_else(|warning| { eprintln!("warning: {warning}"); @@ -881,9 +881,9 @@ pub(crate) async fn fetch_live_ingress_degrading( /// renderings degrade differently (see [`fetch_live_ingress`]): the /// document says the unknown itself, so nothing is printed for it on a /// stderr the error object has alone. -async fn session_policy_json_inputs( +async fn box_policy_json_inputs( global: &GlobalArgs, - session: &str, + box_name: &str, ) -> Result< ( boxes::Record, @@ -904,19 +904,19 @@ async fn session_policy_json_inputs( // lookup the text walk uses, with the failure kinds told apart where // they can be: an RPC the daemon never answered is no daemon to ask; // a lookup that answered with nothing is the not-found itself. - let resp = get_session_record(&mut client, session) + let resp = get_session_record(&mut client, box_name) .await .map_err(|error| match error.downcast_ref::() { Some(ambiguous) => PolicyJsonFailure::SessionNotFound(ambiguous.to_string()), None => PolicyJsonFailure::DaemonUnreachable(format!("{error:#}")), })?; - let record = named_record(resp.record, session) + let record = named_record(resp.record, box_name) .map_err(|error| PolicyJsonFailure::SessionNotFound(error.to_string()))?; // By the resolved id, as the text walk does. - let session = &record.id.to_string(); + let box_id = &record.id.to_string(); use minimald_rpc::{GetEffectiveSessionPolicy, GetEffectiveSessionPolicyRequest}; - let lookup = match SessionLookup::parse(session) { + let lookup = match SessionLookup::parse(box_id) { SessionLookup::Id(id) => GetEffectiveSessionPolicyRequest::Id(id), SessionLookup::Name(n) => GetEffectiveSessionPolicyRequest::Name(n), }; @@ -925,13 +925,13 @@ async fn session_policy_json_inputs( .await .map_err(|error| PolicyJsonFailure::PolicyUnavailable(format!("{error:#}")))?; - let live = fetch_live_ingress(&mut client, session).await; + let live = fetch_live_ingress(&mut client, box_id).await; // The listen publishes the audit log refused (NET-046) and the yielded // shared-address ports (NET-129), from the runtime facts the text walk // reads them from. Optional facts: a daemon that cannot answer — an older // build, a session mid-teardown — leaves both keys out, as a box with // nothing to say does. - let facts_lookup = match SessionLookup::parse(session) { + let facts_lookup = match SessionLookup::parse(box_id) { SessionLookup::Id(id) => minimald_rpc::GetSessionRuntimeFactsRequest::Id(id), SessionLookup::Name(n) => minimald_rpc::GetSessionRuntimeFactsRequest::Name(n), }; @@ -967,12 +967,12 @@ async fn session_policy_json_inputs( /// `main`'s machine-mode error emitter — keyed on the output mode, shared /// by every command that takes `-o json` — writes, so the error path is /// one mechanism rather than a per-command one. -pub(crate) async fn session_policy_as_json( +pub(crate) async fn box_policy_as_json( global: &GlobalArgs, - session: &str, + box_name: &str, ) -> Result<(), anyhow::Error> { let (record, policy, live, unaudited_listen_ports, shared_port_collisions) = - match session_policy_json_inputs(global, session).await { + match box_policy_json_inputs(global, box_name).await { Ok(inputs) => inputs, Err(failure) => return Err(failure.machine_failure().into()), }; diff --git a/crates/minimal/src/cmd/boxes/vm_host.rs b/crates/minimal/src/cmd/boxes/vm_host.rs index 7c019a6f84..c3d7d91585 100644 --- a/crates/minimal/src/cmd/boxes/vm_host.rs +++ b/crates/minimal/src/cmd/boxes/vm_host.rs @@ -229,7 +229,7 @@ pub(crate) async fn release_held_box_name( /// host reads it twice — before the attach, for the pair the box's row was /// registered with, and after, to tell whether the attach ended in a /// daemon-side destroy ([`release_held_name_after_attach`]). -pub(super) async fn attached_session_record( +pub(super) async fn attached_box_record( sock: &std::path::Path, id: boxes::SessionId, ) -> anyhow::Result> { @@ -259,7 +259,7 @@ async fn session_record_by( /// attach on a VM-backed host has ended with the session gone: the /// shell-exit prompt's Delete destroys the session daemon-side, so neither /// `min session attach` nor `activate --attach` passes through -/// [`destroy_session`], and this is the release that destroy would have +/// [`destroy_box`], and this is the release that destroy would have /// made — the row's withdrawal (T66) for a box that registered one, whose /// pair `box_addresses` was read off the record before the attach, and the /// name hold's release for one that did not. The lookup and the release @@ -284,7 +284,7 @@ pub(crate) async fn release_held_name_after_attach( name: &str, box_addresses: Option, ) { - match attached_session_record(sock, id).await { + match attached_box_record(sock, id).await { Ok(None) => match box_addresses { // The record carries no box id, so the pair is the proof. Some(addresses) => { @@ -355,7 +355,7 @@ pub(crate) async fn rehold_held_name_before_attach( if !hold_box_name_with_vm_host(control_sock_beside(sock), name, Some(id), true).await { return; } - if let Ok(None) = attached_session_record(sock, id).await { + if let Ok(None) = attached_box_record(sock, id).await { let by_name = session_record_by( sock, minimald_rpc::GetSessionRecordRequest::Name(name.to_string()), @@ -1691,7 +1691,7 @@ mod tests { project.path().to_str().unwrap(), ) .await; - let record = attached_session_record(&ssh_sock, id) + let record = attached_box_record(&ssh_sock, id) .await .expect("the lookup does not fail") .expect("the session's record is read"); @@ -1769,7 +1769,7 @@ mod tests { project.path().to_str().unwrap(), ) .await; - let record = attached_session_record(&ssh_sock, gone) + let record = attached_box_record(&ssh_sock, gone) .await .expect("the lookup does not fail") .expect("the session's record is read"); @@ -1849,7 +1849,7 @@ mod tests { project.path().to_str().unwrap(), ) .await; - let record = attached_session_record(&ssh_sock, id) + let record = attached_box_record(&ssh_sock, id) .await .expect("the lookup does not fail") .expect("the session's record is read"); diff --git a/crates/minimal/src/cmd/session.rs b/crates/minimal/src/cmd/session.rs index f4f2c2bb67..1c447eb0a9 100644 --- a/crates/minimal/src/cmd/session.rs +++ b/crates/minimal/src/cmd/session.rs @@ -165,7 +165,7 @@ pub async fn cmd_session_policy( // the text walk answers with a message only — and because the text // rendering is not touched at all. if args.output == Some(PolicyOutputFormat::Json) { - return session_policy_as_json(global, &args.session).await; + return box_policy_as_json(global, &args.session).await; } ensure_daemon(global)?; @@ -179,14 +179,14 @@ pub async fn cmd_session_policy( let record = resolve_session(&mut client, &args.session).await?; // The follow-up lookups go by the resolved id, so a session named by an // id prefix reaches the same session they do. - let session = record.id.to_string(); + let box_id = record.id.to_string(); // The daemon resolves the effective egress (NET-074/NET-077), because // the rollout phase and its opt-out are the daemon's own facts; built // here rather than through a `SessionLookup` conversion so the request // types stay the rpc crate's, where the wire contract lives. use minimald_rpc::{GetEffectiveSessionPolicy, GetEffectiveSessionPolicyRequest}; - let lookup = match SessionLookup::parse(&session) { + let lookup = match SessionLookup::parse(&box_id) { SessionLookup::Id(id) => GetEffectiveSessionPolicyRequest::Id(id), SessionLookup::Name(n) => GetEffectiveSessionPolicyRequest::Name(n), }; @@ -205,7 +205,7 @@ pub async fn cmd_session_policy( // enforcement row, silently: the row is an optional fact beside the // declaration, and the same silence is what a session that is not // host-address already prints. - let facts_lookup = match SessionLookup::parse(&session) { + let facts_lookup = match SessionLookup::parse(&box_id) { SessionLookup::Id(id) => minimald_rpc::GetSessionRuntimeFactsRequest::Id(id), SessionLookup::Name(n) => minimald_rpc::GetSessionRuntimeFactsRequest::Name(n), }; @@ -226,7 +226,7 @@ pub async fn cmd_session_policy( // shared fetch: warn on stderr and print no section — the JSON // rendering below degrades differently, saying the unknown in the // document instead. - let live = fetch_live_ingress_degrading(&mut client, &session).await; + let live = fetch_live_ingress_degrading(&mut client, &box_id).await; match resp { minimald_rpc::Errorable::Ok(policy) => { @@ -457,21 +457,21 @@ pub async fn cmd_destroy(global: &GlobalArgs, args: DestroyArgs) -> Result<(), a let mut client = connect_daemon(global).await?; if args.all { - return destroy_all_sessions(global, &mut client, args.force).await; + return destroy_all_boxes(global, &mut client, args.force).await; } - let session = args + let box_name = args .session .as_deref() .context("a session or --all is required")?; - let record = resolve_session(&mut client, session).await?; + let record = resolve_session(&mut client, box_name).await?; // Under --force the at-risk fetch is skipped outright — the gate is // bypassed regardless, so there is nothing to ask the daemon for. let at_risk = if args.force { AtRiskState::Clean } else { - assess_at_risk(session_delta(&mut client, record.id).await) + assess_at_risk(box_delta(&mut client, record.id).await) }; match destroy_gate( args.force, @@ -486,7 +486,7 @@ pub async fn cmd_destroy(global: &GlobalArgs, args: DestroyArgs) -> Result<(), a println!("{line}"); } } - let label = record.name.as_deref().unwrap_or(session); + let label = record.name.as_deref().unwrap_or(box_name); if !confirm( &format!("Destroy session {label}? This permanently deletes all in-session files."), false, @@ -497,7 +497,7 @@ pub async fn cmd_destroy(global: &GlobalArgs, args: DestroyArgs) -> Result<(), a } } - destroy_session( + destroy_box( &mut client, global, record.id, diff --git a/crates/minimal/src/task.rs b/crates/minimal/src/task.rs index 152e0b4253..aa914ae99b 100644 --- a/crates/minimal/src/task.rs +++ b/crates/minimal/src/task.rs @@ -97,7 +97,7 @@ fn task_run_cwd(upload_root: &camino::Utf8Path, invocation_dir: &camino::Utf8Pat /// reduced to the session-name alphabet by the same sanitizer the activate /// autogen path uses, and the caller supplies the hex so a collision retry /// can re-mint with fresh entropy. -fn task_session_name(task: &str, hex: &str) -> String { +fn task_box_name(task: &str, hex: &str) -> String { format!("task-{}-{hex}", crate::sanitize_name_component(task)) } @@ -408,8 +408,8 @@ impl Drop for TaskRunInterrupt { fn arm_task_run_interrupt( global: &GlobalArgs, - session_id: boxes::SessionId, - session_name: String, + box_id: boxes::SessionId, + box_name: String, keep: bool, ) -> TaskRunInterrupt { let sock = @@ -424,12 +424,12 @@ fn arm_task_run_interrupt( } if keep { eprintln!( - "\nInterrupted; session {session_name} kept — attach with: \ - min session attach {session_name}" + "\nInterrupted; session {box_name} kept — attach with: \ + min session attach {box_name}" ); std::process::exit(130); } - eprintln!("\nInterrupted; destroying session {session_name}…"); + eprintln!("\nInterrupted; destroying session {box_name}…"); // The whole connect-and-destroy is bounded by the same 10-second // cleanup ceiling as `best_effort_destroy` — the interrupt may well // mean the daemon is already wedged — and raced against a second @@ -446,19 +446,19 @@ fn arm_task_run_interrupt( { use minimald_rpc::{DestroySession, DestroySessionRequest}; let _ = client - .oneshot_rpc::(DestroySessionRequest { id: session_id }) + .oneshot_rpc::(DestroySessionRequest { id: box_id }) .await; } // The run's own return never comes on this path, so the release // it owes is made here, inside the same bound. - release_task_name_hold(control_sock, session_id, &session_name, false).await; + release_task_name_hold(control_sock, box_id, &box_name, false).await; }; tokio::select! { res = tokio::time::timeout(CLEANUP_TIMEOUT, destroy) => { if res.is_err() { eprintln!( "DestroySession timed out after {CLEANUP_TIMEOUT:?}; the session may \ - still be present (run `min session destroy {session_name}` to clean \ + still be present (run `min session destroy {box_name}` to clean \ up manually)" ); } @@ -650,7 +650,7 @@ pub async fn cmd_task_run(global: &GlobalArgs, args: TaskRunArgs) -> Result<(), crate::ensure_daemon(global)?; let config = minimald_rpc::BoxConfig { - name: Some(task_session_name(&args.task, &crate::random_hex4())), + name: Some(task_box_name(&args.task, &crate::random_hex4())), project_path: abs_path.clone(), network: boxes::NetworkMode::HostNet, policy: boxes::BoxPolicy::default(), @@ -733,7 +733,7 @@ pub async fn cmd_task_run(global: &GlobalArgs, args: TaskRunArgs) -> Result<(), minimald_rpc::Errorable::Err { error } => { if crate::should_retry_autogen(true, attempts, &error) { attempts += 1; - config.name = Some(task_session_name(&args.task, &crate::random_hex4())); + config.name = Some(task_box_name(&args.task, &crate::random_hex4())); continue; } bail!("{error}"); @@ -971,9 +971,9 @@ mod tests { /// pushed through the same sanitizer as the activate autogen so it /// always clears `validate_session_name`. #[test] - fn task_session_name_sanitizes_the_task_stem() { - assert_eq!(task_session_name("build", "9c1e"), "task-build-9c1e"); - assert_eq!(task_session_name("My Task!", "4f2a"), "task-mytask-4f2a"); + fn task_box_name_sanitizes_the_task_stem() { + assert_eq!(task_box_name("build", "9c1e"), "task-build-9c1e"); + assert_eq!(task_box_name("My Task!", "4f2a"), "task-mytask-4f2a"); } /// The hidden `min run` redirect names both canonical forms — the host From a7b55e9408b38ebb5b850a786c8dc69433a198e9 Mon Sep 17 00:00:00 2001 From: "minimal-foundry[bot]" <327719912+minimal-foundry[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 16:49:28 +0000 Subject: [PATCH 2/2] refactor(minimal): finish the box names for the CLI's operations Rename activate_session to activate_box, session_via_ssh to box_via_ssh, session_announce_label to box_announce_label and session_record_by to box_record_by, with their callers, the source-scan lists in tests.rs and the tests that quote the names. Output and wire are unchanged. --- crates/minimal/src/cmd/boxes/attach.rs | 11 ++++------ crates/minimal/src/cmd/boxes/create.rs | 28 ++++++++++++------------- crates/minimal/src/cmd/boxes/policy.rs | 2 +- crates/minimal/src/cmd/boxes/vm_host.rs | 14 ++++++------- crates/minimal/src/cmd/list.rs | 4 ++-- crates/minimal/src/cmd/mod.rs | 2 +- crates/minimal/src/cmd/net.rs | 2 +- crates/minimal/src/cmd/project.rs | 2 +- crates/minimal/src/cmd/session.rs | 8 +++---- crates/minimal/src/tests.rs | 16 +++++++------- 10 files changed, 43 insertions(+), 46 deletions(-) diff --git a/crates/minimal/src/cmd/boxes/attach.rs b/crates/minimal/src/cmd/boxes/attach.rs index 0336a6fa47..32c01b5d37 100644 --- a/crates/minimal/src/cmd/boxes/attach.rs +++ b/crates/minimal/src/cmd/boxes/attach.rs @@ -17,7 +17,7 @@ pub(crate) fn should_announce_box(global: &GlobalArgs) -> bool { /// session is unnamed. The short id is the leading block of the UUID — enough /// to tell two same-named sessions built from the same directory apart without /// the full 36-character id. -pub(crate) fn session_announce_label(id: &boxes::SessionId, name: Option<&str>) -> String { +pub(crate) fn box_announce_label(id: &boxes::SessionId, name: Option<&str>) -> String { let id = id.to_string(); let short = id.split('-').next().unwrap_or(&id); match name { @@ -55,10 +55,7 @@ pub(crate) async fn resolve_attach_target_version_gated( if should_announce_box(global) { eprintln!( "Attaching to session {} on VM {}", - session_announce_label( - &resolved.record.id, - resolved.record.name.as_deref() - ), + box_announce_label(&resolved.record.id, resolved.record.name.as_deref()), resolved.vm ); } @@ -94,7 +91,7 @@ pub(crate) fn resolve_smart_attach( if should_announce_box(global) { eprintln!( "Attaching to session {}{}", - session_announce_label(&entry.id, entry.name.as_deref()), + box_announce_label(&entry.id, entry.name.as_deref()), crate::attach::created_from_suffix(&entry, &cwd) ); } @@ -200,7 +197,7 @@ pub(crate) fn ensure_interactive_attach_tty(stdin_is_tty: bool) -> Result<(), an /// Neither path returns normally: on success the error is a [`Handoff`] /// (exec ssh, or exit with the attach's status) that [`run`] finishes once /// the command's `cmd` span has ended, so callers return it untouched. -pub(crate) async fn session_via_ssh( +pub(crate) async fn box_via_ssh( sock: &std::path::Path, id: boxes::SessionId, wire: Option, diff --git a/crates/minimal/src/cmd/boxes/create.rs b/crates/minimal/src/cmd/boxes/create.rs index e308e8fef5..88dd7e88e1 100644 --- a/crates/minimal/src/cmd/boxes/create.rs +++ b/crates/minimal/src/cmd/boxes/create.rs @@ -198,7 +198,7 @@ fn refuse_unhonourable_grants( Ok(()) } -/// One named step of [`activate_session`], in the order the activation runs +/// One named step of [`activate_box`], in the order the activation runs /// them. Each step runs inside its own `activation_step` span, so a log read /// under `RUST_LOG=info` shows where an activation spent its time and which /// step ended it. @@ -233,7 +233,7 @@ pub(crate) enum ActivationStep { } impl ActivationStep { - /// Every step, in the order [`activate_session`] runs them. + /// Every step, in the order [`activate_box`] runs them. #[cfg(test)] pub(crate) const ORDER: [Self; 13] = [ Self::CheckArguments, @@ -293,7 +293,7 @@ impl ActivationStep { } } -pub(crate) async fn activate_session( +pub(crate) async fn activate_box( global: &GlobalArgs, args: ActivateArgs, offer_scaffold: bool, @@ -1556,7 +1556,7 @@ pub(crate) async fn activate_session( if should_announce_box(global) { eprintln!( "Created session {}", - session_announce_label(&id, config.name.as_deref()) + box_announce_label(&id, config.name.as_deref()) ); } let attach_args = AttachArgs { @@ -1679,7 +1679,7 @@ mod tests { no_prompt: true, attach: false, }; - let err = activate_session(&global, args, false) + let err = activate_box(&global, args, false) .await .expect_err("the grant box is refused"); let refused = err @@ -1736,7 +1736,7 @@ mod tests { no_prompt: true, attach: false, }; - let err = activate_session(&global, args, false) + let err = activate_box(&global, args, false) .await .expect_err("the broken project file is refused"); assert!( @@ -1925,16 +1925,16 @@ mod activation_step_tests { } } - /// The step names [`super::activate_session`] runs, in source order. - fn steps_in_activate_session() -> Vec { + /// The step names [`super::activate_box`] runs, in source order. + fn steps_in_activate_box() -> Vec { let text = include_str!("create.rs"); let start = text - .find("pub(crate) async fn activate_session(") - .expect("create.rs defines activate_session"); + .find("pub(crate) async fn activate_box(") + .expect("create.rs defines activate_box"); let body = &text[start..]; let end = body .find("\nfn normalize_subnets(") - .expect("normalize_subnets follows activate_session"); + .expect("normalize_subnets follows activate_box"); // Comment lines name steps too; only code runs them. let body: String = body[..end] .lines() @@ -1965,7 +1965,7 @@ mod activation_step_tests { .iter() .map(|step| format!("{step:?}")) .collect(); - assert_eq!(steps_in_activate_session(), declared); + assert_eq!(steps_in_activate_box(), declared); // Each step opens its own span, and the failing step names itself // while its error passes through unchanged. @@ -2021,7 +2021,7 @@ mod activation_step_tests { } #[tokio::test(flavor = "current_thread")] - async fn activation_steps_run_in_order_and_name_the_failing_step_in_activate_session() { + async fn activation_steps_run_in_order_and_name_the_failing_step_in_activate_box() { use clap::Parser as _; // A project path that does not exist ends the real activation in its // first step, before any daemon is started or contacted. @@ -2032,7 +2032,7 @@ mod activation_step_tests { let subscriber = tracing_subscriber::registry().with(Capture(seen.clone())); let _guard = tracing::subscriber::set_default(subscriber); - let error = super::activate_session(&crate::cli::GlobalArgs::default(), cli.args, false) + let error = super::activate_box(&crate::cli::GlobalArgs::default(), cli.args, false) .await .expect_err("a missing project path ends the activation"); let expected = format!("Cannot resolve project path '{}'", missing.display()); diff --git a/crates/minimal/src/cmd/boxes/policy.rs b/crates/minimal/src/cmd/boxes/policy.rs index 4ca9f52710..1910d7db21 100644 --- a/crates/minimal/src/cmd/boxes/policy.rs +++ b/crates/minimal/src/cmd/boxes/policy.rs @@ -11,7 +11,7 @@ use super::*; /// /// The opt-out half of the scope is the caller's to check: the daemon, not /// the client, knows whether it set its opt-out (NET-077), so -/// [`activate_session`] reads it off the create reply and stays silent for +/// [`activate_box`] reads it off the create reply and stays silent for /// a box the default does not bind. pub fn deny_all_default_notice(phase: boxes::EgressDefaultPhase) -> Option<&'static str> { match phase { diff --git a/crates/minimal/src/cmd/boxes/vm_host.rs b/crates/minimal/src/cmd/boxes/vm_host.rs index c3d7d91585..012d2a43c4 100644 --- a/crates/minimal/src/cmd/boxes/vm_host.rs +++ b/crates/minimal/src/cmd/boxes/vm_host.rs @@ -206,7 +206,7 @@ pub(crate) fn vm_host_answerer_start_line( /// Releases the zone hold a destroyed session's activation made, when the /// session registered no row (`box_addresses` is `None` — a `host_ip` box /// holds its name in place of a row): the destroy-side twin of the hold -/// [`activate_session`] makes once the session is active. Best-effort and +/// [`activate_box`] makes once the session is active. Best-effort and /// warn-only like the hold; a name no hold kept is the goal state already /// holding, so a `none` box's release changes nothing. The release names /// the session `id`, so it frees only that session's hold, never a newer @@ -233,12 +233,12 @@ pub(super) async fn attached_box_record( sock: &std::path::Path, id: boxes::SessionId, ) -> anyhow::Result> { - session_record_by(sock, minimald_rpc::GetSessionRecordRequest::Id(id)).await + box_record_by(sock, minimald_rpc::GetSessionRecordRequest::Id(id)).await } /// A session's record by `request`, bounded by [`BOX_CONTROL_TIMEOUT`]: /// `None` when no session answers to it. -async fn session_record_by( +async fn box_record_by( sock: &std::path::Path, request: minimald_rpc::GetSessionRecordRequest, ) -> anyhow::Result> { @@ -356,7 +356,7 @@ pub(crate) async fn rehold_held_name_before_attach( return; } if let Ok(None) = attached_box_record(sock, id).await { - let by_name = session_record_by( + let by_name = box_record_by( sock, minimald_rpc::GetSessionRecordRequest::Name(name.to_string()), ) @@ -2102,7 +2102,7 @@ mod tests { attach: false, ..bare_activate_args() }; - activate_session(&global, args, false).await.expect( + activate_box(&global, args, false).await.expect( "a flagless activation reaches a session on the backend its kind \ resolves to", ); @@ -2139,7 +2139,7 @@ mod tests { /// refuses the box's registration ends the activation with the refusal's /// cause — the session does not start with the box unregistered — and no /// session is left behind. The full activation is driven through - /// `activate_session`, so the path proven is the user's: the refusal + /// `activate_box`, so the path proven is the user's: the refusal /// surfaces as the session-start error, not as a warning beside a box /// that created anyway. #[tokio::test] @@ -2187,7 +2187,7 @@ mod tests { attach: false, ..bare_activate_args() }; - let error = activate_session(&global, args, false) + let error = activate_box(&global, args, false) .await .expect_err("a refused registration ends the activation"); let rendered = format!("{error:#}"); diff --git a/crates/minimal/src/cmd/list.rs b/crates/minimal/src/cmd/list.rs index a301b5a91c..3fdbd361c6 100644 --- a/crates/minimal/src/cmd/list.rs +++ b/crates/minimal/src/cmd/list.rs @@ -39,7 +39,7 @@ pub(crate) async fn cmd_bare(global: &GlobalArgs) -> Result<(), anyhow::Error> { "found session" ); let host_asks = super::session::host_asks_box(global, entry.name.as_deref()); - session_via_ssh( + box_via_ssh( &sock, entry.id, None, @@ -57,7 +57,7 @@ pub(crate) async fn cmd_bare(global: &GlobalArgs) -> Result<(), anyhow::Error> { // keystroke into a session must not detour into config authoring. SmartAttach::CreateForCwd | SmartAttach::NoSessions => { drop(client); - activate_session(global, bare_activate_args(), false).await + activate_box(global, bare_activate_args(), false).await } } } diff --git a/crates/minimal/src/cmd/mod.rs b/crates/minimal/src/cmd/mod.rs index 05a9819eb1..3b973e35ec 100644 --- a/crates/minimal/src/cmd/mod.rs +++ b/crates/minimal/src/cmd/mod.rs @@ -91,7 +91,7 @@ pub async fn run(cli: Cli) -> Result<(), anyhow::Error> { /// Neither returns, so neither can run inside the span: the span would never /// end, and every span under it (the client's and the daemon's) would parent /// to one the collector never sees. A command returns this as its error -/// ([`session_via_ssh`]); [`run`] takes it back out once the span has ended +/// ([`box_via_ssh`]); [`run`] takes it back out once the span has ended /// and finishes it there. It is the [`crate::task::TaskExit`] pattern: a /// status carried on the error path, never printed. #[derive(Debug)] diff --git a/crates/minimal/src/cmd/net.rs b/crates/minimal/src/cmd/net.rs index b8a3dc140a..72113d0238 100644 --- a/crates/minimal/src/cmd/net.rs +++ b/crates/minimal/src/cmd/net.rs @@ -85,7 +85,7 @@ pub async fn cmd_net_forward( let mut sigterm = signal_stream(SignalKind::terminate()); let mut sighup = signal_stream(SignalKind::hangup()); - let label = session_announce_label(&record.id, record.name.as_deref()); + let label = box_announce_label(&record.id, record.name.as_deref()); eprintln!( "Forwarding localhost:{local_port} → 127.0.0.1:{box_port} in session {label}. \ Ctrl-C to stop." diff --git a/crates/minimal/src/cmd/project.rs b/crates/minimal/src/cmd/project.rs index b2a99a670a..2192b4ee9c 100644 --- a/crates/minimal/src/cmd/project.rs +++ b/crates/minimal/src/cmd/project.rs @@ -157,7 +157,7 @@ pub fn build_config(global: &GlobalArgs) -> Result { /// callers publish it on different streams: `min init` puts the line on /// stdout — it is that command's whole scriptable result — while /// `min activate`'s scaffold offer keeps it on stderr, where stdout carries -/// only the session id (see [`activate_session`]). +/// only the session id (see [`activate_box`]). pub(crate) enum InitOutcome { /// The operator declined the confirmation; nothing was written. Declined, diff --git a/crates/minimal/src/cmd/session.rs b/crates/minimal/src/cmd/session.rs index 1c447eb0a9..2a9eec0603 100644 --- a/crates/minimal/src/cmd/session.rs +++ b/crates/minimal/src/cmd/session.rs @@ -8,7 +8,7 @@ pub(crate) use super::box_verbs::{ /// Create a new session via the `CreateSession` RPC. pub async fn cmd_activate(global: &GlobalArgs, args: ActivateArgs) -> Result<(), anyhow::Error> { - activate_session(global, args, true).await + activate_box(global, args, true).await } /// Attach to an existing session. Both interactive and `--command` paths @@ -65,7 +65,7 @@ pub async fn cmd_attach(global: &GlobalArgs, args: AttachArgs) -> Result<(), any ); let host_asks = host_asks_box(global, name.as_deref()); - session_via_ssh( + box_via_ssh( &sock, id, None, @@ -102,7 +102,7 @@ pub async fn cmd_exec(global: &GlobalArgs, args: ExecArgs) -> Result<(), anyhow: "found session" ); - session_via_ssh(&sock, r.id, wire, None, None).await + box_via_ssh(&sock, r.id, wire, None, None).await } /// Runs a task declared by the session's project, in that session. @@ -133,7 +133,7 @@ pub async fn cmd_session_run( "found session" ); - session_via_ssh( + box_via_ssh( &sock, r.id, // No owns-box flag (NET-131): the task runs in a session someone diff --git a/crates/minimal/src/tests.rs b/crates/minimal/src/tests.rs index 577f48958e..fbea67b1e2 100644 --- a/crates/minimal/src/tests.rs +++ b/crates/minimal/src/tests.rs @@ -269,7 +269,7 @@ fn every_daemon_connection_is_classified() { // the session is gone after, to withdraw its row or release a // `host_ip` name hold, and which live session holds a name a // re-hold took over; it builds nothing a skew could half-make. - "cmd/boxes/vm_host.rs::session_record_by = ungated", + "cmd/boxes/vm_host.rs::box_record_by = ungated", "cmd/list.rs::cmd_bare = gated", // `min ls` reaches past the selected VM, and the two halves carry // the gate differently (see `ls_listings`): the selected VM is the @@ -317,7 +317,7 @@ fn every_create_session_asserts_the_daemon_build() { assert_eq!( create_site_inventory(env!("CARGO_MANIFEST_DIR")), [ - "cmd/boxes/create.rs::activate_session = asserts", + "cmd/boxes/create.rs::activate_box = asserts", // The dashboard's activation: the same create, the same assertion. "dash/rpc.rs::activate = asserts", "task.rs::cmd_task_run = asserts", @@ -340,7 +340,7 @@ fn every_create_session_asserts_the_daemon_build() { fn the_activation_path_makes_no_version_round_trip() { let manifest = std::path::Path::new(env!("CARGO_MANIFEST_DIR")); for (file, func) in [ - ("src/cmd/boxes/create.rs", "activate_session"), + ("src/cmd/boxes/create.rs", "activate_box"), ("src/task.rs", "cmd_task_run"), ] { let text = std::fs::read_to_string(manifest.join(file)).expect("readable source"); @@ -965,10 +965,10 @@ fn display_with_home_tilde_abbreviates_only_under_home() { /// still distinguishable; an unnamed session falls back to the short id /// alone rather than the full 36-character UUID. #[test] -fn session_announce_label_prefers_name_with_short_id() { +fn box_announce_label_prefers_name_with_short_id() { let id = boxes::SessionId::parse_str("a1b2c3d4-0000-0000-0000-000000000000").unwrap(); - assert_eq!(session_announce_label(&id, Some("api")), "api (a1b2c3d4)"); - assert_eq!(session_announce_label(&id, None), "a1b2c3d4"); + assert_eq!(box_announce_label(&id, Some("api")), "api (a1b2c3d4)"); + assert_eq!(box_announce_label(&id, None), "a1b2c3d4"); } /// A session created without `--name` gets a typable `-` handle: @@ -1778,7 +1778,7 @@ fn composition_failure_does_not_blame_config_for_git_lock() { fn both_creators_share_the_composition_failure_message() { let manifest = std::path::Path::new(env!("CARGO_MANIFEST_DIR")); for (file, func, uses) in [ - ("src/cmd/boxes/create.rs", "activate_session", 2), + ("src/cmd/boxes/create.rs", "activate_box", 2), ("src/task.rs", "cmd_task_run", 2), ("src/cmd/mod.rs", "drive_pending_to_active", 1), ] { @@ -1809,7 +1809,7 @@ fn both_creators_share_the_composition_failure_message() { fn daemon_refusals_print_without_rpc_names() { let manifest = std::path::Path::new(env!("CARGO_MANIFEST_DIR")); for (file, func) in [ - ("src/cmd/boxes/create.rs", "activate_session"), + ("src/cmd/boxes/create.rs", "activate_box"), ("src/cmd/session.rs", "cmd_rename"), ("src/task.rs", "cmd_task_run"), ("src/cmd/mod.rs", "submit_verdict_and_wait"),