SpolettaDocs

Reference

Keeping steps safe

Agents and scripts run code nobody reviewed: what a model decides to run, what a flow's author wrote, what a repository's build scripts do. So Spoletta treats every step as hostile. A step can't read the instance's secrets, can't see other runs, can't reach the internet except at the hosts its project's owners allow, and can't make the trusted side run its code.

Who is trusted

A step's program, its coding agent (pi or Claude Code) and whatever it runs for an agent, or bash for a script, is assumed to read anything it can reach, run anything, and leave traps in whatever it can write. The worker is trusted: it gets a step's directories ready, starts the step's program, and takes back what it made. The webapp holds every secret and hands steps short-lived tokens instead.

No secrets in steps

This holds however steps run, sandboxed or not:

WhatHow a step gets it
Model keysNever. Every model call goes through the webapp's model proxy with a token that lasts as long as the step, and the proxy swaps it for the real key, sealed in the database or kept in the webapp's environment. This works with every model provider, custom gateways included. The proxy also records the tokens each call used. Claude Code gets the step's token as its API key, or on Bedrock as a Bedrock API key, and never signs in otherwise: no Claude.ai sign-in, OAuth token or person's ~/.claude reaches it, and the step fails should it say it signed in with anything else.
MCP servers and connectorsThe same way: a token of the step's, which the webapp's MCP proxy swaps for the real one, adding the headers an owner gave the server.
Services' secretsNever. A step calls a service of its own through the webapp's credential proxy, with a token of the step's, and the proxy adds the credential's secret.
GitA token of its own. In Legacy, with a GitHub App, it covers only the run's repositories and lasts an hour; otherwise it is the project's own git token, else the instance's GIT_TOKEN, neither short-lived, and the flow's settings say so. In any other project it is the project's own git token, or none. A step that would outlive its token is stopped cleanly.
Environment variablesOnly those it needs, from a list (PATH, HOME, the locale, pi's settings, proxies and certificates, who commits), never the worker's own. CHILD_ENV names more, comma-separated, for scripts of Legacy that need a token of their own; agents can read those too. Prefer a credential, which keeps the token out of steps.
  • The worker takes requests only from the webapp, when WORKER_TOKEN (or a file named in WORKER_TOKEN_FILE) is the same in both. Without it, anything reaching the worker's port can run bash on it.
  • A step's private files, its prompt, skills and tokens, only that step can read, and they are deleted when it ends.
  • Each agent step gets a fresh pi agent directory, so no credentials or caches pass from one step to the next.

Claude Code

An agent running with Claude Code is kept to what the worker writes for it. It reads no user, project or local settings, so a repository's .claude/settings.json hooks never run and its CLAUDE.md, skills and agents aren't loaded. It gets no MCP servers but the step's, no auto-memory, and sends nothing but its model calls. Its tools are a list: Bash, Read, Edit, Write, WebFetch, NotebookEdit, and Skill when the step has skills, with no subagents and no web search. Its config directory, which keeps its transcript and its own state and never a credential, is its session's own, so a follow-up carries on from it.

To use a GitHub App, give the webapp GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID and GITHUB_APP_PRIVATE_KEY (or a file in GITHUB_APP_PRIVATE_KEY_FILE), and GITHUB_API_URL for GitHub Enterprise. Only Legacy's steps get its tokens and GIT_TOKEN; another project's owners set a git token of its own.

Between projects

Each project's steps reach only its own. The model, MCP, credential and internet proxies take a step's token as its project's, reach only that project's keys, providers, servers, credentials and hosts, and refuse anything else; what they do goes in that project's audit log and spending. On the worker, each project's shared repositories are kept apart, so a step gets nothing another project's steps fetched, nor their runs' branches. A step of a project other than Legacy gets none of the worker's own configuration: its pi config, AWS_* and CHILD_ENV variables, and git config.

  • SANDBOX=process keeps nothing apart between projects, as it keeps nothing apart between steps: a step can read every project's workspaces and shared repositories, and the worker's environment. Run steps in containers or pods once projects are anyone's but one team's.
  • The addresses a project's owners set, a model provider's, an MCP server's, a connector's and a credential's, are called from the webapp, private addresses included, so an owner of any project can have the webapp call a service on its network. Only the internet proxy keeps a project other than Legacy to public addresses. Make owners only those you would trust with that.
  • Deleting a project for good removes its shared repositories from the worker too. Should the worker be out of reach then, they stay on its workspaces volume, under .projects/<id>, and the webapp's log names them, to be removed by hand.

A sandbox for each step

SANDBOX, set on the worker, picks where steps run. It has no default: a worker without it doesn't start, and says which to choose, so running steps without isolation is always something someone chose.

SANDBOXEach step runsIt seesIt reaches
processas a process of the worker'swhat the worker seeswhat the worker reaches
podmanin a throwaway container of its ownits own directoriesonly the webapp
dockerin a throwaway container of its own, with Docker 26 or laterits own directoriesonly the webapp
kubernetesin a pod of its ownits own directorieswhat network policies allow, checked as the worker starts

A step's container or pod:

  • runs as a user that isn't root (SANDBOX_USER, 1000:1000), with a read-only root filesystem, every Linux capability dropped, no privilege escalation and the default seccomp profile;
  • has limits on memory, CPUs and processes (SANDBOX_MEMORY_MB, SANDBOX_CPUS, SANDBOX_PIDS);
  • can run under gVisor's runsc or another runtime, for a kernel of its own (SANDBOX_RUNTIME);
  • sees only its run's workspace, its own files, its session, its private directory (read-only) and its run's home. Other runs it can't see at all.

Each run has a home directory of its own, outside every checkout. Tools and caches one step installs there stay for the run's later steps and follow-ups, while each step stays in a container of its own.

Checkouts the trusted side never runs git in

A step writes its checkout, its git config, hooks and attributes included, so it may be booby-trapped: a hook, an fsmonitor or a filter runs for whoever runs git there. So the worker never does. What a step left uncommitted is committed inside a sandbox with no network, which sees only the checkout. The worker then fetches the branch from the checkout, which runs nothing the step planted, and checks each object the step made as it does: a malformed one, crafted to trip up whoever reads it, keeps the branch from coming back. Spoletta tests this against planted traps.

The network

Under podman or docker, steps' containers sit on an internal network that reaches only the webapp. Models and MCP servers they reach through the webapp's proxies, and the internet through its egress proxy, with a token of the step's. The egress proxy reaches only:

  • the hosts the project's owners allow in Settings, under Internet access: a name such as registry.npmjs.org, *.example.com for its subdomains, with :port for a port other than 80 and 443;
  • the hosts of the step's own repositories, so its git pushes work.

It dials only public addresses, but in Legacy a host its owners allowed by name may be at a private one, so neither an allowed name nor a repository URL can lead a step to the database or the webapp's neighbours. Not public are the private ranges, shared address space (100.64.0.0/10, where many clusters keep their pods and services), and the IETF's, benchmarking and reserved ranges. The machine's own, link-local (the cloud's metadata service), multicast and 0.0.0.0/8 addresses are never dialled, allowed or not. An IPv4 address written as IPv6, such as ::ffff:100.64.0.1, gets the same rules. Every connection, and every refusal, goes in the run's log. A step's access, its open connections included, ends with the step. Committing a step's leftover changes gets no network at all.

