Skip to content

Commit ed11ac1

Browse files
committed
test(routing): cover the registry branch of the capability lookups
The three registry lookups this PR changed are only reached when the provider is absent from the config, and every case in the file supplied one — so `registryEntry?.model*` went untested. Add a case that resolves `grok-4.6:latest` off the `xai` registry entry with no provider configured, asserting the window, the image modality and the reasoning efforts. It asserts the fixture's shape rather than its values, so registry churn does not turn into a false failure while real drift still does. Against origin/dev the new case fails with `Expected: 500000, Received: undefined`, which is the branch it is meant to hold. Thanks @coderabbitai for the catch.
1 parent 1c82ec8 commit ed11ac1

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎tests/routing-capability-model-matching.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, test } from "bun:test";
22
import { candidateCapabilityEvidence } from "../src/routing/capability";
3+
import { PROVIDER_REGISTRY } from "../src/providers/registry";
34
import { modelRecordValue } from "../src/reasoning-effort";
45
import { isModelTextOnly } from "../src/vision";
56
import type { OcxConfig, OcxProviderConfig } from "../src/types";
@@ -77,6 +78,28 @@ describe("candidateCapabilityEvidence model matching", () => {
7778
expect(evidence.reasoningEfforts).toBeUndefined();
7879
});
7980

81+
test("a registry entry covers its tagged siblings with no provider configured", () => {
82+
// The three registry lookups (capability.ts lines 170/180/206) are a separate branch
83+
// from the configured-provider ones above: they are only reached when the provider is
84+
// absent from the config, which every other case here supplies.
85+
const registryEntry = PROVIDER_REGISTRY.find(entry => entry.id === "xai");
86+
if (!registryEntry) throw new Error("fixture drift: no `xai` entry in PROVIDER_REGISTRY");
87+
88+
// Pin the fixture's shape rather than its values, so registry churn does not turn
89+
// into a false failure here while real drift still does.
90+
const family = "grok-4.6";
91+
expect(registryEntry.modelContextWindows?.[family]).toBeNumber();
92+
expect(registryEntry.modelInputModalities?.[family]).toBeArray();
93+
expect(registryEntry.modelReasoningEfforts?.[family]).toBeArray();
94+
95+
const emptyConfig = { providers: {} } as unknown as OcxConfig;
96+
const evidence = candidateCapabilityEvidence(emptyConfig, "xai", `${family}:latest`);
97+
98+
expect(evidence.contextWindow).toBe(registryEntry.modelContextWindows![family]);
99+
expect(evidence.image).toBe(registryEntry.modelInputModalities![family].includes("image"));
100+
expect(evidence.reasoningEfforts).toEqual(registryEntry.modelReasoningEfforts![family]);
101+
});
102+
80103
test("a prototype-shaped model id resolves nothing", () => {
81104
// modelRecordValue uses hasOwnProperty; a bare lookup would return Object.prototype
82105
// members here and hand routing a function as evidence.

0 commit comments

Comments
 (0)