Skip to content

Commit 7063e3e

Browse files
committed
test(catalog): guard the dated fold's direction at the merge loop, not the predicate
#3034 widens the dated-suffix matcher and pins it with a predicate test that the fold stays one-way: isDatedVariantId("deepseek-v4-pro", "deepseek-v4-pro-0813") is false. That assertion is true of every implementation, including one whose merge loop calls the predicate a second time with the arguments swapped -- which is exactly what #3041 originally proposed and then withdrew. So the guard is moved to where the resurrection would actually happen. These three drive mergeConfiguredModelsIntoLiveCatalog itself, carried from #3041: - a live base row must not resurrect a configured dated id - a live MMDD dated row still folds onto its configured base - a dated id named in retainConfiguredModelIds survives Both directions were mutation-checked. Adding || isDatedVariantId(candidate.id, live.id) to the merge loop fails only the first test (253 pass / 1 fail); narrowing the suffix back to /^\d{8}$/ fails 13, including the MMDD and YYMM folds. Neither mutation is caught by the predicate test alone. The retention test is labelled for what it actually covers: production fills retainConfiguredModelIds from combo targets, not from providers.*.models, so it pins the OCX-111 path. The operator-facing opt-in is #1690's retainModels, which does not exist yet -- and until it does, the dated id #3024 reports is still dropped. This lands the safe half of #3024 and says so. (cherry picked from commit a909682)
1 parent 236858e commit 7063e3e

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

tests/codex-catalog.test.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
33
import { tmpdir } from "node:os";
44
import { join } from "node:path";
55
import { applyNativeVisibility, augmentRoutedModelsWithMetadata, augmentRoutedModelsWithRegistryOpenAiApiRows, buildCatalogEntries, buildComboCatalogOmission, catalogModelSlug, clampCatalogModelsToCodexSupport, clampEntryToCodexSupportedEfforts, clampedDefaultEffort, CODEX_ACCOUNT_BOUND_CATALOG_KIND, CODEX_NATIVE_ALIAS_CATALOG_KIND, comboCatalogOmissionReason, deriveComboCatalogModel, exactComboCatalogSlugs, filterCatalogVisibleModels, filterSupportedNativeSlugs, gatherRoutedModels as gatherRoutedModelsDirect, isDatedVariantId, isMediaGenerationModelId, loadBundledCodexCatalog, materializeBundledCodexCatalog, mergeCatalogEntriesForSync, NATIVE_DAYBREAK_BLUE_MODEL, NATIVE_OPENAI_MODELS, nativeDefaultReasoningEffort, nativeInputModalities, nativeOpenAiCapabilitySourceSlug, nativeOpenAiContextWindow, nativeReasoningEfforts, normalizeRoutedCatalogEntry, resetCatalogRuntimeStateForTests, resetOpenAiApiCatalogWarningStateForTests, resolveComboCatalogMember, shouldExposeRoutedModel, upstreamNativeEntry } from "../src/codex/catalog";
6-
import { applyProviderConfigHints } from "../src/codex/catalog/provider-fetch";
6+
import { applyProviderConfigHints, mergeConfiguredModelsIntoLiveCatalog } from "../src/codex/catalog/provider-fetch";
77
import {
88
CODEX_CUSTOM_MODEL_CATALOG_KIND,
99
CODEX_PROVIDER_MODEL_CATALOG_KIND,
@@ -3713,6 +3713,49 @@ describe("Codex catalog routed normalization", () => {
37133713
expect(isDatedVariantId("deepseek-v4-pro", "deepseek-v4-pro-0813")).toBe(false);
37143714
});
37153715

3716+
// The predicate test above is necessary and not sufficient: it passes on any
3717+
// implementation, including one whose MERGE LOOP calls the predicate a second time with
3718+
// the arguments swapped. These three drive `mergeConfiguredModelsIntoLiveCatalog` itself,
3719+
// so they fail if the loop ever becomes bidirectional. Carried from #3041, where the
3720+
// reverse fold was proposed and then withdrawn — the guard outlives the proposal.
3721+
test("the merge loop does not infer a configured dated id from a live base id", () => {
3722+
const { models, droppedConfiguredIds } = mergeConfiguredModelsIntoLiveCatalog({
3723+
name: "deepseek",
3724+
provider: {},
3725+
models: [{ id: "deepseek-v4-pro" } as never],
3726+
configured: [{ id: "deepseek-v4-pro-0813" } as never],
3727+
});
3728+
expect(droppedConfiguredIds).toEqual(["deepseek-v4-pro-0813"]);
3729+
expect(models.map(m => m.id)).not.toContain("deepseek-v4-pro-0813");
3730+
});
3731+
3732+
test("the merge loop folds a live MMDD dated row onto its configured base", () => {
3733+
const { models, droppedConfiguredIds } = mergeConfiguredModelsIntoLiveCatalog({
3734+
name: "deepseek",
3735+
provider: {},
3736+
models: [{ id: "deepseek-v4-pro-0813" } as never],
3737+
configured: [{ id: "deepseek-v4-pro" } as never],
3738+
});
3739+
expect(droppedConfiguredIds).toEqual([]);
3740+
expect(models.map(m => m.id)).toContain("deepseek-v4-pro");
3741+
});
3742+
3743+
// Retention of a dated id is a decision someone made, not an inference from a name.
3744+
// Note what this set actually is: production fills `retainConfiguredModelIds` from combo
3745+
// targets, not from `providers.*.models`, so this pins the combo-target path (OCX-111).
3746+
// The operator-facing opt-in is #1690's `retainModels`, which does not exist yet.
3747+
test("a dated id named in retainConfiguredModelIds survives the drop", () => {
3748+
const { models, droppedConfiguredIds } = mergeConfiguredModelsIntoLiveCatalog({
3749+
name: "deepseek",
3750+
provider: {},
3751+
models: [{ id: "deepseek-v4-pro" } as never],
3752+
configured: [{ id: "deepseek-v4-pro-0813" } as never],
3753+
retainConfiguredModelIds: new Set(["deepseek-v4-pro-0813"]),
3754+
});
3755+
expect(droppedConfiguredIds).toEqual([]);
3756+
expect(models.map(m => m.id)).toContain("deepseek-v4-pro-0813");
3757+
});
3758+
37163759
test("disabled providers are excluded from routed model gathering", async () => {
37173760
const models = await gatherRoutedModels({
37183761
port: 10100,

0 commit comments

Comments
 (0)