The Warden
The Mandate Warden is an HTTP gateway that sits between an agent and the Fly.io Sprites connectors. It runs on its own Sprite, the only one allowed to use the connectors. The agent runs on a second Sprite whose network is locked so it can only reach the Warden.
For each call, the Warden:
- Recovers which agent signed the request.
- Classifies the call into an action, a resource and (sometimes) a recipient.
- Asks
mandate-corewhether the agent's mandates allow it. - On a deny, answers
403with a reason. On an allow, forwards the call through the connector, which attaches the real credential. The Warden never holds a GitHub or Ollama token.
Every decision is written to a log that the dashboard and GET /v1/state read.
HTTP API
| Route | Auth | What it does |
|---|---|---|
GET / | none | The live dashboard: the path every call takes, decisions, mandates, owner controls, and a "Try to break it" panel that sends unsigned, forged and stale calls |
GET /health | none | ok |
GET /v1/state | none | Owner, labels, mandates, revocations, the last 200 decisions and the known-good checkpoint |
GET /v1/proof | none | What the agent can reach, read live from the Sprites API (cached 60 s), and whether GitHub and Ollama go through connectors or Warden-held tokens. No secrets |
POST /v1/mandates | none | Submit a mandate someone else signed, such as an agent delegating to a sub-agent. It is stored only if its chain leads back to the owner and is valid now. Body: { "mandate": {...}, "label": "..." } (label up to 64 characters) |
POST /v1/admin/mandates | admin | The owner signs a root mandate (see Granting mandates) |
POST /v1/admin/revoke | admin | The owner revokes one of its mandates. Body: { "mandateId": "0x...", "reason": "..." } |
POST /v1/admin/agent/checkpoint | admin | Checkpoint the agent Sprite. Body: { "comment": "...", "markGood": true }. With markGood, it becomes the restore target |
POST /v1/admin/agent/restore | admin | Restore the agent Sprite. Body: { "checkpoint": "v5" }, or empty to use the known-good one |
ANY /v1/gateway/github/{path} | agent signature | A GitHub REST call, e.g. /v1/gateway/github/repos/OWNER/REPO/issues |
ANY /v1/gateway/ollama/{path} | agent signature | An Ollama API call, e.g. /v1/gateway/ollama/api/chat |
Admin routes accept an owner signature, and still accept Authorization: Bearer $WARDEN_ADMIN_TOKEN so the dashboard keeps working. The bearer token is a shared secret: prefer the signature. A request that sends either admin header is checked as a signature and is not silently accepted with the token instead.
Signing an admin request
| Header | Value |
|---|---|
x-mandate-admin-timestamp | Unix seconds |
x-mandate-admin-signature | 0x + 65-byte EIP-191 signature over the digest below |
digest = keccak256(
"mandate-admin/1\n" + METHOD + "\n" + path_and_query + "\n" + timestamp + "\n" + "0x" + hex(keccak256(body))
)path_and_query is the Warden path, for example /v1/admin/mandates. The recovered signer must be the Warden's owner address (GET /v1/state field owner). The same 60 s window and one-time signature rules as agent calls apply. Auth errors return 401 with MISSING_ADMIN_AUTH, BAD_TIMESTAMP, STALE_REQUEST, BAD_SIGNATURE, NOT_OWNER or REPLAYED_REQUEST.
The owner key lives in WARDEN_DATA/owner.key (0x + 32-byte hex). Sign with that key. The Warden still uses it to sign the mandate or revocation it records.
Signing a request
An agent proves who it is with three headers:
| Header | Value |
|---|---|
x-mandate-agent | The agent's address, 0x… |
x-mandate-timestamp | Unix seconds |
x-mandate-signature | 0x + 65-byte EIP-191 (personal_sign) signature over the digest below |
digest = keccak256(
"mandate-call/1\n" + METHOD + "\n" + path_and_query + "\n" + timestamp + "\n" + "0x" + hex(keccak256(body))
)path_and_query is the full Warden path, starting with /v1/gateway/. The Warden treats the recovered signer as the mandate subject, not the claimed address, and rejects the call if they differ. Auth errors return 401 with one of these codes:
MISSING_AUTHBAD_TIMESTAMPSTALE_REQUEST(more than 60 s of clock skew)BAD_SIGNATURESIGNER_MISMATCHREPLAYED_REQUEST(a signature can be used only once)
warden-call and mandate-agent sign for you. Both read MANDATE_AGENT_KEY (hex) and MANDATE_WARDEN_URL.
warden-call keygen # new agent key and address
warden-call GET repos/OWNER/REPO/issues
warden-call POST repos/OWNER/REPO/issues '{"title":"hi"}'
warden-call --ollama POST api/chat '{"model":"gpt-oss:120b","stream":false,"messages":[{"role":"user","content":"hi"}]}'
mandate-agent "Triage the open issues and label anything that is a bug"How calls are classified
GitHub. The resource is github:OWNER/REPO for paths under repos/OWNER/REPO/, otherwise github:account.
| Call | Action | Recipient |
|---|---|---|
any GET / HEAD | read | |
POST issues | issues.create | |
POST issues/N/comments | issues.comment | |
PATCH issues/N | issues.update | |
POST issues/N/labels | issues.label | |
POST pulls | pulls.create | base branch |
PUT pulls/N/merge | pulls.merge | |
PUT contents/... | contents.write | branch from the body, default main |
DELETE contents/... | contents.delete | branch from the body, default main |
POST git/refs | refs.create | the new branch |
PATCH / DELETE git/refs/heads/NAME | refs.update / refs.delete | NAME |
POST git/blobs, git/trees, git/commits | git.objects | |
other DELETE | delete | |
| write outside a repo | account.write | |
| anything else | other.<method>.<first segment> |
Ollama. The resource is always ollama:cloud, and the recipient is the model field. Ollama calls never trigger checkpoints.
| Call | Action |
|---|---|
POST api/chat | model.chat |
POST api/generate | model.generate |
GET api/tags | model.list |
| anything else | other.<method>.<last segment> |
The other.* actions exist so that no mandate grants them by accident. Anything the classifier doesn't recognise is denied.
Decisions
An allowed call returns the upstream response with x-mandate-decision: allow and x-mandate-mandate-id. A denied call returns 403 with x-mandate-decision: deny:
{
"decision": "deny",
"reason": "RECIPIENT_NOT_ALLOWED",
"message": "Target main is not one of the allowed: agent/fix.",
"action": "contents.write",
"resource": "github:OWNER/REPO",
"recipient": "main",
"mandateId": "0x…",
"delegationPath": ["0x…owner", "0x…agent"],
"note": "agent restored to its last known-good checkpoint"
}reason is a stable code from mandate-core: NO_MANDATE, ACTION_NOT_ALLOWED, RESOURCE_NOT_ALLOWED, RECIPIENT_NOT_ALLOWED, AMOUNT_EXCEEDED, EXPIRED, REVOKED, ANCESTOR_REVOKED, INVALID_SIGNATURE, INVALID_DELEGATION or UNTRUSTED_ROOT. note is present only when the Warden did something extra, such as a restore.
Other errors: 400 BAD_PATH (a path segment is empty, . or .., or contains an encoded dot, slash, backslash or NUL), 502 UPSTREAM_ERROR (the connector call failed; details are in the Warden's log, not the response), 503 NO_CONNECTOR (neither a connection nor a direct credential is configured for that provider), 413 BODY_TOO_LARGE (over 5 MiB).
Configuration
| Variable | Default | Purpose |
|---|---|---|
PORT | 8080 | Listen port |
WARDEN_DATA | warden-data | Directory for owner.key, store.json and decisions.jsonl. The owner key is created on first run |
WARDEN_ADMIN_TOKEN | unset | Legacy shared secret for the admin routes. Owner signatures work without it |
GITHUB_CONNECTION_ID | unset | Sprites GitHub connection to forward through |
OLLAMA_CONNECTION_ID | unset | Sprites Ollama connection to forward through |
GITHUB_TOKEN | unset | Outside Sprites: a GitHub token the Warden calls the API with directly. Ignored when GITHUB_CONNECTION_ID is set |
GITHUB_API_URL | https://api.github.com | GitHub API base for direct mode (GitHub Enterprise) |
OLLAMA_URL | unset | Outside Sprites: Ollama base URL for direct mode, e.g. http://host.docker.internal:11434 or https://ollama.com. Ignored when OLLAMA_CONNECTION_ID is set |
OLLAMA_API_KEY | unset | Bearer key for OLLAMA_URL (Ollama cloud) |
SPRITES_TOKEN | unset | Sprites API token; needed for checkpoints and restores |
AGENT_SPRITE | mandate-agent | The Sprite to checkpoint and restore |
WARDEN_CHECKPOINT_ON_WRITE | off | Checkpoint the agent before every allowed write (timeout 60 s) |
WARDEN_RESTORE_ON_DENY | off | Restore the agent to the known-good checkpoint after a denied write |
SPRITES_GATEWAY | https://api.sprites.dev/v1/gateway | Connector gateway base URL |
SPRITES_API | https://api.sprites.dev | Sprites management API base URL |
The agent side reads MANDATE_AGENT_KEY and MANDATE_WARDEN_URL. mandate-agent also reads:
MANDATE_REPO(defaultdicethedev/mandate-demo)MANDATE_MODEL(defaultgpt-oss:120b)MANDATE_MAX_STEPS(default12)
Setting up two Sprites
You need the sprite CLI, logged in to your Fly.io organization.
- Create two Sprites:
mandate-wardenlabelledrole:warden, andmandate-agentlabelledrole:agent. - Add connectors. In Sprites, connect GitHub (with access to the repository the agent works on) and Ollama. Note each connection ID.
- Lock the connectors to the Warden. Give each connection an access policy that allows only the Warden: its name prefix
mandate-wardenand labelrole:warden. To check, call the connector gateway from both Sprites. The Warden should get200and the agent403. - Lock the agent's network. Set the agent Sprite's network policy to allow only the Warden's URL and deny everything else.
- Configure secrets. Create
.env.sprites(gitignored) in the repository root withWARDEN_ADMIN_TOKEN(any long random string),GITHUB_CONNECTION_ID,OLLAMA_CONNECTION_IDandSPRITES_TOKEN. - Deploy. Run
scripts/deploy-warden.sh. It builds in release mode, installsmandate-wardenon the Warden Sprite as thewardenservice (port 8080, with checkpoint-on-write on), and copieswarden-callandmandate-agentto the agent Sprite's~/bin. - Make the agent a key. On the agent Sprite, run
warden-call keygen. KeepMANDATE_AGENT_KEYon that Sprite only, and setMANDATE_WARDEN_URLto the Warden's public URL. - Mark a known-good state. Run
POST /v1/admin/agent/checkpointwith{"markGood": true}, so restores have a target.
Granting mandates
The Warden's owner key signs root mandates. expiresIn is in seconds and defaults to seven days.
Let the agent think with one model only:
curl -X POST "$WARDEN/v1/admin/mandates" \
-H "authorization: Bearer $WARDEN_ADMIN_TOKEN" -H 'content-type: application/json' \
-d '{
"subject": "0xAGENT",
"label": "mandate-agent",
"action": "model.chat",
"resource": "ollama:cloud",
"allowedRecipients": ["gpt-oss:120b"]
}'Let it read the repository and open issues:
for action in read issues.create issues.comment; do
curl -X POST "$WARDEN/v1/admin/mandates" \
-H "authorization: Bearer $WARDEN_ADMIN_TOKEN" -H 'content-type: application/json' \
-d "{\"subject\":\"0xAGENT\",\"action\":\"$action\",\"resource\":\"github:OWNER/REPO\"}"
doneLet it write files only on its own branches:
curl -X POST "$WARDEN/v1/admin/mandates" \
-H "authorization: Bearer $WARDEN_ADMIN_TOKEN" -H 'content-type: application/json' \
-d '{
"subject": "0xAGENT",
"action": "contents.write",
"resource": "github:OWNER/REPO",
"allowedRecipients": ["agent/fix"]
}'Revoke any of them with POST /v1/admin/revoke. Revocation takes effect on the next call.