oficina / equipo Public

Merge design-connections (eaf2f38) into thin-v1-conn1

The revised Connections spec after Astra's review: slice 1 as gates 1a
to 1d.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 06c0c2c4a6af13d8db0cdfe062dbf556c4116c54 parent 076eba3parent eaf2f38
1 file changed, +406 −241
  • docs/superpowers/specs/2026-11-08-equipo-connections.md +406 −241
diff --git a/docs/superpowers/specs/2026-11-08-equipo-connections.md b/docs/superpowers/specs/2026-11-08-equipo-connections.md
index d18e5ef3..8fdab039 100644
--- a/docs/superpowers/specs/2026-11-08-equipo-connections.md
+++ b/docs/superpowers/specs/2026-11-08-equipo-connections.md
@@ -1,6 +1,7 @@
# Equipo Connections: accounts added from the app, any provider for any role
-Status: design for Paul's review, 2026-11-08. Drafted by Claude (Fable 5.1)
+Status: design for Paul's review, 2026-11-08, revision 2 after Astra's
+round 1 (NOT READY at 28f8455). Drafted by Claude (Fable 5.1)
on `design-connections` from `thin-v1-slice4c` (2d1edaf). Builds on the
approved thin v1 spec (`2026-11-06-equipo-thin-v1.md`, §§2, 3, 5, 6, 8) and
the accepted Mac runners spec (`2026-11-07-equipo-mac-runners.md`). Not
@@ -92,10 +93,11 @@ it is for API-key connections only).
resetsAt, utilization}` (the Agent SDK's `SDKRateLimitEvent`), derived
from the `anthropic-ratelimit-unified-*` response headers; retries show
as `system/api_retry` with `error: "rate_limit"` and `retry_delay_ms`.
-`utilization` is a single number; per-window (five-hour versus weekly)
-figures are requested in issues #50518 and #91857 but not documented, so
-Equipo shows the one figure the CLI gives and names the window only when
-the reset time makes it obvious. Each `result` message carries `usage`
+Both `resetsAt` and `utilization` are optional, and `utilization` is a
+single number; per-window (five-hour versus weekly) figures are
+requested in issues #50518 and #91857 but not documented, so Equipo
+shows the one figure the CLI gives, never names a window, and copes with
+either field missing. Each `result` message carries `usage`
(`input_tokens`, `output_tokens`, `cache_creation_input_tokens`,
`cache_read_input_tokens`), `modelUsage` per model (`inputTokens`,
`outputTokens`, `cacheReadInputTokens`, `cacheCreationInputTokens`,
@@ -136,7 +138,11 @@ a route for Equipo.
**Headless and tools.** The path thin v1 §3 already designed:
`initialize`, `thread/start` or `thread/resume`, `turn/start`,
`item/agentMessage/delta`, the four approval requests answered deny or
-relayed as `ask_person`, `turn/interrupt`. Codex remains an MCP client
+relayed as `ask_person`, `turn/interrupt`; a turn ends on
+`turn/completed` whose `status` is `completed`, `failed` or
+`interrupted` (there is no separate `turn/failed`; the decoder in
+`provider/codex/events.go` already switches on these). Codex remains an
+MCP client
(`codex mcp`; `codex mcp-server` was removed in favour of the app-server,
which is not an MCP server). Custom providers in `config.toml` take
`base_url`, `env_key`, `http_headers` and `wire_api`, and **`responses`
@@ -184,9 +190,10 @@ already do some of it, which sets the bar:
Messages API. Ollama and vLLM now serve `/v1/messages` natively
(`ANTHROPIC_BASE_URL=http://localhost:11434`,
`ANTHROPIC_AUTH_TOKEN=ollama`), so local models can run under the
- Claude harness with no proxy; OpenRouter, TensorX and Mistral cannot
- without a translating proxy, and Anthropic says it does not support
- routing Claude Code to non-Claude models.
+ Claude harness with no proxy, and TensorX documents the same route
+ (§1.5); OpenRouter and Mistral cannot without a translating proxy,
+ and Anthropic says it does not support routing Claude Code to
+ non-Claude models.
Neither covers every endpoint, which is why §1.4 verifies Pi and
OpenCode as the dedicated OpenAI-compatible harness. The verdict and the
@@ -273,11 +280,12 @@ but cannot ask a person; default provider is its own metered backend
(browser OAuth or `COMMAND_CODE_API_KEY`), with ChatGPT and Copilot
subscription logins and a BYOK file for Ollama, vLLM and OpenRouter
behind `--local-only`; no sandbox; auto-update, telemetry, a remote
-model catalogue and credit checks to switch off. Verdict: not a
-coordinator (no live relay, no long-lived mode); possible for
-Engineering and Review behind BYOK, proprietary, and nothing it does
-is unavailable in Pi. It stays in the plan as Paul asked, last, and
-is marked "Engineering and Review only" in the matrix.
+model catalogue and credit checks to switch off. It also documents `cmd acp` (ACP over stdio), which
+is a long-lived, prompt-and-permission protocol; whether its permission
+requests reach the host and whether MCP tools are callable under it is
+unprobed. Verdict: proprietary and backend-tied, nothing it does is
+unavailable in Pi, so it comes last; its coordinator cell is "probe
+`cmd acp` before deciding", not "no".
**Decision.** Pi is the one OpenAI-compatible harness for local
models, TensorX (chat wire), the Mistral API, OpenRouter and the CARLOS
@@ -356,11 +364,13 @@ spend is computed from tokens and the price table (Large 4 $0.70 in
and $2.10 out, Small 4 $0.15 and $0.60, Codestral 25.08 $0.30 and
$0.90).
-Vibe is also a candidate for the single OpenAI-compatible harness
-(§5): it has the headless mode, streaming JSON, MCP, resume, hooks and
-custom providers that §1.4 asks of Pi and OpenCode, with the drawback
-of being Mistral's product driving other people's models. The matrix
-in §5 scores it beside them.
+Vibe also documents an experimental `run-server` mode, so a long-lived
+coordinator process is not ruled out; whether it relays approvals to a
+host is unprobed, and the matrix marks its coordinator cell "probe
+`run-server` before deciding". It is a candidate for the single
+OpenAI-compatible harness too (headless mode, streaming JSON, MCP,
+resume, hooks, custom providers), with the drawback of being Mistral's
+product driving other people's models; §5 scores it beside Pi.
### 1.7 Later: Gemini and Muse
Both are parked, with the facts that decided it. Gemini CLI was
@@ -397,9 +407,11 @@ for `capabilities`. On the runner, the same connection is a dedicated
home `~/.local/share/equipo/accounts/<provider>-<n>` (today's layout),
a `connections` table row with the same id, and whatever the harness
keeps there. The existing `wire.Account {id, provider, email, healthy,
-headroom}` in `hello` grows into this record (§7); `accounts` as a word
-stays in the wire for compatibility and in copy as "accounts" where it
-reads better than "connections".
+headroom}` in `hello` is **replaced** by this record under
+`hello.connections` (§7), with the runner protocol version bumped as the
+Mac spec does; `accounts` leaves the wire. In copy the word "account"
+survives only where it names the provider's own thing ("your Claude
+account").
Every flow below is a **connection attempt**: the app POSTs
`/api/v1/connections` with `{provider, kind, runner_id}`, the instance
@@ -471,19 +483,18 @@ person's browser is relative to the runner:
or in a terminal there run `equipo-runner login claude` and paste
the code where the CLI asks. The paste goes into the CLI, on the
runner, never into Equipo.
-3. **Last resort, `setup-token`.** A person who runs
- `claude setup-token` on any machine gets a one-year token. Equipo
- does not accept it in the app (holding it on the instance even in
- transit is storing a session token). The runner's terminal command
- `equipo-runner login claude --token` can read it from the terminal
- into the account's home as `CLAUDE_CODE_OAUTH_TOKEN` for that home's
- launches; it is marked `kind: subscription, method: token`, shown
- with its expiry, and excluded from `--bare` launches. Documented,
- not promoted.
+3. **No token importer.** `claude setup-token` prints a one-year token;
+ a person could type it into a terminal on the runner, but Equipo's
+ command reading it would be Equipo handling a subscription token,
+ which is the intermediation the terms forbid. There is no `--token`
+ path. Claude is signed in only directly to the unmodified binary:
+ loopback on the runner's machine, or finish signing in on the
+ runner. A Claude **API key** connection (§2.4) is the way to use
+ Claude without a browser on that machine.
**Adding a second Claude account in the app** is therefore: tap Add,
choose Claude, and either finish on the runner's machine (no paste) or
-be told plainly that this one needs a terminal there. On Linux every
+be told plainly to finish signing in on the runner. On Linux every
Claude account gets its own home and the copy cycle of thin v1 §2
applies unchanged; the Mac's Keychain question (Mac spec §3.4, probe P3)
decides whether a Mac runner can hold more than one Claude account.
@@ -491,37 +502,75 @@ decides whether a Mac runner can hold more than one Claude account.
### 2.4 API keys, sealed to the runner
The app never sends a key to the instance in the clear, and the instance
-never stores one. The runner already holds an ed25519 identity key from
-enrolment (`internal/runner/enrol.go`); `hello` adds a `seal_key`, an
-X25519 public key derived for this purpose, and the instance republishes
-it on the `Runner` resource. The app seals the key with libsodium's
-`crypto_box_seal` (NaCl sealed boxes: ephemeral sender key, X25519,
-XSalsa20-Poly1305; one call in Swift, Kotlin, Go and the browser's
-libsodium build) and POSTs `{provider, kind: api_key, sealed}`. The
-instance copies the opaque bytes into the `connect` frame, keeps them
-only in the durable mailbox until the runner acks, then deletes the
-payload column and keeps the frame id. The runner opens the box, writes
-the key into the home (`ANTHROPIC_API_KEY` in a 0600 env file for
-Claude; `codex login --with-api-key` on stdin for Codex; the harness's
-own auth file for an endpoint), zeroes the buffer, makes one test call
-(`/v1/models` or the harness's cheapest request), and reports `healthy`
-or `provider_refused`. A sealed payload is capped at 4 KB and never
-logged; the mailbox table's payload column is excluded from every
-diagnostic dump, as credential bytes already are. The instance can read
-nothing, a database export carries nothing, and a replayed frame to a
-different runner cannot be opened. Rotation is "sign out, add again".
-
-### 2.5 Endpoints, with a test call
+never stores one it can read. The runner holds an ed25519 identity key
+from enrolment (`internal/runner/enrol.go`), whose fingerprint the owner
+checked on the approval page (`runner.fingerprint`). The **seal key** is
+the X25519 key derived from that same ed25519 key (the standard
+birational map, as libsodium's `crypto_sign_ed25519_pk_to_curve25519`),
+so the public key the instance republishes on `Runner.seal_key` is
+verifiable by the app against the fingerprint approved at enrolment,
+and a substituted key would not match it. The native apps compare and
+refuse; the web app trusts the instance it is served by, which is
+already true of everything it shows, and that limit is stated in the
+Connections screen's help text.
+
+**Sealing.** The app seals with libsodium `crypto_box_seal` over a
+payload `{secret, runner_id, connection_id, provider, endpoint_host,
+attempt, expires_at}`; the instance-visible fields (`runner_id`,
+`connection_id`, `provider`, `endpoint_host`, `attempt`, `expires_at`)
+travel beside the box in the clear and the runner **rejects the box if
+any of them differs from the plaintext inside**, if `expires_at`
+(ten minutes from sealing) has passed, if the connection attempt is
+not the one it is currently running, or if the `(connection_id,
+attempt)` pair has been seen before (a `seen_seals` table kept for a
+day). The instance copies the opaque box into the durable `connect`
+frame; the runner opens it, writes the secret into the home
+(`ANTHROPIC_API_KEY` in a 0600 env file for Claude; `codex login
+--with-api-key` on stdin for Codex; the harness's auth file for an
+endpoint), fsyncs, zeroes the buffer, and **only then acks** the
+frame; a crash before the ack means a resend, which the `seen_seals`
+check turns into a no-op if the write had landed. The instance then
+deletes the payload column. Honesty about that deletion: the
+ciphertext may persist in SQLite's WAL and in backups until they
+rotate. It is useless without the runner's private key, it names an
+attempt that cannot be replayed, and it expires in ten minutes, so the
+design accepts that residue and says so; it does not claim erasure.
+**Cancel** during `connecting` writes a `cancelled` marker the runner
+checks before writing the secret; a late success report for a
+cancelled attempt is dropped by the instance (`Attempt` and state
+checks as `chat/runner.go` does for turns) and the runner deletes the
+home. A sealed payload is capped at 4 KB and never logged; the mailbox
+payload column is excluded from every diagnostic dump, as credential
+bytes already are. Rotation is "sign out, add again". Sealed keys land
+in slice 2 with the endpoints; slice 1 has no key entry.
+
+### 2.5 Endpoints, with a test call (slice 2)
An endpoint connection is `{base_url, label, sealed key or none,
-harness}`. The runner resolves the host, refuses loopback and LAN
-addresses unless the connection is marked `local` (a local Ollama is the
-point, so `local` is allowed and the egress relay for that connection
-admits exactly that host and port), fetches `/v1/models`, makes a
-one-token completion with the first model, records the model list and
-the latency, and reports `healthy` with `models[]`. The card shows the
-models and lets the person pick a default; the router (§4) may use any
-of them. For OpenRouter the key can arrive by its PKCE flow (§2.6)
+harness, local}`. Two transports, because the existing egress relay
+cannot carry the local case: `egress/proxy.go` accepts one bounded
+CONNECT to a public DNS name on port 443, and the namespace's
+`localhost` is not the host's, so an Ollama on the runner's machine is
+unreachable through it by design. **Public endpoints** (TensorX,
+Mistral, OpenRouter, the CARLOS gateway) use the existing relay with
+the connection's host added to its allow list for that connection's
+actions, HTTPS only. **Local endpoints** use a second, narrower
+listener the runner opens outside the namespace and binds into it on a
+fixed loopback port: it forwards plain HTTP to exactly one `host:port`
+recorded on the connection (the host's loopback or a LAN address the
+person typed), resolves the name once at connect time and pins the
+address, refuses redirects (`3xx` is returned to the harness as an
+error, never followed), admits only the HTTP methods and paths an
+OpenAI-compatible client uses, and is mounted only for actions on that
+connection. The harness is pointed at the loopback port, not at the
+host. On connect the runner fetches `/v1/models`, makes a one-token
+completion with the first model, records the model list and latency,
+and reports `healthy` with `models[]`; the card shows the models and
+lets the person pick a default. Probes before this ships (slice 2):
+the local listener is unreachable from a step whose connection is not
+local; a redirect from the endpoint is refused; a DNS change after
+connect does not move the pinned address; the listener dies with the
+namespace. For OpenRouter the key can arrive by its PKCE flow (§2.6)
instead of typing.
### 2.6 OAuth without a paste: what each provider allows
@@ -536,7 +585,7 @@ sources in §1:
| Codex (API key) | Sealed key | No | n/a | Runner home |
| Claude (subscription), browser on runner's machine | CLI's own loopback OAuth, app shows the link | No | Runner, by the CLI | Runner home (`.credentials.json`, or Keychain on a Mac) |
| Claude (subscription), runner remote | Terminal at the runner: `equipo-runner login claude` | Yes, into the CLI, never into Equipo | Runner, by the CLI | Runner home |
-| Claude (`setup-token`) | Terminal at the runner, `--token` | Yes, into the terminal | n/a | Runner home, one year |
+| Claude (`setup-token`) | Not offered: Equipo would be handling the token | n/a | n/a | n/a |
| Claude (API key) | Sealed key | No | n/a | Runner home |
| OpenRouter | PKCE: app opens `openrouter.ai/auth?callback_url=…&code_challenge=…`; the callback lands on Equipo's web app or the native app's link; the app seals `code` plus `code_verifier` to the runner, which POSTs `/api/v1/auth/keys` and keeps the returned key | No | Runner | Runner home |
| Local or other endpoint | Sealed key or none, test call | No | n/a | Runner home |
@@ -544,124 +593,193 @@ sources in §1:
| Gemini (later) | Fixed Google client, loopback only; `NO_BROWSER` pastes a code; third-party use of the Code Assist service forbidden | Yes | CLI | CLI home |
Only OpenRouter (and Hugging Face) let a third party register or skip
-a client and receive the redirect at a URL Equipo controls; for them the
-redirect lands on the app and the exchange still happens on the runner,
-with the verifier sealed so the instance sees an opaque box. OpenRouter
-publishes "localhost callbacks are supported on any port"; whether a
-custom scheme is accepted is unconfirmed, so the native apps use an
-https app link to the Equipo web origin until that is checked. Codex
-needs no paste because device code is its own protocol. Claude is the
-one subscription where the loopback is the only no-paste path, and the
-terms make the paste belong to the CLI; Equipo's job is to make the
-same-machine case recognisable and the remote case honest.
+a client and receive the redirect at a URL Equipo controls. For
+OpenRouter the flow is hardened as follows: the app generates the
+verifier and uses `S256`; the `callback_url` is an instance route that
+carries the connection attempt id in its path and serves a page with
+`Referrer-Policy: no-referrer` whose first act is to read `code` from
+the query, replace the URL without the query (`history.replaceState`)
+and seal `{code, code_verifier}` to the runner bound to that attempt
+(§2.4); the instance's access log for that route omits the query
+string; a code older than ten minutes (OpenRouter's own expiry) or for
+an attempt that is not `connecting` is refused by the runner, which
+does the exchange at `/api/v1/auth/keys` and keeps the returned key.
+The instance sees the code for the duration of one request and
+never stores it; that is a weaker guarantee than for typed keys and
+the spec says so. Whether OpenRouter accepts a custom scheme is
+unconfirmed, so the native apps use an https app link to the Equipo
+origin. Codex needs no paste because device code is its own protocol.
+Claude is the one subscription where the loopback is the only no-paste
+path, and the terms make the sign-in belong to the CLI; Equipo's job is
+to make the same-machine case recognisable and the remote case honest.
### 2.7 Health, headroom, limits, refresh, sign out
**Health** is what the runner can prove: a `healthy` connection has a
valid credential (the CLI refresh under the source lock for Claude,
-`account/read` for Codex, a `/v1/models` call for an endpoint) checked on
-start, hourly, and before any turn that needs a fresh copy, as today.
-`sign_in_again` is set when refresh fails or reports a different
-identity (thin v1 §2). **Limited** is new: a connection whose provider
-said no to the last request on quota, with `resets_at` when the provider
-gave one. Sources: Claude `rate_limit_event {status: rejected,
-resetsAt}` and `api_retry {error: rate_limit}`; Codex
-`account/rateLimits/updated` with a window at `usedPercent` 100 or
-`rateLimitReachedType` set, and `turn/failed` on quota; endpoints and
-OpenRouter an HTTP 429, with `Retry-After` or the provider's reset
-header when present and otherwise a fifteen-minute cool-off that doubles
-to an hour. Headroom is whatever the provider reports and nothing else:
-Claude's single `utilization` and `resetsAt`, Codex's two windows, an
-endpoint's nothing (shown as "unknown"). A connection leaves `limited`
-when `resets_at` passes or a probe succeeds; the runner probes with the
-cheapest request the harness has, never a model turn, at most once per
-fifteen minutes. **Sign out** is `DELETE /connections/{id}`: the runner
-runs the harness's own logout (`claude auth logout`, `account/logout`,
-or nothing for a key), deletes the home, ends sessions on that
-connection (their rows stay, marked `connection_removed`), and reports
+`account/read` for Codex, the harness's cheapest request for an
+endpoint) checked on start, hourly, and before any turn that needs a
+fresh copy, as today. `connecting` is not healthy and is never chosen.
+`sign_in_again` is set on an `auth` failure (§3) or when refresh reports
+a different identity (thin v1 §2). **Limited** is set on a `quota`
+failure, with `resets_at` when the provider reported one. **All
+telemetry comes from the harness side**: Claude's stream-json
+(`rate_limit_event`, `api_retry`, `result`), the Codex app-server's
+notifications (`account/rateLimits/updated`, `thread/tokenUsage/updated`,
+`turn/completed`), and in slice 2 Pi's JSONL events. The egress relay
+is a CONNECT tunnel (`egress/proxy.go`: one bounded CONNECT, port 443,
+public addresses only) and cannot see upstream headers, so no design
+here reads `Retry-After` or `x-ratelimit-*` off the wire; a metered
+endpoint's limit is whatever its harness reports, and where the harness
+reports nothing the connection becomes `limited` on the harness's
+error event with no reset time and a cool-off of fifteen minutes,
+doubling to an hour. Headroom is whatever the provider reports and
+nothing more: Claude's optional `utilization` and `resetsAt` (one
+figure, never labelled "weekly" or "session" because the SDK does not
+say which window it describes), Codex's `primary` and `secondary`
+windows when present, an endpoint's nothing ("unknown"). The Codex
+decoder today validates and discards rate notices (`rate_notice_test`);
+keeping them as state is slice 1 work. A connection leaves `limited`
+when `resets_at` passes or a probe succeeds; the probe is the harness's
+cheapest request, never a model turn, at most once per fifteen minutes.
+**Sign out** is `DELETE /connections/{id}`: the runner runs the
+harness's own logout (`claude auth logout`, `account/logout`, or
+nothing for a key), deletes the home, ends sessions on that connection
+(their rows stay, marked `connection_removed`), and reports
`signed_out`; the instance keeps the row thirty days for Usage history
and then deletes it.
+
## 3. Selection and failover
-**The choice.** For each run the runner picks a connection from the
-person's own connections on the runner that holds the session or task,
-in this order: capable of the role (the matrix in §5); not `limited`,
-`sign_in_again`, `error` or `signed_out`; the role's preference if the
-person set one (§3, last paragraph); then the router's class (§4); then
-the most headroom, where a subscription's headroom is the provider's
-reported figure, a metered connection's is "unlimited at a price", and a
-local endpoint's is "unlimited and free" but slow and small. Ties go to
-the connection that ran this session or task last, so sessions do not
-hop for nothing. The function stays small and pure: inputs are the
-connection list, the role, the class, the preference and the current
-binding; the output is one connection id and a reason code. It is unit-tested with a table and it is the only place that chooses: it
-replaces `pickReviewer` in `internal/runner/thin/judge.go` and the
-coordinator's binding choice, and it returns a `runner.AccountBinding`
-as they do.
-
-**Coordinator failover mid-conversation.** A turn fails on quota
-(§2.7's signals) or on a provider error the retry policy gives up on.
-The runner marks the connection `limited` with `resets_at`, picks again,
-and if a connection remains it starts a **new session** there (thin v1
-§2: a fresh process, the notebook, the house rule, the 50-message tail
-and a short summary of the current turn written by the runner from the
-tail, not by a model), replays the turn's frame, and the person sees the
-reply arrive with one quiet line under it: "Switched to Codex; Claude's
-weekly limit resets Mon 10:00" (`chat.switched`, with `resets_at`
-rendered in the person's zone, or "Switched to Codex" when there is no
-reset time). The old `sessions` row stays for resume when its
-connection is healthy again; whether the coordinator moves back is the
-same choice function at the next turn start, so a preferred connection
-returns on its own once it has headroom, with a line only when the
-switch happens. The draft deltas of the failed attempt are discarded as
-on cancel; the turn's `attempt` increments; the SSE client sees
-`turn{state: running, attempt: 2}` then deltas, never a failure.
-
-**Engineering mid-step.** A step whose harness dies on quota is a
-failed attempt, as any crash is today: the runner waits for the
-termination proof (pidfd exit of the namespace, thin v1 §4), commits
-nothing (the worktree is discarded; an attempt's partial work is not a
-candidate), picks another connection avoiding the one that failed
-(`avoid_account` already exists on review dispatch and becomes a list
-on every dispatch), and starts attempt n+1 on it with the same brief.
-The step row records both attempts and their connections; the task
-card shows "Engineering on Codex (Claude was limited)". If no
-connection can run Engineering the step waits in `queued` with reason
-`no_connection` and the task shows what to add; it resumes without a
-retry when a connection becomes healthy.
-
-**Review across families.** Thin v1 §3's rule stands and gets its
-third option: Review runs on another family if a healthy, capable
-connection exists (`other_family`), else another connection of the same
-family with fresh context (`same_family`), else a fresh session on
-Engineering's connection (`same_account`). The label is recorded on the
-step and shown, as today. With Codex and an endpoint in the mix,
-`other_family` becomes the common case.
-
-**Ask the implementer** stays bound to the step's own session and
-connection (slice 4b); if that connection is `limited` the question
-fails `account_unavailable` with the reset time in the card, because a
-different model reading the transcript is not the implementer.
-
-**"No connection can answer."** When the choice function returns
-nothing for the coordinator, the turn ends `failed` with the new reason
-`no_connection` and the chat shows a card instead of `chat.failed`:
-"Nothing can answer right now. Claude resets Mon 10:00; Codex is signed
-out." with one action, **Add a connection**, and the message stays
-queued to be sent when a connection returns (the person can delete it).
-The old line "Send your message again to retry" is removed; retrying
-was never the person's job. `wire.Reasons` gains `no_connection`;
-`Task.NeedsYou` gains `no_connection`.
+**The choice.** For each run the runner picks a **connection and model
+pair** from the person's own connections on the runner that holds the
+session or task. Eligible pairs are those whose matrix cell (§5) says
+yes for the role and whose connection is `healthy` (not `connecting`,
+`limited`, `sign_in_again`, `error` or `signed_out`). Among eligible
+pairs the order is: the current binding, if the session or step already
+has one and it is eligible (stickiness is a rule, not a tie-breaker:
+a session leaves its connection only on failure or an explicit
+override); then the tier floor the router set (§4); then the person's
+preference for the role (§3, last paragraph); then headroom, where a
+subscription's headroom is the provider's reported figure, a metered
+connection with no report is "unknown" and ranks below any connection
+with a reported figure, and a local endpoint is "unknown" too, chosen
+by tier and preference rather than by a claim of being unlimited. The
+function is small and pure: inputs are the connection list with their
+models and matrix cells, the role, the tier floor, the preference and
+the current binding; the output is one `(connection, model)` and a
+reason code. It replaces `pickReviewer` in `internal/runner/thin/judge.go`
+and the coordinator's binding choice, returns a `runner.AccountBinding`
+as they do, and is unit-tested with a table.
+
+**Failure kinds.** The runner classifies every provider failure before
+it decides anything: `quota` (Claude `rate_limit_event {status:
+rejected}` or `api_retry {error: rate_limit}` exhausting its retries;
+Codex `account/rateLimits/updated` with a window at `usedPercent` 100
+or `rateLimitReachedType` set, or `turn/completed {status: failed}`
+whose error the decoder recognises as a usage limit); `auth`
+(`authentication_failed`, `oauth_org_not_allowed`, `account_on_hold`,
+`billing_error`; Codex `account/updated` to signed out or a 401 class
+error): the connection becomes `sign_in_again`; `transient`
+(`overloaded`, `server_error`, no response): retried on the same
+connection by the existing retry policy, never a failover. Only
+`quota` makes a connection `limited`; only `quota` and `auth` trigger
+failover. Fields are optional everywhere: `resetsAt` and `utilization`
+may be absent, Codex windows may be absent; a `limited` connection
+without a reset time shows "Limited, no reset time reported" and is
+re-probed on the §2.7 schedule.
+
+**Coordinator failover, with exactly-once effects.** Today a tool call
+id is `turn/attempt/useID` (`thin/bridge.go`), so simply replaying the
+turn on a new attempt would execute `start_task`, `add_project` or
+`ask_person` again under new ids. Failover therefore runs in this
+order, each step durable before the next:
+
+1. The failed attempt is **terminated**: the runner kills the
+ namespace and waits for the pidfd exit proof (thin v1 §4), as it
+ does for cancel. No new attempt exists until then.
+2. The turn enters a new nonterminal state **`waiting`**
+ (`turn{state: waiting, reason: limited | sign_in_again}`), added to
+ the turn state machine beside `queued` and `running`; `wire.Terminal`
+ stays false for it, so `chat/runner.go` keeps accepting reports. The
+ draft deltas are discarded as on cancel. If no eligible pair exists
+ the turn stays `waiting` and the chat shows the card in the last
+ paragraph; queued messages join the waiting turn.
+3. The runner chooses a new pair and **advances the attempt** in its
+ `runs` row and in a `turn{state: running, attempt: n+1}` report,
+ which the instance accepts only as a forward transition from
+ `waiting` for that turn.
+4. Before the new process gets the frame, the runner **reconciles tool
+ effects**: it asks the instance for the recorded tool calls of the
+ turn (`tool_calls{turn}` request, answered from the stored results
+ the instance already keeps by call id, thin v1 §4) and builds the
+ new attempt's frame as the person's messages plus a short,
+ runner-written summary that lists each completed tool call and its
+ recorded result ("You already added oficina/sample; task tk_… is
+ started; the person was asked X and answered Y"). The coordinator
+ is told, in the house rule for a resumed attempt, that these effects
+ exist and are not to be repeated. On the instance side, a
+ `tool_call` whose name and arguments match a recorded call of the
+ same turn is answered with the stored result rather than executed;
+ the match key is `(turn, name, canonical args)`, and the stored
+ result is returned with `replayed: true` so the runner can log it.
+ This closes the gap for a model that repeats a write regardless.
+5. The frame goes to the new session, seeded from the notebook, the
+ house rule and the tail as thin v1 §2, and the reply arrives with one
+ quiet line under it: "Switched to Codex; Claude resets Mon 10:00"
+ (`chat.switched`), or "Switched to Codex" when no reset time was
+ reported. Returning to a preferred connection happens at the next
+ turn start when it is eligible again, with the line only when the
+ switch happens, and the old session is resumed with a fresh notebook
+ and tail injection (thin v1 §2's daily reset rule covers staleness).
+
+A cancel during `waiting` ends the turn `cancelled` and voids the
+pending frame; a cancel that arrives after step 3 targets attempt n+1
+and ignores stale reports for attempt n (`chat/runner.go` already drops
+reports for `Attempt < r.Attempt`).
+
+**Engineering mid-step.** A step whose harness fails on `quota` or
+`auth` is a failed attempt as any crash is: termination proof first,
+nothing committed (the worktree is discarded; partial work is not a
+candidate), then a new attempt on another eligible pair avoiding the
+connections that failed (`avoid_connections[]` on dispatch replaces
+`avoid_account`), same brief. The step records both attempts and their
+pairs; the card shows "Engineering on Codex (Claude was limited)".
+With no eligible pair the step waits in `queued` with reason
+`no_connection` and resumes on its own when a connection returns.
+
+**Review across families.** Thin v1 §3's rule stands, with the family
+read from the pair actually chosen, not from the connection: an
+endpoint that serves several model families is `other_family` only
+when the chosen model's family differs from Engineering's. `other_family`
+first, then `same_family` with fresh context, then `same_account`; the
+label is recorded on the step.
+
+**Ask the implementer** keeps its exact binding: the kept session on
+the connection and model that ran the step (slice 4b). It never moves;
+if that connection is not `healthy` the question fails
+`account_unavailable` with the reset time in the card.
+
+**"Nothing can answer."** When no eligible pair exists for the
+coordinator the turn is `waiting` with reason `no_connection`, and the
+chat shows a card in place of `chat.failed`: "Nothing can answer right
+now. Claude resets Mon 10:00; Codex is signed out." with one action,
+**Add a connection**. The message is not lost and is not resent by the
+person; when a connection becomes eligible the runner advances the
+attempt and the reply arrives. The person may cancel the turn.
+`wire.Reasons` gains `limited` and `no_connection`; `Task.NeedsYou`
+gains `no_connection`; the old "Send your message again to retry" line
+goes.
**The preference.** Settings gains one quiet row per role, "Coordinator
prefers", "Engineering prefers", "Review prefers", each a picker over
-the person's connections plus "Automatic" (the default). A preference is
-the first tie-breaker after capability and health, never a requirement:
-a preferred connection that is limited is skipped with the switched
-line, and a preference for a connection the role cannot use (the matrix)
-is refused in the picker. `PUT /api/v1/preferences {role, connection_id
-| null, revision}`. Per task, the task page offers "Run on …" before the
-first step starts and "Retry on …" at a failed step.
+the person's connections and, for endpoints, a model, plus "Automatic"
+(the default). It sits after the tier floor in the order above, so a
+preference cannot put a `strong` job on a `cheap` model, and it never
+overrides health. `PUT /api/v1/preferences {role, connection_id,
+model | null, revision}`. Per task, the task page offers "Run on …"
+before the first step starts and "Retry on …" at a failed step; a
+per-task choice is a tier override as well, recorded as such.
## 4. Routing: who does what
@@ -688,47 +806,52 @@ enums with one-line definitions; a missing or invalid class defaults
to `medium`, `normal`, `feature` and is recorded as defaulted. The
coordinator does not choose a connection; it describes the job.
+**Models, not connections, have tiers and families.** A connection
+offers one or more models (a subscription offers the provider's
+current models; an endpoint offers its `models[]`). The runner ships a
+static **model map**: for each known model id, its family (`claude`,
+`gpt`, `glm`, `deepseek`, `kimi`, `qwen`, `mistral`, `llama`, …), its
+tier (`cheap`, `standard`, `strong`) and, for metered connections, a
+price per million tokens with a `price_version`; an unknown model is
+`cheap`, family `unknown`, and is reported so the map can be extended.
+Two endpoints serving the same model are two pairs with the same
+family and tier; one endpoint serving several families is several
+pairs. Every step and turn records the pair that ran and its family,
+and Review's `other_family` is judged on recorded families (§3).
+
**The policy.** A table, shipped as defaults and never edited by the
-person in v1: a class maps to a **tier** (`cheap`, `standard`,
-`strong`) per role. Engineering: `small` and `low` risk start `cheap`;
-`medium` or `normal` start `standard`; `large` or `high` start
-`strong`. Review: one tier above Engineering's, minimum `standard`,
-and another family where possible. Coordinator: always `standard` or
-above (it holds the person's context; a cheap coordinator is a false
-economy). Ask: the step's own connection. Each connection carries a
-tier from a static map the runner ships (Claude and Codex
-subscriptions `strong`; TensorX kimi-k3.1-pro and Mistral Large 4
-`standard`; glm-5.3-flash, deepseek-v4-flash, Small 4 and any local
-model `cheap`, with a local model's tier capped by its parameter count
-when the endpoint reports it) and a **cost signal**: `subscription`
-(headroom is the cost: free until limited), `metered` (a price per
-million tokens from the connection's price table, so dollars), or
-`free` (local). The choice function of §3 takes the tier as a filter
-(a `cheap` job may run on anything at or above `cheap`, preferring the
-cheapest cost signal with headroom; a `strong` job runs only on
-`strong`) and then applies preference, headroom and stickiness as
-before. Nothing here needs setup: with one Claude account every job
-lands there, exactly as today; add a local Ollama and small fixes
-start moving to it; add Codex and Review becomes cross-family.
-
-**Cheap-first escalation.** A `cheap` or `standard` first pass that
-fails checks or gets `changes_requested` is retried one tier up on the
-first fix round, on a different family if one is available; the second
-fix round (thin v1's `MaxFixRounds` 2) stays on the escalated tier.
-Escalation is recorded on the step as `escalated_from`. A `strong`
-first pass that fails stays `strong`; there is nowhere to go, and the
-fix-round cap already ends it at Needs you.
+person in v1: a class maps to a **tier floor** per role. Engineering:
+`small` and `low` risk floor at `cheap`; `medium` or `normal` at
+`standard`; `large` or `high` at `strong`. Review: one tier above
+Engineering's actual tier, minimum `standard`, another family where an
+eligible pair exists. Coordinator: `standard` or above. Ask: pinned to
+the step's pair. A pair's **cost signal** is `subscription` (within
+plan: no marginal cost until limited, overage priced if the person
+typed one), `metered` (price from the model map), or `free` (local).
+The choice function of §3 applies, in its fixed order: eligibility,
+stickiness, the tier floor as a filter, the preference, then headroom
+with the cheapest cost signal first among equals. Nothing here needs
+setup: with one Claude account every job lands there, exactly as
+today; add a local Ollama and small fixes start moving to it; add
+Codex and Review becomes cross-family.
+
+**Cheap-first escalation.** A first pass whose pair is below `strong`
+and that fails checks or gets `changes_requested` is retried one tier
+up on the first fix round, on a different family if an eligible pair
+exists; the second fix round (thin v1's `MaxFixRounds` 2) stays on the
+escalated tier. Escalation is recorded on the step as `escalated_from`.
+A `strong` first pass that fails stays `strong`.
**What the person sees.** One quiet line on the task card and in the
timeline: "Engineering on Codex, local model for the first pass" or
"Engineering on Claude (Paul prefers Claude)". The Usage page (§6)
sums it: "3 tasks moved to Codex while Claude was limited". Every
-decision is a `routing` row: task, step, role, class, tier,
-connection, reason (`preference`, `headroom`, `cheapest`,
-`escalated`, `failover`, `only_option`, `same_family_review`), so the
-line and the sum are read from data, not reconstructed. Override is
-per task ("Run on …", §3) or standing (the preference), and an override
-is a `reason: preference` row like any other.
+decision is a `routing` row: task, step, role, class, tier floor,
+connection, model, family, reason (`sticky`, `preference`, `headroom`,
+`cheapest`, `escalated`, `failover`, `only_option`,
+`same_family_review`), so the line and the sum are read from data.
+Override is per task ("Run on …", §3) or standing (the preference),
+and an override is a `reason: preference` row like any other.
## 5. Tools and safety per harness, and the capability matrix
@@ -756,7 +879,20 @@ namespace is the containment. On the owner's Mac (Mac spec §4) Claude
Code's `sandbox.enabled` profile is trusted for Claude steps; Codex and
Pi on the Mac are parked until probe P5 shows Codex's Seatbelt nests
under `srt`, and Pi, having no sandbox, would run under an `srt`
-profile of Equipo's own, which is slice F work there, not here. Each
+profile of Equipo's own, which is slice F work there, not here. **Termination comes from the namespace, never from the harness**: Pi's
+`abort` waits for the session to go idle and keeps the process alive
+(its RPC docs), Codex's `turn/interrupt` ends a turn, Claude's SIGINT
+ends a turn; Equipo kills the namespace and waits for the pidfd proof,
+as today. Before any harness earns a "yes" cell it passes the same
+**containment proofs** in CI and once on staging: it works through the
+CONNECT relay with no direct network (proxy support); a model tool
+cannot read the credential home or the runner's state (credential-read
+denial, tried by a hostile prompt in the fake and a `cat` in staging);
+shell is absent or restricted in the read-only roles; MCP tools are
+exactly the pinned set and nothing else is callable; and killing the
+namespace ends every descendant, including the harness's subprocesses
+(descendant termination). Claude passes these today; Codex and Pi get
+them as the first task of their slices. Each
harness gets a **fake CLI** in CI reproducing its pinned protocol from
recordings: `fakeclaude` exists, `fakecodex` is slice 1 here (the
app-server JSON-RPC including device-code login, `account/rateLimits`
@@ -767,11 +903,11 @@ and `thread/tokenUsage/updated`), `fakepi` is the local-models slice
|---|---|---|---|---|---|---|
| Claude subscription or API key, Claude Code | Yes (today) | Yes (today) | Yes (today) | Yes (today) | `rate_limit_event {utilization, resetsAt}`, one figure | Live; multi-account in 1 |
| ChatGPT plan or OpenAI key, Codex app-server | Yes: `turn/start`, MCP via `codex mcp`, approvals relayed | Yes: thin v1 §3 path | Yes: `sandbox_mode = read-only`, no write tools | Yes: `thread/resume` | `account/rateLimits` two windows with `resetsAt`, `thread/tokenUsage/updated` | 1 |
-| Local model (Ollama, vLLM, LM Studio), Pi | Yes, if the model handles tool calls; `cheap` tier, so chosen only by preference | Yes, `cheap` tier | Yes, read-only tool allowlist, `same_family` never (it is its own family) | Yes | None reported; HTTP 429 observation only | 2 |
+| Local model (Ollama, vLLM, LM Studio), Pi | Yes, if the model handles tool calls and the containment proofs pass; tier from the model map | Yes, `cheap` tier | Yes, read-only tool allowlist, `same_family` never (it is its own family) | Yes | None reported; HTTP 429 observation only | 2 |
| TensorX, Pi (chat wire) | Yes, `standard` tier for the larger models | Yes | Yes | Yes | 429 `retry-after`, `x-ratelimit-reset`, `x-ratelimit-remaining-*` | 2 |
| Mistral API or OpenRouter, Pi | Yes, `standard` | Yes | Yes | Yes | 429 `Retry-After`; OpenRouter key info endpoint later | 2 |
-| Mistral subscription, Vibe CLI | **No** in v1: `-p --output streaming` has no stdin-held long-lived mode documented, and headless denies asks rather than relaying them | Yes: `--auto-approve` inside the namespace, MCP, `--resume` | Yes: tool `permission` denies for edit and shell | Yes: `--resume <id>` | 429 `Retry-After`; plan budget not reported | 3 |
-| Command Code, BYOK `--local-only` | **No**: no long-lived mode, hooks cannot ask | Yes, `--yolo` inside the namespace | Yes, `--permission-mode plan` | Yes, `--resume` | Exit code 5 on rate limit only | 5 |
+| Mistral subscription, Vibe CLI | Probe `run-server` before deciding; `-p` alone denies asks rather than relaying them | Yes: `--auto-approve` inside the namespace, MCP, `--resume` | Yes: tool `permission` denies for edit and shell | Yes: `--resume <id>` | 429 `Retry-After`; plan budget not reported | 3 |
+| Command Code, BYOK `--local-only` | Probe `cmd acp` before deciding; `-p` hooks cannot ask | Yes, `--yolo` inside the namespace | Yes, `--permission-mode plan` | Yes, `--resume` | Exit code 5 on rate limit only | 5 |
| Gemini, Muse | Later | Later | Later | Later | | |
"Yes" in the Pi rows is conditional on the probes in §8 passing: RPC
@@ -814,22 +950,40 @@ estimate where there is one. *Routing*: the sum lines from §4 for the
period ("3 tasks moved to Codex while Claude was limited", "12 small
fixes ran on the local model", "2 escalations after review").
-**Recording, from day one.** The runner already receives per-turn and
-per-step usage from each harness: Claude's `result.usage` and
-`result.modelUsage` (with `costUSD` as a cross-check, never shown),
-Codex's `thread/tokenUsage/updated` (the `last` breakdown per turn,
-`total` as the check), and the endpoint harness's equivalent (OpenAI
-`usage` on the final chunk with `stream_options.include_usage`, or the
-harness's own usage event, §1.4). It writes one `usage` row per turn or
-step attempt: person, connection, harness, model, role, project, task,
-step, turn, input, cached input, cache write, output, reasoning output,
-estimated cost in micro-dollars (null for subscriptions and free
-endpoints), recorded at, and sends it in the existing `reply` and
-`step` frames as a `usage` object, which already exists on `reply` as
-`wire.Usage` ("without cost data", today) and gains the same fields. The instance stores it as a
-`usage` table and serves sums; raw rows are kept 90 days, daily sums
-indefinitely. Slice 1 records every field it can and shows nothing
-new; the page comes later and finds the data waiting.
+**Recording, from day one.** The runner writes one `usage` row per
+**attempt** of a turn, step or question, whether it replied, failed,
+was cancelled or is still waiting for a reconnect: person, connection,
+model, harness, role, project, task, step, turn, attempt, outcome
+(`replied | failed | cancelled | superseded`), input, cached input,
+cache write, output, reasoning output (each nullable: a harness that
+did not report a figure leaves null, never zero), `complete` (true
+only when the harness's final usage message for that attempt was
+seen), estimated cost in micro-dollars with `price_version` (the id of
+the price-table revision used; null for a subscription within plan and
+for a local endpoint), and recorded at. Per harness: Claude's `result`
+message gives `usage` and `modelUsage` once per attempt, and
+`modelUsage` is kept per model (one row per model when a turn used
+several); Codex sends several `thread/tokenUsage/updated` notices within
+one turn and across a resume, so the runner keeps the first `total` seen
+after `thread/resume` as the attempt's baseline, takes the attempt's
+figure as the last `total` minus that baseline, uses `last` only as a
+consistency check, and drops a notice whose `turnId` or `threadId`
+does not match the attempt (the local fixtures in `provider/codex/testdata`
+already show multiple notices per turn); Pi's `message_end.usage`
+(slice 2) is summed over the attempt's messages. Rows travel in the
+existing `reply`, `step` and `answer` frames as a `usage` array (the
+present `wire.Usage` "without cost data" becomes this shape), and a
+`usage` frame of its own carries rows for attempts that produced no
+reply. The instance stores them as a `usage` table keyed by
+`(turn or step or question, attempt, model)`, so a resent frame is a
+no-op; raw rows are kept 90 days, daily sums indefinitely. A
+subscription is not free past its plan: Claude's `rate_limit_info`
+carries `overageStatus` and `isUsingOverage`, and Codex's
+`rateLimitReachedType` and `credits` say when paid credits are being
+consumed; a row recorded under overage carries `overage: true` and is
+counted in Spend at the connection's typed overage price, labelled as
+such. Slice 1 records every field it can and shows nothing new; the
+page comes later and finds the data waiting.
**Resources.** `GET /api/v1/usage?period=day|week|month&by=connection|
role|project|task` returns `UsageReport {period, from, to, rows[{key,
@@ -919,30 +1073,36 @@ then UI, then deploy, as thin v1 §8. Sizes are agent days.
| Slice | Content | Tests | Size |
|---|---|---|---|
-| 1 Several accounts, Codex coordinator, in-app Codex and second Claude | `Connection` rows and homes, `connect` and `connection` frames, the Codex device-code flow, the Claude same-machine flow and the honest remote card, `hello.connections` and `seal_key`; the choice function over several connections with health and headroom; coordinator failover with the switched line and the new session seeded from the notebook; Engineering retry on another connection after termination; `no_connection` card; `fakecodex` with device-code login, `account/rateLimits`, `thread/tokenUsage/updated` and `turn/failed` on quota; **usage recording** from Claude `result` and Codex `tokenUsage` into the `usage` table and frames, no page; `routing` rows with reason `headroom`, `failover`, `only_option` only (no classes yet) | Headless: C1 two Claude accounts, first hits a fake weekly limit mid-turn, reply arrives from the second with the switched line, no duplicate; C2 Codex coordinator end to end (hello, tools, a task); C3 in-app Codex device code against `fakecodex`, card shows code, turns healthy; C4 add a second Claude in the same-machine case against `fakeclaude` (loopback callback simulated), and the remote case shows the terminal card; C5 Engineering step fails on quota, termination proof, retried on Codex, card shows both; C6 nothing available, `no_connection` card, message queued, connection returns, reply arrives; C7 guard: no secret-shaped field anywhere, `sealed` never in a report. Staging witness: one real Codex device-code sign-in in the app, one real Codex refresh (thin v1's debt), one real Claude limit observed or injected by a `rate_limit_event` replay, three coordinator turns across the switch | 4 days |
-| 2 Local models and metered endpoints through Pi | Pi probes P1 to P4 (RPC session across 100 fake turns; `extension_ui_request` relay for a blocked tool; MCP pinning; `abort` termination), `fakepi`, Pi containment profile in `policy.go`, endpoint connections with the test call and `local` hosts, sealed API keys (`seal_key`, sealed box in the web app and the Go client), OpenRouter PKCE on the web app, TensorX and Mistral API as endpoints with their price tables and 429 parsing, Pi usage into `usage`, tiers from the static map (no classes yet: an endpoint is chosen by preference or when nothing else is healthy) | Headless: P1 to P4 as tests; E1 add an Ollama endpoint, model list shown, a Review step runs on it with `other_family`; E2 sealed key round trip, instance database contains no plaintext (grep the SQLite file), replay to another runner fails to open; E3 TensorX 429 with `retry-after` marks `limited` with the right time; E4 OpenRouter PKCE callback to the web app, exchange on the runner against a fake. Staging: a real Ollama on docs-t1 or Tito Studio running one Review step and one small Engineering step; one real TensorX test call | 4 days (OpenCode fallback adds 2) |
+| 1a Fake Codex and usage recording | `fakecodex` reproducing the pinned app-server protocol from recordings: `initialize`, `thread/start` and `thread/resume`, `turn/start`, items, `turn/completed` with `status: completed | failed | interrupted`, `account/login/start {chatgptDeviceCode}` and `account/login/completed`, `account/read`, `account/rateLimits/read` and `/updated` with and without windows, several `thread/tokenUsage/updated` per turn; the `usage` table, rows and frames of §6 for Claude and Codex, including failed and cancelled attempts; Codex rate notices kept as state rather than discarded | Unit: usage aggregation over the recorded fixtures (baseline after resume, dedup of a resent frame, nullable fields, `complete` false when the final notice is missing); property test that sums over random rows match by every grouping. Headless: U1 a Claude turn and a Codex turn each produce one row with `complete: true`; U2 a cancelled turn produces a row with `outcome: cancelled` | 1 day |
+| 1b Protocol and auth | `Connection` rows and homes, `connect`, `connection`, `disconnect` frames, `hello.connections`, `sync.connections`; Codex device code in the app; Claude same-machine loopback and the finish-on-runner card; health, `limited`, `sign_in_again` and the failure classifier of §3; Claude and Codex only, over the existing egress relay, no endpoints and no sealed keys | Headless: A1 device code against `fakecodex`, card shows the code, connection turns `healthy` with plan and windows; A2 device code refused (not enabled), `provider_refused`; A3 Claude same-machine against `fakeclaude` with a simulated loopback callback, `healthy` with the observed email; A4 remote case shows the finish-on-runner card and nothing else; A5 cancel during `connecting` defeats a late success (the runner's late `healthy` report for a cancelled attempt is dropped and the home deleted); A6 `rate_limit_event {rejected}` with and without `resetsAt` marks `limited` correctly; A7 an `auth` failure marks `sign_in_again`, never `limited`; A8 guard: no secret-shaped field in any frame, fixture or report | 1 day |
+| 1c Failover and continuity | The choice function over pairs with stickiness; the `waiting` turn state; termination before failover; durable attempt advancement; tool-effect reconciliation (`tool_calls{turn}` request, replayed results by `(turn, name, canonical args)`, the resumed-attempt house rule); the switched line; Engineering retry on another pair after termination; `no_connection` waiting card; pinned ask | Headless: F1 two Claude accounts, the first hits a fake limit mid-turn, reply from the second with the switched line, no duplicate message; F2 quota failure immediately after each write tool in turn (`add_project`, `record_task`, `start_task`, `ask_person`, `set_project_home`), the new attempt's summary names the effect, and a repeated call is answered `replayed: true` with no second project, task or card; F3 runner crash between termination and attempt advancement, restart recovers the turn in `waiting` and advances once; F4 ack loss on the `turn{running, attempt: 2}` report, resend is a no-op; F5 cancel during `waiting` ends `cancelled`, cancel after advancement targets attempt 2 and a stale attempt-1 report is dropped; F6 Engineering step fails on quota, termination proof, attempt 2 on Codex, card shows both; F7 nothing eligible, `waiting` with `no_connection`, the card, then a connection returns and the reply arrives without the person resending; F8 the preferred connection returns, the next turn switches back with the line and resumes the old session with a fresh notebook injection; F9 ask on a step whose connection is `limited` fails `account_unavailable` and never moves. Staging witness: one real Codex device-code sign-in in the app, one real Codex refresh (thin v1's debt), one real Claude limit observed or injected by a `rate_limit_event` replay against the real CLI, three coordinator turns across the switch, one of them straight after `start_task` | 1.5 days |
+| 1d UI | Connections list and Add in Settings, the connecting card, the switched line, the waiting card, the finish-on-runner card; no Usage page | Browser suite on A1, A4, F1, F7 | 0.5 day |
+| 2 Local models and metered endpoints through Pi | Pi containment proofs and probes P1 to P5 (RPC session across 100 fake turns; `extension_ui_request` relay for a blocked tool; MCP pinning; credential-read denial; descendant termination under namespace kill), `fakepi`, Pi profile in `policy.go`; the local transport of §2.5 with its four probes; public endpoints over the relay; sealed keys with the §2.4 lifecycle (`seal_key` derived from the enrolment key, bound payload, `seen_seals`, ack after fsync, cancel marker); OpenRouter PKCE hardened as §2.6; TensorX and Mistral API as endpoints with the model map's prices and their harness-side 429 events; Pi usage into `usage`; tiers from the model map, no classes yet | Headless: P1 to P5 as tests; E1 add a local endpoint through the local listener, model list shown, a Review step runs on it with `other_family` by recorded family; E2 sealed key round trip, the instance database and its WAL contain no plaintext (grep the files), a box with a changed `connection_id` or an expired `expires_at` or a repeated attempt is refused, a replay to another runner fails to open; E3 a step on a non-local connection cannot reach the local listener; E4 a redirecting endpoint is refused; E5 OpenRouter callback to the instance route, query stripped from the URL and the access log, exchange on the runner against a fake; E6 Pi reports a 429 as an error event, connection `limited` without a reset time, probe clears it. Staging: a real Ollama on docs-t1 or Tito Studio running one Review step and one small Engineering step; one real TensorX test call | 5 days (OpenCode fallback adds 2) |
| 3 Routing and Usage page | `size`, `risk`, `kind` on `record_task` and `start_task`; the class-to-tier table; cheap-first escalation; routing lines on the task card; preferences per role and per task override; the Usage page with availability, spend, token tabs and routing lines; soft ceiling, 80% line and Pause (thin v1 slice 6's item, moved here); the sidebar dot; Mistral Vibe CLI as an Engineering and Review harness (`fakevibe`), subscription connection by the CLI's browser sign-in in the same-machine case and `MISTRAL_API_KEY` sealed otherwise | Headless: R1 a small, low-risk fix lands on the local model, fails checks, escalates to `standard` on another family, passes; R2 a high-risk task goes `strong` straight away; R3 preference set, switched line only on failover; R4 Usage sums equal the `usage` rows for each grouping and period (property test over random rows); R5 ceiling crossed, dot appears, Pause stops new metered steps and never the coordinator; V1 Vibe Engineering step with a fake. Staging: three routed tasks on the mix, page checked against the rows | 4 days |
| 4 Native apps and polish | Fixtures published, sealed box in Swift and Kotlin, `same_machine` detection on the Mac app, Connections and Usage screens | Contract fixtures replayed by the apps' own tests | app teams |
| 5 Command Code | BYOK `--local-only` Engineering and Review rows, `fakecmd`, containment profile with its network switches | One headless Engineering step, one Review step | 1.5 days |
-Slice 1 is the one that unblocks Paul: with two Claude accounts or one
-Claude and one Codex connected, the coordinator keeps answering through
-a weekly limit, and both can be added from the app (Codex entirely;
-Claude at the machine or by the terminal card).
+Slice 1 (gates 1a to 1d, four days) is the one that unblocks Paul:
+with two Claude accounts or one Claude and one Codex connected, the
+coordinator keeps answering through a limit, and both can be added from
+the app (Codex entirely; Claude at the machine, or finished on the
+runner). Each gate is green in CI before the next starts, and 1c's
+staging witness runs before 1d.
## 9. Decisions for Paul
-1. **Claude on a remote runner stays a terminal step.** Anthropic's
- terms forbid Equipo intermediating the code or token, so when the
- browser is not on the runner's machine the app shows the honest
- card and the paste happens in `equipo-runner login claude` there,
- never in Equipo. The alternative, a device-side bridge in the native
- apps, is technically possible and is not built. Confirm, or say the
- risk is acceptable and the bridge goes on the list.
+1. **Claude signs in only to the unmodified binary.** On the runner's
+ machine by loopback, otherwise "finish signing in on the runner"
+ (`equipo-runner login claude` there, the paste going into the CLI).
+ No token importer and no device-side bridge, because Anthropic's
+ terms forbid Equipo handling the code or token and an owner's
+ acceptance cannot waive a provider's terms. Confirm; the
+ alternative is a Claude API-key connection for remote machines.
2. **Pi is the single OpenAI-compatible harness**, with OpenCode as the
fallback if the slice 2 probes fail, Vibe for the Mistral
- subscription only, and Command Code last and never a coordinator.
- Confirm, or name a different order.
+ subscription with `run-server` probed before it is given a
+ coordinator cell, and Command Code last with `cmd acp` probed the
+ same way. Confirm, or name a different order.
## 10. Risks
@@ -959,6 +1119,11 @@ the container, as the design already assumed. Spend is an estimate
from tokens and a price table that someone must keep current, labelled
as such. TensorX's and Mistral's quieter corners (streamed tool-call
chunks, prompt caching, whether a plan key may be used from Pi) are
-marked unverified above and are probed, not assumed. The word count is
-above the brief because three sections were added on the way; nothing
-in them is optional for the design to hold together.
+marked unverified above and are probed, not assumed. Tool-effect reconciliation
+depends on the instance's stored results by call id and on a model
+honouring the resumed-attempt house rule; the `(turn, name, canonical
+args)` replay is the backstop and F2 tests it after every write tool.
+Sealed-box residue in WAL and backups is accepted and labelled, not
+erased. The word count is above the brief because four sections were
+added on the way; nothing in them is optional for the design to hold
+together.