Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
brainwires-sandbox
Container-based sandboxing for tool execution in the Brainwires Agent
Framework. Provides a Sandbox trait with Docker / Podman implementations
(via bollard) that isolate tool
invocations from the host: resource limits, read-only root filesystems,
egress-allowlist networking, and whitelisted bind mounts.
┌──────────────────────┐ spawn() ┌─────────────────────┐
│ ChatAgent / │ ──────────────▶ │ SandboxPolicy │
│ brainwires-tool-* │ │ - resource caps │
└──────────────────────┘ │ - mount whitelist │
│ - NetworkPolicy │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ DockerSandbox │
│ (bollard client) │
└──────────┬──────────┘
│
┌──────────────┼──────────────┐
▼ ▼ ▼
┌──────────────┐┌──────────────┐┌──────────────┐
│ tool ││ sidecar ││ internal │
│ container ││ proxy ││ docker net │
│ (read-only) ││ (allowlist) ││ (no egress) │
└──────────────┘└──────────────┘└──────────────┘
Features
| Flag | Default | Enables |
|---|---|---|
docker |
on | DockerSandbox (bollard-backed; works with Docker and Podman sockets). |
unsafe-host |
off | HostSandbox pass-through. Development only. No isolation. |
Quick start
use BTreeMap;
use PathBuf;
use Duration;
use ;
# async
API
Sandbox trait
spawn— create the container, attach stdio, validate every mount against the policy (path components are checked for..traversal and each source iscanonicalized to close the symlink-race window), start the workload. Returns an opaqueExecHandle.wait— stream stdout/stderr, await the container exit. EnforcesExecSpec.timeoutviatokio::time::timeout; on elapse,kill_containeris called explicitly andSandboxError::Timeoutis returned withtracing::warncarryingcontainer_id,elapsed_ms, andtimeout_ms.shutdown— force-remove every container still tracked by this sandbox instance; tears down per-spawn networks and proxy sidecars.
SandboxPolicy
| Field | Purpose |
|---|---|
runtime |
Docker, Podman, or Host (unsafe-host feature only). |
image |
Container image for workloads. |
network |
None, Limited(Vec<String>), or Full. |
cpu_limit |
Cores (e.g. 2.0). None disables. |
memory_limit_mb |
Cap in MiB. None disables. |
pid_limit |
Max processes inside the sandbox. |
read_only_rootfs |
Default true. |
workspace_mount |
Implicitly allowed bind source. |
allowed_mount_sources |
Explicit host-path whitelist for bind mounts. |
proxy_image |
Image for the Limited sidecar proxy. |
proxy_listen_port |
TCP port the proxy listens on inside its container. |
proxy_container_name |
Reuse a named long-lived proxy; default spawns an ephemeral one. |
NetworkPolicy
None—--network=none. No egress, no DNS, no loopback to host.Full— default bridge. No egress controls. Trusted images only.Limited(hosts)— sandbox lives on aninternal: truedocker network with no default route. Abrainwires-sandbox-proxysidecar is attached to both that network and the bridge; the sandbox receivesHTTP_PROXY/HTTPS_PROXYenv vars. Only hosts inhostsare forwarded; raw (non-HTTP) TCP is blocked at the network level by design.
Errors
Usage notes
Mount validation is two-stage: SandboxPolicy::validate_mount rejects
paths that aren't lexically inside the whitelist or contain ..
components; DockerSandbox::spawn then canonicalizes each source and
re-validates the resolved path. A symlink swapped between those steps is
rejected with SandboxError::PolicyViolation.
Podman is selected by setting policy.runtime = SandboxRuntime::Podman.
The socket path is taken from PODMAN_SOCKET (default
unix:///run/podman/podman.sock).
HostSandbox (feature unsafe-host) runs the requested command
directly on the host with no isolation. It exists for local development
only and must never be enabled in production — DockerSandbox::connect
refuses SandboxRuntime::Host explicitly.
Consumed by
brainwires-tool-builtins uses the Sandbox trait to execute bash / python tool
calls under isolation; brainwires-agent composes per-agent sandbox
policies.