| 1 | # S1 progress: metered connections |
| 2 | |
| 3 | Branch `connections-s1-metered` from main 1d7b4e41. Spec: |
| 4 | `docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md` |
| 5 | revision 3.1 (on `connections-slice2-design`, 629221f6), approved by Paul |
| 6 | as recommended, all eight decisions. Slice S1 (§11): §0 decisions 3, 4 |
| 7 | and 7, §2.1 to §2.3, the S1 parts of §3, §7's metered guard for Ask, and |
| 8 | §10's wire, API and fixtures for them. Builds on the Claude token |
| 9 | connection (2e5a6103 to 92105191) and Connections rev 3 §2.4. |
| 10 | |
| 11 | There is no real harness in S1: Pi arrives in S2. The metered provider is |
| 12 | TensorX (`https://api.tensorx.ai`, harness Pi) with a versioned price |
| 13 | table; tests use a fake harness (functions standing in for the S2 |
| 14 | adapter) and a fake OpenAI-compatible provider on 127.0.0.1. No real |
| 15 | provider, key or sign-in was used. |
| 16 | |
| 17 | ## Done |
| 18 | |
| 19 | 1. Wire (b5720ae5). Protocol 12, `ProtocolMetered`. `KindAPIKey` |
| 20 | (`api_key`), prompts `api_key` and `model` (`ConnectPrompt.models`), |
| 21 | billing `subscription | metered`, the provider table |
| 22 | `wire.APIKeyProviders` (TensorX: Pi, upstream, `/v1`, endpoint |
| 23 | `https://api.tensorx.ai:443`, per token, USD), the §2.1 rule |
| 24 | (`CheckConfirmations`, `Billing`), `Budget` and `Spend`. |
| 25 | `Connection` gains `harness`, `upstream`, `billing`, `model`, |
| 26 | `limit_confirmed_at`, `payg_off_confirmed_at`, `budget`, `spend`, |
| 27 | `budget_pending`; `Connect` gains `limit_confirmed`, |
| 28 | `payg_off_confirmed`, `budget`; `ConnectCommand` `billing`, `budget`; |
| 29 | `HeldConnection` the metered facts; `Usage` gains `cost_micros`, |
| 30 | `currency`, `price_version`, `cost_reported_micros`; `UsageReport` |
| 31 | gains `probe_id`. Frames (instance to runner, durable): `model`, |
| 32 | `budget` (acked when applied), `resume_spend`. Hold reasons `busy`, |
| 33 | `budget`, `spend_unknown` (also question reasons); connect reasons |
| 34 | `key_refused`, `no_priced_model`. All new fields are omitempty, so |
| 35 | every earlier fixture is byte-identical. Below 12, `Encode` drops |
| 36 | API-key connections from hello and sync and the cost fields from |
| 37 | usage rows, says a probe's usage as a check, and refuses the new |
| 38 | frames, an API-key connect and a held question's report: an older |
| 39 | runner is refused metered connections rather than downgraded. |
| 40 | Fixtures: `api/connection-metered.json`, `api/connection-choose-model.json`, |
| 41 | `api/connect-request-api-key.json`, `api/budget.json`, |
| 42 | `api/resume-request.json`, `api/model-request.json`, |
| 43 | `frames/budget.json`, `frames/model.json`, `frames/resume_spend.json`, |
| 44 | `frames/connect-api-key.json`, `frames/usage-probe.json`, |
| 45 | `frames/hello-metered.json`; the secret-field guard covers every new |
| 46 | type and fixture (the only allowance: `"kind":"api_key"`, a value). |
| 47 | |
| 48 | 2. Egress (0268db20). `egress.ProviderPolicy` and `Policy.Hash` read one |
| 49 | table keyed by `(harness, provider)`: `(claude, claude)`, |
| 50 | `(codex, codex)`, `(pi, tensorx)` to `api.tensorx.ai` only. |
| 51 | `NetworkContract` and `Policy` gain `Harness` (empty for a provider's |
| 52 | own CLI), so the Claude and Codex policy hashes are unchanged; a pair |
| 53 | that is not a row is refused. A test ties each API-key provider's row |
| 54 | to its upstream host. |
| 55 | |
| 56 | 3. The ledger (f0f18906), `internal/runner/metered`: |
| 57 | - price tables, versioned (`tensorx-2026-11-12`), in integer |
| 58 | micro-units per million tokens; usage normalised into |
| 59 | `uncached_input`, `cached_input`, `cache_write`, `output` and |
| 60 | `reasoning` (reasoning apart only where the table says so); each |
| 61 | part rounded up, 128-bit intermediate, overflow is unknown; an |
| 62 | unpriced model, an unpriceable component or an incomplete row is |
| 63 | unknown; the larger of the priced and the reported cost is charged |
| 64 | and both kept; |
| 65 | - thin.db tables `metered_connections`, `metered_slot` (one per |
| 66 | connection) and `budget_charge` keyed by the usage row's key |
| 67 | `(turn, step, attempt, connection, model)`; |
| 68 | - `Admit`: the slot free, spend known, reported spend under the day's |
| 69 | and the month's budget, claimed in the caller's transaction (a |
| 70 | question's start rides in it); `Charge` with the report in one |
| 71 | transaction; `Settle` only after the termination proof, releasing |
| 72 | the slot with the charge or with `spend_unknown` under a new |
| 73 | `pause_revision`; `Resume` consumed once and only for the current |
| 74 | pause; `ApplyBudget` above the revision held; |
| 75 | - `Meter.Run` is the entry a harness adapter (S2's Pi) calls; |
| 76 | `Meter.Recover` reconciles claimed slots at start-up (in `run.go`, |
| 77 | before the connector and the step engine start): namespace proven |
| 78 | gone, committed charges kept, otherwise `spend_unknown`, then the |
| 79 | slot released; one that cannot be proven stays held. Slots of |
| 80 | attempts running in this process are never touched; |
| 81 | `StepEngine.Probe` runs it again for ended, unproven ones. |
| 82 | |
| 83 | 4. The runner (956f2d59): |
| 84 | - API-key attempts reuse the token delivery (`Secret`, `keep`, the |
| 85 | staged and committed file, `seen_seals`, restart recovery), bound to |
| 86 | the provider's endpoint; the key lands 0600 in the connection's own |
| 87 | home under the accounts root (`tensorx-N`); |
| 88 | - the runner, outside any namespace, reads `GET /v1/models` with the |
| 89 | key (`connect.APIClient`), offers the models the price table knows |
| 90 | (prompt `model`), waits for the `model` frame, adds the connection |
| 91 | unvalidated, then runs the one-token probe |
| 92 | (`POST /v1/chat/completions`, `max_tokens: 1`) through `Meter.Run` |
| 93 | with role `probe`; its usage row is charged and sent in a usage |
| 94 | frame with `probe_id`; success validates the connection, a 401/403 |
| 95 | ends the attempt `key_refused`; |
| 96 | - Check again on a metered connection runs the probe again (through |
| 97 | the guard; a refused key reads `sign_in_again`); hello carries each |
| 98 | validated metered connection with its budget and spend; `budget` |
| 99 | and `resume_spend` frames apply in the transaction that records |
| 100 | their frame id; sign-out deletes the record, then the home, through |
| 101 | the durable cleanup; |
| 102 | - the metered guard for questions (`askmetered.go`): a question whose |
| 103 | kept session is on a metered connection is admitted through |
| 104 | `Meter.Admit` with its start in the same transaction; refused, it |
| 105 | is held (asks `hold`, `not_before`), reports `queued` with the hold |
| 106 | as its reason once per hold, is never moved, and is looked at again |
| 107 | on any change of a connection's standing (slot released, budget |
| 108 | applied, Resume) or, for the budget, at the next UTC day or month. |
| 109 | With no harness for it (S1), it fails `account_unavailable` without |
| 110 | claiming the slot. |
| 111 | |
| 112 | 5. The instance (79f4daad): `POST /api/v1/connections` with |
| 113 | `kind: api_key` (refused 422 without the limit confirmation, with a |
| 114 | pay-as-you-go confirmation on a per-token provider, without a budget |
| 115 | in bounds; 409 `runner_too_old` below protocol 12); the |
| 116 | confirmations kept with their time on the record; the box on |
| 117 | `POST /connections/{id}/secret` bound to the provider's endpoint; |
| 118 | `POST /connections/{id}/model`; `PUT /connections/{id}/budget` |
| 119 | (revision-checked, pending until the runner's ack); |
| 120 | `POST /connections/{id}/resume` (bound to the pause shown); hello's |
| 121 | metered facts recorded; usage rows keep their cost; a probe's row has |
| 122 | role `probe`; a held question keeps its hold as its reason. Migration |
| 123 | 0068 (additive). |
| 124 | |
| 125 | 6. The page (68cdc2f6): Add a connection offers TensorX with the |
| 126 | required confirmation, how TensorX limits a key (its billing docs), |
| 127 | what Equipo cannot see, and the budget pre-filled at 1 and 10; a |
| 128 | refusal says why. The key card seals in the page (connections.js, |
| 129 | `data-key-form`) for TensorX's origin; the model card lists the |
| 130 | runner's models. A metered row: model, the spend line ("$0.84 of $1 |
| 131 | today · $6.20 of $10 this month", "Reported by Pi. Spending can |
| 132 | exceed the budget by one step."), "Paused until tomorrow" / "Paused |
| 133 | until 1 Dec", "Paused: spend unknown. Check your spending at TensorX, |
| 134 | then choose Resume" with Resume, "Applies when |
| 135 | <runner> confirms", Change budget, Check again, Sign out. Metered |
| 136 | connections stay out of the coordinator lines and the preference. |
| 137 | |
| 138 | ## Tests |
| 139 | |
| 140 | - `internal/wire`: `TestEncodeBelowProtocol12DropsMetered` (mixed |
| 141 | versions: the new frames, an API-key connect and the metered fields |
| 142 | never reach an older peer), `TestMeteredConfirmations`, the secret |
| 143 | guards over the new types and fixtures, fixture round trips. |
| 144 | - `internal/runner/egress`: `TestEgressTableKeyedByHarnessAndProvider`. |
| 145 | - `internal/runner/metered`, with a fake harness, the S1 finish line: |
| 146 | (a) `TestMeteredBudgetHoldsTheNextAttempt`, (b) |
| 147 | `TestMeteredRaceAdmitsExactlyOne` (Engineering, Review and a question |
| 148 | race, eight rounds), (c) `TestMeteredCrashBeforeChargeIsSpendUnknown`, |
| 149 | (d) `TestMeteredStaleResumeLeavesTheNewerPause`, (e) |
| 150 | `TestMeteredResentUsageChargesOnce`, (f) |
| 151 | `TestMeteredUnpricedModelIsSpendUnknown`; `TestPricesNormalisedComponents`. |
| 152 | - `internal/runner/connect`: `TestAPIClientModelsAndProbe` (fake |
| 153 | provider on 127.0.0.1). |
| 154 | - `internal/runner/thin`: `TestAPIKeyConnectionRoundTrip` (sealed paste, |
| 155 | model list, probe charged as role probe, hello, Check again, a refused |
| 156 | key, budget frames, sign-out; the key in no frame or log line), |
| 157 | `TestAPIKeyBoxBoundToTheProvider`, `TestMeteredGuardHoldsQuestions`, |
| 158 | `TestMeteredQuestionWithNoHarness`. |
| 159 | - `internal/thintest`: `TestContractMeteredConnection` (an older runner |
| 160 | refused; confirmations, budget and provider refused without; the |
| 161 | sealed key's binding; the model pick; the probe row charged once when |
| 162 | resent; budget pending until the ack; Resume bound to its pause; the |
| 163 | page's add form, refusal, key and model cards, spend line, pending and |
| 164 | spend unknown; the key nowhere on the instance); |
| 165 | `TestPagesConnectionsAdd` now expects TensorX offered and two greyed. |
| 166 | - Local runs were targeted only (`-run`), plus gofmt, go vet (linux, |
| 167 | testbuild, darwin), staticcheck on the changed packages, `make |
| 168 | budget` and the dead-reference scan. |
| 169 | |
| 170 | ## Mutations, each observed failing |
| 171 | |
| 172 | - wire M1: downgradeMetered kept API-key connections in hello -> TestEncodeBelowProtocol12DropsMetered (hello at protocol 11) |
| 173 | - wire M2: meteredOnly refusal off -> TestEncodeBelowProtocol12DropsMetered (budget encoded at protocol 11) |
| 174 | - wire M3: api_key field on ResumeSpendCommand -> TestConnectionTypesCarryNoSecrets |
| 175 | - wire M4: CheckConfirmations ignores the limit -> TestMeteredConfirmations |
| 176 | - wire M5: probe usage not said as a check below 12 -> TestEncodeBelowProtocol12DropsMetered (usage at 11) |
| 177 | - egress E1: tensorx row allowed a second host -> TestEgressTableKeyedByHarnessAndProvider (tensorx through pi) |
| 178 | - egress E2: an empty harness taken as pi -> TestEgressPolicy, TestEgressPolicyFrozen, TestEgressTableKeyedByHarnessAndProvider (tensorx with no harness admitted) |
| 179 | - egress E3: harness always set on the policy -> TestEgressTableKeyedByHarnessAndProvider (claude policy hash changed) |
| 180 | - metered MM1: Admit ignored a held slot -> TestMeteredRaceAdmitsExactlyOne (round 4: two held, none ran: the claim overwrote; with the conditional UPDATE alone kept the race still admitted one, so the holder check is the guard and the conditional UPDATE is belt and braces) |
| 181 | - metered MM2: budget check disabled -> TestMeteredBudgetHoldsTheNextAttempt (after the budget: admitted, ran) |
| 182 | - metered MM3: Settle never pauses -> TestMeteredCrashBeforeChargeIsSpendUnknown, TestMeteredUnpricedModelIsSpendUnknown |
| 183 | - metered MM4: Resume not bound to pause_revision -> TestMeteredStaleResumeLeavesTheNewerPause (stale resume cleared) |
| 184 | - metered MM5: ledger without the usage key -> TestMeteredResentUsageChargesOnce (charged 700000, 4x) |
| 185 | - metered MM6: an unpriced model priced at zero -> TestMeteredUnpricedModelIsSpendUnknown |
| 186 | - metered MM7: Recover released a slot whose namespace was not proven gone -> TestMeteredCrashBeforeChargeIsSpendUnknown |
| 187 | - runner AK1: an API-key box accepted when bound to Claude's endpoint -> TestAPIKeyBoxBoundToTheProvider (the bad box was taken; the attempt waited for a model) |
| 188 | - runner AK2: the probe's usage not reported -> TestAPIKeyConnectionRoundTrip (probe usage []) |
| 189 | - runner AK3: unpriced models offered -> TestAPIKeyConnectionRoundTrip (offered [vendor/unpriced z-ai/glm-5.3]) |
| 190 | - runner AK5: a refused probe not recorded -> TestAPIKeyConnectionRoundTrip (no sign_in_again) |
| 191 | - runner Q1: a metered question sent down the Claude path -> TestMeteredGuardHoldsQuestions (a metered question went to the Claude path) |
| 192 | - runner Q2: holds not looked at again on a change -> TestMeteredGuardHoldsQuestions (q1 stayed queued busy) |
| 193 | - runner Q3: a refused question run anyway -> TestMeteredGuardHoldsQuestions (the slot is not this attempt's; answered while the probe held it) |
| 194 | - instance I1: confirmations not checked -> TestContractMeteredConnection (no limit confirmation accepted) |
| 195 | - instance I2: no protocol check -> TestContractMeteredConnection (a protocol 11 runner accepted) |
| 196 | - instance I3: the budget frame's ack not applied -> TestContractMeteredConnection (timed out waiting for the budget applied) |
| 197 | - instance I4: Resume not bound to the pause -> TestContractMeteredConnection (a stale resume accepted) |
| 198 | - instance I5: probe usage recorded as a check -> TestContractMeteredConnection (probe usage role check) |
| 199 | - page U1: the spend line dropped -> TestContractMeteredConnection (the row lacks the spend line) |
| 200 | - page U2: the add form taken as confirmed -> TestContractMeteredConnection (unconfirmed add went through) |
| 201 | |
| 202 | ## Decisions where the spec was open |
| 203 | |
| 204 | - Metered connections live in thin.db (`metered_connections`), not in |
| 205 | the bindings file: the bindings file is the certified launcher's |
| 206 | config and admits only Claude and Codex; S2 adds the Pi launch from |
| 207 | the metered record. |
| 208 | - The sealed key travels on `POST /connections/{id}/secret`, as the |
| 209 | token's does, not on `POST /connections` (§10 lists `sealed` there): |
| 210 | the box is bound to the connection's id, which does not exist before |
| 211 | the POST. |
| 212 | - The model pick needs a frame the spec does not name: `model` |
| 213 | (instance to runner, durable, refused below 12). |
| 214 | - The key is kept in the home under the token's file names |
| 215 | (`.oauth-token`, staged as the token is), so delivery and recovery are |
| 216 | one code path. |
| 217 | - The probe runs in the runner process (no namespace); a 401/403 is not |
| 218 | billed (nothing charged, no pause); any other failure after the |
| 219 | request (no answer, 5xx, no usage reported) is spend unknown. |
| 220 | - Normalisation: input or output not reported, or the row not complete, |
| 221 | is unknown; a cached or cache-write figure not reported counts as none. |
| 222 | TensorX's table: the 2026-11-12 published prices of ten models |
| 223 | (tensorx.ai/pricing, matching models.dev); cache writes unpriced (any |
| 224 | is unknown), reasoning part of output; to be checked before release. |
| 225 | - A connection keeps the price version it was made with. |
| 226 | - Budgets: UTC days and months; a day at most 1,000 and a month at most |
| 227 | 10,000 in the currency, day not above month; pre-filled 1 and 10. |
| 228 | - `budget_pending` is the person's budget revision above the highest |
| 229 | the runner applied (its frame's ack, or hello's revision), and is not |
| 230 | shown while connecting (the first budget rides the connect frame). |
| 231 | - A held question reports `queued` with the hold as its reason, once per |
| 232 | hold. A runner restart fails it `runner_restarted`, as it already does |
| 233 | for any question not yet started. |
| 234 | - In S1 no Engineering or Review step can be admitted to a metered |
| 235 | connection: `Conns.Mine` and `connect.Choose` stay Claude and Codex |
| 236 | (metered work is `urgent` or released, which is S3). `Meter.Run` is |
| 237 | the entry S2's adapter calls; the race test runs all three roles |
| 238 | through it. |
| 239 | - A restart in the middle of the connect probe that leaves the spend |
| 240 | unknown ends the attempt `provider_refused` (the unvalidated record |
| 241 | goes; its charge stays in the ledger). |
| 242 | - The slot's holder is `role|turn|step|attempt`. |
| 243 | - Pay-as-you-go off on a per-token provider is refused (422), not |
| 244 | ignored. The overflow rule is tested with a fake table row only. |
| 245 | |
| 246 | ## New copy keys (in the Plan 3 inventory; see the delegated review below) |
| 247 | |
| 248 | - `chat.connections.metered.title`: Connect %s |
| 249 | - `chat.connections.metered.key_sub`: An API key, billed per token. You set its spending limit at %s. |
| 250 | - `chat.connections.metered.limit_confirm`: This key has a spending limit at %s |
| 251 | - `chat.connections.metered.limit_how.tensorx`: At TensorX the limit is your prepaid balance: keys stop working below $0.05. Keep the balance at what you are willing to spend, and check that no automatic top-up is set. |
| 252 | - `chat.connections.metered.limit_docs`: How TensorX billing works |
| 253 | - `chat.connections.metered.cannot_see`: Equipo can’t see this limit. It is the only thing that stops spending for certain: Equipo’s own budget is checked between steps, and a step that is running can use this key up to the limit you set at %s. |
| 254 | - `chat.connections.metered.budget_legend`: Equipo’s budget for this key |
| 255 | - `chat.connections.metered.budget_day`: A day, in $ |
| 256 | - `chat.connections.metered.budget_month`: A month, in $ |
| 257 | - `chat.connections.metered.budget_note`: Equipo stops starting new steps when the reported spend reaches either figure. A step that is running finishes, so it can go over by one step. |
| 258 | - `chat.connections.metered.continue`: Continue |
| 259 | - `chat.connections.metered.confirm_first`: Confirm the spending limit and set a budget first. |
| 260 | - `chat.connections.metered.too_old`: Your runner needs an update before it can use a metered connection. |
| 261 | - `chat.connections.metered.key_paste`: Paste your %s API key |
| 262 | - `chat.connections.metered.key_bad`: That does not look like an API key. Paste it again. |
| 263 | - `chat.connections.metered.waiting_key`: Reading the models this key can use… |
| 264 | - `chat.connections.metered.model_pick`: Pick the model this connection uses. Another model needs another connection. |
| 265 | - `chat.connections.metered.model_use`: Use this model |
| 266 | - `chat.connections.metered.waiting_probe`: Trying the model with one token. It is charged to the budget. |
| 267 | - `chat.connections.metered.spend`: %s today of %s · %s this month of %s |
| 268 | - `chat.connections.metered.reported_by`: Reported by %s, can go over by one step |
| 269 | - `chat.connections.metered.paused_day`: Paused until tomorrow |
| 270 | - `chat.connections.metered.paused_month`: Paused until %s |
| 271 | - `chat.connections.metered.unknown`: Spend unknown: check %s, then Resume |
| 272 | - `chat.connections.metered.resume`: Resume |
| 273 | - `chat.connections.metered.pending`: Applies when %s confirms |
| 274 | - `chat.connections.metered.change_budget`: Change budget |
| 275 | - `chat.connections.reason.key_refused`: The provider refused the key: the balance may be empty, or the key was revoked. |
| 276 | - `chat.connections.reason.no_priced_model`: None of the models this key can use has a price Equipo knows, so it cannot keep a budget for it. |
| 277 | - `work.ask.held.busy`: Waiting: its connection is running another step |
| 278 | - `work.ask.held.budget`: Waiting: its connection has reached today’s budget |
| 279 | - `work.ask.held.spend_unknown`: Waiting: its connection’s spend is unknown. Check it, then Resume |
| 280 | - `chat.connections.metered.key_failed`: That did not go through. Paste the key again. |
| 281 | |
| 282 | ## Security round (Astra, read-only, on 789cb8d) |
| 283 | |
| 284 | Verdict NOT READY, nine findings, all mechanical; each fixed with a test |
| 285 | written first and a mutation observed: |
| 286 | |
| 287 | 1. Admission before registration (`meter.go`): `Meter.Admit` registers |
| 288 | the attempt as running before its admission commits, so `Recover` |
| 289 | never sees the claim without it. |
| 290 | `TestMeteredRecoverBetweenAdmissionAndLaunch` runs `Recover` in the |
| 291 | window after the commit. |
| 292 | 2. A repeated holder (`ledger.go`): a holder already claiming the slot |
| 293 | gets `Claimed` and a hold, never leave to launch; the Meter refuses a |
| 294 | holder already running in its process too. |
| 295 | `TestMeteredDuplicateHolderRunsOnce`. |
| 296 | 3. Sign-out during a probe (`apikey.go`): the sign-out retires the |
| 297 | connection (nothing more admitted), waits for the slot (proving an |
| 298 | ended attempt with `Recover`), so the probe's charge or spend_unknown |
| 299 | commits, and `metered.Remove` refuses while the slot is held. |
| 300 | `TestMeteredRetireWaitsForTheSlot`, `TestAPIKeySignOutDuringAProbe`. |
| 301 | 4. Frame binding (`apikey.go`, `ledger.go`): API-key homes take a random, |
| 302 | never reused name (`tensorx-<12 chars>`); the metered record keeps the |
| 303 | instance's connection id; Budget and Resume check the frame id first, |
| 304 | then the runner name, the connection id and the person, in one |
| 305 | transaction; the ledger's updates name the connection too. |
| 306 | `TestMeteredBindingNamesTheConnection`, `TestAPIKeyConnectionRoundTrip`. |
| 307 | 5. The probe's transport (`connect/apikey.go`): `connect.SafeClient`, no |
| 308 | ambient proxy, the host resolved once and every answer required to be |
| 309 | public (`egress.PublicAddress`, now exported), the connection made to |
| 310 | the resolved address, TLS verified for the host name, no redirect |
| 311 | followed, answers capped at 1 MiB. `TestAPIClientTransport`; the |
| 312 | runner's tests use the same transport with loopback allowed. |
| 313 | 6. The answering model (`connect/apikey.go`): the probe reads the model |
| 314 | the provider says answered; another model is `ErrModelMismatch`, no |
| 315 | proof, and the usage row is that model's (unpriced: spend unknown). |
| 316 | `TestAPIClientModelsAndProbe`, `TestAPIKeyProbeAnsweredByAnotherModel`. |
| 317 | 7. Downgrade (`wire/runners.go`): below 12 an API-key attempt's report |
| 318 | (its provider, the `api_key` and `model` prompts, `key_refused`, |
| 319 | `no_priced_model`) and a question with a hold reason are refused, not |
| 320 | translated. `TestEncodeBelowProtocol12AgainstFrozenSchemas` decodes |
| 321 | what is still sent into frozen pre-12 shapes and value sets. |
| 322 | 8. Authority (`chat/metered.go`): `TestMeteredWritesCheckPersonAndRoster` |
| 323 | (another person, and a roster check failing between authentication |
| 324 | and the write, change nothing) and the contract test's teammate and |
| 325 | removed-owner requests. |
| 326 | 9. Audit (`chat/metered.go`): `connection.budget` (id@revision), |
| 327 | `connection.resume` (id@pause) and `connection.limit_confirmed` / |
| 328 | `connection.payg_off_confirmed` (id@provider) are appended in the |
| 329 | write's transaction, credential-free. |
| 330 | |
| 331 | Mutations observed: |
| 332 | |
| 333 | - F1: the attempt registered as running only after its admission commits -> TestMeteredRecoverBetweenAdmissionAndLaunch (the slot was released between the admission and the launch) |
| 334 | - F2: the ledger let a claiming holder in again -> TestMeteredDuplicateHolderRunsOnce (a claimed holder admitted again); with the in-process reservation also off, the same holder ran twice |
| 335 | - F3: a retiring connection admitted with its slot free -> TestMeteredRetireWaitsForTheSlot; Remove with the slot held -> same test (removed with its slot held) |
| 336 | - F4: budget and Resume not bound to the connection -> TestMeteredBindingNamesTheConnection (another connection's budget applied; its resume consumed) |
| 337 | - F3 (runner): the sign-out deleted the record without waiting for the slot -> TestAPIKeySignOutDuringAProbe (removed while its probe ran); the sign-out without retiring -> same test (never retiring) |
| 338 | - F4 (runner): a consumed budget frame applied again -> TestAPIKeyConnectionRoundTrip (budget {4 4 rev 8}); API-key homes from nextHome -> same test (the runner name "tensorx-1" was reused); the runner's binding check alone off -> still held by the ledger's connection check (layered) |
| 339 | - F5: unsafe answers allowed -> TestAPIClientTransport (link-local dialed); the default transport -> same test; redirects followed -> same test; an ambient proxy -> same test |
| 340 | - F6: the answering model ignored by the check -> TestAPIClientModelsAndProbe and TestAPIKeyProbeAnsweredByAnotherModel (made a connection on another model's answer); the row priced under the selected model -> TestAPIKeyProbeAnsweredByAnotherModel (no spend unknown) |
| 341 | - F7: an API-key attempt's report sent below 12 -> TestEncodeBelowProtocol12AgainstFrozenSchemas (a pre-12 instance cannot read a tensorx report); the new reasons sent -> same test (no_priced_model); hold reasons on a failed answer sent -> same test (spend_unknown) |
| 342 | - F8: connections looked up without the person -> TestMeteredWritesCheckPersonAndRoster (another person's model) and TestContractMeteredConnection (a teammate's model pick: 409); the roster check left out of SetBudget -> TestMeteredWritesCheckPersonAndRoster (a removed person's budget) |
| 343 | - F9: the budget's or the Resume's audit left out -> TestMeteredWritesCheckPersonAndRoster (audits) |
| 344 | |
| 345 | ## Copy: delegated review (Astra, 2026-11-12) |
| 346 | |
| 347 | The 33 strings went through Astra as the copy-review gate (Paul's |
| 348 | delegation of 2026-10-25): 17 kept, 16 changed, applied verbatim, each |
| 349 | now `COPY ACCEPTED BY DELEGATION (Astra, 2026-11-12)` in `copy.go` and in |
| 350 | the Plan 3 inventory. The changes put Equipo in the first person ("I |
| 351 | can’t see this limit", "I stop starting new steps"), name the budget |
| 352 | fields ("Daily budget", "Monthly budget"), group each amount with its |
| 353 | budget on the spend line ("$0.84 of $1 today · $6.20 of $10 this |
| 354 | month"), say what can exceed what ("Spending can exceed the budget by |
| 355 | one step"), make the probe's charge plain ("This test costs money and |
| 356 | counts towards your budget"), say "Paused: spend unknown" with what to |
| 357 | check, and make the held-question lines cover a busy connection and |
| 358 | either budget. The list above shows the texts as first written; the |
| 359 | final texts are in `copy.go`. Tests that quote them updated. |
| 360 | |
| 361 | ## Open |
| 362 | |
| 363 | - No browser test of the key card's sealing in the page (S1's UI is |
| 364 | checked server-side and by the runner's own seal test); a `-tags |
| 365 | browser` test like the token card's is owed with the UI pass. |
| 366 | - The spec's spend line starts "TensorX:"; the row already names TensorX, |
| 367 | so the line starts at the figures. |
| 368 | - Staging and the real pinned harness are S2. |
| 369 | |