Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(model-hub): settle a 429 that names a plan or billing cause by that cause (#2758)
Call White7975e850e1e3
diff --git a/config/v2_config.py b/config/v2_config.pyindex aef9f846c..2de2cc94a 100644--- a/config/v2_config.py+++ b/config/v2_config.py@@ -2249,6 +2249,8 @@ class ModelHubSourceStateConfig:"models.source.needs_action.balance_exhausted","models.source.needs_action.credential_revoked","models.source.needs_action.account_banned",+ "models.source.needs_action.plan_excludes_product",+ "models.source.needs_action.spend_limit_reached",}if status in {"active", "standby"} and (retry_at is not None or detail_key is not None):raise ValueError(f"Config healthy source state '{status}' cannot carry blocker detail")diff --git a/core/handlers/model_hub/adapter.py b/core/handlers/model_hub/adapter.pyindex 7a375aefe..81ddde9eb 100644--- a/core/handlers/model_hub/adapter.py+++ b/core/handlers/model_hub/adapter.py@@ -1,4 +1,4 @@-"""Model Hub EngineAdapter interface. FINAL CONTRACT v15 (2026-10-15).+"""Model Hub EngineAdapter interface. FINAL CONTRACT v16 (2026-10-16).This file is the canonical adapter boundary and must remain byte-identical to``core/handlers/model_hub/adapter.py``. The adapter owns one-Source operations:diff --git a/core/handlers/model_hub/classification.py b/core/handlers/model_hub/classification.pyindex 68e560450..199311c37 100644--- a/core/handlers/model_hub/classification.py+++ b/core/handlers/model_hub/classification.py@@ -26,6 +26,8 @@ ResolutionReason = Literal["credential_revoked","balance_exhausted","account_banned",+ "plan_excludes_product",+ "spend_limit_reached","unclassified_error",]@@ -50,6 +52,8 @@ SOURCE_SETTLEMENT_AUTHORITY: Mapping[str, SourceSettlementRule] = {"credential_revoked": SourceSettlementRule("needs_action", 30),"balance_exhausted": SourceSettlementRule("needs_action", 30),"account_banned": SourceSettlementRule("needs_action", 30),+ "plan_excludes_product": SourceSettlementRule("needs_action", 30),+ "spend_limit_reached": SourceSettlementRule("needs_action", 30),}_SOURCE_STATE_PRIORITY = {"active": 0,@@ -129,6 +133,23 @@ _MACHINE_ERROR_TAXONOMY: Final[Mapping[str, _MachineErrorRule]] = {# the reset, which the engine client carries as retry advice."usage_limit_reached": _MachineErrorRule("transient", True, 80, "fallback", "quota_exhausted", None, 300, None),"billing_error": _MachineErrorRule("transient", True, 80, "fallback", "balance_exhausted", None, 0, None),+ # A plan that does not include the product: Codex's 429 for a ChatGPT plan+ # without it, which only an upgrade ends (openai/codex api_bridge.rs).+ "usage_not_included": _MachineErrorRule("transient", True, 85, "fallback", "plan_excludes_product", None, 0, None),+ # OpenAI's billing 429s name their cause in the code, beside a type that may+ # be the generic insufficient_quota, so they outrank it. Its error-code guide+ # says retrying restores none of them: only credit, or a raised spend or+ # usage limit, does, so none is a cooldown.+ "credit_balance_exhausted": _MachineErrorRule("transient", True, 85, "fallback", "balance_exhausted", None, 0, None),+ "organization_spend_limit_exceeded": _MachineErrorRule(+ "transient", True, 85, "fallback", "spend_limit_reached", None, 0, None+ ),+ "project_spend_limit_exceeded": _MachineErrorRule(+ "transient", True, 85, "fallback", "spend_limit_reached", None, 0, None+ ),+ "organization_usage_limit_exceeded": _MachineErrorRule(+ "transient", True, 85, "fallback", "spend_limit_reached", None, 0, None+ ),"overloaded": _MachineErrorRule("transient", True, 80, "fallback", "server_error", None, 30, None),"overloaded_error": _MachineErrorRule("transient", True, 80, "fallback", "server_error", None, 30, None),"server_error": _MachineErrorRule("server", True, 70, "fallback", "server_error", None, 30, None),diff --git a/core/handlers/model_hub/events.py b/core/handlers/model_hub/events.pyindex 25a59c96b..cbe09af6e 100644--- a/core/handlers/model_hub/events.py+++ b/core/handlers/model_hub/events.py@@ -55,6 +55,8 @@ EVENT_REASON_AUTHORITY: dict[str, ReasonClass] = {"credential_revoked": "non_self_healing","balance_exhausted": "non_self_healing","account_banned": "non_self_healing",+ "plan_excludes_product": "non_self_healing",+ "spend_limit_reached": "non_self_healing","unclassified_error": "non_self_healing","no_enabled_source": "structural","no_eligible_source": "structural",@@ -74,6 +76,8 @@ SOURCE_DETAIL_EVENT_REASONS = {"models.source.needs_action.credential_revoked": "credential_revoked","models.source.needs_action.balance_exhausted": "balance_exhausted","models.source.needs_action.account_banned": "account_banned",+ "models.source.needs_action.plan_excludes_product": "plan_excludes_product",+ "models.source.needs_action.spend_limit_reached": "spend_limit_reached","models.source.error.unclassified": "unclassified_error",}diff --git a/core/handlers/model_hub/provenance.py b/core/handlers/model_hub/provenance.pyindex 6552f0ff5..ba4998c65 100644--- a/core/handlers/model_hub/provenance.py+++ b/core/handlers/model_hub/provenance.py@@ -2713,7 +2713,7 @@ class TurnCorrelationRegistry:self.store.put({- "contract_version": 15,+ "contract_version": 16,"turn_id": normalized_turn_id,"ts": ts or _utc_now_iso(),"agent": trace.agent,diff --git a/core/handlers/model_hub/service.py b/core/handlers/model_hub/service.pyindex f17e19f33..65635c477 100644--- a/core/handlers/model_hub/service.py+++ b/core/handlers/model_hub/service.py@@ -247,7 +247,7 @@ from .usage import (local_usage_day,)-CONTRACT_VERSION = 15+CONTRACT_VERSION = 16def seeded_source_name(vendor: str) -> str:@@ -370,8 +370,8 @@ def _described_as_unfit_for_agent_turns(match: Mapping[str, Any]) -> bool:)-AGENT_CHAIN_CONTRACT_VERSION = 15-PROBE_RESULT_CONTRACT_VERSION = 15+AGENT_CHAIN_CONTRACT_VERSION = 16+PROBE_RESULT_CONTRACT_VERSION = 16_SOURCE_DISCOVERY_TIMEOUT_SECONDS = 15_SOURCE_PROBE_TIMEOUT_SECONDS = 60# Background inventory refresh. The first tick doubles as the startup delay, so@@ -1301,7 +1301,7 @@ def _runtime_payload(status: EngineStatus, *, enabled: bool) -> dict:manager = EngineRuntimeManager()return {- "contract_version": 15,+ "contract_version": 16,"enabled": enabled,"host_platform": status.host_platform or manager.host_platform(),"manifest": manager.contract_manifest(),@@ -8392,6 +8392,10 @@ class ModelHubService:return "models.source.needs_action.balance_exhausted", "balance_exhausted"if decision.reason == "account_banned":return "models.source.needs_action.account_banned", "account_banned"+ if decision.reason == "plan_excludes_product":+ return "models.source.needs_action.plan_excludes_product", "plan_excludes_product"+ if decision.reason == "spend_limit_reached":+ return "models.source.needs_action.spend_limit_reached", "spend_limit_reached"if outcome.http_status == 403:return "models.source.needs_action.credential_revoked", "credential_revoked"if decision.reason == "unclassified_error":@@ -9509,6 +9513,8 @@ class ModelHubService:"credential_revoked": "models.source.needs_action.credential_revoked","balance_exhausted": "models.source.needs_action.balance_exhausted","account_banned": "models.source.needs_action.account_banned",+ "plan_excludes_product": "models.source.needs_action.plan_excludes_product",+ "spend_limit_reached": "models.source.needs_action.spend_limit_reached","unclassified_error": "models.source.error.unclassified",}[event_reason]persisted = await self._write_source_blocker_locked(diff --git a/docs/plans/model-hub-contracts/README.md b/docs/plans/model-hub-contracts/README.mdindex d029bc341..7d1feab81 100644--- a/docs/plans/model-hub-contracts/README.md+++ b/docs/plans/model-hub-contracts/README.md@@ -1,6 +1,15 @@# Model Hub contracts-Status: **contract_version 15**, 2026-10-15: hosted tools design v2 (`../vibey-hosted-tools.md`), passive and+Status: **contract_version 16**, 2026-10-16: two non-self-healing Source causes,+`plan_excludes_product` (`models.source.needs_action.plan_excludes_product`), for a plan that does not include the+product, and `spend_limit_reached` (`models.source.needs_action.spend_limit_reached`), for an account past a spend or+usage limit only raising it lifts, join the resolution-event, provenance, Source, agent-chain and probe vocabularies,+and the mirror registry pairs them. The+terminal diagnostic's `upstream_error_code` gains `usage_not_included`, `credit_balance_exhausted`,+`organization_spend_limit_exceeded`, `project_spend_limit_exceeded` and `organization_usage_limit_exceeded`. Each+is a closed value a v15 consumer rejects.++It builds on v15 (2026-10-15): hosted tools design v2 (`../vibey-hosted-tools.md`), passive anddefault-on, with no probes. This bump publishes the Model Hub side; the hop-resolution and executor changes join itbefore it ships.- Capability evidence is passive (`capability-evidence.schema.json`, version 2): `basis` is `observed` only; a record is@@ -224,7 +233,7 @@ comparison. A gate may not report success by comparing stale input with itself.## Version closure-`contract_version` 15 must coexist in all registered version locations on the same tested head:+`contract_version` 16 must coexist in all registered version locations on the same tested head:- `mirror-registry.json`- `agent-chain.schema.json`diff --git a/docs/plans/model-hub-contracts/adapter-interface.py b/docs/plans/model-hub-contracts/adapter-interface.pyindex 7a375aefe..81ddde9eb 100644--- a/docs/plans/model-hub-contracts/adapter-interface.py+++ b/docs/plans/model-hub-contracts/adapter-interface.py@@ -1,4 +1,4 @@-"""Model Hub EngineAdapter interface. FINAL CONTRACT v15 (2026-10-15).+"""Model Hub EngineAdapter interface. FINAL CONTRACT v16 (2026-10-16).This file is the canonical adapter boundary and must remain byte-identical to``core/handlers/model_hub/adapter.py``. The adapter owns one-Source operations:diff --git a/docs/plans/model-hub-contracts/agent-chain.schema.json b/docs/plans/model-hub-contracts/agent-chain.schema.jsonindex 9a5d76004..4bd2a3a87 100644--- a/docs/plans/model-hub-contracts/agent-chain.schema.json+++ b/docs/plans/model-hub-contracts/agent-chain.schema.json@@ -7,7 +7,7 @@"required": ["contract_version", "backend", "model_id", "manual_override", "route_origin", "chain", "current", "supply_state"],"additionalProperties": false,"properties": {- "contract_version": { "const": 15 },+ "contract_version": { "const": 16 },"backend": { "enum": ["claude", "codex", "opencode", "vibey"] },"model_id": { "type": "string" },"manual_override": {@@ -87,6 +87,8 @@"models.source.needs_action.balance_exhausted","models.source.needs_action.credential_revoked","models.source.needs_action.account_banned",+ "models.source.needs_action.plan_excludes_product",+ "models.source.needs_action.spend_limit_reached","models.source.error.unclassified"]},@@ -253,7 +255,7 @@],"examples": [{- "contract_version": 15,+ "contract_version": 16,"backend": "codex","model_id": "unlisted-model","manual_override": null,@@ -263,7 +265,7 @@"supply_state": "ok"},{- "contract_version": 15,+ "contract_version": 16,"backend": "codex","model_id": "gpt-5.6","manual_override": null,@@ -273,7 +275,7 @@"supply_state": "ok"},{- "contract_version": 15,+ "contract_version": 16,"backend": "claude","model_id": "claude-opus-4-6","manual_override": null,@@ -283,7 +285,7 @@"supply_state": "waiting"},{- "contract_version": 15,+ "contract_version": 16,"backend": "opencode","model_id": "glm-5.2","manual_override": { "hops": [{ "source_id": "src_relay9c1x", "model_id": "glm-5.2" }] },@@ -293,7 +295,7 @@"supply_state": "waiting"},{- "contract_version": 15,+ "contract_version": 16,"backend": "codex","model_id": "gpt-5.6","manual_override": null,@@ -303,7 +305,7 @@"supply_state": "interrupted"},{- "contract_version": 15,+ "contract_version": 16,"backend": "codex","model_id": "gpt-5.6","manual_override": null,@@ -313,7 +315,7 @@"supply_state": "interrupted"},{- "contract_version": 15,+ "contract_version": 16,"backend": "claude","model_id": "claude-haiku-4-5","manual_override": null,diff --git a/docs/plans/model-hub-contracts/api-response.schema.json b/docs/plans/model-hub-contracts/api-response.schema.jsonindex c982ad52a..48e621771 100644--- a/docs/plans/model-hub-contracts/api-response.schema.json+++ b/docs/plans/model-hub-contracts/api-response.schema.json@@ -60,7 +60,7 @@"required": ["ok", "contract_version", "probe"],"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"probe": {"$ref": "model-hub/source-probe-result.schema.json"}}},@@ -159,7 +159,7 @@"SuccessCore": {"properties": {"ok": {"const": true},- "contract_version": {"const": 15}+ "contract_version": {"const": 16}}},"SourceListResponse": {@@ -168,7 +168,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"sources": {"type": "array", "items": {"$ref": "#/definitions/SourceApi"}}}},@@ -178,7 +178,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"observation": {"$ref": "model-hub/observation-result.schema.json"}}},@@ -188,7 +188,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"source": {"$ref": "#/definitions/SourceApi"},"added_to": {"type": "array", "items": {"$ref": "#/definitions/AddedTo"}},"adopted_by": {"type": "array", "items": {"$ref": "#/definitions/AdoptedBy"}, "uniqueItems": true}@@ -200,7 +200,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"source": {"$ref": "#/definitions/SourceApi"}}},@@ -210,7 +210,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"source": {"$ref": "#/definitions/SourceApi"},"removed_hops": {"type": "array", "items": {"$ref": "#/definitions/RouteHopRef"}},"interrupted": {"type": "array", "items": {"$ref": "#/definitions/SupplyGap"}}@@ -222,7 +222,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"removed_hops": {"type": "array", "items": {"$ref": "#/definitions/RouteHopRef"}},"interrupted": {"type": "array", "items": {"$ref": "#/definitions/SupplyGap"}}}@@ -233,7 +233,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"agents": {"type": "array", "items": {"$ref": "#/definitions/AgentSupplyApi"}}}},@@ -243,7 +243,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"agent": {"$ref": "#/definitions/AgentSupplyApi"}}},@@ -260,7 +260,7 @@],"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"agent": {"$ref": "#/definitions/AgentSupplyApi"},"removed_hops": {"type": "array", "items": {"$ref": "#/definitions/RouteHopRef"}, "uniqueItems": true},"interrupted": {"type": "array", "items": {"$ref": "#/definitions/SupplyGap"}, "uniqueItems": true}@@ -285,7 +285,7 @@"additionalProperties": false,"properties": {"ok": {"const": false},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"error": {"const": "candidate_suppliers_changed"},"detail": {"type": "string", "minLength": 1},"changed": {@@ -305,7 +305,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"agent": {"type": "object","required": ["backend", "mode", "catalog_models"],@@ -406,7 +406,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"candidates": {"type": "object","required": ["builtin", "providers", "in_list"],@@ -425,7 +425,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"matches": {"type": "array","maxItems": 8,@@ -459,7 +459,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"chain": {"$ref": "model-hub/agent-chain.schema.json"}}},@@ -469,7 +469,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"chains": {"type": "array", "items": {"$ref": "model-hub/agent-chain.schema.json"}}}},@@ -479,7 +479,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"chain": {"$ref": "model-hub/agent-chain.schema.json"},"removed_hops": {"type": "array", "items": {"$ref": "#/definitions/RouteHopRef"}},"interrupted": {"type": "array", "items": {"$ref": "#/definitions/SupplyGap"}}@@ -491,7 +491,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"probe": {"$ref": "model-hub/probe-result.schema.json"}}},@@ -501,7 +501,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"events": {"type": "array", "items": {"$ref": "model-hub/resolution-event.schema.json"}}}},@@ -511,7 +511,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"usage": {"$ref": "model-hub/usage-summary.schema.json"}}},@@ -521,7 +521,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"quota": {"$ref": "model-hub/quota-summary.schema.json"}}},@@ -531,7 +531,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"hosted_tools": {"$ref": "model-hub/hosted-tools-status.schema.json"}}},@@ -541,7 +541,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"flow": {"allOf": [{"$ref": "model-hub/oauth-flow.schema.json"},@@ -563,7 +563,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"flow": {"allOf": [{"$ref": "model-hub/oauth-flow.schema.json"},@@ -586,7 +586,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"flow": {"allOf": [{"$ref": "model-hub/oauth-flow.schema.json"},@@ -611,7 +611,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15}+ "contract_version": {"const": 16}}},"RuntimeApi": {@@ -633,7 +633,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"scan": {"$ref": "model-hub/migration-scan.schema.json"}}},@@ -643,7 +643,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"applied": {"type": "integer", "minimum": 0},"sources": {"type": "array", "items": {"$ref": "#/definitions/SourceApi"}},"added_to": {"type": "array", "items": {"$ref": "#/definitions/AddedTo"}}@@ -655,7 +655,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"provenance": {"$ref": "model-hub/turn-provenance.schema.json"}}},@@ -666,7 +666,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"provenance": {"anyOf": [{"$ref": "model-hub/turn-provenance.schema.json"},@@ -681,7 +681,7 @@"additionalProperties": false,"properties": {"ok": {"const": true},- "contract_version": {"const": 15},+ "contract_version": {"const": 16},"runtime": {"$ref": "#/definitions/RuntimeApi"}}}diff --git a/docs/plans/model-hub-contracts/api.md b/docs/plans/model-hub-contracts/api.mdindex 0c0324595..17a9f8b24 100644--- a/docs/plans/model-hub-contracts/api.md+++ b/docs/plans/model-hub-contracts/api.md@@ -8,11 +8,11 @@ credential redaction and supply-impact confirmation rules still apply; unknownAPI siblings retain the Owner default.-Status: **Normative, `contract_version` 15** — Model Hub implementations must conform, and the response conformance guard enumerates this route table and validates one real server response for every route.+Status: **Normative, `contract_version` 16** — Model Hub implementations must conform, and the response conformance guard enumerates this route table and validates one real server response for every route.-Success envelope: `{ok: true, contract_version: 15, ...}`.+Success envelope: `{ok: true, contract_version: 16, ...}`.Failure envelope:-`{ok: false, contract_version: 15, error: <machine_code>, detail?: <i18n_key>}`.+`{ok: false, contract_version: 16, error: <machine_code>, detail?: <i18n_key>}`.`detail` is always a string. Structured error data lives in a named sibling.Guarded mutation refusals specialize that envelope through`guard-refusal.schema.json`; both report arrays are required and together form the plan@@ -24,7 +24,7 @@ table. The contract guard requires the two endpoint sets to be identical, requirexercised HTTP response for every registry entry, and validates that response againstthe route's named schema.-The shared envelope and every versioned nested contract carry `contract_version` 15, the+The shared envelope and every versioned nested contract carry `contract_version` 16, theterminal value. Supported persisted config shapes and historical TurnProvenanceremain readable; ephemeral envelopes use only the terminal version.@@ -82,7 +82,7 @@ runtime open. Once models are configured it participates in the runtime Stop gua| POST `/api/models/migration/scan` | → `{scan: MigrationScan}` | Read-only. || POST `/api/models/migration/apply` | `{item_ids: string[], clean_api_keys?: boolean}` → `{applied, sources, added_to}` | Applies one grouped, server-owned custody transaction. It checks saved configuration and custody locally, copies API keys without upstream validation, upgrades an existing native subscription Source in place when present, and commits Source/Routes/backend mode atomically. API-key originals are kept unless cleanup was selected. Pre-exposure failure is reversible; post-exposure recovery is forward-only and keeps the backend blocked until terminalized. || GET `/api/models/turns/<turn_id>/provenance` | → `{provenance: TurnProvenance}` or documented absence error | Debug read for exactly attributed Hub turns. |-| GET `/api/models/runtime/status` | → `{runtime: RuntimeDependency}` | Read-only managed engine status. The nested object carries `contract_version` 15 and persisted user intent in `enabled`; `not_started` is installed lazy-start idleness, not an alarm. |+| GET `/api/models/runtime/status` | → `{runtime: RuntimeDependency}` | Read-only managed engine status. The nested object carries `contract_version` 16 and persisted user intent in `enabled`; `not_started` is installed lazy-start idleness, not an alarm. || POST `/api/models/runtime/install` | → `{runtime: RuntimeDependency}` | Idempotently starts server-owned installation. It returns and persists `installing`; reload reads the same state. Uses the existing mutation authentication and CSRF guards. || POST `/api/models/runtime/start` | → `{runtime: RuntimeDependency}` | Persists `enabled: true` and explicitly starts the managed engine. Service startup restores this intent; runtime availability has no separate enable-confirmation step. Uses the existing mutation authentication and CSRF guards; status reads never start it. || POST `/api/models/runtime/stop` | → `{runtime: RuntimeDependency}` | Explicitly stops the managed engine, persists `enabled: false`, and returns it to `not_started`. The mutation is rejected with `runtime_in_use` while any native backend is configured for Hub mode or Avibe has catalog models, so disabling the shared runtime cannot strand a configured route. An empty Avibe catalog does not keep the runtime open. |@@ -640,7 +640,7 @@ The terminal result of both ordinary API-key creation and OAuth creation is:```json{"ok": true,- "contract_version": 15,+ "contract_version": 16,"source": {"id": "src_anthkey01","kind": "api_key",@@ -750,7 +750,7 @@ Every guarded Source/inventory mutation uses the §4.5 envelope matrix and the c```json{"ok": false,- "contract_version": 15,+ "contract_version": 16,"error": "source_last_supplier","would_remove_hops": [],"would_interrupt": [@@ -886,7 +886,7 @@ API-key success:```json{"ok": true,- "contract_version": 15,+ "contract_version": 16,"source": {"id": "src_relay9c1x","kind": "api_key",@@ -977,7 +977,7 @@ Status and submit return the same terminal shape:```json{"ok": true,- "contract_version": 15,+ "contract_version": 16,"flow": {"flow_id": "oaf_claude01","client_nonce": "ofn_01j5w8z7p4n6q2rt",@@ -1050,9 +1050,9 @@ a valid `interrupted` chain.```json{"ok": true,- "contract_version": 15,+ "contract_version": 16,"chain": {- "contract_version": 15,+ "contract_version": 16,"backend": "codex","model_id": "gpt-5.6","manual_override": null,@@ -1079,7 +1079,7 @@ In Direct mode both chain and probe refuse with:```json{"ok": false,- "contract_version": 15,+ "contract_version": 16,"error": "direct_mode","detail": "models.hub.direct_mode"}@@ -1093,9 +1093,9 @@ A successful probe nests its result:```json{"ok": true,- "contract_version": 15,+ "contract_version": 16,"probe": {- "contract_version": 15,+ "contract_version": 16,"backend": "claude","channel": "hub","reachable": false,@@ -1118,7 +1118,7 @@ not-ready carries the closed i18n key `models.probe.native_cli_unavailable`.```json{- "contract_version": 15,+ "contract_version": 16,"backend": "codex","channel": "native_cli","reachable": true,@@ -1131,7 +1131,7 @@ not-ready carries the closed i18n key `models.probe.native_cli_unavailable`.```json{- "contract_version": 15,+ "contract_version": 16,"backend": "codex","channel": "native_cli","reachable": false,@@ -1147,7 +1147,7 @@ No candidate is an API error with a typed model-scoped state:```json{"ok": false,- "contract_version": 15,+ "contract_version": 16,"error": "probe_no_candidate","detail": "models.probe.no_candidate.waiting","supply": {@@ -1338,7 +1338,7 @@ The store retains at most 500 exactly attributed settled turns with its existingwrites. Ambiguous attribution remains excluded; this is not a log of every upstreamrequest. Null means no matching retained record, including eviction. A newer served,canceled or other record without a terminal error supersedes older error display.-Success uses exactly `{ok: true, contract_version: 15, provenance: TurnProvenance | null}`;+Success uses exactly `{ok: true, contract_version: 16, provenance: TurnProvenance | null}`;there is no `success` field or envelope exception.Local `engine_down` records may also contain `local_error_detail`, an OS-generated@@ -1432,7 +1432,7 @@ ambiguous absence are explicit and distinguishable from an unknown turn:```json{"ok": false,- "contract_version": 15,+ "contract_version": 16,"error": "provenance_unavailable","detail": "models.provenance.direct_mode"}@@ -1441,7 +1441,7 @@ ambiguous absence are explicit and distinguishable from an unknown turn:```json{"ok": false,- "contract_version": 15,+ "contract_version": 16,"error": "provenance_unavailable","detail": "models.provenance.attribution_ambiguous"}diff --git a/docs/plans/model-hub-contracts/guard-refusal.schema.json b/docs/plans/model-hub-contracts/guard-refusal.schema.jsonindex c58a8e6aa..8ca74e059 100644--- a/docs/plans/model-hub-contracts/guard-refusal.schema.json+++ b/docs/plans/model-hub-contracts/guard-refusal.schema.json@@ -61,7 +61,7 @@],"properties": {"ok": { "const": false },- "contract_version": { "const": 15 },+ "contract_version": { "const": 16 },"error": {"enum": ["source_last_supplier",@@ -116,7 +116,7 @@"examples": [{"ok": false,- "contract_version": 15,+ "contract_version": 16,"error": "source_model_in_route_chain","detail": "modelHub.errors.source_model_in_route_chain","would_remove_hops": [diff --git a/docs/plans/model-hub-contracts/mirror-registry.json b/docs/plans/model-hub-contracts/mirror-registry.jsonindex d9605d702..29571f446 100644--- a/docs/plans/model-hub-contracts/mirror-registry.json+++ b/docs/plans/model-hub-contracts/mirror-registry.json@@ -1,5 +1,5 @@{- "contract_version": 15,+ "contract_version": 16,"input_generation": {"mode": "same_run_live_files","external_snapshot": "content_fingerprint_required"@@ -209,6 +209,8 @@"credential_revoked": "models.source.needs_action.credential_revoked","balance_exhausted": "models.source.needs_action.balance_exhausted","account_banned": "models.source.needs_action.account_banned",+ "plan_excludes_product": "models.source.needs_action.plan_excludes_product",+ "spend_limit_reached": "models.source.needs_action.spend_limit_reached","unclassified_error": "models.source.error.unclassified"}},@@ -332,6 +334,8 @@"models.source.needs_action.balance_exhausted","models.source.needs_action.credential_revoked","models.source.needs_action.account_banned",+ "models.source.needs_action.plan_excludes_product",+ "models.source.needs_action.spend_limit_reached","models.source.error.unclassified"],"mapping": {@@ -914,6 +918,8 @@"models.source.needs_action.balance_exhausted","models.source.needs_action.credential_revoked","models.source.needs_action.account_banned",+ "models.source.needs_action.plan_excludes_product",+ "models.source.needs_action.spend_limit_reached","models.source.error.unclassified","models.probe.native_cli_unavailable"]diff --git a/docs/plans/model-hub-contracts/observation-result.schema.json b/docs/plans/model-hub-contracts/observation-result.schema.jsonindex 719c6b727..a4ce038c0 100644--- a/docs/plans/model-hub-contracts/observation-result.schema.json+++ b/docs/plans/model-hub-contracts/observation-result.schema.json@@ -16,7 +16,7 @@],"additionalProperties": false,"properties": {- "contract_version": { "const": 15 },+ "contract_version": { "const": 16 },"outcome": {"enum": ["observed",@@ -150,7 +150,7 @@],"examples": [{- "contract_version": 15,+ "contract_version": 16,"outcome": "observed","reachable": true,"authenticated": "authenticated",@@ -165,7 +165,7 @@]},{- "contract_version": 15,+ "contract_version": 16,"outcome": "authentication_failed","reachable": true,"authenticated": "rejected",@@ -175,7 +175,7 @@"model_metadata": []},{- "contract_version": 15,+ "contract_version": 16,"outcome": "ambiguous","reachable": true,"authenticated": "unknown",@@ -185,7 +185,7 @@"model_metadata": []},{- "contract_version": 15,+ "contract_version": 16,"outcome": "unreachable","reachable": false,"authenticated": "unknown",@@ -195,7 +195,7 @@"model_metadata": []},{- "contract_version": 15,+ "contract_version": 16,"outcome": "adapter_error","reachable": null,"authenticated": "unknown",@@ -205,7 +205,7 @@"model_metadata": []},{- "contract_version": 15,+ "contract_version": 16,"outcome": "timeout","reachable": null,"authenticated": "unknown",diff --git a/docs/plans/model-hub-contracts/probe-result.schema.json b/docs/plans/model-hub-contracts/probe-result.schema.jsonindex 57909469c..cbd6a7ae2 100644--- a/docs/plans/model-hub-contracts/probe-result.schema.json+++ b/docs/plans/model-hub-contracts/probe-result.schema.json@@ -7,7 +7,7 @@"required": ["contract_version", "backend", "channel", "reachable", "source_id", "model_id", "latency_ms", "error"],"additionalProperties": false,"properties": {- "contract_version": { "const": 15 },+ "contract_version": { "const": 16 },"backend": { "enum": ["claude", "codex", "opencode", "vibey"] },"channel": { "enum": ["hub", "native_cli"] },"reachable": { "type": "boolean" },@@ -26,6 +26,8 @@"models.source.needs_action.balance_exhausted","models.source.needs_action.credential_revoked","models.source.needs_action.account_banned",+ "models.source.needs_action.plan_excludes_product",+ "models.source.needs_action.spend_limit_reached","models.source.error.unclassified","models.probe.native_cli_unavailable"]@@ -66,10 +68,10 @@}],"examples": [- { "contract_version": 15, "backend": "codex", "channel": "hub", "reachable": true, "source_id": "src_chatgptplus", "model_id": "gpt-5.6", "latency_ms": 412, "error": null },- { "contract_version": 15, "backend": "claude", "channel": "hub", "reachable": false, "source_id": "src_relay9c1x", "model_id": "glm-5.2", "latency_ms": 287, "error": "models.source.needs_action.balance_exhausted" },- { "contract_version": 15, "backend": "codex", "channel": "hub", "reachable": false, "source_id": "src_chatgptplus", "model_id": "gpt-5.6", "latency_ms": null, "error": "models.source.backoff.connection_failed" },- { "contract_version": 15, "backend": "codex", "channel": "native_cli", "reachable": true, "source_id": "src_chatgptplus", "model_id": "gpt-5.6", "latency_ms": null, "error": null },- { "contract_version": 15, "backend": "codex", "channel": "native_cli", "reachable": false, "source_id": "src_chatgptplus", "model_id": "gpt-5.6", "latency_ms": null, "error": "models.probe.native_cli_unavailable" }+ { "contract_version": 16, "backend": "codex", "channel": "hub", "reachable": true, "source_id": "src_chatgptplus", "model_id": "gpt-5.6", "latency_ms": 412, "error": null },+ { "contract_version": 16, "backend": "claude", "channel": "hub", "reachable": false, "source_id": "src_relay9c1x", "model_id": "glm-5.2", "latency_ms": 287, "error": "models.source.needs_action.balance_exhausted" },+ { "contract_version": 16, "backend": "codex", "channel": "hub", "reachable": false, "source_id": "src_chatgptplus", "model_id": "gpt-5.6", "latency_ms": null, "error": "models.source.backoff.connection_failed" },+ { "contract_version": 16, "backend": "codex", "channel": "native_cli", "reachable": true, "source_id": "src_chatgptplus", "model_id": "gpt-5.6", "latency_ms": null, "error": null },+ { "contract_version": 16, "backend": "codex", "channel": "native_cli", "reachable": false, "source_id": "src_chatgptplus", "model_id": "gpt-5.6", "latency_ms": null, "error": "models.probe.native_cli_unavailable" }]}diff --git a/docs/plans/model-hub-contracts/resolution-event.schema.json b/docs/plans/model-hub-contracts/resolution-event.schema.jsonindex 209eef14c..0984fe398 100644--- a/docs/plans/model-hub-contracts/resolution-event.schema.json+++ b/docs/plans/model-hub-contracts/resolution-event.schema.json@@ -53,6 +53,8 @@"credential_revoked","balance_exhausted","account_banned",+ "plan_excludes_product",+ "spend_limit_reached","unclassified_error","no_enabled_source","no_eligible_source",@@ -61,7 +63,7 @@"model_unsupported","native_cli_unavailable"],- "description": "Adapter classification. The five non-self-healing source causes map bijectively to Source.state.detail_key: credential_expired→models.source.needs_action.oauth_expired; credential_revoked→models.source.needs_action.credential_revoked; balance_exhausted→models.source.needs_action.balance_exhausted; account_banned→models.source.needs_action.account_banned; unclassified_error→models.source.error.unclassified. The machine-readable mirror registry enforces the attempt-failure relation."+ "description": "Adapter classification. The seven non-self-healing source causes map bijectively to Source.state.detail_key: credential_expired→models.source.needs_action.oauth_expired; credential_revoked→models.source.needs_action.credential_revoked; balance_exhausted→models.source.needs_action.balance_exhausted; account_banned→models.source.needs_action.account_banned; plan_excludes_product→models.source.needs_action.plan_excludes_product; spend_limit_reached→models.source.needs_action.spend_limit_reached; unclassified_error→models.source.error.unclassified. The machine-readable mirror registry enforces the attempt-failure relation."},"billing_note": {"enum": [null, "entered_metered", "left_metered"]@@ -124,7 +126,7 @@}},{- "$comment": "A needs_action record is source-scoped and carries one of the five non-self-healing source causes.",+ "$comment": "A needs_action record is source-scoped and carries one of the seven non-self-healing source causes.","if": {"properties": { "kind": { "const": "needs_action" } },"required": ["kind"]@@ -141,6 +143,8 @@"credential_revoked","balance_exhausted","account_banned",+ "plan_excludes_product",+ "spend_limit_reached","unclassified_error"]}@@ -177,6 +181,8 @@"credential_revoked","balance_exhausted","account_banned",+ "plan_excludes_product",+ "spend_limit_reached","unclassified_error"]}diff --git a/docs/plans/model-hub-contracts/runtime-dependency.schema.json b/docs/plans/model-hub-contracts/runtime-dependency.schema.jsonindex d5c6a8218..1bb9d72ff 100644--- a/docs/plans/model-hub-contracts/runtime-dependency.schema.json+++ b/docs/plans/model-hub-contracts/runtime-dependency.schema.json@@ -7,7 +7,7 @@"required": ["contract_version", "manifest", "status"],"additionalProperties": false,"properties": {- "contract_version": { "const": 15 },+ "contract_version": { "const": 16 },"enabled": {"type": "boolean","description": "Persisted user intent for the managed gateway. Fresh/default configuration is true; explicit stop persists false."@@ -131,7 +131,7 @@},"examples": [{- "contract_version": 15,+ "contract_version": 16,"host_platform": "darwin-arm64","manifest": {"name": "cliproxyapi",diff --git a/docs/plans/model-hub-contracts/source.schema.json b/docs/plans/model-hub-contracts/source.schema.jsonindex a9f24899f..175f9e2a9 100644--- a/docs/plans/model-hub-contracts/source.schema.json+++ b/docs/plans/model-hub-contracts/source.schema.json@@ -185,7 +185,9 @@"models.source.needs_action.oauth_expired","models.source.needs_action.balance_exhausted","models.source.needs_action.credential_revoked",- "models.source.needs_action.account_banned"+ "models.source.needs_action.account_banned",+ "models.source.needs_action.plan_excludes_product",+ "models.source.needs_action.spend_limit_reached"]},"retry_at": {@@ -256,6 +258,8 @@"models.source.needs_action.balance_exhausted","models.source.needs_action.credential_revoked","models.source.needs_action.account_banned",+ "models.source.needs_action.plan_excludes_product",+ "models.source.needs_action.spend_limit_reached","models.source.error.unclassified"]}diff --git a/docs/plans/model-hub-contracts/turn-provenance.schema.json b/docs/plans/model-hub-contracts/turn-provenance.schema.jsonindex 103762559..1160377ff 100644--- a/docs/plans/model-hub-contracts/turn-provenance.schema.json+++ b/docs/plans/model-hub-contracts/turn-provenance.schema.json@@ -36,7 +36,7 @@"additionalProperties": false,"properties": {"contract_version": {- "enum": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],+ "enum": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],"$comment": "The only versioned object written to disk, so released versions form a set rather than a constant. Historical records validate after the existing persistence-read normalization of retired reasons; tests/fixtures/model_hub/released_v5_permission_denied.json exercises that boundary, not raw-file validation. Reading preserves the writer generation and requires no new route fields. New records carry the terminal member. Other versioned objects are ephemeral envelopes pinned to that value alone.","description": "Generation that wrote this record. Readers retain every supported released value, apply existing retired-reason normalization independently of version, and do not require route_origin or manual_override."},@@ -111,6 +111,8 @@"credential_revoked","balance_exhausted","account_banned",+ "plan_excludes_product",+ "spend_limit_reached","unclassified_error"],"description": "The attempt-failure partition of ResolutionEvent.reason. The mirror registry enforces totality."@@ -223,6 +225,11 @@"insufficient_quota","usage_limit_reached","billing_error",+ "usage_not_included",+ "credit_balance_exhausted",+ "organization_spend_limit_exceeded",+ "project_spend_limit_exceeded",+ "organization_usage_limit_exceeded","overloaded","overloaded_error","server_error",@@ -352,6 +359,8 @@"credential_revoked","balance_exhausted","account_banned",+ "plan_excludes_product",+ "spend_limit_reached","unclassified_error"]}@@ -478,7 +487,7 @@],"examples": [{- "contract_version": 15,+ "contract_version": 16,"turn_id": "turn_01k9x2m4","ts": "2026-07-29T06:32:11Z","agent": "claude",@@ -503,7 +512,7 @@"blockers": []},{- "contract_version": 15,+ "contract_version": 16,"turn_id": "turn_01k9x33p","ts": "2026-07-29T06:41:02Z","agent": "opencode",@@ -524,7 +533,7 @@"blockers": []},{- "contract_version": 15,+ "contract_version": 16,"turn_id": "turn_01k9x3zq","ts": "2026-07-29T06:48:20Z","agent": "codex",@@ -544,7 +553,7 @@]},{- "contract_version": 15,+ "contract_version": 16,"turn_id": "turn_01k9x4b7","ts": "2026-07-29T07:02:44Z","agent": "claude",@@ -564,7 +573,7 @@"blockers": []},{- "contract_version": 15,+ "contract_version": 16,"turn_id": "turn_modelmissing01","ts": "2026-09-05T17:31:10Z","agent": "claude",@@ -586,7 +595,7 @@"blockers": []},{- "contract_version": 15,+ "contract_version": 16,"turn_id": "turn_01k9x5ca","ts": "2026-07-29T07:08:00Z","agent": "codex",diff --git a/docs/plans/model-hub-ui-spec.md b/docs/plans/model-hub-ui-spec.mdindex 7820d0fcb..b5509eb50 100644--- a/docs/plans/model-hub-ui-spec.md+++ b/docs/plans/model-hub-ui-spec.md@@ -3974,15 +3974,17 @@ complete server-derived `adopted_by` array from `GET /api/models/sources`, exactcreation response retained in client state. The fact is registered once and cited twiceso both consumers select the same active/in-use split.-**`needs_action` is four causes, not one, and the row above resolves to whichever of them+**`needs_action` is six causes, not one, and the row above resolves to whichever of themthe payload carries** `[contract]`. `state.detail_key` is required on this state and itsenum runs `models.source.needs_action.oauth_expired`,`models.source.needs_action.balance_exhausted`,`models.source.needs_action.credential_revoked`,-`models.source.needs_action.account_banned` — four causes with four different remedies, of-which only one is about a credential being wrong. One label reading 凭据失效 was therefore-false on three of them, and false in the expensive direction: it sends a user whose balance-ran out to re-enter a key that is fine. So the four have four strings, selected by the key+`models.source.needs_action.account_banned`,+`models.source.needs_action.plan_excludes_product`,+`models.source.needs_action.spend_limit_reached` — six causes with six different+remedies, of which only one is about a credential being wrong. One label reading 凭据失效 was therefore+false on five of them, and false in the expensive direction: it sends a user whose balance+ran out to re-enter a key that is fine. So the six have six strings, selected by the keythe payload already carries. What this does **not** do is enumerate the ways a *request*can fail — that set is closed at F1–F5 and stays closed. `detail_key` is a field on thesource, persisted and read back, and rendering a field the contract requires is not thediff --git a/docs/plans/model-hub.md b/docs/plans/model-hub.mdindex 6abc6125f..293196a1b 100644--- a/docs/plans/model-hub.md+++ b/docs/plans/model-hub.md@@ -859,7 +859,13 @@ failed response whose error envelope has type `usage_limit_reached`, its`resets_at` (Unix seconds) as an HTTP date, else its `resets_in_seconds` as aninteger. A ChatGPT subscription past its cap answers 429 with both, so it coolsas quota exhaustion until its reset instead of being re-probed. The same field-names in any other error envelope are not advice. Malformed, past, oversized, and+names in any other error envelope are not advice. A 429 whose machine code names a+plan or billing cause settles its Source by that cause instead of as a rate limit:+`usage_not_included` (a ChatGPT plan without Codex) is `plan_excludes_product` and+`credit_balance_exhausted` is `balance_exhausted`, and OpenAI's+`organization_spend_limit_exceeded`, `project_spend_limit_exceeded` and+`organization_usage_limit_exceeded` are `spend_limit_reached`. All of them need the user:+retrying restores none, so none is a cooldown. Malformed, past, oversized, andnon-ASCII advice is ignored with a redacted diagnostic. Scheduling and windowduration are monotonic; aware UTC timestamps are read projections. Networkstate is never persisted. Existing shaped cooldown persistence remainsdiff --git a/tests/e2e/test_model_hub_runtime.py b/tests/e2e/test_model_hub_runtime.pyindex f2e364650..6e8641ba0 100644--- a/tests/e2e/test_model_hub_runtime.py+++ b/tests/e2e/test_model_hub_runtime.py@@ -684,7 +684,7 @@ def test_a1_feature_flag_disables_the_complete_models_api(assert response.status == 404, (method, path, body)assert body == {"ok": False,- "contract_version": 15,+ "contract_version": 16,"error": "feature_disabled",}diff --git a/tests/e2e/test_model_hub_sources.py b/tests/e2e/test_model_hub_sources.pyindex 09cc4ed05..de7bd59bd 100644--- a/tests/e2e/test_model_hub_sources.py+++ b/tests/e2e/test_model_hub_sources.py@@ -13,7 +13,7 @@ from tests.e2e.drivers.mock_llm_upstream import MockLLMUpstreampytestmark = pytest.mark.e2e_model_hub-CONTRACT_VERSION = 15+CONTRACT_VERSION = 16MENU_MODEL = "claude-sonnet-4-6"SYNTHETIC_API_KEY = "sk-model-hub-e2e-not-real"diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yamlindex 49f10013e..e2666bab5 100644--- a/tests/scenarios/model_hub/catalog.yaml+++ b/tests/scenarios/model_hub/catalog.yaml@@ -774,6 +774,14 @@ scenarios:kind: recoverylayer: unittest: tests/test_model_hub_retry_lifecycle.py::test_a_usage_cap_cools_its_source_as_quota_until_the_upstream_reset+ - id: MH-RETRY-ADVICE-003+ name: >-+ A 429 that names a plan or billing cause settles its Source by that cause, not as a 60 s rate limit: a plan+ without the product, an exhausted credit balance and a spend or usage limit all need the user+ status: covered+ kind: recovery+ layer: unit+ test: tests/test_model_hub_retry_lifecycle.py::test_a_plan_or_billing_429_settles_its_source_by_the_code_that_names_it- id: MH-RETRY-EVIDENCE-001name: Unknown buffered success passes through without proving recoverystatus: covereddiff --git a/tests/test_model_hub_api.py b/tests/test_model_hub_api.pyindex 7f7b696e6..13034029b 100644--- a/tests/test_model_hub_api.py+++ b/tests/test_model_hub_api.py@@ -1031,7 +1031,7 @@ def test_runtime_start_is_explicit_and_returns_v4_status(tmp_path):assert adapter.start_calls == 1assert store.config.enabled is Trueassert runtime["enabled"] is True- assert runtime["contract_version"] == 15+ assert runtime["contract_version"] == 16assert runtime["status"]["health"] == "ok"_assert_valid("runtime-dependency.schema.json", runtime)@@ -1338,7 +1338,7 @@ def test_runtime_start_crosses_the_controller_rpc_boundary(monkeypatch):async def rpc(operation, payload=None):calls.append((operation, payload))- return {"contract_version": 15, "status": {"health": "ok"}}+ return {"contract_version": 16, "status": {"health": "ok"}}monkeypatch.setattr(model_hub_client, "_rpc", rpc)@@ -1355,7 +1355,7 @@ def test_runtime_stop_crosses_the_controller_rpc_boundary(monkeypatch):async def rpc(operation, payload=None):calls.append((operation, payload))- return {"contract_version": 15, "status": {"health": "not_started"}}+ return {"contract_version": 16, "status": {"health": "not_started"}}monkeypatch.setattr(model_hub_client, "_rpc", rpc)@@ -1372,7 +1372,7 @@ def test_runtime_install_crosses_the_controller_rpc_boundary(monkeypatch):async def rpc(operation, payload=None):calls.append((operation, payload))- return {"contract_version": 15, "status": {"health": "installing"}}+ return {"contract_version": 16, "status": {"health": "installing"}}monkeypatch.setattr(model_hub_client, "_rpc", rpc)@@ -1390,7 +1390,7 @@ def test_runtime_dependency_ensure_crosses_the_controller_rpc_boundary(monkeypatdef rpc(operation, payload=None):calls.append((operation, payload))return {- "contract_version": 15,+ "contract_version": 16,"changed": True,"status": {"health": "not_started", "verified": True},}@@ -4810,7 +4810,7 @@ def test_agent_models_route_returns_only_picker_catalog_fields(monkeypatch):assert response.status_code == 200assert response.get_json() == {"ok": True,- "contract_version": 15,+ "contract_version": 16,"agent": {"backend": "codex","mode": "hub",@@ -9678,7 +9678,7 @@ def test_runtime_start_route_requires_csrf_before_starting_engine(monkeypatch, tassert accepted.status_code == 200runtime = accepted.get_json()["runtime"]assert adapter.start_calls == 1- assert runtime["contract_version"] == 15+ assert runtime["contract_version"] == 16_assert_valid("runtime-dependency.schema.json", runtime)diff --git a/tests/test_model_hub_config.py b/tests/test_model_hub_config.pyindex 185881d71..dee0e4299 100644--- a/tests/test_model_hub_config.py+++ b/tests/test_model_hub_config.py@@ -96,7 +96,7 @@ def test_auto_detect_asks_for_responses_before_chat():def test_unsaved_observation_schema_closes_all_terminal_shapes():schema = _schema("observation-result.schema.json")- assert schema["properties"]["contract_version"]["const"] == 15+ assert schema["properties"]["contract_version"]["const"] == 16assert tuple(schema["properties"]["outcome"]["enum"]) == tuple(member.value for member in ObservationOutcome)@@ -120,7 +120,7 @@ def test_observation_terminal_authority_and_schema_accept_the_same_products():def payload(observation: SourceObservation) -> dict:return {- "contract_version": 15,+ "contract_version": 16,"outcome": observation.outcome.value,"reachable": observation.reachable,"authenticated": (@@ -700,7 +700,7 @@ def test_guard_refusal_error_requires_its_corresponding_nonempty_plan_array():route_refusal = {"ok": False,- "contract_version": 15,+ "contract_version": 16,"error": "source_in_route_chain","detail": "modelHub.errors.source_in_route_chain","would_remove_hops": [hop],@@ -716,7 +716,7 @@ def test_guard_refusal_error_requires_its_corresponding_nonempty_plan_array():}candidate_refusal = {"ok": False,- "contract_version": 15,+ "contract_version": 16,"error": "candidate_suppliers_changed","detail": "modelHub.errors.candidate_suppliers_changed","changed": {@@ -800,7 +800,7 @@ def test_v8_mirror_registry_is_executable_and_complete():registry = json.loads((CONTRACTS / "mirror-registry.json").read_text(encoding="utf-8"))schemas = _mirror_schemas(registry)- assert registry["contract_version"] == 15+ assert registry["contract_version"] == 16ids = [entry["id"] for entry in registry["entries"]]assert idsassert len(ids) == len(set(ids))@@ -937,8 +937,8 @@ def test_model_hub_authority_closure_anchors_the_persisted_version_floor(monkeyp"kind": "contract_version_schema_drift","domain": "V1","file": "docs/plans/model-hub-contracts/turn-provenance.schema.json",- "values": [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],- "expected": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],+ "values": [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],+ "expected": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],} in result["findings"]@@ -1249,7 +1249,7 @@ def test_v5_shape_amendments_reject_the_false_states_they_replace():with pytest.raises(ValidationError):chain_validator.validate(interrupted)exact_hop = {- "contract_version": 15,+ "contract_version": 16,"backend": "claude","model_id": "claude-opus-4-6","manual_override": None,diff --git a/tests/test_model_hub_l3.py b/tests/test_model_hub_l3.pyindex edecd9cf5..e0ea48660 100644--- a/tests/test_model_hub_l3.py+++ b/tests/test_model_hub_l3.py@@ -5579,7 +5579,7 @@ def test_backend_failure_keeps_the_gateway_terminal_error_no_later_request_superdef test_released_backend_rejection_records_read_unchanged(tmp_path: Path) -> None:"""Records the earlier bridge wrote stay as written: no reason or phase is re-derived on read."""released = {- "contract_version": 15,+ "contract_version": 16,"turn_id": "turn_released_rejection","ts": NOW.isoformat(),"agent": "vibey",@@ -7055,7 +7055,7 @@ def test_source_observation_reduces_the_order_at_the_first_authenticated_proof(_assert_valid("observation-result.schema.json",{- "contract_version": 15,+ "contract_version": 16,"outcome": "adapter_error","reachable": True,"authenticated": "unknown",@@ -9589,7 +9589,7 @@ def test_native_chain_visibility_and_probe_readiness(tmp_path: Path) -> None:probe = asyncio.run(service.probe_agent("codex", "shared-model"))assert probe == {- "contract_version": 15,+ "contract_version": 16,"backend": "codex","channel": "native_cli","reachable": True,diff --git a/tests/test_model_hub_provenance.py b/tests/test_model_hub_provenance.pyindex 97184f5c5..1419bf1d1 100644--- a/tests/test_model_hub_provenance.py+++ b/tests/test_model_hub_provenance.py@@ -261,7 +261,7 @@ def test_live_recovery_snapshots_never_revive_invalid_or_terminal_owners(tmp_patdef _record(turn_id, *, backend="claude", model=MODEL, outcome="failed_terminal"):identity = {"source_id": "src_deleted01", "configured_model_id": "unknown-model", "channel": "hub"}return {- "contract_version": 15,+ "contract_version": 16,"turn_id": turn_id,"ts": "2026-09-06T00:00:00Z","agent": backend,@@ -461,6 +461,6 @@ def test_model_history_client_rpc_http_share_nullable_read_only_result(monkeypatf"/api/models/agents/claude/provenance?model={MODEL}", headers=csrf_headers(client, origin), base_url=origin)assert response.status_code == 200- assert response.get_json() == {"ok": True, "contract_version": 15, "provenance": record}+ assert response.get_json() == {"ok": True, "contract_version": 16, "provenance": record}assert store.config.to_payload() == beforeassert adapter.synced == []diff --git a/tests/test_model_hub_resolution.py b/tests/test_model_hub_resolution.pyindex 468b361a3..df4f6b4db 100644--- a/tests/test_model_hub_resolution.py+++ b/tests/test_model_hub_resolution.py@@ -1808,7 +1808,7 @@ def test_service_accepts_authoritative_reachable_adapter_error(tmp_path):)assert result["observation"] == {- "contract_version": 15,+ "contract_version": 16,"outcome": "adapter_error","reachable": True,"authenticated": "unknown",@@ -1839,7 +1839,7 @@ def test_unknown_adapter_error_does_not_claim_connection(tmp_path):assert exc.value.code == "discovery_failed"assert exc.value.detail == "modelHub.errors.adapter_error"assert exc.value.data["observation"] == {- "contract_version": 15,+ "contract_version": 16,"outcome": "adapter_error","reachable": None,"authenticated": "unknown",diff --git a/tests/test_model_hub_retry_lifecycle.py b/tests/test_model_hub_retry_lifecycle.pyindex 7c19a9798..4824344b2 100644--- a/tests/test_model_hub_retry_lifecycle.py+++ b/tests/test_model_hub_retry_lifecycle.py@@ -440,6 +440,55 @@ def test_a_usage_cap_cools_its_source_as_quota_until_the_upstream_reset(tmp_pathasyncio.run(run())+_SPEND_LIMIT = ("needs_action", "models.source.needs_action.spend_limit_reached")++[email protected](("error", "settled"), [+ # Codex's own client turns this 429 type into "upgrade to Plus" (openai/codex+ # codex-api/src/api_bridge.rs); only a plan change ends it.+ (+ {"type": "usage_not_included", "message": "To use Codex with your ChatGPT plan, upgrade to Plus."},+ ("needs_action", "models.source.needs_action.plan_excludes_product"),+ ),+ # OpenAI's error-code guide: a billing 429 names its cause in the code, the+ # type may stay the generic insufficient_quota, and retrying restores none.+ (+ {"type": "insufficient_quota", "code": "credit_balance_exhausted", "message": "No prepaid credits remain."},+ ("needs_action", "models.source.needs_action.balance_exhausted"),+ ),+ ({"type": "insufficient_quota", "code": "organization_spend_limit_exceeded", "message": "Spend limit."}, _SPEND_LIMIT),+ ({"type": "insufficient_quota", "code": "project_spend_limit_exceeded", "message": "Spend limit."}, _SPEND_LIMIT),+ ({"type": "insufficient_quota", "code": "organization_usage_limit_exceeded", "message": "Usage limit."}, _SPEND_LIMIT),+ # A request-class type beside the code does not decide it.+ ({"type": "invalid_request_error", "code": "project_spend_limit_exceeded", "message": "Spend limit."}, _SPEND_LIMIT),+ # The generic type alone names no cause, so it keeps cooling as quota.+ (+ {"type": "insufficient_quota", "message": "You exceeded your current quota."},+ ("cooldown", "models.source.cooldown.quota_exhausted"),+ ),+], ids=lambda value: value.get("code", value.get("type")) if isinstance(value, dict) else None)+def test_a_plan_or_billing_429_settles_its_source_by_the_code_that_names_it(tmp_path, error, settled):+ """MH-RETRY-ADVICE-003: a 429 naming a plan or billing cause is not a 60 s rate limit (#2530)."""+ async def run():+ service, _clock, models = configured_service(tmp_path)+ body = json.dumps({"error": error}, separators=(",", ":"))+ calls = []++ async def respond(request):+ calls.append(await request.json())+ return web.Response(status=429, text=body, content_type="application/json")++ async with loopback_engine(tmp_path, service, respond):+ async with gateway_client(service, "codex", models["codex"]) as (_gateway, client, url, headers):+ async with client.post(url, headers=headers, json={"model": "shared-model"}) as response:+ assert response.status >= 400+ state = service.store.load().sources[0].state+ assert (state.status, state.detail_key) == settled+ assert (state.retry_at is None) is (settled[0] == "needs_action")+ assert len(calls) == 1+ asyncio.run(run())++@pytest.mark.parametrize("persisted", [False, True])@pytest.mark.parametrize("reason,delay", [("server_error", 30), ("rate_limited", 60), ("quota_exhausted", 300), ("network", 1),diff --git a/tests/test_model_hub_runtime.py b/tests/test_model_hub_runtime.pyindex 38f5de94e..6b8c1177f 100644--- a/tests/test_model_hub_runtime.py+++ b/tests/test_model_hub_runtime.py@@ -1351,7 +1351,7 @@ def test_manifest_resolution_drives_admission_persistence_and_schema(installer=manager,state_store=EngineStateStore(tmp_path / "state"),)- projected = {"contract_version": 15, **supervisor.status()}+ projected = {"contract_version": 16, **supervisor.status()}schema = json.loads(Path("docs/plans/model-hub-contracts/runtime-dependency.schema.json").read_text(encoding="utf-8"diff --git a/tests/test_model_hub_structure_guards.py b/tests/test_model_hub_structure_guards.pyindex e235939a8..51d212c2e 100644--- a/tests/test_model_hub_structure_guards.py+++ b/tests/test_model_hub_structure_guards.py@@ -304,6 +304,11 @@ MACHINE_ERROR_FAMILY_FIXTURES = {"insufficient_quota","usage_limit_reached","billing_error",+ "usage_not_included",+ "credit_balance_exhausted",+ "organization_spend_limit_exceeded",+ "project_spend_limit_exceeded",+ "organization_usage_limit_exceeded","overloaded","overloaded_error",),diff --git a/tests/test_model_hub_vibey_contract_matrix.py b/tests/test_model_hub_vibey_contract_matrix.pyindex aae4e44bc..1199078c7 100644--- a/tests/test_model_hub_vibey_contract_matrix.py+++ b/tests/test_model_hub_vibey_contract_matrix.py@@ -48,13 +48,13 @@ def _fixture(kind):# Start from a valid native response so no Hub latency constraint can# accidentally reject the Avibe/native pairing for an unrelated cause.return {- "contract_version": 15, "backend": "claude", "channel": "native_cli", "reachable": True,+ "contract_version": 16, "backend": "claude", "channel": "native_cli", "reachable": True,"source_id": "src_fixture01", "model_id": "fixture-model", "latency_ms": None,"error": None,}if kind == "chain":return {- "contract_version": 15, "backend": "vibey", "model_id": "fixture-model",+ "contract_version": 16, "backend": "vibey", "model_id": "fixture-model","manual_override": None, "route_origin": "automatic","chain": [{"source_id": "src_fixture01", "model_id": "fixture-model", "channel": "hub","health": "healthy", "runnable": True, "reason": None, "retry_at": None}],@@ -66,7 +66,7 @@ def _fixture(kind):"proposed_action": "import", "selected": False,}return {- "contract_version": 15, "turn_id": "turn-fixture", "ts": "2026-10-02T07:00:00Z",+ "contract_version": 16, "turn_id": "turn-fixture", "ts": "2026-10-02T07:00:00Z","agent": "vibey", "requested_model_id": "fixture-model", "outcome": kind,"failed_attempts": [{**identity, "reason": "rate_limited"}] if kind == "exhausted" else [],"served": identity if kind == "served" else None,diff --git a/ui/e2e/chat-interactions/interactions.spec.ts b/ui/e2e/chat-interactions/interactions.spec.tsindex eb890c57d..b9bbb7cbd 100644--- a/ui/e2e/chat-interactions/interactions.spec.ts+++ b/ui/e2e/chat-interactions/interactions.spec.ts@@ -11,7 +11,7 @@ for (const lang of ['en', 'zh'] as const) {if (url.origin !== 'http://127.0.0.1:5227' || route.request().method() !== 'GET') return route.abort();if (url.pathname === `/api/models/turns/${TURN}/provenance`) {return route.fulfill({ json: { provenance: {- contract_version: 15, turn_id: TURN, agent: 'codex', requested_model_id: 'fixture-model',+ contract_version: 16, turn_id: TURN, agent: 'codex', requested_model_id: 'fixture-model',outcome: 'failed_terminal', failed_attempts: [], blockers: [],terminal_error: { source_id: 'fixture-source', configured_model_id: 'fixture-model', reason: 'engine_down' },} } });diff --git a/ui/e2e/model-catalog/gatewayFixture.tsx b/ui/e2e/model-catalog/gatewayFixture.tsxindex 88d877752..b401d3f2b 100644--- a/ui/e2e/model-catalog/gatewayFixture.tsx+++ b/ui/e2e/model-catalog/gatewayFixture.tsx@@ -35,13 +35,13 @@ export function GatewayFixture() {}],};const chains = Object.fromEntries(ids.map((model_id, index) => [modelChainKey(backend, model_id), readyRegion<AgentChain>({- contract_version: 15, backend, model_id, route_origin: origins[index],+ contract_version: 16, backend, model_id, route_origin: origins[index],manual_override: origins[index] === 'manual' ? { hops: [{ source_id: source.id, model_id }] } : null,current: { source_id: source.id, model_id }, supply_state: 'ok',chain: [{ source_id: source.id, model_id, channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }],})]));const runtime = freshRuntimeProjection(readyRegion({- contract_version: 15,+ contract_version: 16,manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1.0.0', source_sha: 'fixture', assets: [] },status: { installed_version: '1.0.0', verified: true, listening: null, health: 'ok', last_check: null },}));diff --git a/ui/e2e/model-catalog/routeFixture.tsx b/ui/e2e/model-catalog/routeFixture.tsxindex 5d09d0d0b..e107ba732 100644--- a/ui/e2e/model-catalog/routeFixture.tsx+++ b/ui/e2e/model-catalog/routeFixture.tsx@@ -28,7 +28,7 @@ const supply: AgentSupply = {sources: { order: sources.map((source) => source.id), eligibility: sources.map((source) => ({ source_id: source.id, eligible: true })) },};const makeChain = (hops: RouteHop[], manual: boolean): AgentChain => ({- contract_version: 15, backend, model_id: modelId,+ contract_version: 16, backend, model_id: modelId,manual_override: manual ? { hops } : null,route_origin: manual ? 'manual' : origin === 'passthrough' ? 'passthrough' : 'automatic',current: hops[0] ?? null, supply_state: hops.length ? 'ok' : 'interrupted',diff --git a/ui/e2e/model-routing-origin.spec.ts b/ui/e2e/model-routing-origin.spec.tsindex b00e36786..2a8745a2a 100644--- a/ui/e2e/model-routing-origin.spec.ts+++ b/ui/e2e/model-routing-origin.spec.ts@@ -102,7 +102,7 @@ test('MH-ROUTING-007 follow-defaults switch, undo, cancel, and save preserve expwould_remove_hops: [{ backend: gateway.backend, menu_model: gateway.model, ...manual.hops[0], position: 1 }],would_interrupt: [],};- expect(await refused.json()).toMatchObject({ ok: false, contract_version: 15, error: 'source_in_route_chain', ...plan });+ expect(await refused.json()).toMatchObject({ ok: false, contract_version: 16, error: 'source_in_route_chain', ...plan });expect((await api.agentChain(gateway.backend, gateway.model)).manual_override).toEqual(manual);// The one question is its own modal over the chain the user was editing.const guard = hub.dialogTitled(copy('guard.title.saveRoute', { menuModel: gateway.model }));diff --git a/ui/e2e/onboarding-fidelity/hub-ownership.spec.ts b/ui/e2e/onboarding-fidelity/hub-ownership.spec.tsindex 6b4cc1088..3bff6f569 100644--- a/ui/e2e/onboarding-fidelity/hub-ownership.spec.ts+++ b/ui/e2e/onboarding-fidelity/hub-ownership.spec.ts@@ -92,7 +92,7 @@ for (const width of [1200, 390]) {if (path === '/api/models/runtime/status') return answer({ok: true,runtime: {- contract_version: 15, enabled: true, host_platform: 'linux',+ contract_version: 16, enabled: true, host_platform: 'linux',manifest: { name: 'cliproxyapi', resolution: 'resolved', version: 'fixture', source_sha: 'a'.repeat(40), assets: [] },status: { installed_version: 'fixture', verified: true, health: 'ok' },},diff --git a/ui/e2e/onboarding-fidelity/pm-main-flow.spec.ts b/ui/e2e/onboarding-fidelity/pm-main-flow.spec.tsindex 45ded868a..2d8ac8ffe 100644--- a/ui/e2e/onboarding-fidelity/pm-main-flow.spec.ts+++ b/ui/e2e/onboarding-fidelity/pm-main-flow.spec.ts@@ -18,7 +18,7 @@ for (const [width,chosen] of [[1200,"claude"],[390,"claude"],[1200,"codex"]] asconst config=()=>({version:'v2',mode:'self_host',setup_completed:completed,setup_state:{needs_setup:!completed},capabilities:{model_hub:{enabled:true}},platforms:{primary:'slack',enabled:[]},runtime:{},agents:Object.fromEntries(['claude','codex','opencode'].map(b=>[b,{enabled:b!=='opencode',cli_path:b}])),agent:{default_cwd:'/fixture/work'},model_hub:{enabled:true,runtime_default_applied:true}});const source={id:'src_fixture',kind:'api_key',vendor:'openai',display_name:'Fixture source',protocol:'openai_chat',supply_channel:'hub',billing:'metered',state:{status:'active'},masked_credential:'fixture-only',models:hops.map(h=>({id:h.model_id,display_name:h.model_id==='gpt-5'?'GPT-5':undefined,origin:'discovered',reasoning_efforts:[],reasoning_efforts_source:null})),last_discovered_at:null};const supply=(b:string)=>({backend:b,cli_present:true,mode:'hub',menu_kind:'fixed',sources:{order:[source.id],eligibility:[{source_id:source.id,eligible:true}]},routes:{},builtin_models:[],catalog_models:[],menu:null,model_supply:[],named_agents:[{name:b,effective_model_id:agent(b).model,supply_status:saved[b].length?'ok':'unavailable'}],supply_status:saved[b].length?'ok':'unavailable'});- const chain=(b:string,hs=saved[b])=>({contract_version:15,backend:b,model_id:agent(b).model,manual_override:hs.length?{hops:hs}:null,route_origin:hs.length?'manual':'automatic',current:hs[0]??null,chain:hs.map(h=>({...h,channel:'hub',health:'healthy',runnable:true,reason:null,retry_at:null})),supply_state:hs.length?'ok':'unavailable'});+ const chain=(b:string,hs=saved[b])=>({contract_version:16,backend:b,model_id:agent(b).model,manual_override:hs.length?{hops:hs}:null,route_origin:hs.length?'manual':'automatic',current:hs[0]??null,chain:hs.map(h=>({...h,channel:'hub',health:'healthy',runnable:true,reason:null,retry_at:null})),supply_state:hs.length?'ok':'unavailable'});await page.addInitScript(()=>localStorage.setItem('i18nextLng','en'));await page.route(`${ORIGIN}/api/**`,async route=>{const req=route.request(),path=new URL(req.url()).pathname;@@ -34,7 +34,7 @@ for (const [width,chosen] of [[1200,"claude"],[390,"claude"],[1200,"codex"]] as}if(path==='/api/agents')return answer({ok:true,default_agent_name:defaultName,agents:[agent('claude'),agent('codex')]});if(/^\/api\/agents\/(claude|codex)$/.test(path))return answer({ok:true,agent:agent(path.split('/').at(-1)!),default_agent_name:defaultName});- if(path==='/api/models/runtime/status')return answer({ok:true,runtime:{contract_version:15,enabled:true,host_platform:'linux',manifest:{name:'cliproxyapi',resolution:'resolved',version:'fixture',source_sha:'a'.repeat(40),assets:[]},status:{installed_version:'fixture',verified:true,health:'ok'}}});+ if(path==='/api/models/runtime/status')return answer({ok:true,runtime:{contract_version:16,enabled:true,host_platform:'linux',manifest:{name:'cliproxyapi',resolution:'resolved',version:'fixture',source_sha:'a'.repeat(40),assets:[]},status:{installed_version:'fixture',verified:true,health:'ok'}}});if(path==='/api/models/sources')return answer({ok:true,sources:[source]});if(path==='/api/models/agents')return answer({ok:true,agents:[supply('claude'),supply('codex')]});if(/\/api\/models\/agents\/(claude|codex)\/chains$/.test(path)){diff --git a/ui/e2e/onboarding-fidelity/provider-support.ts b/ui/e2e/onboarding-fidelity/provider-support.tsindex b2b6a8ff9..378c619a3 100644--- a/ui/e2e/onboarding-fidelity/provider-support.ts+++ b/ui/e2e/onboarding-fidelity/provider-support.ts@@ -129,7 +129,7 @@ const CONFIG = {/** Installed, verified and serving: the screen's `gatewayIntent` reads `running` and* starts no install, which is the state every proof below is about something else. */const RUNTIME = {- contract_version: 15,+ contract_version: 16,enabled: true,host_platform: 'darwin',manifest: {diff --git a/ui/e2e/onboarding-fidelity/support.ts b/ui/e2e/onboarding-fidelity/support.tsindex 7100a7d3a..39d785e4d 100644--- a/ui/e2e/onboarding-fidelity/support.ts+++ b/ui/e2e/onboarding-fidelity/support.ts@@ -87,7 +87,7 @@ export async function serveProduct(page: Page) {const backend = new URL(route.request().url()).pathname.split('/')[4];return route.fulfill({ json: { ok: true, agent: { backend, mode: 'direct', sources: { order: [], eligibility: [] }, routes: {}, builtin_models: [], catalog_models: [], named_agents: [], menu: null, model_supply: [], supply_status: 'unavailable' } } });});- await page.route('**/api/models/runtime/status', (route) => route.fulfill({ json: { ok: true, runtime: { contract_version: 15, enabled: true, host_platform: 'linux', manifest: { name: 'cliproxyapi', resolution: 'resolved', version: 'fixture', source_sha: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', assets: [] }, status: { installed_version: 'fixture', verified: true, health: 'ok' } } } }));+ await page.route('**/api/models/runtime/status', (route) => route.fulfill({ json: { ok: true, runtime: { contract_version: 16, enabled: true, host_platform: 'linux', manifest: { name: 'cliproxyapi', resolution: 'resolved', version: 'fixture', source_sha: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', assets: [] }, status: { installed_version: 'fixture', verified: true, health: 'ok' } } } }));await page.route(`${ORIGIN}/status`, (route) => route.fulfill({ json: { state: 'running' } }));await page.route('**/api/backend/*/connection', (route) => route.fulfill({ json: { ok: true, backend: new URL(route.request().url()).pathname.split('/').at(-2), installed: true, enabled: true, auth: 'none', application: 'applied', ready: false, entry_eligible: false } }));await page.route('**/api/config', (route) => route.fulfill({ json: CONFIG }));diff --git a/ui/e2e/workbench-general/geometry.spec.ts b/ui/e2e/workbench-general/geometry.spec.tsindex bf4494125..8a359dcc9 100644--- a/ui/e2e/workbench-general/geometry.spec.ts+++ b/ui/e2e/workbench-general/geometry.spec.ts@@ -48,7 +48,7 @@ const MODEL_HUB_AGENT = {};const MODEL_HUB_RUNTIME = {- contract_version: 15,+ contract_version: 16,enabled: true,manifest: { name: 'cliproxyapi', resolution: 'resolved', version: 'fixture', source_sha: 'f'.repeat(40), assets: [] },status: { installed_version: 'fixture', verified: true, listening: { host: '127.0.0.1', port: 43123 }, health: 'ok' },diff --git a/ui/src/components/onboarding/AssistantSetup.test.tsx b/ui/src/components/onboarding/AssistantSetup.test.tsxindex 9af849e76..8a638df35 100644--- a/ui/src/components/onboarding/AssistantSetup.test.tsx+++ b/ui/src/components/onboarding/AssistantSetup.test.tsx@@ -50,7 +50,7 @@ const hubAgent = (enabled = true) => ({system_prompt: null, created_at: '', metadata: { builtin_default: true },});const hubChain = (modelId: string) => ({- contract_version: 15, backend: 'claude', model_id: 'opus-5',+ contract_version: 16, backend: 'claude', model_id: 'opus-5',manual_override: { hops: [{ source_id: 'src_a', model_id: modelId }] },route_origin: 'manual', current: { source_id: 'src_a', model_id: modelId },chain: [{ source_id: 'src_a', model_id: modelId, channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }],@@ -354,7 +354,7 @@ describe('assistant installation presentation', () => {mock.api.getVibeAgent.mockResolvedValue({ ok: true, agent });mock.models.listSources.mockResolvedValue([]);const chain = {- contract_version: 15, backend: 'claude', model_id: 'opus-5',+ contract_version: 16, backend: 'claude', model_id: 'opus-5',manual_override: { hops: [{ source_id: 'src_a', model_id: 'opus-5' }, { source_id: 'src_b', model_id: 'opus-5' }] },route_origin: 'manual', current: { source_id: 'src_a', model_id: 'opus-5' },chain: [diff --git a/ui/src/components/onboarding/BuiltinAssistant.test.tsx b/ui/src/components/onboarding/BuiltinAssistant.test.tsxindex 0bd9ebc64..28f77fe1f 100644--- a/ui/src/components/onboarding/BuiltinAssistant.test.tsx+++ b/ui/src/components/onboarding/BuiltinAssistant.test.tsx@@ -65,7 +65,7 @@ const vibeyAgent = (model: string | null) => ({system_prompt: null, created_at: '', metadata: { builtin_default: true, lock_delete: true },});const chain = (modelId: string) => ({- contract_version: 15, backend: 'vibey', model_id: modelId,+ contract_version: 16, backend: 'vibey', model_id: modelId,manual_override: null, route_origin: 'automatic', current: { source_id: 'src_openai', model_id: modelId },chain: [{ source_id: 'src_openai', model_id: modelId, channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }],supply_state: 'ok',diff --git a/ui/src/components/onboarding/providers/ProvidersScreen.test.tsx b/ui/src/components/onboarding/providers/ProvidersScreen.test.tsxindex b4a0efca9..737c30855 100644--- a/ui/src/components/onboarding/providers/ProvidersScreen.test.tsx+++ b/ui/src/components/onboarding/providers/ProvidersScreen.test.tsx@@ -79,7 +79,7 @@ const supply = (over: Partial<AgentSupply> & { backend: AgentSupply['backend'] }});const runtimeOf = (health: RuntimeHealth, over: Partial<RuntimeDependency> = {}): RuntimeDependency => ({- contract_version: 15,+ contract_version: 16,manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1.0.0', source_sha: 'sha', assets: [] },status: { verified: true, health },...over,diff --git a/ui/src/components/onboarding/providers/providerStage.test.ts b/ui/src/components/onboarding/providers/providerStage.test.tsindex b88c88ef6..25ddf6a7e 100644--- a/ui/src/components/onboarding/providers/providerStage.test.ts+++ b/ui/src/components/onboarding/providers/providerStage.test.ts@@ -660,7 +660,7 @@ describe('adoptionBackend', () => {});const runtime = (health: RuntimeHealth, over: Partial<RuntimeDependency> = {}): RuntimeDependency => ({- contract_version: 15,+ contract_version: 16,manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1.0.0', source_sha: 'sha', assets: [] },status: { verified: true, health },...over,diff --git a/ui/src/components/settings/models/AgentCard.test.tsx b/ui/src/components/settings/models/AgentCard.test.tsxindex 4c607dc6f..454a5079c 100644--- a/ui/src/components/settings/models/AgentCard.test.tsx+++ b/ui/src/components/settings/models/AgentCard.test.tsx@@ -17,7 +17,7 @@ import { freshRuntimeProjection } from './runtimeLifecycle';import type { AgentSupply, RuntimeDependency, Source } from './types';const runtime: RuntimeDependency = {- contract_version: 15,+ contract_version: 16,manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1.0.0', source_sha: 'fixture', assets: [] },status: { installed_version: '1.0.0', verified: true, listening: null, health: 'ok', last_check: null },};@@ -414,7 +414,7 @@ describe('AgentCard', () => {['zh', 'Backup → claude-opus-4-6(已自动切换)', '打开 claude-opus-4-6 的路由 · Backup → claude-opus-4-6(已自动切换)'],] as const)('derives and announces takeover from the exact current hop in %s', (lng, mappingCopy, accessibleName) => {const key = modelChainKey('claude', 'claude-opus-4-6');- render(<I18nextProvider i18n={localeInstance(lng)}><AgentCard agents={[hubAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ manual_override: {hops:[{source_id:'src_a',model_id:'claude-opus-4-6'},{source_id:'src_b',model_id:'claude-opus-4-6'}]}, route_origin: "manual" as const, contract_version: 15, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'hub', health: 'cooldown', runnable: false, reason: null, retry_at: '2099-01-01T00:00:00Z' }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);+ render(<I18nextProvider i18n={localeInstance(lng)}><AgentCard agents={[hubAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ manual_override: {hops:[{source_id:'src_a',model_id:'claude-opus-4-6'},{source_id:'src_b',model_id:'claude-opus-4-6'}]}, route_origin: "manual" as const, contract_version: 16, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'hub', health: 'cooldown', runnable: false, reason: null, retry_at: '2099-01-01T00:00:00Z' }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);expect(screen.getByText(/Backup/)).toBeTruthy();expect(screen.getByTitle(mappingCopy)).toBeTruthy();expect(screen.getByRole('button', { name: accessibleName })).toBeTruthy();@@ -434,7 +434,7 @@ describe('AgentCard', () => {sources={[source('src_b', 'Backup source')]}chains={{[key]: readyRegion({ manual_override: {hops:[{source_id:'src_b',model_id:'routed-opus'}]}, route_origin: "manual" as const,- contract_version: 15,+ contract_version: 16,backend: 'claude',model_id: 'claude-opus-4-6',current: { source_id: 'src_b', model_id: 'routed-opus' },@@ -467,7 +467,7 @@ describe('AgentCard', () => {it('does not call a later current hop takeover unless the head is unavailable for cooldown', () => {const key = modelChainKey('claude', 'claude-opus-4-6');- render(<I18nextProvider i18n={i18n}><AgentCard agents={[hubAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ manual_override: {hops:[{source_id:'src_a',model_id:'claude-opus-4-6'},{source_id:'src_b',model_id:'claude-opus-4-6'}]}, route_origin: "manual" as const, contract_version: 15, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'native_cli', health: 'healthy', runnable: false, reason: 'native_cli_unavailable', retry_at: null }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);+ render(<I18nextProvider i18n={i18n}><AgentCard agents={[hubAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ manual_override: {hops:[{source_id:'src_a',model_id:'claude-opus-4-6'},{source_id:'src_b',model_id:'claude-opus-4-6'}]}, route_origin: "manual" as const, contract_version: 16, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'native_cli', health: 'healthy', runnable: false, reason: 'native_cli_unavailable', retry_at: null }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);expect(screen.getByText(/Backup/)).toBeTruthy();expect(screen.queryByText(/takeover/i)).toBeNull();});@@ -475,7 +475,7 @@ describe('AgentCard', () => {it('hides current and takeover projections while the runtime is stopped', () => {const key = modelChainKey('claude', 'claude-opus-4-6');const stopped = { ...runtime, status: { ...runtime.status, health: 'down' as const } };- render(<I18nextProvider i18n={i18n}><RuntimeAgentCard runtime={freshRuntimeProjection(readyRegion(stopped))} agents={[hubAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ manual_override: {hops:[{source_id:'src_a',model_id:'claude-opus-4-6'},{source_id:'src_b',model_id:'claude-opus-4-6'}]}, route_origin: "manual" as const, contract_version: 15, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'hub', health: 'cooldown', runnable: false, reason: null, retry_at: '2099-01-01T00:00:00Z' }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenModels={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);+ render(<I18nextProvider i18n={i18n}><RuntimeAgentCard runtime={freshRuntimeProjection(readyRegion(stopped))} agents={[hubAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ manual_override: {hops:[{source_id:'src_a',model_id:'claude-opus-4-6'},{source_id:'src_b',model_id:'claude-opus-4-6'}]}, route_origin: "manual" as const, contract_version: 16, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'hub', health: 'cooldown', runnable: false, reason: null, retry_at: '2099-01-01T00:00:00Z' }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenModels={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);expect(screen.queryByText(/Backup/)).toBeNull();expect(screen.queryByText(/takeover/i)).toBeNull();@@ -487,7 +487,7 @@ describe('AgentCard', () => {const onOpenModels = vi.fn();const key = modelChainKey('claude', 'claude-opus-4-6');const directAgent: AgentSupply = { ...hubAgent, mode: 'direct', sources: null, routes: null, supply_status: null, model_supply: null };- render(<I18nextProvider i18n={i18n}><AgentCard agents={[directAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ manual_override: {hops:[{source_id:'src_a',model_id:'claude-opus-4-6'},{source_id:'src_b',model_id:'claude-opus-4-6'}]}, route_origin: "manual" as const, contract_version: 15, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'hub', health: 'cooldown', runnable: false, reason: null, retry_at: '2099-01-01T00:00:00Z' }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenModels={onOpenModels} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);+ render(<I18nextProvider i18n={i18n}><AgentCard agents={[directAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ manual_override: {hops:[{source_id:'src_a',model_id:'claude-opus-4-6'},{source_id:'src_b',model_id:'claude-opus-4-6'}]}, route_origin: "manual" as const, contract_version: 16, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'hub', health: 'cooldown', runnable: false, reason: null, retry_at: '2099-01-01T00:00:00Z' }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenModels={onOpenModels} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);expect(screen.queryByText(/Adjust priority/i)).toBeNull();expect(screen.queryByRole('button', { name: /route chain/i })).toBeNull();expect(screen.queryByText(/Backup/)).toBeNull();diff --git a/ui/src/components/settings/models/BackendSupplyModeCard.test.tsx b/ui/src/components/settings/models/BackendSupplyModeCard.test.tsxindex 7a8da03a6..cf48d12bf 100644--- a/ui/src/components/settings/models/BackendSupplyModeCard.test.tsx+++ b/ui/src/components/settings/models/BackendSupplyModeCard.test.tsx@@ -34,7 +34,7 @@ const CLAUDE_KEY: MigrationItem = {};const RUNTIME: RuntimeDependency = {- contract_version: 15,+ contract_version: 16,manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1', source_sha: 'a'.repeat(40), assets: [] },status: { installed_version: '1', verified: true, health: 'ok' },};diff --git a/ui/src/components/settings/models/RouteChainDialog.directEdit.test.tsx b/ui/src/components/settings/models/RouteChainDialog.directEdit.test.tsxindex ffa3eeb19..5a549f9be 100644--- a/ui/src/components/settings/models/RouteChainDialog.directEdit.test.tsx+++ b/ui/src/components/settings/models/RouteChainDialog.directEdit.test.tsx@@ -17,7 +17,7 @@ const sources: Source[] = ['a', 'b'].map((id) => ({}));const hops = sources.map((source) => ({ source_id: source.id, model_id: 'gpt-test' }));const makeChain = (backend: AgentSupply['backend'], routeOrigin: 'automatic' | 'passthrough' | 'manual'): AgentChain => ({- contract_version: 15, backend, model_id: 'gpt-test', route_origin: routeOrigin,+ contract_version: 16, backend, model_id: 'gpt-test', route_origin: routeOrigin,manual_override: routeOrigin === 'manual' ? { hops } : null,current: hops[0], supply_state: 'ok',chain: hops.map((hop) => ({ ...hop, channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null })),diff --git a/ui/src/components/settings/models/RouteChainDialog.test.tsx b/ui/src/components/settings/models/RouteChainDialog.test.tsxindex 49ca0508a..8b989ab5c 100644--- a/ui/src/components/settings/models/RouteChainDialog.test.tsx+++ b/ui/src/components/settings/models/RouteChainDialog.test.tsx@@ -57,7 +57,7 @@ const sources: Source[] = [},];const chain: AgentChain = { manual_override: {hops:[{source_id:"src_a",model_id:"claude-opus-5"},{source_id:"src_b",model_id:"opus-5"}]}, route_origin: "manual" as const,- contract_version: 15,+ contract_version: 16,backend: "claude",model_id: "opus-5",current: { source_id: "src_b", model_id: "opus-5" },diff --git a/ui/src/components/settings/models/RouteRecordedTurn.test.tsx b/ui/src/components/settings/models/RouteRecordedTurn.test.tsxindex 6167fa081..590a5c2ad 100644--- a/ui/src/components/settings/models/RouteRecordedTurn.test.tsx+++ b/ui/src/components/settings/models/RouteRecordedTurn.test.tsx@@ -15,7 +15,7 @@ import { PERSISTED_TURN_CONTRACT_VERSIONS } from './types';import type { RouteHop, TurnProvenance } from './types';const record: TurnProvenance = {- contract_version: 15, turn_id: 'turn-recorded', ts: '2026-09-05T15:00:00Z', agent: 'codex', requested_model_id: 'requested-model',+ contract_version: 16, turn_id: 'turn-recorded', ts: '2026-09-05T15:00:00Z', agent: 'codex', requested_model_id: 'requested-model',outcome: 'failed_terminal', failed_attempts: [], served: null, canceled_attempt: null, model_supply_state: null, blockers: [],terminal_error: { source_id: 'src_historical', configured_model_id: 'historical-model', channel: 'hub', reason: 'invalid_parameter', stream_started: false, http_status: 404, upstream_error_code: 'model_not_found' },};diff --git a/ui/src/components/settings/models/RuntimeNotStartedAction.test.tsx b/ui/src/components/settings/models/RuntimeNotStartedAction.test.tsxindex 02b058673..f42034002 100644--- a/ui/src/components/settings/models/RuntimeNotStartedAction.test.tsx+++ b/ui/src/components/settings/models/RuntimeNotStartedAction.test.tsx@@ -31,7 +31,7 @@ const runtime = (? 'unresolved' as const: hostPlatform === 'linux-amd64' ? 'unsupported' as const : 'resolved' as const;return {- contract_version: 15,+ contract_version: 16,...(hostPlatform === undefined ? {} : { host_platform: hostPlatform }),manifest: resolution === 'unresolved'? { name: 'cliproxyapi', resolution, assets: [] }diff --git a/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx b/ui/src/components/settings/models/SettingsModelsPage.render.test.tsxindex bd188a5e1..eda7d536b 100644--- a/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx+++ b/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx@@ -48,7 +48,7 @@ const manifest = {} satisfies RuntimeManifest;const runtime: RuntimeDependency = {- contract_version: 15,+ contract_version: 16,manifest,status: { installed_version: '1', verified: true, health: 'ok' },};@@ -119,7 +119,7 @@ const takeoverAgent: AgentSupply = {};const takeoverChain: AgentChain = { manual_override: {hops:[{source_id:'src_head',model_id:'gpt-5.6-sol'},{source_id:'src_relay',model_id:'gpt-5.6-sol'}]}, route_origin: "manual" as const,- contract_version: 15,+ contract_version: 16,backend: 'codex',model_id: 'gpt-5.6-sol',current: { source_id: 'src_relay', model_id: 'gpt-5.6-sol' },@@ -222,7 +222,7 @@ const routedHubAgent: AgentSupply = {const routedChain: AgentChain = {manual_override: { hops: [{ source_id: retainedSource.id, model_id: routedModelId }] },route_origin: 'manual' as const,- contract_version: 15,+ contract_version: 16,backend: 'claude',model_id: routedModelId,current: { source_id: retainedSource.id, model_id: routedModelId },diff --git a/ui/src/components/settings/models/SupplyGraph.test.ts b/ui/src/components/settings/models/SupplyGraph.test.tsindex d8a9c19b5..ba0aff1b9 100644--- a/ui/src/components/settings/models/SupplyGraph.test.ts+++ b/ui/src/components/settings/models/SupplyGraph.test.ts@@ -7,7 +7,7 @@ import { buildSupplyRelations as buildRelations } from './supplyRelations';import type { AgentChain, AgentSupply, RuntimeDependency, Source } from './types';const runtime: RuntimeDependency = {- contract_version: 15,+ contract_version: 16,manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1.0.0', source_sha: 'fixture', assets: [] },status: { installed_version: '1.0.0', verified: true, listening: null, health: 'ok', last_check: null },};@@ -47,7 +47,7 @@ const agent: AgentSupply = {};const chain = (current: string, headHealth: AgentChain['chain'][number]['health'] = 'healthy', headRunnable = true, reason: AgentChain['chain'][number]['reason'] = null): AgentChain => ({ manual_override: {hops:[{source_id:'native',model_id:'model-a'},{source_id:'relay',model_id:'model-a'},{source_id:'unused',model_id:'model-a'}]}, route_origin: "manual" as const,- contract_version: 15,+ contract_version: 16,backend: 'claude',model_id: 'model-a',current: { source_id: current, model_id: 'model-a' },diff --git a/ui/src/components/settings/models/apiFailure.test.ts b/ui/src/components/settings/models/apiFailure.test.tsindex 5cc35f7a2..935abfe5e 100644--- a/ui/src/components/settings/models/apiFailure.test.ts+++ b/ui/src/components/settings/models/apiFailure.test.ts@@ -33,7 +33,7 @@ afterEach(() => {describe('apiFailure — whether the route named the failure', () => {it('posts installation to the dedicated runtime route', async () => {const runtime = {- contract_version: 15,+ contract_version: 16,manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1', source_sha: 'sha', assets: [] },status: { installed_version: null, verified: false, listening: null, health: 'installing', last_check: null },} as const;diff --git a/ui/src/components/settings/models/gatewayAdoption.test.ts b/ui/src/components/settings/models/gatewayAdoption.test.tsindex f9bc15ad7..9c6c243c4 100644--- a/ui/src/components/settings/models/gatewayAdoption.test.ts+++ b/ui/src/components/settings/models/gatewayAdoption.test.ts@@ -14,7 +14,7 @@ const agent = (mode: AgentSupply['mode']): AgentSupply => ({});const runtime = (health: RuntimeDependency['status']['health']): RuntimeDependency => ({- contract_version: 15,+ contract_version: 16,manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1', source_sha: 'a'.repeat(40), assets: [] },status: { installed_version: health === 'not_installed' ? null : '1', verified: health !== 'not_installed', health },});diff --git a/ui/src/components/settings/models/repair.test.ts b/ui/src/components/settings/models/repair.test.tsindex d64372522..d2a65db68 100644--- a/ui/src/components/settings/models/repair.test.ts+++ b/ui/src/components/settings/models/repair.test.ts@@ -113,6 +113,10 @@ describe('repairAction — the one tap a stopped source offers', () => {// user says they handled it.expect(repairAction(blocked('models.source.needs_action.balance_exhausted'))).toBe('retest');expect(repairAction(blocked('models.source.needs_action.account_banned'))).toBe('retest');+ // A plan without the product is upgraded off-site, then re-checked here.+ expect(repairAction(blocked('models.source.needs_action.plan_excludes_product', subscription))).toBe('retest');+ // So is a spend or usage limit, raised in the vendor's console.+ expect(repairAction(blocked('models.source.needs_action.spend_limit_reached'))).toBe('retest');});it('treats an unclassified error as an upstream cause, not a credential one', () => {diff --git a/ui/src/components/settings/models/routeProjectionReconciliation.test.ts b/ui/src/components/settings/models/routeProjectionReconciliation.test.tsindex 5ca836510..cae668a7d 100644--- a/ui/src/components/settings/models/routeProjectionReconciliation.test.ts+++ b/ui/src/components/settings/models/routeProjectionReconciliation.test.ts@@ -24,7 +24,7 @@ const source: Source = {};const report: RouteReport = {chain: {- contract_version: 15,+ contract_version: 16,backend: "claude",model_id: "模型/opus",manual_override: null,diff --git a/ui/src/components/settings/models/runtimeLifecycle.test.ts b/ui/src/components/settings/models/runtimeLifecycle.test.tsindex 89dc0b858..ef757cdf2 100644--- a/ui/src/components/settings/models/runtimeLifecycle.test.ts+++ b/ui/src/components/settings/models/runtimeLifecycle.test.ts@@ -11,7 +11,7 @@ const asset = (platform: 'darwin-arm64' | 'linux-amd64') => ({});const runtime = (resolution: 'resolved' | 'unresolved' | 'unsupported'): RuntimeDependency => ({- contract_version: 15,+ contract_version: 16,host_platform: 'darwin-arm64',manifest: resolution === 'unresolved'? { name: 'cliproxyapi', resolution, assets: [] }diff --git a/ui/src/components/settings/models/sourceStateClassification.ts b/ui/src/components/settings/models/sourceStateClassification.tsindex b5ce05872..acd4e502e 100644--- a/ui/src/components/settings/models/sourceStateClassification.ts+++ b/ui/src/components/settings/models/sourceStateClassification.ts@@ -32,6 +32,8 @@ export const SOURCE_STATE_CLASSIFICATION = {'models.source.needs_action.balance_exhausted': 'needs_user','models.source.needs_action.credential_revoked': 'needs_user','models.source.needs_action.account_banned': 'needs_user',+ 'models.source.needs_action.plan_excludes_product': 'needs_user',+ 'models.source.needs_action.spend_limit_reached': 'needs_user','models.source.error.unclassified': 'needs_user',},} as const satisfies {diff --git a/ui/src/components/settings/models/sourceStatePresentation.ts b/ui/src/components/settings/models/sourceStatePresentation.tsindex c047567db..cc89682f1 100644--- a/ui/src/components/settings/models/sourceStatePresentation.ts+++ b/ui/src/components/settings/models/sourceStatePresentation.ts@@ -54,6 +54,8 @@ const NEEDS_ACTION_KEY: Readonly<Record<NeedsActionDetailKey, TranslationKey>> ='models.source.needs_action.balance_exhausted': 'settings.models.sourceDetail.status.needsAction.balanceExhausted','models.source.needs_action.credential_revoked': 'settings.models.sourceDetail.status.needsAction.credentialRevoked','models.source.needs_action.account_banned': 'settings.models.sourceDetail.status.needsAction.accountBanned',+ 'models.source.needs_action.plan_excludes_product': 'settings.models.sourceDetail.status.needsAction.planExcludesProduct',+ 'models.source.needs_action.spend_limit_reached': 'settings.models.sourceDetail.status.needsAction.spendLimitReached',};type Rule = (state: SourceState, surface: SourceStateSurface, locale: string, now: number) => SourceStatePresentation;diff --git a/ui/src/components/settings/models/types.ts b/ui/src/components/settings/models/types.tsindex dcae8f9f7..bd31d79dc 100644--- a/ui/src/components/settings/models/types.ts+++ b/ui/src/components/settings/models/types.ts@@ -10,8 +10,8 @@// and the PR records the server implementation and feature-flag activation// edge. The client never synthesizes a fallback payload shape.-export const CONTRACT_VERSION = 15 as const;-export const PERSISTED_TURN_CONTRACT_VERSIONS = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] as const;+export const CONTRACT_VERSION = 16 as const;+export const PERSISTED_TURN_CONTRACT_VERSIONS = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] as const;export const AGENT_CHAIN_CONTRACT_VERSION = CONTRACT_VERSION;export const PROBE_RESULT_CONTRACT_VERSION = CONTRACT_VERSION;@@ -51,6 +51,8 @@ export const NEEDS_ACTION_DETAIL_KEYS = ['models.source.needs_action.balance_exhausted','models.source.needs_action.credential_revoked','models.source.needs_action.account_banned',+ 'models.source.needs_action.plan_excludes_product',+ 'models.source.needs_action.spend_limit_reached',] as const;export type NeedsActionDetailKey = (typeof NEEDS_ACTION_DETAIL_KEYS)[number];@@ -550,6 +552,8 @@ export type ResolutionReason =| 'credential_revoked'| 'balance_exhausted'| 'account_banned'+ | 'plan_excludes_product'+ | 'spend_limit_reached'| 'permission_denied'| 'unclassified_error'| 'no_enabled_source'diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex abc9d5247..f50ec9ba9 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -2163,7 +2163,9 @@"oauthExpired": "Sign in again","balanceExhausted": "Out of balance","credentialRevoked": "Credential revoked",- "accountBanned": "Account restricted"+ "accountBanned": "Account restricted",+ "planExcludesProduct": "Plan doesn't include Codex",+ "spendLimitReached": "Usage limit reached"},"error": "Error","standbyHintLabel": "What this status means",@@ -2645,7 +2647,9 @@"oauth_expired": "Needs a new sign-in","balance_exhausted": "Out of balance — top it up","credential_revoked": "Credential revoked — enter a new one",- "account_banned": "Account is restricted"+ "account_banned": "Account is restricted",+ "plan_excludes_product": "Plan doesn't include Codex — upgrade it or use another Source",+ "spend_limit_reached": "Usage limit reached — raise it or use another Source"},"error": {"unclassified": "Unknown error — temporarily unavailable"@@ -5087,6 +5091,8 @@"credential_revoked": "Credential revoked","balance_exhausted": "Balance exhausted","account_banned": "Account suspended",+ "plan_excludes_product": "Plan doesn't include this product",+ "spend_limit_reached": "Usage limit reached","permission_denied": "Permission denied","unclassified_error": "Unclassified upstream error","no_enabled_source": "No source is enabled",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 7701f659a..90c549298 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -2163,7 +2163,9 @@"oauthExpired": "需要重新登录","balanceExhausted": "余额用完","credentialRevoked": "凭据被吊销",- "accountBanned": "账号被限制"+ "accountBanned": "账号被限制",+ "planExcludesProduct": "套餐不含 Codex",+ "spendLimitReached": "已达用量上限"},"error": "异常","standbyHintLabel": "这个状态是什么意思",@@ -2645,7 +2647,9 @@"oauth_expired": "需要重新登录","balance_exhausted": "余额不足,需要充值","credential_revoked": "凭据已失效,需要重新填写",- "account_banned": "账号被限制使用"+ "account_banned": "账号被限制使用",+ "plan_excludes_product": "套餐不含 Codex,需要升级套餐或改用其他供应商",+ "spend_limit_reached": "已达用量上限,需要提高上限或改用其他供应商"},"error": {"unclassified": "未知错误,暂时不可用"@@ -5087,6 +5091,8 @@"credential_revoked": "凭据已吊销","balance_exhausted": "余额不足","account_banned": "账号被封禁",+ "plan_excludes_product": "套餐不含此产品",+ "spend_limit_reached": "已达用量上限","permission_denied": "无权限","unclassified_error": "未分类的上游错误","no_enabled_source": "没有已启用的供应商",diff --git a/vibe/i18n/en.json b/vibe/i18n/en.jsonindex 2a6e36f19..035f4280f 100644--- a/vibe/i18n/en.json+++ b/vibe/i18n/en.json@@ -1209,6 +1209,8 @@"credential_revoked": "credential revoked","balance_exhausted": "balance exhausted","account_banned": "account unavailable",+ "plan_excludes_product": "plan excludes this product",+ "spend_limit_reached": "usage limit reached","unclassified_error": "unclassified source error","no_enabled_source": "no source is enabled","no_eligible_source": "no source is eligible",diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.jsonindex ff8fb21b7..9e96ad6e0 100644--- a/vibe/i18n/zh.json+++ b/vibe/i18n/zh.json@@ -1209,6 +1209,8 @@"credential_revoked": "凭证已撤销","balance_exhausted": "余额不足","account_banned": "账户不可用",+ "plan_excludes_product": "套餐不含此产品",+ "spend_limit_reached": "已达用量上限","unclassified_error": "供应商发生未知错误","no_enabled_source": "没有已启用的供应商","no_eligible_source": "没有适用的供应商",