# Pi shell isolation and offline Go

Paul approved this containment change on 2026-11-13 ("fix it all up"). This
controller design supersedes the Pi Bash exception in the connectors spec,
section 2.1, and the Pi deferral in the Engineering toolchain spec.

Pi 1.5.2's `dist/core/tools/bash.js` calls `createLocalBashOperations`, then
spawns the configured shell. `dist/utils/shell.js:getShellEnv` copies the CLI
environment. Equipo supplies the provider key through the secret argument pipe
(`containment/mounts.go:addSecretEnv`); the credential home itself is never
mounted. The old shell could read that variable and the CLI's `/proc` files.
It also shared the relay at `127.0.0.1:18080` and `/egress/proxy.sock`
(`containment/egress.go`). Equipo's extension approved calls without adding a
sandbox. The previous `TestPiP4AStepCanReadTheKey` explicitly asserted this.

Use Pi's existing `shellPath` setting, fixed to `/config/pi/bash`. No Pi patch
or package pin change is needed. In the pinned tree,
`dist/core/agent-session.js` uses `getShellPath()` both to construct the Bash
tool and in `executeBash`; `dist/utils/shell.js:getShellConfig` passes `-c`
and the command separately to the configured executable. Missing wrappers fail
closed. The wrapper passes the command as one argument to Bash after bubblewrap
has created the sandbox. It never evaluates the command in the CLI namespace.

The wrapper uses absolute executable paths, including setup before isolation.
It starts bubblewrap through `env -i`, then clears the child environment again;
otherwise bubblewrap itself can retain the key in its process environment.
The wrapper is embedded in Equipo, checked against its compiled digest and
mounted read-only, with the pinned bubblewrap executable. It creates fresh
user, PID, network, IPC and UTS namespaces, drops capabilities, disables nested
user namespaces, clears the environment and mounts a fresh `/proc` and `/dev`.
The filesystem contains read-only `/usr` and `/etc`, a writable workspace and
shell-only temporary directory, and an empty home. The CLI's home, config,
package tree, key file, tool socket and relay socket are absent. Shell exit
also ends its background processes. Pi's native file tools are confined to the
workspace by a path check when each call is gated; its settings, model and MCP
files are individually mounted read-only. The containing directory stays
writable for Pi's settings lock.

Pi gates every call in one assistant message before running them together, so
the gate-time path check alone could race a shell command that swaps a checked
path for a link. Equipo's extension therefore never lets a file tool and a
shell command run at the same time: whichever is gated second while the other
is still running is refused ("Run file tools and shell commands in separate
messages"). Calls of one kind still run in parallel, and separate messages run
in turn. TestPiBatchSeparatesShellAndFileTools covers both orders with a
positive control. The shell inherits only stdio (TestPiShellInheritedDescriptors).

Engineering gets the same configured Go root and optional module cache as
Claude and Codex. A Pi attempt retains directory descriptors using the shared
Go pinning code; cleanup closes them. Only the Go root is hashed. Both outer
and inner mounts are read-only. The inner environment sets local toolchain,
offline module resolution and private scratch, disables Go environment files,
workspace discovery, telemetry and CGO, and ignores global Git configuration.
Review and answer roles keep their existing tool sets and get no Go mounts.
A missing module cache is omitted; an invalid existing cache is refused.

The real pinned Pi runs against the existing local fake provider in tests.
Shell and Go-built probes test credential files, inherited and process
variables, TCP relay and Unix sockets. The same Go binary runs outside the
sandbox as a positive control, reporting only whether access succeeded. An
import from a prepared module cache proves offline `go test`; writes to both
trees must fail. Mutation checks remove each boundary and must fail its guard.
These offline probes do not replace provider release certification.

The Pi policy format advances to `pi-v2`, so old policies cannot silently
retain the old shell behavior. No wire protocol or database migration changes
are needed. `origin/copy-specialist` already reserves protocol 21 and migration
0081; this change consumes neither. Rollback uses the previous versioned
release and its matching certificates, restoring the old Pi shell limitation.
