# S2 progress: Pi on TensorX

Branch `connections-s2-pi` from main 87b66610 (S1 merged). Spec:
`docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md`
revision 3.1 (on `connections-slice2-design`), §11 row S2: §3 (isolated
configuration, containment, pinning, mapping, families, the acceptance
list), §4.1 (Pi, the TensorX part; the Command Code provider is S7),
§4.4 (Pi to TensorX: Engineering, Review and Ask; never the
coordinator), §2.1 to §2.3 (S1's guard, which Pi plugs into) and §7
(Ask stays on its step's session and connection; a kept session stays
put). Connections rev 3 §1.4, §5 and §8 slice 2's probes P1 to P5.

No real key, no sign-in, no real provider. The real pinned Pi ran only
against a fake OpenAI-compatible TensorX on 127.0.0.1 (TLS under a test
authority), through the real relay, in the real bubblewrap namespace.

## Early checks (the brief's stop conditions)

- (a) The relay. Pi 1.5.2 on Node 22.23.4 sends its provider calls
  through `HTTPS_PROXY` as `CONNECT api.tensorx.ai:443` with no extra
  switch (Pi sets its own proxy agent; `NODE_USE_ENV_PROXY` is not
  needed). It found one real fault: undici sends `Host: api.tensorx.ai`
  without the port, and the relay required `api.tensorx.ai:443`, so every
  real TensorX call would have been refused (403). The relay now accepts
  the bare host when the port is 443 (the same authority, RFC 9110's
  default port); another host or port is still refused
  (`TestEgressAcceptsNodeConnect`, `TestEgressRejectsSmuggling`).
- (b) Isolated configuration. Pi's argv turns off every project and
  context source: `--no-approve --offline --no-context-files
  --no-extensions -e builtin:mcp -e /config/pi/equipo.ts --no-skills
  --no-prompt-templates --no-themes --session-dir`, with
  `PI_OFFLINE=1 PI_SKIP_VERSION_CHECK=1 PI_TELEMETRY=0`, and settings.json
  says `defaultProjectTrust: never`. A hostile repository (.pi settings
  with sessionDir, defaultTools and extensions; a .pi extension that
  writes a marker and registers a tool; .pi/mcp.json starting a server;
  SYSTEM.md, APPEND_SYSTEM.md, skills in .pi and .agents, prompts;
  AGENTS.md and CLAUDE.md asking for a tool) loads nothing:
  `TestPiAcceptanceHostileRepository`.
- (c) RPC. One session holds a hundred turns, and a kept session resumes
  in a new process with its history (`TestPiP1SessionAcrossTurns`).
  `abort` with a pending extension dialog does not settle until the
  dialog is answered, so `Interrupt` cancels pending dialogs first; ending
  everything is the namespace kill, proven (`TestPiP5DescendantTermination`:
  an abort leaves a shell's background loop running, the kill ends it).

## Done

1. Pinning (1bdc4288, c396d426). `internal/runner/provider/pi`: the
   committed `npm/package.json` and `package-lock.json` (Pi 1.5.2 by its
   integrity, every package by integrity; no install script runs:
   `npm ci --ignore-scripts`); Node v22.23.4 (the Mac's srt Node) from the
   official Linux archives, pinned by archive and program digests for
   amd64 and arm64; the tree digest committed per platform
   (`provider.TreeSHA256`: every entry's path, mode and content, links by
   target, each link relative and inside the tree, anything writable
   refused). The install is sealed read-only (directories 0555, files
   0555 or 0444) so modes do not depend on the umask. npm 10.9.9 (the
   pinned Node's) and npm 11 make the same tree; it has no
   platform-specific package, so amd64 and arm64 share one digest. Node
   and the tree are checked when the policy is built and again at every
   launch's attestation; `pi.Verify(root)` checks an install root.
2. Getting it there (c396d426). `equipo-runner install-pi <root>` on a
   Linux runner: Node's archive checked before it is unpacked (the Mac
   installer's `mac.Fetch`), `npm ci --ignore-scripts` from the committed
   lockfile, sealed, verified, removed if it does not verify; it prints
   `EQUIPO_PI_ROOT=...` for the runner's environment. `install` records
   `EQUIPO_PI_ROOT` when set; `install` and `verify-installed` run
   `pi.Verify` then. CI's box installs the same (`scripts/ci-box.py`
   `install_pi`, Python computing exactly `provider.TreeSHA256`; pins in
   `scripts/ci-box.json` "pi", held to the code by
   `TestBoxPiMatchesTheCode`), mounts it at `/opt/equipo-pi` and sets
   `EQUIPO_PI_ROOT`; testci fingerprints it, so a pin change reruns the
   real-Pi tests.
3. The Pi policy kind (1bdc4288), `check_policy.go`'s effective-policy
   check extended to Pi: `BuildPiPolicy` / `IsPi` / attestation. The
   exact argv above; the environment above plus `EQUIPO_PI_TOOLS` and,
   for a read-only role, `EQUIPO_PI_CONFINE=/workspace`; mounts `/opt/node`
   (file), `/opt/pi/node_modules` (the tree; Node resolves packages only
   under a `node_modules` path), `/opt/equipo-tool-proxy`,
   `/config/pi/equipo.ts`; Pi's config directory in the attempt's own
   runtime home (`PI_CODING_AGENT_DIR=/home/runner/agent`: Pi writes its
   credential store and a settings lock there, so it cannot be read-only)
   holding `models.json`, `settings.json` and `mcp.json` the runner wrote,
   hashed into the manifest and read back at attestation. models.json is
   accepted only as one provider, `openai-completions`, an https base URL,
   the selected model and `apiKey: "$TENSORX_API_KEY"` (never a literal or
   a `!command`). Tools: names only; a read-only role (Review, a question)
   gets no `bash`, `edit` or `write`; MCP tools only `mcp__equipo__<name>`.
4. Containment (1bdc4288): the existing namespace; the tree mounted
   read-only whole; Pi's variables allowed only for a Pi policy; the key
   (`.oauth-token` in the connection's home, S1's delivery) reaches the
   namespace as `TENSORX_API_KEY` through bubblewrap's `--args` pipe, in
   no argv, policy or manifest; egress by S1's table `(pi, tensorx)` to
   `api.tensorx.ai` only (the policy names its harness).
5. Equipo's extension (`pi/equipo.ts`, embedded, its digest a pinned file
   in the manifest): the role's tools run; for a read-only role its read
   tools only inside `/workspace` (after resolving links, so a link the
   repository plants does not lead out); anything else is asked of
   Equipo as an `extension_ui_request` and runs only on a yes. In a step
   nobody can answer, so Equipo refuses (and the tail says so).
6. The adapter (1bdc4288): an RPC client (LF framing, id-correlated
   responses), `Decoder` (text deltas to `delta`; `tool_execution_start`
   and `_end` to `tool_call` and `tool_result`; the extension's dialog to
   `ask`; each assistant `message_end` to `usage`; `agent_end` that will
   not retry to `done` with `completed`, `interrupted` or `failed` and the
   class: 401/403 `auth`, 429 after Pi's own retries `quota`, else
   `provider`; unknown events counted by type name and dropped, logged by
   name and count), `Tally` (the sum over assistant messages, complete on
   that `agent_end`; Pi's own cost as the reported cost when Pi priced it)
   and `Launcher`, a `provider.Launcher` over a `ProcessHost`. `fakepi`
   reproduces the recorded protocol (recordings in `pi/testdata`) and
   plays the extension's gate.
7. Steps (7ba4c538): `connect.Choose` takes the harness's capability (the
   matrix gains `pi` for Engineering and Review, not the coordinator) and
   an explicit leave to spend; metered connections are candidates only
   with it, and then only when no subscription can run the role.
   `Conns.ChooseFor` passes it; `Choose` (the coordinator's) never
   spends. Engineering and Review on a metered connection run `runPi`
   through `Meter.Run`: admission with the slot claimed, the namespace
   recorded in the step and the slot before it starts, usage priced and
   charged once, the slot released after the termination proof; held,
   the step waits deferred; a refused key marks the connection refused.
   Review's family and label come from the model that ran. A step's Pi
   session is kept for questions; an Engineering fix round on Pi resumes
   its kept session on the same connection.
8. Ask (7ba4c538): `askPi` is S1's `MeteredAsk`: a question about a step
   whose kept session is on the metered connection runs there, through
   the guard, resuming that session read-only on the exact commit.
9. The browser test the controller added (c0822242):
   `TestBrowserConnectionsMeteredLimitRequired`.
10. No wire change: S2 rides S1's protocol 12. No migration.

## Tests

- `internal/runner/provider`: `TestPiPolicyIsolatedConfiguration`,
  `TestPiPolicyRefusals`, `TestPiPolicyAttestation`,
  `TestPiLaunchSecretEnv`.
- `internal/runner/provider/pi`: `TestLockfilePinsPi`, `TestTreeDigest`,
  `TestTreePinsByPlatform`, `TestPinnedInstallVerifies`;
  `TestDecodeRecordedRuns`, `TestDecodeEndings`, `TestDecodeUnknownEvents`,
  `TestTallyUsage`, `TestFamilyFromModel`; fakepi in the namespace
  `TestPiFakeReviewInNamespace`; the real pinned Pi:
  `TestPiP1SessionAcrossTurns`, `TestPiP2RelayForABlockedTool`,
  `TestPiP3MCPPinning`, `TestPiP4AStepCanReadTheKey` (rev 3's
  credential-read probe, replaced as spec rev 3.1 says: it asserts that a
  step CAN read the key from the namespace's environment, and that the key
  is in no argv), `TestPiP5DescendantTermination`,
  `TestPiAcceptanceHostileRepository`.
- `internal/runner/thin` (real containment): `TestPiReviewStep`,
  `TestPiReviewWithoutLeaveToSpend`, `TestPiBudgetHoldsTheNextStep`,
  `TestPiNoUsagePausesTheConnection`, `TestPiKeyRefused`,
  `TestPiAskKeptSession`, `TestPiEngineeringRun`,
  `TestPiEngineeringHeldIsDeferred`, `TestPiReviewFamilyFromTheModelThatRan`,
  `TestPiStepRefusesAsks`, and the finish line `TestPiReviewStepRealPi`.
- `internal/runner/connect`: `TestChooseMetered`.
- `internal/runner/egress`: `TestEgressAcceptsNodeConnect`.
- `internal/testci`: `TestBoxPiMatchesTheCode`.
- `cmd/equipo-runner`: `TestReleaseRunnerHasNoFakeWorker` (also: no egress
  route, no leave to spend in a release build).
- `internal/headless` (`-tags browser`): `TestBrowserConnectionsMeteredLimitRequired`.

The §3 acceptance list for the Pi cells, in CI: the hostile repository
loads nothing (`TestPiAcceptanceHostileRepository`); only the provider
host is reachable (same test: another host 403 at the relay, no other
network); Review has no write or shell tool (`TestPiP3MCPPinning`,
`TestPiAcceptanceHostileRepository`, and the policy refusals); killing
the namespace ends every descendant (`TestPiP5DescendantTermination`);
the budget stops the next step (`TestPiBudgetHoldsTheNextStep`); a step
with no usage figure pauses the connection
(`TestPiNoUsagePausesTheConnection`); a resent usage row charges once
(`TestPiReviewStep`). The finish line: `TestPiReviewStepRealPi`, a Review
of a Claude change with the real pinned Pi on the fake TensorX, recorded
`other_family`, family `glm`, charged once, then a question that resumes
its session.

Local runs were targeted (`-run`), with `-tags testbuild` where the
seams are needed, the real-Pi tests against a local pinned install
(`EQUIPO_PI_ROOT`); plus gofmt, go vet (linux and the darwin runner
build), `rastrillo budget size` and the dead-reference scan.

## Mutations, each observed failing

- policy P1: a read-only role allowed bash, edit or write -> TestPiPolicyRefusals (review with bash/edit/write, ask with bash: accepted)
- policy P2: models.json's apiKey not required to be the variable -> TestPiPolicyRefusals (the key in models.json, a command for the key: accepted)
- policy P3: attestation did not re-read the config files -> TestPiPolicyAttestation (models.json, mcp.json changed after the policy: attested)
- policy P4: attestation ignored the tree digest -> TestPiPolicyAttestation (tree: attested)
- policy P5: --no-context-files left out of argv -> TestPiPolicyIsolatedConfiguration (argv)
- policy P6: Node's digest not checked -> TestPiPolicyRefusals (another node: accepted)
- policy P9: a Pi launch without a tool socket attested -> TestPiPolicyAttestation (tool socket missing)
- policy P10: the selection's provider not checked -> TestPiPolicyAttestation (provider)
- tree P7: a link leaving the tree accepted -> TestTreeDigest (link out of the tree)
- tree P8: a writable directory accepted -> TestTreeDigest (writable directory)
- egress E1: the release check not refusing the egress route -> TestReleaseRunnerHasNoFakeWorker (accepted the egress route)
- egress E2: the egress route built into every build -> TestReleaseRunnerHasNoFakeWorker (the release runner contains the route)
- real Pi R1: --no-context-files left out -> TestPiAcceptanceHostileRepository (the repository's AGENTS.md reached the model's system prompt)
- real Pi R3: --approve instead of --no-approve -> TestPiAcceptanceHostileRepository (the repository's EVIL-MCP loaded)
- real Pi R4: the extension's confinement off -> TestPiP2RelayForABlockedTool (/etc/hostname read without an ask)
- real Pi R5: Equipo's MCP server at codemode exposure -> TestPiP3MCPPinning, TestPiAcceptanceHostileRepository (the pinned tool not declared)
- relay R6: Node's CONNECT Host without the port refused (the relay as it was) -> TestEgressAcceptsNodeConnect, TestPiP3MCPPinning (every real-Pi request: 403 at the relay)
- relay R7: any Host header carried -> TestEgressRejectsSmuggling, TestEgressAcceptsNodeConnect
- choose C1: a metered connection a candidate without leave to spend -> TestChooseMetered (no leave: never chosen; chose tensorx-a)
- choose C2: metered ranked with the subscriptions -> TestChooseMetered (a subscription first even with less room; chose tensorx-a). First run MISSED: the order alone kept Claude first; the case with more reported room on the metered one was added, then caught
- choose C3: Pi in the coordinator row -> TestChooseMetered (never the coordinator; the matrix row)
- thin T1: a metered binding sent down the Claude path (no runPi) -> TestPiReviewStep and five more (policy_rejected)
- thin T2: leave to spend always granted -> TestPiReviewWithoutLeaveToSpend (Review ran on TensorX)
- thin T3: Review's family from the configured model, not the one that ran -> TestPiReviewFamilyFromTheModelThatRan (another model: same_account)
- thin T4: the extension's question allowed in a step -> TestPiStepRefusesAsks. First run MISSED: the tail's "Refused" line is written before the answer; the test now checks the call's outcome, then caught
- thin T5: a refused key not recorded -> TestPiKeyRefused (the connection not refused)
- thin T6: an Engineering step the guard holds not deferred -> TestPiEngineeringHeldIsDeferred. First run MISSED (no test reached Engineering's held branch); the test was added, then caught
- thin T7: a Review the guard holds not deferred -> TestPiBudgetHoldsTheNextStep, TestPiNoUsagePausesTheConnection (failed metered_held)
- release E3: the leave-to-spend seam built into every build -> TestReleaseRunnerHasNoFakeWorker (the release runner contains it)
- install V0 (a real bug, found by running install-pi twice by hand): pi.Verify took its pins from Install{}.Pinned(), which reports not ok for an empty install, so every install was refused; fixed to read the platform's pins; TestPinnedInstallVerifies covers it
- install V1: the tree digest not compared -> TestPinnedInstallVerifies (another tree verified)
- install V2: Node's digest not compared -> TestPinnedInstallVerifies (another Node verified). First run MISSED (the test had no right tree beside a wrong Node); the case was added, then caught
- page B1: the confirmation not required in the form -> TestBrowserConnectionsMeteredLimitRequired (1280 and 390: not required and unticked)
- instance B2: the server not checking the confirmation -> TestBrowserConnectionsMeteredLimitRequired (the stripped form went through: no refusal)
- decode D1: a retry Pi will make taken as the end -> TestDecodeEndings (rate-limited: four ends)
- decode D2: a 401 not classed as a refused key -> TestDecodeEndings (key-refused: provider)
- decode D3: usage complete before agent_end -> TestTallyUsage (complete before the end)
- decode D4: unknown events not counted -> TestDecodeUnknownEvents
- decode D5: system and user messages' usage counted -> TestDecodeRecordedRuns, TestTallyUsage
- decode D6: Pi's unpriced zero cost recorded as a reported cost -> TestTallyUsage

## Security round (Astra, read-only, on ca3e7bb0)

Verdict NOT READY, nine findings, all mechanical; each fixed with a test
written first and a mutation observed. Nothing was found against the
relay's Host change, the gitleaks entry or the leave-to-spend seam.

1. The Pi tree hashed by path, then mounted by a fresh open
   (`containment/mounts.go`): the containment now hashes the tree again
   through the very descriptor it mounts and refuses a mismatch; an
   install root anyone else could write (other-writable without the
   sticky bit, or group-writable for a group that is not this user's own),
   an entry another user owns, and a file with a second name (a hard link
   another path could write through) are refused at the policy, the
   attestation and `pi.Verify`. `TestNamespacePiTreeSwapAfterAttestation`
   swaps a file and the whole directory after the attestation.
2. A Pi that stops reading its stdin held the runner (`pi/rpc.go`): writes
   take their own lock, never held by a waiting caller, and give up with
   their context; Interrupt is bounded by its context, cancelling pending
   dialogs first; a cancelled step asks Pi to stop aside while the
   namespace is killed regardless. `TestClientWritesAreCancellable`,
   `TestLauncherInterruptIsBounded`.
3. Missing usage counted as zero (`pi/decode.go`): a message without
   usage, without input or output, with a negative figure, a run with no
   message at all, and a sum that overflows (checked addition) leave the
   attempt's figures null, so the spend is unknown however the run ends.
   `TestTallyUnknownUsage`, `TestPiEndWithoutUsagePausesTheConnection`.
4. Configuration accepted by secret-shaped names only (`check_policy.go`):
   the policy rebuilds models.json, settings.json and mcp.json from the
   provider and model and accepts exactly those (no other MCP server,
   command, argument or exposure, no other setting, no other field, the
   provider table's base URL), and pins the extension's digest; the
   extension moved into the provider package. New cases in
   `TestPiPolicyRefusals`, `TestPiBaseURLsAreTheProviders`.
5. The key in logs and reports (`thin/pistep.go`): the runner reads the
   launch's key once and redacts it (as itself and as JSON text) from every
   delta, as a stream so a key split across deltas is caught, the step
   log, the tail, activity subjects, provider errors, unknown event names
   and the arguments Pi gives Equipo's tools. `TestPiRedactsTheKey`,
   `TestRedactorStream`.
6. Unbounded text and queues (`thin/pistep.go`, `pi/rpc.go`): the client
   keeps at most 16 MiB of records (Pi waits for the rest), a record over
   8 MiB ends the stream, events carry no tool arguments over 64 KiB,
   the events channel holds 64, and a reply over 1 MiB ends the run with
   its usage incomplete (spend unknown). `TestClientQueueIsBounded`,
   `TestDecodeClipsToolArguments`, `TestPiOversizedReply`.
7. A kept Pi session moved to a recovered subscription
   (`connect/choose.go`): with leave to spend, a usable kept metered
   connection is chosen first, before subscription precedence; the guard
   then holds the round there (busy, budget), it does not move; an
   Engineering fix round now finds a kept Pi transcript.
   `TestPiKeptSessionStaysPut`, new `TestChooseMetered` cases.
8. Lexical link containment (`provider/tree.go`): links are followed
   link by link under the root, refusing escapes, dangling links, absolute
   targets and chains over 40 (cycles); the CI installer does the same.
   New `TestTreeDigest` cases.
9. The leave-to-spend release check untested on its own
   (`release_guard_test.go`): `TestReleaseCheckRefusesEachMarker` hands
   the script one marker at a time.

Decisions within the findings: group write on an install root is allowed
only for this user's own group (Debian's user private groups make
`~/.cache` group-writable); a kept metered session without leave to spend
is not kept (no leave, no metered run: decision 5), which no release build
meets before S3; a Review whose verdict was already recorded through
Equipo's tool keeps it when its reply is then cut for length.

Mutations observed:

- S8a: link containment lexical again (the old prefix check) -> TestTreeDigest (a chain out of the tree, a dangling link, a cycle: accepted)
- S8b: a link to nothing accepted -> TestTreeDigest (a dangling link)
- S8c: the hop limit removed -> TestTreeDigest (a cycle: the walk never ends; the run fails at its 20s timeout). Raising the limit to 100000 instead was MISSED: the cycle is still refused, only later, so that change is not observable
- S1a: a file with a second name accepted -> TestTreeDigest (a second name for a file)
- S1b: the mount not hashing the tree through its retained descriptor -> TestNamespacePiTreeSwapAfterAttestation (file, directory: a tree changed after its attestation was mounted)
- S1c: an install root others can write accepted -> TestPiPolicyRefusals (an install root others can write)
- S9: the release script not refusing the leave-to-spend marker -> TestReleaseCheckRefusesEachMarker (a binary with only that marker was accepted). Before the fix, TestReleaseRunnerHasNoFakeWorker alone passed with this change, as the finding says
- S3a: a run with no assistant message counted as zero -> TestTallyUnknownUsage (no message at all)
- S3b: a message without countable usage counted as zero -> TestTallyUnknownUsage (without usage, negative, not an object, without input, one good and one without)
- S3c: unchecked sums -> TestTallyUnknownUsage (a sum that overflows)
- S3d: missing input or output read as zero -> TestTallyUnknownUsage (usage without input, without output)
- S3e: as S3a, through a whole step on fakepi -> TestPiEndWithoutUsagePausesTheConnection (charged zero, spend not unknown)
- S4a: the configuration checked by secret-shaped names only (as it was) -> TestPiPolicyRefusals (an MCP server running a shell, a second MCP server, a field in a model, a command for the key, a token in settings: accepted)
- S4b: the extension's digest not pinned -> TestPiPolicyRefusals (another extension)
- S4c: a base URL that is not the provider table's -> TestPiBaseURLsAreTheProviders
- S2a: a write that waits for Pi however long (as it was) -> TestClientWritesAreCancellable, TestLauncherInterruptIsBounded (both hang to the 30s test timeout)
- S2b: the interrupt's dialog cancellation ignoring its context -> TestLauncherInterruptIsBounded (hangs to the timeout). First run MISSED: the test's Pi had no pending question, so no cancellation was sent; the stuck Pi now asks one first, then caught
- S6a: the reply text not capped -> TestPiOversizedReply (no cut, spend not unknown)
- S6b: the client's byte budget off -> TestClientQueueIsBounded (2020 bytes queued in 20 records against 300)
- S6c: tool arguments not clipped in events -> TestDecodeClipsToolArguments (a 200047-byte payload)
- S6d: no record size limit -> TestClientQueueIsBounded (the oversized record is taken and the test hangs to its timeout)
- S5a: Equipo's tools given Pi's arguments unredacted -> TestPiRedactsTheKey (the report holds the key: the verdict's headline and summary)
- S5b: deltas redacted one by one, not as a stream -> TestPiRedactsTheKey (the key split across two deltas reached the report's tail)
- S5c: the step log written unredacted -> TestPiRedactsTheKey (the step log holds the key)
- S5d: the stream holding nothing back -> TestRedactorStream (pieces of 1: the key passed)
- S7a: a kept metered session not resolved first (as it was) -> TestChooseMetered (kept on metered, a subscription usable: chose c1), TestPiKeptSessionStaysPut (the round moved to claude-a)
- S7b: a kept metered connection kept even when it cannot run (refused) -> TestChooseMetered (kept on metered, refused)
- S7c: a fix round not finding a kept Pi transcript -> TestPiKeptSessionStaysPut (the kept Pi session was not found)

## Decisions where the spec was open

- Leave to spend (controller, 2026-11-12, option A): `connect.Choose`
  takes it explicitly; it is false for every step in a release build until
  S3 sets it from `urgent` and Run now, so nothing selects TensorX in
  production yet. The CI tests set it through a seam that exists only in a
  test build (`spend_testbuild.go`), as are the egress route to a loopback
  provider and the test CA; `scripts/no-fake-worker.sh` refuses a release
  binary that contains any of them. No runner switch was built.
- A metered connection is chosen only when no subscription connection can
  run the role (§7 rules 3 and 4), even with leave.
- Pi's config directory is in the attempt's runtime home, not a read-only
  mount: Pi writes there. The files are the runner's, hashed and read back
  before launch; a model could change them only inside its own attempt,
  after Pi read them.
- The tree digest covers modes as the seal sets them; the seal is part of
  the install.
- Review's tools: `read, grep, find, ls` and its Equipo tools; questions
  the same with `git_log`, `git_diff`, `git_show`; Engineering also
  `bash, edit, write`. Equipo's MCP server at `direct` exposure,
  `autoEnableCodemode: false`; the role names every MCP tool exactly.
- The repository's AGENTS.md is not loaded as context (`--no-context-files`):
  the hostile fixture is exactly an AGENTS.md asking for a tool. The model
  can still read it with `read`, as file contents.
- The reported cost is Pi's `usage.cost.total` only when Pi priced it
  (`totalFromProvider`, or a non-zero figure): models.json carries no
  prices, so a TensorX-reported cost is the only one Pi can give. With
  none, the priced figure alone is charged.
- Usage is complete at the `agent_end` that will not retry; Pi's own
  retries (three, on 429 and connection errors) belong to the attempt.
- A 429 after Pi's retries marks the connection limited with no reset
  (TensorX reports only per-minute limits, §4.1).
- Equipo picks the Pi session id (`--session-id`), so a kept session is
  found by it; the transcript is copied out to the step's keep directory.
- The family is the vendor of the model id (`z-ai` is glm, `moonshotai`
  kimi, `qwen`, `deepseek`, `minimax`), from the model Pi says answered.
- Pi is not in the release manifest (whose schema lists single programs);
  a runner gets it with `install-pi` and `EQUIPO_PI_ROOT`, and without it
  runs no metered step (`account_unavailable`).

## New copy keys

None. A refused key reads with S1's `chat.connections.reason.key_refused`
and the connection's sign-in-again state; the step tail lines are the
runner's log tail, not app copy.

## Staging witness (later, after S3)

The spec's finish line, a real Review on TensorX GLM on staging, needs a
step with leave to spend, which only S3 gives (an `urgent` task, or Run
now). It waits for S3. Then:

1. On the staging runner: `equipo-runner install-pi
   /home/<runner>/.local/share/equipo-runner/pi`, add the printed
   `EQUIPO_PI_ROOT` to the service environment, `equipo-runner
   verify-installed`, restart the unit.
2. Paul adds TensorX in Settings, Connections, Add a connection: confirms
   the spending limit (a small prepaid balance, no automatic top-up), keeps
   the $1 and $10 budget, pastes the key, picks `z-ai/glm-5.3`; the
   one-token probe makes it Ready and appears on the spend line.
3. A small task on a test repository whose Engineering runs on Claude,
   marked `urgent` (S3), or its Review released with Run now; with
   Claude's other accounts limited or absent, Review runs on TensorX.
4. Witness: the Review step's family `glm` and label `other_family`; its
   usage row with `cost_micros` and the spend line moved by the same
   amount; TensorX's dashboard shows the calls; the runner log shows no
   egress denial and no `pi unknown events` line (or names them).
5. Ask the Review a question: it answers from its session, on TensorX,
   charged.
6. Check again on the connection and sign out at the end.

## Open

- The staging witness waits for S3 (above).
- No full headless scenario (instance, runner process, forge) runs a Pi
  step; the finish line runs the real Review step in thin with real
  containment.
- Mac runners: Pi stays parked (rev 3 §5), no srt profile for it.
- Equipo answers the extension's questions with a refusal only; relaying
  one to the person is not built (no role needs it).
