From 632a08c8543f0db533efc7bfb6728b50a77ae3d8 Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 22:34:16 +0000 Subject: sandbox: the seam between the pipeline and where build code runs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The step machine spawned its own subprocesses, which quietly made "build code runs on this machine, inside a devtools chroot, under §14's sudo rules" a pipeline fact rather than a deployment fact. Every build subprocess now goes through SandboxBackend: acquire a lease, run argv shaped commands (never a shell string), move content-addressed blobs, destroy. The loopback backend is today's behavior wearing the interface - same child_env shim protocol, same captured output - which is why the shim suite passes untouched: a step that cannot tell loopback from a remote sandbox is the property under test. --- src/pipeline/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/pipeline/mod.rs') diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs index bd37258..5e0a823 100644 --- a/src/pipeline/mod.rs +++ b/src/pipeline/mod.rs @@ -10,12 +10,15 @@ pub mod dispatch; mod steps; use std::path::PathBuf; +use std::sync::Arc; +use std::time::Duration; use crate::config::Config; use crate::db::{self, builds, Db, Pkgbase}; use crate::db::model::*; use crate::db::SnapshotRow; use crate::error::{Error, Result}; +use crate::sandbox::{Sandbox, SandboxBackend}; /// The approved source identity a build must reproduce. /// @@ -120,6 +123,9 @@ pub struct Ctx { pub log: PathBuf, pub profile: String, pub attempt: i64, + /// Where build code runs. Defaults to the loopback backend (§8, sandbox + /// seam); the pipeline itself never spawns a build subprocess directly. + pub backend: Arc, } impl Ctx { @@ -165,9 +171,26 @@ impl Ctx { log: cfg.build_log_path(build_id), profile, attempt, + backend: Arc::new(crate::sandbox::loopback::LoopbackBackend::new(cfg)), }) } + /// Lease a sandbox for this build's profile. Today every step acquires and + /// releases around itself; a remote backend will hold one sandbox across + /// the sandbox-bearing steps of a build, and steps stay idempotent either + /// way (I5). The TTL is the lease window: a sandbox that outlives it is + /// assumed dead, which is exactly what the reaper already concludes about + /// an expired build lease. + pub fn sandbox(&self) -> Result> { + let spec = crate::sandbox::SandboxSpec { + profile: self.profile.clone(), + task: self.build.id.clone(), + ttl: Duration::from_secs(self.cfg.lease_secs.max(1) as u64), + disk_mb: self.cfg.min_free_disk_mb, + }; + self.backend.acquire(&spec) + } + /// Append to the build log; the SSE tail reads this file (§12). pub fn log_line(&self, line: &str) { use std::io::Write; -- cgit v1.2.3