oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1# Pi shell isolation and offline Go
2
3Paul approved this containment change on 2026-11-13 ("fix it all up"). This
4controller design supersedes the Pi Bash exception in the connectors spec,
5section 2.1, and the Pi deferral in the Engineering toolchain spec.
6
7Pi 1.5.2's `dist/core/tools/bash.js` calls `createLocalBashOperations`, then
8spawns the configured shell. `dist/utils/shell.js:getShellEnv` copies the CLI
9environment. Equipo supplies the provider key through the secret argument pipe
10(`containment/mounts.go:addSecretEnv`); the credential home itself is never
11mounted. The old shell could read that variable and the CLI's `/proc` files.
12It also shared the relay at `127.0.0.1:18080` and `/egress/proxy.sock`
13(`containment/egress.go`). Equipo's extension approved calls without adding a
14sandbox. The previous `TestPiP4AStepCanReadTheKey` explicitly asserted this.
15
16Use Pi's existing `shellPath` setting, fixed to `/config/pi/bash`. No Pi patch
17or package pin change is needed. In the pinned tree,
18`dist/core/agent-session.js` uses `getShellPath()` both to construct the Bash
19tool and in `executeBash`; `dist/utils/shell.js:getShellConfig` passes `-c`
20and the command separately to the configured executable. Missing wrappers fail
21closed. The wrapper passes the command as one argument to Bash after bubblewrap
22has created the sandbox. It never evaluates the command in the CLI namespace.
23
24The wrapper uses absolute executable paths, including setup before isolation.
25It starts bubblewrap through `env -i`, then clears the child environment again;
26otherwise bubblewrap itself can retain the key in its process environment.
27The wrapper is embedded in Equipo, checked against its compiled digest and
28mounted read-only, with the pinned bubblewrap executable. It creates fresh
29user, PID, network, IPC and UTS namespaces, drops capabilities, disables nested
30user namespaces, clears the environment and mounts a fresh `/proc` and `/dev`.
31The filesystem contains read-only `/usr` and `/etc`, a writable workspace and
32shell-only temporary directory, and an empty home. The CLI's home, config,
33package tree, key file, tool socket and relay socket are absent. Shell exit
34also ends its background processes. Pi's native file tools are confined to the
35workspace by a path check when each call is gated; its settings, model and MCP
36files are individually mounted read-only. The containing directory stays
37writable for Pi's settings lock.
38
39Pi gates every call in one assistant message before running them together, so
40the gate-time path check alone could race a shell command that swaps a checked
41path for a link. Equipo's extension therefore never lets a file tool and a
42shell command run at the same time: whichever is gated second while the other
43is still running is refused ("Run file tools and shell commands in separate
44messages"). Calls of one kind still run in parallel, and separate messages run
45in turn. TestPiBatchSeparatesShellAndFileTools covers both orders with a
46positive control. The shell inherits only stdio (TestPiShellInheritedDescriptors).
47
48Engineering gets the same configured Go root and optional module cache as
49Claude and Codex. A Pi attempt retains directory descriptors using the shared
50Go pinning code; cleanup closes them. Only the Go root is hashed. Both outer
51and inner mounts are read-only. The inner environment sets local toolchain,
52offline module resolution and private scratch, disables Go environment files,
53workspace discovery, telemetry and CGO, and ignores global Git configuration.
54Review and answer roles keep their existing tool sets and get no Go mounts.
55A missing module cache is omitted; an invalid existing cache is refused.
56
57The real pinned Pi runs against the existing local fake provider in tests.
58Shell and Go-built probes test credential files, inherited and process
59variables, TCP relay and Unix sockets. The same Go binary runs outside the
60sandbox as a positive control, reporting only whether access succeeded. An
61import from a prepared module cache proves offline `go test`; writes to both
62trees must fail. Mutation checks remove each boundary and must fail its guard.
63These offline probes do not replace provider release certification.
64
65The Pi policy format advances to `pi-v2`, so old policies cannot silently
66retain the old shell behavior. No wire protocol or database migration changes
67are needed. `origin/copy-specialist` already reserves protocol 21 and migration
680081; this change consumes neither. Rollback uses the previous versioned
69release and its matching certificates, restoring the old Pi shell limitation.
70