oficina / equipo Public

spec: Equipo connectors and token scheduling, rev 1 (Astra: NOT READY)

Command Code, Mistral Vibe, Pi on TensorX and OpenCode as connectors,
spend caps for pay-per-token connections, and a deterministic
scheduler with advice cards. Astra's round-1 findings are kept beside
it; revision 2 folds them in by cutting scope.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 732d7d6d5dbbc565fa65849b1a31facf5f973ffb parent 1d7b4e4
2 files changed, +962 −0
  • docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md +905 −0
  • docs/superpowers/specs/CODEX-FINDINGS-CONNECTORS-SCHEDULING.md +57 −0
diff --git a/docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md b/docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md
new file mode 100644
index 00000000..56cc78a6
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md
@@ -0,0 +1,905 @@
+# Equipo connectors and token-aware scheduling
+
+Status: design for Paul's review, 2026-11-12, revision 1. Spec only,
+nothing built. Drafted by Claude (Opus 5.5) on `connections-slice2-design`
+from main 1d7b4e4. Builds on Connections rev 3
+(`2026-11-08-equipo-connections.md`, "rev 3" below) as built in
+`CONN1-PROGRESS.md`, the spend lines (`chat_usage` with `round` and
+`turns`, migration 0059), the housekeeping budgets
+(`2026-11-08-equipo-housekeeping.md` §4) and the merge authority's
+ask-with-a-recommendation pattern (`2026-11-11-equipo-merge-authority.md`
+§4). Provider facts were read from official docs on 2026-11-12 (§14).
+
+## 0. Decisions for Paul
+
+Each has a recommendation. Nothing is built until these are answered.
+
+1. **"Pi" means Pi as the harness, with TensorX as the paid
+ connection.** Pi has no subscription of its own. Your Pi connector
+ is TensorX through Pi, capped. *Recommend: yes.* Other API-key
+ providers (Mistral API, OpenRouter) can follow on the same path later.
+2. **When subscriptions run out, which work may spend TensorX money?**
+ *Recommend:* only tasks you marked `urgent`, and only by your tap,
+ never the coordinator's. `normal` and `low` work waits for the
+ reset. A deadline that waiting would miss asks you, with "I'd run it
+ on TensorX: about $0.40". The "cheap and short" rule (Review or
+ explore steps under $0.02 go to TensorX to save subscription room)
+ ships **off**. Alternative: allow `normal` to spill as well.
+3. **Default caps for a new TensorX connection**, pre-filled on the
+ connect card and required before first use. *Recommend: $1 a day and
+ $10 a month.* Equipo refuses to dispatch past either, and kills a
+ step that reaches the cap mid-run.
+4. **The reserve ladder.** `low` work stops at 70% of a subscription
+ window, and `normal` at 90%. Above that, only `urgent` work and your
+ chat with the coordinator go on. *Recommend: these numbers*, changed
+ later from data.
+5. **Command Code.** Its hosts and headless stream are undocumented, and
+ it is proprietary. It goes last, over ACP, after a host discovery
+ probe. Please check in Command Code Studio whether a Studio API key
+ draws on your plan or on pay-as-you-go credits. If it is credits,
+ the connection is metered and capped like TensorX. *Recommend: keep
+ it, last.*
+6. **OpenCode Go can overflow into Console credit** when a Go limit is
+ hit, and Equipo may not see it. *Recommend:* keep your OpenCode
+ Console credit balance at zero (or switch the fallback off, if the
+ Console offers that), so overflow fails instead of billing.
+7. **The coordinator stays on Claude and Codex** in this design. The new
+ connectors take Engineering, Review and Ask, which is where tokens
+ go. *Recommend: yes.* A coordinator cell for Pi or OpenCode is a
+ later slice after rev 3's probes.
+8. **Order.** *Recommend:* metered base and caps, Pi on TensorX, the
+ scheduler, Usage and advice, OpenCode, Vibe, Command Code, then Mac.
+ Alternative: the scheduler first, if holding work matters more to you
+ right now than TensorX.
+
+## 1. Why, and the shape
+
+Paul, 2026-11-12: the coordinator should "prioritise tasks according to
+token availability… deciding what can wait etc, and … proactively offer
+advice on how to handle tokens", and "can I get connectors for my
+Mistral, Pi, Opencode and Command Code subscriptions? … Pi I guess would
+then use… my TensorX? But I don't want to run that down too much."
+
+Part A adds four harnesses behind the existing `provider.Launcher`
+contract, each with sign-in from the app, the Linux bubblewrap and Mac
+srt containment, a digest pin, honest usage readings and a row in the
+capability matrix. It adds hard spend caps for pay-per-token
+connections, enforced by the runner that owns the connection. Part B
+adds a deterministic scheduler on the runner that holds, routes or runs
+each step from recorded facts, and an advice function on the instance
+that turns the same facts into quiet cards. No model decides anything
+in either part; models only describe a task (as rev 3 §4 already has the
+coordinator do).
+
+What exists and is reused, not redesigned: connections, homes and
+`connect.Choose` (`internal/runner/connect/choose.go`); sealed secrets
+(`internal/sealbox`, rev 3 §2.4, built for Claude tokens); the egress
+relay, one bounded CONNECT to a public name on 443 per allowed host
+(`internal/runner/egress`); usage rows per attempt (`wire.Usage`,
+`chat_usage`); the step deferral (`stepDeferred` in
+`internal/runner/thin/engineer.go`); the housekeeping reservation ledger
+(`chat/housekeeping.go`); the policy and manifest digests
+(`internal/runner/provider/policy.go`, `check_policy.go`); and the pinned
+srt lockfile on the Mac (`internal/runner/mac`, every npm package by
+integrity).
+
+# Part A: connectors
+
+## 2. What every connector must have
+
+A connector is one harness adapter, one sign-in kind, one containment
+profile, one pin, one usage parser, one fake CLI and one row in the
+matrix (§5). No harness earns a "yes" cell until it passes rev 3 §5's
+containment proofs in CI, with its fake, and once on staging with the
+real pinned binary:
+
+- proxy support through the relay, with no direct network;
+- the credential home unreadable from model tools;
+- shell absent in the read-only roles;
+- exactly the pinned MCP tools;
+- descendant termination when the namespace is killed.
+
+**Sign-in, never a terminal.** There are three kinds, all built or
+designed already:
+
+- (a) a **sealed paste** of an API key, into the rev 3 §2.4 sealed path
+ as built for Claude tokens (`sealbox`, `seen_seals`, the delivery
+ state machine), generalised from `KindToken` to `KindAPIKey` with an
+ `endpoint` origin per provider;
+- (b) a **device code** relayed as a card, as Codex does;
+- (c) a **provider link whose one-time code comes back sealed**, as
+ Claude's sign-in by a link does.
+
+The runner then makes one cheap authenticated request (a model list or
+a one-token call) before it reports `healthy`. A connector whose only
+subscription sign-in is a browser loopback on the runner's machine
+offers the API-key paste instead. A connector is never signed in by
+Equipo handling a provider's OAuth refresh token outside the
+provider's own CLI.
+
+**Containment, Linux.** Each connector runs in the existing bubblewrap
+namespace. It has the credential home mounted to the harness and denied
+to model tools, the runtime copy, no inherited environment, and pidfd
+termination proofs. The harness's own approval layer is set to "allow
+inside the namespace", because the namespace is the containment, as
+Codex's `danger-full-access` already is. Egress goes through the relay
+with an allowlist per provider host. `egress.ProviderPolicy` and
+`Policy.Hash` today accept only `claude` and `codex`. They become a
+table keyed by `(harness, provider)`, so a Pi connection to TensorX
+allows exactly `api.tensorx.ai`. Sign-in hosts are allowed only to the
+sign-in action, as `SignInPolicy` does for Claude. Every startup
+side-channel (update check, telemetry, model catalogue, package
+download) is switched off by flag or environment and then denied by the
+relay anyway. A connector whose hosts are undocumented starts its slice
+with a **host discovery probe**: the pinned binary on staging, with the
+relay in record-and-deny mode, a throwaway prompt, and the hosts it
+tried written down and reviewed. Only after that does the allowlist go
+into the policy table.
+
+**Containment, Mac.** srt 0.0.81 (pinned, Mac runners spec §4.4) with a
+profile of Equipo's own for each connector: `network.allowedDomains`
+set to the same host table, `filesystem.denyRead` set to the runner's
+state and every other connection's home, and writes only to the task
+tree and the attempt's scratch. This is new: today only Checks run under
+srt on a Mac, and Claude's own sandbox is trusted for Claude. Each
+connector on a Mac therefore needs the Mac spec's probe pattern
+(P2-style "denied" proven on every path) before its Mac cell turns
+yes. Linux comes first, and the Mac cells say "after probe".
+
+**Pinning.** Claude and Codex are pinned by the SHA-256 of the binary
+per architecture (`provider/claude/pins.go`, `codex/pins.go`). The new
+harnesses ship in three forms:
+
+- **npm** (Pi, OpenCode, Command Code): pinned as srt is, a committed
+ `package-lock.json` with every package's `integrity`, installed by
+ `npm ci --ignore-scripts` into a versioned directory with the pinned
+ Node. The runner then records the SHA-256 of the installed tree's
+ manifest (`provider.ManifestDigest` over a sorted file list and
+ digests) and refuses to launch on any drift. Where the package pulls
+ platform binaries (OpenCode), the binary's own SHA-256 is pinned too.
+- **PyPI** (Vibe): `uv pip install --require-hashes` from a committed
+ lock into a versioned virtualenv, with a pinned `uv`-managed Python
+ (SHA-256 of the archive). The same tree digest is taken at launch.
+- **A standalone release binary**, where one exists: SHA-256 per
+ architecture, like Codex.
+
+Auto-update is switched off by flag, the install directory is mounted
+read-only, and the version check is denied by the relay.
+
+**Usage.** Each adapter maps its stream to `wire.Usage` rows (one per
+attempt and model, nullable figures, `complete` only when the final
+usage message was seen). Each reports headroom only as the provider
+reports it. "Not reported" is a state the Usage page shows in words,
+never a 0% or 100% meter.
+
+**Mapping to turns and steps.** The adapter's `Decode` turns the
+harness's stream into Equipo's events:
+
+- `delta` for assistant text;
+- `tool_call` for a tool request;
+- `tool_result` for its result;
+- `ask` for a permission the harness wants answered;
+- `usage`;
+- `done` with `completed | failed | interrupted`;
+- `limit` or `auth` failures for the classifier.
+
+These are the kinds the Claude and Codex adapters already produce
+(`provider/claude`, `provider/codex/events.go`). An event the adapter
+does not recognise is logged and dropped, never shown.
+
+**Model families.** The model map of rev 3 §4 (family, tier, price,
+`price_version`) gains the models these connectors serve. Review's
+`other_family` is judged on the model that actually ran, so one
+connector serving several families (Command Code, OpenCode Zen, Pi on
+TensorX) can review its own Engineering only with a different family.
+
+## 3. Command Code
+
+Command Code is a proprietary agent CLI, npm package `command-code`,
+1.88.5 on 2026-11-07, Node 22 or later, `UNLICENSED`. It has a hosted
+backend that sells credits under plans: Go $1, GOAT $10, Pro $20, Max
+$100 and $200 a month. Each plan has a monthly dollar allowance and
+5-hour and weekly caps, also in dollars. [CC1, CC4]
+
+- **Sign-in:** a sealed paste of a Command Code API key from Studio
+ (kind (a)). Headless runs take `COMMAND_CODE_API_KEY`, which
+ overrides saved credentials, and `cmd status` names the source in
+ use. [CC3] `cmd login` uses a browser with a temporary loopback
+ callback, the shape Equipo does not relay. Whether a Studio key draws
+ on the plan or on pay-as-you-go credits is **unconfirmed** and is a
+ Paul decision (§0). It is checked on first live use by `/usage`
+ before and after one call, run by hand in Studio, not by Equipo.
+- **Containment:** `--yolo` inside the namespace for Engineering,
+ because headless blocks writes and shell without it, and
+ `--permission-mode plan` for Review. Its own rules
+ (`permissions.deny` for `Shell(*)` and `Edit(*)`, and `disableBypass`)
+ are written into the home's `settings.json` for Review as a second
+ layer. [CC5] The hosts are **undocumented**: only
+ `api.commandcode.ai` is named, and only for the separate Provider API.
+ [CC6] The slice therefore starts with the host discovery probe. The
+ side-channels are switched off with:
+ - `DO_NOT_TRACK=1`, plus `"telemetry": false` in `config.json`;
+ - `CMD_DISABLE_REMOTE_MODEL_CATALOG=1`;
+ - `COMMANDCODE_SKIP_UPDATES` and `--no-auto-update`;
+ - `CMD_ZDR=1`.
+
+ It has no OS sandbox of its own. [CC5, CC6]
+- **Pinning:** npm lockfile by integrity. The registry gives a sha512
+ `dist.integrity` and registry signatures, but no provenance and no
+ release binaries. [CC1]
+- **Usage:** headless gives token totals on the final `result` line,
+ with no named fields and no cost. [CC2] The plan's 5-hour and weekly
+ meters exist only in the interactive `/usage` and on the Studio site.
+ [CC4] So headroom is **not reported**. Exit 5 (rate limited) is
+ `limited` with no reset and the rev 3 cool-off; exit 10 (out of
+ credits) is `limited` until a probe succeeds, at most hourly; exit 3
+ is `auth`. [CC2]
+- **Mapping:** `-p --output-format json` emits NDJSON. Only
+ `tool_running` and the final `result {subtype, usage, finalText,
+ sessionId, stopReason}` are documented. [CC2] That is too thin to map
+ text, tool calls and results, or to relay a permission. The adapter
+ therefore targets `cmd acp`, the Agent Client Protocol over stdio, as
+ rev 3 already suggested. Its `session/update` notifications carry
+ message chunks, tool calls and tool-call updates, and
+ `session/request_permission` is a real relay. Whether Command Code's
+ ACP mode reports usage and honours MCP servers is **unprobed**, and
+ probe CC-P1 decides it. If ACP fails, Command Code gets Engineering
+ and Review cells through `-p` only (no relay, final text only), and no
+ coordinator cell.
+- **Families:** many. The default is `deepseek/deepseek-v4.1-flash`, and
+ `-m` takes Anthropic, OpenAI, Gemini, xAI, DeepSeek, Qwen, Kimi, GLM
+ and MiniMax models. [CC7] Equipo always passes `-m` and records the
+ family from it. That makes Command Code useful for a cross-family
+ Review of a Claude or Codex step, for example with GLM or Kimi.
+
+**One ACP adapter for two connectors.** Command Code (`cmd acp`) and
+Mistral Vibe (`vibe-acp`) both speak the Agent Client Protocol. Equipo
+therefore writes one `provider/acp` adapter, with one fake (`fakeacp`)
+and one permission relay (`session/request_permission` becomes an
+`ask_person` or a deny by policy, as Claude's `--permission-prompt-tool`
+does). Each connector adds only its pin, hosts, sign-in and usage
+reading. That is the same economy rev 3 sought with "one
+OpenAI-compatible harness".
+
+## 4. Mistral Vibe
+
+Vibe is Mistral's open-source CLI (Apache 2.0), 3.1.2 on PyPI
+(2026-11-10). The `vibe` command is now a Rust binary that drives a
+Python app server. [V1, V2]
+
+- **Sign-in:**
+ - **Preferred:** a link, if probe V-P1 passes. The CLI's default
+ browser sign-in is PKCE plus polling: it POSTs `{api_base}/vibe/sign-in`,
+ opens a browser, polls, then exchanges. It ends with an API key, and
+ nothing listens on localhost. [V3] So the unmodified CLI can run in
+ a sign-in containment on the runner, as Claude's sign-in by a link
+ does. `BROWSER` is set to a recorder, and the runner shows the URL
+ as a card; Paul signs in on any device while the CLI polls. Nothing
+ comes back through Equipo, which makes it closer to Codex's device
+ code than to Claude's link. Whether the browser may be on another
+ device is **unconfirmed**, and V-P1 is that check. The second, OIDC
+ flow (loopback 127.0.0.1:8766) is off by default and stays off. [V4]
+ - **Fallback**, and always offered: a sealed paste of a key from
+ chat.mistral.ai/code/extensions. The docs say the key "works in Free
+ mode, with a paid plan, or with pay-as-you-go enabled". [V5]
+ Mistral's help centre says API automation should use a
+ pay-as-you-go key rather than a plan key, which rev 3 §1.6 noted.
+ Running the official CLI with the plan key is the use the plan
+ covers. Using that key from Pi or OpenCode is not, and Equipo
+ refuses it: a Vibe connection's key is mounted only into Vibe
+ launches.
+- **Containment:** the home is `VIBE_HOME` (config, `.env`, logs). [V6]
+ `config.toml` sets:
+ - `enable_telemetry = false`, which also stops crash reporting;
+ - `enable_update_checks = false`;
+ - `outside_workdir = "deny"`. [V7, V8]
+
+ Telemetry would otherwise post to `api.mistral.ai/v1/datalake/events`,
+ and the Sentry host is unconfirmed. [V9] The runtime allowlist is
+ `api.mistral.ai` only. The sign-in action adds the hosts V-P1 records.
+ It honours `HTTPS_PROXY`. [V10] Engineering runs with `--auto-approve`
+ inside the namespace, because headless denies anything that needs
+ approval without it. Review runs with `--enabled-tools` set to the
+ read tools and `permission = "never"` for write and bash. [V8]
+- **Pinning:** PyPI wheels with SHA-256 per platform (the Linux x86_64
+ wheel of 3.1.2 is `f4318943…df235`), no signatures, no provenance.
+ [V2] The install is `uv pip install --require-hashes` with a pinned
+ Python 3.12 or later. The `vibe-acp` binaries are GitHub release
+ assets with SHA-256 digests for 3.1.1, and 3.1.2 has none, so the
+ adapter pins whichever version ships both the CLI wheel and a
+ matching `vibe-acp`. [V11]
+- **Usage:** usage is not in the `streaming` output. `--output-dir DIR`
+ writes `export.json` with token usage, cost and the outcome at the end
+ of a run. [V12] The adapter reads it after exit, and `complete` is
+ true only when the file is present and whole. For in-flight spend on
+ a pay-as-you-go key, `--max-price` set to the reservation is the
+ guard, and Vibe ends with exit 3 when it is reached. [V12]
+ - **Headroom:** the plan's monthly usage is shared across Studio, the
+ API and Vibe, and Mistral publishes no figures. [V13, V14] The app
+ server reads `/v1/billing/budget` (`usage_percentage`,
+ `initial_budget`, `reset_at`). That is visible in its source and
+ undocumented. [V15] Probe V-P3 checks it with the connection's own
+ key. If it works, it is the headroom reading, refreshed by the rev 3
+ §2.7 probe at most every 15 minutes and labelled "from Mistral's
+ billing". If it does not, headroom is "not reported".
+- **Mapping:** the target is ACP (`vibe-acp`). Without ACP it falls back
+ to `-p --output streaming`, whose lines are completed history entries
+ (`id`, `turnId`, `generationStatus`, `outcome`, tool calls as
+ `type: "effect"`). The full schema is **unconfirmed**. [V16] The exit
+ codes are 0 done, 1 config, 2 infrastructure, 3 limit (turns, tokens,
+ price, time), 4 aborted. [V12] Exit 3 with `export.json` naming price
+ is `spend_cap`. A 429 is `limited` with no reset.
+- **Families:** `mistral-large-4-0` and `mistral-medium-latest` are
+ family `mistral`, and `zai-glm-5-3` and `-flash` are family `glm`.
+ [V6] Vibe is the natural cross-family Review for Claude or Codex
+ Engineering.
+
+## 5. Pi and OpenCode
+
+### 5.1 Pi, the harness for TensorX
+
+Pi is `@earendil-works/pi-coding-agent` 1.5.2. The `@mariozechner`
+package is deprecated. It needs Node 22.19 or later and has no install
+scripts. [P1]
+
+- **Sign-in:** a sealed paste of the TensorX key (`tx-…`). [T1] The
+ runner then calls `GET /v1/models` and makes a one-token completion,
+ and it reports `healthy` with the model list. Pi's own `/login`
+ subscription OAuth is not used, so no Claude subscription goes through
+ a third-party harness.
+- **Containment:** `PI_CODING_AGENT_DIR` points at the connection's
+ home. [P2] `models.json` declares `tensorx` with `baseUrl
+ https://api.tensorx.ai/v1`, `api: openai-completions` and `apiKey:
+ "$TENSORX_API_KEY"`. [P3, T1] The key reaches the launch through
+ bubblewrap's `--args` pipe, never argv, exactly as Claude's token does
+ (rev 3 §2.4, as built). The environment sets `PI_OFFLINE=1`,
+ `PI_SKIP_VERSION_CHECK=1` and `PI_TELEMETRY=0`. [P4] The allowlist is
+ `api.tensorx.ai`, and `pi.dev` and the catalogue host are denied. Pi
+ has no permission layer at all. [P5] Gating is an extension of
+ Equipo's (`-e`, hashed in the policy manifest) whose `tool_call` hook
+ blocks or asks, as rev 3 §1.4 found. Review runs with `--tools
+ read,grep,find,ls`.
+- **Pinning:** a committed lockfile by integrity
+ (`sha512-mUWI04rq…5yA==` for 1.5.2), `npm ci --ignore-scripts`, and
+ the tree digest at launch. [P1]
+- **Usage:** `message_update` and `message_end` carry `usage {input,
+ output, cacheRead, cacheWrite, totalTokens, cost{…, total}}`, and
+ RPC's `get_session_stats` gives session totals. [P6, P7] The in-flight
+ cap is charged per `message_end`.
+ - **Headroom:** TensorX's `x-ratelimit-remaining-*` headers are
+ per-minute rate limits, not spend, and neither Pi nor the CONNECT
+ relay surfaces them. [T2] Headroom is therefore **not reported**,
+ and the money cap (§6) is what limits TensorX. A 429 is `limited`
+ for the rev 3 cool-off.
+ - **Empty balance:** TensorX disables keys whose balance falls under
+ $0.05, and they then fail as authentication errors. [T3] An `auth`
+ failure on a TensorX connection that was healthy within the hour
+ therefore reads "TensorX refused the key: the balance may be empty,
+ or the key was revoked", state `sign_in_again`.
+- **Mapping:** RPC mode (`--mode rpc`). `prompt` starts a turn and
+ `abort` stops it, but termination is always the namespace kill. The
+ events map as:
+ - `message_update` to `delta`;
+ - `tool_execution_start` and `_end` (by `toolCallId`) to `tool_call`
+ and `tool_result`;
+ - `extension_ui_request` to `ask`;
+ - `agent_end` to `done`. [P6, P7]
+
+ Rev 3's probes P1 to P5 (100-turn session, relay, MCP pinning,
+ credential-read denial, descendant termination) gate every cell.
+- **Families:** from the TensorX model id (`z-ai/glm-5.3` is `glm`,
+ `moonshotai/kimi-k3.1-pro` is `kimi`, `deepseek/…` is `deepseek`,
+ `minimax/…` is `minimax`, Qwen is `qwen`), with prices from TensorX's
+ list (glm-5.3-flash $0.20 in and $0.50 out per million). [T1, T4]
+
+### 5.2 OpenCode: Paul's Go subscription, and Pi's fallback
+
+OpenCode v2 is `@opencode/cli` 2.2.7. It has a `postinstall` script and
+platform binaries as optional dependencies. v1 `opencode-ai` 1.19.5 is
+the legacy major. [OC1] Paul's OpenCode subscription is presumably
+**OpenCode Go** ($10, Plus $40 a month): a dollar limit per model, with
+the 5-hour limit at 20% of the monthly one and the weekly at 50%,
+serving GLM, Kimi, Qwen, DeepSeek, MiniMax and MiMo, plus Claude Haiku
+5.5, Gemini 4 Argon and GPT 6 Luna. [OC2] When a Go limit is reached,
+requests can fall back to Console credit, which is pay-as-you-go. [OC2]
+
+- **Sign-in:** a sealed paste of the key from opencode.ai/console. No
+ environment variable name is documented, so the key is written into
+ the home's credential store by `opencode auth login` run by the
+ runner, reading stdin, as Codex's API key is. [OC3] Probe OC-P1
+ checks that it works headless.
+- **Containment:**
+ - `opencode serve --standalone --hostname 127.0.0.1 --port <fixed>`
+ inside the namespace. Its loopback is the namespace's own, so the
+ host's network never sees it. [OC4]
+ - `XDG_CONFIG_HOME` and `OPENCODE_DB` point into the home. [OC5]
+ - Config sets `update: "disable"` and a `permissions` list that ends
+ in an explicit deny (the default base allows everything but
+ `*.env`). Review gets explicit `edit` and `shell` denies. [OC6, OC7]
+ - The runtime allowlist is `opencode.ai`, for `/inference/go/…` and
+ `/inference/…`. [OC8]
+ - The models.dev catalogue fetch, telemetry and share switches are
+ **unconfirmed** in v2, so the slice starts with the host discovery
+ probe. The relay denies `models.dev`, and the catalogue is seeded
+ into the pinned tree.
+ - The `openai-compatible` provider package is pre-installed in the
+ pinned tree, because OpenCode would otherwise download it at
+ runtime. [OC9]
+- **Pinning:** the lockfile by integrity
+ (`sha512-qsSExDfp…LCg==` for 2.2.7), `npm ci --ignore-scripts`, and
+ the platform binary's own SHA-256 pinned, since `postinstall` does not
+ run. [OC1]
+- **Usage:** assistant messages and sessions carry `tokens {input,
+ output, reasoning, cache}` and `cost` in USD, and `session.usage.updated`
+ is an event. [OC4] Each Go response body includes
+ `opencode.allowance` and `opencode.billing_source`, but there are no
+ rate-limit headers or balance endpoint. [OC10] Whether OpenCode
+ surfaces `allowance` in its events is **unconfirmed** (probe OC-P3).
+ If it does, that is Go's headroom. If not, headroom is "not reported".
+ `billing_source` matters for spend. A response billed to Console
+ credit is metered, so the adapter records `overage: true` (rev 3 §6's
+ field) and charges it against the connection's caps, when OpenCode
+ surfaces it. When it does not, Paul's Console credit balance is the
+ only guard (§0 decision 6).
+- **Mapping:** the `serve` HTTP API maps as:
+ - `POST /api/session` and `/api/session/{id}/prompt` start the turn;
+ - the SSE `GET /api/event` gives `session.text.delta` (`delta`),
+ `session.tool.called` and `success` or `failed` (`tool_call` and
+ `tool_result`), `session.step.ended`, `session.usage.updated` and
+ `permission.asked` (`ask`);
+ - `ask` is answered at `POST /api/session/{id}/permission/{requestID}/reply`.
+ [OC4]
+
+ It is a real relay. The cost is an HTTP server inside the namespace.
+- **Families:** many, read from the model id (`opencode-go/<id>`,
+ `opencode/<id>`, `tensorx/<id>`). [OC2, OC11]
+- **As Pi's fallback for TensorX:** models.dev lists a `tensorx`
+ provider (`TENSORX_API_KEY`, `@ai-sdk/openai-compatible`). [T5] If
+ Pi fails its probes, the same TensorX connection gets
+ `harness: opencode` and nothing else changes.
+
+### 5.3 The capability matrix, added rows
+
+| Connector | Coordinator | Engineering | Review | Ask | Headroom | Billing | Mac |
+|---|---|---|---|---|---|---|---|
+| Command Code over ACP | Not in this design | Yes, if CC-P1 passes; else `-p` with no relay | Yes, `plan` mode plus deny rules | Yes (`--resume` or an ACP session) | Not reported; exit 5 or 10 | Plan or credits, §0 decision 5 | After the srt probe |
+| Mistral Vibe over ACP | Not in this design | Yes | Yes | Yes | `/v1/billing/budget` if V-P3 passes, else not reported | Plan; a pay-as-you-go key is metered | After the srt probe |
+| Pi on TensorX (RPC) | Later (rev 3 P1 to P5 first) | Yes | Yes | Yes | Not reported; the money cap governs | Metered, capped | After the srt probe |
+| OpenCode on Go (serve) | Later | Yes | Yes | Yes | `allowance` if OC-P3 passes | Subscription, with an overflow risk | After the srt probe |
+| OpenCode on TensorX | Only if Pi fails | as Pi | as Pi | as Pi | as Pi | Metered, capped | After the srt probe |
+
+The coordinator stays on Claude and Codex in this design (§0
+decision 7). The new connectors take steps, which is where tokens go:
+Engineering, Review and the questions about them.
+
+## 6. Spend caps for pay-per-token connections
+
+A **metered** connection is an API key billed per token: Pi or OpenCode
+on TensorX, the Mistral API or OpenRouter, a Vibe or Command Code
+pay-as-you-go key. Paul's TensorX credit is prepaid and he does not want
+it run down.
+
+**The cap.** Each metered connection carries `caps {day, month}`, each
+`{limit, unit: money | tokens}`. Money is in the price table's currency
+(USD for TensorX), stored in micro-units. Day and month are in Paul's
+zone (UTC until one is known, as the Connections page does today).
+Paul sets the caps on the connection's row and on the Usage page. A
+metered connection is not usable until both caps are set. The connect
+card pre-fills them (§0 decision 3) and the connection becomes healthy
+on Save, so the setup is one tap, not a form.
+
+**Who enforces it.** A connection lives on exactly one runner, and every
+token it spends goes through that runner's harness. The runner is
+therefore the authoritative meter, and it enforces the cap even while
+the instance is unreachable. A `spend` ledger in `thin.db` holds
+reservations and charges per connection. It is written in one SQLite
+transaction with each admission, so two steps cannot both take the last
+dollar. The instance mirrors it for display only.
+
+**Four lines of defence:**
+
+1. **Admission.** A step or turn on a metered pair reserves its
+ estimated `p90` cost (§7), priced by the model map's `price_version`.
+ Without history it reserves the seed estimate. It is admitted only
+ when the reservation fits under both the day and the month remaining.
+ Otherwise it is held with reason `cap`.
+2. **In flight.** Every usage event the harness streams (Pi
+ `message_end`, OpenCode `step_finish`, Vibe's per-message usage) is
+ priced and charged as it arrives. When the charges reach the
+ reservation and the cap's remainder is spent, the runner kills the
+ namespace, waits for the termination proof, and ends the attempt
+ `failed` with reason `spend_cap`. Engineering's partial tree is
+ discarded, as on any failed attempt. A model response with no usage
+ is charged at the worst case for that request (the context window's
+ input plus the output limit Equipo set), so a harness that stops
+ reporting cannot spend uncounted.
+3. **Harness limits**, where they exist: Vibe's `--max-price` set to
+ the reservation, and Equipo's own `max_tokens` on every request where
+ the harness takes a per-model output limit. These are a second
+ barrier only; the runner's ledger is the rule.
+4. **Provider-side limits**, recommended to Paul and not relied on: a
+ per-key credit limit where the provider offers one (OpenRouter does;
+ TensorX's per-key limits are rate limits, not spend limits).
+
+**Reconciling.** A reservation is released only after the termination
+proof and the attempt's usage row (the housekeeping rule). An attempt
+with no usage figure is charged its whole reservation. Where the
+harness reports its own cost (Pi's `usage.cost`), the runner charges
+the larger of that and its own price-table figure, and records both.
+Lowering a cap stops new admissions at once. In-flight attempts may
+spend up to their reservation and no further.
+
+**Subscriptions first.** `schedule.Decide` (§8) offers a metered pair
+only when one of these holds:
+
+- **Spill:** no subscription pair is plausible for the step at its
+ priority, and either the task is `urgent` (§0 decision 2) or Paul
+ allowed metered use for this task. A `normal` or `low` task waits for
+ the reset instead. A task whose `by` the wait would miss goes to Needs
+ you with "I'd run it on TensorX" (§9), never to TensorX on its own.
+- **Cheap and short:** the step's `p90` cost is at most the
+ connection's `cheap_job` threshold (default $0.02), its p90 duration
+ is at most 10 minutes, and the role is Review, Checks triage or
+ explore. This spends a few cents to save subscription room for
+ Engineering. It is off until Paul turns it on (§0 decision 2).
+
+**The spend line on the Usage page.** It shows one row per metered
+connection, for example "TensorX: $0.84 today of $1 · $6.20 this month
+of $10", with a thin meter each and the words "estimated from tokens".
+TensorX and the Mistral API publish no usage API, and OpenRouter's key
+endpoint can later replace the estimate. Subscriptions show tokens,
+never dollars. A capped connection's row says "Paused until tomorrow" or
+"Paused until 1 Dec". The sidebar dot of rev 3 §6 also lights at 80% of
+any cap.
+
+# Part B: token-aware scheduling and advice
+
+## 7. Facts the scheduler reads
+
+Everything is recorded before it is used. Nothing is read from a model's
+words at decision time.
+
+**Per connection** (runner, `thin.db`, mirrored to the instance as
+today): `kind` (`subscription`, `metered`, `local`), state, the
+headroom windows the provider reported (`used`, `resets_at`,
+`checked_at`), and for metered connections the caps and spend of §6.
+Unreported is null, never zero.
+
+**Calibration, per connection and window.** Providers report a
+percentage, steps cost tokens. The runner learns `w_per_pct`, the
+weighted tokens that moved a window by one percent. It uses two readings
+of the same window on the same connection, at most six hours apart and
+within one reset period, with every Equipo attempt between them
+`complete`. Weighted tokens are `input + cache_write + output +
+reasoning + cached_input / 10`. This is a unit for comparing steps
+against each other, not a claim about how providers meter. The runner
+keeps the median of the last 20 samples. Paul also uses these
+subscriptions outside Equipo, which only lowers a sample (more percent
+for the same Equipo tokens), so the calibration errs towards "less
+room". With fewer than 5 samples the calibration is `unknown`.
+
+**Per task:** `priority` (`urgent`, `normal`, `low`; default `normal`)
+and an optional `by` (a date). The coordinator may set `low`, `normal`
+and `by` on `record_task` and `start_task` from what the person said
+("no rush", "I need this by Friday"). Like rev 3 §4's size and risk,
+this describes the job and chooses nothing. **Only Paul's tap sets
+`urgent`**, because `urgent` is the one priority that may spend metered
+money (§6). This follows merge authority's rule that the coordinator
+can only tighten. The task page shows priority and `by`, and Paul
+changes them with one tap. A value the coordinator set is labelled "set
+from your message" until he does. Caps are never affected by priority.
+
+**Per step kind: the estimate.** The instance computes it from
+`chat_usage` rows with `complete` and `outcome = replied`, keyed by
+`(project, specialist, round = 0 | fix)`. It uses the last 20 rows, falls
+back to the same key across all the person's projects, and then to seed
+values (Engineering first pass 300k weighted, fix round 150k, Review
+100k, Checks 0) that data replaces after 5 rows. It sends `estimate {p50,
+p90, basis: project | person | seed, rows}` on `dispatch`, so the runner
+decides with the instance's history even when the instance is offline
+later. The size class, once rev 3 slice 3 lands, scales the seed only
+(small ×0.5, large ×2), never measured figures.
+
+## 8. The decision: `schedule.Decide`
+
+One pure function in `internal/schedule`, evaluated by the runner each
+time a step is admitted from its queue and again for every held step
+when a fact changes: a reset passes, a reading arrives, a step ends, a
+cap or preference changes, or Paul taps Run now. Its inputs are the
+facts of §7, the eligible pairs from `connect.Choose`'s filter
+(capable, usable, not avoided, the Review family rule), the open
+reservations and `now`. It returns `{action: run | hold, connection,
+model, reason, until, needs_person}`. A table test covers each rule and
+a property test covers the invariants below. The instance never
+re-decides; it shows what the runner reported, as it does for failover.
+
+**Room.** The room on a subscription connection for a step is the
+tightest reported window's `(1 − used − reserve) × 100 × w_per_pct`,
+less the open reservations on that connection. A step is **plausible**
+there when `room ≥ p90`. With calibration `unknown` the step is plausible
+when the tightest window's `used ≤ 1 − reserve − 0.1`. With no window
+reported at all (Command Code headless, Vibe), it is plausible when the
+connection is not `limited`, and the routing row says "headroom not
+reported". A reading older than 15 minutes is refreshed by the rev 3
+§2.7 probe before it counts, as housekeeping's stand-down already does.
+
+**The reserve ladder** is the core of "deciding what can wait". Each
+priority leaves part of every subscription window untouched:
+
+| Priority | Reserve kept free | Effect |
+|---|---|---|
+| `low` | 30% | runs on the first 70% of a window, then waits for its reset |
+| `normal` | 10% | stops short of the last 10%, which keeps the coordinator answering |
+| `urgent` | 0% | uses whatever is plausible |
+
+Person turns with the coordinator are never held for priority. They use
+the 10% the steps leave, and they still fail over and wait on
+`no_connection` as today. Housekeeping keeps its own stand-down (0.8 on
+the selected connection), which is stricter than `low`.
+
+**Order of rules**, the first that applies wins:
+
+1. **Hard bars.** Health, the Review family rule, and for metered
+ connections the cap reservation of §6. Nothing overrides a hard bar,
+ Run now included.
+2. **Override.** Paul tapped Run now: run on the eligible pair with the
+ most room, ignoring the ladder and plausibility (reason `override`).
+3. **Subscription first.** Among subscription pairs where the step is
+ plausible with its priority's reserve: stickiness, then preference,
+ then the most room (rev 3 §3 order, reasons as today).
+4. **Local**, when a local endpoint is eligible and its tier meets the
+ step's floor (rev 3 §4), reason `cheapest`.
+5. **Metered**, only as §6 allows (reason `metered_spill` or
+ `metered_cheap`).
+6. **Hold.** No pair qualifies. `until` is the earliest reset among the
+ eligible subscription pairs after which the step would be plausible,
+ or null. The reason is `headroom` (naming that connection), `cap`, or
+ `no_connection` (today's).
+
+**Release order.** When room returns, held steps are reconsidered in
+this order: `urgent`, then an earlier `by`, then `normal`, then `low`,
+oldest first within each. Each admitted step reserves its `p90` against
+the connection's room until it ends, so two steps never claim the same
+last room. Reservations live in one table and are written in one
+transaction with the admission, the shape of the housekeeping ledger.
+They are released after the termination proof and the attempt's usage
+row, and an attempt with no usage figure is charged its whole
+reservation.
+
+**Never start what cannot finish.** Rule 3's plausibility is the check
+before start. During a step nothing is cut short for headroom. A
+subscription that refuses mid-step is the existing quota failover
+(termination proof, fresh tree, another pair). Only a metered cap kills
+a step mid-run (§6).
+
+**Invariants**, each a property test over random facts:
+
+- Nothing is held while a plausible subscription pair exists for its
+ priority.
+- A `low` step never takes a window past 70%.
+- A metered pair is never chosen when §6 forbids it.
+- The sum of open reservations never exceeds a connection's room at
+ admission.
+- Run now never passes a hard bar.
+- The output depends only on the inputs: the same facts give the same
+ decision.
+
+## 9. Holding, visibly, and Paul's override
+
+A held step reports `step {state: deferred, hold {reason, connection,
+until}}`, an optional extension of today's deferred report. The task
+row and the task page say:
+
+- "Waiting for headroom on Claude, resets Thu 10:00" (`headroom`, with
+ `until`);
+- "Waiting for headroom on Claude" (no reset reported);
+- "Waiting: TensorX has reached today's cap" (`cap`).
+
+Each has one action, **Run it now anyway**.
+
+**Needs you stays clean.** A hold enters Needs you only when Paul's
+input would change the outcome:
+
+- the task has a `by` and `until` (or, with no `until`, now plus 24 h)
+ falls after `by` minus the step's p90 duration;
+- no reset is in sight (`until` null, or more than 72 h away) and a
+ metered pair could run it if Paul allowed it. Allow TensorX for this
+ task is a per-task override, recorded, that still obeys the cap. A
+ hold with a reset in sight stays quiet, even when TensorX could take
+ it;
+- nothing at all can run the role (`no_connection`, today's card).
+
+The card asks with a recommendation, as the merge authority does
+(§4.1 there). The instance composes it from the hold:
+
+- "I'd wait: Claude resets Thu 10:00, before Friday." **Wait** /
+ **Run now on Claude**
+- "I'd run it on TensorX: about $0.40, within today's cap." **Run on
+ TensorX** / **Wait for Claude**
+
+**Run it now anyway** is `POST /api/v1/tasks/{id}/run-now`. It sends a
+durable `release{task, step}` frame, whose effect is rule 2 for that
+step's next admission only. A held coordinator turn is not something
+Paul sees here: person turns are never held for priority.
+
+## 10. Advice: quiet cards, computed, rate-limited
+
+`advice.Compute(facts, now) []Advice` is a pure function on the
+instance. It reads the mirrored connection facts, the open holds, the
+estimates, `chat_usage` and the routing rows. It runs on those events
+and at 08:00 in Paul's zone. Each advice has a `kind`, a `subject` and
+a stable key. The copy is fixed templates with slots, so no model turn
+computes or phrases it. The coordinator can read open advice through
+`status` when Paul asks how his tokens look. It cannot create, change or
+dismiss advice.
+
+| Kind | Fires when (all facts recorded) | Card | One-tap actions |
+|---|---|---|---|
+| `prefer_switch` | the role's preferred subscription is past `normal`'s reserve with its reset more than 24 h away, another subscription has 50% room, and the queued steps' p50 fits in it | "Claude is near its limit until Thu. Codex has room. Prefer Codex for Engineering until then?" | **Prefer Codex until Thu** (a preference with `until`, which reverts by itself) / **Not now** |
+| `defer_tasks` | queued `normal` tasks without `by` have a p50 total above the room left before the reset, while `urgent` or `by` work is queued | "These 3 tasks would use most of Claude's week. Let them wait for Thu?" | **Make them low priority** / **Not now** |
+| `add_account` | in 14 days, steps waited on `headroom` for at least 8 h over at least 3 days, or one subscription was limited 3 or more times | "Work waited 19 h for Claude in the last two weeks. Another account would cover it." | **Add a connection** / **Not now** |
+| `swap_account` | a subscription has had no usage rows for 30 days while another was limited at least twice | "Vibe has not been used in a month while Claude ran out twice. Prefer Vibe for Review?" | **Prefer Vibe for Review** / **Not now** |
+| `cap_near` | a metered connection passes 80% of a cap | "TensorX: $0.84 of today's $1." | **Raise today's cap** / **Leave it** |
+
+**Never nags:**
+
+- at most one new advice card per person per day, and at most one open
+ at a time;
+- a key Paul answered Not now stays silent for 14 days, and for 60 days
+ after a second Not now;
+- advice whose facts stop holding is withdrawn silently;
+- quiet hours from 22:00 to 08:00, using housekeeping's `VisibleAt`;
+- never in Needs you, never a push notification.
+
+Cards show at the top of the Usage page and as one quiet card in the
+conversation, the receipt shape of merge authority §6.1. An action is a
+normal API call (preference, task priority, cap) recorded with
+`source: advice` and the key. Withdrawal and dismissal are rows in an
+`advice` table keyed `(person, kind, subject)`, which only moves forward
+like the housekeeping ledger.
+
+## 11. Wire, API and fixtures
+
+**Dispatch** gains `priority`, `by`, `estimate`, `metered_allowed`
+(the per-task override) and `run_now` (a release). **Step reports**
+gain `hold`. **Instance to runner:**
+
+- `caps{connection, day, month, revision}` (durable);
+- `release{task, step}` (durable);
+- `preference` gains `until`.
+
+**Runner to instance:**
+
+- `connection` gains `kind: metered | local`, `spend {day, month,
+ currency, estimated: true}` and `caps`;
+- `routing` reasons gain `override`, `metered_spill`, `metered_cheap`
+ and `held`.
+
+**API:**
+
+- `PUT /api/v1/connections/{id}/caps`;
+- `PUT /api/v1/tasks/{id}/priority {priority, by, revision}`;
+- `POST /api/v1/tasks/{id}/run-now`;
+- `POST /api/v1/tasks/{id}/allow-metered`;
+- `GET /api/v1/advice`;
+- `POST /api/v1/advice/{id}/act|dismiss`;
+- `GET /api/v1/usage`, as rev 3 §6 with `spend` per connection.
+
+The tools `record_task` and `start_task` gain the optional `priority`
+and `by`. The protocol version is bumped, and an older runner is never
+sent the new fields. As merge authority does, older runners are refused
+metered dispatch: a runner without the cap ledger cannot hold a metered
+connection.
+
+**Fixtures** under `wiretest/testdata`:
+
+- `api/connection-metered.json`, `api/caps.json`,
+ `api/task-held.json`, `api/advice.json`;
+- `frames/caps.json`, `frames/release.json`,
+ `frames/dispatch-estimate.json`, `frames/step-held.json`.
+
+The secret-field guard is extended to every new type.
+
+## 12. Slices
+
+Each slice runs headless first (contracts, runner, a fake-CLI scenario
+green in CI), then on staging with the real pinned CLI, then UI, as
+rev 3 §8. Every connector slice opens with its probes, and a failed
+probe turns its cells to "No" with the reason; nothing is spun. **Sec**
+marks a slice that needs its own Astra round on its branch before merge.
+Sizes are agent days.
+
+| # | Slice | Finish line | Sec | Size |
+|---|---|---|---|---|
+| S1 | Metered base: `KindAPIKey` sealed paste generalised from tokens, the egress host table keyed by harness and provider, the `spend` ledger, caps and the four defences of §6, the spend line | A fake metered step is killed at the cap with a termination proof, and the ledger, the usage row and the Usage line agree | **Sec** | 2 |
+| S2 | Pi on TensorX: pin, Pi profile in `policy.go`, the gating extension, `fakepi`, RPC adapter, rev 3 probes P1 to P5 | A real Review step runs on TensorX GLM under a $0.10 cap on staging and is recorded `other_family` | **Sec** | 3 |
+| S3 | Scheduler: `priority` and `by`, estimates on dispatch, `schedule.Decide` with the reserve ladder, holds with reason and `until`, release order, Run now, the Needs you rule | A `low` task shows "Waiting for headroom on Claude, resets …" past 70% and starts by itself after the reset, or at once on Run now | | 2.5 |
+| S4 | Calibration, the Usage page (availability, spend, tokens), advice and its rate limits | Each advice kind fires once from recorded fixtures, and Not now silences it for 14 days | | 2 |
+| S5 | OpenCode: Go subscription and TensorX fallback, `serve` adapter, host discovery, probes OC-P1 to OC-P3 | One real Engineering step on OpenCode Go on staging, with its usage row and no host outside the allowlist attempted | **Sec** | 2.5 |
+| S6 | The ACP adapter and Mistral Vibe: `fakeacp`, the link sign-in (V-P1) and the sealed key, `export.json` usage, V-P3 billing headroom | A real Vibe Review of a Claude step on staging, signed in from the app with no terminal | **Sec** | 3 |
+| S7 | Command Code over ACP: host discovery, CC-P1, the sealed Studio key | One real Command Code Engineering step on staging, or its cells marked No with the probe's reason | **Sec** | 1.5 |
+| S8 | Mac: an srt profile per connector and the P2-style denial probes | One Pi Review step on Tito Studio under srt, with denial proven on every path | **Sec** | 2 |
+
+The recommended order is S1, S2, S3, S4, S5, S6, S7, S8 (§0
+decision 8). S3 and S4 touch no credential and can run beside S1 and
+S2.
+
+## 13. Risks
+
+- **Headroom stays best effort.** Three of the four new connectors
+ report none headless. The scheduler treats "not reported" as "not
+ limited" for plausibility, so on those connectors it holds nothing
+ until a limit is hit, and failover does the rest.
+- **The calibration is a model.** Equipo has its own weighting, and
+ Paul's outside use shares the windows. It errs towards holding, the
+ invariants keep it from ever blocking `urgent` work on a subscription
+ with reported room, and Run now is always one tap away.
+- **The relay cannot meter.** It is a CONNECT tunnel, so a harness that
+ under-reports usage could spend more than Equipo counts. The
+ worst-case charge for an unreported response and the whole-reservation
+ charge for a silent attempt bound that.
+- **OpenCode Go can overflow into Console credit.** When OpenCode does
+ not surface `billing_source`, Equipo cannot see that overflow, and
+ the Console balance is the guard.
+- **Undocumented surfaces.** Command Code's hosts and stream, Vibe's
+ billing endpoint, and OpenCode v2's switches are undocumented or
+ unconfirmed. Each is a probe with a stated fallback, not an
+ assumption.
+- **A third-party CLI holds a subscription key.** The Mistral plan key
+ goes only into Vibe, and the OpenCode Go key only into OpenCode, so
+ each subscription is used by its own vendor's client.
+- **Version drift.** Three npm trees and one Python tree to keep pinned
+ means more upkeep. Each pin bump re-runs that connector's probes,
+ as a Claude version bump rechecks its sandbox builder today.
+
+## 14. Sources
+
+Read 2026-11-12. Facts from source code rather than docs are marked as
+such in the text.
+
+- [CC1] https://registry.npmjs.org/command-code/latest, https://commandcode.ai/changelog
+- [CC2] https://commandcode.ai/docs/headless
+- [CC3] https://commandcode.ai/docs/quickstart, https://commandcode.ai/docs/settings
+- [CC4] https://commandcode.ai/docs/resources/pricing-limits, https://commandcode.ai/docs/resources/usage-limits
+- [CC5] https://commandcode.ai/docs/permissions, https://commandcode.ai/docs/resources/security
+- [CC6] https://commandcode.ai/docs/provider, https://commandcode.ai/docs/troubleshooting/telemetry
+- [CC7] https://commandcode.ai/docs/reference/cli/models
+- [V1] https://github.com/mistralai/mistral-vibe
+- [V2] https://pypi.org/pypi/mistral-vibe/3.1.2/json
+- [V3] https://github.com/mistralai/mistral-vibe/blob/main/vibe/setup/auth/http_browser_sign_in_gateway.py (source)
+- [V4] https://github.com/mistralai/mistral-vibe/blob/main/vibe/setup/auth/_oidc_config.py (source)
+- [V5] https://docs.mistral.ai/vibe/code/cli/api-keys-profiles
+- [V6] https://docs.mistral.ai/vibe/code/cli/configuration
+- [V7] https://docs.mistral.ai/vibe/code/cli/configuration-reference
+- [V8] https://docs.mistral.ai/vibe/code/safety-approvals-permissions
+- [V9] https://github.com/mistralai/mistral-vibe/blob/main/vibe/core/telemetry/send.py, .../vibe/observability/sentry.py (source)
+- [V10] https://github.com/mistralai/mistral-vibe/blob/main/docs/proxy-setup.md
+- [V11] https://api.github.com/repos/mistralai/mistral-vibe/releases
+- [V12] https://github.com/mistralai/mistral-vibe/blob/main/docs/programmatic-mode.md
+- [V13] https://docs.mistral.ai/admin/billing-usage/subscriptions
+- [V14] https://mistral.ai/pricing/
+- [V15] https://github.com/mistralai/mistral-vibe/blob/main/vibe/app_server/_billing.py (source)
+- [V16] https://github.com/mistralai/mistral-vibe/blob/main/vibe/cli-rust/src/headless_output.rs (source)
+- [P1] https://registry.npmjs.org/@earendil-works/pi-coding-agent/latest
+- [P2] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/configuration.md
+- [P3] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/models.md
+- [P4] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/environment-variables.md, .../docs/settings.md
+- [P5] https://pi.dev
+- [P6] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/json.md
+- [P7] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/rpc.md, .../docs/rpc-commands.md
+- [OC1] https://registry.npmjs.org/@opencode/cli/latest, https://registry.npmjs.org/opencode-ai/latest
+- [OC2] https://opencode.ai/docs/console/go/
+- [OC3] https://opencode.ai/docs/providers/
+- [OC4] https://opencode.ai/docs/api, https://opencode.ai/docs/cli/
+- [OC5] https://opencode.ai/docs/cli/config/, https://opencode.ai/docs/troubleshooting/
+- [OC6] https://opencode.ai/docs/config/
+- [OC7] https://opencode.ai/docs/permissions/
+- [OC8] https://opencode.ai/docs/network/
+- [OC9] https://opencode.ai/docs/providers/ (custom provider package)
+- [OC10] https://opencode.ai/docs/console/api/inference/
+- [OC11] https://opencode.ai/docs/console/models/
+- [T1] https://docs.tensorx.ai/, https://tensorx.ai/
+- [T2] https://docs.tensorx.ai/api-reference/rate-limits.md
+- [T3] https://docs.tensorx.ai/billing.md
+- [T4] https://tensorx.ai/pricing/
+- [T5] https://github.com/anomalyco/models.dev/tree/dev/providers/tensorx
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-CONNECTORS-SCHEDULING.md b/docs/superpowers/specs/CODEX-FINDINGS-CONNECTORS-SCHEDULING.md
new file mode 100644
index 00000000..e9119a44
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-FINDINGS-CONNECTORS-SCHEDULING.md
@@ -0,0 +1,57 @@
+VERDICT: NOT READY
+
+1. **Critical — §§6, 13:** Post-response usage cannot enforce a hard spend cap: billing precedes the event, silent requests remain invisible, and under-reported nonzero usage avoids the fallback charge. Require an enforceable worst-case reservation before every billable request through a trusted boundary or provider-side cap; otherwise describe this as a soft budget.
+
+2. **Critical — §§2, 5.1, 12/S8:** A namespace shared by the harness and its shell children does not protect the harness’s credential files or environment; the proposed Mac profile likewise leaves its own connection home accessible. Require separate tool containment, environment scrubbing and credential/process-read denial equivalent to rev 3 §2.4 before enabling any affected role.
+
+3. **High — §6:** The in-flight rule permits an attempt to exceed its reservation until the cap remainder is spent, potentially consuming money reserved by concurrent attempts. Define `charged + outstanding commitments ≤ cap`, with atomic reservation increases before further requests and no access to another attempt’s reservation.
+
+4. **High — §§6, 8:** The spend ledger has no crash-recovery or event-deduplication state machine, so a restart can lose charges, charge cumulative events twice, or retain reservations indefinitely. Specify durable admission, request and charge identities, recovery before new admission, and reconciliation of interrupted, missing and replayed usage.
+
+5. **High — §6:** Lowering a cap “at once” conflicts with allowing existing reservations to finish and with runners operating offline. Define when a revision becomes effective, expose pending runner acknowledgement, and explicitly choose whether outstanding commitments are grandfathered or further requests stop.
+
+6. **High — §§6, 11:** Connection-local accounting does not bound account depletion when a key is re-added, duplicated or used elsewhere, and reservations crossing midnight or month-end have no allocation rule. Define the budget identity and scope, retain charges across reconnection, and specify timezone changes and cross-period commitments.
+
+7. **High — §§0.5–6, 3–5:** OpenCode overflow is charged only after billing, while Vibe keys can have mixed billing and Command Code’s billing source remains unknown. Treat every potentially paid request as metered before dispatch unless a provider-enforced subscription-only mode is verified; a manually maintained zero balance is not a hard guard.
+
+8. **High — §§2, 4, 11:** New sign-in flows lack the precise URL validation, secret-output filtering and recovery rules of the built Claude flow; logging unknown adapter events also risks recording credentials. Specify provider-specific authorization URL checks, sanitized diagnostics, and cancellation/crash tests covering credential installation and sealed delivery.
+
+9. **High — §§2, 4, 5.2:** Host allowlisting cannot deny telemetry or paid inference paths on an allowed host: Mistral telemetry shares `api.mistral.ai`, and OpenCode Go and Console inference share `opencode.ai`. Replace the “denied by the relay anyway” claim with verified configuration guarantees, and make host discovery iterative so an initial denied bootstrap request cannot conceal later dependencies.
+
+10. **High — §2, Pinning:** Recording an installed tree’s digest establishes a local baseline rather than a release-approved pin, unlike the committed `SRTTreeSHA256`; extra files and executable links are unspecified. Commit expected digests per supported platform and define complete tree coverage, link validation and verification before launch.
+
+11. **High — §§2–5:** Disabling updates does not prevent repository-local configuration, plugins, extensions or startup hooks from changing tools, destinations or executing inside the credential-bearing harness. Require isolated configuration sources and effective-policy checks, with hostile repository fixtures proving that only Equipo’s pinned configuration and extensions load.
+
+12. **High — §§8–9, 11:** Run now precedes the metered permission rule, so a normal task can select TensorX without satisfying §6; its durable release also lacks consumption and stale-replay semantics. Make metered consent a hard eligibility condition and bind each release to an authorized person, task/step revision and atomically consumed admission.
+
+13. **High — §7:** Allowing the coordinator to change `low` to `normal` relaxes the reserve from 30% to 10%, contradicting “can only tighten.” Permit descriptive defaults at creation, but require a person’s action for subsequent priority increases or relaxation of a person-set restriction.
+
+14. **High — §§2, 7–8, 11–12:** The design assumes model-pair selection, tier floors, per-role preferences and pricing that the built `connect.Choose` and wire types do not provide. Make Connections slice 3 an explicit dependency or assign these additions to concrete slices, including separate harness, credential-method and billing-kind fields.
+
+15. **High — §8:** Filtering by plausibility before stickiness changes rev 3’s binding rule, and the existing failover loop can choose another connection without returning through the proposed admission gate. Define the permitted switching boundaries and route every new attempt through scheduling and reservation, while preserving Ask’s exact session/model binding.
+
+16. **High — §§7–8:** `schedule.Decide` lacks a complete input contract and total ordering: current binding, preferences, model prices, consent, unknown-room ranking and tie-breakers are unspecified, while refreshing readings requires side effects. Define a versioned immutable input and deterministic comparators, with probing and transactional revalidation outside the pure function.
+
+17. **High — §§6–7, 9:** Weighted tokens alone cannot determine dollar cost or p90 duration, yet both govern admission and deadline cards; the formula also ignores provider differences in whether cached and reasoning tokens are included in totals. Define normalized token components, complete-attempt aggregation, cost and duration estimates, quantile rules, missing-value handling and checked arithmetic.
+
+18. **Medium — §7, Calibration:** Calibration does not reject zero or negative percentage movement, overlapping attempts, delayed readings or changing window/model scope, so it can produce invalid or optimistic room. Specify valid sample boundaries, positive denominators and matching window scope, then calculate remaining capacity separately for every applicable window.
+
+19. **High — §8, Reservations:** Releasing a reservation after usage arrives can restore apparent capacity while the provider reading remains stale; conversely, a refreshed reading can already include consumption still counted as reserved. Track usage since each reading and the unconsumed part of each reservation so admission neither forgets nor double-counts consumption.
+
+20. **High — §§8, 13:** The stated invariants are false under the stated rules: Run now bypasses the ladder, unknown calibration ignores estimated size, and p90 admission cannot guarantee that low-priority work stays below 70%. Test admission guarantees with explicit override exceptions and describe actual subscription consumption as best effort.
+
+21. **High — §§8–9:** `until` considers only eligible subscriptions, excluding currently limited connections whose future reset may release the hold; cap resets and approaching deadline thresholds also lack explicit wakeups. Compute wakeups from future candidates and all binding windows, and persist timers for cap boundaries, deadlines and preference expiry.
+
+22. **Medium — §§8–9:** Strict priority can starve low work indefinitely, while a task larger than every connection’s maximum admissible room can remain quietly held forever. Define an impossible-to-fit outcome and an aging or notification policy, while ensuring held work never blocks runnable steps or person turns.
+
+23. **High — §§6, 8, 12:** Housekeeping’s 80% stand-down is less restrictive than low work’s 70%, and merely copying its ledger shape does not preserve its per-person budget across attempts and downstream steps. Define how both ledgers compose, retain `caused_by` and remaining-budget enforcement, and preserve housekeeping’s unknown-headroom stand-down and person-first behavior.
+
+24. **Medium — §10:** Advice has no deterministic arbitration or fully specified dismissal input, and account-switch suggestions do not establish runner, role, tier or family eligibility; “another account would cover it” is unsupported. Define stable keys and ordering, persisted cooldown facts and eligibility checks, with revision-checked actions and evidence-qualified recommendations.
+
+25. **High — §12:** The finish lines omit the failures most likely to invalidate the design: dishonest usage, crashes, cap revisions, hostile configuration and release replay; one Pi Review also cannot certify every Mac connector and role. Require an explicit adversarial acceptance matrix per supported cell, and prevent ACP fallbacks from earning cells when mandatory containment or permission-relay proofs fail.
+
+**Cut**
+
+- Defer “cheap and short” routing: subscription-first ordering currently prevents it from saving subscription room.
+- Defer token-denominated caps, OpenRouter and generic local routing until the money-cap path is sound.
+- Defer account-purchase advice until recorded waits can support its recommendation.
\ No newline at end of file