Skip to content

Commit 37dfe49

Browse files
committed
test: guard manifest catalog against baseline projection drift
Parses openclaw.plugin.json and compares every modelCatalog entry with the providerFromRows projection of the bundled baseline (ids, order, api, baseUrl, contextWindow, maxTokens, cost), so the JS projection in generate-baseline.mjs can never silently diverge from projectModel.
1 parent 314d215 commit 37dfe49

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

test/modelMapping.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
resolveCommandCodeDynamicModel,
77
} from "../index.js";
88
import { commandCodeBaselineModels } from "../src/baseline.models.js";
9+
import manifest from "../openclaw.plugin.json";
910

1011
describe("isClaudeModel", () => {
1112
it("detects Claude ids by convention", () => {
@@ -129,3 +130,37 @@ describe("resolveCommandCodeDynamicModel", () => {
129130
expect(m?.api).toBe("anthropic-messages");
130131
});
131132
});
133+
134+
describe("manifest modelCatalog (drift guard)", () => {
135+
const catalog = manifest.modelCatalog.providers.commandcode;
136+
const projected = providerFromRows(commandCodeBaselineModels);
137+
138+
it("mirrors the baseline projection model by model", () => {
139+
expect(catalog.models.length).toBe(projected.models.length);
140+
const byId = new Map(projected.models.map((m) => [m.id, m]));
141+
for (const entry of catalog.models) {
142+
const expected = byId.get(entry.id);
143+
expect(expected, `manifest model ${entry.id} missing from baseline projection`).toBeDefined();
144+
expect(entry.name).toBe(expected?.name);
145+
expect(entry.api).toBe(expected?.api);
146+
expect(entry.baseUrl).toBe(expected?.baseUrl);
147+
expect(entry.reasoning).toBe(expected?.reasoning);
148+
expect(entry.input).toEqual(expected?.input);
149+
expect(entry.contextWindow).toBe(expected?.contextWindow);
150+
expect(entry.maxTokens).toBe(expected?.maxTokens);
151+
expect(entry.cost).toEqual(expected?.cost);
152+
}
153+
});
154+
155+
it("keeps ids in the same order as the baseline", () => {
156+
expect(catalog.models.map((m) => m.id)).toEqual(
157+
commandCodeBaselineModels.map((r) => r.id),
158+
);
159+
});
160+
161+
it("declares static discovery and the provider-level transport", () => {
162+
expect(manifest.modelCatalog.discovery.commandcode).toBe("static");
163+
expect(catalog.baseUrl).toBe("https://api.commandcode.ai/provider/v1");
164+
expect(catalog.api).toBe("openai-completions");
165+
});
166+
});

0 commit comments

Comments
 (0)