Skip to Content
turbo-12f
Architecture

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.

Explanation

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: IsForbiddenEnvKey strips 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 with CONTEXT7_API_KEY.
  • Per-command gate: In review mode, guard hooks ask through a scratch spool that a host bridge copies to the approvals table.

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 featureEnforcement
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 9Abstract Unix socket/signal scoping (ABI 6) and fsResolveUnix (ABI 9)
Process hardeningSets 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() passes uid:gid on Linux and 0:0 on Darwin (T12_CONTAINER_USER overrides). ResolveDockerHost and DockerClientEnv select Docker or Colima sockets under T12_CONTAINER_ENGINE (auto, docker, colima), stripping DOCKER_CONTEXT.
  • State-home checkouts & deps-cache: Checkouts mount from <home>/checkouts/ with a startup mount probe (24h sweep); node_modules cache under <home>/deps-cache/ (8-entry LRU, 14d TTL).
  • Persistent lane cages (sandbox.StartLane): Starts one background container per lane (t12-lane-<hex>, --label t12.lane=<req>) with .git mounted read-only to avoid per-turn container startup cost.
  • Cloud worker uses Docker cages: The t12-worker.yml job sets T12_SANDBOX_ADAPTER=docker for run, confirm, release-merge, and try-publish, because Landlock denies every TCP bind and a web project's E2E server (wrangler dev on 127.0.0.1:8787) could not start under it. A Prepare lane cages step first pulls (or builds and pushes) the project's cage image, then scripts/bootstrap-cages.sh pulls the pinned runtime and scanner images and the red team's offline npm database.
  • Offline after install: devops.Install sets Network: true only when adapter == "docker" during Project Gate dependency installs; qc, uicheck, and redteam stay offline.
  • Environment scrubbing (IsForbiddenEnvKey): Strips API keys, tokens, DATABASE_URL, PROD/PRODUCTION vars, git overrides, PYTHONPATH, LD_PRELOAD, DYLD_INSERT_LIBRARIES, AGY_ADC_AUTH, GOOGLE_*, and DOCKER_HOST.

Namespace containment and container self-wrap

  • t12-cage (internal/cage): Creates Linux user and PID namespaces (CLONE_NEWUSER | CLONE_NEWPID), binds Pdeathsig: SIGKILL, and runs "t12-cage-init". Outside-cage Commit opens .git with O_NOFOLLOW and rejects nested .git directories.
  • t12-container (internal/container): Wraps bin/t12 inside a read-only --network none container for full CLI containment. Because Postgres is the only store, the host runs a db.Broker on 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, so DATABASE_URL never 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

Flow
100%
Ring 1 · Host · operator file rightsRing 2 · Guard · agy, omp & claude hooksRing 3 · Lane cage · t12.lane Docker labelRing 4 · Verify sandbox · aparttool calldocker execcheckout verifyAgent harness (agy · omp)holds the requester's per-run credentialsTrust boundary scopeguard filters tool calls, not raw host procsGuard rules & hookro paths · approval spool · dockerLane Docker containerno net · no caps · worktree rwFresh checkout sandboxLandlock · Docker · zero secrets

Each boundary strips privileges inward from host credentials, through tool guards, into lane containers and fresh verify sandboxes.

Click any node or press Play

Worker 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.

HarnessGo RPC driverGuard hook scriptGuard mechanism
agyinternal/agyrpcadapters/agy/guard-hook.tsSets toolPermission: "request-review"; hook rewrites run_command via overwrite + BypassSandbox: true; CheckWorkspace refuses .agents/
ompinternal/omprpcadapters/omp/guard.tsIntercepts tool_call events inside the extension runtime to reject forbidden writes and commands
claude (retired in the app)internal/ccrpcadapters/claude/guard-hook.tsRuns 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.

Read-only and scoped role containment

  • Read-only sessions (readonlysession.Run): Runs NoCommands: true or guardTree (confine: true), writes numbered transcripts (transcript-<id>[-N].jsonl), applies roles.* overrides, and reverts edits on exit.
  • Scoped/toolless sessions: analyzer runs a 15m caged session (TestGlobs writable); context runs 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 startsHow it gets the credentials
t12-ui on a hostResolves 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-workerReceives 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.GuardFor starts a bridge goroutine per session and approvals.EndSession stops it. The bridge inserts each ask into approvals, writes decisions made in the table (UI or Observer) into the spool, and mirrors the approval-mode document into mode.json there.
  • Fail-closed mode checks: guard-hook.ts (agy, claude) and guard.ts (omp) read the spool's mode.json before 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>.json under <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. Pending scans 30m, Recent caps at 500, and asks older than Retention (7d) are pruned.
  • Guard vs. role timeouts: WaitTimeout (30m) sits inside HookTimeout (31m / 1860s), while approvals.EndSession closes undecided asks (409 on late UI posts) whenever a shorter role timer finishes first:
CallerSession timeoutCallerSession timeout
analyzer, explorer15mdeslop, observer5m
codereview, redteam, sre10mstrategist3m

Prompt assembly and Context7 socket forwarding

  • Embedded prompts & skills (assets.Files): assets/skills/map.json pins each skill to a SHA-256 digest and SOURCE line within budget_words: 9000 (skillmap.Check() runs at confirm; wording_test.go checks neutral phrasing).
  • Context7 socket proxy (internal/docs, internal/adapters/docs): Launches t12-adapter context7 serve on /tmp/t12d-.../c7.sock. Its Forwarder forwards only POST /mcp calls for resolve-library-id and query-docs with CONTEXT7_API_KEY injected outside the cage, logging lookups to RoleReport.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

On this page