Skip to content

Commit 8daaf45

Browse files
committed
fix(codex): gate gpt-5.6 native models by entitlement
Sol/Terra/Luna shipped as static native rows, so an account without upstream entitlement saw them advertised (Codex catalog, Claude gateway discovery, management rows) and every request died upstream with "model is not supported when using Codex with a ChatGPT account", relaid to Claude Code as repeated 502 stream truncations. Add the GPT-5.6 family to ACCOUNT_GATED_NATIVE_OPENAI_MODELS so the existing per-account /models roster evidence gates catalog projection, gateway discovery, and Pool/Direct dispatch — the same mechanism #2097 shipped for Daybreak Blue. Unconfirmed rosters fail closed. Tests reworked to seed rosters where they exercise window/effort/toggle mechanics rather than gating, and to use ungated stand-ins where the slug was only an ordinary-native fixture. Refs #2548
1 parent c0c9544 commit 8daaf45

13 files changed

Lines changed: 225 additions & 81 deletions

‎src/codex/catalog/native-models.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ export const NATIVE_DAYBREAK_BLUE_MODEL = "gpt-daybreak-blue-latest";
33

44
/** Native ChatGPT/Codex ids whose availability is proven per authenticated account. */
55
export const ACCOUNT_GATED_NATIVE_OPENAI_MODELS: ReadonlySet<string> = new Set([
6+
"gpt-5.6-sol",
7+
"gpt-5.6-terra",
8+
"gpt-5.6-luna",
69
NATIVE_DAYBREAK_BLUE_MODEL,
710
]);
811

