Skip to main content

Module sandbox

Module sandbox 

Source
Expand description

Where a checker runs something it did not write.

§Why this boundary is declared here

Feature 09 owns the sandbox: what a capability is, how a filesystem grant becomes a preopened descriptor, how a network grant becomes an egress proxy. None of that exists yet, and the compile checker (US-0804) and the test-run checker (US-0805) need exactly one thing from it — somewhere to run a command and get its exit status back.

So the boundary is declared here, as narrowly as it can be, exactly as feature 07 declares Store for the content store it does not own and the runtime declares LedgerSink for the log it does not own. Feature 09’s Sandbox will satisfy Sandbox unchanged.

§The sandbox is handed the grant, and must refuse what it cannot enforce

Sandbox::run takes a GrantSet as well as a Command. That is not decoration: it is the whole contract. An implementation that cannot confine a child to the granted authority must return SandboxError::Unenforceable rather than run it anyway.

The alternative — a sandbox that accepts any grant and enforces whichever parts it happens to implement — produces a system where the compiler proved a property that the runtime silently does not hold. Refusal keeps the failure loud and local.

§Unconfined is not a sandbox, and says so

It runs the command as this process’s user, on this machine, with this machine’s filesystem. It enforces a working directory, a timeout, and a cleared environment, and it enforces nothing else. It is named for what it is so that no flow definition can contain it by accident, and it is behind the unconfined feature so that a deployment can make it impossible to build.

What it does do is refuse honestly: any grant beyond reading the workspace and executing the named program is SandboxError::Unenforceable, because those are the only two it can even pretend to. That makes it useful for M3 — the compile and test checkers need nothing else — without it ever claiming containment it does not provide.

Structs§

Command
What to run, and under what limits.
Outcome
What running a command produced.
Unconfined
Runs commands on this machine, with no isolation whatsoever.

Enums§

SandboxError
The command could not be run under the authority it was given.

Constants§

DEFAULT_TIMEOUT
How long a checker’s command may run before it is killed.
MAX_OUTPUT
How much of a command’s output is kept.

Traits§

Sandbox
Runs a command under a grant, or refuses to.

Functions§

normalise
A path as a grant resource writes it: forward slashes, no trailing one.
workspace_grant
The grant a checker needs to run program over workspace, and no more.