oficina / equipo Public

spec: §16 revised for Astra's models round (NOT READY, ten Important)

Astra's one round on the first §16 draft said NOT READY with ten
Important findings and no Critical. The revision answers each: one
ordered choice over connection and model pairs, first-use probes
inside the step's admission, a monotone tier rule, questions that fail
rather than move, the models protocol, immutable bindings, and an
initial tier table. Not built; awaiting the controller's call.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 7348f56e41a36e6ffee075ad623d783e2317757a parent a0fc42a
2 files changed, +261 −112
  • docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md +240 −112
  • docs/superpowers/specs/CODEX-FINDINGS-CONNECTORS-MODELS.md +21 −0

CI passed — run details

diff --git a/docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md b/docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md
index 62d55aca..110e1279 100644
--- a/docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md
+++ b/docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md
@@ -1,7 +1,9 @@
# Equipo connectors and token-aware scheduling
Status: **revision 3.3 proposed** (2026-11-12): §16, models chosen per
-step, on Paul's question at the TensorX model picker. Revision 3.2 below
+step, on Paul's question at the TensorX model picker. Astra's round on
+the first draft said NOT READY (ten Important); §16 is revised to
+answer them (§16.8) and awaits the controller's call. Revision 3.2 below
is approved and unchanged elsewhere, except that §2.2's "one model per
connection" is superseded by §16.
@@ -898,129 +900,255 @@ answered above.
Paul, at the Connect TensorX model picker ("Pick the model this
connection uses. Another model needs another connection."): "Surely the
co-ordinator or some other process would choose the model too, no?" He
-is right. This section replaces "one model per connection" (§2.2). It is
-its own slice, S5b, built after S5 and before Vibe. Everything else in
-revisions 3.1 and 3.2 stands.
+is right. This section supersedes §2.2's "one model per connection" and
+the connect-time model pick. It is its own slice, S5b, built after S5
+and before Vibe. Everything else in revisions 3.1 and 3.2 stands.
+
+Astra's one round on the first draft (a0fc42a) said NOT READY, with ten
+Important findings. This text answers them (§16.8).
### 16.1 A connection is a key and an allowed set
- **The allowed set.** A metered connection is its key plus a set of
- allowed models, a subset of the models the key lists (`GET /v1/models`)
- that are both priced (§2.3) and tiered (§16.2).
- - A listed model without a price or a tier is shown greyed with "No
- price yet" and cannot be allowed.
+ allowed models. These are a subset of the models the key lists
+ (`GET /v1/models`) that are both priced (§2.3) and tiered (§16.2).
+ - A listed model with no price or tier is shown greyed with "No price
+ yet", and cannot be allowed.
- On the add screen, every model that can be allowed is ticked by
- default, and Paul can untick any. At least one must stay ticked.
+ default. Paul can untick any, but at least one must stay ticked.
- The connection row says "Models: 9 of 10" and opens the same list.
-- **Changing the set.** A change is a revision-checked, owner-only call,
- audited, delivered to the runner as a durable `models{connection,
- allowed[], revision}` frame. It replaces S1's `model` frame and is
- applied on ack, as budgets are. A model removed from the set is never
- admitted again. A step already running on it finishes.
-- **Migration.** Every existing connection gets the allowed set `{its
- one model}`. Its probe status carries over.
-
-### 16.2 The model table
-
-A committed table beside the price table: per `(provider, model)`, a
-`family` (`glm`, `kimi`, `deepseek`, `qwen`, `minimax`, `mistral`, …)
-and a `tier` (`strong`, `standard` or `cheap`). It has its own version
-with a source and date, as `tensorx-2026-11-12` has. The Usage page's
-source line names both tables' dates.
-
-- A test fails if a priced model has no tier entry, or a tier entry has
- no price.
-- The tiers are Equipo's judgement, recorded in the table and changed by
- commit; no model output ever sets them.
-
-### 16.3 The choice, inside `Decide`
-
-`Decide` (§7) still picks the connection by its rules, unchanged. For a
-metered connection it then picks the model with a pure `pickModel`.
-Its inputs are:
-
-- the role;
-- the allowed set;
-- each model's tier, family, price and probe state;
-- the family Engineering actually used (for Review);
-- the connection's **fill**, the larger of reported spend ÷ budget for
- the day and for the month.
-
-The **tier cap** narrows as the fill grows: fill below 0.5 allows
-`strong`, below 0.8 `standard`, and at or above 0.8 `cheap` only. A
-model is **eligible** when it is allowed, not `unhealthy` (§16.4), and
-within the cap. When no model is within the cap, the cheapest allowed
-healthy model is eligible.
-
-- **Engineering, a first pass or a fix round without a kept session:**
- the eligible model with the highest tier. Ties go to the lower output
- price, then the model id, bytewise.
-- **Engineering, a fix round on a kept session:** the session's own
- model while it is still allowed and not unhealthy (§7 rule 1:
- sessions keep their binding). Otherwise the round starts afresh, with
- the rule above.
-- **Review:**
- 1. among eligible models whose family differs from the family
- Engineering actually ran, the same ordering as Engineering (label
- `other_family`);
- 2. if none is allowed, the same ordering over all eligible models
- (label `same_family`).
-
- This applies across connections too. `Decide`'s Review family rule
- now compares the recorded Engineering family with each
- `(connection, model)` pair's family, where it used to compare
- connections.
-- **Questions:** a question resumes its step's own session (rev 3 §3),
- so it uses that session's model and is never re-chosen. This is the
- one deliberate exception to "questions use the cheapest model": moving
- a question to another model would lose the session it asks about. A
- question with no kept session to resume (none exists today) would take
- the cheapest eligible model.
-- **Probes and housekeeping:** the cheapest eligible model (lowest
- output price, then input price, then id). Housekeeping still never
- uses a metered connection (§7), so in practice this rule covers
- probes.
-- **Recorded.** The chosen model, its tier, family and `price_version`
- are recorded on the step attempt and its usage rows. The routing line
- reads, for example, "Review on TensorX, kimi-k3.1-pro (other family)",
- and the Usage page shows the model.
-- **The model never chooses itself.** No tool, prompt or harness setting
- lets a model name or change the model it runs on. The harness is
- launched with the chosen model fixed (Pi `--model` and `models.json`
- with exactly that model, and the same for OpenCode), and the policy
- check refuses any other.
-
-### 16.4 Probing each model on first use
-
-- **First use.** A model with no probe record is probed before the
- first step that would run on it. The one-token completion (§2.2) runs
- through the connection's slot as its own attempt, is charged as role
- `probe`, and must be answered by that model.
-- **The cache.** The result is cached per `(connection, model)`:
- `healthy` with its time, or `unhealthy` with a reason. Unhealthy
- models are not eligible. A model is probed again on Check again, or
- when it was `unhealthy` more than 24 hours ago. A `healthy` model
- whose step fails with an authentication or model-not-found error
- becomes `unhealthy`.
-- **Accounting.** The probe is admitted by the same budget and leave-to-
- spend bars as the step it precedes. It runs only when the step itself
- would be admitted, and both are charged. If the probe fails, `Decide`
- runs again without that model.
-
-### 16.5 Invariants (property tests)
+- **Connecting (supersedes §2.2's pick).** The connection becomes
+ `healthy` after the key is proven once. That proof is one charged
+ one-token completion on the cheapest allowed model, run at connect as
+ today. Every other allowed model starts `unprobed`.
+- **Changing the set (finding 8).** A change is `PUT
+ /api/v1/connections/{id}/models {allowed[], revision}`:
+ - owner-only, with the actor taken from the session;
+ - the roster checked in the write transaction, and audited;
+ - delivered as a durable `models{connection, allowed[], revision}`
+ frame, which replaces S1's `model` frame.
+
+ Revisions rise by one per change, and the runner refuses any revision
+ not above the one it holds. The runner applies the set in one
+ `thin.db` transaction, then acks. Until the ack the page shows the
+ pending set beside the applied one. `hello` and `sync` carry each
+ connection's applied revision, so a reconnect sends the frame again
+ if the runner is behind.
+- **Removing a model.** A removed model is never admitted again. A step
+ already running on it finishes.
+- **Older runners.** A runner below the protocol S5b takes is refused
+ any change to the set. Its connections keep working with their one
+ model, exactly as before, and the page says the runner needs an
+ update to allow more models.
+
+### 16.2 The model table (finding 10)
+
+The model table is committed beside the price table. It gives a
+`family` and a `tier` (`strong`, `standard` or `cheap`) per `(provider,
+model)`, under its own version. Version `tiers-2026-11-12`, Equipo's
+judgement from TensorX's prices and the models' public descriptions,
+for review with this spec:
+
+| Model | Family | Tier |
+|---|---|---|
+| `z-ai/glm-5.3` | glm | strong |
+| `moonshotai/kimi-k3.1-pro` | kimi | strong |
+| `moonshotai/kimi-k3` | kimi | strong |
+| `deepseek/deepseek-v4-pro-0813` | deepseek | strong |
+| `z-ai/glm-5.2` | glm | standard |
+| `qwen/qwen3.8-27b` | qwen | standard |
+| `deepseek/deepseek-v4.1-flash` | deepseek | standard |
+| `z-ai/glm-5.3-flash` | glm | cheap |
+| `deepseek/deepseek-v4-flash-0731` | deepseek | cheap |
+| `minimax/minimax-m3.1-flash` | minimax | cheap |
+
+- **Versions.** The tier table is keyed by model id, separately from a
+ connection's pinned price version. A model allowed under one table
+ that has no entry in a newer one stops being eligible, and the row
+ says "No price yet".
+- **Recording.** Every attempt records the model, family, tier,
+ `price_version` and `tier_version` it ran under.
+- **Tests.** A test fails if a priced model has no tier, or a tiered
+ model has no price, in the current versions. The Usage page's source
+ line names both tables' dates.
+
+### 16.3 One ordered choice over connection and model pairs (findings 4 and 6)
+
+`Decide` now ranks **pairs** of `(connection, model)` rather than
+connections. A subscription connection is one pair, with its own model
+as today. Each metered connection contributes one pair per eligible
+model.
+
+**Eligible models.** A model is eligible when it is allowed, its tier
+and price exist in the current tables, and it is not `unhealthy`. An
+`unprobed` model is eligible, and is probed on first use (§16.4).
+
+**The fill and the tier cap.** A connection's fill is the larger of
+reported spend ÷ budget for the day and for the month. The cap is
+`strong` below 0.5, `standard` below 0.8, and `cheap` at or above 0.8.
+
+**The model for a role on one connection.** `pickModel` takes the
+eligible models and picks:
+
+1. the highest tier that is at or below the cap;
+2. if no allowed model is at or below the cap, the **lowest** tier
+ present.
+
+Within a tier, ties go to the lower output price, then the lower input
+price, then the model id, bytewise. This is monotone: a higher fill
+never yields a higher tier.
+
+**Choosing the pair.** The order of rules is §7's, applied to pairs:
+
+1. **Kept session.** A step resuming a kept session uses that session's
+ connection and model while both are usable, allowed and not
+ `unhealthy`. A spending bar holds the step; it never moves (§7
+ rule 1, with ruling #8's switch for a withdrawn leave to spend).
+2. **Preferred.** The role's preferred connection, with its
+ `pickModel` model.
+3. **Subscription.** As §7.
+4. **Metered.** As §7, each metered connection with its `pickModel`
+ model.
+
+**Review across families.** For Review, one more key comes before all
+of the order above:
+
+- Pairs whose family differs from the family Engineering's attempt
+ recorded (§16.5) rank first. Those whose family matches rank second.
+- §7's order then applies within each group. That covers the kept
+ session (never for Review), preference, subscription before metered,
+ and room, and for Review it prefers a connection other than
+ Engineering's at equal rank, as the scheduler does today.
+- The labels stay as built: `other_family`, `same_family` and
+ `same_account`.
+
+For a metered connection, the family key takes the best other-family
+model under that connection's cap, with the same tie rule. So Review of
+a GLM step on TensorX runs Kimi or DeepSeek when one is allowed, and
+GLM only when nothing else is.
+
+**Questions (finding 5)** never go through the choice. A question
+resumes its step's session, on that session's model. If the model has
+since been removed or is `unhealthy`, the question fails with reason
+`model_unavailable` and the card "That model is no longer allowed on
+TensorX" or "That model is not answering". It never moves to another
+model or connection. A question with no kept session does not exist
+today, and is out of scope.
+
+**Probes** target the model the step chose (§16.4). At connect, the
+cheapest allowed model is probed (§16.1).
+
+### 16.4 Probing a model on first use (findings 1, 2 and 3)
+
+- **Admission covers the probe.** When `Decide` picks an `unprobed`
+ model, the step's admission is made as usual. That means:
+ - leave to spend, from urgent or a Run now grant for the step
+ revision;
+ - the budget;
+ - the slot.
+
+ Before the step itself launches, the admitted attempt runs the probe
+ as its own durable sub-attempt, `probe:<step>:<attempt>:<model>`,
+ charged as role `probe`. The probe must be answered by that model.
+- **Then decide again.** When the probe settles (charged, or spend
+ unknown), the slot is released and `Decide` runs again from fresh
+ facts: budget, urgency, grant, allowed set and probe state. If the
+ step is still admissible on that model, it launches under a new
+ admission. If not (the budget is now reached, urgency withdrawn, or
+ the model removed), it is held as §8 says.
+- **Run now.** A Run now grant covers the step revision's probes and
+ its attempts, and ends with the step, as built.
+- **Failures:**
+ - **Authentication** (401 or 403): connection-wide. The connection
+ becomes `sign_in_again`, as today; no model is marked.
+ - **Model not found, or answered by another model:** that model
+ becomes `unhealthy`, with `failed_at` and the reason. `Decide` runs
+ again without it.
+ - **Spend unknown** (no usable usage): the connection pauses, as §2.3
+ says. Nothing else is probed until Paul taps Resume.
+- **Retries.** An `unhealthy` model becomes eligible again only on
+ demand:
+ - when Paul taps Check again, which probes each `unhealthy` allowed
+ model under the normal budget bar, as Check again does today;
+ - or when 24 hours have passed since `failed_at` and a step would pick
+ it, in which case it is probed as on first use, under the same
+ admission rules.
+
+ No timer probes on its own.
+- **After a step fails.** A `healthy` model whose step fails with
+ model-not-found becomes `unhealthy` the same way.
+
+### 16.5 What is bound and recorded (findings 7 and 9)
+
+- **Attempts.** Every attempt records its model, family, tier,
+ `price_version` and `tier_version` as immutable columns.
+- **Sessions.** Kept sessions record the model and family they were
+ created on. Engineering's family for Review is read from Engineering's
+ attempt record, never from the connection.
+- **Backfill.** Rows written before S5b are backfilled from the
+ connection's one model, which was the only model it could run. A
+ connection with no model selected gets no backfill, and its sessions
+ (there are none) need none.
+- **Migration** of connections:
+ - with a selected model: the allowed set is `{that model}`, with that
+ model's probe state as it is;
+ - with none selected yet: the allowed set is every model that can be
+ allowed, all `unprobed`, and the connection state unchanged;
+ - refused or unvalidated: unchanged, with an allowed set of the
+ selected model if there is one, and no invented probe results or
+ times.
+- **What Equipo guarantees about the model.** Equipo chooses the model,
+ launches the harness with it, and checks that at launch:
+ - **Pi:** `--model`, plus a `models.json` holding exactly that model,
+ under the exact-config policy.
+ - **OpenCode:** the adapter puts the model in the session-create and
+ prompt bodies, and the in-namespace bridge refuses a body naming
+ any other model.
+
+ Equipo does not claim more. During an attempt, a harness's writable
+ runtime configuration, or a step's shell holding the key (§2.1),
+ could reach another model at the provider. So the usage rows record
+ the model the provider reported. If that differs from the chosen
+ model, the row is marked `model_mismatch` and charged at the reported
+ model's price, or spend is unknown if that model is unpriced.
+ `model_mismatch` makes the chosen model `unhealthy` for this
+ connection until Check again.
+
+### 16.6 Invariants (property tests)
- (a) The chosen model is allowed, priced, tiered and not unhealthy.
-- (b) For Review, a different family is chosen whenever an eligible
- model of a different family is allowed on an eligible connection.
+ Kept sessions are the exception: they use their own model under rule
+ 1's conditions, which imply the same.
+- (b) For Review, a pair whose family differs from Engineering's
+ recorded family is chosen whenever any eligible one exists on any
+ eligible connection.
- (c) At equal inputs except fill, a higher fill never yields a higher
tier.
-- (d) A kept session keeps its model while it is allowed and healthy,
- and a question always uses its session's model.
-- (e) The same input gives the same model.
+- (d) A question uses its session's model or fails `model_unavailable`;
+ it never runs on another model.
+- (e) The same input gives the same pair.
- (f) No harness is launched with a model other than the chosen one.
+- (g) A probe never runs without the admission its step would need, and
+ a step never launches on a model whose first-use probe has not
+ settled healthy.
-### 16.6 Slice S5b
+### 16.7 Slice S5b
| # | Slice | Finish line | Sec | Size |
|---|---|---|---|---|
-| S5b | Allowed sets with migration, the model table, `pickModel` inside `Decide`, per-model probes and their cache, the `models` frame (next free protocol, with a downgrade step and frozen-schema tests), the add screen and row ("Models: 9 of 10"), and the model shown on steps and Usage | With fakes: a first Engineering pass on a fresh connection probes and then runs the strongest allowed model; at 0.8 fill the next pass runs a cheap one; Review of a GLM step runs Kimi; unticking Kimi makes Review run GLM labelled same family; a question stays on its session's model; a migrated single-model connection behaves exactly as before | **Sec** (it sets what is spent) | 2 |
+| 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 |
+
+### 16.8 Astra on the first draft, folded in
+
+| # | Finding, short | Here |
+|---|---|---|
+| 1 | Probe admission lifecycle | §16.4: a sub-attempt inside the step's admission; decide again after it settles; Run now grants cover probes |
+| 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 |
+| 3 | Retries and failure states | §16.4: `failed_at`, demand-driven retries, authentication connection-wide, spend unknown stops |
+| 4 | Review chose the connection first | §16.3: one ordered choice over pairs, family first for Review, labels kept |
+| 5 | Questions and removed models | §16.3, §16.6(d): `model_unavailable`, never moved |
+| 6 | Fallback broke monotonicity | §16.3: the lowest tier present, so the rule is monotone |
+| 7 | "Never chooses itself" overstated | §16.5: claims limited to choice and launch; `model_mismatch` recorded and charged |
+| 8 | The models protocol | §16.1: monotonic revisions, applied then acked, reconcile on reconnect, owner-only, older runners refused |
+| 9 | Session and migration identity | §16.5: immutable bindings, backfill, migration per connection state |
+| 10 | No actual tiers | §16.2: the initial table and its version rules |
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-CONNECTORS-MODELS.md b/docs/superpowers/specs/CODEX-FINDINGS-CONNECTORS-MODELS.md
new file mode 100644
index 00000000..157575d9
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-FINDINGS-CONNECTORS-MODELS.md
@@ -0,0 +1,21 @@
+VERDICT: NOT READY
+
+1. **Important — §16.4: Probe admission lacks a release lifecycle.** Existing probes use `Meter.Run`, which checks budget and slot but does not establish the scheduler’s spending grant. Specify atomic consumption of Run now into a grant covering prerequisite probes and the step, distinct durable attempt identities, and fresh admission after probe settlement so exhausted budgets, withdrawn urgency and changed allowed sets take effect.
+
+2. **Important — §16.3–16.4 and status: Probe target and bootstrap conflict.** “Probes … cheapest eligible” conflicts with probing the model selected for Engineering; unchanged §2.2 still requires a connect-time completion, and `scheduleFacts` excludes unvalidated connections. Define the initial connection state, whether connect-time probing remains, and require first-use probes to target the selected model; explicitly supersede the affected §2.2 rules.
+
+3. **Important — §16.4: Retry and failure states are incomplete.** Unhealthy models are ineligible, yet must be retried after 24 hours; no retry timestamp, eligibility transition, wake-up or Check again scope is defined. Specify demand-driven retries with renewed consent and budget checks, timestamp every failure, distinguish connection-wide authentication failures from model failures, and preserve `spend_unknown` as a stop rather than automatically probing another model.
+
+4. **Important — §16.3: Review cannot choose the connection first.** Choosing a connection unchanged and then choosing its model can miss another eligible connection’s different-family model, violating invariant (b); the existing scheduler also prefers another connection before Engineering’s own, and `reviewLabel` distinguishes `same_account`. Define one ordered selection over eligible connection/model pairs, including family precedence, subscription/preference ordering, connection ties and the retained independence labels.
+
+5. **Important — §16.1, §16.3, §16.5(a,d): Questions contradict model removal.** A question must always use its session’s model, but removing that model prohibits every new admission; an unhealthy session model creates the same conflict. Specify that such questions hold or fail without switching models, and qualify the invariants accordingly.
+
+6. **Important — §16.3, §16.5(c): The fallback breaks tier monotonicity.** With an expensive standard model and a cheaper strong model, fill 0.6 selects standard, while fill 0.8 can select strong through the cheapest-model fallback. Replace the fallback with a monotone rule or weaken the invariant explicitly, and define its ordering and behavior when only unprobed models remain.
+
+7. **Important — §16.3: “The model never chooses itself” overstates enforcement.** Pi’s launch policy fixes the initial model, but S2 deliberately leaves configuration writable during the attempt, and §2.1 permits Engineering’s shell to read the key and call the provider directly. Limit the guarantee to Equipo-controlled selection and launches, or specify additional enforcement; define OpenCode’s model binding through its actual session/prompt control path rather than “the same.”
+
+8. **Important — §16.1, §16.6: The models protocol is underspecified.** “Applied on ack” reverses the existing budget sequence, and merely requesting a downgrade step leaves unresolved what an older runner does with multiple models or a removed legacy model. Specify atomic runner application before acknowledgment, monotonic revisions, replay/reconnect reconciliation, pending versus applied sets, ownership binding and transactional roster checks; refuse unsupported changes where downgrade cannot preserve the restriction.
+
+9. **Important — §16.1, §16.3: Migration does not preserve session identity sufficiently.** Existing kept-session records bind the account/session without a dedicated model field, while `engineerOf` derives Engineering’s family from the current connection; both become unreliable once a connection supports several models. Specify immutable model/family bindings for sessions and attempts, backfill them from trustworthy historical data, and define migration for unselected, refused and unvalidated connections without inventing successful probes or timestamps.
+
+10. **Important — §16.2–16.3: The spending table and version rules remain undecided.** No actual tier assignments are supplied, and the new table’s relationship to connection-pinned price versions is unspecified; builders must decide which expensive models run and how upgrades change eligibility. Provide the initial assignments, compatible table-version rules and missing-entry behavior, and persist the tier-table version alongside the chosen model and price version.
\ No newline at end of file