Architecture
Three layers. None inside the agent.
On this page
The three layersLink to this section
Text description
Three stacked layers, connected top to bottom.
01 Runtime & Sandbox, implemented: Firecracker microVM or two-network Docker sandbox, Squid egress allowlist, wall-clock kill switch. Code in internal/sandbox/.
02 Identity & Governance, implemented: did:key identity (the W3C CCG method), an audit log signed and hash-chained with an identity, human gates at the MCP proxy, per-run and per-day USD ledger. Code in internal/identity/, internal/audit/, internal/mcpgate/, internal/spending/.
03 Communication, implemented: A2A with Ed25519-signed envelopes, signed and verified host-side, declared peers only, no discovery by design. Code in internal/a2a/.
Layer by layerLink to this section
Layer 1 · Runtime and sandboxLink to this section
A two-network Docker sandbox (the default) or a Firecracker microVM. On Docker, the agent's network has no route out, and your host has no address on it. Whether DNS lookups can leave through Docker's own resolver is untested. On Firecracker the proxy runs on the host, which drops everything from the guest but the proxy and the run's gates. The agent reaches the internet through a Squid proxy that allowlists network.allowed_hosts by name, and a wall-clock kill switch stops the agent when limits.max_duration_seconds elapses. Both backends render their proxy policy from the same function, so Docker and Firecracker enforce one ruleset rather than two that drift. Details: Network isolation.
Layer 2 · Identity and governanceLink to this section
A did:key identity (the W3C CCG method) whose private key never enters the sandbox (Identity). A JSONL audit log: with an identity, each line is signed with the agent's own key (Ed25519) and chained to the one before (Audit log). Human approval at the MCP gate: name a tool, and its calls that pass through the gate wait for a yes (Human gates). A per-run and per-day USD ledger that counts priced tool calls that pass through the gate (Spend caps). With a daily cap, the daily ledger is durable across runs and keyed by DID, so renaming an agent does not reset its spend.
Layer 3 · CommunicationLink to this section
Agent-to-agent messages as Ed25519-signed envelopes, exchanged only with peers named in the manifest. The host signs and verifies. The sandbox performs no cryptography and is never given a peer's real endpoint. There is no discovery mechanism, by design: an agent can only message the peers its manifest declared before it started. Details: Agent-to-agent.
Where each rule is enforcedLink to this section
Every enforcement point sits outside the sandbox (spec §2.3). The proxy and the tool gate enforce where the agent's traffic passes them:
| Chokepoint | When | Enforces |
|---|---|---|
| Sandbox environment construction | before the agent exists | credentials, sandbox.memory_mb |
| Squid egress proxy | per run | sandbox.network.allowed_hosts |
| MCP gate proxy | per run | mcp.servers[].tools, human_gates.* and spending.* metering, on calls that pass through the gate |
| A2A gate + host listener | per run | a2a.peers authorization, envelope signing and verification |
| Supervisor process | per run | limits.max_duration_seconds |
The first row is the only one that acts before the agent exists rather than while it runs: the environment is composed, the sandbox is started with it, and there is no later moment at which an agent could ask for more.
Constle assumes nothing inside the sandbox is trustworthy. A control that depended on the agent truthfully announcing its own behaviour would be reliable only while it was unnecessary. That is why some intuitively useful fields don't exist: there is no human gate on filesystem writes, because writes have no chokepoint outside the sandbox.
Isolation levels and backendsLink to this section
sandbox.isolation is one of none, process, network or kernel. Each declared capability needs a minimum level, and the strongest of them is the capability floor. Omit isolation: and the runtime uses the floor. Declare it and it may only be equal or stronger, or constle validate rejects the Agentfile, naming the capabilities that set the floor.
The resolved level is a minimum contract, not a preference. Each backend provides a fixed level:
| Docker | Firecracker | |
|---|---|---|
| Provides | network: separate process and network namespaces, shared host kernel |
kernel: a guest kernel behind KVM |
| Route out | Network created --internal with the isolated-gateway option (an Engine that can't provide it is refused), with one on-link route and no default route |
A default route only to the TAP gateway on the host (a /30, no forwarding or NAT). The per-run nftables inet table accepts only the proxy and gate ports and drops everything else from the tap |
| IPv6 | Off, via an explicit --ipv6=false |
Kernel link-local fe80:: only |
| Selected when | The default, or --backend=docker |
When the isolation contract needs kernel (isolation: kernel, or a capability whose floor is kernel), or with --backend=firecracker |
So isolation: kernel selects Firecracker, and when Firecracker is unusable on the machine (it needs KVM and root) the run aborts instead of continuing on Docker. The one way to run on a weaker boundary than the host can build is for an operator to name it:
constle run --accept-isolation=network agent.yamlThe run prints ISOLATION DOWNGRADE ACCEPTED and records both the requested and the achieved level in its run_started audit entry. The flag cannot waive the capability-floor refusal, which fires at validation, before any backend is chosen.
Life of an MCP tool callLink to this section
- The agent calls a name. It calls the address in
CONSTLE_MCP_<ID>_URL, which points at the gate. Constle never passes your MCP servers' real addresses into the sandbox. - The gate reads the call. Only
POST,GETandDELETE, and a JSON-RPC body only onPOST. A body with duplicate or case-colliding keys, any path below the declared endpoint, a query string and a protocol upgrade are all refused. - Tool allowlist. When a server declares
tools, a tool not listed is refused at the gate (mcp_tool_blocked). An empty list allows none, and no list allows all. Tool calls go through the tool checks. The handshake,ping,tools/list, notifications and responses pass. Resource, prompt, completion and logging requests pass only if the server'smethodslist names them, and any other request the agent sends is refused. That list is closed to nine names (theresources/…methods,prompts/list,prompts/get,completion/complete,logging/setLevel), so any other method the agent sends is refused. What the server sends, its own requests and notifications on itsGETstream included, is relayed without method checks. A listed method is forwarded and logged, not tool-checked, gated or metered. - Human gate. If gates are on (
human_gates.enabled: true) and the tool name is inrequire_approval_for, its calls that pass through the gate wait for the terminal or a signed webhook decision. - Forward and meter. The call goes to the declared endpoint only. Priced tool calls that pass through the gate are metered against the server's
pricing. The call that crosses a cap is counted, and the run is stopped. - Record. Gate decisions, tool calls and limit hits are written as they happen. Network events are copied from the proxy's log when the run ends, and the run's last moments can be missing. With an identity, each line is signed with the agent's own key and chained to the one before.
Setting this up for a server, and what the gate does not inspect: MCP tool allowlists.
What never enters the sandboxLink to this section
| Stays on the host | Why |
|---|---|
~/.constle/identities/<name>/ |
The agent's private key, mode 0600. |
mcp.servers[].url |
Real MCP endpoints. Constle never passes them into the sandbox. The agent gets the gate's address. |
a2a.peers[].endpoint |
Real peer endpoints. The agent can only name a peer. |
| Your shell's environment | Nothing from it crosses in except the variables the Agentfile's credentials names. Those do enter, as environment variables the agent can read. |
The url_secret_ref value |
The webhook URL lives in a host environment variable, not the Agentfile. |
~/.constle/webhook-keys/ |
The approver's signing key from constle webhook-keygen. Constle never passes it into the sandbox. You give it to whoever runs the decision endpoint. |
Why the direction of control mattersLink to this section
The agent runs in the sandbox, and the controls run on the host, outside the sandbox. The two are not peers. What the agent gets of them is a proxy address and a set of per-run gate addresses.
A control the agent can reconfigure is a control the agent can be talked into disabling. The agent can reach its gates, because that is how its calls get out, but nothing it sends them changes what they enforce: the policy is read once, before the sandbox starts, and nothing inside the sandbox can change it.
A prompt injection that tells the model to send a document to a host you didn't list does not fail because the model reconsiders. The proxy refuses it, below the model, and the attempt is written to the audit log as a network_blocked event, which is how the operator finds out it happened at all. A host that shares a server with one you allowed is the exception (limitation 2).