返回 CodeWhale
ROUTE_INVENTORY.md
根目录 / docs / ROUTE_INVENTORY.md
1 # Exact route inventory
2
3 Existing GET /v1/providers/{kind}/models?model_provider_id={exact-id}&filter=...&cursor=... remains the read. Each model adds `route: {model, selection: {route_id, binding_id}, provider_rank, evidence, readiness}`. `evidence` is advertised/configured_unverified/metadata_only/absent; advertised is listing evidence, never proof of inference. Readiness retains the Engine enum. Existing facts remain metadata.
4
5 When a connection publishes typed metadata, a model row also carries `type` and `capabilities.tools.supported`. A missing capability means the connection did not declare it. OpenCode Go authenticates discovery for a concrete model before choosing among connections that advertise the same ID. The `auto` selector uses its configured routing policy.
6
7 Response adds `inventory_revision`, `inventory_status` (existing CatalogStatus), and `discovery_supported`. Cursor is bound to exact scope, inventory revision, filtered rows and query. Empty successful listing, unsupported discovery, and failed/stale reads remain distinct. Match opaque model IDs exactly; filter searches before pagination and exact matches rank first.
8
9 PATCH /v1/threads/{id} accepts optional `route_selection: {route_id,binding_id}` with `model`, `model_provider`, and exact `model_provider_id` when present in provider listing. This changes the session, not the saved startup default. Omission preserves the legacy request. Engine re-admits identity, checks binding and current readiness, and resolves the exact wire model before accepting. A changed binding requires refresh and explicit reselection; never silently replay selection against a new provider. Preserve query/focus keyed by route_id; never use inventory revision or credential generation as favorite/history identity.
10
11 route_id is stable configured route + exact model (case preserved). binding_id fences endpoint/account; known-account credential renewal retains selection identity. API keys without a provable account identity require reselection on credential replacement. Client receives no account identifier or credential generation. This candidate adds no discovery on picker open, provider registry, or roster database.
12
13 Desktop clients can adopt these optional fields independently; older clients retain the existing model-list and selection request shapes.
14
15 ## Evidence and limits
16
17 The process fence extends the existing provider catalog request-generation owner. A change in the route observation clears account-scoped or authenticated rosters. Anonymous public listings and keyless routes without credential-bearing transport settings retain their exact-endpoint cache across restarts. Older cache files lack provenance for this distinction, so their rows require a fresh listing. No favorite/history key includes a credential generation. No inference request is made by inventory or selection validation. Prefix/KV-cache behavior is unchanged: this is a host-side selection contract, not new model-visible context.
18
19 Same-account binding preservation requires a provable backing identity (official ChatGPT registration or the active Codewhale account session). Unknown-account API-key replacement invalidates the binding. A manual route remains unverified when discovery is unsupported or fails; a fresh authoritative absence is unavailable. Metadata never asserts entitlement. Thread selection is additive; legacy unfenced requests keep their established behavior. Headless `exec --resume` confirms the saved endpoint and account before sending another prompt. Pass an explicit `--provider` or `--model` to reselect after a binding change or when the account cannot be proven. Older sessions acquire the binding when headless execution next saves them. The read uses the requesting runtime's verified configured identities; it is not a cross-runtime or arbitrary host inventory service.
20
21 Fixture commands: `scripts/dev-test.sh engine exact_inventory_` and `scripts/dev-test.sh app-server exact_inventory_`. These exercise exact selection, discovery outcomes, binding changes, and cursor scope without live provider calls. Existing catalog and TUI selection fixtures cover the compatibility consumers. Installed UI behavior and real inference require separate qualification.
22
23 An exact `[[custom_models]]` declaration can specify `type = "chat"` and `tool_call = true` for a model whose named connection omits these fields. A successful turn can establish chat support for the same connection, model, and credential. Tool support still requires an explicit capability. A known non-chat type, negative tool capability, or unavailable route is ineligible for Fleet.
24
25 Hosts that advertise `fleet_worker_model_pool` expose `GET` and `PUT /v1/providers/{id}/worker-model-pool`. Use the exact configured provider ID. A missing saved pool is returned as JSON `null`. A PUT sends `mode` (`all`, `selected` or `none`), `models` (exact wire IDs in Selected mode), `expected_revision` (zero for a new pool) and the current inventory `binding_id`. A changed inventory binding or revision requires a fresh read. The pool applies to Fleet and native session children. A connection change can require a new selection, reported by `needs_reselection`.
26
26 lines MARKDOWN