From 4304b0f336ddba7b4ec6780795059ff2066d105b Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:33:17 +0000 Subject: comments: keep only what the code cannot show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound. --- src/sandbox/kata.rs | 42 ------------------------------------------ 1 file changed, 42 deletions(-) (limited to 'src/sandbox/kata.rs') diff --git a/src/sandbox/kata.rs b/src/sandbox/kata.rs index 9169f9f..fafe858 100644 --- a/src/sandbox/kata.rs +++ b/src/sandbox/kata.rs @@ -15,9 +15,6 @@ use crate::sandbox::remote::RemoteSandbox; use crate::sandbox::wire::{self, Frame}; use crate::sandbox::{Sandbox, SandboxBackend, SandboxInfo, SandboxSpec}; -/// What any provisioner needs to know to start one sandbox pointed at this -/// hub. `sandbox_id` is the rendezvous nonce: the hub will only lease the -/// connection whose hello carries it back. #[derive(Debug, Clone)] pub struct ProvisionRequest { pub sandbox_id: String, @@ -29,10 +26,7 @@ pub struct ProvisionRequest { } pub trait Provisioner: Send + Sync { - /// Start a sandbox for `req`. Must return quickly; the sandbox dials in - /// asynchronously and `acquire` waits on the dial. fn provision(&self, req: &ProvisionRequest) -> Result<()>; - /// Reclaim a sandbox out of band (TTL would also do it eventually). fn reclaim(&self, sandbox_id: &str) -> Result<()>; fn name(&self) -> &str; } @@ -77,9 +71,6 @@ pub fn sandbox_cr(req: &ProvisionRequest) -> serde_json::Value { } impl K8sSandboxProvisioner { - /// The provisioner an `agent-sandbox` configuration names. Split out so a - /// test can assert the cluster coordinates reach it from a parsed config, - /// and so `shared_for` and any later caller build it the same way. pub fn for_config(cfg: &Config) -> Option { match &cfg.sandbox { crate::config::Sandbox::AgentSandbox { api, namespace, bearer, .. } => Some(Self { @@ -92,9 +83,6 @@ impl K8sSandboxProvisioner { } } -/// Talks to a Kubernetes API serving an agent-sandbox-style CRD. Real code, -/// exercised only by the gated live tier — this repository's philosophy is -/// that a gated tier is recorded as skipped, never silently absent. pub struct K8sSandboxProvisioner { pub api: String, pub bearer: String, @@ -133,9 +121,6 @@ impl Provisioner for K8sSandboxProvisioner { } } -/// The test/dev provisioner: a real `sandbox-agent` process, no VM. This is -/// what keeps the kata rendezvous and TTL logic under honest test on a -/// machine with neither root nor `/dev/kvm`. pub struct LocalAgentProvisioner { pub bin: PathBuf, children: Mutex>, @@ -184,24 +169,11 @@ pub struct KataBackend { token: String, addr: String, provisioner: Arc, - /// Nonce → the waiting `acquire`. The accept thread routes dial-ins by - /// the `agent_id` the hello frame carries; anything unknown is dropped, - /// because a sandbox the hub did not ask for is a sandbox to not lease. pending: Arc>>>, counter: AtomicU64, } impl KataBackend { - /// The one Kata backend this process should use for this configuration. - /// - /// A Kata backend cannot share only its listener the way the plain remote - /// backend does: it routes every dial-in by the nonce in its `Hello` into a - /// map that belongs to it, so two backends on one address would each see half - /// the dial-ins. The whole backend is therefore shared, and binding happens - /// exactly once per distinct configuration. - /// - /// The key is a digest of everything that distinguishes one backend from - /// another, so the tokens are not sitting around in a second place. pub fn shared_for(cfg: &Config) -> Result> { let crate::config::Sandbox::AgentSandbox { api, namespace, bearer, image, listen, token, .. } = &cfg.sandbox @@ -227,9 +199,6 @@ impl KataBackend { Ok(backend) } - /// The request a lease turns into, for one nonce. Split out of `acquire` so - /// a test can assert what a *configuration* becomes without a cluster in - /// the loop. pub fn provision_request(&self, spec: &SandboxSpec, id: &str) -> ProvisionRequest { ProvisionRequest { sandbox_id: id.to_string(), @@ -269,8 +238,6 @@ impl KataBackend { }) } - /// Reclaim a sandbox out of band. The TTL would also do this eventually; - /// this is just not making someone else pay for the wait. pub fn reclaim(&self, sandbox_id: &str) -> Result<()> { self.provisioner.reclaim(sandbox_id) } @@ -289,15 +256,11 @@ impl KataBackend { } } -/// Read one hello and route it. A connection that greets with a nonce nobody -/// asked for is dropped unread — the TTL on the provisioner cleans that box -/// up, and the hub never leases a sandbox it did not order. fn route_dial_in( stream: TcpStream, token: &str, pending: &Arc>>>, ) { - // Bounded so a box that connects and says nothing cannot park the loop. let _ = stream.set_read_timeout(Some(Duration::from_secs(10))); let mut reader = match stream.try_clone() { Ok(s) => BufReader::new(s), @@ -323,8 +286,6 @@ impl SandboxBackend for KataBackend { self.pending.lock().unwrap().remove(&id); return Err(e); } - // The TTL is the wait bound *and* the sandbox's own deadline: nobody - // dials in by then, and nobody ever will — the box is dying or dead. let stream = match rx.recv_timeout(spec.ttl) { Ok(s) => s, Err(_) => { @@ -378,11 +339,8 @@ mod tests { .iter() .map(|v| v.as_str().unwrap().to_string()) .collect::>(); - // The rendezvous nonce and the hub coordinates must reach the agent. assert!(args.windows(2).any(|w| w[0] == "--agent-id" && w[1] == "sbx-abc123")); assert!(args.windows(2).any(|w| w[0] == "--hub" && w[1] == "10.0.0.5:9443")); assert!(args.windows(2).any(|w| w[0] == "--token" && w[1] == "t0ken")); } - - } -- cgit v1.2.3