OpenRouter chat drift leg (cost-safe live canary + envelope triangulation)#333
Merged
Conversation
Add cost-safe drift coverage for the shipped OpenRouter chat/router mock
(src/openrouter-chat.ts), which had none. Mirrors openrouter-video.drift.ts:
1. LIVE canary (FREE, OPENROUTER_API_KEY-gated): GET /api/v1/models (catalog
metadata only, never a paid completion) — asserts the author families
aimock mirrors (openai/anthropic/google) are still present and the
per-model object schema has not drifted.
2. Static envelope shapes (no key): drive the real handler over
POST /api/v1/chat/completions and triangulate the non-streaming envelope,
a streaming chunk, the final usage-bearing chunk (cost/cost_details/
service_tier), and the OpenRouter error envelope {error:{code,message}}
against hand-authored conformant exemplars.
Adds listOpenRouterModels() to providers.ts and registers the
'openrouter-chat' surface in surface-registry.ts.
commit: |
jpr5
marked this pull request as ready for review
July 23, 2026 01:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenRouter chat drift leg (cost-safe live canary + static envelope triangulation)
Follow-up to #328, which shipped the OpenRouter chat/router mock (
src/openrouter-chat.ts,/api/v1/chat/completionsetc.) with zero drift coverage. This addssrc/__tests__/drift/openrouter-chat.drift.ts, mirroring the existingopenrouter-video.drift.tspattern cost-safely (no paid completions).Two parts
listOpenRouterModels()GETs the publicGET /api/v1/modelscatalog (metadata only, never a paid generation) and asserts the chat-model families aimock mirrors are still present and the model-object schema hasn't drifted.describe.skipIf(!OPENROUTER_API_KEY)— runs in CI where the secret exists, skips cleanly locally.gen-id / top-levelprovider/native_finish_reason/usage+cost_details/system_fingerprint/service_tier, a streaming chunk, and the error envelope) against hand-authored conformant exemplars.Registers the
openrouter-chatsurface insurface-registry.ts.OPENROUTER_API_KEYis already a repo secret and wired intotest-drift.yml.Review
API DRIFT DETECTED / TYPE MISMATCHreport; reverted → green.system_fingerprintfalse-pass (existence-only assertion) — now value-asserted and mutation-proven (forcing the mock to emitnullfails the leg); plus a namedjson.datacatalog-drift guard and an empty-catalog guard so the canary fails loudly, never silently.src/__tests__, excluded from the basetsc); leg green (static pass / live skip); build green. No version bump.🤖 Generated with Claude Code
https://claude.ai/code/session_018yy1y2Cwc31DaB4UNqvT8K