Turning it on with compose

compose.sandbox.yaml builds the steps' image, gives the worker the engine's socket, and puts the webapp on the internal network spoletta-sandbox:

sh
# Podman, rootless
podman compose -f compose.yaml -f compose.sandbox.yaml up --build -d
# Docker 26 or later
SANDBOX=docker CONTAINER_SOCKET_HOST=/var/run/docker.sock \
  docker compose -f compose.yaml -f compose.sandbox.yaml up --build -d

On a Mac, Podman's socket is inside its machine: podman info --format '{{.Host.RemoteSocket.Path}}' says where, and CONTAINER_SOCKET_HOST takes it.

Turning it on in Kubernetes

With SANDBOX=kubernetes, each step runs in a pod beside the worker's, made with the worker's service account. The pod has the same limits as a container, a memory-backed /tmp, no service account token, and each of its directories is a subPath of the worker's volume claims. Claims only one node mounts (ReadWriteOnce) keep steps' pods on the worker's node, by a node affinity naming it, through the scheduler rather than by nodeName: the pod takes the worker's pod's tolerations, and runs there even when the node is cordoned. With ReadWriteMany claims, set SANDBOX_SAME_NODE=false, and the scheduler picks any node. Kubernetes has no process limit per pod, so set the kubelet's podPidsLimit.

  1. Let the worker make pods

    worker-rbac.yamlyaml
    apiVersion: v1
    kind: ServiceAccount
    metadata: {name: spoletta-worker, namespace: spoletta}
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata: {name: spoletta-worker, namespace: spoletta}
    rules:
      - apiGroups: [""]
        resources: [pods]
        verbs: [create, get, list, delete]
      - apiGroups: [""]
        resources: [pods/log]
        verbs: [get]
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata: {name: spoletta-worker, namespace: spoletta}
    subjects: [{kind: ServiceAccount, name: spoletta-worker, namespace: spoletta}]
    roleRef: {apiGroup: rbac.authorization.k8s.io, kind: Role, name: spoletta-worker}
  2. Run the worker as the steps' user, with its own name

    the worker's podyaml
    spec:
      serviceAccountName: spoletta-worker
      securityContext: {runAsUser: 1000, runAsGroup: 1000, runAsNonRoot: true}
      containers:
        - name: worker
          image: registry.example.com/spoletta-worker
          env:
            - {name: SANDBOX, value: kubernetes}
            - {name: SANDBOX_IMAGE, value: registry.example.com/spoletta-sandbox}
            - {name: STEPS_DIR, value: /data/steps}
            - {name: POD_NAME, valueFrom: {fieldRef: {fieldPath: metadata.name}}}
            - {name: WORKER_TOKEN, valueFrom: {secretKeyRef: {name: spoletta, key: worker-token}}}
          volumeMounts:
            - {name: data, mountPath: /data/files, subPath: files}
            - {name: data, mountPath: /data/workspaces, subPath: workspaces}
            - {name: data, mountPath: /data/steps, subPath: steps}
      volumes:
        - {name: data, persistentVolumeClaim: {claimName: spoletta-data}}

    The webapp mounts the same files, read-only.

    SANDBOX_IMAGE is the steps' image, built from worker/sandbox.Containerfile. Where agents run with Claude Code, build it with the same CLAUDE_CODE_VERSION as the worker's; see Claude Code.

  3. Hold steps' pods to the webapp

    Steps' pods are labelled spoletta.sandbox/network: webapp for those that may reach the webapp, offline for those that may reach nothing. With a network plugin that enforces network policies:

    step-network.yamlyaml
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata: {name: spoletta-steps, namespace: spoletta}
    spec:
      podSelector: {matchLabels: {spoletta.sandbox/network: webapp}}
      policyTypes: [Ingress, Egress]
      egress:
        - to: [{podSelector: {matchLabels: {app: spoletta-webapp}}}]
          ports: [{port: 8080}]
        - to: [{namespaceSelector: {}, podSelector: {matchLabels: {k8s-app: kube-dns}}}]
          ports: [{port: 53, protocol: UDP}, {port: 53, protocol: TCP}]
    ---
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata: {name: spoletta-steps-offline, namespace: spoletta}
    spec:
      podSelector: {matchLabels: {spoletta.sandbox/network: offline}}
      policyTypes: [Ingress, Egress]

    Set the webapp's PROXY_URL to its service's address, such as http://spoletta-webapp.spoletta:8080, which steps reach through these policies.

