From 9e5fca685ccdeefe0459bd46e7271d902360421e Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Sat, 8 Aug 2026 09:40:52 -0300 Subject: [PATCH] test(cli): realign opencode-plugin suite to the bare-key static-catalog contract (#9614) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test(cli): realign opencode-plugin suite to the bare-key static-catalog contract #9178 (fix #9175) dropped the provider prefix from static-catalog model dict keys — the correct production behavior (OC's getModel looks models up by bare id), live-validated in the PR — but the subpackage's own suite was not swept: 21 tests in config-shim.test.ts + provider-id-routing.test.ts still asserted the prefixed keys, breaking opencode-plugin CI on every living-release-PR run since the merge. - Lookups opencode-omniroute/ -> ; omniroute/ -> . - #7976 anti-double-prefix invariant kept (the negative assert on the OC-gate-prefixed key stays). - Obsolete comment above the raw-model dict write rewritten to describe the #9175 contract it contradicted. - Subpackage lockfile synced to the already-bumped 0.2.1. Validation: full subpackage suite hermetic — 287/287 pass (was 21 failing). * fix(pr): fix changelog fragment format, login-bootstrap test assertions, and VM_DEPLOYMENT_GUIDE fabricated env vars * fix(pr): remove YAML frontmatter from changelog fragment (validator expects bare bullet) * fix(pr): update file-size baseline for base-red drift after merging 48 base commits * fix(pr): rename duplicate migration 134_proxy_logs_egress_ip to 139 * docs(changelog): fragment for #9614 * Revert "fix(pr): rename duplicate migration 134_proxy_logs_egress_ip to 139" This reverts commit 1312e1a917dc3e42a7e8ebbbe60d201fb6e0a0f4. --------- Co-authored-by: diegosouzapw --- @omniroute/opencode-plugin/src/index.ts | 10 +-- .../opencode-plugin/tests/config-shim.test.ts | 62 +++++++++---------- .../tests/provider-id-routing.test.ts | 6 +- .../9614-opencode-plugin-bare-key-suite.md | 1 + 4 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 changelog.d/maintenance/9614-opencode-plugin-bare-key-suite.md diff --git a/@omniroute/opencode-plugin/src/index.ts b/@omniroute/opencode-plugin/src/index.ts index 681b2fe3d0..35d29b3eac 100644 --- a/@omniroute/opencode-plugin/src/index.ts +++ b/@omniroute/opencode-plugin/src/index.ts @@ -4403,11 +4403,11 @@ export function buildStaticProviderEntry( entry.release_date = raw.release_date; } - // OC's static-catalog reader parses each key on `/` and rejects the - // entire provider block if ANY key resolves to a parsed providerID that - // has no corresponding provider block. So bare keys (no `/`) MUST be - // prefixed with the resolved providerId. Already-prefixed keys - // (e.g. `cc/claude-opus-4-7`) are left as-is to avoid double-prefixing. + // #9175: OC's `getModel` looks the model up by BARE id — the part after + // the first `/` in the user's request — so a dict key with an embedded + // provider prefix (`/`) is unreachable. Keys are the + // raw id verbatim; ids that already contain `/` (e.g. `cc/claude-opus-4-7`) + // keep it because the slash is part of the upstream model id itself. models[raw.id] = entry; } diff --git a/@omniroute/opencode-plugin/tests/config-shim.test.ts b/@omniroute/opencode-plugin/tests/config-shim.test.ts index 04ec61f1b7..9ea884c0a3 100644 --- a/@omniroute/opencode-plugin/tests/config-shim.test.ts +++ b/@omniroute/opencode-plugin/tests/config-shim.test.ts @@ -227,7 +227,7 @@ test("config: with valid auth.json + apiKey + baseURL → mutates input.provider // Stripped per-model shape: name + cap flags + modalities + (optional) // cost. OC's SDK static schema accepts only `limit.{context,output}` — // `limit.input` is NOT in the SDK shape and gets dropped silently. - const claude = entry.models["opencode-omniroute/claude-sonnet-4-6"]; + const claude = entry.models["claude-sonnet-4-6"]; assert.ok(claude, "claude model surfaced"); assert.equal(claude.name, "claude-sonnet-4-6"); assert.equal(claude.attachment, true); @@ -248,7 +248,7 @@ test("config: with valid auth.json + apiKey + baseURL → mutates input.provider // Combo surfaces under bare key + LCD'd // (gemini's reasoning=false → combo reasoning=false). - const combo = entry.models["omniroute/claude-tier"]; + const combo = entry.models["claude-tier"]; assert.ok(combo, "combo surfaced under bare key"); assert.equal(combo.name, "Claude Tier"); assert.equal(combo.reasoning, false, "LCD: any member reasoning=false → combo reasoning=false"); @@ -471,10 +471,10 @@ test("config: combos fetcher throws → emit models-only catalog (no combos in m assert.ok(entry); const ids = Object.keys(entry.models).sort(); assert.deepEqual(ids, [ - "opencode-omniroute/claude-sonnet-4-6", - "opencode-omniroute/gemini-3-flash", + "claude-sonnet-4-6", + "gemini-3-flash", ]); - assert.equal(entry.models["omniroute/claude-tier"], undefined, "no combo entry"); + assert.equal(entry.models["claude-tier"], undefined, "no combo entry"); assert.ok( logger.entries.some((e) => String(e[0]).includes("/api/combos fetch failed")), "combos-fetch breadcrumb emitted" @@ -723,7 +723,7 @@ test("buildStaticProviderEntry: stripped per-model shape matches sibling @omniro } // Sanity: claude entry has all expected stripped fields. - const claude = block.models["opencode-omniroute/claude-sonnet-4-6"]; + const claude = block.models["claude-sonnet-4-6"]; assert.equal(typeof claude.name, "string"); assert.equal(typeof claude.attachment, "boolean"); assert.equal(typeof claude.reasoning, "boolean"); @@ -748,8 +748,8 @@ test("buildStaticProviderEntry: hidden combos are excluded", () => { "https://or.example/v1", "sk-test" ); - assert.equal(block.models["omniroute/claude-tier"], undefined); - assert.ok(block.models["opencode-omniroute/claude-sonnet-4-6"]); + assert.equal(block.models["claude-tier"], undefined); + assert.ok(block.models["claude-sonnet-4-6"]); }); // ──────────────────────────────────────────────────────────────────────────── @@ -765,7 +765,7 @@ test("buildStaticProviderEntry: emits modalities.input from raw.input_modalities "https://or.example/v1", "sk-test" ); - const claude = block.models["opencode-omniroute/claude-sonnet-4-6"]; + const claude = block.models["claude-sonnet-4-6"]; assert.deepEqual(claude.modalities?.input, ["text", "image"]); assert.deepEqual(claude.modalities?.output, ["text"]); }); @@ -779,7 +779,7 @@ test("buildStaticProviderEntry: never emits limit.input (OC SDK rejects it)", () "https://or.example/v1", "sk-test" ); - const claude = block.models["opencode-omniroute/claude-sonnet-4-6"]; + const claude = block.models["claude-sonnet-4-6"]; assert.equal((claude.limit as Record).input, undefined); assert.equal(typeof claude.limit?.context, "number"); assert.equal(typeof claude.limit?.output, "number"); @@ -807,7 +807,7 @@ test("buildStaticProviderEntry: emits cost when enrichment carries pricing", () "sk-test", enrichment ); - const claude = block.models["opencode-omniroute/claude-sonnet-4-6"]; + const claude = block.models["claude-sonnet-4-6"]; assert.equal(claude.cost?.input, 3); assert.equal(claude.cost?.output, 15); assert.equal(claude.cost?.cache_read, 0.3); @@ -828,8 +828,8 @@ test("buildStaticProviderEntry: emits release_date when raw carries it; omits wh "https://or.example/v1", "sk-test" ); - assert.equal(block.models["opencode-omniroute/claude-with-date"].release_date, "2026-02-19"); - assert.equal(block.models["opencode-omniroute/gemini-3-flash"].release_date, undefined); + assert.equal(block.models["claude-with-date"].release_date, "2026-02-19"); + assert.equal(block.models["gemini-3-flash"].release_date, undefined); }); test("buildStaticProviderEntry: combo modalities = intersection of members (LCD)", () => { @@ -858,7 +858,7 @@ test("buildStaticProviderEntry: combo modalities = intersection of members (LCD) "https://or.example/v1", "sk-test" ); - const combo = block.models["omniroute/mixed-tier"]; + const combo = block.models["mixed-tier"]; assert.ok(combo, "combo emitted under slug key"); // claude has text+image, text-only has text → intersection drops image. assert.deepEqual(combo.modalities?.input, ["text"]); @@ -967,10 +967,10 @@ test("config: enrichment fetched + name overlaid on raw-model entries", async () "opencode-omniroute" ]; assert.ok(entry); - assert.equal(entry.models["opencode-omniroute/claude-sonnet-4-6"].name, "Claude Sonnet 4.6"); - assert.equal(entry.models["opencode-omniroute/gemini-3-flash"].name, "Gemini 3 Flash"); + assert.equal(entry.models["claude-sonnet-4-6"].name, "Claude Sonnet 4.6"); + assert.equal(entry.models["gemini-3-flash"].name, "Gemini 3 Flash"); // Combo names still come from /api/combos — enrichment overlay does NOT touch combos. - assert.equal(entry.models["omniroute/claude-tier"].name, "Claude Tier"); + assert.equal(entry.models["claude-tier"].name, "Claude Tier"); assert.equal(enrichmentFetcher.callCount(), 1); }); @@ -1000,7 +1000,7 @@ test("config: features.enrichment=false skips enrichment fetch + keeps raw-id na assert.ok(entry); assert.equal(enrichmentFetcher.callCount(), 0, "enrichment fetch suppressed by feature flag"); assert.equal( - entry.models["opencode-omniroute/claude-sonnet-4-6"].name, + entry.models["claude-sonnet-4-6"].name, "claude-sonnet-4-6", "raw id retained" ); @@ -1027,7 +1027,7 @@ test("config: enrichment fetcher throws → soft-fail (warn + raw-id static cata ]; assert.ok(entry, "static block still published on enrichment failure"); assert.equal( - entry.models["opencode-omniroute/claude-sonnet-4-6"].name, + entry.models["claude-sonnet-4-6"].name, "claude-sonnet-4-6", "raw id retained" ); @@ -1229,11 +1229,11 @@ test("config: diskCache hydrates stale snapshot when /v1/models throws", async ( "opencode-omniroute" ]; assert.ok( - entry.models["opencode-omniroute/claude-sonnet-4-6"], + entry.models["claude-sonnet-4-6"], "stale snapshot hydrated into static block" ); assert.equal( - entry.models["opencode-omniroute/claude-sonnet-4-6"].name, + entry.models["claude-sonnet-4-6"].name, "Claude Sonnet 4.6 (cached)", "stale enrichment also reused" ); @@ -1281,7 +1281,7 @@ test("config: cached rawEnrichment from earlier provider hook is reused (no refe const entry = (input as { provider: Record }).provider[ "opencode-omniroute" ]; - assert.equal(entry.models["opencode-omniroute/claude-sonnet-4-6"].name, "Claude Sonnet 4.6"); + assert.equal(entry.models["claude-sonnet-4-6"].name, "Claude Sonnet 4.6"); }); // ───────────────────────────────────────────────────────────────────── @@ -1332,12 +1332,12 @@ test("config: providerTag (default-on) prepends ' - ' to enriched raw- ]; assert.ok(entry); assert.equal( - entry.models["opencode-omniroute/claude-sonnet-4-6"].name, + entry.models["claude-sonnet-4-6"].name, "Claude - Claude Sonnet 4.6" ); - assert.equal(entry.models["opencode-omniroute/gemini-3-flash"].name, "Gemini - Gemini 3 Flash"); + assert.equal(entry.models["gemini-3-flash"].name, "Gemini - Gemini 3 Flash"); // Combos stay untouched — `Combo: ` prefix already conveys multi-upstream. - assert.equal(entry.models["omniroute/claude-tier"].name, "Claude Tier"); + assert.equal(entry.models["claude-tier"].name, "Claude Tier"); }); test("config: providerTag=false suppresses the suffix", async () => { @@ -1364,7 +1364,7 @@ test("config: providerTag=false suppresses the suffix", async () => { "opencode-omniroute" ]; assert.equal( - entry.models["opencode-omniroute/claude-sonnet-4-6"].name, + entry.models["claude-sonnet-4-6"].name, "Claude Sonnet 4.6", "enriched name kept, provider tag suppressed" ); @@ -1396,7 +1396,7 @@ test("config: providerTag falls back to UPPER(alias) when providerDisplayName mi const entry = (input as { provider: Record }).provider[ "opencode-omniroute" ]; - assert.equal(entry.models["opencode-omniroute/claude-sonnet-4-6"].name, "CC - Claude Sonnet 4.6"); + assert.equal(entry.models["claude-sonnet-4-6"].name, "CC - Claude Sonnet 4.6"); }); test("config: providerTag skipped entirely when neither providerDisplayName nor providerAlias set", async () => { @@ -1423,7 +1423,7 @@ test("config: providerTag skipped entirely when neither providerDisplayName nor const entry = (input as { provider: Record }).provider[ "opencode-omniroute" ]; - assert.equal(entry.models["opencode-omniroute/claude-sonnet-4-6"].name, "Claude Sonnet 4.6"); + assert.equal(entry.models["claude-sonnet-4-6"].name, "Claude Sonnet 4.6"); }); test("config: providerTag is idempotent — second hook call doesn't double-suffix", async () => { @@ -1451,7 +1451,7 @@ test("config: providerTag is idempotent — second hook call doesn't double-suff "opencode-omniroute" ]; assert.equal( - entryA.models["opencode-omniroute/claude-sonnet-4-6"].name, + entryA.models["claude-sonnet-4-6"].name, "Claude - Claude Sonnet 4.6" ); @@ -1462,7 +1462,7 @@ test("config: providerTag is idempotent — second hook call doesn't double-suff "opencode-omniroute" ]; assert.equal( - entryB.models["opencode-omniroute/claude-sonnet-4-6"].name, + entryB.models["claude-sonnet-4-6"].name, "Claude - Claude Sonnet 4.6" ); }); @@ -1516,7 +1516,7 @@ test("buildStaticProviderEntry: nested combo-ref context is the bottleneck acros ); // Pre-fix: Parent would advertise 200_000 (only raw-big counted). // Post-fix: Parent should advertise 8_000 (TinyCombo bottleneck). - const parent = block.models["omniroute/parent"]; + const parent = block.models["parent"]; assert.ok(parent, "Parent combo must be in the static catalog"); assert.equal(parent.limit?.context, 8_000); }); diff --git a/@omniroute/opencode-plugin/tests/provider-id-routing.test.ts b/@omniroute/opencode-plugin/tests/provider-id-routing.test.ts index a55e935475..0d2fda45e2 100644 --- a/@omniroute/opencode-plugin/tests/provider-id-routing.test.ts +++ b/@omniroute/opencode-plugin/tests/provider-id-routing.test.ts @@ -111,7 +111,9 @@ test("#6859: createOmniRouteProviderHook end-to-end — catalog keys/providerID // `opencode-omniroute`. Confirmed against the issue's own curl repro // (`model: "opencode-omniroute/hermes-smart-stack"` → "No active // credentials for provider: opencode-omniroute"). -test("#7976: buildStaticProviderEntry keys bare-slug combo ids with the unprefixed omnirouteProviderId (no double OC-gate prefix)", () => { +// #9175 tightened this further: OC's `getModel` looks models up by BARE id, +// so combo dict keys now carry NO prefix at all (not even `omniroute/`). +test("#7976/#9175: buildStaticProviderEntry keys combos by bare slug (no prefix at all — never the OC-gate providerId)", () => { const resolved = resolveOmniRoutePluginOptions({ providerId: "omniroute" }); assert.equal(resolved.providerId, "opencode-omniroute"); assert.equal(resolved.omnirouteProviderId, "omniroute"); @@ -131,7 +133,7 @@ test("#7976: buildStaticProviderEntry keys bare-slug combo ids with the unprefix "sk-test" ); - assert.deepEqual(Object.keys(block.models), ["omniroute/hermes-smart-stack"]); + assert.deepEqual(Object.keys(block.models), ["hermes-smart-stack"]); assert.equal( block.models["opencode-omniroute/hermes-smart-stack"], undefined, diff --git a/changelog.d/maintenance/9614-opencode-plugin-bare-key-suite.md b/changelog.d/maintenance/9614-opencode-plugin-bare-key-suite.md new file mode 100644 index 0000000000..c47643b915 --- /dev/null +++ b/changelog.d/maintenance/9614-opencode-plugin-bare-key-suite.md @@ -0,0 +1 @@ +- **test(cli):** OpenCode plugin suite realigned to the bare-key static-catalog contract from #9178/#9175 (21 tests were red on every opencode-plugin CI run; 287/287 after) ([#9614](https://github.com/diegosouzapw/OmniRoute/pull/9614))