From 87b84a7b080718c001dea3a8eb6b07cf7a0c388d Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 18:43:41 -0600 Subject: [PATCH] docs: design provider model kinds and modalities --- ...ign_provider_model_kinds_and_modalities.md | 293 ++++++++++++++++++ doc/README.md | 1 + 2 files changed, 294 insertions(+) create mode 100644 doc/2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities/2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities.md diff --git a/doc/2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities/2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities.md b/doc/2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities/2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities.md new file mode 100644 index 000000000..201a6e9aa --- /dev/null +++ b/doc/2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities/2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities.md @@ -0,0 +1,293 @@ +# Design: provider/model purposes and input/output modality routing + +**Date:** 2026-11-24 00:25 UTC +**Status:** Proposed design; no implementation or configuration change in this record. +**Tracking:** [code#10306](https://github.com/developing-today/code/issues/10306), under the design mill tracked by [code#9399](https://github.com/developing-today/code/issues/9399). +**Related design:** [`brief-capabilities-supplement.md`](../2026-11-13T09-26-00Z_design_pool_effort_system/brief-capabilities-supplement.md), especially §§0–3 and §8. + +## 1. Problem and context + +The router needs to distinguish *what operation a model can perform* from +*what data it can receive or produce*. Without both distinctions, a route can +select a model that accepts the wrong request protocol or cannot consume the +request's attachments. A typed decision endpoint is not a chat endpoint; an +embedding model does not produce a chat completion; and an image-capable model +is not necessarily eligible for a text-only pool or vice versa. + +The source issue records concrete failures and requirements: + +- System One / Jev decision endpoints reject chat calls, while the historical + `system1` route was only a name that resolved and did not itself supply a + decision-call path. +- Voice, embedding, image generation, transcription, and reranking need + distinct operation families. In particular, reranking is not embedding: + it scores query/document pairs rather than producing reusable vectors. +- The capabilities supplement already specifies capability-set eligibility, + per-capability failover, pool inheritance/wrappers, and provider translation. + It also calls out the interaction with context-limited pools. +- The repository has since added `model_designations` in + `.opencode/opencode.jsonc` (code#13675): model-level `purposes` and + `capabilities`, source strings, and a static route-rules check over every + model route. This is useful groundwork, not yet the complete request-time + contract: declaration/checking alone does not prove that an incoming + multimodal request is normalized, filtered at every fallback boundary, and + delivered through a compatible provider API. + +The immediate design goal is to complete and formalize that groundwork rather +than add an unrelated parallel metadata system. Existing configuration and the +supplement are the evidence base; this document does not claim that the +proposed runtime behavior exists today. + +## 2. Goals and non-goals + +### Goals + +1. Make operation-family compatibility structural and checked before dispatch. +2. Represent input and output modalities independently, including combinations + such as text+image input and text+audio output. +3. Filter ineligible models at every route, nested-pool, and class-fallback + boundary; preserve per-capability failover rather than treating one + modality's failure as another's. +4. Preserve context limits, provider-specific request translation, weights, + ordering, quota/health gates, and existing route semantics for compatible + requests. +5. Make metadata provenance and uncertainty auditable, using provider catalogs + and models.dev without treating a catalog claim as live end-to-end proof. +6. Migrate existing seats incrementally, with decision-only routes as the first + high-value kind-safety case. + +### Non-goals + +- Implementing new model endpoints, a general-purpose AI gateway, or all + OpenAI/Claude/System One protocol families in this design-only change. +- Inferring capabilities by sending user content to candidate models. +- Treating `purpose` as a replacement for billing, quota, strength, context, + transport, or harness-only feature metadata. +- Automatically enabling every modality a provider advertises, or changing + route weights/order as part of metadata migration. +- Treating PDF as interchangeable with image: PDF/document parsing is a + document-input feature and must not be inferred from image input alone. + +## 3. Alternatives considered + +| Option | Advantages | Costs / reason not chosen | +| --- | --- | --- | +| Do nothing; rely on comments and provider errors | No migration or router changes | Keeps wrong-family routes expressible; errors occur after dispatch, may leak attachments to an incompatible provider, and cannot provide predictable fallback. | +| One boolean `kind` per model | Simple validation and UI | A single exclusive kind cannot express a model that supports both chat and decision, or providers exposing multiple API families. It also conflates operation with input/output data. | +| Capability flags only (for example `vision: true`) | Small schema, familiar | Does not distinguish chat from embedding/rerank/decision; booleans do not express required combinations, direction, document parsing, or pool policy. | +| Put all metadata on pools | Lets operators control routes locally | Duplicates model facts across pools, drifts as the same model is seated elsewhere, and cannot support catalog reconciliation. Keep pool declarations as *allow policy*, not the source of model facts. | +| Put all metadata on providers | Captures endpoint families | A provider may serve models with different capabilities and model IDs may vary by endpoint/version. Provider endpoint support and model-specific capability claims must remain distinct. | +| One shared model designation plus pool policy (chosen) | Extends existing `model_designations`; separates model facts, endpoint-family support, request requirements, and pool allow-lists; supports multi-purpose models | Needs a closed vocabulary, migration of unclassified routes, source reconciliation, and runtime enforcement across all route compositions. | + +## 4. Chosen approach and contracts + +### 4.1 Three independent dimensions + +Retain `purposes` as a **set** on a model designation, not a singular `kind`: +`chat`, `decision`, `embed`, `rerank`, `recommend`, `transcribe`, `speak`, +`guard`, and future reviewed operation families. A model may list multiple +purposes only when there is evidence that each operation is served. A provider +declares which API families/transports it exposes; that declaration is not a +claim that every model under that provider supports each family. + +Represent modalities directionally on each model: `input_modalities` and +`output_modalities`, drawn from a closed vocabulary (`text`, `image`, `video`, +`audio`, `document`). Keep protocol features such as real-time audio streaming +and file/path upload as separate transport/feature capabilities, not synonyms +for a modality. Model-specific operations and modalities are independent: for +example, an image input capability does not make a model an image generator. +Document/PDF support requires explicit document parsing evidence; it is not +derived from image support. + +The existing `capabilities` field is a transition surface. During migration, +map its current values (`visual`, `pdf`, `audio-in`, `audio-bidir`, `tts`, +`stt`) through a single checked compatibility table into the directional model +and transport features. Do not keep two independently edited vocabularies. +Rename or replace that field only in an implementation slice after the +compatibility mapping and all consumers are tested. + +### 4.2 Configuration ownership and precedence + +- **Model designation:** one canonical record keyed by normalized catalog + identity, with provider-specific IDs mapped to it. It contains purposes, + directional modalities, optional context limits, evidence/source, checked + time, and confidence/status. Keep an explicit override for provider-specific + variants when the endpoint's actual behavior differs from the canonical + family. +- **Provider endpoint family:** provider adapter declares the operation/API + families it can translate and dispatch (chat/responses, embeddings, + reranking, decision, speech, etc.), including required native knobs. One + provider entry may expose multiple families; silently dropping a required + knob is forbidden. Compatibility façade translation remains one layer, as + required by the issue's Cohere example. +- **Pool policy:** a pool declares allowed purposes and an array of accepted + *sets* of input/output/transport requirements. Model facts flow upward when + a pool has no policy. An explicit wrapper/pool policy narrows that branch; + nested policies compose by intersection, never by widening a child. This + preserves the supplement's `Luna text` wrapper example and prevents a + text-only wrapper from inheriting image eligibility accidentally. +- **Request contract:** normalize the incoming API surface into one operation + purpose plus required input modalities, requested output modalities, and + transport features. A multi-part request requires every member of its + capability set. Translation to the selected provider's native shape happens + only after eligibility is established. + +Precedence for conflicting evidence is: provider's current operation-specific +catalog/API evidence; models.dev record for the exact normalized model/version; +reviewed local override with source and timestamp. Provider evidence is +authoritative for available endpoint families; model-level capability claims +remain version-specific. A disagreement marks the record `needs_review` and +must not silently broaden routing eligibility. Ingestion is a candidate-data +process, not an automatic route-enablement mechanism. + +### 4.3 Router and fallback enforcement + +1. Normalize request requirements once at the routing boundary. Unknown + operation is rejected before route expansion; an absent modality is not + guessed from content bytes. +2. Before selection, intersect request requirements with the consuming pool's + policy, each nested pool/wrapper policy, the model designation, and the + provider adapter's supported operation family. Any mismatch makes that leaf + ineligible (equivalent to walled for this request only). +3. Apply the same eligibility test when expanding class fallback routes and + provider-route members. A fallback may not shed a required modality or + change operation purpose. If no eligible leg remains, return a typed + `no_eligible_route` error that identifies the missing requirement without + echoing attachment contents. +4. Keep capability-local failures scoped to the affected operation/capability + set; global failures such as quota/auth/route-construction failure retain + their existing whole-leg semantics from the supplement. +5. Preserve per-target context caps such as `limited`: eligibility is checked + before dispatch, then the selected target's effective context limit is + applied. Context overflow is not repaired by selecting an ineligible + modality fallback. +6. Record operation, normalized capability-set ID, eligibility disposition, + and selected leaf in route-attempt telemetry. Do not record prompts, + documents, image/audio bytes, or extracted content. + +### 4.4 Security and capability analysis + +Metadata is routing input, not a security boundary on its own. Only reviewed, +source-attributed claims may broaden routing; unknown or stale declarations +must not enable a non-text path. Attachments are passed only to a leaf proven +eligible for the exact requirement set and only through its adapter. PDF and +other document parsing is an explicit capability because parsers process +untrusted complex input. Telemetry uses opaque capability identifiers and +must never capture attachment payloads. Config validation rejects unknown +purpose/modality values and duplicate/conflicting normalized model identities. + +## 5. Dependency-ordered build slices + +Each slice is intended to fit one implementation lane/session. This design +does not authorize implementation; each slice should be tracked separately +after the design is accepted. + +1. **Vocabulary and evidence inventory.** Define closed purpose, modality, + transport-feature, and status enums; inventory current designations, model + IDs, aliases, and route usages; publish the one-time legacy compatibility + map. **Acceptance:** every currently designated entry maps without loss; + duplicate/unknown values fail validation; inventory names all unclassified + routed models and assigns an evidence source or an explicit unknown. +2. **Static config contract and diagnostics.** Validate model designation, + provider-family, pool-policy, wrapper composition, and route/fallback + compatibility. Keep runtime behavior unchanged in this slice. + **Acceptance:** fixtures reject a decision-only model in chat, a rerank + model in an embedding pool, a modality-incompatible fallback, unknown enum + values, and widening nested wrappers; positive fixtures cover multi-purpose + models and a narrowed text wrapper. +3. **Request normalization and eligibility engine.** Convert chat/messages, + responses, embedding, rerank, decision, and supported media request shapes + to the canonical contract; filter candidate leaves before dispatch at all + composition boundaries. **Acceptance:** model-based tests prove that every + returned leaf satisfies purpose, modality, transport, and context + constraints; unsupported combinations return `no_eligible_route` without + provider calls or payload-bearing logs. +4. **Provider adapters and façade families.** Add/extend family-specific + adapter contracts and mechanical translation, preserving native-only knobs + (including Cohere embed `input_type`); wire the minimum family needed for + each admitted purpose. **Acceptance:** provider contract tests assert the + exact translated request and prove unsupported knobs fail rather than + disappear; chat and non-chat families share one provider identity without + cross-family endpoint confusion. +5. **Decision-first migration and telemetry.** Migrate `system1`/decision + designations, then embeddings/rerank and speech; finally classify visual, + PDF, and remaining multimodal seats from evidence. Add capability-set + telemetry and staged rollout gates. **Acceptance:** decision calls resolve + only decision-capable adapters, chat cannot select decision-only leaves, + every migrated route has a source, and sampled routed requests show the + expected eligibility/selection without payload capture. + +## 6. Rollout and rollback + +Roll out in shadow/diagnostic mode first: compute eligibility alongside the +existing selector, record only requirement IDs and would-filter decisions, and +compare with route-attempt outcomes. Then enable hard filtering for one family +at a time, starting with decision-only seats because the existing failure is +structural and the model set is small. Next enable embeddings/rerank and +transcription/speech, followed by visual/document/video inputs. Keep the +existing route order, weights, quota gates, and `limited` context caps fixed +during each step so the effect is attributable. + +For each stage, require static config validation, family contract tests, +representative end-to-end proof, and an observed no-payload telemetry review. +If the eligible set unexpectedly empties or a provider rejects a translated +request, disable the new family gate (or revert its designation/pool policy), +restore the previous route behavior for that family, and preserve the incident +evidence. Never roll back by routing a known incompatible attachment to a +text-only model. Existing route-attempt records and user data remain unchanged. + +## 7. Verification plan + +- **Schema/config:** closed-enum tests, source-required checks for non-chat + designations, alias-collision tests, pool/wrapper composition tests, and + `bin/check-opencode-route-rules.mjs` coverage for every pool and fallback. +- **Property/model tests:** for every selected leaf, assert requested purpose + and each required input/output/transport feature are supported, pool policy + is satisfied, nested restrictions never widen, and context limits hold. + Generate combinations of request sets, model offers, and nested pool + declarations; the oracle is the formal subset/intersection rule in §4. +- **Adapter contract tests:** assert native endpoint family, parameter + preservation, media conversion, and errors for unsupported operations. + Include a provider with multiple families and a model with both chat and + decision purposes. +- **Failover tests:** capability-local failure advances only that request's + eligible legs; quota/auth/route-construction failures retain existing + global semantics; fallback expansion never drops requirements or repeats + routes. +- **End-to-end live proof:** use non-sensitive synthetic text/image/audio and + document fixtures against a designated test route, record exact provider, + model, operation, and capability-set IDs, and confirm no content appears in + telemetry. Live provider testing is separately authorized and is not part of + the design task. +- **Rollout observation:** compare shadow decisions with actual outcomes and + review empty-eligible-set rates, wrong-family rejections, and failover rates + by operation before enabling each gate. + +## 8. Open questions and defaults + +1. **Vocabulary owner — Drew:** should the proposed `document` input be a + modality or a separately typed content format (PDF, office documents)? + **Default:** keep document as a distinct required feature, not implied by + image; settle the final enum before slice 1 lands. +2. **Metadata owner — Drew:** should models.dev be the default source for + model identity/capability data, or should provider live catalogs take + precedence wherever they exist? **Default:** exact provider evidence wins + for endpoint availability; models.dev is the normalized catalog baseline; + conflicting records require review and do not broaden eligibility. +3. **Migration owner — Drew:** should an undesignated legacy model default to + chat+text during migration, or become ineligible until reviewed? + **Default:** static audit first; runtime migration must explicitly classify + current routed models before fail-closed enforcement. After the migration + gate, unknown models cannot serve non-text or non-chat requests. +4. **API contract owner — OpenCode maintainers:** which provider API families + are required in the first adapter slice (Responses, native embedding, + rerank, System One, speech)? **Default:** decision and embedding first, + rerank next, then media families; no family is claimed complete without a + contract test. +5. **Rollout owner — Drew:** which non-sensitive live test accounts/routes may + be used for media end-to-end proof? **Default:** tests remain synthetic and + opt-in; no customer/user attachment is used. + +## 9. Record and tracking + +This dated design is the design record for [code#10306](https://github.com/developing-today/code/issues/10306), which remains the tracking issue; its existing queue task is the delivery queue item for this design slice. No new implementation/config change is included here. The source issue should link this file (and the eventual merged revision) so subsequent slices can be issued against the settled contracts above. diff --git a/doc/README.md b/doc/README.md index 8c5306a86..0c8d6c0af 100644 --- a/doc/README.md +++ b/doc/README.md @@ -52,6 +52,7 @@ Folders are named `__`. The kinds in use are `feature` - [CNCF landscape — the slice this estate will actually need](2026-11-23T22-33-41Z_research_cncf-landscape/2026-11-23T22-33-41Z_research_cncf-landscape.md) — research record (2026-11-23): ~150 cloud-native projects across the seven areas this estate will need, each with CNCF status (graduated / incubating / sandbox / not CNCF) and an estate verdict — observability (OpenTelemetry as the contract; Prometheus as the language, VictoriaMetrics as the store; Grafana stays; no open-source Datadog exists), networking (Cilium yes; Gateway API after ingress-nginx's March 2026 retirement; MetalLB is the remembered LAN LoadBalancer; no service mesh yet), platform & GitOps (Flux over Argo CD for us; Cozystack fits with the caveat that it decides storage/tenancy/GitOps for you; Crossplane graduated but not now), data (TiKV no — a storage layer, not a database, and its Jepsen record is honest; CloudNativePG + replicas; NATS yes with a JetStream shape; LINSTOR over Rook), security & identity (Keycloak ≠ OpenBao; cert-manager and Kyverno when Kubernetes lands; SPIRE later, chained under the fleet CA; OPA management-plane only), runtimes (no OCI runtime is "much faster"; KubeVirt graduated and is the VMs-in-Kubernetes answer; Wasm apps designed to the Component Model, not WasmEdge), and registries & builds (GHCR until friction, then Zot; Harbor is a registry and Dragonfly a distribution layer, not alternatives; Nix + Actions already win the build category). Includes the Oct–Nov 2026 status-correction list (Crossplane, KubeVirt, NATS, Dragonfly graduated; CloudNativePG, OpenFGA promoted) and the uncertain-name identifications (Argonize doesn't exist; Trimmer→Tremor; Yuki→youki; Percy→Pixie; Spiffy→SPIFFE). - [Roc ecosystem research](2026-11-23T22-00-25Z_research_roc-ecosystem/2026-11-23T22-00-25Z_research_roc-ecosystem.md) — research record (2026-11-23): the state of the Roc language ecosystem — the new Zig compiler (feature parity July 2026; 0.1.0-RC1 shipped 2026-11-21, promotion to 0.1.0 still open), platforms (basic-cli, basic-webserver, Joy, roc-ray, roc-gui, Cloudflare Workers, native Android), the new-compiler package canon, real projects and production use (Joy/roc-deflate, roc-chat), a 30-day Zulip digest (linear types decided against FBIP; the LLM-generated-code conversation, no policy adopted; tooling and distribution progress), and the talks/releases/showcases worth watching. - [AUDIT-7 Lane 5 — design review](2026-11-24T00-11-27Z_report_audit-7-lane-5-design-review/2026-11-24T00-11-27Z_report_audit-7-lane-5-design-review.md) — exhaustive internal-soundness review of all 442 design records across the four repos (tracking #13876): dependency order and head prioritisation verified per design; zero true ordering defects, two major designs (#13765, #13774) found with no doc/ record, 10 records with no tracking-issue reference, full per-design ledger inside. +- [Provider/model purposes and input/output modality routing](2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities/2026-11-24T00-25-00Z_design_provider_model_kinds_and_modalities.md) — design for #10306: distinct operation purposes, directional modality requirements, capability-aware selection/failover, provider-family translation, migration slices, rollout, and verification. - [Turso → D1 migration audit](2026-11-23T23-15-07Z_design_turso-d1-migration-audit/2026-11-23T23-15-07Z_design_turso-d1-migration-audit.md) — table-by-table audit of all 50 Turso databases for #13844: measured usage (fleet-platform = 87% of writes, fleet-queue = 81% of reads, atlas = 73% of storage), MOVE-CLEAN / MOVE-WITH-BRIDGE / STAY-TURSO groups G1–G8 with the D1-first/Turso-fallback bridge pattern, an honest test of the D1-most-things end state (plan downgrade needs the queue read-shape fix too), and the recommended first slice (G1 telemetry mirror). - [Modes and configuration surface](2026-11-23T20-56-52Z_design_id9111_modes_config_surface/2026-11-23T20-56-52Z_design_id9111_modes_config_surface.md) — design record for #9111 (§7 of #9106): the config schema for modes, link kinds, storages and tiering (behaviour as config, mechanism as primitives), the peer/trust and namespace knobs in one schema, the #9144 fan-out keys with defaults and the `max_hops` ceiling of 8, file format and merge rules with fail-closed trust sections, open questions with chosen defaults, and implementation issues named but not filed. - [Iroh ecosystem — research record](2026-11-23T22-00-30Z_research_iroh-ecosystem/2026-11-23T22-00-30Z_research_iroh-ecosystem.md) — research record for #13779/#13752 (2026-11-23): iroh core at 1.5.0 on the frozen 1.0 wire protocol (identity, noq, relays, address lookup, custom transports, the post-1.0 release train); the first-party protocol family (blobs, gossip on the road to 1.0, docs, irpc 1.0, sendme/dumbpipe) with the iroh-willow staleness verdict; pkarr in both its roles (small signed-message channel and global discovery/relay bootstrap) and Pubky as its flagship consumer; real projects with honest scale labels (Delta Chat in depth — device setup, webxdc gossip channels, calls deliberately on WebRTC — OpenArchive Save, the shipped field); where the community actually talks (login-gated Discord vs the public GitHub Discussions board) with recent important conversations paraphrased (post-quantum identity, WebRTC as an external transport, group discovery and authorisation as open wants); the talks/releases/showcases index (23 items); and implications for the fleet (transport bet confirmed, gossip stabilisation, subduction_iroh on iroh 1.0, blinded address lookup, the watch list).