Sandbox and harnesses
How Landlock, Docker cages, Request Review command approvals through a spool bridge, read-only guards, per-person run credentials, the container database broker, and Context7 socket forwarding isolate execution.
turbo-12f runs builds, tests, and model sessions inside stacked OS containment boundaries with secrets stripped from child environments. Durable state lives in Postgres, so a cage keeps no network and reaches the database only through a host-side broker.
Inside the cage
- Network disabled: Docker uses
--network none; Landlock filters TCP/Unix sockets. - Secrets scrubbed:
IsForbiddenEnvKeystrips API keys, tokens, and git/linker overrides. - Scoped writes: Read-only roles revert changes; Engineer writes only its lane worktree.
Host-side drivers & proxies
- Harnesses (
agy,omp): Run outside cages behind RPC wrappers and guard hooks, on the requesting person's own credentials. - Context7 socket (
t12-adapter): Proxies docs lookups over a Unix socket withCONTEXT7_API_KEY. - Per-command gate: In
reviewmode, guard hooks ask through a scratch spool that a host bridge copies to theapprovalstable.
Linux Landlock and process limits
landlock_linux.go enforces filesystem and socket sandboxing on Linux with zero external libraries. Re-executing with argv[0] set to "t12-landlock-exec" applies the kernel ruleset before launching the child:
| Kernel feature | Enforcement |
|---|---|
ABI 4 (netTCP) | TCP bind and connect filters on supported kernels |
ABI 5 (MinCageABI) | Required by t12-cage for directory-scoped containment |
| ABI 6 & ABI 9 | Abstract Unix socket/signal scoping (ABI 6) and fsResolveUnix (ABI 9) |
| Process hardening | Sets PR_SET_NO_NEW_PRIVS and caps RLIMIT_NPROC at userTasks() + 8192 |
Docker verification containers and persistent lane cages
On Linux and macOS (MinMacOSMajor = 26), sandbox.go runs checks inside Docker containers with --network none, --cap-drop ALL, --security-opt no-new-privileges, and --pids-limit 8192.
- User & engine resolution (docker_host.go):
ContainerUser()passesuid:gidon Linux and0:0on Darwin (T12_CONTAINER_USERoverrides).ResolveDockerHostandDockerClientEnvselect Docker or Colima sockets underT12_CONTAINER_ENGINE(auto,docker,colima), strippingDOCKER_CONTEXT. - State-home checkouts &
deps-cache: Checkouts mount from<home>/checkouts/with a startup mount probe (24hsweep);node_modulescache under<home>/deps-cache/(8-entry LRU,14dTTL). - Persistent lane cages (
sandbox.StartLane): Starts one background container per lane (t12-lane-<hex>,--label t12.lane=<req>) with.gitmounted read-only to avoid per-turn container startup cost. - Cloud worker uses Docker cages: The
t12-worker.ymljob setsT12_SANDBOX_ADAPTER=dockerforrun,confirm,release-merge, andtry-publish, because Landlock denies every TCP bind and a web project's E2E server (wrangler devon127.0.0.1:8787) could not start under it. APrepare lane cagesstep first pulls (or builds and pushes) the project's cage image, thenscripts/bootstrap-cages.shpulls the pinned runtime and scanner images and the red team's offline npm database. - Offline after install:
devops.InstallsetsNetwork: trueonly whenadapter == "docker"during Project Gate dependency installs;qc,uicheck, andredteamstay offline. - Environment scrubbing (
IsForbiddenEnvKey): Strips API keys, tokens,DATABASE_URL,PROD/PRODUCTIONvars, git overrides,PYTHONPATH,LD_PRELOAD,DYLD_INSERT_LIBRARIES,AGY_ADC_AUTH,GOOGLE_*, andDOCKER_HOST.
Namespace containment and container self-wrap
t12-cage(internal/cage): Creates Linux user and PID namespaces (CLONE_NEWUSER | CLONE_NEWPID), bindsPdeathsig: SIGKILL, and runs"t12-cage-init". Outside-cageCommitopens.gitwithO_NOFOLLOWand rejects nested.gitdirectories.t12-container(internal/container): Wrapsbin/t12inside a read-only--network nonecontainer for full CLI containment. Because Postgres is the only store, the host runs adb.Brokeron a Unix socket in a private folder and mounts it into the container (T12_DB_BROKER); the broker adds the connection string and forwards to Neon, soDATABASE_URLnever enters the container.
Broker scope
The broker does not parse SQL, so the container has the host's database access for the life of the run, while the cage keeps no network, no capabilities, and a read-only root.
Concentric containment rings
Each boundary strips privileges inward from host credentials, through tool guards, into lane containers and fresh verify sandboxes.
Click any node or press PlayWorker harness matrix and read-only guards
turbo-12f drives agent CLIs through RPC wrappers (internal/agyrpc, internal/omprpc, internal/ccrpc). The app offers agy and omp; claude is retired as a connection but still wired in code. For image attachments (internal/imginput), omprpc and ccrpc pass image blocks (checking vision capability), while agyrpc fails explicitly rather than silently dropping images.
| Harness | Go RPC driver | Guard hook script | Guard mechanism |
|---|---|---|---|
agy | internal/agyrpc | adapters/agy/guard-hook.ts | Sets toolPermission: "request-review"; hook rewrites run_command via overwrite + BypassSandbox: true; CheckWorkspace refuses .agents/ |
omp | internal/omprpc | adapters/omp/guard.ts | Intercepts tool_call events inside the extension runtime to reject forbidden writes and commands |
claude (retired in the app) | internal/ccrpc | adapters/claude/guard-hook.ts | Runs bun --no-env-file ./guard-hook.ts and emits JSON permissionDecision plus updatedInput |
Where claude stands
internal/project still lists claude among Harnesses, and workersession still dispatches it to ccrpc (API-key mode needs T12_CLAUDE_AUTH=api_key and ANTHROPIC_API_KEY). The app does not offer it: a stored claude agent setting is read as omp on the same anthropic/ model, and a run that names claude needs the person's omp connection.
- Model, effort & token caps:
project.SplitAgyRoleModelsplits legacy slugs, andagyrpc.Argvemits--modeland--effort.agyrpc.RunWorkerrecordsSession.ToolCallsfromstep_updateand enforcesMaxTokensand a dollar budget (StatusCostCap); the budget is measured in a derived token cap that counts cache reads at a quarter. A session whose shell commands agy refused (commandorunsandboxed) ends asStatusNoCalland says how many were refused. - Scratch home credentials (
PrepareSession): Copiesantigravity-oauth-token,credential-user-scope, and conditionalapplication_default_credentials.json(0600) from the run's credential home (T12_CREDENTIALS_HOME, else the real home) into scratch homes. - Conditional keys: Forwards
GEMINI_API_KEYandGOOGLE_GEMINI_BASE_URLonly whensettings.jsonsets"modelProvider": "gemini", and forwardsAGY_ADC_AUTH/GOOGLE_*only whenAGY_ADC_AUTHistrueor1.
Read-only and scoped role containment
- Read-only sessions (
readonlysession.Run): RunsNoCommands: trueorguardTree(confine: true), writes numbered transcripts (transcript-<id>[-N].jsonl), appliesroles.*overrides, and reverts edits on exit. - Scoped/toolless sessions:
analyzerruns a15mcaged session (TestGlobswritable);contextruns without shell tools (Settings(nil, nil)).
Per-person credentials per run
Runs use the credentials of the person who asked for them, held in internal/connections and sealed with T12_PROJECT_ENV_KEY. Each person connects GitHub (a GitHub App user token), agy (a Gemini key or Google sign-in, optionally with a Google Cloud project and location), and omp (Anthropic or OpenAI keys, or its own sign-in). Two optional hosting connections, Cloudflare (API token and account id) and Vercel (token and optional team), are for a release's production deploy only: the cloud worker redeems them for the release-merge action alone, never for an action that starts an agent.
| Where the run starts | How it gets the credentials |
|---|---|
t12-ui on a host | Resolves the person's connections from the database and writes sign-in files into a credential home under <home>/credentials/<slot>-<salt> (0700), removed after the job |
t12-cloud-worker | Receives only a random per-run reference (T12_INPUT_CREDENTIALS), redeems it from the same database, and rewrites its own environment before starting git, t12, or a harness |
A run without the needed connection fails before it starts: agy needs the agy connection, omp and claude need the omp connection. Factory-wide credentials stay in the environment only when the Operator sets T12_SHARED_CREDENTIALS=1.
Per-command approvals (Request Review mode)
When an Operator sets factory mode to review (Request Review) in t12 ui, every agent shell command waits for a decision recorded in the approvals table (approvals.go, bridge.go). A guard hook runs inside the harness sandbox and cannot reach the database, so it talks to the host through a scratch spool directory:
- Per-session bridge:
approvals.GuardForstarts a bridge goroutine per session andapprovals.EndSessionstops it. The bridge inserts each ask intoapprovals, writes decisions made in the table (UI or Observer) into the spool, and mirrors theapproval-modedocument intomode.jsonthere. - Fail-closed mode checks:
guard-hook.ts(agy,claude) andguard.ts(omp) read the spool'smode.jsonbefore every command; the bridge writes{"mode":"unreadable"}when the document cannot be read, so commands block until the mode is chosen again. - Write-once decisions: Asks write
<unix-nanos>-<6hex>.jsonunder<home>/approvals/<YYYY-MM-DDTHH>/; a decision is written once (UPDATE ... WHERE decided_at IS NULL), and a decision the hook already wrote, such as its timeout, wins for the hook and is recorded in the table.Pendingscans30m,Recentcaps at500, and asks older thanRetention(7d) are pruned. - Guard vs. role timeouts:
WaitTimeout(30m) sits insideHookTimeout(31m/1860s), whileapprovals.EndSessioncloses undecided asks (409on late UI posts) whenever a shorter role timer finishes first:
| Caller | Session timeout | Caller | Session timeout |
|---|---|---|---|
analyzer, explorer | 15m | deslop, observer | 5m |
codereview, redteam, sre | 10m | strategist | 3m |
Prompt assembly and Context7 socket forwarding
- Embedded prompts & skills (
assets.Files): assets/skills/map.json pins each skill to a SHA-256 digest andSOURCEline withinbudget_words: 9000(skillmap.Check()runs at confirm; wording_test.go checks neutral phrasing). - Context7 socket proxy (
internal/docs,internal/adapters/docs): Launchest12-adapter context7 serveon/tmp/t12d-.../c7.sock. ItsForwarderforwards onlyPOST /mcpcalls forresolve-library-idandquery-docswithCONTEXT7_API_KEYinjected outside the cage, logging lookups toRoleReport.Docs.
Key takeaway
Even when AI harnesses execute on the host, every shell command is rewritten through a fail-closed guard hook into an offline, secret-free cage.
Next steps
Record and evidence
How turbo-12f keeps tamper-evident hash-chained event streams, evidence blobs, documents, and leases in Postgres, typed evidence reports, read-side rollups, and the legacy v1 model.
Release and SRE
How lanes enter staging through the lease-serialized merge queue, clear merge policies and proof bisection, record sign-offs and promotions in Postgres, and stay monitored after promotion.