When the cluster has no room

A step's pod asks for 256 MiB and a tenth of a CPU. While no node it may run on has that much left, the scheduler holds it pending, and starts it once one has, as other steps end. The step's log says so, with the scheduler's reason, such as 0/3 nodes are available: 3 Insufficient cpu, again each minute it waits, and how long it waited once it starts.

  • Turned away before it ran. The pod is deleted and made again 5 seconds later when the kubelet turns it away as it comes (OutOfcpu, OutOfmemory, OutOfpods), a resource quota of the namespace refuses it (exceeded quota), or the API asks for fewer requests (429). Any other refusal fails the step at once, such as a role that doesn't let the worker make pods.
  • Never run twice. A pod is never made again once its container ran, so a script never runs twice. An evicted pod fails its step, as it may have run.
  • Two minutes at most. Pending or made again, a step waits for room 2 minutes at most, then fails as one that couldn't start, saying why, such as no room on the cluster after waiting 2m0s: 0/3 nodes are available: 3 Insufficient cpu. Its process's retries, if it has any, try it again. The wait counts toward the step's time limit, its process's own or else the worker's RUN_TIMEOUT_MS, 10 minutes unless set, so a step with less time left gives up sooner.
  • Where room comes from. Pinned to the worker's node, a step waits for the steps there to end. With SANDBOX_SAME_NODE=false, the cluster's autoscaler, if it has one, can add a node for it. The worker's role needs nothing more for this: it reads why a pod waits from the pod's own status, not from events.

