Skip to content

OpenRouter chat drift leg (cost-safe live canary + envelope triangulation)#333

Merged
jpr5 merged 1 commit into
mainfrom
feat/openrouter-chat-drift-leg
Jul 23, 2026
Merged

OpenRouter chat drift leg (cost-safe live canary + envelope triangulation)#333
jpr5 merged 1 commit into
mainfrom
feat/openrouter-chat-drift-leg

Conversation

@jpr5

@jpr5 jpr5 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

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/completions etc.) with zero drift coverage. This adds src/__tests__/drift/openrouter-chat.drift.ts, mirroring the existing openrouter-video.drift.ts pattern cost-safely (no paid completions).

Two parts

  1. Live canary (FREE, key-gated) — a new listOpenRouterModels() GETs the public GET /api/v1/models catalog (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.
  2. Static envelope triangulation (no key) — drives the real aimock handler over HTTP and triangulates the OpenRouter chat envelopes it emits (non-streaming gen- id / top-level provider / 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-chat surface in surface-registry.ts. OPENROUTER_API_KEY is already a repo secret and wired into test-drift.yml.

Review

  • Drift-detection demonstrated: perturbing an exemplar produced a real API DRIFT DETECTED / TYPE MISMATCH report; reverted → green.
  • CR caught and fixed a system_fingerprint false-pass (existence-only assertion) — now value-asserted and mutation-proven (forcing the mock to emit null fails the leg); plus a named json.data catalog-drift guard and an empty-catalog guard so the canary fails loudly, never silently.
  • Tests-inclusive typecheck clean (the drift file is under src/__tests__, excluded from the base tsc); leg green (static pass / live skip); build green. No version bump.

🤖 Generated with Claude Code

https://claude.ai/code/session_018yy1y2Cwc31DaB4UNqvT8K

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.
@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@333

commit: ea2d63c

@jpr5
jpr5 marked this pull request as ready for review July 23, 2026 01:54
@jpr5
jpr5 merged commit a8ddc97 into main Jul 23, 2026
28 checks passed
@jpr5
jpr5 deleted the feat/openrouter-chat-drift-leg branch July 23, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant