Skip to Content
turbo-12f
Architecture

Sandbox and harnesses

How Landlock, Docker cages, Request Review command approvals, read-only guards, prompt budgets, 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.

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, claude): Run outside cages behind RPC wrappers and guard hooks.
  • Context7 socket (t12-adapter): Proxies docs lookups over a Unix socket with CONTEXT7_API_KEY.
  • Per-command gate: In review mode, guard hooks pause commands on <home>/approvals/.

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.
  • 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, 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.

Concentric containment rings

Flow
100%
Ring 1 · Host · operator file rightsRing 2 · Guard · omp, agy & claude hooksRing 3 · Lane cage · t12.lane Docker labelRing 4 · Verify sandbox · aparttool calldocker execcheckout verifyAgent harness (agy · omp · claude)holds model API credentialsTrust boundary scopeguard filters tool calls, not raw host procsGuard rules & hookro paths · approvals · 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 three agent CLIs (agy, omp, claude) through RPC wrappers (internal/agyrpc, internal/omprpc, internal/ccrpc). 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
claudeinternal/ccrpcadapters/claude/guard-hook.tsRuns bun --no-env-file ./guard-hook.ts and emits JSON permissionDecision plus updatedInput

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-command approvals (Request Review mode)

When an Operator sets factory mode to review (Request Review) in t12 ui, every agent shell command waits on a live file gate in internal/approvals (approvals.go):

  • Fail-closed mode checks: guard-hook.ts (agy, claude) and guard.ts (omp) read <home>/access/mode.json before every command, blocking commands if unreadable or corrupt.
  • Write-once decisions: Asks write <unix-nanos>-<6hex>.json (0600) under <home>/approvals/<YYYY-MM-DDTHH>/; approvals write <id>.decision.json via hard link (EEXIST safe). Pending scans 30m, Recent caps at 500, and Retention prunes after 7d.
  • 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 (factory.Files): 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