From 3374ffd34921e1de414e8b07f69753113f5ba5f9 Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 11:36:36 +0000 Subject: sandbox: ephemeral agent, wire protocol, and the hub's remote backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seam from the previous commits only had one body. This adds the other one: a sandbox-agent binary that dials the hub (outbound rendezvous — the hub never needs a route into an untrusted box), serves Run/Put/Get frames over length-prefixed JSON, streams the child's stdout/stderr as they fill, and dies — taking its child with it — when the connection drops or its TTL expires. The TTL watchdog is the backstop under every leak: hub crash, partition, a forgotten destroy. Hub side, RemoteBackend implements the same SandboxBackend: acquire waits for a dial-in and verifies the shared token and profile before a lease exists; a vanished sandbox fails the step, which is already the shape of an expired lease (I5), so the remote path adds no new failure vocabulary. Run frames carry the hub's child environment, so the §16a shim protocol reaches remote children exactly as local ones — which is what makes the end-to-end test honest: a real build, real frames, real log streaming into the SSE-tailed file, no root and no container. Workspace sync over the wire is deliberately not here: Run carries a hub-side cwd, honest for loopback-shaped deployments and this test tier, and the module says so rather than pretending. --- src/bin/sandbox-agent.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/bin/sandbox-agent.rs (limited to 'src/bin') diff --git a/src/bin/sandbox-agent.rs b/src/bin/sandbox-agent.rs new file mode 100644 index 0000000..1c2a8d8 --- /dev/null +++ b/src/bin/sandbox-agent.rs @@ -0,0 +1,52 @@ +//! The ephemeral sandbox agent — see `aur_build::sandbox::agent`. +//! +//! This is the piece that runs *inside* the disposable sandbox (a Kata +//! container, a throwaway VM, a test's temp process). It dials the hub, +//! serves exactly one lease, and dies with it. + +use std::time::Duration; + +fn main() { + let mut hub = None; + let mut token = None; + let mut profile = Some("extra-x86_64".to_string()); + let mut ttl = 90u64; + let args: Vec = std::env::args().skip(1).collect(); + let mut i = 0; + while i < args.len() { + let take = |i: &mut usize| { + *i += 1; + args.get(*i).cloned().ok_or_else(|| format!("{} needs a value", args[*i - 1])) + }; + let r = match args[i].as_str() { + "--hub" => take(&mut i).map(|v| hub = Some(v)), + "--token" => take(&mut i).map(|v| token = Some(v)), + "--profile" => take(&mut i).map(|v| profile = Some(v)), + "--ttl" => take(&mut i).and_then(|v| v.parse::().map(|t| ttl = t).map_err(|_| "bad ttl".to_string())), + other => Err(format!("unknown argument {other}")), + }; + if let Err(e) = r { + eprintln!("sandbox-agent: {e}"); + eprintln!("usage: sandbox-agent --hub HOST:PORT --token T [--profile P] [--ttl SECS]"); + std::process::exit(2); + } + i += 1; + } + let (hub, token) = match (hub, token) { + (Some(h), Some(t)) => (h, t), + _ => { + eprintln!("usage: sandbox-agent --hub HOST:PORT --token T [--profile P] [--ttl SECS]"); + std::process::exit(2); + } + }; + let opts = aur_build::sandbox::agent::AgentOptions { + hub, + token, + profile: profile.unwrap(), + ttl: Duration::from_secs(ttl), + }; + if let Err(e) = aur_build::sandbox::agent::serve(&opts) { + eprintln!("sandbox-agent: {e}"); + std::process::exit(1); + } +} -- cgit v1.2.3