Credentials

A step calling a service of its own, such as Jira or an internal API, uses a credential the project's owners keep under Settings → Credentials. Its secret is sealed with the secret key and never sent back to the browser, the worker or the step. The step gets a URL per credential at the webapp's proxy, and one token for them all, which ends with the step. The proxy swaps the token for the secret and passes the call on.

What a step can do with a credential is call its service, at paths under its base URL, while it runs. It can't:

  • read the secret. It is blanked out of what the service answers, headers and body, in the forms it went out in and those a service could echo it in: URL-encoded, base64, escaped in JSON or HTML, and any eight of its characters in a row.
  • hand its token to someone else. The step's tokens are blanked out of what is kept of it: what a script prints, an agent's conversation, the run's log and the worker's. They reach nothing once the step ends.
  • reach other paths or hosts. A path stepping out of the base URL is refused, as are paths with a ;, an encoded slash or a character outside ASCII, which some servers read as a step up. The proxy never follows a redirect, and never dials a link-local address such as a cloud's metadata service.
  • send the call as something else. Only the usual request headers go on, and those the credential names; none that some servers take as another URL, host, method or client.
  • keep a session got with it. Only the headers saying what an answer is come back: no cookies. And what comes back is sandboxed, so an answer opened in a browser can't act as the app.
  • use a credential its process didn't pick, or one its flow may no longer use. Which a run's steps get is what its version picked, so a draft can't hand a run a credential.

An owner's edit can't send a kept secret elsewhere either: changing a credential's base URL, or where its secret goes on a request, needs the secret again.

A request may send at most 64 MB, and a call take ten minutes. Each call goes in the run's log and the audit log by its method, credential, path and status, never with the secret or the token.

Spending and limits

A project's owners set its limits in Settings, under Spending & limits, in the Limits card, each with its unit in its field; Save limits can be pressed once one changed. Everyone else sees there what they spent, and the limits that apply to them as values they can't change. Each limit is off until it is set. A person's monthly spending and the steps their runs have going at once count in each project apart.

Over every project's limits, admins of Spoletta set ceilings, in the settings' Instance group, under Ceilings: The most any project's runs and people may use, whatever its owners set. An empty field is no ceiling. An owner can save no limit above its ceiling: the field says so, such as a run may spend at most $5.00, the instance's ceiling. What holds in a project is the lesser of its own limit and the ceiling, so a ceiling lowered holds at once, even over a limit set higher before, and that project's owners can save no limits until they bring that one down. Under each field, the tab says what holds, and marks a limit the ceiling holds to as the instance's ceiling.

