Skip to main content

Tool confinement

World serves ten coding tools. Nine run the AILANG tool binary under AILANG's policy layer; the tenth, workspace-exec, runs operator-profiled commands under the srt sandbox and is covered in its own section.

Every AILANG-tool fact on this page was measured first-party on the AILANG v0.51.0 tool binary, re-proved on v0.52.1 (Verification Log §13, V69–V80), and carried to v0.54.15, the only release the daemon now accepts for --tool-ailang-bin, by row 139's compatibility gate (the real-binary matrix tests run on it with no World regression). Each fact is cited by its Verification Log row (V…) in design_docs/planned/w-software-engineering-domain.md. Most are also regression tests that run against the real binary (the AC4.1 matrix).

A different tool binary changes these facts. The daemon refuses any other release, and the policy is to stay on the last binary that passed the matrix and never widen (R-SE-8).

The sandbox root is the episode worktree​

FactEvidence
The rendered policy's fs_sandbox is <workspace-root>/<episode>; each handler runs with that directory as its working directory.§4.3, V39
The episode ID must match ^[a-z0-9][a-z0-9-]{0,63}$, and <root>/<episode> must resolve to itself (no symlink redirect onto another directory or a sibling episode). Otherwise the episode gets an empty handler registry and every effect is refused before it runs.§4.3, AC4.4
The policy file, the tool cache, the store and its archive must be outside the workspace root, or startup refuses: an agent that can edit its own policy has no policy.§4.3, AC4.5
The policy file sits outside the sandbox and is passed by absolute path; the supervised worker re-reads it and admits the run.V33, V39

Paths that are refused​

AttemptResultEvidence
.. out of the worktree (op)refused … escapes sandboxV16, V36
Absolute path such as /etc/hosts (op)refused … escapes sandboxV16, V36
Symlink inside the worktree pointing outside (op)refused … escapes sandboxV36
A running program reading ../ep2/secret.txtrc 1, execution failed: readFile: path "…" escapes sandboxV34, V39
A path that is empty, absolute, contains a .. segment, or starts with -Refused by the tool's own plan before any effect (a contracted path predicate in each module)§4.5, L-ARGS

The path predicate in the transitions is for a clear refusal message. The confinement itself is the policy layer's.

.git is read-only​

AttemptResultEvidence
Op write to .git/config and to .GIT/configrefused: .git/ is read-only to the lane's tools (both spellings)V36
A running program writing .git/config, .GIT/config, .git/hooks/pre-commitrc 1, E_FS_PROTECTED: … is under .git, which is read-only in restricted mode; files byte-unchangedV52
In a real git worktree add worktree, where .git is a pointer file (gitdir: …): program or op writes to .git / .GITRefused; the pointer file stays byte-unchanged, so the gitdir redirect cannot be rewrittenV54

.git is case-folded upstream in both layers; the .GIT fix is in v0.50.1 and later (V19, V32).

The deny list, case-folded​

The rendered policy makes these read-only to the agent:

  • directories .github/, .pi/, .claude/, .ailang/
  • files .gitmodules, .gitattributes