@@ -58,8 +61,8 @@ export function nativeOpenAiCapabilitySourceSlug(slug: string): string {
5861
* discover it on a clean install.
5962
*
6063
* Availability is not static: catalog sync and Pool routing require the account's authenticated
61-
* `/models` roster to contain the slug. An unconfirmed or unentitled account never receives the
62-
* request. `disabledModels` remains the independent user visibility control.
64+
* `/models` roster to contain account-gated slugs. An unconfirmed or unentitled account never
65+
* receives the request. `disabledModels` remains the independent user visibility control.
6366
*
6467
* Devlog: 260816_codexrs_multiagent_v2_and_history_perf/011 §4-bis.
6568
*/

‎tests/claude-desktop-native-context.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { join } from "node:path";
55
import { buildClaudeDesktopState } from "../src/server/management/shared";
66
import { nativeOpenAiContextWindow, visibleNativeSlugs } from "../src/codex/catalog";
77
import { generateDesktop3pModels } from "../src/claude/desktop-3p";
8+
import {
9+
resetCodexModelEntitlementCacheForTests,
10+
seedCodexModelEntitlementsForTests,
11+
} from "../src/codex/model-entitlements";
812
import type { OcxConfig } from "../src/types";
913

1014
/**
@@ -24,6 +28,8 @@ const config = {
2428
} as unknown as OcxConfig;
2529

2630
test("buildClaudeDesktopState gives native rows their real context window", async () => {
31+
// Sol/Terra/Luna are account-gated; this test is about window metadata, so confirm them.
32+
seedCodexModelEntitlementsForTests("main", ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"]);
2733
const home = tempHome();
2834
const prev = process.env.OPENCODEX_CLAUDE_DESKTOP_CONFIG_DIR;
2935
process.env.OPENCODEX_CLAUDE_DESKTOP_CONFIG_DIR = home;
@@ -44,6 +50,7 @@ test("buildClaudeDesktopState gives native rows their real context window", asyn
4450
if (prev === undefined) delete process.env.OPENCODEX_CLAUDE_DESKTOP_CONFIG_DIR;
4551
else process.env.OPENCODEX_CLAUDE_DESKTOP_CONFIG_DIR = prev;
4652
rmSync(home, { recursive: true, force: true });
53+
resetCodexModelEntitlementCacheForTests();
4754
}
4855
});
4956

‎tests/codex-auth-context.test.ts‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ describe("Codex auth context", () => {
450450
});
451451
let discoveries = 0;
452452
await expect(resolveCodexAuthContext(new Headers(), config(), "pool", {
453-
modelId: "gpt-5.6-sol",
453+
modelId: "gpt-5.5",
454454
resolveCodexModelEntitlements: async () => {
455455
discoveries += 1;
456456
throw new Error("must not run");
@@ -479,7 +479,7 @@ describe("Codex auth context", () => {
479479

480480
const exactContext = await resolveCodexAuthContext(headers, cfg, "direct", {
481481
accountId: "pool-a",
482-
modelId: "gpt-5.6-sol",
482+
modelId: "gpt-5.5",
483483
});
484484
expect(exactContext).toMatchObject({
485485
kind: "pool",
@@ -493,7 +493,7 @@ describe("Codex auth context", () => {
493493
_codexAccountOverride: { accessToken: "fixed_pool_token", chatgptAccountId: "fixed_pool_acc" },
494494
});
495495
expect(cfg.activeCodexAccountId).toBe("pool-b");
496-
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.6-sol" }))
496+
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.5" }))
497497
.resolves.toMatchObject({ kind: "pool", accountId: "pool-b" });
498498
});
499499

@@ -706,15 +706,15 @@ describe("Codex auth context", () => {
706706

707707
// The pool path honors the order: pool-b outranks pool-a, so an unbound request
708708
// prefers pool-b.
709-
await expect(resolveCodexAuthContext(new Headers(), cfg, "pool", { modelId: "gpt-5.6-sol" }))
709+
await expect(resolveCodexAuthContext(new Headers(), cfg, "pool", { modelId: "gpt-5.5" }))
710710
.resolves.toMatchObject({ kind: "pool", accountId: "pool-b" });
711711

712712
// An exact selector names pool-a: it must resolve to pool-a even though pool-b is
713713
// ordered earlier. Selection order is a tiebreak inside the eligible pool, never a
714714
// way to redirect a request that already named its account.
715715
await expect(resolveCodexAuthContext(new Headers(), cfg, "pool", {
716716
accountId: "pool-a",
717-
modelId: "gpt-5.6-sol",
717+
modelId: "gpt-5.5",
718718
})).resolves.toMatchObject({
719719
kind: "pool",
720720
accountId: "pool-a",
@@ -735,7 +735,7 @@ describe("Codex auth context", () => {
735735

736736
await expect(resolveCodexAuthContext(new Headers(), cfg, "pool", {
737737
accountId: MAIN_CODEX_ACCOUNT_ID,
738-
modelId: "gpt-5.6-sol",
738+
modelId: "gpt-5.5",
739739
})).resolves.toMatchObject({
740740
kind: "main-pool",
741741
accountId: MAIN_CODEX_ACCOUNT_ID,
@@ -841,7 +841,7 @@ describe("Codex auth context", () => {
841841
expect(isCodexAuthContextUsable(captured, cfg)).toBe(true);
842842
await expect(resolveCodexAuthContext(new Headers(), cfg, "pool", {
843843
accountId: "pool-a",
844-
modelId: "gpt-5.6-sol",
844+
modelId: "gpt-5.5",
845845
})).rejects.toThrow("Selected Codex account is unavailable");
846846
expect(cfg.activeCodexAccountId).toBe("pool-a");
847847
await expect(resolveCodexAuthContext(new Headers(), cfg, "pool"))
@@ -868,7 +868,7 @@ describe("Codex auth context", () => {
868868

869869
await expect(resolveCodexAuthContext(new Headers(), cfg, "pool", {
870870
accountId: "pool-a",
871-
modelId: "gpt-5.6-sol",
871+
modelId: "gpt-5.5",
872872
})).rejects.toThrow("Selected Codex account needs reauthentication");
873873
expect(cfg.activeCodexAccountId).toBe("pool-b");
874874
});
@@ -885,7 +885,7 @@ describe("Codex auth context", () => {
885885

886886
await expect(resolveCodexAuthContext(new Headers(), cfg, "pool", {
887887
accountId: "pool-a",
888-
modelId: "gpt-5.6-sol",
888+
modelId: "gpt-5.5",
889889
})).rejects.toThrow("Selected Codex account is unavailable");
890890
expect(cfg.activeCodexAccountId).toBe("pool-a");
891891
});
@@ -905,18 +905,18 @@ describe("Codex auth context", () => {
905905
recordCodexUpstreamOutcome(cfg, "pool-a", 429, {
906906
resetAt: Math.floor((now + 60 * 60_000) / 1_000),
907907
now,
908-
modelId: "gpt-5.6-sol",
908+
modelId: "gpt-5.5",
909909
fixedAccount: true,
910910
});
911911
Date.now = () => now + CODEX_QUOTA_PROBE_INTERVAL_MS;
912912

913913
await expect(resolveCodexAuthContext(new Headers(), cfg, "pool", {
914914
accountId: "pool-a",
915-
modelId: "gpt-5.6-sol",
915+
modelId: "gpt-5.5",
916916
})).rejects.toBeInstanceOf(CodexAccountCooldownError);
917917

918918
const ordinaryProbe = await resolveCodexAuthContext(new Headers(), cfg, "pool", {
919-
modelId: "gpt-5.6-sol",
919+
modelId: "gpt-5.5",
920920
});
921921
expect(ordinaryProbe).toMatchObject({ kind: "pool", accountId: "pool-a" });
922922
expect(ordinaryProbe.kind === "pool" ? ordinaryProbe.probeLeaseId : undefined).toBeTruthy();
@@ -1079,20 +1079,20 @@ describe("Codex auth context", () => {
10791079
});
10801080

10811081
// Spark owns a separate quota, so Terra can use the same account.
1082-
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.6-terra" }))
1082+
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.4" }))
10831083
.resolves.toMatchObject({ kind: "pool", accountId: "pool-a" });
10841084
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.3-codex-spark" }))
10851085
.rejects.toBeInstanceOf(CodexAccountCooldownError);
10861086

10871087
recordCodexUpstreamOutcome(cfg, "pool-a", 429, {
10881088
now,
10891089
resetAt,
1090-
modelId: "gpt-5.6-terra",
1090+
modelId: "gpt-5.4",
10911091
});
10921092

10931093
// Terra and Luna stay in the shared native quota group, while Spark keeps
10941094
// its independent cooldown instead of being overwritten by Terra's 429.
1095-
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.6-luna" }))
1095+
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.4-mini" }))
10961096
.rejects.toBeInstanceOf(CodexAccountCooldownError);
10971097
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.3-codex-spark" }))
10981098
.rejects.toBeInstanceOf(CodexAccountCooldownError);
@@ -1104,7 +1104,7 @@ describe("Codex auth context", () => {
11041104
retryAfter: "60",
11051105
modelId: "gpt-5.3-codex-spark",
11061106
});
1107-
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.6-terra" }))
1107+
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.4" }))
11081108
.rejects.toBeInstanceOf(CodexAccountCooldownError);
11091109
} finally {
11101110
Date.now = originalNow;
@@ -1137,7 +1137,7 @@ describe("Codex auth context", () => {
11371137
Date.now = () => now;
11381138
// Establish the shared-scope binding first. The Spark fallback below must
11391139
// create a second binding rather than replacing this one.
1140-
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.6-terra" }))
1140+
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.4" }))
11411141
.resolves.toMatchObject({ kind: "pool", accountId: "pool-a" });
11421142

11431143
recordCodexUpstreamOutcome(cfg, "pool-a", 429, {
@@ -1149,7 +1149,7 @@ describe("Codex auth context", () => {
11491149
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.3-codex-spark" }))
11501150
.resolves.toMatchObject({ kind: "pool", accountId: "pool-b" });
11511151
expect(cfg.activeCodexAccountId).toBe("pool-a");
1152-
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.6-terra" }))
1152+
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.4" }))
11531153
.resolves.toMatchObject({ kind: "pool", accountId: "pool-a" });
11541154
// This second Spark request proves routing retained the peer choice for
11551155
// the Spark affinity instead of relying on an auth-layer substitution.
@@ -1182,7 +1182,7 @@ describe("Codex auth context", () => {
11821182
recordCodexUpstreamOutcome(cfg, "pool-a", 429, {
11831183
now,
11841184
resetAt,
1185-
modelId: "gpt-5.6-terra",
1185+
modelId: "gpt-5.4",
11861186
});
11871187

11881188
const probeAt = now + CODEX_QUOTA_PROBE_INTERVAL_MS;
@@ -1205,7 +1205,7 @@ describe("Codex auth context", () => {
12051205
Date.now = () => probeAt + 1;
12061206
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.3-codex-spark" }))
12071207
.resolves.toMatchObject({ kind: "pool", accountId: "pool-a" });
1208-
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.6-luna" }))
1208+
await expect(resolveCodexAuthContext(headers, cfg, "pool", { modelId: "gpt-5.4-mini" }))
12091209
.resolves.toMatchObject({ kind: "pool", probeQuotaScope: "shared" });
12101210
} finally {
12111211
Date.now = originalNow;

‎tests/codex-catalog-sync-hardening.test.ts‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe("Codex catalog sync hardening", () => {
108108
if (existsSync(opencodexHome)) rmSync(opencodexHome, { recursive: true, force: true });
109109
});
110110

111-
test("Gap B: drops legacy OpenAI-family natives but keeps supported + user natives", () => {
111+
test("Gap B: drops legacy and unentitled account-gated natives but keeps supported + user natives", () => {
112112
const catalogPath = join(codexHome, "catalog.json");
113113
writeFileSync(join(codexHome, "config.toml"), 'model_catalog_json = "catalog.json"\n', "utf8");
114114
writeFileSync(catalogPath, JSON.stringify({
@@ -138,9 +138,11 @@ describe("Codex catalog sync hardening", () => {
138138
expect(slugs).toContain("gpt-5.4");
139139
expect(slugs).toContain("gpt-5.4-mini");
140140
expect(slugs).toContain("gpt-5.3-codex-spark");
141-
expect(slugs).toContain("gpt-5.6-sol");
142-
expect(slugs).toContain("gpt-5.6-terra");
143-
expect(slugs).toContain("gpt-5.6-luna");
141+
// This isolated fixture has no authenticated ChatGPT roster, so account-gated
142+
// native models must fail closed rather than remain selectable.
143+
expect(slugs).not.toContain("gpt-5.6-sol");
144+
expect(slugs).not.toContain("gpt-5.6-terra");
145+
expect(slugs).not.toContain("gpt-5.6-luna");
144146
expect(slugs).toContain("user-native"); // genuine user native preserved
145147
expect(slugs).not.toContain("gpt-5.3-codex"); // legacy dropped
146148
expect(slugs).not.toContain("gpt-5.2"); // legacy dropped
@@ -153,8 +155,8 @@ describe("Codex catalog sync hardening", () => {
153155
writeFileSync(catalogPath, JSON.stringify({
154156
models: [
155157
{
156-
...nativeEntry("gpt-5.6-sol", 0),
157-
display_name: "Original Sol",
158+
...nativeEntry("gpt-5.5", 0),
159+
display_name: "Original GPT-5.5",
158160
comp_hash: "native-sol-hash",
159161
base_instructions: "Native Sol instructions",
160162
model_messages: { instructions_template: "Native Sol instructions" },
@@ -178,17 +180,17 @@ describe("Codex catalog sync hardening", () => {
178180
adapter: "openai-chat",
179181
baseUrl: "https://api.example.test/v1",
180182
liveModels: false,
181-
models: ["codex/gpt-5.6-sol"]
183+
models: ["codex/gpt-5.5"]
182184
}
183185
},
184186
codexAccounts: [{ id: "stored-team-account", isMain: false }],
185187
codexAccountNamespaces: { team: "stored-team-account" },
186188
combos: {
187189
"nova-sol": {
188-
alias: "gpt-5.6-sol",
190+
alias: "gpt-5.5",
189191
nativeAlias: true,
190-
displayName: "Nova Sol",
191-
targets: [{ provider: "Nova1", model: "codex/gpt-5.6-sol" }]
192+
displayName: "Nova GPT-5.5",
193+
targets: [{ provider: "Nova1", model: "codex/gpt-5.5" }]
192194
}
193195
}
194196
};
@@ -205,13 +207,13 @@ describe("Codex catalog sync hardening", () => {
205207
tool_mode?: string | null;
206208
opencodex_catalog_kind?: string;
207209
}>;
208-
expect(rows.filter(row => row.slug === "gpt-5.6-sol")).toEqual([
210+
expect(rows.filter(row => row.slug === "gpt-5.5")).toEqual([
209211
expect.objectContaining({
210-
display_name: "Nova Sol",
212+
display_name: "Nova GPT-5.5",
211213
opencodex_catalog_kind: "combo-native-alias-v1",
212214
}),
213215
]);
214-
expect(rows.find(row => row.slug === "team/gpt-5.6-sol")).toMatchObject({
216+
expect(rows.find(row => row.slug === "team/gpt-5.5")).toMatchObject({
215217
comp_hash: "native-sol-hash",
216218
base_instructions: "Native Sol instructions",
217219
model_messages: { instructions_template: "Native Sol instructions" },

‎tests/codex-catalog.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
cursorModelReasoningEfforts,
1919
} from "../src/adapters/cursor/discovery";
2020
import { getModelMetadata, resolveMetadataProvider } from "../src/generated/model-metadata";
21+
import { resetCodexModelEntitlementCacheForTests, seedCodexModelEntitlementsForTests } from "../src/codex/model-entitlements";
2122
import {
2223
clearModelCache,
2324
getProviderDiscoveryStatus,
@@ -57,6 +58,7 @@ afterEach(() => {
5758
globalThis.fetch = originalFetch;
5859
clearModelCache();
5960
resetOpenAiApiCatalogWarningStateForTests();
61+
resetCodexModelEntitlementCacheForTests();
6062
});
6163

6264
function normalizedCombo(
@@ -1258,7 +1260,9 @@ describe("combo catalog capability intersection", () => {
12581260
// The "openai" provider uses forward-auth (Codex login passthrough) — fetchProviderModels
12591261
// returns [] for it, so native slugs only surface through nativeOpenAiSlugs(). Before the
12601262
// fix, memberByKey never contained openai/<slug>, so combos with a native-openai target were
1261-
// silently dropped from the catalog.
1263+
// silently dropped from the catalog. Sol is account-gated now, so the combo's native member
1264+
// needs a confirmed roster to be visible at all.
1265+
seedCodexModelEntitlementsForTests("main", ["gpt-5.6-sol"]);
12621266
globalThis.fetch = (() => { throw new Error("forward providers must not fetch /models"); }) as typeof fetch;
12631267
const config: OcxConfig = {
12641268
port: 10100,

0 commit comments

Comments
 (0)