From 32eaaeae9e0fe2c2285fb79efa0e579150d8bd83 Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 15:23:23 +0000 Subject: config: refuse a sandbox configuration that cannot work, at startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The enum makes the impossible unrepresentable, but two things survive any type: a field that is present and empty, and an assertion the type leaves defaulted on purpose. `Config::validate` catches both, and it runs at startup — before the watcher, the dispatcher or the UI are up and looking healthy — and again where a backend is constructed, so nothing that builds one can skip it. The one that matters is the workspace. `Run` frames carry a hub-side working directory and the srcdir is never shipped to the sandbox, so a `remote` backend on a machine that does not share the hub's filesystem would fail in `makepkg` with a missing directory — and, worse, would *succeed* in the case nobody wants: quietly building untrusted code on the hub. So a remote or agent-sandbox config must say `"shared_workspace": true`, and the refusal says why rather than just naming the field. Loopback needs no assertion because it shares the filesystem by construction, which is also why it stays the zero-config default. Empty `listen`, `token`, `api`, `namespace`, `bearer` and `image` are each refused by name. Two tests drive the compiled binary rather than the library, because a guard that only exists as a callable function is a guard the CLI can walk past. --- src/main.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 9e3b1e0..ccd20a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,6 +132,9 @@ fn main() -> anyhow::Result<()> { } else { Config::load(&root)? }; + // Startup, not first-build: a configuration that cannot work is refused + // before the watcher, the dispatcher or the UI are up and looking healthy. + cfg.validate()?; if let Cmd::Serve { bind } = &cli.cmd { let mut cfg = cfg; if let Some(b) = bind { -- cgit v1.2.3