| 1 | # Equipo connectors and token-aware scheduling |
| 2 | |
| 3 | Status: **revision 3.3, approved** (2026-11-12): §16, models chosen per |
| 4 | step, on Paul's question at the TensorX model picker. Astra's round on |
| 5 | the first draft said NOT READY (ten Important); §16 was revised to |
| 6 | answer them (§16.8) and the controller approved it as written, with |
| 7 | three notes folded in: the tier table is committed beside the price |
| 8 | tables and covers OpenCode Go too (§16.2), OpenCode's model is fixed |
| 9 | over ACP rather than by a bridge (§16.5), and S5b takes protocol 18 |
| 10 | (§16.1). S5 (OpenCode on Go, protocol 17) is built and merged: |
| 11 | `S5-OPENCODE-PROGRESS.md`. Slice S5b builds this revision: |
| 12 | `S5B-MODELS-PROGRESS.md`. Revision 3.2 below is unchanged elsewhere, |
| 13 | except that §2.2's "one model per connection" is superseded by §16. |
| 14 | |
| 15 | Revision 3.2: approved (2026-11-12, the controller's rulings |
| 16 | #7 and #8 on S3's review). S1 (metered connections), S2 (Pi on TensorX) |
| 17 | and S3 (the scheduler) are built and merged: `S1-METERED-PROGRESS.md`, |
| 18 | `S2-PI-PROGRESS.md`, `S3-SCHEDULER-PROGRESS.md`. S4 (Usage and advice) |
| 19 | builds on this revision. Ruling #7: Codex readings older than 15 minutes |
| 20 | are refreshed by `account/rateLimits/read` with no model turn, Claude's |
| 21 | stay as last reported, and every reading's age is shown (§6, §7, §12). |
| 22 | Ruling #8: a kept metered session whose step lost its leave to spend |
| 23 | starts afresh on a subscription, as built (§7 rule 1). Drafted by |
| 24 | Claude (Opus 5.5) on `connections-slice2-design` from main 1d7b4e4. |
| 25 | |
| 26 | **History.** |
| 27 | |
| 28 | - Revision 1 (732d7d6): Astra round 1 said NOT READY. |
| 29 | - Revision 2 (6591b33) added a metering gateway on the runner. Astra |
| 30 | round 2 also said NOT READY, with a new Critical (the gateway did not |
| 31 | bound request bodies) and an Important (no namespace transport for |
| 32 | it). The full texts are in `CODEX-FINDINGS-CONNECTORS-SCHEDULING.md` |
| 33 | and `-R2.md`. |
| 34 | - Revision 3, on the controller's direction, **cuts the gateway from |
| 35 | v1**: |
| 36 | - hard caps live at the provider; |
| 37 | - Equipo keeps a soft budget from reported usage; |
| 38 | - keys reach the harness as Claude's and Codex's credentials do; |
| 39 | - scheduling decides admission from the readings taken at admission |
| 40 | and claims nothing about what a step will go on to consume. |
| 41 | |
| 42 | - Astra round 3, the last, on revision 3 (e9f1bc7): **READY WITH |
| 43 | CHANGES**, no Critical. Its ten Important findings are folded into |
| 44 | revision 3.1 (`-R3.md`, §15), with no further round. |
| 45 | - Revision 3.2 (2026-11-12) records the controller's two rulings on |
| 46 | S3's security review (#7 reading freshness, #8 a kept metered session |
| 47 | moving) and that S1 to S3 are built. Nothing else changes. |
| 48 | - S5 (OpenCode on Go, 2026-11-12) records the controller's ruling on |
| 49 | its security round's finding 3: OpenCode's usage gap is accepted and |
| 50 | stated (§2.3, §4.2, §12); reading OpenCode's own per-request rows is a |
| 51 | follow-up slice. |
| 52 | |
| 53 | §15 maps all three rounds' findings. |
| 54 | |
| 55 | This builds on: |
| 56 | |
| 57 | - Connections rev 3 (`2026-11-08-equipo-connections.md`, "rev 3"), as |
| 58 | built in `CONN1-PROGRESS.md`; |
| 59 | - the spend lines (`chat_usage`, migration 0059); |
| 60 | - the housekeeping budgets (`2026-11-08-equipo-housekeeping.md` §4); |
| 61 | - merge authority (`2026-11-11-equipo-merge-authority.md`): a |
| 62 | deterministic gate, the coordinator can only tighten, and asks come |
| 63 | with a recommendation. |
| 64 | |
| 65 | Provider facts were read from official docs and source on 2026-11-12 |
| 66 | (§14). |
| 67 | |
| 68 | ## 0. Decisions for Paul |
| 69 | |
| 70 | Each has a recommendation. Nothing is built until these are answered. |
| 71 | |
| 72 | 1. **"Pi" means Pi as the harness, with TensorX as the paid |
| 73 | connection.** Pi has no subscription of its own. *Recommend: yes.* |
| 74 | 2. **Command Code comes in as a provider behind Pi, for now.** You |
| 75 | already use its models through Pi, and its Provider API is a plain |
| 76 | API key. Its own CLI has undocumented hosts and output, so it is a |
| 77 | later design. *Recommend: yes.* Please check in Command Code Studio |
| 78 | whether Provider API calls draw on your plan's windows or on credits. |
| 79 | Until then it counts as metered. |
| 80 | 3. **The hard cap is the provider's, never Equipo's.** A metered |
| 81 | connection is accepted only after you confirm, on the add-connection |
| 82 | screen, that the key has a provider-side limit (§2.1 shows how for |
| 83 | each provider). For TensorX that limit is the prepaid balance, so |
| 84 | keep it at what you are willing to spend. A shell inside a step |
| 85 | could use the key up to that limit. *Recommend: accept this.* The |
| 86 | alternative, Equipo enforcing a hard cap itself, needs the gateway |
| 87 | that failed two reviews (§5). |
| 88 | 4. **Equipo's own budget is soft.** It is a daily and a monthly figure |
| 89 | per metered connection. Equipo stops starting new steps when the |
| 90 | **reported** spend reaches either. A metered connection runs one |
| 91 | step at a time, so it can overshoot by at most one step, and the |
| 92 | screen says so. *Recommend: $1 a day and $10 a month* as the |
| 93 | pre-filled defaults. |
| 94 | 5. **When does metered money get spent?** Only on tasks you mark |
| 95 | `urgent` (your tap, never the coordinator's), or a step you release |
| 96 | with "Run it now anyway". `normal` and `low` work waits for a |
| 97 | subscription. *Recommend: yes.* |
| 98 | 6. **The reserve thresholds.** A `low` step starts only while every |
| 99 | reported window of a subscription is below 60%, and a `normal` step |
| 100 | below 80%. `urgent` steps start on any connection that is not |
| 101 | limited. The thresholds are the margin, because Equipo does not |
| 102 | predict a step's consumption. *Recommend: these numbers.* |
| 103 | 7. **Subscriptions that can bill overflow** count as metered unless you |
| 104 | confirm on the add-connection screen that a **standing setting** |
| 105 | turns overflow off. For a Mistral plan that setting is pay-as-you-go |
| 106 | off. For OpenCode Go, a zero Console balance is a snapshot rather |
| 107 | than a setting, and no overflow switch is documented, so Go counts |
| 108 | as **metered** until you find one in the Console. *Recommend:* turn |
| 109 | Mistral's pay-as-you-go off and confirm it; leave OpenCode Go |
| 110 | metered until a switch is confirmed. |
| 111 | 8. **The coordinator stays on Claude and Codex.** The new connectors |
| 112 | take Engineering, Review and Ask. *Recommend: yes.* |
| 113 | 9. **Order.** *Recommend:* metered connections and the budget, Pi on |
| 114 | TensorX, the scheduler, Usage and advice, OpenCode Go, Mistral Vibe, |
| 115 | then the Command Code provider. The gateway, Command Code's CLI and |
| 116 | Mac are later (§5). |
| 117 | |
| 118 | ## 1. Why, and the shape |
| 119 | |
| 120 | Paul, 2026-11-12: the coordinator should "prioritise tasks according to |
| 121 | token availability… deciding what can wait etc, and … proactively offer |
| 122 | advice on how to handle tokens", and "can I get connectors for my |
| 123 | Mistral, Pi, Opencode and Command Code subscriptions? … Pi I guess would |
| 124 | then use… my TensorX? But I don't want to run that down too much." |
| 125 | |
| 126 | **Part A** adds three harnesses (Pi, OpenCode, Mistral Vibe) over four |
| 127 | accounts: TensorX, the Command Code Provider API, OpenCode Go and the |
| 128 | Mistral plan. The provider holds the hard cap, and Equipo keeps a soft |
| 129 | budget. |
| 130 | |
| 131 | **Part B** adds `schedule.Decide`, a pure function on the runner that |
| 132 | starts or holds each step from the readings taken at admission, and |
| 133 | `advice.Compute`, a pure function on the instance that turns recorded |
| 134 | facts into quiet cards. No model decides anything. |
| 135 | |
| 136 | **Reused, not redesigned:** |
| 137 | |
| 138 | - connections, homes and `connect.Choose`; |
| 139 | - the sealed paste, with `sealbox`, `seen_seals` and the delivery state |
| 140 | machine (rev 3 §2.4, built for Claude tokens); |
| 141 | - the token's delivery to the CLI, via a 0600 file outside |
| 142 | model-readable paths and bubblewrap's `--args` pipe; |
| 143 | - the egress relay (`internal/runner/egress`), CONNECT to allowlisted |
| 144 | public hosts on 443; |
| 145 | - usage rows (`wire.Usage`, `chat_usage`); |
| 146 | - the step deferral (`stepDeferred`); |
| 147 | - the policy and manifest digests; |
| 148 | - srt's committed-digest pinning. |
| 149 | |
| 150 | # Part A: connectors |
| 151 | |
| 152 | ## 2. Metered connections |
| 153 | |
| 154 | ### 2.1 The provider's limit is the only hard cap |
| 155 | |
| 156 | A connection is **metered** when its key is billed per token, or when it |
| 157 | is a subscription that can bill overflow and Paul has not confirmed that |
| 158 | pay-as-you-go is off. The add-connection screen for a metered connection |
| 159 | has one required confirmation, "This key has a spending limit at |
| 160 | <provider>", with a line and a link saying how, from the provider's |
| 161 | docs: |
| 162 | |
| 163 | | Provider | The provider-side limit | Source | |
| 164 | |---|---|---| |
| 165 | | TensorX | The prepaid balance. Keys are disabled when it falls under $0.05. Keep it at what you are willing to spend. Whether TensorX has automatic top-up, and per-key spend limits, is not documented; check that no top-up is set. | [T3] | |
| 166 | | Command Code Provider API | A pay-as-you-go account has only its credit balance, and a plan has dollar caps per 5 hours and per week. Either is a limit, if auto-purchase of credits is off (not documented; check in Studio). | [CC4] | |
| 167 | | OpenCode Go | The Go plan's per-model limits, and then the prepaid Console credit that overflow draws on (top-ups carry a fee). The Console balance is the hard limit. It is a balance, not a setting, so Go stays metered (§0 decision 7). | [OC2, OC12] | |
| 168 | | Mistral plan | The plan's monthly usage. Overflow needs pay-as-you-go to be enabled, so pay-as-you-go off is the limit. | [V13] | |
| 169 | |
| 170 | The confirmation is recorded with the person, the time and the provider. |
| 171 | Equipo cannot verify it, and the screen says so: |
| 172 | |
| 173 | > "Equipo can't see this limit. It is the only thing that stops spending |
| 174 | > for certain: Equipo's own budget is checked between steps, and a step |
| 175 | > that is running can use this key up to the limit you set at |
| 176 | > <provider>." |
| 177 | |
| 178 | **Why a step can use the key.** These harnesses have no sandbox of |
| 179 | their own for shell commands, unlike Claude Code's nested sandbox, which |
| 180 | keeps its token out of reach (rev 3 §2.4). A command a model runs is in |
| 181 | the same namespace and user as the harness, so it can read the harness's |
| 182 | environment and spend the key. It can spend it only at the provider's |
| 183 | host, because the relay allows nothing else. That is stated, not |
| 184 | mitigated, in v1. Keeping the key out of the namespace altogether is the |
| 185 | gateway, which is later (§5). |
| 186 | |
| 187 | ### 2.2 Delivery, as Claude and Codex credentials are delivered |
| 188 | |
| 189 | - **Sign-in is a sealed paste only:** rev 3 §2.4 as built, generalised |
| 190 | from `KindToken` to `KindAPIKey`, with `endpoint` the provider's |
| 191 | origin. The key lands as a 0600 file in the connection's home, |
| 192 | outside every path a model tool is given. |
| 193 | - **Each launch** gets the key as the harness's environment variable |
| 194 | through bubblewrap's `--args` pipe, never in argv, a manifest or a |
| 195 | record. The harness's config names that variable and never holds the |
| 196 | key. |
| 197 | - **Egress** goes through the relay, allowed to the provider's host |
| 198 | only: `api.tensorx.ai`, `api.commandcode.ai`, `opencode.ai`, |
| 199 | `api.mistral.ai`. `egress.ProviderPolicy` and `Policy.Hash` become a |
| 200 | table keyed by `(harness, provider)`. There is no other network. |
| 201 | - **Health (round 3, finding 10):** the runner, outside the namespace, |
| 202 | calls `GET /v1/models` with the key, and Paul picks the connection's |
| 203 | one model from the list on the connect card (superseded by §16: an |
| 204 | allowed set, with the model chosen per step). A second model is a |
| 205 | second connection, since rev 3's model-pair routing is unbuilt. The |
| 206 | connection is `healthy` only after a **one-token completion** on the |
| 207 | selected model (`POST …/chat/completions`, `max_tokens: 1`, at the |
| 208 | provider's own path in §4) succeeds. That is the selected-model proof |
| 209 | rev 3 §2.5 requires. It runs at connect and on Check again only, as |
| 210 | Claude's token check does, never hourly. It is billable, so it is |
| 211 | recorded as a usage row with role `probe` and charged to the budget |
| 212 | like any other. |
| 213 | |
| 214 | ### 2.3 The soft budget |
| 215 | |
| 216 | - **Figures.** Each metered connection has `budget {day, month}` in the |
| 217 | price table's currency, with both required and pre-filled (§0 |
| 218 | decision 4). Day and month are in the person's zone, UTC until one is |
| 219 | known. |
| 220 | - **Spend is what the harness reported (round 3, finding 5).** Each |
| 221 | attempt's usage becomes **normalised billable components**: |
| 222 | `uncached_input`, `cached_input`, `cache_write`, `output` and |
| 223 | `reasoning`. `reasoning` is counted apart from `output` only where |
| 224 | the provider's price-table entry says it bills separately; otherwise |
| 225 | it is treated as included in `output` and not added. Per adapter: |
| 226 | - **Pi:** `message_end.usage` is per request. The attempt's figure is |
| 227 | the sum over its assistant messages, and it is `complete` when |
| 228 | `agent_end` was seen. |
| 229 | - **OpenCode:** whether `session.usage.updated` is cumulative or |
| 230 | incremental is probe OC-P4. If cumulative, the attempt is the last |
| 231 | total less the total at the attempt's start, as `CodexTally` does; |
| 232 | if incremental, the sum. It is `complete` when the session went |
| 233 | idle. As built (S5, over ACP, §4.2): the prompt's answer carries the |
| 234 | turn's own sum over its requests (OC-P4), complete at that answer; |
| 235 | a turn whose figure has no input at all is spend unknown. A request |
| 236 | inside a turn that the provider answers without usage counts as |
| 237 | zero in that sum, so a turn of several requests can be |
| 238 | under-counted, and Equipo cannot see it through ACP (§12). |
| 239 | - **Vibe:** one attempt is one run. It is `export.json`'s totals, |
| 240 | `complete` when the file is present and parses. |
| 241 | |
| 242 | Price tables are versioned per connection: `{model, currency, |
| 243 | micros per million for each component, price_version}`. Cost is |
| 244 | int64 micro-units with overflow checks. A model with no price, or a |
| 245 | component the table cannot price, makes the attempt's spend unknown |
| 246 | (above). Where the harness reports its own cost (Pi `usage.cost`, |
| 247 | OpenCode `cost`, Vibe's export), the larger figure is charged and |
| 248 | both are recorded. `wire.Usage` gains `cost_micros`, `currency`, |
| 249 | `price_version` and `cost_reported_micros`. Spend is charged to the |
| 250 | day and month in which the attempt's usage row was recorded. |
| 251 | - **The ledger:** `budget_charge` rows in `thin.db`, keyed by the usage |
| 252 | row's existing key `(turn, step, attempt, connection, model)`, so a |
| 253 | resent row charges once. |
| 254 | - **One slot per metered connection (round 3, finding 1).** A metered |
| 255 | connection has one durable `metered_slot` row in `thin.db`. Every |
| 256 | attempt on it claims the slot in the same transaction as its |
| 257 | admission, whatever it is: an Engineering or Review step, a question, |
| 258 | a probe. Admission requires the slot to be free and `reported spend < |
| 259 | budget` for both the day and the month. The slot is released only |
| 260 | after the attempt's **termination proof** and either a committed |
| 261 | charge or `spend_unknown`, in one transaction. Cancellation and |
| 262 | failure take the same path. |
| 263 | - **Restart recovery.** At start-up, before anything is admitted, a |
| 264 | claimed slot is reconciled: |
| 265 | 1. the attempt's namespace is recovered and killed, with the exit |
| 266 | proven, as the existing recovery does; |
| 267 | 2. a usage row already committed is charged; |
| 268 | 3. otherwise the connection becomes `spend_unknown`; |
| 269 | 4. then the slot is released. |
| 270 | |
| 271 | The overshoot is therefore at most what one attempt spends, which the |
| 272 | provider's limit bounds. |
| 273 | - **Unknown spend pauses.** An attempt that ends without a complete, |
| 274 | priced usage figure marks the connection **"spend unknown"**, with a |
| 275 | `pause_revision`. Nothing more is admitted to it until Paul taps |
| 276 | Resume, after looking at the provider's dashboard. **Resume (finding |
| 277 | 3)** carries the `pause_revision` it saw. The runner consumes it |
| 278 | atomically once, and only if that is still the current pause. A stale |
| 279 | or repeated Resume leaves a newer pause in place. |
| 280 | - **Budget changes** take effect when the runner applies the durable |
| 281 | `budget` frame. Until then the page shows "applies when <runner> |
| 282 | confirms". A running step is not stopped by a change. |
| 283 | - **The screen** shows, for example, "TensorX: $0.84 today of $1 · |
| 284 | $6.20 this month of $10 · reported by Pi, can go over by one step", |
| 285 | with "Paused until tomorrow", "Paused until 1 Dec" or "Spend unknown: |
| 286 | check TensorX, then Resume". |
| 287 | |
| 288 | ## 3. What every connector must have |
| 289 | |
| 290 | - **Isolated configuration.** Each harness loads only Equipo's |
| 291 | configuration: fixed config and home directories; project-local |
| 292 | configuration, extensions, plugins and hooks disabled by flag or |
| 293 | environment; and `check_policy.go`'s effective-policy check extended |
| 294 | to each harness. A hostile-repository fixture (a project config, an |
| 295 | extension, an `AGENTS.md` asking for a tool) proves it. |
| 296 | - **Containment (Linux).** The existing bubblewrap namespace: the |
| 297 | credential home mounted to the harness, the relay to the provider |
| 298 | host only, a runtime copy, no inherited environment, pidfd |
| 299 | termination. The harness's approval layer is set to "allow inside the |
| 300 | namespace", because the namespace is the containment. Update checks, |
| 301 | telemetry and catalogue fetches are switched off by configuration, |
| 302 | and on a host other than the provider's they are also refused by the |
| 303 | relay. |
| 304 | - **Pinning.** Expected digests are **committed per supported |
| 305 | platform**, as srt's tree digest is: |
| 306 | - npm trees (Pi, OpenCode): a committed `package-lock.json` installed |
| 307 | with `npm ci --ignore-scripts`, plus a committed SHA-256 over every |
| 308 | file's path, mode and content, symlinks included (each must resolve |
| 309 | inside the tree), and the platform binary's own SHA-256 where there |
| 310 | is one; |
| 311 | - the PyPI tree (Vibe): `uv pip install --require-hashes` from a |
| 312 | committed lock, a pinned Python, and the same tree digest. |
| 313 | |
| 314 | The digest is verified before every launch, and the install directory |
| 315 | is read-only. |
| 316 | - **Mapping.** Each adapter's `Decode` yields Equipo's existing kinds: |
| 317 | `delta`, `tool_call`, `tool_result`, `ask`, `usage`, `done` |
| 318 | (`completed`, `failed` or `interrupted`) and the failure classes. |
| 319 | Unknown events are counted and dropped, type names only. |
| 320 | - **Families.** Review's `other_family` is judged on the model that ran. |
| 321 | - **Acceptance**, per supported cell, in CI with the fake and once on |
| 322 | staging with the pinned binary: |
| 323 | - the hostile-repository fixture loads nothing; |
| 324 | - only the provider host is reachable; |
| 325 | - Review has no write or shell tool; |
| 326 | - killing the namespace ends every descendant; |
| 327 | - the budget stops the next step when the reported spend reaches it; |
| 328 | - a step with no usage figure pauses the connection; |
| 329 | - a resent usage row charges once. |
| 330 | |
| 331 | Unlike Claude's acceptance, there is **no** "a model `cat` finds no |
| 332 | key" check, because §2.1 says it can. The test asserts the opposite |
| 333 | plainly, so the statement stays true. |
| 334 | |
| 335 | ## 4. The connectors |
| 336 | |
| 337 | ### 4.1 Pi on TensorX, and on the Command Code Provider API |
| 338 | |
| 339 | Pi is `@earendil-works/pi-coding-agent` 1.5.2. The `@mariozechner` |
| 340 | package is deprecated. It needs Node 22.19 or later and has no install |
| 341 | scripts. [P1] |
| 342 | |
| 343 | - **Provider config:** `PI_CODING_AGENT_DIR` points at the home. [P2] |
| 344 | `models.json` declares the provider as `openai-completions` with |
| 345 | `apiKey: "$TENSORX_API_KEY"`, or Command Code's variable. [P3] |
| 346 | - TensorX is OpenAI-compatible at `https://api.tensorx.ai/v1`. [T1] |
| 347 | - Command Code's Provider API is at `api.commandcode.ai/provider/v1`, |
| 348 | and its Claude models need `/messages`, which is not used. [CC6] |
| 349 | That other models are served on chat completions is inferred. Probe |
| 350 | CC-P1 checks it, and S7 is dropped if it fails. |
| 351 | - **Switches:** `PI_OFFLINE=1`, `PI_SKIP_VERSION_CHECK=1`, |
| 352 | `PI_TELEMETRY=0` and `--no-approve`. [P4] Pi has no permission layer. |
| 353 | [P5] Gating is Equipo's own extension (`-e`, hashed in the manifest), |
| 354 | and Review runs with `--tools read,grep,find,ls`. |
| 355 | - **Mapping:** RPC mode. `message_update` is `delta`. |
| 356 | `tool_execution_start` and `_end` are `tool_call` and `tool_result`. |
| 357 | `extension_ui_request` is `ask`, `agent_end` is `done`, and |
| 358 | `message_end.usage` gives `usage`, with `cost`. [P6, P7] Rev 3's |
| 359 | probes P1 to P5 gate every cell. |
| 360 | - **Headroom:** none reported. TensorX shows only per-minute rate |
| 361 | limits, and a key whose balance is under $0.05 fails as an |
| 362 | authentication error. [T2, T3] Such a failure reads "TensorX refused |
| 363 | the key: the balance may be empty, or the key was revoked". |
| 364 | - **Families:** from the model id (`z-ai/glm-5.3` is `glm`, |
| 365 | `moonshotai/kimi-k3.1-pro` is `kimi`, `deepseek/…` is `deepseek`). |
| 366 | [T4, CC7] |
| 367 | |
| 368 | ### 4.2 OpenCode on OpenCode Go |
| 369 | |
| 370 | OpenCode v2 is `@opencode/cli` 2.2.7. It has a `postinstall` script and |
| 371 | platform binaries as optional dependencies, so the platform binary is |
| 372 | pinned by SHA-256. [OC1] Paul's subscription is presumably **OpenCode |
| 373 | Go** ($10, Plus $40 a month): a dollar limit per model, with the 5-hour |
| 374 | limit at 20% of the monthly one and the weekly at 50%. On a limit it can |
| 375 | fall back to Console credit. [OC2] |
| 376 | |
| 377 | - **Provider config:** a custom `openai-compatible` provider, its |
| 378 | package pre-installed in the pinned tree, with the key in an |
| 379 | environment variable it names. [OC3, OC9] The upstream is |
| 380 | `https://opencode.ai/inference/go`, chat completions only. [OC10] |
| 381 | - **Switches:** `update: "disable"`, with `XDG_CONFIG_HOME` and |
| 382 | `OPENCODE_DB` in the home. [OC5, OC6] The permissions list ends in an |
| 383 | explicit deny, and Review gets explicit `edit` and `shell` denies. |
| 384 | [OC7] Catalogue and telemetry switches are unconfirmed in v2. Probe |
| 385 | OC-P1 checks that OpenCode works with only `opencode.ai` reachable. |
| 386 | If the catalogue lives on `opencode.ai` too, its fetch is a known, |
| 387 | stated leak of the model list request, not of data. |
| 388 | - **Driving it (round 3, finding 9):** `opencode serve --standalone |
| 389 | --hostname 127.0.0.1 --port <fixed>` inside the namespace, on the |
| 390 | namespace's own loopback, which the runner cannot reach. The control |
| 391 | path is therefore an **in-namespace stdio bridge**: a small mode of |
| 392 | the certified namespace helper (the binary that is already PID 1). It |
| 393 | connects only to `127.0.0.1:<fixed>` inside the namespace, allows only |
| 394 | the OpenCode paths the adapter uses (create session, prompt, the SSE |
| 395 | event stream, the permission reply, abort), and relays them as framed |
| 396 | JSON over the helper's stdio, which the runner already owns as the |
| 397 | capture. Its mode, port and path list are part of the policy manifest |
| 398 | and its hash, and it exits with the namespace. The SSE `GET |
| 399 | /api/event` gives text, tool calls, results and `permission.asked`, |
| 400 | answered at the reply endpoint. Usage comes from |
| 401 | `session.usage.updated`. [OC4] If probe OC-P2 finds a stdio mode in |
| 402 | OpenCode v2 (`acp`, unconfirmed), the bridge is not built. |
| 403 | - **Usage as built (S5).** OC-P2 found `opencode acp`, so S5 drives ACP |
| 404 | and builds no bridge. ACP gives each turn's usage summed over its |
| 405 | requests, with no per-request figure. In a turn with several |
| 406 | requests, OpenCode reports a request without usage as zero, so the |
| 407 | turn's spend can be under-counted, and Equipo cannot see this through |
| 408 | ACP. The gap is accepted (the controller's ruling on S5's security |
| 409 | round, finding 3) and stated on the Usage page for OpenCode's |
| 410 | connections. The follow-up slice reads the per-request rows from |
| 411 | `OPENCODE_DB` after the attempt (each request is one `assistant` row |
| 412 | with its own tokens; one without usage has every token 0), and makes |
| 413 | such a turn spend unknown. |
| 414 | - **Billing:** metered (§0 decision 7), unless Paul confirms a standing |
| 415 | Console setting that disables overflow, which is undocumented today. |
| 416 | Headroom is "not reported" unless probe OC-P3 finds the Go allowance |
| 417 | in OpenCode's events. |
| 418 | - **Fallback:** if Pi fails its probes, a TensorX connection may use |
| 419 | `harness: opencode`. [T5] |
| 420 | |
| 421 | ### 4.3 Mistral Vibe on the Mistral plan |
| 422 | |
| 423 | Vibe 3.1.2 (PyPI, 2026-11-10) is Apache 2.0. [V1, V2] |
| 424 | |
| 425 | - **Provider config:** `VIBE_HOME` is the home. [V6] The plan key, from |
| 426 | chat.mistral.ai/code/extensions, "works … with a paid plan". [V5] It |
| 427 | reaches the launch as `MISTRAL_API_KEY`, through the pipe. |
| 428 | - **Switches:** `enable_telemetry = false` (which also stops crash |
| 429 | reports), `enable_update_checks = false` and `outside_workdir = |
| 430 | "deny"`. [V7, V8, V9] Telemetry would otherwise post to |
| 431 | `api.mistral.ai`, the one allowed host, so this switch, checked by the |
| 432 | policy test, is what stops it. |
| 433 | - **Driving it:** Engineering runs `-p --output streaming |
| 434 | --auto-approve`, and Review runs `--enabled-tools` with the read tools |
| 435 | only. `--output-dir` gives `export.json` with usage and cost. [V12, |
| 436 | V16] The line schema is unconfirmed: if probe V-P2 cannot map it, the |
| 437 | cells stay No. |
| 438 | - **Headroom:** the runner, outside the namespace, may read `GET |
| 439 | /v1/billing/budget` (`usage_percentage`, `reset_at`) with the key, |
| 440 | rev 3 §2.7's probe at most every 15 minutes. That endpoint is from |
| 441 | Vibe's source and undocumented. [V15] Probe V-P3 decides whether it is |
| 442 | used. If not, headroom is "not reported". |
| 443 | - **Billing:** a subscription only if Paul confirms pay-as-you-go is |
| 444 | off. Otherwise it is metered. |
| 445 | - **Families:** `mistral-large-4-0` and `mistral-medium-latest` are |
| 446 | `mistral`, and `zai-glm-5-3` is `glm`. [V6] |
| 447 | |
| 448 | ### 4.4 The capability matrix, added rows |
| 449 | |
| 450 | | Connection | Coordinator | Engineering | Review | Ask | Headroom | Billing | |
| 451 | |---|---|---|---|---|---|---| |
| 452 | | Pi → TensorX | No | Yes, after §3 acceptance | Yes | Yes | Not reported | Metered | |
| 453 | | Pi → Command Code Provider API | No | Yes, if CC-P1 | Yes | Yes | Not reported | Metered until §0 decision 2 | |
| 454 | | OpenCode → OpenCode Go | No | Yes | Yes | Yes | OC-P3, else not reported | Metered, unless a standing overflow-off setting is confirmed | |
| 455 | | Vibe → Mistral plan | No | Yes, if V-P2 | Yes, if V-P2 | Yes (`--resume`) | V-P3, else not reported | Subscription if pay-as-you-go is off, else metered | |
| 456 | | OpenCode → TensorX | No | only if Pi fails | as Pi | as Pi | as Pi | Metered | |
| 457 | |
| 458 | Mac cells are all "later". |
| 459 | |
| 460 | ## 5. Later, named so nothing is lost |
| 461 | |
| 462 | - **The metering gateway.** Its requirements, from Astra round 2: |
| 463 | - a strict request schema per provider, forcing the priced model, a |
| 464 | single completion and text-only input, rejecting unpriced features, |
| 465 | and bounding every billable component; |
| 466 | - a per-attempt socket bridge into the namespace, with fixed |
| 467 | connection and attempt authority, lifecycle and policy attestation; |
| 468 | - dialing the validated address without resolving again. |
| 469 | |
| 470 | It is the only route to a cap Equipo enforces, and to keeping the key |
| 471 | out of the namespace. |
| 472 | - Command Code's own CLI (over ACP, after host discovery). |
| 473 | - Mac srt profiles. |
| 474 | - Coordinator cells. |
| 475 | - Sign-in by link or device code for these providers. |
| 476 | - Model-pair routing and tiers (rev 3 slice 3). |
| 477 | - Step estimates (tokens, cost, duration), the "too big" outcome, and |
| 478 | calibration. |
| 479 | - The "cheap and short" rule, token-denominated budgets, OpenRouter and |
| 480 | local endpoints. |
| 481 | - Advice about buying or swapping accounts. |
| 482 | |
| 483 | # Part B: token-aware scheduling and advice |
| 484 | |
| 485 | ## 6. Facts |
| 486 | |
| 487 | **Connections:** `state`; `billing` (`subscription | metered`); the |
| 488 | windows as reported (`used` from 0 to 1, `minutes`, `resets_at`, |
| 489 | `checked_at`); and, for metered connections, the budget, the reported |
| 490 | spend, `spend_unknown` and whether a step is running. |
| 491 | |
| 492 | **Readings and their age (rev 3.2, ruling #7).** A Codex reading older |
| 493 | than 15 minutes is refreshed **before** `Decide` is called by the |
| 494 | app-server's `account/rateLimits/read`: no thread and no model turn, |
| 495 | run as the hourly refresh runs (the source home under its lock, the |
| 496 | same containment and egress), at most once per 15 minutes a |
| 497 | connection. Claude has no read without a model turn, so a **Claude |
| 498 | reading may be stale**: it is used as last reported, and a window past |
| 499 | its reset counts as not reported (§7). Every reading carries the time |
| 500 | the runner took it (`Headroom.checked_at`, protocol 15), and its age is |
| 501 | shown on the routing line of a step held for headroom and on the Usage |
| 502 | page's availability rows: "as of 2 h ago" for Codex, "as last reported |
| 503 | 2 h ago" for Claude. |
| 504 | |
| 505 | **Tasks:** |
| 506 | |
| 507 | - `priority` is `urgent`, `normal` or `low`, default `normal`. |
| 508 | - `by` is an optional date. |
| 509 | - The coordinator may set `low` or `normal`, and `by`, **only when it |
| 510 | creates the task**, from what Paul said. Every later change, and |
| 511 | every `urgent`, is Paul's tap. That keeps merge authority's rule: the |
| 512 | model can describe, never loosen. |
| 513 | - Values the coordinator set are labelled "set from your message". |
| 514 | |
| 515 | ## 7. `schedule.Decide` |
| 516 | |
| 517 | **Contract.** `Decide(in Input) Decision` is a pure function in |
| 518 | `internal/schedule`. Its input is a versioned, immutable struct: |
| 519 | |
| 520 | - the step: role, priority, `by`, `kept_session` (the connection whose |
| 521 | session it resumes, or none), `avoid`, and `release` (a Run now id, |
| 522 | or none); |
| 523 | - the person's connections on this runner, with the facts of §6 and |
| 524 | each one's capability for the role and family; |
| 525 | - the role's preference and its `until`; |
| 526 | - `now`. |
| 527 | |
| 528 | The output is `{run | hold, connection, reason, wake_at, needs_person}`. |
| 529 | The runner calls it at admission and writes the admission in one |
| 530 | `thin.db` transaction that rechecks the connections' row revisions it |
| 531 | read. If any changed, it calls `Decide` again. |
| 532 | |
| 533 | **What it claims.** Admission is decided from the readings taken at |
| 534 | admission. It does not predict or reserve a step's future consumption, |
| 535 | and several steps admitted against the same reading may together run a |
| 536 | window out. The reserve thresholds are the margin. A window that runs |
| 537 | out mid-step is rev 3's quota failover (termination proof, then another |
| 538 | connection), as today. A Claude reading may be stale (§6): Codex's are |
| 539 | refreshed without a turn, Claude's are as last reported. |
| 540 | |
| 541 | **Bars**, never overridden, Run now included: |
| 542 | |
| 543 | - the connection is usable (rev 3 §2.7); |
| 544 | - the Review family rule; |
| 545 | - not in `avoid`; |
| 546 | - for a metered connection: the task is `urgent` or the step carries a |
| 547 | release, no other step is running on it, spend is known, and the |
| 548 | reported spend is under both the day and the month budget. |
| 549 | |
| 550 | **Ask (round 3, finding 2)** never comes through `Decide` for its |
| 551 | choice: it stays on its step's exact session and connection (rev 3 §3). |
| 552 | On a metered connection, every question still passes the **metered |
| 553 | guard**: the slot, the day and month budget, and no `spend_unknown`, |
| 554 | all in the same admission transaction as a step. Consent is the |
| 555 | question itself, because Paul asking is his own action. A question the |
| 556 | guard refuses is held with the step's hold copy ("Waiting: TensorX has |
| 557 | reached today's budget"), never moved to another connection. |
| 558 | |
| 559 | **Thresholds.** A subscription connection **admits** a step at priority |
| 560 | `p` when every reported window has `used < t(p)`, where `t(low) = 0.60`, |
| 561 | `t(normal) = 0.80`, `t(urgent) = 1.0` (only "not limited"). A |
| 562 | A connection with no window reported admits when it is not limited, and |
| 563 | the routing row says "headroom not reported". A window whose |
| 564 | `resets_at` has passed with no newer reading counts as not reported, |
| 565 | never at its old figure. A release (Run now) gives the step the |
| 566 | **effective priority** `urgent` for thresholds and metered eligibility, |
| 567 | and the bars still apply. |
| 568 | |
| 569 | **Room, with a fixed precedence (finding 16).** Among subscription |
| 570 | connections that admit the step, the one with the most room is the |
| 571 | least by these keys, in order (round 3, finding 6): |
| 572 | |
| 573 | 1. connections with at least one reported window before those with |
| 574 | none; the rest of the keys apply only between two connections that |
| 575 | both have windows; |
| 576 | 2. the largest `used` among its reported windows (lower is more room); |
| 577 | 3. the `used` of its first window when its windows are sorted by |
| 578 | `minutes` ascending (missing `minutes` sorts last), then by name; |
| 579 | 4. the connection id, bytewise. |
| 580 | |
| 581 | Among metered connections, the most room is the least by: |
| 582 | |
| 583 | 1. the larger of day and month spend as a fraction of its budget; |
| 584 | 2. the connection id, bytewise. |
| 585 | |
| 586 | A subscription always ranks before a metered connection. A preference |
| 587 | for a metered connection does not change that: it orders metered |
| 588 | connections first among themselves, in rule 4. |
| 589 | |
| 590 | **Order of rules.** The first that yields a connection wins. |
| 591 | |
| 592 | 1. **Kept session (findings 15 and round 3, finding 4).** A step that |
| 593 | resumes a kept session (a fix round on its Engineering session) stays |
| 594 | on that connection, whatever the threshold, while it is usable. When |
| 595 | a **spending bar** blocks it (busy slot, budget, spend unknown), the |
| 596 | step is **held** on that connection, not moved. It switches only as |
| 597 | rev 3 allows: a quota or auth failure (the connection is then not |
| 598 | usable and is in `avoid`), Paul's explicit per-task "Run on …", or |
| 599 | **spending permission withdrawn** (rev 3.2, ruling #8): a kept |
| 600 | metered session whose step no longer has leave to spend (neither |
| 601 | `urgent` nor a release) starts afresh on a subscription rather than |
| 602 | being held on the metered connection. Reason `sticky`. |
| 603 | 2. **Preferred.** The role's preferred connection, if it admits the |
| 604 | step. Reason `preference`. |
| 605 | 3. **Subscription.** The subscription with the most room. Reason |
| 606 | `headroom`. |
| 607 | 4. **Metered.** The metered connection with the most room. Reason |
| 608 | `metered_urgent` or `metered_release`. |
| 609 | 5. **Hold.** Reason `headroom` (naming the admitting candidate whose |
| 610 | reset comes first), `budget`, `spend_unknown` or `no_connection`. |
| 611 | |
| 612 | Every attempt, failover included, is admitted through `Decide`, with |
| 613 | the failed connection in `avoid`. A consumed release becomes a durable |
| 614 | **grant** for `(step, step_revision)`. It covers every attempt of that |
| 615 | step revision, failover attempts included, and ends when the step ends. |
| 616 | A second admission for the same step revision is refused by a unique |
| 617 | key, so a replayed release cannot start another execution. |
| 618 | |
| 619 | **Wake-ups (round 3, finding 7).** `wake_at` is the earliest time |
| 620 | **strictly after `now`** among: |
| 621 | |
| 622 | - every future `resets_at` of every capable connection, limited ones |
| 623 | included; |
| 624 | - the next budget day or month boundary; |
| 625 | - the preference's `until`, while it is in the future (an expired |
| 626 | preference is cleared and treated as absent); |
| 627 | - `by` minus 24 h, unless the deadline check has already fired for |
| 628 | this step, which is recorded as `deadline_notified`. |
| 629 | |
| 630 | When none exists, `wake_at` is null and only a fact change wakes the |
| 631 | step. |
| 632 | |
| 633 | The runner persists it with the hold, re-runs `Decide` then, and also |
| 634 | on any reading, step end, budget change, preference change or release. |
| 635 | |
| 636 | **Release order.** `urgent`, then the earliest `by`, then `normal`, then |
| 637 | `low`, then the oldest, then the step id. A held step never blocks a |
| 638 | runnable step or a person's turn. Person turns are never held for |
| 639 | priority. |
| 640 | |
| 641 | **Housekeeping.** Its ledger, reservations and 0.8 stand-down stay as |
| 642 | built. Its turns and retries count as `low` for the threshold, so the |
| 643 | stricter rule wins, and it never uses a metered connection. |
| 644 | |
| 645 | **Invariants**, each a property test: |
| 646 | |
| 647 | - (a) no admission on a subscription with a reported, unexpired window |
| 648 | at or above `t(effective priority)`, except a kept session; |
| 649 | - (b) no metered admission without `urgent` or a release; |
| 650 | - (c) never two attempts (steps, questions or probes) holding one |
| 651 | metered connection's slot, and never a slot released before its |
| 652 | attempt's termination proof and charge; |
| 653 | - (d) no metered admission once the reported spend reaches the budget, |
| 654 | or while spend is unknown; |
| 655 | - (e) a hold only when rules 1 to 4 all fail; |
| 656 | - (f) the same input gives the same output. |
| 657 | |
| 658 | ## 8. Holds, Needs you, and Run now |
| 659 | |
| 660 | A held step reports `step {state: deferred, hold {reason, connection, |
| 661 | wake_at}}`, an optional extension of today's deferred report. The task |
| 662 | says one of: |
| 663 | |
| 664 | - "Waiting for headroom on Claude, resets Thu 10:00"; |
| 665 | - "Waiting for headroom on Claude" (no reset reported); |
| 666 | - "Waiting: TensorX has reached today's budget"; |
| 667 | - "Waiting: TensorX spend unknown, check it, then Resume". |
| 668 | |
| 669 | Each has **Run it now anyway**, except `budget` and `spend_unknown`, |
| 670 | which offer **Raise the budget** and **Resume**. |
| 671 | |
| 672 | **Needs you**, only where Paul's input changes the outcome: |
| 673 | |
| 674 | - the deadline check fires (`by` minus 24 h with the step still held); |
| 675 | - no reset in sight (no reset-based `wake_at`, or one more than 72 h |
| 676 | away); |
| 677 | - `no_connection` (today's card). |
| 678 | |
| 679 | The card asks with a recommendation, composed by the instance as merge |
| 680 | authority §4.1 does: "I'd wait: Claude resets Thu 10:00, before |
| 681 | Friday." **Wait** / **Run it now**. |
| 682 | |
| 683 | **Run now.** `POST /api/v1/tasks/{id}/run-now {step, step_revision}`, |
| 684 | from the task's owner only, writes a durable `release{id, task, step, |
| 685 | step_revision}`. The runner consumes it **atomically with the admission |
| 686 | it causes**. A release with a stale step revision, or one already |
| 687 | consumed, is acked and ignored. A release may use a metered connection |
| 688 | (§0 decision 5), and never passes a bar. |
| 689 | |
| 690 | ## 9. Advice |
| 691 | |
| 692 | `advice.Compute(facts, now) []Advice` is pure, on the instance. It runs |
| 693 | on fact changes and at 08:00 in the person's zone. The copy is fixed |
| 694 | templates with slots, so no model turn is involved. The coordinator can |
| 695 | read open advice through `status`, and cannot create, change or dismiss |
| 696 | it. Each recommendation is checked with the same capability, runner and |
| 697 | family rules as `Decide`. |
| 698 | |
| 699 | | Kind (arbitration order) | Fires when | Card | Actions | |
| 700 | |---|---|---|---| |
| 701 | | `budget_near` | a metered connection's reported spend passes 80% of a budget | "TensorX: $0.84 of today's $1." | **Raise today's budget** / **Leave it** | |
| 702 | | `prefer_switch` | the role's preferred subscription has a window at or above 0.80 with its reset more than 24 h away, another eligible subscription has every window below 0.50, and steps for the role are held or queued | "Claude is near its limit until Thu. Codex has room. Prefer Codex for Engineering until then?" | **Prefer Codex until Thu** / **Not now** | |
| 703 | | `defer_tasks` | `urgent` or `by` work is held on `headroom` while `normal` tasks without `by` are queued for the same role | "3 tasks could wait for Thu so the urgent one goes first. Let them wait?" | **Make them low priority** / **Not now** | |
| 704 | | `held_long` | a `low` task has been held for 7 days | "2 low-priority tasks have waited a week." | **Make them normal** / **Not now** | |
| 705 | |
| 706 | **Deterministic choice (finding 24).** Each advice has the key `(person, |
| 707 | kind, subject)`: |
| 708 | |
| 709 | - for `budget_near` and `prefer_switch`, the subject is the connection |
| 710 | id (for `prefer_switch`, the role then the target connection id); |
| 711 | - for `defer_tasks` and `held_long`, it is the sorted task ids. |
| 712 | |
| 713 | When several are eligible, the one shown is the least by: the kind's |
| 714 | arbitration order; then, within a kind, for connection subjects the |
| 715 | connection id bytewise, for roles the fixed order coordinator, |
| 716 | engineering, review, and for task sets the earliest task `created_at`, |
| 717 | then the first task id; then the key string bytewise. |
| 718 | |
| 719 | **Rules:** |
| 720 | |
| 721 | - At most one new card per person per day, and one open at a time. |
| 722 | - Not now silences a key for 14 days, and for 60 days after a second |
| 723 | Not now. |
| 724 | - Advice whose facts stop holding is withdrawn silently. |
| 725 | - Quiet hours are 22:00 to 08:00 (housekeeping's `VisibleAt`). |
| 726 | - Never Needs you, never a push. |
| 727 | - An action is the ordinary API call, revision-checked and recorded |
| 728 | with `source: advice` and the key. |
| 729 | |
| 730 | The `advice` table only moves forward. Cards show at the top of Usage |
| 731 | and as one quiet card in the conversation. |
| 732 | |
| 733 | ## 10. Wire, API and fixtures |
| 734 | |
| 735 | **`Connection`** gains `harness`, `upstream` (origin only), `billing`, |
| 736 | `model`, `limit_confirmed_at`, `payg_off_confirmed_at`, `budget`, |
| 737 | `spend {day, month, currency, unknown}` and `budget_pending`. |
| 738 | **`Dispatch`** gains `priority`, `by` and `release`. **Step reports** |
| 739 | gain `hold`. **`Headroom`** gains `checked_at` (rev 3.2, protocol 15; |
| 740 | dropped below it and from the runner's first hello). |
| 741 | |
| 742 | **Frames, instance to runner:** `budget` (durable, acked when applied), |
| 743 | `release` (durable, consumed once), `preference.until` (durable) and |
| 744 | `resume_spend{connection, pause_revision}` (durable, consumed once). |
| 745 | |
| 746 | **Routing reasons** gain `sticky`, `metered_urgent`, `metered_release` |
| 747 | and `held`. |
| 748 | |
| 749 | **API:** |
| 750 | |
| 751 | - `POST /api/v1/connections` gains `kind: api_key`, `sealed`, |
| 752 | `limit_confirmed` and `payg_off_confirmed`; |
| 753 | - `PUT /api/v1/connections/{id}/budget`; |
| 754 | - `POST /api/v1/connections/{id}/resume`; |
| 755 | - `PUT /api/v1/tasks/{id}/priority {priority, by, revision}`; |
| 756 | - `POST /api/v1/tasks/{id}/run-now`; |
| 757 | - `GET /api/v1/advice`; |
| 758 | - `POST /api/v1/advice/{id}/act`; |
| 759 | - `POST /api/v1/advice/{id}/dismiss`; |
| 760 | - `PUT /api/v1/preferences` gains `until`. |
| 761 | |
| 762 | `record_task` and `start_task` gain the optional `priority` (`low` or |
| 763 | `normal`) and `by`. The protocol is bumped, and an older runner is |
| 764 | refused metered connections rather than downgraded. |
| 765 | |
| 766 | **Fixtures:** `api/connection-metered.json`, `api/budget.json`, |
| 767 | `api/task-held.json`, `api/advice.json`; `frames/budget.json`, |
| 768 | `frames/release.json`, `frames/step-held.json`. The secret-field guard |
| 769 | covers every new type. |
| 770 | |
| 771 | ## 11. Slices |
| 772 | |
| 773 | Each slice runs headless first, then on staging with the real pinned |
| 774 | binary, then UI. Connector slices open with their probes, and a failed |
| 775 | probe turns a cell to No with the reason. **Sec** marks a slice that |
| 776 | needs its own Astra round on its branch. |
| 777 | |
| 778 | | # | Slice | Finish line | Sec | Size | |
| 779 | |---|---|---|---|---| |
| 780 | | S1 | Metered connections: `KindAPIKey` sealed paste, the limit and overflow confirmations, the selected-model probe, the egress table keyed by `(harness, provider)`, normalised components and price tables, the budget ledger, the durable slot and its restart recovery, spend unknown with bound Resume, the metered guard for questions, the spend line | With a fake harness: the attempt after the budget is crossed is held; a concurrent Engineering, Review and question race admits exactly one; a crash between exit and charge ends in `spend_unknown` before anything else is admitted; a stale Resume leaves a newer pause; a resent usage row charges once; an unpriced model gives spend unknown | **Sec** | 2.5 | |
| 781 | | S2 | Pi on TensorX: committed pins, isolated config, Equipo's extension, `fakepi`, RPC adapter, rev 3 P1 to P5, the §3 acceptance | A real Review step on TensorX GLM on staging, recorded `other_family`, with the hostile-repository fixture loading nothing | **Sec** | 3 | |
| 782 | | S3 | Scheduler: priority and `by`, `Decide`, holds, wake-ups, release order, Run now grants with replay refusal, the Needs you rules, `preference.until` | The six invariants pass as property tests; a `low` step holds at 0.61 and starts by itself after the reset; a replayed or stale release starts nothing; a failover attempt inside a grant is admitted; no wake-up is ever in the past | | 2.5 | |
| 783 | | S4 | Usage page (availability, spend, tokens) and the four advice kinds | From fixtures, each kind fires once, ties pick the same card on every run, and Not now silences it for 14 days | | 2 | |
| 784 | | S5 | OpenCode on Go: pins, isolated config, the in-namespace stdio bridge (unless OC-P2 finds a stdio mode), serve adapter, OC-P1, OC-P3 and OC-P4 | A real Engineering step on Go on staging, with its usage row; the bridge refuses a path outside its list | **Sec** | 3 | |
| 785 | | S6 | Vibe on the Mistral plan: PyPI pin, V-P2 and V-P3 | A real Vibe Review of a Claude step on staging | **Sec** | 2 | |
| 786 | | S7 | Command Code Provider API behind Pi, after CC-P1 | A real Review step through it | **Sec** | 0.5 | |
| 787 | |
| 788 | ## 12. Risks |
| 789 | |
| 790 | - **Claude readings may be stale (rev 3.2).** Claude reports headroom |
| 791 | only on a model turn, so its reading can be hours old when `Decide` |
| 792 | uses it. Codex readings are refreshed by `account/rateLimits/read`. |
| 793 | Each reading's age is shown, so a stale one is visible. |
| 794 | |
| 795 | - **A step can spend up to the provider's limit.** The key sits in the |
| 796 | namespace, and the soft budget is checked only between steps. This is |
| 797 | the trade Paul is asked to accept (§0 decision 3). The gateway (§5) is |
| 798 | the remedy. |
| 799 | - **Reported usage can be wrong or missing.** Wrong usage misleads the |
| 800 | soft budget. Missing usage pauses the connection. |
| 801 | - **OpenCode can under-count a turn (S5).** In a turn with several |
| 802 | requests, OpenCode reports a request without usage as zero, so the |
| 803 | turn's spend can be under-counted; Equipo cannot see this through ACP. |
| 804 | The Usage page says so for OpenCode's connections. The follow-up slice |
| 805 | reads the per-request rows from `OPENCODE_DB` after the attempt (§4.2). |
| 806 | - **OpenCode cannot see another model answering (S5b).** OpenCode's ACP |
| 807 | usage names no model of its own, so a provider answering with a |
| 808 | different model than the one fixed at launch is charged as the fixed |
| 809 | model and the mismatch is not detected (§16.5). Pi is unaffected. The |
| 810 | same follow-up slice, reading OpenCode's per-request rows from |
| 811 | `OPENCODE_DB` after the attempt, closes it. |
| 812 | - **The confirmations are Paul's word.** Equipo cannot check a provider |
| 813 | limit or a pay-as-you-go setting. |
| 814 | - **Thresholds are not predictions.** Concurrent steps can run a window |
| 815 | out. Failover is the backstop. |
| 816 | - **Undocumented surfaces:** Command Code's chat-completions route, Go's |
| 817 | allowance in events, Vibe's line schema and its budget read. Each is |
| 818 | a probe whose failure turns a cell to No or headroom to "not |
| 819 | reported". |
| 820 | - **Three more pinned trees** to keep current. Each bump re-runs that |
| 821 | connector's probes. |
| 822 | |
| 823 | ## 13. Not claimed |
| 824 | |
| 825 | - Equipo does not enforce a hard spend cap. |
| 826 | - It does not keep metered keys from a step's shell. |
| 827 | - It does not predict a step's consumption. |
| 828 | - It does not read provider headers or bodies. |
| 829 | |
| 830 | ## 14. Sources |
| 831 | |
| 832 | Read 2026-11-12. Facts from source code rather than docs are marked as |
| 833 | such in the text. |
| 834 | |
| 835 | - [CC1] https://registry.npmjs.org/command-code/latest, https://commandcode.ai/changelog |
| 836 | - [CC2] https://commandcode.ai/docs/headless |
| 837 | - [CC3] https://commandcode.ai/docs/quickstart, https://commandcode.ai/docs/settings |
| 838 | - [CC4] https://commandcode.ai/docs/resources/pricing-limits, https://commandcode.ai/docs/resources/usage-limits |
| 839 | - [CC5] https://commandcode.ai/docs/permissions, https://commandcode.ai/docs/resources/security |
| 840 | - [CC6] https://commandcode.ai/docs/provider, https://commandcode.ai/docs/troubleshooting/telemetry |
| 841 | - [CC7] https://commandcode.ai/docs/reference/cli/models |
| 842 | - [V1] https://github.com/mistralai/mistral-vibe |
| 843 | - [V2] https://pypi.org/pypi/mistral-vibe/3.1.2/json |
| 844 | - [V3] https://github.com/mistralai/mistral-vibe/blob/main/vibe/setup/auth/http_browser_sign_in_gateway.py (source) |
| 845 | - [V4] https://github.com/mistralai/mistral-vibe/blob/main/vibe/setup/auth/_oidc_config.py (source) |
| 846 | - [V5] https://docs.mistral.ai/vibe/code/cli/api-keys-profiles |
| 847 | - [V6] https://docs.mistral.ai/vibe/code/cli/configuration |
| 848 | - [V7] https://docs.mistral.ai/vibe/code/cli/configuration-reference |
| 849 | - [V8] https://docs.mistral.ai/vibe/code/safety-approvals-permissions |
| 850 | - [V9] https://github.com/mistralai/mistral-vibe/blob/main/vibe/core/telemetry/send.py, .../vibe/observability/sentry.py (source) |
| 851 | - [V10] https://github.com/mistralai/mistral-vibe/blob/main/docs/proxy-setup.md |
| 852 | - [V11] https://api.github.com/repos/mistralai/mistral-vibe/releases |
| 853 | - [V12] https://github.com/mistralai/mistral-vibe/blob/main/docs/programmatic-mode.md |
| 854 | - [V13] https://docs.mistral.ai/admin/billing-usage/subscriptions |
| 855 | - [V14] https://mistral.ai/pricing/ |
| 856 | - [V15] https://github.com/mistralai/mistral-vibe/blob/main/vibe/app_server/_billing.py (source) |
| 857 | - [V16] https://github.com/mistralai/mistral-vibe/blob/main/vibe/cli-rust/src/headless_output.rs (source) |
| 858 | - [P1] https://registry.npmjs.org/@earendil-works/pi-coding-agent/latest |
| 859 | - [P2] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/configuration.md |
| 860 | - [P3] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/models.md |
| 861 | - [P4] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/environment-variables.md, .../docs/settings.md |
| 862 | - [P5] https://pi.dev |
| 863 | - [P6] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/json.md |
| 864 | - [P7] https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/rpc.md, .../docs/rpc-commands.md |
| 865 | - [OC1] https://registry.npmjs.org/@opencode/cli/latest, https://registry.npmjs.org/opencode-ai/latest |
| 866 | - [OC2] https://opencode.ai/docs/console/go/ |
| 867 | - [OC3] https://opencode.ai/docs/providers/ |
| 868 | - [OC4] https://opencode.ai/docs/api, https://opencode.ai/docs/cli/ |
| 869 | - [OC5] https://opencode.ai/docs/cli/config/, https://opencode.ai/docs/troubleshooting/ |
| 870 | - [OC6] https://opencode.ai/docs/config/ |
| 871 | - [OC7] https://opencode.ai/docs/permissions/ |
| 872 | - [OC8] https://opencode.ai/docs/network/ |
| 873 | - [OC9] https://opencode.ai/docs/providers/ (custom provider package) |
| 874 | - [OC10] https://opencode.ai/docs/console/api/inference/ |
| 875 | - [OC11] https://opencode.ai/docs/console/models/ |
| 876 | - [OC12] https://opencode.ai/docs/console/billing/ |
| 877 | - [T1] https://docs.tensorx.ai/, https://tensorx.ai/ |
| 878 | - [T2] https://docs.tensorx.ai/api-reference/rate-limits.md |
| 879 | - [T3] https://docs.tensorx.ai/billing.md |
| 880 | - [T4] https://tensorx.ai/pricing/ |
| 881 | - [T5] https://github.com/anomalyco/models.dev/tree/dev/providers/tensorx |
| 882 | |
| 883 | ## 15. Astra rounds 1 and 2, folded in |
| 884 | |
| 885 | Round 1 (revision 1) and round 2 (revision 2) both said NOT READY. The |
| 886 | dispositions below are for revision 3. Round 2 counted items 2 to 6, 9 |
| 887 | to 13 and 20 to 23 resolved under the gateway. Those that depended on |
| 888 | the gateway are now cut or restated. |
| 889 | |
| 890 | | # | Finding, short | Revision 3 | |
| 891 | |---|---|---| |
| 892 | | 1 | No hard cap from post-response usage | Not claimed (§13): the provider's limit is the hard cap (§2.1), and Equipo's budget is soft (§2.3) | |
| 893 | | 2 | The key is reachable from the namespace | Stated (§2.1), and the acceptance asserts it (§3); remedy later (§5) | |
| 894 | | 3 to 6 | Reservation, crash, cap change, identity | The gateway ledger is gone. The soft budget is keyed by usage rows, changes apply on ack, and periods follow the row time (§2.3) | |
| 895 | | 7 | Overflow billing | Metered unless Paul confirms pay-as-you-go is off (§2.1, §4.2, §4.3) | |
| 896 | | 8 | Sign-in flows | Sealed paste only | |
| 897 | | 9 | Paths on allowed hosts | Vibe telemetry is off by config, under the policy check; OpenCode's catalogue on its own host is stated (§4) | |
| 898 | | 10, 11 | Pins, isolated config | §3, unchanged from revision 2 (resolved in round 2) | |
| 899 | | 12 | Run now replay | §8: revision-bound, consumed atomically, refused on replay (S3 finish line) | |
| 900 | | 13 | The coordinator relaxing priority | Creation only, never `urgent` (§6) | |
| 901 | | 14 | Unbuilt rev 3 slice 3 | One model per connection; new fields named in §10 and assigned to S1 and S3 | |
| 902 | | 15 | Switching boundaries | §7 rule 1: kept sessions stay, as rev 3 binds them | |
| 903 | | 16 | "Most room" undefined | §7: a fixed key precedence for subscriptions and for metered connections | |
| 904 | | 17 | Estimates | Cut (§5) | |
| 905 | | 18 | Calibration | Cut (§5) | |
| 906 | | 19 | A reading after the step starts | Removed: admission uses only the readings taken at admission, and claims nothing further (§7) | |
| 907 | | 20 | Invariants | §7: restated for the new rules | |
| 908 | | 21 to 23 | Wake-ups, starvation, housekeeping | §7: wake-ups kept; `too_big` cut with the estimates; `held_long` kept; housekeeping unchanged | |
| 909 | | 24 | Equal-kind ordering in advice | §9: subject ordering defined | |
| 910 | | 25 | Adversarial finish lines | §3 acceptance and §11 finish lines name the budget, replay and hostile-config cases | |
| 911 | | R2 Critical | The gateway does not bound request bodies | Gateway cut (§5), requirement recorded | |
| 912 | | R2 Important | No namespace transport for the gateway | Gateway cut (§5), requirement recorded | |
| 913 | |
| 914 | **Round 3 (revision 3): READY WITH CHANGES.** All ten Important |
| 915 | findings are folded into 3.1: |
| 916 | |
| 917 | | # | Finding, short | Revision 3.1 | |
| 918 | |---|---|---| |
| 919 | | 1 | No durable lifecycle for the one-step bound | §2.3: a durable slot for every attempt, released after the proof and the charge; restart reconciliation; S1 race and crash cases | |
| 920 | | 2 | Ask bypasses the budget | §7: questions pass the metered guard and are held, never moved | |
| 921 | | 3 | Resume not bound to its pause | §2.3: `pause_revision`, consumed once | |
| 922 | | 4 | Kept session and release lifetime | §7: a spending bar holds a kept session; a release becomes a grant for the step revision | |
| 923 | | 5 | Cost accounting underspecified | §2.3: normalised components, per-adapter aggregation, versioned price tables, unpriced means unknown | |
| 924 | | 6 | Comparator and invariant | §7: known before unknown first, window ordering defined, effective priority, metered preference | |
| 925 | | 7 | Wake-ups in the past | §7: strictly future, expired preferences cleared, `deadline_notified`, expired readings not reported | |
| 926 | | 8 | A zero balance is not a setting | §0 decision 7, §2.1, §4.2: Go stays metered without a standing overflow-off setting | |
| 927 | | 9 | No OpenCode control transport | §4.2: an in-namespace stdio bridge in the certified helper, unless OC-P2 finds a stdio mode | |
| 928 | | 10 | Model list is not a credential proof | §2.2: a one-token completion on the selected model, charged as a `probe` | |
| 929 | |
| 930 | The round 3 statuses it gave "NOT RESOLVED" for round 1 items (#4, |
| 931 | #7, #12, #15 to #17, #20, #21, #25) are these ten findings, and are |
| 932 | answered above. |
| 933 | |
| 934 | ## 16. Models chosen per step (revision 3.3) |
| 935 | |
| 936 | Paul, at the Connect TensorX model picker ("Pick the model this |
| 937 | connection uses. Another model needs another connection."): "Surely the |
| 938 | co-ordinator or some other process would choose the model too, no?" He |
| 939 | is right. This section supersedes §2.2's "one model per connection" and |
| 940 | the connect-time model pick. It is its own slice, S5b, built after S5 |
| 941 | and before Vibe. Everything else in revisions 3.1 and 3.2 stands. |
| 942 | |
| 943 | Astra's one round on the first draft (a0fc42a) said NOT READY, with ten |
| 944 | Important findings. This text answers them (§16.8). |
| 945 | |
| 946 | ### 16.1 A connection is a key and an allowed set |
| 947 | |
| 948 | - **The allowed set.** A metered connection is its key plus a set of |
| 949 | allowed models. These are a subset of the models the key lists |
| 950 | (`GET /v1/models`) that are both priced (§2.3) and tiered (§16.2). |
| 951 | - A listed model with no price or tier is shown greyed with "No price |
| 952 | yet", and cannot be allowed. |
| 953 | - On the add screen, every model that can be allowed is ticked by |
| 954 | default. Paul can untick any, but at least one must stay ticked. |
| 955 | - The connection row says "Models: 9 of 10" and opens the same list. |
| 956 | - **Connecting (supersedes §2.2's pick).** The connection becomes |
| 957 | `healthy` after the key is proven once. That proof is one charged |
| 958 | one-token completion on the cheapest allowed model, run at connect as |
| 959 | today. Every other allowed model starts `unprobed`. |
| 960 | - **Changing the set (finding 8).** A change is `PUT |
| 961 | /api/v1/connections/{id}/models {allowed[], revision}`: |
| 962 | - owner-only, with the actor taken from the session; |
| 963 | - the roster checked in the write transaction, and audited; |
| 964 | - delivered as a durable `models{connection, allowed[], revision}` |
| 965 | frame, which replaces S1's `model` frame. |
| 966 | |
| 967 | Revisions rise by one per change, and the runner refuses any revision |
| 968 | not above the one it holds. The runner applies the set in one |
| 969 | `thin.db` transaction, then acks. Until the ack the page shows the |
| 970 | pending set beside the applied one. `hello` and `sync` carry each |
| 971 | connection's applied revision, so a reconnect sends the frame again |
| 972 | if the runner is behind. |
| 973 | - **Removing a model.** A removed model is never admitted again. A step |
| 974 | already running on it finishes. |
| 975 | - **Older runners.** S5b takes protocol 18. A runner below it is refused |
| 976 | any change to the set. Its connections keep working with their one |
| 977 | model, exactly as before, and the page says the runner needs an |
| 978 | update to allow more models. |
| 979 | |
| 980 | ### 16.2 The model table (finding 10) |
| 981 | |
| 982 | The model table is committed beside the price table. It gives a |
| 983 | `family` and a `tier` (`strong`, `standard` or `cheap`) per `(provider, |
| 984 | model)`, under its own version. Version `tiers-2026-11-12`, Equipo's |
| 985 | judgement from TensorX's prices and the models' public descriptions, |
| 986 | for review with this spec: |
| 987 | |
| 988 | | Model | Family | Tier | |
| 989 | |---|---|---| |
| 990 | | `z-ai/glm-5.3` | glm | strong | |
| 991 | | `moonshotai/kimi-k3.1-pro` | kimi | strong | |
| 992 | | `moonshotai/kimi-k3` | kimi | strong | |
| 993 | | `deepseek/deepseek-v4-pro-0813` | deepseek | strong | |
| 994 | | `z-ai/glm-5.2` | glm | standard | |
| 995 | | `qwen/qwen3.8-27b` | qwen | standard | |
| 996 | | `deepseek/deepseek-v4.1-flash` | deepseek | standard | |
| 997 | | `z-ai/glm-5.3-flash` | glm | cheap | |
| 998 | | `deepseek/deepseek-v4-flash-0731` | deepseek | cheap | |
| 999 | | `minimax/minimax-m3.1-flash` | minimax | cheap | |
| 1000 | |
| 1001 | - **OpenCode Go.** Its priced models (S5's `opencode-go-2026-11-12` |
| 1002 | table) are tiered in the same table and version, judged the same way |
| 1003 | from Go's prices and the models' public descriptions; the assignments |
| 1004 | are listed in `S5B-MODELS-PROGRESS.md` for review. |
| 1005 | - **Where it lives.** The table is committed in the runner beside the |
| 1006 | price tables (`internal/runner/metered`), with its source date. The |
| 1007 | Usage page's source line names it beside the price date, so the |
| 1008 | tiers read as Equipo's own judgement. |
| 1009 | - **Versions.** The tier table is keyed by model id, separately from a |
| 1010 | connection's pinned price version. A model allowed under one table |
| 1011 | that has no entry in a newer one stops being eligible, and the row |
| 1012 | says "No price yet". |
| 1013 | - **Recording.** Every attempt records the model, family, tier, |
| 1014 | `price_version` and `tier_version` it ran under. |
| 1015 | - **Tests.** A test fails if a priced model has no tier, or a tiered |
| 1016 | model has no price, in the current versions. The Usage page's source |
| 1017 | line names both tables' dates. |
| 1018 | |
| 1019 | ### 16.3 One ordered choice over connection and model pairs (findings 4 and 6) |
| 1020 | |
| 1021 | `Decide` now ranks **pairs** of `(connection, model)` rather than |
| 1022 | connections. A subscription connection is one pair, with its own model |
| 1023 | as today. Each metered connection contributes one pair per eligible |
| 1024 | model. |
| 1025 | |
| 1026 | **Eligible models.** A model is eligible when it is allowed, its tier |
| 1027 | and price exist in the current tables, and it is not `unhealthy`. An |
| 1028 | `unprobed` model is eligible, and is probed on first use (§16.4). |
| 1029 | |
| 1030 | **The fill and the tier cap.** A connection's fill is the larger of |
| 1031 | reported spend ÷ budget for the day and for the month. The cap is |
| 1032 | `strong` below 0.5, `standard` below 0.8, and `cheap` at or above 0.8. |
| 1033 | |
| 1034 | **The model for a role on one connection.** `pickModel` takes the |
| 1035 | eligible models and picks: |
| 1036 | |
| 1037 | 1. the highest tier that is at or below the cap; |
| 1038 | 2. if no allowed model is at or below the cap, the **lowest** tier |
| 1039 | present. |
| 1040 | |
| 1041 | Within a tier, ties go to the lower output price, then the lower input |
| 1042 | price, then the model id, bytewise. This is monotone: a higher fill |
| 1043 | never yields a higher tier. |
| 1044 | |
| 1045 | **Choosing the pair.** The order of rules is §7's, applied to pairs: |
| 1046 | |
| 1047 | 1. **Kept session.** A step resuming a kept session uses that session's |
| 1048 | connection and model while both are usable, allowed and not |
| 1049 | `unhealthy`. A spending bar holds the step; it never moves (§7 |
| 1050 | rule 1, with ruling #8's switch for a withdrawn leave to spend). |
| 1051 | 2. **Preferred.** The role's preferred connection, with its |
| 1052 | `pickModel` model. |
| 1053 | 3. **Subscription.** As §7. |
| 1054 | 4. **Metered.** As §7, each metered connection with its `pickModel` |
| 1055 | model. |
| 1056 | |
| 1057 | **Review across families.** For Review, one more key comes before all |
| 1058 | of the order above: |
| 1059 | |
| 1060 | - Pairs whose family differs from the family Engineering's attempt |
| 1061 | recorded (§16.5) rank first. Those whose family matches rank second. |
| 1062 | - §7's order then applies within each group. That covers the kept |
| 1063 | session (never for Review), preference, subscription before metered, |
| 1064 | and room, and for Review it prefers a connection other than |
| 1065 | Engineering's at equal rank, as the scheduler does today. |
| 1066 | - The labels stay as built: `other_family`, `same_family` and |
| 1067 | `same_account`. |
| 1068 | |
| 1069 | For a metered connection, the family key takes the best other-family |
| 1070 | model under that connection's cap, with the same tie rule. So Review of |
| 1071 | a GLM step on TensorX runs Kimi or DeepSeek when one is allowed, and |
| 1072 | GLM only when nothing else is. |
| 1073 | |
| 1074 | **Questions (finding 5)** never go through the choice. A question |
| 1075 | resumes its step's session, on that session's model. If the model has |
| 1076 | since been removed or is `unhealthy`, the question fails with reason |
| 1077 | `model_unavailable` and the card "That model is no longer allowed on |
| 1078 | TensorX" or "That model is not answering". It never moves to another |
| 1079 | model or connection. A question with no kept session does not exist |
| 1080 | today, and is out of scope. |
| 1081 | |
| 1082 | **Probes** target the model the step chose (§16.4). At connect, the |
| 1083 | cheapest allowed model is probed (§16.1). |
| 1084 | |
| 1085 | ### 16.4 Probing a model on first use (findings 1, 2 and 3) |
| 1086 | |
| 1087 | - **Admission covers the probe.** When `Decide` picks an `unprobed` |
| 1088 | model, the step's admission is made as usual. That means: |
| 1089 | - leave to spend, from urgent or a Run now grant for the step |
| 1090 | revision; |
| 1091 | - the budget; |
| 1092 | - the slot. |
| 1093 | |
| 1094 | Before the step itself launches, the admitted attempt runs the probe |
| 1095 | as its own durable sub-attempt, `probe:<step>:<attempt>:<model>`, |
| 1096 | charged as role `probe`. The probe must be answered by that model. |
| 1097 | - **Then decide again.** When the probe settles (charged, or spend |
| 1098 | unknown), the slot is released and `Decide` runs again from fresh |
| 1099 | facts: budget, urgency, grant, allowed set and probe state. If the |
| 1100 | step is still admissible on that model, it launches under a new |
| 1101 | admission. If not (the budget is now reached, urgency withdrawn, or |
| 1102 | the model removed), it is held as §8 says. |
| 1103 | - **Run now.** A Run now grant covers the step revision's probes and |
| 1104 | its attempts, and ends with the step, as built. |
| 1105 | - **Failures:** |
| 1106 | - **Authentication** (401 or 403): connection-wide. The connection |
| 1107 | becomes `sign_in_again`, as today; no model is marked. |
| 1108 | - **Model not found, or answered by another model:** that model |
| 1109 | becomes `unhealthy`, with `failed_at` and the reason. `Decide` runs |
| 1110 | again without it. |
| 1111 | - **Spend unknown** (no usable usage): the connection pauses, as §2.3 |
| 1112 | says. Nothing else is probed until Paul taps Resume. |
| 1113 | - **Retries.** An `unhealthy` model becomes eligible again only on |
| 1114 | demand: |
| 1115 | - when Paul taps Check again, which probes each `unhealthy` allowed |
| 1116 | model under the normal budget bar, as Check again does today; |
| 1117 | - or when 24 hours have passed since `failed_at` and a step would pick |
| 1118 | it, in which case it is probed as on first use, under the same |
| 1119 | admission rules. |
| 1120 | |
| 1121 | No timer probes on its own. |
| 1122 | - **After a step fails.** A `healthy` model whose step fails with |
| 1123 | model-not-found becomes `unhealthy` the same way. |
| 1124 | |
| 1125 | ### 16.5 What is bound and recorded (findings 7 and 9) |
| 1126 | |
| 1127 | - **Attempts.** Every attempt records its model, family, tier, |
| 1128 | `price_version` and `tier_version` as immutable columns. |
| 1129 | - **Sessions.** Kept sessions record the model and family they were |
| 1130 | created on. Engineering's family for Review is read from Engineering's |
| 1131 | attempt record, never from the connection. |
| 1132 | - **Backfill.** Rows written before S5b are backfilled from the |
| 1133 | connection's one model, which was the only model it could run. A |
| 1134 | connection with no model selected gets no backfill, and its sessions |
| 1135 | (there are none) need none. |
| 1136 | - **Migration** of connections: |
| 1137 | - with a selected model: the allowed set is `{that model}`, with that |
| 1138 | model's probe state as it is; |
| 1139 | - with none selected yet: the allowed set is every model that can be |
| 1140 | allowed, all `unprobed`, and the connection state unchanged; |
| 1141 | - refused or unvalidated: unchanged, with an allowed set of the |
| 1142 | selected model if there is one, and no invented probe results or |
| 1143 | times. |
| 1144 | - **What Equipo guarantees about the model.** Equipo chooses the model, |
| 1145 | launches the harness with it, and checks that at launch: |
| 1146 | - **Pi:** `--model`, plus a `models.json` holding exactly that model, |
| 1147 | under the exact-config policy. |
| 1148 | - **OpenCode:** driven over `opencode acp` (S5's probe OC-P2), not |
| 1149 | an HTTP bridge. The exact-config policy pins the one provider and |
| 1150 | model in `opencode.json` and holds the launch's selection to it at |
| 1151 | attestation. The adapter checks the ACP session's model option is |
| 1152 | that model when the session is created or loaded and again before |
| 1153 | every prompt, never sends a request that sets a model or a config |
| 1154 | option, and refuses to go on (an identity failure) once OpenCode |
| 1155 | reports the model option changed. |
| 1156 | |
| 1157 | Equipo does not claim more. During an attempt, a harness's writable |
| 1158 | runtime configuration, or a step's shell holding the key (§2.1), |
| 1159 | could reach another model at the provider. So the usage rows record |
| 1160 | the model the provider reported. If that differs from the chosen |
| 1161 | model, the row is marked `model_mismatch` and charged at the reported |
| 1162 | model's price, or spend is unknown if that model is unpriced. |
| 1163 | `model_mismatch` makes the chosen model `unhealthy` for this |
| 1164 | connection until Check again. |
| 1165 | |
| 1166 | **OpenCode's gap (the controller's ruling on S5b's security round, |
| 1167 | finding 7).** Pi reports the model of each request, so the rule above |
| 1168 | holds for Pi. OpenCode's ACP usage carries no model of its own: a |
| 1169 | provider answering with another model than the one fixed at launch is |
| 1170 | charged as the fixed model, and the mismatch is not detected. This is |
| 1171 | accepted and stated (§12). The follow-up slice that closes it reads |
| 1172 | OpenCode's per-request rows from `OPENCODE_DB` after the attempt, |
| 1173 | which closes the under-count gap too (§4.2). |
| 1174 | |
| 1175 | ### 16.6 Invariants (property tests) |
| 1176 | |
| 1177 | - (a) The chosen model is allowed, priced, tiered and not unhealthy. |
| 1178 | Kept sessions are the exception: they use their own model under rule |
| 1179 | 1's conditions, which imply the same. |
| 1180 | - (b) For Review, a pair whose family differs from Engineering's |
| 1181 | recorded family is chosen whenever any eligible one exists on any |
| 1182 | eligible connection. |
| 1183 | - (c) At equal inputs except fill, a higher fill never yields a higher |
| 1184 | tier. |
| 1185 | - (d) A question uses its session's model or fails `model_unavailable`; |
| 1186 | it never runs on another model. |
| 1187 | - (e) The same input gives the same pair. |
| 1188 | - (f) No harness is launched with a model other than the chosen one. |
| 1189 | - (g) A probe never runs without the admission its step would need, and |
| 1190 | a step never launches on a model whose first-use probe has not |
| 1191 | settled healthy. |
| 1192 | |
| 1193 | ### 16.7 Slice S5b |
| 1194 | |
| 1195 | | # | Slice | Finish line | Sec | Size | |
| 1196 | |---|---|---|---|---| |
| 1197 | | S5b | Allowed sets and their protocol, migration and backfill, the tier table, `pickModel` and pairs in `Decide`, first-use probes inside admission, unhealthy models and their retries, `model_unavailable`, `model_mismatch`, the add screen and row, and the model shown on steps and Usage | With fakes: a first Engineering pass probes, then runs the strongest allowed model; at 0.8 fill the next pass runs a cheap one; Review of a GLM step runs Kimi; with Kimi and DeepSeek unticked, Review runs GLM labelled same family; a question whose model was unticked fails `model_unavailable`; a probe answered by another model marks it unhealthy and the step runs on the next pick; a migrated single-model connection behaves exactly as before; an older runner is refused a set change | **Sec** (it sets what is spent) | 2.5 | |
| 1198 | |
| 1199 | ### 16.8 Astra on the first draft, folded in |
| 1200 | |
| 1201 | | # | Finding, short | Here | |
| 1202 | |---|---|---| |
| 1203 | | 1 | Probe admission lifecycle | §16.4: a sub-attempt inside the step's admission; decide again after it settles; Run now grants cover probes | |
| 1204 | | 2 | Probe target and bootstrap | §16.1 connect-time proof on the cheapest model; §16.3 and §16.4 first-use probes target the chosen model; §2.2's pick superseded | |
| 1205 | | 3 | Retries and failure states | §16.4: `failed_at`, demand-driven retries, authentication connection-wide, spend unknown stops | |
| 1206 | | 4 | Review chose the connection first | §16.3: one ordered choice over pairs, family first for Review, labels kept | |
| 1207 | | 5 | Questions and removed models | §16.3, §16.6(d): `model_unavailable`, never moved | |
| 1208 | | 6 | Fallback broke monotonicity | §16.3: the lowest tier present, so the rule is monotone | |
| 1209 | | 7 | "Never chooses itself" overstated | §16.5: claims limited to choice and launch; `model_mismatch` recorded and charged | |
| 1210 | | 8 | The models protocol | §16.1: monotonic revisions, applied then acked, reconcile on reconnect, owner-only, older runners refused | |
| 1211 | | 9 | Session and migration identity | §16.5: immutable bindings, backfill, migration per connection state | |
| 1212 | | 10 | No actual tiers | §16.2: the initial table and its version rules | |
| 1213 | |