Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

docs(reports): carry the Alibaba billing-products and black-box reports

Jack Rudenko9d0e2faf6e75
diff --git a/ai-docs/reports/alibaba-billing-products/report.md b/ai-docs/reports/alibaba-billing-products/report.md
new file mode 100644
index 00000000..ab197e13
--- /dev/null
+++ b/ai-docs/reports/alibaba-billing-products/report.md
@@ -0,0 +1,152 @@
+# Report — Alibaba Cloud billing products as distinct products
+
+> **Ported 2026-09-19** from branch `worktree-qwen-token-plan` (`1e5e157`) onto `eceab30`.
+> This is that branch's report, not a report on HEAD. Provider names, shortcuts,
+> variables and labels are translated to HEAD's everywhere, including inside quoted code
+> and output, and the retired term for a per-credential model list is now *dynamic models
+> catalog*. Quoted material is therefore not byte-verbatim. Passages about the
+> metered-fallback billing gate, which HEAD does not carry, are removed.
+>
+> **What differs at HEAD.** `qwen-coding` leads both bare Qwen routing chains (`qwen3.*`,
+> `qwen3-*`); on that branch it was explicit access only. So R9 below does not hold at
+> HEAD: for a user holding `QWEN_CODING_PLAN_API_KEY`, the public `coding-intl…/v1/models`
+> list is fetched and read as the account's answer. HEAD keeps the discovery result as a
+> bare list with a five-minute in-memory TTL, not the three-state status and few-second
+> memo described below. Three-valued credential readiness is not in HEAD.
+
+Branch `worktree-qwen-token-plan`, eight signed commits from baseline `b7a7868`.
+Depth: full · Automation: autonomous · Session `dev-feature-alibaba-subscript-20260917`.
+
+**Read the "not done" section before treating anything here as finished.**
+
+---
+
+## What the request asked for, and what it turned out to be
+
+The request said claudish supported Token Plan but lacked Coding Plan support. The code
+said the opposite. Both readings were half right, and the reason was the defect:
+
+```
+name: "qwen-token-plan"
+displayName: "Qwen Plan" ← names neither product
+baseUrl: "token-plan.ap-southeast-1.maas.aliyuncs.com" ← Token Plan host
+apiKeyUrl: ".../model-studio/claude-code" ← Coding Plan documentation
+```
+
+One provider entry wore both products' clothes. A user following that link believed they
+had configured the Coding Plan; their requests went to Token Plan. The work therefore
+became *make the products distinct*, not *add a provider*.
+
+## Commits
+
+Six of the branch's eight commits. The other two belong to work not carried to HEAD.
+
+| SHA | Scope |
+|---|---|
+| `c0ac7d8` | product naming, eligibility, capability, credential readiness, error clarity |
+| `fe8722e` | stop persisting the dynamic models catalog (−429 lines) |
+| `83f9afb` | rename the retired term to *dynamic models catalog* (71 files, behaviour identical) |
+| `6b627f1` | black-box tests written without sight of the implementation |
+| `80ff29b` | record what was measured and what is still unverified |
+| `0ba1bfa` | three products, three credentials, three providers — `qwen-coding` added |
+
+All verify `G` (good signature).
+
+## Tests
+
+| Point | pass | skip | fail |
+|---|---:|---:|---:|
+| Baseline, before `bun install` | 3119 | 17 | **17** |
+| Baseline, after `bun install` | 3417 | 19 | 0 |
+| Final | **3657** | 19 | **0** |
+
+The first baseline was environmental: this worktree had **no `node_modules`**, so Bun was
+resolving from the main checkout. Taking it at face value would have blamed 17 phantom
+failures on this feature.
+
+## Requirements
+
+| # | Requirement | Status |
+|---|---|---|
+| R1 | Four products named distinctly end to end | **Met** — verified in the live request path: `[Alibaba Token Plan] Response status: 200` |
+| R2 | Eligibility from live per-account data, never pinned | **Met** — no pinned model list in `src/`; the dynamic models catalog is never persisted |
+| R3 | Individual and Team coverage distinct | **Met by construction** — per-seat keys mean coverage is per-credential; nothing is cached across identities |
+| R4 | Subscription-first selection | **Met** — chain order verified through the repo build |
+| R5 | User can tell which product serves a request | **Met** — provider and billing named in probe, preflight and logs |
+| R6 | Clear explanation for credential / quota / unsupported / uncertain | **Met** — four distinct hints; silo-isolation clause driven by `siblingKeyEnvVars` |
+| R8 | A failed refresh preserves accepted state | **Met differently than specified** — nothing is stored, so a failed refresh *denies nothing*. Stronger than remembering |
+| R9 | Public availability never implies entitlement | **Met on that branch** — `coding-intl/v1/models` is unauthenticated and was used nowhere as evidence. Not true at HEAD (see the note at the top) |
+| R10 | Stock shortage cannot erase coverage | **Met** — no availability signal gates a configured subscription |
+| R11 | Capability-aware selection | **PARTIALLY MET** — see below |
+| R12 | Existing Token Plan and PAYG setups keep working | **Met** — verified live, unchanged from the before-snapshot |
+
+## NOT done, and why — read this section
+
+**The Coding Plan request path is UNVERIFIED — its AUTHENTICATION, not its route.** A
+dedicated provider now exists (`0ba1bfa`): `qcode@` → `qwen-coding`, with
+`QWEN_CODING_PLAN_API_KEY`, `modelDiscovery.path: "/v1/models"` and membership in
+`SUBSCRIPTION_PROVIDERS`. The route is **verified-reachable**, probed 2026-09-18:
+`coding-intl…/apps/anthropic/v1/messages` rejects a bogus key in its own wording,
+`invalid access token or token expired`, where `token-plan…` says `Invalid API-key
+provided.` — so the reply identifies which host served it. Entitlement is the open half.
+No key exists and none is purchasable; measured 2026-09-17, the stored `sk-sp-` key is
+rejected by `coding-intl` byte-identically to a fabricated key, across both API surfaces
+and all three header shapes, with a passing control on the Token Plan host proving the
+probe discriminates. Nothing here claims a request on that path succeeds — reachable is
+not entitled.
+
+**The blank-`BASE_URL` guard is dead code — a fix this branch CLAIMED and does not have.**
+`resolveBaseUrl` treats `QWEN_TOKEN_PLAN_BASE_URL=""` as unset and falls back to the
+vendor host, so the `unreachable` branch the design lists as fixed cannot be reached by
+any provider with a static `baseUrl`. Found by the black-box tests, confirmed live,
+quarantined with its test and failure at `ai-docs/reports/blackbox-tests-alibaba/quarantine/`.
+Not repaired because empty-means-unset affects every provider and every base-URL
+variable. The same holds at HEAD.
+
+**R11 is PARTIALLY MET.** The video gap is closed by name patterns
+(`happyhorse-1.1-t2v/i2v/r2v` were classified as chat). No authoritative capability
+source exists for an arbitrary id: `ModelDoc.capabilities` has no `video` key. A bug
+report was filed for models-index on that branch; it is not carried here.
+
+**Two HIGH code-review findings are deferred**, each with 1-of-4 reviewer support and
+contested by others: catalog-sourced denial overriding non-fresh per-account evidence
+(its fix rewrites a test three reviewers call a correct control), and the dynamic models
+catalog memo key taking a display label rather than credential provenance (its fix needs
+provenance the credential authority does not return). The mechanisms were recorded in
+that branch's code-review consolidation, which is not carried here.
+
+**Known residuals declared by implementers**: `auth/antigravity-token.ts`'s
+`defaultReadStore` still collapses a locked keychain into `null`, as do the devin and
+grok file readers.
+
+## Review gates
+
+- **plan-review round 1: FAIL** (6 CRITICAL). Revised.
+- **plan-review round 2: FAIL** (6 CRITICAL, 8 HIGH). Revision limit reached.
+- **plan-review: OVERRIDDEN BY THE USER.** Shown the surviving findings and the option to
+ ship only the uncontested half, the user chose to implement in full. **This is not a
+ passed gate.**
+- **code-review: FAIL** (1 CRITICAL, 5 HIGH merged). The CRITICAL and 3 HIGHs fixed.
+- **Two reviewers graded against their own thresholds**, including the internal reviewer,
+ which returned PASS on 1 HIGH (dispatched rule: CONDITIONAL), enumerated its findings
+ twice with inconsistent counts, and lost the body of one finding. **That PASS was quoted
+ to the user before this was known; it is retracted.**
+
+## What the process actually caught
+
+**The multi-model plan gate** found that the first credential fix was *relocated, not
+resolved*: `describeReadiness()` produced `"failed"` only on a throw, in modules
+annotated "NEVER THROWS". The type was honest; the third state was unreachable.
+
+**The black-box tests** — written by a model that never saw the implementation — found
+defects that four reviewers and 125 self-written tests missed, among them the dead
+blank-`BASE_URL` guard above, and classified **zero** tests as "wrong". Where they
+disagreed with the code, the code was wrong.
+
+## One fact that outlives this task
+
+**`grep` silently under-reports in this repo.** `providers/model-resolvers/devin.ts` and
+`adapters/grok-effort-support.ts` contain literal NUL bytes, so grep treats them as binary
+and returns nothing from them. Nineteen occurrences were invisible to every repo-wide
+sweep, including baseline counts quoted during this work. Recorded in
+`ai-docs/architecture/debugging.md`.
diff --git a/ai-docs/reports/alibaba-billing-products/validation-results.md b/ai-docs/reports/alibaba-billing-products/validation-results.md
new file mode 100644
index 00000000..848c60fc
--- /dev/null
+++ b/ai-docs/reports/alibaba-billing-products/validation-results.md
@@ -0,0 +1,160 @@
+# Phase 7 — validation results
+
+> **Ported 2026-09-19** from branch `worktree-qwen-token-plan` (`1e5e157`) onto `eceab30`.
+> These are that branch's results, not a run of HEAD. Provider names, shortcuts,
+> variables and labels are translated to HEAD's everywhere, including inside quoted
+> commands and output, so quoted material is not byte-verbatim. The metered-fallback
+> billing gate's validation (V3 on that branch) is removed, because HEAD does not carry
+> the gate. At HEAD a bare `qwen3.*` chain starts with the Alibaba Coding Plan when
+> `QWEN_CODING_PLAN_API_KEY` is set, so V4's chain would gain a first row on a machine
+> holding that key.
+
+Run 2026-09-18 against the **repo build** (`packages/cli/dist/index.js`, `bun run build`),
+not the global binary. That distinction matters: `preflight` through the claudish MCP
+server runs the **released** global install, so an after-comparison there would
+re-measure v9.4.0 and report no change whatever was implemented.
+
+Commit under test: `6b627f1`. Suite: **3657 pass / 19 skip / 0 fail** across 237 files.
+
+---
+
+## V6 — end-to-end run — **PASS**, with log evidence
+
+Command (run in an isolated pane, per the project rule against running claudish in the
+main shell):
+
+```
+bun run packages/cli/dist/index.js --model [email protected] --debug -p "Reply with exactly: VALIDATION_OK"
+```
+
+Output: `VALIDATION_OK`
+
+Debug log `~/.claudish/logs/claudish_2026-09-17_17-25-13.log`:
+
+```
+[Proxy] Handler: provider=qwen-token-plan, model=qwen3.7-plus
+[Proxy] Created qwen-token-plan handler (composed): qwen3.7-plus
+[Alibaba Token Plan] Response status: 200
+```
+
+Two things proven here, not inferred:
+
+1. The request was served by **`qwen-token-plan`** — the subscription — and returned 200.
+2. The log line says **"Alibaba Token Plan"**. The naming fix reaches the **live request
+ path**, not merely a display surface. This is the defect that started the task:
+ previously one entry called itself "Qwen Plan" while linking users to Coding Plan
+ documentation.
+
+## V4 — back-compat — **PASS**
+
+`providers` through the repo build:
+
+```
+✓ qwen-token-plan env
+· qwen-payg —
+```
+
+`qwen-token-plan` resolves (the Keychain write-through is classified `env` by design, per
+`ai-docs/architecture/keychain.md`); `qwen-payg` is correctly unconfigured, since no
+`DASHSCOPE_API_KEY` exists on this machine.
+
+`--probe qwen3.8-max` returns the designed chain order:
+
+```
+1 Alibaba Token Plan [email protected]
+2 OpenCode Zen Go [email protected]
+3 Alibaba PAYG [email protected]
+4 OpenRouter accounts/fireworks/models/qwen3p8-max
+```
+
+Subscription first, metered after — unchanged from the before-snapshot in
+`before-routing.md`, and the display name is now correct.
+
+### One result that needed a control before it could be read
+
+`--probe` reports `○ missing` for `[email protected]` even though the credential resolves.
+That looks like a regression from the credential work, so it was checked against the
+**released v9.4.0 binary**, which predates every change here:
+
+```
[email protected] qwen-token-plan · 0/1 live ○ missing
+```
+
+Identical. This is **pre-existing** and explained in `keychain.md`: `describeSourceSync`
+decides the readiness dot and **cannot await**, so a keychain-only provider renders as
+unconfigured while working perfectly at request time — which V6 above demonstrates.
+
+Without that control the finding would have been reported as a regression this change
+introduced.
+
+## V5 — TUI — **PASS on its stated purpose, PARTIAL on coverage**
+
+The config TUI was driven in a tmux pane and rendered as PNG (not text capture), because
+the failure this check exists to catch — a module-level `const` snapshotting the palette
+before theme detection runs — is invisible to text.
+
+Rendered correctly: tab bar, provider table, status/auth columns, the detail panel and
+the key legend, with theme colours applied live.
+
+**Partial:** the Alibaba rows sit below the not-configured divider (same
+`describeSourceSync` limitation as above) and the list is clipped at this pane height.
+`PageDown` is not bound and stepping there would have taken ~15 further round trips, so
+the naming was verified through the `providers` listing instead. The palette question —
+V5's actual purpose — is answered.
+
+Evidence: screenshots captured in-session; navigation confirmed working (selection moved
+Antigravity → Devin under a single `Down`).
+
+## V1 — live silo behaviour — **PASS**
+
+Proven live at the start of this work and unchanged by it:
+
+| Host | Credential | Result |
+|---|---|---|
+| `token-plan…` | stored key | **200** (and again in V6 above) |
+| `coding-intl…/v1/models` | none, bogus, real | **200 with no key** — unauthenticated, never entitlement evidence |
+| `dashscope-intl…` | Token Plan key | **401** `Incorrect API key provided` |
+
+## V2 — capability filtering — **PASS**, covered by a tracked test
+
+`packages/cli/src/providers/transport/chat-capability.test.ts` asserts all 25 live Token
+Plan ids and all 10 Coding Plan ids classify correctly, and that the three `happyhorse-*`
+video ids are **not** chat. Reverting the video patterns reddens 14 tests naming exactly
+those three ids.
+
+This began as a probe in the gitignored session directory; it was promoted to a tracked
+test precisely so the guard survives the worktree. That test file is not carried to
+HEAD; HEAD has the video name patterns themselves (`providers/transport/probe-discovery.ts`).
+
+---
+
+## NOT verified, and reported as such
+
+**The Coding Plan request path is UNVERIFIED — its AUTHENTICATION, not its route.** Since
+`0ba1bfa` the product has its own provider entry (`qcode@` → `qwen-coding`,
+`QWEN_CODING_PLAN_API_KEY`, discovery on `/v1/models`), so it is **built**. It is also **verified-reachable**, probed 2026-09-18: a bogus key sent
+to `coding-intl…/apps/anthropic/v1/messages` draws that host's own wording, `invalid
+access token or token expired`, where `token-plan…` answers `Invalid API-key provided.`
+The host that answers identifies itself.
+
+**Entitled is the state still missing.** No Coding Plan key exists, and the user reports
+none is purchasable. Measured 2026-09-17: the stored `sk-sp-` key is rejected by
+`coding-intl` byte-identically to a fabricated key, across both API surfaces and all
+three header shapes, with a passing control on the Token Plan host proving the probe
+discriminates. Nothing in this change claims that path works — and nothing here says the
+plan was unreachable before `0ba1bfa`, because the documented Token Plan base-URL
+override did reach it.
+
+**The blank-`BASE_URL` guard is dead code** — found by the black-box tests, quarantined
+at `ai-docs/reports/blackbox-tests-alibaba/quarantine/`. `resolveBaseUrl` treats `""` as
+unset, so the `unreachable` branch the design lists as fixed cannot be reached by any
+provider with a static `baseUrl`. A claimed fix that does not work. The same holds at HEAD.
+
+**R11 capability-aware selection: PARTIALLY MET.** The video gap is closed by name
+patterns; no authoritative capability source exists for an arbitrary id, because
+`ModelDoc.capabilities` has no `video` key. Bug report filed for models-index.
+
+**R8 completeness: DETECTED, NOT PROVEN.** Alibaba publishes no total, no pagination and
+no continuation signal. Now less consequential than at design time: nothing is persisted,
+so an undetectably partial response cannot overwrite accepted state — it can only fail to
+confirm, and a non-fresh result denies nothing.
diff --git a/ai-docs/reports/blackbox-tests-alibaba/blackbox-results.md b/ai-docs/reports/blackbox-tests-alibaba/blackbox-results.md
new file mode 100644
index 00000000..aae92826
--- /dev/null
+++ b/ai-docs/reports/blackbox-tests-alibaba/blackbox-results.md
@@ -0,0 +1,328 @@
+# Black-box behaviour suite — integration results
+
+> **Ported 2026-09-19** from branch `worktree-qwen-token-plan` (`6b627f1`) onto `eceab30`.
+> These are that branch's results. Provider names, shortcuts and variables are
+> translated to HEAD's everywhere, including inside quoted test titles and output, and
+> the retired term for a per-credential model list is now *dynamic models catalog*, so
+> quoted material is not byte-verbatim. The suite for the metered-fallback billing gate,
+> which HEAD does not carry, is removed with every row and finding about it; the counts
+> below exclude it.
+>
+> **At HEAD only two pieces exist:** `test-helpers/blackbox-env.ts` and
+> `handlers/shared/model-unsupported.blackbox.test.ts` (E1–E4, whose two `Model not exist`
+> cases failed on `eceab30` and pass once that wording is recognised). The discovery,
+> availability, probe-discovery and credential-type suites need APIs HEAD lacks: an
+> exported parser returning `{models, dropped, total}`, `discoverDynamicCatalog`,
+> `_setDynamicCatalogForTest`, `splitByChatCapability`, and `readinessDetail`.
+
+The 125 tests already in this branch were written by the agents that wrote the
+code, in the same pass. They are implementation-coupled regression tests. This
+suite is the only independent behaviour check in the change: `gpt-6-astra` wrote
+it inside a sandbox containing the spec, the acceptance criteria, the measured
+facts, and `.d.ts` contracts with every function body stripped — and no
+implementation file at all. Blindness was enforced by the FILE SYSTEM, not by an
+instruction (`qa/inputs.json`), and the writer's own `Files Read` list contains
+no path outside the sandbox, so nothing here is marked SUSPECT.
+
+Its value comes entirely from the writer not having seen the code. Therefore:
+**no assertion was edited to make a test pass.** Where a test failed and was
+right, the finding is below with the failure output pasted. Where a test targeted
+API that no longer exists, it was moved aside and recorded as obsolete, never
+rewritten into something green.
+
+**Result: 64 kept and passing, 1 quarantined as a real defect, 29 dropped as
+obsolete-by-design-change, 0 dropped as wrong.** Suite on that branch:
+**3657 pass / 19 skip / 0 fail** across 237 files (baseline 3557/19/0 across 231).
+
+---
+
+## 1. Where the tests live
+
+Colocated with the module each covers, `foo.ts` → `foo.blackbox.test.ts`. Most of
+the names collide with an existing implementation-coupled test file; the
+`.blackbox.` infix is the provenance marker and is the convention to reuse for
+any future blind suite. Nothing was overwritten.
+
+| Black-box file | Covers | Tests |
+|---|---|---|
+| `packages/cli/src/providers/model-discovery.blackbox.test.ts` | `providers/model-discovery.ts` | 20 |
+| `packages/cli/src/providers/model-availability.blackbox.test.ts` | `providers/model-availability.ts` | 6 |
+| `packages/cli/src/providers/transport/probe-discovery.blackbox.test.ts` | `providers/transport/probe-discovery.ts` | 28 |
+| `packages/cli/src/handlers/shared/model-unsupported.blackbox.test.ts` | `handlers/shared/model-unsupported.ts` | 8 |
+| `packages/cli/src/auth/credentials/types.blackbox.test.ts` | `auth/credentials/types.ts` | 2 |
+| `packages/cli/src/test-helpers/blackbox-env.ts` | shared isolation helper | — |
+
+`test-env.ts` became `test-helpers/blackbox-env.ts`, next to the repo's existing
+`test-helpers/credential-gate.ts` and `test-helpers/provider-quota.ts`. It
+duplicates neither. Its rewrite is the one substantial adaptation and is
+explained in §4.
+
+---
+
+## 2. Outcome by test
+
+`PASS` = the implementation satisfies an independently written expectation.
+
+### `model-discovery.blackbox.test.ts` — 20 kept, 1 quarantined, 4 obsolete
+
+| ID | Outcome | What it proves / why dropped |
+|---|---|---|
+| D1 × `owned_by` / `ownedBy` | PASS | Both measured wire spellings parse; a new id survives; no capability or context window is invented. |
+| D2 × missing / null / object container, null body | PASS | `total: null`, no rows. "No parseable container" is not a valid empty enumeration. |
+| D3 | PASS | A real `data: []` is `{models:[],dropped:0,total:0}` — distinguishable from D2. |
+| D4 × null / scalar / missing-id / numeric-id / empty-id row | PASS | A lost row is COUNTED. A truncated parse is never labelled complete. |
+| D5 | PASS | An all-invalid enumeration reports three drops, not a genuine empty plan. |
+| D6 | PASS | A three-model generated catalog parses; no vendor minimum or whitelist. |
+| D7 × `context_length` / `context_window` / `max_context_length` | PASS | The account's own window survives each documented spelling; nothing is hardcoded. |
+| D10 × Token Plan host, PAYG host | PASS | The diagnostic names the exact rejecting hostname, not a generic "check your key". |
+| D11 | PASS | A provider with no `modelDiscovery` is `not-declared` with no `failure` — absent, not a transport failure. |
+| **D12** | **FAIL — test right → QUARANTINED** | See the D12 finding in §3. |
+| D8 × stale / incomplete | OBSOLETE | Parameterised only over statuses deleted in `fe8722e` (decision D-K). |
+| D9 × stale / incomplete | OBSOLETE | Same. The "deliberate sizing exception" has no weak state left to draw on. |
+
+### `model-availability.blackbox.test.ts` — 6 kept, 4 obsolete
+
+| ID | Outcome | What it proves / why dropped |
+|---|---|---|
+| A1 × fresh | PASS | A generated wire id in a fresh account catalog is `serves`. Not satisfiable by any shipped model list. |
+| A2 × fresh | PASS | A missing id is `not-served` ONLY when complete fresh evidence exists. |
+| A3 × failed | PASS | A failed refresh neither confirms nor denies — `unknown`. This is the money-asymmetry: weak evidence may not drop a paid subscription. |
+| A3 × not-declared | PASS | An undeclared discovery is equally non-committal. |
+| A4 | PASS | Membership follows the WIRE id, never the row's display label. |
+| A5 | PASS | A smaller complete fresh catalog legitimately removes one id while retaining another — no fixed count, no union-forever, no cached eligibility. |
+| A1/A2 × stale, A1/A2 × incomplete | OBSOLETE | Both statuses deleted in `fe8722e`. |
+
+### `probe-discovery.blackbox.test.ts` — 28 kept
+
+| ID | Outcome | What it proves |
+|---|---|---|
+| K1 × 9 measured ids | PASS | Image, audio and the documented cross-edition video ids classify `not-chat` and are excluded. |
+| K2 × 9 general forms | PASS | Video is a NAMING rule, not a whitelist of the three measured ids: boundaries, case and other vendors all match (`qa_i2v_next`, `qa.r2v.next`, `T2V-01`, `veo-3`, `sora-2`). |
+| K3 | PASS | A wildcard deployment route is not a concrete model to offer. |
+| K4 | PASS | A generated catalog-unknown id is `unknown` and STILL OFFERED — not rounded to `chat`, not hidden. |
+| K5 × qwen-vl, gemini-vision, qa-t2vector, qa-sorafenib, qa-veolia | PASS | Video patterns do not swallow vision INPUT models or unanchored substrings. The negative control on the regex set. |
+| K6 | PASS | The split keeps unknown rows, duplicate occurrences, attached row data and within-group order, and does not mutate its input. |
+| K7 | PASS | Probe RANKING uses the same filter as the classifier — the selection path was not left on an obsolete permissive one. |
+| K8 | PASS | An all-non-chat catalog yields no candidate rather than falling back to the first image row. |
+
+### `model-unsupported.blackbox.test.ts` — 8 kept
+
+| ID | Outcome | What it proves |
+|---|---|---|
+| E1 × raw / enveloped `Model not exist`, Zen Go wording | PASS | Alibaba's measured wording is recognised regardless of HTTP status or response envelope. |
+| E2 × InvalidApiKey / invalid access token or token expired / Incorrect API key provided | PASS | A credential rejection is NOT classified as model exclusion. The false-positive direction (sending a user with a broken key to audit their model name) is closed. |
+| E3 | PASS | A vendor opt-in URL is detected as actionable and is not confused with model absence. |
+| E4 | PASS | A plain key error does not pretend to carry an action link. |
+
+### `types.blackbox.test.ts` — 2 kept
+
+| ID | Outcome | What it proves |
+|---|---|---|
+| T1 | PASS | A vault exception keeps the sentence the user can act on — not erased, not `[object Object]`. |
+| T2 | PASS | A 40 000-line SDK dump becomes ONE bounded line that still contains the headline. |
+
+### The on-disk store suite — 17 declarations (S1–S17, 21 expanded) — ALL OBSOLETE
+
+It targets the seven exported symbols of the store module that persisted the dynamic
+models catalog: its identity fingerprint, salt, write, lookup, read, clear and
+maximum-age constant. Every one was deleted with that module (396 lines) in
+`fe8722e`, decision **D-K: stop persisting the dynamic models catalog**. There is no
+store, so there is no cache key, no salted fingerprint, no thirty-day retention
+window and no expiry state. S1–S17 are not failing tests; they address a module
+that does not exist, and rewriting them into something that passes would have
+produced 21 green assertions about nothing. The file was preserved on that branch;
+it is not carried here.
+
+Worth recording rather than merely deleting: the removal of the store is what
+makes S1's whole class of defect (one credential identity inheriting another
+seat's entitlement) *impossible* rather than *tested*, and it is the same change
+that removed the variable that switched the store off — a variable the blind
+writer still set, from the contract it was given.
+
+---
+
+## 3. Defects found by tests whose author had never seen the code
+
+### The D12 finding — the blank-`*_BASE_URL` guard is dead code for every provider with a static `baseUrl` (NOT fixed, quarantined)
+
+Caught by D12. Failure, verbatim:
+
+```
+src/providers/model-discovery.blackbox.test.ts:
+119 | test("D12 a blank Token Plan endpoint is a failure, not an absent subscription list", async () => {
+120 | process.env.QWEN_TOKEN_PLAN_BASE_URL = "";
+121 | const result = await discoverDynamicCatalog(provider);
+122 | expect(result.status).toBe("failed");
+123 | expect(result.models).toEqual([]);
+124 | expect(result.failure?.kind).toBe("unreachable");
+ ^
+error: expect(received).toBe(expected)
+
+Expected: "unreachable"
+Received: "no-credentials"
+
+ at <anonymous> (.../packages/cli/src/providers/model-discovery.blackbox.test.ts:124:34)
+(fail) discovery failures identify the rejecting silo > D12 a blank Token Plan endpoint is a failure, not an absent subscription list [0.73ms]
+
+ 20 pass
+ 1 fail
+```
+
+The writer took this from the design document it was handed
+(`contract/behaviour-spec.md`, architecture.md §4.2), which lists it as the FIRST
+of "the two collapse sites, fixed":
+
+> `model-discovery.ts:423` — `if (!baseUrl) return [];` becomes
+> `return recordFailure({ kind: "unreachable", … detail: "no base URL resolved — check " + … })`.
+> **A blank `QWEN_TOKEN_PLAN_BASE_URL` override currently reads as "this plan lists no models".**
+
+That premise is wrong about `resolveBaseUrl`, which skips empty values
+(`if (v) return v`) and falls through to the provider's static `baseUrl`. The
+guard was written and is correct; the case it names cannot reach it. Confirmed
+directly — a blank override silently reverts to the vendor default host, while a
+non-blank one is honoured:
+
+```
+{"override":"","status":"failed","failure":{"kind":"no-credentials","provider":"qwen-token-plan",
+ "endpoint":"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/models"}}
+{"override":"https://qa-override.invalid","status":"failed","failure":{"kind":"no-credentials",
+ "provider":"qwen-token-plan","endpoint":"https://qa-override.invalid/compatible-mode/v1/models"}}
+```
+
+(`no-credentials` rather than a 401 only because the QA environment holds no
+Token Plan key. On a machine that HAS one, a blank override sends a real,
+credentialed request to the DEFAULT host — the user's override is discarded with
+no diagnostic at all, which is the more interesting half.)
+
+What R6/R8 actually demand is satisfied: the status is `failed`, not an empty
+plan, so a misconfiguration is never reported as "your subscription lists no
+models". What is NOT satisfied is the diagnostic — it names neither the setting
+nor the misconfiguration, and the architecture document's claim #1 is not true of
+the shipped code.
+
+**Not fixed**, because the fix is not obviously correct: distinguishing
+"declared but empty" from "unset" in `resolveBaseUrl` changes what an empty
+`*_BASE_URL` means for EVERY provider and every base-URL env var, and `FOO=` is
+a common shell idiom for "leave it at the default". That is a decision for the
+contract owners, not a repair to smuggle in under a QA phase.
+
+Quarantined, not skipped and not deleted — the blind writer's own rule was "no
+`test.todo()` entries to make a report look green", and a skipped test in the
+suite is the same thing. The test, its failure and the root cause:
+`quarantine/` beside this file. The removal is marked in place, in
+`model-discovery.blackbox.test.ts`, with the reason.
+
+---
+
+## 4. Counts, and every adaptation with its reason
+
+Counted in EXPANDED cases — each parameterised row is one test, which is how the
+runner counts and how the plan enumerates its inputs.
+
+| | Count |
+|---|---|
+| Delivered by the blind writer | **94** across 6 files |
+| **Kept and passing** | **64** across 5 files |
+| **FAIL, test right → quarantined** | **1** — D12 |
+| **OBSOLETE by design change** | **29** |
+| **FAIL, test wrong → dropped or repaired** | **0** |
+
+Obsolete arithmetic: the store suite S1–S17 = 21 expanded cases (S1 expands ×5)
++ `D8`/`D9` × {stale, incomplete} = 4 + `A1`/`A2` × {stale, incomplete} = 4.
+All 29 trace to one commit, `fe8722e` / decision **D-K**. 64 + 1 + 29 = 94.
+
+### Adaptations, and which tests are still independent evidence
+
+**Every kept test's assertions are byte-identical to what the blind writer
+produced.** Nothing in the list below changes an expected value, so all 64 keep
+their standing as independent evidence.
+
+1. **Import rewiring (all 5 files).** `../contract/*` stems are declaration files
+ with no runtime. Repointed at the real modules; `await import()` became a
+ static import where nothing depended on load ordering any more.
+
+2. **Renamed symbols (2 files).** Three symbols named with the retired term became
+ `DynamicCatalogStatus`, `discoverDynamicCatalog` and
+ `_setDynamicCatalogForTest`. The seed seam
+ also LOST its per-seat argument (`(provider, seat, models, opts)` →
+ `(provider, models, opts)`) because the credential fingerprint went with the
+ disk store; the calls dropped `"qa-seat"`.
+
+3. **Removed API (2 files).** `discoverDynamicCatalog` takes no `{ cachePath }`
+ — there is nothing to persist, so there is no path to redirect. D11 was
+ otherwise unchanged.
+
+4. **`test-env.ts` → `test-helpers/blackbox-env.ts` — the one substantial
+ rewrite, and it touches no test.** The original relocated `HOME` and replaced
+ `globalThis.fetch` at MODULE LOAD and restored them only at
+ `process.once("exit")`. Correct in a seven-file sandbox; wrong in a 237-file
+ suite, for two independent reasons:
+ - Bun's runner shares ONE process across every test file (the same property
+ that makes `mock.module()` bleed here, which the conventions file already
+ bans). A process-wide `HOME` swap changes what every LATER file sees, and a
+ permanently throwing `fetch` would take the live-API `fallback-handler` and
+ `routing-rules` tests with it.
+ - It would not have worked anyway: `profile-config.ts:18` and
+ `all-models-cache.ts` (`:102` at HEAD) snapshot `homedir()` at MODULE scope, so a `HOME`
+ swap performed after those modules load is invisible to the very readers it
+ was meant to redirect — and `loadConfig()` would have read the developer's
+ real config.
+
+ So isolation is now FILE-SCOPED (`useBlackboxEnv()` → `beforeAll` install,
+ `afterAll` uninstall), and config reads are isolated through the repo's own
+ `setConfigFileOverride()` seam instead of through `HOME`. The writer's
+ two guarantees are intact: no real user state, and a fail-closed fetch
+ tripwire whose `afterEach` check catches even an implementation that swallows
+ the rejection into `unknown`. The tripwire now records the attempted URL
+ rather than a fixed string — strictly better diagnostics, same
+ `toEqual([])` assertion. The variable that switched the deleted store off was
+ dropped: it no longer exists.
+
+ Verified against `test:safe`: the guard reports no damage to either guarded
+ real file, and the suite is 0 fail. It duplicates no existing helper
+ (`test-helpers/` held only `credential-gate.ts` and `provider-quota.ts`).
+
+5. **Formatting.** `biome` reordered imports and wrapped two array literals. No
+ semantic change.
+
+**No test was edited to make it pass.**
+
+---
+
+## 5. The writer's own stated limits — are they still true?
+
+The plan's "What must not be claimed" list and its B-series table of tests blocked on
+a missing public seam still hold for everything outside the billing gate: no
+refresh-preservation proof, no public-list entitlement test (B10), no product-UI or
+live-auth validation (B13/B16), and the Coding Plan request path remains
+**UNVERIFIED**, as required.
+
+One design tension the writer flagged is still open and is NOT a test problem:
+
+> `behaviour-spec.md` §4.4.b separately permits a catalog plan-drop to stand
+> unless fresh account evidence restores it. That differs from the user's
+> stricter catalog rule. No test here silently endorses that catalog-denial
+> exception. … the contract owners should reconcile the prose before integration.
+
+`fe8722e` moved that branch's code to the stricter rule ("cloud catalog data may deny
+a candidate only when there is no fresh per-account answer at all"). HEAD does the
+opposite for plans whose `modelDiscovery` is `"catalog"`: published membership drops
+the candidate before discovery runs. See `ai-docs/architecture/routing.md`.
+
+---
+
+## 6. Negative control
+
+The control on that branch mutated an expected value in the billing-gate suite, so it
+is not carried here. For the one suite ported to HEAD, the E1 `Model not exist` cases
+fail against `eceab30` and pass with the wording recognised.
+
+## 7. Gate
+
+```
+bun run typecheck PASS
+bun run lint PASS (977 pre-existing warnings, 0 errors)
+bun run format PASS
+bun run test:safe PASS — 3657 pass / 19 skip / 0 fail, 237 files; guard reports
+ no change to ~/.claudish/config.json or all-models.json
+```
diff --git a/ai-docs/reports/blackbox-tests-alibaba/quarantine/D12-blank-base-url.ts.txt b/ai-docs/reports/blackbox-tests-alibaba/quarantine/D12-blank-base-url.ts.txt
new file mode 100644
index 00000000..54fdc58d
--- /dev/null
+++ b/ai-docs/reports/blackbox-tests-alibaba/quarantine/D12-blank-base-url.ts.txt
@@ -0,0 +1,21 @@
+// QUARANTINED BLACK-BOX TEST — D12, as the blind writer produced it, with only
+// mechanical rewires applied: the discovery entry point renamed to
+// `discoverDynamicCatalog`, the `cachePath` option removed with the store deleted
+// in fe8722e, and (ported 2026-09-19) HEAD's variable name and wording.
+// `discoverDynamicCatalog` does not exist at HEAD, whose equivalent check is
+// `discoverProviderModels` + `getDiscoveryFailure`. The finding still holds there:
+// a blank override counts as unset.
+//
+// It FAILS, and the test is right. Not repaired, not skipped in the suite, not
+// deleted. See ../blackbox-results.md, the D12 finding.
+//
+// Kept as .ts.txt so no test runner ever collects it.
+
+test("D12 a blank Token Plan endpoint is a failure, not an absent subscription list", async () => {
+ process.env.QWEN_TOKEN_PLAN_BASE_URL = "";
+ const result = await discoverDynamicCatalog(provider);
+ expect(result.status).toBe("failed");
+ expect(result.models).toEqual([]);
+ expect(result.failure?.kind).toBe("unreachable");
+ expect(result.failure?.detail).toContain("QWEN_TOKEN_PLAN_BASE_URL");
+});
diff --git a/ai-docs/reports/blackbox-tests-alibaba/quarantine/D12-failure.txt b/ai-docs/reports/blackbox-tests-alibaba/quarantine/D12-failure.txt
new file mode 100644
index 00000000..bf933f09
--- /dev/null
+++ b/ai-docs/reports/blackbox-tests-alibaba/quarantine/D12-failure.txt
@@ -0,0 +1,26 @@
+Ported 2026-09-19 from branch worktree-qwen-token-plan (6b627f1). Test title and
+variable name translated to HEAD's; otherwise as captured on that branch.
+
+bun test v1.4.0 (34cbb9a40)
+
+src/providers/model-discovery.blackbox.test.ts:
+119 | test("D12 a blank Token Plan endpoint is a failure, not an absent subscription list", async () => {
+120 | process.env.QWEN_TOKEN_PLAN_BASE_URL = "";
+121 | const result = await discoverDynamicCatalog(provider);
+122 | expect(result.status).toBe("failed");
+123 | expect(result.models).toEqual([]);
+124 | expect(result.failure?.kind).toBe("unreachable");
+ ^
+error: expect(received).toBe(expected)
+
+Expected: "unreachable"
+Received: "no-credentials"
+
+ at <anonymous> (/Users/jack/mag/claudish/.claude/worktrees/qwen-token-plan/packages/cli/src/providers/model-discovery.blackbox.test.ts:124:34)
+(fail) discovery failures identify the rejecting silo > D12 a blank Token Plan endpoint is a failure, not an absent subscription list [0.73ms]
+
+ 0 pass
+ 20 filtered out
+ 1 fail
+ 4 expect() calls
+Ran 1 test across 1 file. [19.00ms]
diff --git a/ai-docs/reports/blackbox-tests-alibaba/test-plan.md b/ai-docs/reports/blackbox-tests-alibaba/test-plan.md
new file mode 100644
index 00000000..faf08789
--- /dev/null
+++ b/ai-docs/reports/blackbox-tests-alibaba/test-plan.md
@@ -0,0 +1,174 @@
+# Alibaba billing-product black-box test plan
+
+> **Ported 2026-09-19** from branch `worktree-qwen-token-plan` (`6b627f1`) onto `eceab30`.
+> This is the blind writer's plan as delivered on that branch. Provider names are
+> HEAD's, and the retired term for a per-credential model list is now *dynamic models
+> catalog*. The billing-gate cases (the `metered-fallback` suite, and the blocked
+> B-series rows that needed it) are removed, because HEAD does not carry the gate.
+> Results, and which suites exist at HEAD: [`blackbox-results.md`](blackbox-results.md).
+
+## Status and boundaries
+
+**STOP_AT: implement. Tests authored, not executed, compiled, or typechecked. No pass claim.**
+
+Only the supplied specification, acceptance criteria, measured facts and public contracts were read. No implementation was located or inspected. Test files import the declaration-module stems under `../contract/`; those modules deliberately have no runtime implementations in this sandbox. Integration must supply the corresponding public implementations or relocate the tests beside the production modules and change import paths only. Do not fill the sandbox with mock implementations to make this suite green.
+
+The writer's seven `.test.ts` files covered its seven supplied declaration contracts. Six are listed below; the billing gate's is not. `test-env.ts` is isolation infrastructure, not an implementation or test double of the product.
+
+### Isolation and input provenance
+
+- Bun + TypeScript; `bun:test`; no snapshots and no `mock.module()`.
+- Before dynamically importing any product module, relocate HOME, USERPROFILE and XDG_CONFIG_HOME to a generated directory **inside `tests/`**, and disable Keychain, 1Password and the default on-disk persistence of the dynamic models catalog. Keep the relocation process-wide until exit so a later file cannot reopen the real HOME through a cached module.
+- Store functions always receive explicit scratch paths. Capability classification receives an explicit nonexistent catalog path; compatibility functions without a path see the relocated, cold HOME.
+- A fail-closed fetch tripwire rejects and records unexpected fetches. The after-test check catches even an implementation that swallows the rejection into `unknown`. It returns no simulated vendor responses. It is a safety backstop, not a transport injection seam or a claim to intercept every possible network library.
+- Tests restore per-test environment changes and reset the supplied seams. Scratch files are removed; HOME and the process-wide fetch tripwire are restored at process exit. Do not run these files concurrently with unrelated suites that intentionally exercise network access.
+- Account membership in the dynamic models catalog is generated per test. There is no expected 25-model or 10-model list, no edition inference from counts, and no guessed production context window. Parser sizing values are test inputs, not product defaults.
+- The parser's field shapes and credential-error strings come from `measured-facts.md` and the declaration comments. Malformed rows, generated IDs and context-window spellings are deliberate contract inputs/mutations, **not claimed live recordings**. Named image/audio/video IDs test capability, never account membership. No invented Alibaba quota-exhaustion wording.
+
+### Oracle priorities and design tensions
+
+1. The user's current rule is authoritative: stale, incomplete, failed and catalog evidence must not deny eligibility. The availability tests enforce that asymmetry directly.
+2. `behaviour-spec.md` §4.4.b separately permits a catalog plan-drop to stand unless fresh account evidence restores it. That differs from the user's stricter catalog rule. No test here silently endorses that catalog-denial exception. The blocked routing test B8 below records the requested observable behavior; the contract owners should reconcile the prose before integration.
+3. `measured-facts.md` says an unrecognized ID defaults to “chat,” while the later tri-state contract clarifies **unknown, still offered**. K4/K5 require that clarified distinction, not confirmed chat and not hidden.
+4. The capability pseudocode in the design mentions catalog fields absent from the supplied slim-cache contract. Do not invent a catalog fixture schema to test it. Warm-catalog cases are blocked pending a public schema/seam (B12).
+
+## Implemented cases
+
+The IDs below are also present in test titles. Each parameterized row expands into separately named tests; the inputs are enumerated here. “Wrong implementation” is the mutation/defect that must make that case red. None of these are assertions about internal call counts or private maps.
+
+### `model-availability.test.ts`
+
+| IDs / expanded inputs | Observable behavior | Requirement / acceptance | Wrong implementation caught |
+|---|---|---|---|
+| A1 × fresh/stale/incomplete | A generated wire ID in the account's dynamic models catalog is served | R2, R3, R8 | Uses a pinned model list; discards positive retained/partial evidence |
+| A2 × fresh | A missing wire ID is not served when complete fresh evidence exists | R2, R3 | Never applies a genuine account exclusion |
+| A2 × stale/incomplete | A missing wire ID is unknown, never not-served | R8 | Uses weak evidence to drop the subscription |
+| A3 × failed/not-declared | Neither unanswered state proves inclusion or exclusion | R8, R9 | Treats an empty result as an authoritative empty plan |
+| A4 | Membership follows wire ID, not the row's human display label | R2 | Compares the requested wire ID against presentation labels |
+| A5 | A smaller complete fresh dynamic models catalog can legitimately remove an ID while retaining another | R2, R3, R8 | Enforces a fixed count, unions old membership forever, or caches old eligibility across a new seeded result |
+
+A3 intentionally has the same eligibility result for two distinct producer states. It does **not** prove the producer preserves that distinction; D11/D12 cover a real absent-vs-failed producer branch, and B7 covers the missing transport branches.
+
+### `model-discovery.test.ts`
+
+| IDs / expanded inputs | Observable behavior | Requirement / acceptance | Wrong implementation caught |
+|---|---|---|---|
+| D1 × `owned_by`/`ownedBy` | Both measured wire spellings preserve a new ID and complete counts; no tools/window is invented | R2, R9, R11, V1 parser shape only | Requires one owner spelling, rejects new IDs, or fabricates capability/context metadata |
+| D2 × missing/null/object container, null body | Missing enumeration gives `total:null`, no usable rows | R8 completeness | Equates “no parseable container” with a valid empty enumeration |
+| D3 | Real empty array gives total 0, dropped 0, no rows | R8 completeness | Loses the distinction between malformed container and empty enumeration |
+| D4 × null/scalar/missing-ID/numeric-ID/empty-ID row | Preserve valid row, count all received rows and each dropped row | R8 completeness | Silently discards malformed entries and labels a truncated parse complete |
+| D5 | All-invalid enumeration reports three drops, not a genuine empty list | R8 | Folds all parse loss into an empty success |
+| D6 | A small generated list parses regardless of published model counts | R2, R3 | Enforces a vendor/edition minimum or whitelist |
+| D7 × context_length/context_window/max_context_length | Supplied account-specific window survives each documented spelling | R2, R12 | Hardcodes a window or recognizes only one spelling |
+| D8 × stale/incomplete | Legacy wrapper returns the useful retained list | R8 | Returns [] for every non-fresh status |
+| D9 × stale/incomplete | Context sizing uses retained evidence for the matching ID, not an unrelated ID | R8; deliberate sizing exception | Rejects all stale sizing, or substitutes the first listed model's window for any request |
+| D10 × Token Plan/PAYG rejecting endpoint | Diagnostic identifies the exact rejecting silo and credential problem | R6, V1 diagnostic only | Prints generic “check your key” without saying which isolated host rejected it |
+| D11 | Provider with no discovery declaration returns not-declared, empty models, no failure | R8 five-state contract | Calls absent discovery a transport failure |
+| D12 | Blank Token Plan base-URL override returns failed/unreachable and identifies the setting | R6, R8, R12 | Collapses a misconfigured endpoint to not-declared/empty plan, ignores the override, or attempts a real request |
+
+D1–D7 test parsing, not the complete refresh state machine. D8/D9 test consumers of injected states, not production of stale/incomplete states. Seeding the answer and asserting that same answer would not prove refresh behavior, so that purported test is deliberately not included.
+
+### The on-disk store suite (a module deleted in `fe8722e`)
+
+| IDs / expanded inputs | Observable behavior | Requirement / acceptance | Wrong implementation caught |
+|---|---|---|---|
+| S1 × changed key/base URL/source/provider/salt | Original accepted entry is readable; changed identity cannot inherit it; original remains intact | R2, R3, R8 identity binding; V4 URL override | Fingerprints only provider, omits any named identity dimension, or falls back to a by-provider lookup |
+| S2 | Header name case/order changes preserve access to the same entry | R8 identity stability | Fingerprints object serialization or case-sensitive header names |
+| S3 | Header **values** stay case-sensitive | R3 identity binding | Lowercases credentials and merges distinct seats |
+| S4 | A different provider cannot read an entry by presenting its fingerprint | R3 identity binding | Ignores the lookup's provider scope |
+| S5 | Two seat entries coexist and retain their different lists | R3 | Stores only one list per provider |
+| S6 | ENOENT yields miss and creates no file | R8; no read-side user-state writes | Treats absence as failure or writes during lookup |
+| S7 | Unknown fingerprint in a valid file yields miss | R3, R8 | Returns the first/only provider list on identity miss |
+| S8 | Truncated JSON yields unreadable with diagnostic, and nullable projection returns null | R8 failed ≠ absent | Catches corruption and calls it miss, throws, or confirms corrupted data |
+| S9 | Reading a directory (non-ENOENT error) yields unreadable, not miss | R8 | Collapses every filesystem exception to stable absence |
+| S10 | Invalid entry model-array shape cannot confirm eligibility | R8 | Trusts any valid JSON object as a usable accepted list |
+| S11 | Expired entry returns expired with original timestamp; legacy read gives null | R8 | Confirms expired membership, calls it a plain miss, or loses diagnostic age |
+| S12 | Recent accepted state round-trips through explicit path even with default persistence disabled | R8; hermetic path contract | Disables explicit scratch writes as well as the real default path, or drops entry metadata |
+| S13 | Maximum age is the specified thirty days | R8 architecture contract | Retains entitlement indefinitely or silently changes the retention window |
+| S14 | Salt/identity computation is non-persisting and stable before first write | R8 store contract | Writes on every routing read or changes identity salt on every lookup |
+| S15 | File contains a salted 16-hex fingerprint, accepted metadata, stable salt, no raw credential values | R3 identity/security contract | Persists raw keys/tokens or fails to retain the salt needed to retrieve accepted evidence |
+| S16 | Reading retained evidence preserves original date and file bytes | R8 | Refreshes the timestamp on read so old entitlement never expires |
+| S17 | Explicit clearing removes evidence and rotates the salt | R3, R8 | Leaves entries or reproduces the old fingerprint after a clear |
+
+These test the store's public semantics. They do not establish that the discovery caller writes **only** fresh results, nor that writes are atomic under concurrent processes (B7/B17).
+
+### `probe-discovery.test.ts`
+
+| IDs / expanded inputs | Observable behavior | Requirement / acceptance | Wrong implementation caught |
+|---|---|---|---|
+| K1 × qwen-image-2.0, qwen-image-2.0-pro, wan2.7-image, wan2.7-image-pro | Image generators classify not-chat and are excluded | R11, V2 | Treats subscription membership or lack of catalog data as chat capability |
+| K1 × qwen-audio-3.0-tts-plus, qwen-audio-3.0-realtime-plus | Audio models classify not-chat and are excluded | R11, V2 | Drops image models only and still offers speech as chat |
+| K1 × happyhorse-1.1-t2v/i2v/r2v | Documented cross-edition video models are excluded | R11, measured negative control | Leaves the exact measured video gap unchanged |
+| K2 × video-01, wan2.2-video, hunyuan-video, T2V-01, qa_i2v_next, qa.r2v.next, qa-v2v, veo-3, sora-2 | General video forms work across boundaries/case/vendors | R11 design rule | Whitelists the three measured IDs or misses boundary/case/vendor variants |
+| K3 | A wildcard route is not a concrete model to offer | R11 contract | Offers deployment wildcard syntax as a chat model |
+| K4 | Generated cold-catalog ID is unknown and still offered | R11, R2 | Rounds unknown to confirmed chat or hides it as not-chat |
+| K5 × qwen-vl, gemini-vision, qa-t2vector, qa-sorafenib, qa-veolia | Vision inputs and unanchored substrings remain unknown/offered with cold catalog | R11 | Excludes vision input models or overmatches video substrings |
+| K6 | Split retains unknown rows, duplicate occurrences, attached data and within-group order without mutating input | R11 presentation contract | Drops unknowns, mixes them with confirmed chat, deduplicates, or loses row metadata |
+| K7 | Probe ranking keeps a new unknown candidate and excludes image/audio/video candidates | R11, V2 consumer | Fixes classifier but leaves the selection path using an obsolete permissive filter |
+| K8 | All-non-chat input yields no probe candidate | R11 | Falls back to the first image/video row when filtering empties the list |
+
+No warm-catalog “chat” fixture is invented; B12 covers the missing input contract. No claim about rendered `?` labels or footer counts follows from K6; B13 covers those surfaces.
+
+### `types.test.ts`
+
+| ID | Observable behavior | Requirement / acceptance | Wrong implementation caught |
+|---|---|---|---|
+| T1 | Credential exception retains its actionable message | R6 | Erases the failure reason or replaces it with `[object Object]` |
+| T2 | Large multiline exception becomes one shorter bounded diagnostic line | R6 | Dumps multiline SDK output into the routing explanation without bounding it |
+
+The supplied types describe three-valued readiness, but an interface is not an executable authority. T1/T2 are diagnostic tests only; neither proves `failed` survives readiness resolution.
+
+### `model-unsupported.test.ts`
+
+| IDs / expanded inputs | Observable behavior | Requirement / acceptance | Wrong implementation caught |
+|---|---|---|---|
+| E1 × raw/enveloped `Model not exist`, measured Zen Go unsupported wording | Unsupported wording is recognized independently of HTTP status | R6 | Omits Alibaba's wording or only recognizes one response envelope |
+| E2 × InvalidApiKey, invalid access token or token expired, Incorrect API key provided | Credential rejections are not classified as model exclusion | R6, V1 | Treats every auth-shaped error as a missing model |
+| E3 | Vendor region opt-in link is actionable, not model absence | R6 | Requires one hardcoded error type or confuses account opt-in with a nonexistent model |
+| E4 | Plain key error does not claim an actionable URL | R6 | Treats every explanatory error message as an action link |
+
+These predicates do not prove retry behavior, status remapping, or preservation of the provider's complete error in the UI (B6/B13).
+
+## Required tests BLOCKED by missing public input/control contracts
+
+These are planned requirements, **not implemented, skipped tests, or claimed coverage**. No `test.todo()` entries are used to make a report look green. Each has an observable oracle and a specific wrong implementation; the missing ingredient is a callable, hermetic public surface. Adding a test-only copy of the routing logic or a dummy `CredentialProvider` and testing that dummy would not test this feature.
+
+| ID | Planned behavior / oracle | Requirement | Wrong implementation caught | Needed contract/seam |
+|---|---|---|---|---|
+| B2 | Only DASHSCOPE_API_KEY, subscription genuinely absent → qwen-payg primary `[email protected]`; repeat when catalog really plan-drops an unheld subscription | R12 | Treats every catalog subscription candidate as a held/displaced plan | Route signature, routing-entry/catalog schema, authority registration/reset seam; ambient keys isolated |
+| B4 | Authority outcomes: present→available true, absent→false, failed/throw→false **with failed diagnostic retained**; unknown provider genuinely absent | R6 | Boolean authority erases source failures before routing decisions | Executable authority and registration/reset seams; types alone are insufficient |
+| B7 | Fresh complete fetch accepts state; malformed JSON/transport failure retains identity-matched stale state; missing container, continuation markers (`has_more`, `next`, `next_page`, `next_page_token`), dropped rows and empty 200 yield incomplete and leave accepted bytes unchanged; valid smaller complete refresh replaces them | R2, R8 | Marks every nonempty parse fresh, overwrites state with partial data, ignores pagination, or compares counts to old/published counts | Discovery transport + credential-authority injection; the exposed seed bypasses the producer and store |
+| B8 | Fresh account inclusion beats catalog omission; catalog/stale/incomplete/failed evidence alone must not deny a candidate (user's governing rule) | R2, R4, R8 | A catalog plan-drop silently removes a paid subscription before the live account can answer | Catalog-entry schema + route invocation; reconcile §4.4.b with user's stricter rule |
+| B9 | Seed accepted identity A; rotate key, resolved endpoint or source to B; force discovery outage → failed/empty, never A's stale list; same-identity outage → stale; unresolved identity → failed, no provider-wide fallback | R3, R8 | Disk store is correct but in-memory discovery cache is provider-keyed, or no-identity branch fetches any stored list | Credential and transport injection for real discovery path |
+| B10 | Public Coding Plan model list cannot confirm entitlement; existing Token Plan subscribers do not depend on purchase stock | R9, R10, V1 | Adds unauthenticated entitlement source or gates existing coverage on purchase availability | Provider/discovery entry points and controllable source responses; no stock input exists in these contracts |
+| B11 | Token Plan and PAYG keep old key names, aliases, resolved hosts and overrides; same-prefix keys are never product evidence; inspect actual outgoing signer's credential | R1, R5, R12, V1, V4 | Aliases subscription key onto PAYG, ignores override, classifies `sk-sp-` as product, or labels metered signing SUB | Provider definition/credential resolution/transport contracts |
+| B12 | Public warm catalog positive tools/thinking/vision evidence yields chat; positive flags cannot override an already-known image/audio/video exclusion | R11 | Never confirms chat, ignores catalog refresh, or widens known non-chat into chat | Slim catalog JSON schema or `_setCatalogEntriesForTest` declaration; neither supplied |
+| B13 | Picker/preflight/probe show product+billing, stale/incomplete age and uncertainty despite nonempty rows; unknown capability gets marker, not false chat label; error messages distinguish key/quota/model/uncertain access | R1, R5, R6, R8, R11; V2, V5 | Correct helper results lost by display consumers, or failure read occurs only on empty list | Public render/probe/preflight contracts and catalog seams; V5 screenshots outside sandbox scope |
+| B15 | Billing classification follows active signing arm on a dual-mode provider at each advance | R5 | Memoizes provider-name billing, or treats any auth object as OAuth | Credential-decided billing probe registration/reset contract |
+| B16 | Live authentic/bogus silo controls, built-provider signing and billing log, real TUI screenshot, repo-build session | V1–V6 | Unit seams all pass while production setup diverges | Authorized live environment, repo build and real credentials; explicitly prohibited here |
+| B17 | Simultaneous readers/writers see whole old or whole new valid store, never a torn successful entry | R8 atomic persistence contract | Writes directly over the file rather than atomically replacing it | Isolated runtime module supplied to child processes; no implementation in sandbox |
+| B18 | Repeated stale/incomplete discovery within TTL reuses evidence without repeated timeout; expiry permits new evidence | R8 availability contract | Repeated request-path outages multiply discovery delays | Transport/credential seam and controllable clock/TTL contract |
+
+### What must not be claimed
+
+- No refresh-preservation or in-memory identity-cache proof follows from store-only or seeded availability tests.
+- No public-list entitlement, configuration back-compat, product UI, live auth, or billing-label validation is complete.
+- Coding Plan request path remains **UNVERIFIED**, as required.
+- R10 has no injectable stock input here. An assertion that a handcrafted object lacks a stock field, or a grep for one, would not be an observable black-box test and is deliberately omitted.
+- Future mutation validation should make each listed wrong implementation red. No mutation run was performed at this stop point.
+
+## Files Read
+
+All paths are relative to the supplied sandbox. Directory listings were used only to locate the supplied contracts and empty output directory. The following are the files opened for input, less two contracts for work not carried to HEAD (the deleted store module and the billing gate); no implementation or outside file was opened:
+
+1. `TEST-CONVENTIONS.md`
+2. `spec.md`
+3. `acceptance-criteria.md`
+4. `measured-facts.md`
+5. `contract/model-availability.d.ts`
+6. `contract/model-discovery.d.ts`
+7. `contract/model-unsupported.d.ts`
+8. `contract/probe-discovery.d.ts`
+9. `contract/types.d.ts`
+10. `contract/behaviour-spec.md`
+11. `contract/architecture-contracts.md`