test(providers): SSOT-driven DeriveProvider routing matrix — every offered runtime×provider gated (keyless, required-lane) #2292
Reference in New Issue
Block a user
Delete Branch "harden/derive-provider-matrix-e2e"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
SSOT-driven, KEYLESS, REQUIRED-lane-gateable test that asserts every offered (runtime × model/provider arm) in the providers SSOT resolves to the exact correct provider via
DeriveProvider— closing the provider-routing-correctness coverage hole for ALL ~29 providers + every BYOK arm without needing any LLM key.Closes the gap flagged in the regression-coverage audit: many offered (runtime → provider) pairs — hermes's 17 name-only BYOK arms, claude-code's zai/deepseek/xiaomi-mimo, openclaw's byok-openai/byok-minimax/groq/openrouter/custom, codex's byok-minimax, etc. — are pure prefix-routing (resolved by
DeriveProvider(runtime, modelId)) and had zero test. A regression in the routing table (wrong provider, dropped arm, bad regex) shipped silently and wedged tenant agents at boot.Why keyless / why it gates in the required lane
DeriveProvider+ModelPrefixMatchresolve a model id to a provider with no upstream call — a pure function of the merged registry. So the entire offered routing table is gateable in the REQUIREDCI / all-requiredlane with zero secrets.Approach — SSOT-driven, not hardcoded
workspace-server/internal/providers/derive_provider_matrix_test.goiteratesLoadManifest().Runtimes(the same registry production reads). For every runtime × every offered arm it asserts: (a)DeriveProviderresolves to the exact expected provider (computed from the SSOT), (b) the (runtime, model) is registration-valid (thevalidateRegisteredModelForRuntimepredicate: on the platform menu OR DeriveProvider resolves), (c) no offered id silently misroutes or falls through.Coverage
5 runtimes, 43 (runtime×provider) arms across 29 distinct providers, 53 exact-listed (runtime×model) assertions + 29 name-only BYOK routing probes (82 routing assertions total).
Known-tricky forms pinned explicitly
So a regression names its class, not just a generic cell:
MiniMax-M2.7→minimax,minimax/…→platform,minimax:…→unregistered (adapter can't stripminimax:)groq:→groq; openclawminimax:→byok-minimaxanthropic//gemini//openai:/minimax:→byok-*(NOT platform — cp#529 tenant-key billing safety)gpt-*no-auth→openai-subscriptionvsOPENAI_API_KEY→openai-apiplatform:→platformvs baregemini-…→googleWatch-it-fail proof
Adding
minimax:MiniMax-M2.7to claude-code'splatformarm (pointing the colon BYOK form at platform) reds the matrix naming the exact mismatch:Reverted → green. This proves real coverage of the #2263/#2274 routing class.
Verification
go test ./internal/providers/ -run 'DeriveProvider|Matrix|Routing' -count=1— all greengo build ./...— cleango vet ./internal/providers/— cleanTest-only; additive; no production path changed.
🤖 Generated with Claude Code
Closes the provider-routing-correctness coverage hole identified in the regression-coverage audit: many offered (runtime → provider) pairs — hermes's 17 name-only BYOK arms, claude-code's zai/deepseek/xiaomi-mimo, openclaw's byok-openai/byok-minimax/groq/openrouter/custom, codex's byok-minimax, etc. — are pure prefix-routing resolved by DeriveProvider(runtime, modelId) and had ZERO test. A regression in the routing table (wrong provider, dropped arm, bad regex) shipped silently and wedged tenant agents at boot. DeriveProvider + ModelPrefixMatch resolve a model id to a provider with NO upstream call — fully keyless — so the ENTIRE offered routing table is gateable in the REQUIRED CI / all-required lane with zero secrets. derive_provider_matrix_test.go is SSOT-DRIVEN (not hardcoded): it iterates LoadManifest().Runtimes (the same registry production reads) and, for every runtime × every offered model/provider arm, asserts (a) DeriveProvider resolves to the EXACT expected provider (computed from the SSOT), (b) the (runtime, model) is registration-valid (the validateRegisteredModelForRuntime predicate), and (c) no offered id silently resolves to the wrong arm or falls through. - exact-listed arms: every model id iterated off the SSOT, expected provider computed from native declaration order (first-declared wins the codex/ anthropic "one id, two auth arms" shape). A newly-added model is auto-covered. - name-only arms (zero models, pure prefix BYOK): each probed with a representative BYOK id its regex must own. The matrix REQUIRES a representative for every name-only arm in the SSOT — "added an arm, forgot routing/sample" fails RED. A dead representative (provider removed) also fails RED. Coverage: 5 runtimes, 43 (runtime×provider) arms across 29 distinct providers, 53 exact-listed (runtime×model) assertions + 29 name-only BYOK routing probes. Known-tricky forms pinned as explicit assertions so a regression names its class: the #2263/#2274 colon-vs-slash-vs-bare MiniMax triple on claude-code (bare→minimax, slash→platform, colon→unregistered), openai-namespaced-rejected-on-claude-code (#2265 class), groq→groq, hermes anthropic//gemini//openai://minimax: → byok-* (NOT platform — cp#529 billing safety), codex gpt default→openai-subscription vs OPENAI_API_KEY→openai-api, google-adk platform: vs bare gemini. Watch-it-fail proven: adding minimax:MiniMax-M2.7 to claude-code's platform arm (pointing the colon BYOK form at platform) reds the matrix naming the exact mismatch ("= platform, want an unregistered/unrouteable ERROR"); reverted → green. go build ./... and go vet ./internal/providers/ clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>Reviewed: SSOT-driven DeriveProvider routing matrix — 82 assertions across 29 providers + every offered runtime×provider arm + name-only BYOK probes, keyless in the required internal/providers lane. Iterates LoadManifest().Runtimes so new providers auto-covered; requires a representative for every name-only arm (catches added-arm-but-no-routing). Pins the tricky classes (#2263/#2274 minimax colon/slash/bare, #2265, hermes BYOK billing-safety cp#529, codex auth-split, groq). Watch-it-fail proven (pointed minimax-colon at platform → RED). Test-only, additive, go build/vet/test green. Big coverage win for the no-regression goal. Approve.
5-axis review: APPROVED.
Correctness: This is a test-only SSOT-driven DeriveProvider routing matrix that walks LoadManifest().Runtimes rather than duplicating a hand-maintained table. It covers exact-listed model arms, name-only BYOK/provider-prefix arms through required representatives, registration-validity, and explicit historically tricky routing forms including minimax slash/colon/bare, hermes BYOK vendor arms, codex auth-env selection, and google-adk platform/BYOK split.
Robustness: The representative coverage is bidirectional: missing samples for new name-only arms fail, and stale representative entries fail. The floor guards prevent an accidentally empty matrix from passing. Security: no secrets or live provider calls; this is pure keyless registry/provider routing validation. Performance: bounded unit-test matrix over the manifest with pure DeriveProvider calls, acceptable for the required lane. Readability: verbose, but the comments document why each guard exists and the deterministic ordering keeps failures stable.
Required-context review: head
c3fd113780is mergeable; E2E API Smoke and Handlers PG are green, and the red combined state is from SOP-tier ceremony, not a code/required-context failure.