Settings, Spending & limits tab. The tiles read $7.37 spent in November 2026 (each person up to $150.00), 29 model calls at $0.25 a call on average, and 0 without a known price: every call had its model's price. The Limits card, where an empty field means no limit, has $5 a run may spend, $150 a person may spend a month, 6 steps a person's runs may have going at once and 4096 MB of disk a run may take, each explained beneath, and reads Saved beside Save limits. By person, for November 2026, shows Maya Okafor $6.38 (25 calls, 4% of the month's limit), Tom Reyes $0.49 and Jonas Berg $0.49. Costliest runs, with their subflows and follow-ups, each of which may spend $5.00, ranks ten Production incident triage runs, from run 155 at $0.61 down to run 151 at $0.51.
Spending & limits: the month at a glance, the limits, and spending by person and by run.
LimitWhat it does
Most a run may spend ($)Covers the run with its subflows, list items and follow-ups. Once the run has spent it, its model calls are refused and the run is stopped and fails. A flow can set a lower limit for its own runs in its settings, under Spending; when both are set, the lower applies.
Most a person may spend a month ($)Covers their runs, follow-ups and flow assistants, by calendar month in UTC. Once they pass it, their agents' model calls are refused until the next month.
Steps a person's runs may have going at once (steps)Agent, script and connector steps, out of PARALLEL_STEPS, so one person's runs can't take every slot, counted across every replica of the webapp. Their other steps wait their turn without holding one.
Disk a run may take (MB)Its checkouts, agents' sessions, home and generated files, checked after each step by the disk blocks they really take: a sparse file counts as what it holds, hard-linked files once. A step that leaves its run over the limit fails, but its work is still committed.

Every model call goes through the model proxy, which prices it at the model's price in pi's catalog or the worker's models.json, cache reads and writes included. Claude Code's calls are counted the same way, on Bedrock too, as are the few it makes on Bedrock as it starts. A model without a known price is counted at the price of the largest models, so a limit is never passed unseen. A run stopped for spending fails with the reason in its step and its log, such as it was stopped, as its run spent $5.02 on its models, and may spend $5.00. Calls already under way finish, so a run with steps going in parallel can spend a little more than its limit. Limits hold across every replica of the webapp, and a change reaches them all within 5 seconds.

Above the limits, three tiles give the month at a glance, such as Spent in October 2026: what was spent, naming each person's monthly limit when one is set; how many model calls were made, with the average a call cost; and Without a known price, how many of those calls had a model without a known price, which are counted at the largest models' price. With none, it reads every call had its model's price. Below them, side by side:

  • By person: who spent most this month, with how many of their calls had no known price. Runs no one signed in started are listed as Runs nobody started. With a monthly limit set, each bar fills toward it and shows the percent used, red once it is reached.
  • Costliest runs: the runs that spent most, by flow name and run number, each linking to its run. With a run limit set, the heading says so, such as each may spend $5.00.

Bars compare the amounts, so they are left out where every amount reads the same; under By person, they still show while a monthly limit is set.

A run's panel shows what it spent and its limit.

The audit log

Each project keeps its own, which its owners open in Settings, as the Audit log tab under Oversight, at #/p/<project>/settings/audit, where it fills the window beside the tabs. The old #/audit address still opens it, a ?q= search included, and so does Audit log in the command palette. Each event says when, its kind, which run and which step, and what happened, and who where it names someone; tokens and keys are never written in it. It records:

  • every token a step is given for its models, MCP servers, internet access, credentials and git, and when its model, internet and credential tokens end;
  • every internet connection, allowed or refused, and every call through the credential proxy;
  • every delivery to a webhook, never what it carried;
  • model calls refused, and runs stopped for spending their limit;
  • owners' changes to limits, allowed internet hosts, model keys, credentials and webhooks;
  • the project renamed, who is given it by hand and by group, and what everyone else signed in may do there.

It is searched as a flow's stored data is, with facets, a query bar and a time range. It asks for the latest events every 10 seconds, and Refresh, beside the search, at once. Above the table it says how many events show of how many, such as Showing 500 of 1,284 events. The Who column shows only when an event shown names someone, and the Run and Step filters start folded, as each row links to its run. Its kinds include model.grant, model.refused, internet.connect, internet.refused, git.grant, run.overspent and limits.set:

text
kind:internet.refused run:42
kind:model.refused