FactEvidence
Writes to .github/** and .claude/** are refused for ops (matches fs_deny_write ".github/**") and for programs (rc 1 E_FS_PROTECTED).V36, V52
.gitmodules and .gitattributes were writable in a worktree until they were added to the list.V54
.ailang/** is denied so an agent cannot poison the compile cache later checks and runs read; run and check still work.V57
On a case-insensitive volume (macOS APFS), v0.51.0 matched the deny list case-sensitively: .CLAUDE/settings.json, .GITHUB/…, .AILANG/…, .Pi/…, .GITMODULES, .GitAttributes and .gitmoduleſ (U+017F) all wrote through to the protected lowercase files, by write, edit and running programs.V68
Fix, in the policy only: each directory is rendered as every Unicode simple-fold variant of its name plus /** (196 literals), and each file as one path.Match class over its fold orbit, for example .[gG][iI][tT][mM][oO][dD][uU][lL][eE][sſS]. 198 patterns, 3102 bytes. All case-variant rows are refused, with the lowercase targets unchanged.V68, R-SE-15
On v0.52.1 the deny matcher folds case upstream (one matcher, fileguard.Protection): with only the six lowercase entries, all 39 case-variant rows are refused. World still renders the folded list (redundant, harmless). policy-tool also refuses fmt --write on a deny-listed path, and test no longer writes into the tested file's directory.V72, V73, V75
The only non-ASCII code points APFS folds onto ASCII letters are ſ (U+017F, onto s) and the Kelvin sign (U+212A, onto k); no code point is ignored. None of the four directory names contains s or k.V68

Environment and cache​

FactEvidence
Both handler branches get a minimal environment, never the daemon's: HOME=<db-dir>/cache/<episode>, PATH=/usr/bin:/bin, LANG=C, LC_ALL=C, AILANG_CACHE_DIR=<db-dir>/cache/<episode>, and AILANG_EXAMPLES only when a corpus is configured. The registry credential cannot reach a tool.childEnv in host/broker/handlers_ailang.go
policy-tool honours AILANG_CACHE_DIR; run --policy ignores it and writes its compile cache to <worktree>/.ailang/, which the deny list makes read-only to the agent.V57, R-SE-4
Because HOME is the per-episode cache, examples-search never finds the operator's ~/.ailang/examples by itself; it uses only the corpus serve --examples-dir names, which must be outside the workspace root. Without one it refuses and never runs the op, which also stops the binary's CWD fallback from searching the agent's own worktree.V65

No shell, a fixed op set​

FactEvidence
There is no shell tool. Each effect name has a fixed op allowlist: Workspace.Read → read; Workspace.Write → write, edit; Workspace.Delete → delete (v0.54.15; it refuses the same protected paths, .git/, symlinks out and directories, and removes a symlink itself, never its target; row 191a); Ailang.Check → ai_check; Ailang.Discover → builtins_list, examples_search; Ailang.CLI → the policy summary's cli list; Ailang.Run → the run path only. Workspace.Exec runs only an operator-profiled command, never a shell line (below).§4.3, V40
ailang-cli's allowlist is the policy summary's 20 cli ops: agent_prompt, ai_check, axioms, builtins_list, builtins_show, check, devtools_prompt, docs_search, examples_list, examples_search, examples_show, examples_tags, fmt, iface, pkg_docs, policy_check, prompt, test, tree, version. Not read, write, edit or run.V40
Per-op flag admission is policy-tool's own: for example fmt --check --write, test --allow-skips --json --no-color --package, check --json --quiet --strict-syntax, docs_search --json --limit, builtins_list --json; most ops admit none.V56, V67
policy-tool silently ignores unknown top-level request keys, so each transition refuses any argument key outside its schema (L-ARGS).V56
An op with write/edit on Workspace.Read is refused by the handler, with no file change; so is delete on any effect but Workspace.Delete.AC4.2, row 191a
Every toolchain child (policy-tool, run --policy, the CLI ops) gets TMPDIR = the episode cache's own tmp/ (0700), never /tmp: v0.54.15's CLI ops make a private cache dir there while they run.row 197

Flag injection​

FactEvidence
ailang run --policy P -policy.ail parses the path as a flag (flag provided but not defined).V58
Closed twice: the plan's path predicate refuses a leading -, and the run handler always passes the path after -- (ailang run --policy P [--args-json J] -- <path>).§4.3, AC4.3
policy-tool refuses a hyphen-leading path (looks like a flag), and sandbox-checks --package.V67

ailang-cli never writes​

FactEvidence
fmt --write rewrote deny-listed files (.claude/x.ail, .ailang/x.ail) through policy-tool, because the formatter does not consult fs_deny_write. Only the exact key write maps to --write, and its value is ignored ("false" writes). FLAGS/Flags alias flags, and duplicate flags objects merge.V67
Fix, in both layers: the ailang-cli plan refuses fmt with a write key in any flags entry (a Z3-verified predicate, zero-effect refusal), and the handler refuses the same plus any case-folded alias of op or flags, forwarding only its own re-encoding. fmt returns the formatted text; save it with ailang-write.V67, R-SE-13
On v0.51.0, test wrote a transient _namedtest_body_<random>.ail into the tested file's directory, including a deny-listed one, then removed it. On v0.52.1 it no longer does, and policy-tool itself refuses fmt --write on a deny-listed path; World keeps its own refusal.V67, V75, R-SE-13

ailang-run outcome shapes​

The run handler composes its result {admitted, exit_code, decision, limit, stdout, stderr} from exactly four observed shapes, and records anything else as a handler failure. It never infers success from the exit code.

ShapeWhat the binary doesEvidence
(a) admittedrc 0 or the program's rc; program output on stdout; one policy: JSON line on stderrV33, V39
(b) admitted, refused at runtimerc 1; execution failed: … escapes sandbox plus the policy: lineV34
(c) refused before executionnon-zero rc (2 for a policy violation or type error, 1 for an unreadable file); the decision JSON on stdout, stderr empty; admitted:false, with error_kind such as policy_violation or read_failedV49, V63
(d) supervisor limitrc 3; partial stdout; the policy: line plus a policy-result: line with reason (for example timeout) and stageV61
FactEvidence
A refused inner effect can still exit 0: a program printed E_NET_IP_BLOCKED … 127.0.0.1 and returned rc 0.V35
A program declaring Net is refused statically under the IO/FS policy (missing_from_policy: ["Net"]).V49
security_mode defaults to restricted if omitted; the rendered policy states it anyway, and a test pins the exact key set.V62
The policy's timeout_ms is 8000, below the handler's 10 s cap, so AILANG's supervisor kills first and reports shape (d).§4.3, V61

ailang-run capabilities​

By default ailang-run runs under the episode policy above: restricted mode, IO and FS. Row 135 (design_docs/planned/w-ailang-run-stdin-argv-caps.md) adds stdin, argv and caps, the run's exact capability set, like the grader's --caps. Each capability beyond IO and FS passes three gates:

  1. The broker (who). An Env run is the effect Ailang.RunEnv and a Net run is Ailang.RunNet, each with its own grant and budget. A Declassify run stays Ailang.Run (D-135-5): Declassify is an admission-only label with no runtime operations.
  2. The operator (what is possible). serve --run-allow-caps Env,Net,Declassify names the extra capabilities a run may request; anything else is refused by the handler before any process starts. Net also needs --run-net-allow 127.0.0.1:PORT (repeatable), and plain http needs --run-net-allow-http.
  3. The policy layer (what runs). World renders one policy variant per episode and cap set, next to the episode policy and outside the worktree. AILANG's own policy-tool summary must report exactly the rendered mode, caps, net_allow, sandbox and digest before the variant's first run. AILANG enforces it.
Requested capsVariantEvidence
a subset of IO, FS, Declassifyrestricted. FS is always allowed, at budget 0 when not requested, so the entry file must be inside the sandbox and a file operation fails at first use, as the grader's wouldV23, V24, V33
with Netrestricted, with net_allow set to the operator's IP:PORT literals. Only those pairs are reachable: another port (World's own :7644 included), localhost, [::1], another loopback address and a redirect hop are all refused. .git stays read-onlyV34
with Envtrusted_host, the only mode that admits Env. Its relaxations are compensated in the rendered policy: one .git/** deny entry (which, on v0.52.1, covers every case spelling, the bare .git and a worktree's .git pointer file), and the four byte limits set to the restricted defaults. The program sees only the handler's minimal environmentV36–V38
FactEvidence
argv always follows an inner -- after the path, so no item reaches the run's flag parser: ["--caps=IO,Net","-","--","a b"] comes back verbatim.V13, V39
stdin is passed to the program's standard input; --args-json - stays refused.V12, V14
Env and Net together are refused in one run; public-network Net is not offered.§2, R-135-4
Startup refuses an unknown capability name, Net without --run-net-allow, a --run-net-allow entry that is a bare host, a name, or a non-loopback address, and any variant the policy layer refuses at load.§4.3, V35

workspace-exec: operator-profiled commands under srt​

workspace-exec (row 140, effect Workspace.Exec) lets an agent build and test a non-AILANG project without a shell. The operator decides what can run; the agent picks from that list.

FactSource
Commands come only from an operator exec profile (world/exec-profile/v1, serve --exec-profile, one per project). The agent passes command, the id of one profile command, and optional args; never a program or a shell line, and no shell sees an argument.serve --help, the workspace-exec descriptor
The profile fixes the program, its leading arguments, the working directory, the environment, the read roots and the timeout. args (at most 16, each 1 to 512 bytes, no NUL) must match the command's grammar: only its listed flags, and positionals of its declared class.the workspace-exec descriptor
The command runs under the srt sandbox (@anthropic-ai/sandbox-runtime 0.0.78, --exec-sandbox): writes stay inside the worktree and the episode's exec cache; the operator's home directory, World's state and other episodes are unreadable; there is no network.serve --help, the descriptor
The sandbox tree is archived at startup and re-verified before every call; its dist/cli.js must hash to the pin. The profile, srt, node and every cache seed must lie outside the workspace root and the state directory.serve --help
Each profile must pass a seven-arm startup probe (arm1-write-inside … arm7-toolchain), or serve refuses to start.serve --help, QUICKSTART §10
Without --exec-profile, Workspace.Exec is still bound with the workspace tools, but every call is refused no exec profile configured.serve --help
A command whose stdout or stderr passes --exec-max-output-bytes (default 64 MiB) is killed. The result reports exit_code without judging it, plus the profile command and the sandbox it ran in (runtime, version, CLI hash, settings digest, read fence, network).serve --help, the descriptor
The result carries a worktree_delta when the command changed files in the worktree.row 184

Known gap: a profiled test command runs whatever test files are in the worktree, and the agent can edit those files. Protected test paths are queue row 156, a blocker for v1.0.0 (see Residuals).

Host launches: confined, observed and fallback​

The launchers ailang-worldd hosts init writes (rows 223a and 223d) start an agent with World's tools as its only file and shell access. See Run your agents through World.

LevelWhat it means
ConfinedWorld's tools are the agent's only file and shell access, so every effect is a World entry.
ObservedWorld sees the agent's MCP calls, not its built-in tools.
Fallbackherdr's plain pane after a failed World check, labelled world: fallback: not confined, and never labelled so.

Off-machine actions are never controlled: what a cloud service does on its own servers is outside World.

What each launch turns off:

HostLaunch settings
Claude Code--strict-mcp-config with only World's MCP server; Bash, Edit, Write, Read, Glob, Grep, NotebookEdit, WebFetch and WebSearch denied; bypass-permissions mode disabled.
CodexCODEX_HOME set to the launch settings' codex/ directory, whose config.toml sets sandbox_mode = "read-only", approval_policy = "never", web_search = "disabled", shell_tool = false, unified_exec = false, and World's MCP server required.
pi--no-builtin-tools --no-extensions, then -e pi-mcp-adapter with World's MCP config. pi has no built-in MCP, so the adapter is how World's tools reach it.
  • Codex. Code mode still exposes apply_patch as a nested tool. With approval_policy = "never", the read-only sandbox refuses it rather than asking you. A live probe on 27 Oct 2026 (Codex 0.164, gpt-6.1-sol) confirmed it. Through codex-world, the agent declined, citing World's instructions. With those instructions removed, it called apply_patch and got patch rejected: writing is blocked by read-only sandbox; rejected by user approval settings, and no file was written. A control with only the sandbox made writable created the file. doctor --host codex warns when approval_policy = "never" is missing from the launch config.
  • pi. Before #381, pi-world started pi with no tools at all. A launch directory written since then loads pi-mcp-adapter, and a missing adapter makes pi-world refuse with the fix: pi install npm:pi-mcp-adapter, then ailang-worldd hosts init --replace.
  • Drift. doctor --host compares every launch file with the digests in hosts.json. A file that differs is a warning, because that launch would be observed, not confined.

Confinement is per launch. A host started any other way on the same machine is not confined.

Not covered by the broker​

The inner file operations of a program run by ailang-run, and of a workspace-exec command, are confined (by the policy, and by srt) but not brokered, journaled or replayable individually. For ailang-run that is an owner-ratified trade-off (D-SE-3 = A), recorded as residual R-SE-11. Since row 184, each such call's result records a summary of what it changed in the worktree (worktree_delta).