SendBox · Architecture
Host Agent Orchestration
Status: production transport-neutral orchestration. sendbox-agent owns an
immutable run plan and the pure host-side state machine. sendbox-host composes
it with CLI run, concrete Apple/Kata/Hyperlight adapters, guest platform
controls, MCP, and security persistence without adding those dependencies to the
orchestration crate.
Run sequence
- Validate
SandboxConfigurationand compile workspace, mount, environment, command, workload-secret, package-policy, capability, and transport intents intoRunPlan. An optional enclosing workspace becomes the signed mount root while the initial cwd and Git guard stay bound to the selected project. - Reject missing runtime, brokered-exec, or transport capabilities before resource creation. Package-enabled plans additionally require authenticated audit/report capability.
- Preflight, initialize, create, and start the selected runtime.
- Resolve redacted bootstrap material, including registry-only credentials that cannot overlap workload secrets, provision a lifecycle-owned channel, and accept exactly one stream before the readiness deadline.
- Authenticate the expected session with
sendbox-protocoland verify guest exec, streamed-I/O, and health capabilities. - Resolve named secret envelopes through an injected trait and send references plus envelopes to the guest. Debug output never exposes envelope bytes.
- Launch and monitor the workload through the guest channel. Runtime
execremains bootstrap/control-only. - After a terminal response, fetch the bounded package report exactly once
when package analysis is enabled, fetch a single bounded syscall report
when tracing is requested, then gracefully close the authenticated
session. The guest report is returned to
sendbox-hostfor independent digest/schema validation and owner-only atomic persistence. - On success, signal, cancellation, transport loss, service death, report failure, or backpressure, clean up guest execution, guest session, channel, runtime stop, and runtime resources in order.
Native CLI profiles do not change this state machine or add a host execution path. Requested syscall tracing additionally requires authenticated readiness for the mandatory BPF service. Guest homes are session-specific and never inherit the host home. See CLI compatibility.
RunFailure preserves the primary error and every cleanup failure separately.
Cancellation uses explicit tokens and an injected signal source. Readiness uses
a bounded Tokio deadline; tests use deterministic in-memory or Unix streams and
fault injection rather than vendor processes.
State model
stateDiagram-v2
Planned --> Preflighted
Preflighted --> Initialized
Initialized --> Created
Created --> Started
Started --> ChannelProvisioned
ChannelProvisioned --> GuestReady
GuestReady --> SecretsResolved
SecretsResolved --> Running
Running --> ReportRetrieved
ReportRetrieved --> Cleaning
Running --> Cleaning
Cleaning --> Completed
Planned --> Failed
Preflighted --> Failed
Initialized --> Cleaning
Created --> Cleaning
Started --> Cleaning
ChannelProvisioned --> Cleaning
GuestReady --> Cleaning
SecretsResolved --> Cleaning