Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(codex): fail-close ChatGPT assignment, grants, and runtime allowlists

Alfredo Lopez7dfdf9496057
diff --git a/codex-llm-proxy/src/auth/adminPermitVerifier.ts b/codex-llm-proxy/src/auth/adminPermitVerifier.ts
index 8e91c88ca..58412791e 100644
--- a/codex-llm-proxy/src/auth/adminPermitVerifier.ts
+++ b/codex-llm-proxy/src/auth/adminPermitVerifier.ts
@@ -1,14 +1,18 @@
import jwt from 'jsonwebtoken'
import type { CodexLlmProxyConfig } from '../config.js'
+export type AdminPermitOperation = 'catalog_list' | 'connection_test'
+
export type AdminPermitClaims = {
sub: string
typ: 'codex-admin-permit'
+ operation: AdminPermitOperation
}
export function verifyAdminPermit(
token: string,
- config: CodexLlmProxyConfig
+ config: CodexLlmProxyConfig,
+ operation?: AdminPermitOperation
): AdminPermitClaims | null {
try {
const verified = jwt.verify(token, config.jwtPublicKey, {
@@ -19,7 +23,9 @@ export function verifyAdminPermit(
if (typeof verified !== 'object' || verified === null) return null
const claims = verified as jwt.JwtPayload
if (claims.typ !== 'codex-admin-permit' || typeof claims.sub !== 'string') return null
- return { sub: claims.sub, typ: 'codex-admin-permit' }
+ if (claims.operation !== 'catalog_list' && claims.operation !== 'connection_test') return null
+ if (operation && claims.operation !== operation) return null
+ return { sub: claims.sub, typ: 'codex-admin-permit', operation: claims.operation }
} catch {
return null
}
diff --git a/codex-llm-proxy/src/auth/platformJwtVerifier.ts b/codex-llm-proxy/src/auth/platformJwtVerifier.ts
index 2b1be0f41..947619c5a 100644
--- a/codex-llm-proxy/src/auth/platformJwtVerifier.ts
+++ b/codex-llm-proxy/src/auth/platformJwtVerifier.ts
@@ -25,6 +25,8 @@ export function verifyPlatformJwt(
if (!Array.isArray(claims.hostRefs) || !Array.isArray(claims.workflowControlScopes)) {
return null
}
+ if (typeof claims.exp !== 'number') return null
+ if (claims.hostRefs.some(ref => String(ref) === '*')) return null
if (!claims.workflowControlScopes.includes('llm:codex:execute')) return null
return {
sub: String(claims.sub),
diff --git a/codex-llm-proxy/src/codexTransport.ts b/codex-llm-proxy/src/codexTransport.ts
index ab6945112..24c31b3f0 100644
--- a/codex-llm-proxy/src/codexTransport.ts
+++ b/codex-llm-proxy/src/codexTransport.ts
@@ -312,11 +312,15 @@ async function consumeSse(
let completed = false
let failed = false
let usage: SafeUsage | undefined
+ const maxSseBufferBytes = 1_048_576
try {
while (!signal.aborted) {
const { done, value } = await reader.read()
if (done) break
buffer += decoder.decode(value, { stream: true })
+ if (buffer.length > maxSseBufferBytes) {
+ throw new CodexTransportError('sse_buffer_exceeded', 'upstream SSE buffer exceeded')
+ }
const parts = buffer.split('\n\n')
buffer = parts.pop() ?? ''
for (const part of parts) {
diff --git a/codex-llm-proxy/src/logger.ts b/codex-llm-proxy/src/logger.ts
index 2abf726fd..1da726307 100644
--- a/codex-llm-proxy/src/logger.ts
+++ b/codex-llm-proxy/src/logger.ts
@@ -10,6 +10,10 @@ export const REDACT_PATHS = [
'headers.authorization',
'req.headers.authorization',
'attemptReceipt',
+ 'id_token',
+ 'idToken',
+ 'pkceVerifier',
+ 'refresh_token',
]
export function createProxyLogger(destination?: DestinationStream) {
diff --git a/codex-llm-proxy/src/originPolicy.ts b/codex-llm-proxy/src/originPolicy.ts
index aeb735990..3af757fc5 100644
--- a/codex-llm-proxy/src/originPolicy.ts
+++ b/codex-llm-proxy/src/originPolicy.ts
@@ -116,7 +116,8 @@ export function isBlockedAddress(address: string): boolean {
if (a === 172 && b >= 16 && b <= 31) return true
if (a === 192 && b === 168) return true
if (a === 192 && b === 0) return true
- if (a === 198 && (b === 51 || b === 18)) return true
+ if (a === 100 && b >= 64 && b <= 127) return true
+ if (a === 198 && (b === 18 || b === 19 || b === 51)) return true
if (a === 203 && b === 113) return true
if (a >= 224) return true
return false
@@ -130,6 +131,8 @@ function isBlockedV6(address: string): boolean {
normalized.startsWith('fc') ||
normalized.startsWith('fd') ||
normalized.startsWith('fe80') ||
+ normalized.startsWith('ff') ||
+ normalized.startsWith('64:ff9b:') ||
normalized.startsWith('::ffff:')
)
}
diff --git a/codex-llm-proxy/src/server.ts b/codex-llm-proxy/src/server.ts
index ecdabaa5d..86a73a49b 100644
--- a/codex-llm-proxy/src/server.ts
+++ b/codex-llm-proxy/src/server.ts
@@ -134,7 +134,7 @@ export function createProxyApps(config: CodexLlmProxyConfig, deps: ProxyRuntimeD
reject(res, 403, 'ticket_invalid')
return
}
- if (!platform.hostRefs.includes('*') && !platform.hostRefs.includes(ticket.hostRef)) {
+ if (platform.hostRefs.includes('*') || !platform.hostRefs.includes(ticket.hostRef)) {
reject(res, 403, 'host_binding_mismatch')
return
}
@@ -212,7 +212,7 @@ export function createProxyApps(config: CodexLlmProxyConfig, deps: ProxyRuntimeD
reject(res, 403, 'insufficient_scope')
return
}
- if (!verifyAdminPermit(bearer(req), config)) {
+ if (!verifyAdminPermit(bearer(req), config, kind === 'models' ? 'catalog_list' : 'connection_test')) {
reject(res, 401, 'Unauthorized')
return
}
diff --git a/codex-llm-proxy/test/originPolicy.test.ts b/codex-llm-proxy/test/originPolicy.test.ts
index a0f3307e2..0a7f017df 100644
--- a/codex-llm-proxy/test/originPolicy.test.ts
+++ b/codex-llm-proxy/test/originPolicy.test.ts
@@ -6,6 +6,7 @@ import {
assertAllowedUpstreamUrl,
assertRedirectLocation,
fetchFrozenOrigin,
+ isBlockedAddress,
} from '../src/originPolicy.js'
const LOOPBACK_V4 = ['127', '0', '0', '1'].join('.')
@@ -29,6 +30,11 @@ describe('originPolicy', () => {
OriginDeniedError
)
expect(() => assertAllowedUpstreamUrl('https://169.254.169.254/', 'catalog')).toThrow(OriginDeniedError)
+ expect(isBlockedAddress('100.64.0.1')).toBe(true)
+ expect(isBlockedAddress('198.18.0.1')).toBe(true)
+ expect(isBlockedAddress('198.19.255.1')).toBe(true)
+ expect(isBlockedAddress('64:ff9b::1')).toBe(true)
+ expect(isBlockedAddress('ff02::1')).toBe(true)
expect(() => assertAllowedUpstreamUrl('https://chatgpt.com/backend-api/codex/responses?hijack=1', 'completions')).toThrow(
OriginDeniedError
)
diff --git a/codex-llm-proxy/test/server.security.test.ts b/codex-llm-proxy/test/server.security.test.ts
index fbe9ba6b7..8a51e2f5c 100644
--- a/codex-llm-proxy/test/server.security.test.ts
+++ b/codex-llm-proxy/test/server.security.test.ts
@@ -64,7 +64,10 @@ function ticket(): string {
}
function adminPermit(): string {
- return sign({ sub: 'admin-1', typ: 'codex-admin-permit' }, 'codex-llm-proxy-admin')
+ return sign(
+ { sub: 'admin-1', typ: 'codex-admin-permit', operation: 'catalog_list' },
+ 'codex-llm-proxy-admin'
+ )
}
describe('codex-llm-proxy security surface', () => {
@@ -163,6 +166,40 @@ describe('codex-llm-proxy security surface', () => {
expect(res.body.error).toBe('host_binding_mismatch')
})
+ it('rejects a platform JWT whose hostRefs is a wildcard', async () => {
+ const { runtimeApp } = createProxyApps(config())
+ const wildcard = sign(
+ {
+ sub: 'default/research-host',
+ hostRefs: ['*'],
+ workflowControlScopes: ['llm:codex:execute'],
+ },
+ 'workflow-approvals'
+ )
+ const res = await request(runtimeApp)
+ .post('/internal/runtime/v1/codex/completions')
+ .set('Authorization', `Bearer ${wildcard}`)
+ .send({
+ executionTicket: ticket(),
+ requestHash: 'a'.repeat(64),
+ request: {},
+ })
+ expect(res.status).toBe(401)
+ })
+
+ it('rejects an admin permit whose operation does not match the route', async () => {
+ const { adminApp } = createProxyApps(config())
+ const wrong = sign(
+ { sub: 'admin-1', typ: 'codex-admin-permit', operation: 'connection_test' },
+ 'codex-llm-proxy-admin'
+ )
+ const res = await request(adminApp)
+ .post('/internal/admin/v1/codex/models')
+ .set('Authorization', `Bearer ${wrong}`)
+ .send({ accessToken: 'tok' })
+ expect(res.status).toBe(401)
+ })
+
it('rejects missing, zero, and unbounded config', () => {
expect(() => loadConfig({ CODEX_LLM_PROXY_RUNTIME_PORT: '0' })).toThrow(/greater than zero/)
expect(() =>
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 7c300491b..fd104aecc 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.503",
+ "version": "0.1.504",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.503",
+ "version": "0.1.504",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/image-policy": "file:../packages/image-policy",
diff --git a/control-api/package.json b/control-api/package.json
index 85b2d1640..f582d2167 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.503",
+ "version": "0.1.504",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/src/routes/admin/codexSubscription.ts b/control-api/src/routes/admin/codexSubscription.ts
index cb9d2dd6f..390831889 100644
--- a/control-api/src/routes/admin/codexSubscription.ts
+++ b/control-api/src/routes/admin/codexSubscription.ts
@@ -423,7 +423,7 @@ export function createAdminCodexSubscriptionRouter(
oauthDeps(req, resolveBrowserRedirectUri(req), keyFromReq(req)),
state
)
- if (result.status === 'connected') await publishRuntimeAllowlistBestEffort()
+ if (result.status === 'connected' && (await publishRuntimeAllowlistOrFail(res))) return
res.status(200).json(result)
} catch (err) {
sendOAuthError(res, err)
@@ -461,6 +461,21 @@ export function createAdminCodexSubscriptionRouter(
const synced = await syncCodexSubscriptionCatalog(db, catalogTransport, secrets.accessToken, {
connectionKey,
})
+ if (!synced.connection) {
+ res.status(409).json({ error: 'stale_revision' })
+ return
+ }
+ if (synced.outcome !== 'ready') {
+ res.status(503).json({
+ error: 'catalog_sync_failed',
+ outcome: synced.outcome,
+ added: synced.added,
+ refreshed: synced.refreshed,
+ staled: synced.staled,
+ connection: synced.connection,
+ })
+ return
+ }
if (await publishRuntimeAllowlistOrFail(res)) return
res.status(200).json({
outcome: synced.outcome,
@@ -555,6 +570,10 @@ export function createAdminCodexSubscriptionRouter(
typeof req.body?.displayName === 'string' && req.body.displayName.trim()
? req.body.displayName.trim()
: 'Codex subscription'
+ if (displayName.length > 64) {
+ res.status(400).json({ error: 'display_name_too_long' })
+ return
+ }
const requestedKey =
typeof req.body?.connectionKey === 'string' && req.body.connectionKey.trim()
? assertCodexConnectionKey(req.body.connectionKey.trim())
@@ -591,7 +610,7 @@ export function createAdminCodexSubscriptionRouter(
oauthDeps(req, resolveBrowserRedirectUri(req), keyFromReq(req))
)
if (!('id' in connection)) {
- res.status(200).json({ models: [] })
+ res.status(409).json({ error: 'not_connected' })
return
}
const models = await listCodexCatalogModels(dbClient(), connection.id)
@@ -620,6 +639,10 @@ export function createAdminCodexSubscriptionRouter(
res.status(400).json({ error: 'empty_patch' })
return
}
+ if (hasDisplayName && req.body.displayName.trim().length > 64) {
+ res.status(400).json({ error: 'display_name_too_long' })
+ return
+ }
const defaultModel = hasDefaultModel
? typeof req.body.defaultModel === 'string'
? req.body.defaultModel.trim()
diff --git a/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts b/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts
index 6765ec1f6..72fb8bc56 100644
--- a/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts
+++ b/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts
@@ -5,7 +5,7 @@ import type { K8sGateway } from '../../k8s.js'
import { requireMcpHostJwt } from '../../middleware/mcpHostJwtAuth.js'
import { rootLogger } from '../../observability/logger.js'
import {
- CODEX_SUBSCRIPTION_CONNECTION_KEY,
+ CODEX_UNASSIGNED_CONNECTION_KEY,
readHostCodexConnectionRef,
} from '../../services/codexSubscriptionConnection.js'
import {
@@ -47,7 +47,7 @@ export async function resolveHostAssignedConnectionKey(
hostRef: string
): Promise<string> {
if (hostRef.includes('/')) {
- return CODEX_SUBSCRIPTION_CONNECTION_KEY
+ return CODEX_UNASSIGNED_CONNECTION_KEY
}
try {
const host = (await gateway.getResource('hosts', hostRef, config.hostsNamespace)) as {
diff --git a/control-api/src/services/codexSubscriptionCatalog.ts b/control-api/src/services/codexSubscriptionCatalog.ts
index 2c0351219..9e0dcb679 100644
--- a/control-api/src/services/codexSubscriptionCatalog.ts
+++ b/control-api/src/services/codexSubscriptionCatalog.ts
@@ -190,7 +190,7 @@ export function pickCodexGrantModel(
if (trimmed && offered.includes(trimmed)) return trimmed
const fallback = grantDefault?.trim() ?? ''
if (fallback && offered.includes(fallback)) return fallback
- return offered[0] ?? trimmed
+ return offered[0] ?? ''
}
/** Enabled, non-stale models on a connected grant whose catalog is ready. */
@@ -251,6 +251,17 @@ export async function setCodexCatalogModelEnabled(
[connectionId, model, enabled]
)
if (updated.rowCount === 0) return null
+ if (!enabled) {
+ await db.query(
+ `UPDATE codex_subscription_connections
+ SET default_model = NULL,
+ updated_at = now()
+ WHERE id = $1
+ AND default_model = $2
+ AND revoked_at IS NULL`,
+ [connectionId, model]
+ )
+ }
await rebuildLiveCodexUnionAllowlist(db)
return listCodexCatalogModels(db, connectionId)
}
diff --git a/control-api/src/services/codexSubscriptionConnection.ts b/control-api/src/services/codexSubscriptionConnection.ts
index 1b6fe91db..78425fd31 100644
--- a/control-api/src/services/codexSubscriptionConnection.ts
+++ b/control-api/src/services/codexSubscriptionConnection.ts
@@ -663,6 +663,7 @@ export async function updateCodexSubscriptionConnectionMetadata(
`UPDATE codex_subscription_connections
SET ${sets.join(', ')}
WHERE connection_key = $${values.length}
+ AND revoked_at IS NULL
RETURNING ${SAFE_CONNECTION_COLUMNS}`,
values
)
diff --git a/control-api/src/services/codexSubscriptionOAuth.ts b/control-api/src/services/codexSubscriptionOAuth.ts
index 57cf474b2..289810d3c 100644
--- a/control-api/src/services/codexSubscriptionOAuth.ts
+++ b/control-api/src/services/codexSubscriptionOAuth.ts
@@ -355,14 +355,7 @@ export async function revokeCodexSubscription(
const key = connectionKeyOf(deps)
const secrets = await loadCodexSubscriptionSecrets(deps.db, deps.encryptionKey, key)
const local = await revokeCodexSubscriptionConnection(deps.db, key)
- try {
- await rebuildLiveCodexUnionAllowlist(deps.db)
- } catch (err) {
- log.warn(
- { event: 'codex_union_rebuild_after_revoke_failed', err },
- 'union allowlist rebuild failed'
- )
- }
+ await rebuildLiveCodexUnionAllowlist(deps.db)
if (secrets?.refreshToken) {
try {
const revokePayload: Record<string, string> = {
diff --git a/control-api/src/services/llmProviderAttemptAuthorizer.ts b/control-api/src/services/llmProviderAttemptAuthorizer.ts
index 5f47d1a45..654c17e86 100644
--- a/control-api/src/services/llmProviderAttemptAuthorizer.ts
+++ b/control-api/src/services/llmProviderAttemptAuthorizer.ts
@@ -13,10 +13,10 @@ import { evaluateBudgetCheck } from './budgets/check.js'
import { getActiveReservation } from './budgets/reservations.js'
import { getCodexCatalogModelState } from './codexSubscriptionCatalog.js'
import {
- CODEX_SUBSCRIPTION_CONNECTION_KEY,
+ CODEX_UNASSIGNED_CONNECTION_KEY,
getSafeCodexSubscriptionConnection,
isCodexUnassignedConnectionKey,
- normalizeCodexConnectionKey,
+ readHostCodexConnectionRef,
} from './codexSubscriptionConnection.js'
import {
getMaxLlmProviderAttemptGeneration,
@@ -95,7 +95,7 @@ const defaultDeps = (): LlmProviderAttemptAuthorizerDeps => ({
withTransaction,
getConnection: getSafeCodexSubscriptionConnection,
getModelState: getCodexCatalogModelState,
- resolveConnectionKey: async () => CODEX_SUBSCRIPTION_CONNECTION_KEY,
+ resolveConnectionKey: async () => CODEX_UNASSIGNED_CONNECTION_KEY,
evaluateBudget: evaluateBudgetCheck,
getActiveReservation,
getMaxGeneration: getMaxLlmProviderAttemptGeneration,
@@ -245,7 +245,7 @@ export async function authorizeLlmProviderAttempt(
)
}
- const connectionKey = normalizeCodexConnectionKey(
+ const connectionKey = readHostCodexConnectionRef(
await resolvedDeps.resolveConnectionKey(caller.hostRef)
)
if (isCodexUnassignedConnectionKey(connectionKey)) {
diff --git a/control-api/src/utils/log/redact.ts b/control-api/src/utils/log/redact.ts
index eb50c0f18..d1d5db37e 100644
--- a/control-api/src/utils/log/redact.ts
+++ b/control-api/src/utils/log/redact.ts
@@ -19,6 +19,12 @@ export const TOKEN_LEAK_REDACT_PATHS: readonly string[] = [
'claimToken',
'client_secret',
'clientSecret',
+ 'executionTicket',
+ 'attemptReceipt',
+ 'id_token',
+ 'idToken',
+ 'pkceVerifier',
+ 'refresh_token',
]
/** Asserted by unit tests so redactions can grow but never shrink. */
@@ -34,4 +40,10 @@ export const REQUIRED_REDACT_PATHS: readonly string[] = [
'claimToken',
'client_secret',
'clientSecret',
+ 'executionTicket',
+ 'attemptReceipt',
+ 'id_token',
+ 'idToken',
+ 'pkceVerifier',
+ 'refresh_token',
]
diff --git a/control-api/test/routes.admin.codexSubscription.test.ts b/control-api/test/routes.admin.codexSubscription.test.ts
index 3924b943e..253c412da 100644
--- a/control-api/test/routes.admin.codexSubscription.test.ts
+++ b/control-api/test/routes.admin.codexSubscription.test.ts
@@ -417,7 +417,7 @@ describe('admin Codex subscription routes', () => {
assertNoLeak(res.body)
})
- it('keeps a connected device poll at 200 when ConfigMap publish fails', async () => {
+ it('returns 503 when a connected device poll cannot publish the runtime ConfigMap', async () => {
const materialize = vi.fn(async () => {
throw new Error('apiserver down')
})
@@ -425,8 +425,8 @@ describe('admin Codex subscription routes', () => {
const res = await request(makeAuthedApp(makeGateway(materialize))).get(
'/admin/llm/providers/codex-subscription/device/poll'
)
- expect(res.status).toBe(200)
- expect(res.body.status).toBe('connected')
+ expect(res.status).toBe(503)
+ expect(res.body.error).toBe('configmap_write_failed')
expect(materialize).toHaveBeenCalledTimes(1)
assertNoLeak(res.body)
})
@@ -675,6 +675,23 @@ describe('admin Codex subscription routes', () => {
expect(res.body).toEqual({ error: 'default_model_not_offered' })
})
+ it('rejects an empty metadata patch', async () => {
+ const res = await request(app)
+ .patch('/admin/llm/providers/codex-subscription/connections/codex-aaa')
+ .send({})
+ expect(res.status).toBe(400)
+ expect(res.body).toEqual({ error: 'empty_patch' })
+ })
+
+ it('does not rewrite a revoked grant tombstone', async () => {
+ vi.mocked(pool.query).mockResolvedValueOnce({ rows: [], rowCount: 0 })
+ const res = await request(app)
+ .patch('/admin/llm/providers/codex-subscription/connections/codex-aaa')
+ .send({ displayName: 'Tomb' })
+ expect(res.status).toBe(404)
+ expect(res.body).toEqual({ error: 'no_grant' })
+ })
+
it('lists grant models and toggles enabled', async () => {
oauth.getConnection.mockResolvedValue({
id: 'id-codex-aaa',
diff --git a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts b/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts
index 3d27a6d83..08c52ebc8 100644
--- a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts
+++ b/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts
@@ -171,13 +171,13 @@ describe('resolveHostAssignedConnectionKey', () => {
)
})
- it('aliases a recipe caller to deployment-default without a Host GET', async () => {
+ it('aliases a recipe caller to unassigned without a Host GET', async () => {
const gateway = {
getResource: vi.fn(),
}
await expect(
resolveHostAssignedConnectionKey(gateway, 'sandbox-recipes/codex-recipe')
- ).resolves.toBe('deployment-default')
+ ).resolves.toBe('unassigned')
expect(gateway.getResource).not.toHaveBeenCalled()
})
diff --git a/control-api/test/services.codexSubscriptionCatalog.test.ts b/control-api/test/services.codexSubscriptionCatalog.test.ts
index c592bbe84..08b7bb0d8 100644
--- a/control-api/test/services.codexSubscriptionCatalog.test.ts
+++ b/control-api/test/services.codexSubscriptionCatalog.test.ts
@@ -21,7 +21,7 @@ describe('pickCodexGrantModel', () => {
})
it('does not invent a model when the grant list is empty', () => {
- expect(pickCodexGrantModel('gpt-5.4-mini', [])).toBe('gpt-5.4-mini')
+ expect(pickCodexGrantModel('gpt-5.4-mini', [])).toBe('')
expect(pickCodexGrantModel('', [])).toBe('')
})
diff --git a/control-api/test/services.codexSubscriptionConnection.test.ts b/control-api/test/services.codexSubscriptionConnection.test.ts
index 7d2cd3a64..fe64fe255 100644
--- a/control-api/test/services.codexSubscriptionConnection.test.ts
+++ b/control-api/test/services.codexSubscriptionConnection.test.ts
@@ -11,6 +11,7 @@ import {
normalizeCodexConnectionKey,
readHostCodexConnectionRef,
rotateCodexSubscriptionCredentials,
+ updateCodexSubscriptionConnectionMetadata,
} from '../src/services/codexSubscriptionConnection.js'
const KEY = deriveOAuthEncryptionKey('ab'.repeat(32))
@@ -169,6 +170,15 @@ describe('codex subscription connection repository', () => {
expect(sql).not.toMatch(/revoked_at = NULL/)
})
+ it('refuses metadata writes on a revoked grant', async () => {
+ query.mockResolvedValueOnce({ rows: [], rowCount: 0 })
+ await expect(
+ updateCodexSubscriptionConnectionMetadata({ query }, KEY, { displayName: 'Tomb' })
+ ).resolves.toBeNull()
+ const [sql] = query.mock.calls[0] as [string]
+ expect(sql).toMatch(/revoked_at IS NULL/)
+ })
+
it('rejects the reserved unassigned key and keeps it on Host reads', () => {
expect(() => assertCodexConnectionKey('unassigned')).toThrow(
CodexSubscriptionInvalidConnectionKeyError
diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsx
index a8529bd6c..3c021a0ac 100644
--- a/control-ui/app/hosts/[name]/page.tsx
+++ b/control-ui/app/hosts/[name]/page.tsx
@@ -39,6 +39,7 @@ import {
normalizeAllowedModels,
normalizeLlmPolicy,
normalizeProvider,
+ offeredCodexModelNames,
projectCredentialDraft,
resolveCodexGrantModel,
resolveDefaultModel,
@@ -144,6 +145,7 @@ export default function HostDetailsPage() {
const [connectionRefDraft, setConnectionRefDraft] = useState(CODEX_UNASSIGNED_CONNECTION_KEY)
const [codexModels, setCodexModels] = useState<string[]>([])
const [codexConnections, setCodexConnections] = useState<CodexSubscriptionConnectionView[]>([])
+ const [grantCatalogError, setGrantCatalogError] = useState('')
const catalogForEditor = useMemo(() => {
if (providerDraft !== 'codex-subscription') return allowedCatalog
const others = allowedCatalog.filter(row => row.provider !== 'codex-subscription')
@@ -238,8 +240,10 @@ export default function HostDetailsPage() {
allowedModelsDraft,
'codex-subscription'
)
- const next = resolveCodexGrantModel(modelNameDraft, offered)
- if (next && next !== modelNameDraft) setModelNameDraft(next)
+ if (offered.length === 0) return
+ const grant = codexConnections.find(row => row.connectionKey === connectionRefDraft)
+ const next = resolveCodexGrantModel(modelNameDraft, offered, grant?.defaultModel)
+ if (next !== modelNameDraft) setModelNameDraft(next)
return
}
if (modelNameDraft === '' && providerModelOptions.length > 0) {
@@ -253,8 +257,11 @@ export default function HostDetailsPage() {
.then(rows => {
if (!cancelled) setCodexConnections(rows)
})
- .catch(() => {
- if (!cancelled) setCodexConnections([])
+ .catch(err => {
+ if (!cancelled) {
+ setCodexConnections([])
+ setError(err instanceof Error ? err.message : 'Could not load ChatGPT subscriptions')
+ }
})
return () => {
cancelled = true
@@ -264,16 +271,23 @@ export default function HostDetailsPage() {
useEffect(() => {
if (!connectionRefDraft.trim() || connectionRefDraft === CODEX_UNASSIGNED_CONNECTION_KEY) {
setCodexModels([])
+ setGrantCatalogError('')
return
}
let cancelled = false
+ setGrantCatalogError('')
void listCodexConnectionModels(connectionRefDraft)
.then(models => {
if (cancelled) return
- setCodexModels(models.filter(row => row.enabled && !row.stale).map(row => row.model))
+ setCodexModels(offeredCodexModelNames(models))
})
- .catch(() => {
- if (!cancelled) setCodexModels([])
+ .catch(err => {
+ if (cancelled) return
+ setCodexModels([])
+ setModelNameDraft('')
+ setGrantCatalogError(
+ err instanceof Error ? err.message : 'Could not load ChatGPT grant models'
+ )
})
return () => {
cancelled = true
@@ -481,27 +495,20 @@ export default function HostDetailsPage() {
setSecretRefDraft('')
setConnectionRefDraft(CODEX_UNASSIGNED_CONNECTION_KEY)
setCodexModels([])
+ setGrantCatalogError('')
return
}
if (parsed.kind === 'subscription') {
- const grant = codexConnections.find(row => row.connectionKey === parsed.connectionKey)
setSecretRefDraft('')
setConnectionRefDraft(parsed.connectionKey)
setProviderDraft('codex-subscription')
- void listCodexConnectionModels(parsed.connectionKey)
- .then(models => {
- const offered = models.filter(row => row.enabled && !row.stale).map(row => row.model)
- setCodexModels(offered)
- setModelNameDraft(resolveCodexGrantModel(grant?.defaultModel ?? '', offered))
- })
- .catch(() => {
- setCodexModels([])
- })
+ setModelNameDraft('')
return
}
setSecretRefDraft(parsed.name)
setConnectionRefDraft(CODEX_UNASSIGNED_CONNECTION_KEY)
setCodexModels([])
+ setGrantCatalogError('')
if (providerDraft === 'codex-subscription') {
setProviderDraft('openai')
setModelNameDraft(resolveDefaultModel('openai', getModelOptions(allowedCatalog, 'openai')))
@@ -588,6 +595,22 @@ export default function HostDetailsPage() {
setError(modelNameProblem)
return false
}
+ if (providerDraft === 'codex-subscription') {
+ if (!connectionRefDraft.trim() || connectionRefDraft === CODEX_UNASSIGNED_CONNECTION_KEY) {
+ setError('Choose a ChatGPT subscription before saving.')
+ return false
+ }
+ if (grantCatalogError) {
+ setError(grantCatalogError)
+ return false
+ }
+ if (!codexModels.includes(modelNameDraft.trim())) {
+ setError(
+ 'This subscription has no offered models yet. Sign in and sync the catalog before assigning agents.'
+ )
+ return false
+ }
+ }
// Client-side mirror of control-api's write gate (spec R5.3): block a save
// with an out-of-allowlist fallback model before the round-trip. Skip the
// check when the allowlist failed to load (`allowedCatalog` empty) — every
@@ -1066,7 +1089,14 @@ export default function HostDetailsPage() {
setEditingModel(false)
}
}}
- disabled={busy || Boolean(hostModelNameError(modelNameDraft))}
+ disabled={
+ busy ||
+ Boolean(hostModelNameError(modelNameDraft)) ||
+ (providerDraft === 'codex-subscription' &&
+ (connectionRefDraft === CODEX_UNASSIGNED_CONNECTION_KEY ||
+ Boolean(grantCatalogError) ||
+ !codexModels.includes(modelNameDraft.trim())))
+ }
>
{busy ? 'Saving…' : 'Save'}
</button>
@@ -1196,7 +1226,9 @@ export default function HostDetailsPage() {
<option value={secretRefDraft}>{secretRefDraft} (custom)</option>
</optgroup>
) : null}
- {codexConnections.some(row => row.status !== 'revoked') ? (
+ {codexConnections.some(row => row.status !== 'revoked') ||
+ (connectionRefDraft &&
+ connectionRefDraft !== CODEX_UNASSIGNED_CONNECTION_KEY) ? (
<optgroup label="Subscriptions">
{codexConnections
.filter(row => row.status !== 'revoked')
@@ -1208,6 +1240,16 @@ export default function HostDetailsPage() {
{row.displayName || row.connectionKey}
</option>
))}
+ {connectionRefDraft &&
+ connectionRefDraft !== CODEX_UNASSIGNED_CONNECTION_KEY &&
+ !codexConnections.some(
+ row =>
+ row.connectionKey === connectionRefDraft && row.status !== 'revoked'
+ ) ? (
+ <option value={credentialSelectValue('', connectionRefDraft)}>
+ {connectionRefDraft} (unavailable)
+ </option>
+ ) : null}
</optgroup>
) : null}
</select>
diff --git a/control-ui/components/CodexSubscriptionHub/index.tsx b/control-ui/components/CodexSubscriptionHub/index.tsx
index 3e83695ad..6cc3c56c1 100644
--- a/control-ui/components/CodexSubscriptionHub/index.tsx
+++ b/control-ui/components/CodexSubscriptionHub/index.tsx
@@ -60,7 +60,13 @@ export function CodexSubscriptionHub() {
const enabled = isCodexSubscriptionUiEnabled(capability)
useEffect(() => {
- void loadCodexSubscriptionCapability().then(setCapability)
+ void loadCodexSubscriptionCapability()
+ .then(setCapability)
+ .catch(err => {
+ setCapability({ enabled: false, error: err instanceof Error ? err.message : 'unavailable' })
+ setError(err instanceof Error ? err.message : 'Failed to load ChatGPT subscriptions')
+ setLoading(false)
+ })
}, [])
const load = useCallback(async () => {
@@ -125,8 +131,9 @@ export function CodexSubscriptionHub() {
try {
const models = await listCodexConnectionModels(row.connectionKey)
setEditModels(models)
- } catch {
+ } catch (err) {
setEditModels([])
+ setError(err instanceof Error ? err.message : 'Could not load grant models')
}
} else {
setEditModels([])
@@ -187,11 +194,13 @@ export function CodexSubscriptionHub() {
if (polled.status === 'expired' || polled.status === 'denied') {
setUserCode(null)
setVerificationUri(null)
- break
+ setError(`ChatGPT sign-in ${polled.status}. Try again.`)
+ return
}
}
setUserCode(null)
setVerificationUri(null)
+ setError('ChatGPT sign-in timed out. Try again.')
} catch (err) {
setUserCode(null)
setVerificationUri(null)
@@ -205,7 +214,11 @@ export function CodexSubscriptionHub() {
if (row.status !== 'connected') return
setBusyKey(row.connectionKey)
try {
- await syncCodexSubscriptionCatalog(row.connectionKey)
+ const synced = await syncCodexSubscriptionCatalog(row.connectionKey)
+ if (synced.outcome !== 'ready') {
+ setError(`Catalog sync ${synced.outcome}`)
+ return
+ }
const models = await listCodexConnectionModels(row.connectionKey)
setEditModels(models)
await load()
@@ -274,7 +287,9 @@ export function CodexSubscriptionHub() {
<SecretsScopeTabs activeValue="llm" />
<LlmSecretsSubTabs activeValue="subscriptions" />
</div>
- <div className="cu-empty">ChatGPT subscriptions are disabled.</div>
+ <div className="cu-empty">
+ {capability.error || error || 'ChatGPT subscriptions are disabled.'}
+ </div>
</div>
)
}
@@ -302,7 +317,13 @@ export function CodexSubscriptionHub() {
<button
type="button"
className="cu-btn cu-btn--icon cu-btn--toolbar"
- onClick={() => void load()}
+ onClick={() =>
+ void load().catch(err => {
+ setError(
+ err instanceof Error ? err.message : 'Failed to load ChatGPT subscriptions'
+ )
+ })
+ }
disabled={initialLoad || loading}
aria-label={loading ? 'Refreshing...' : 'Reload ChatGPT subscriptions'}
>
@@ -329,7 +350,7 @@ export function CodexSubscriptionHub() {
<LlmSecretsSubTabs activeValue="subscriptions" />
</div>
- {error ? (
+ {error && !creating && !editing ? (
<div className="cu-card__body cu-card__body--auto cu-secrets-message-strip">
<div className="cu-banner cu-banner--error">{error}</div>
</div>
@@ -423,16 +444,7 @@ export function CodexSubscriptionHub() {
{creating ? (
<div
- style={{
- position: 'fixed',
- inset: 0,
- background: 'var(--cu-overlay)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- zIndex: 1000,
- padding: '1rem',
- }}
+ className="cu-modal-overlay"
role="presentation"
onClick={e => {
if (e.target === e.currentTarget && busyKey !== 'create') {
@@ -443,6 +455,7 @@ export function CodexSubscriptionHub() {
<div
className="cu-modal-panel"
role="dialog"
+ aria-modal="true"
aria-labelledby="codex-create-title"
onClick={e => e.stopPropagation()}
>
@@ -461,6 +474,7 @@ export function CodexSubscriptionHub() {
</button>
</div>
<div className="cu-form-stack">
+ {error ? <div className="cu-banner cu-banner--error">{error}</div> : null}
<div className="cu-field">
<label htmlFor="codex-new-name">Name</label>
<input
@@ -495,16 +509,7 @@ export function CodexSubscriptionHub() {
{editing ? (
<div
- style={{
- position: 'fixed',
- inset: 0,
- background: 'var(--cu-overlay)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- zIndex: 1000,
- padding: '1rem',
- }}
+ className="cu-modal-overlay"
role="presentation"
onClick={e => {
if (e.target === e.currentTarget && !busyKey) closeEdit()
@@ -513,6 +518,7 @@ export function CodexSubscriptionHub() {
<div
className="cu-modal-panel"
role="dialog"
+ aria-modal="true"
aria-labelledby="codex-edit-title"
onClick={e => e.stopPropagation()}
>
@@ -531,6 +537,7 @@ export function CodexSubscriptionHub() {
</button>
</div>
<div className="cu-form-stack" style={{ maxWidth: '100%' }}>
+ {error ? <div className="cu-banner cu-banner--error">{error}</div> : null}
<div className="cu-field">
<label htmlFor="codex-edit-name">Name</label>
<input
diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsx
index 0a786247d..fe9b30b1a 100644
--- a/control-ui/components/HostWizard/index.tsx
+++ b/control-ui/components/HostWizard/index.tsx
@@ -39,6 +39,7 @@ import {
getProvidersWithCompleteCredentials,
isProviderUsable,
llmChainRequiresSecret,
+ offeredCodexModelNames,
projectCredentialDraft,
resolveCodexGrantModel,
resolveDefaultModel,
@@ -261,6 +262,7 @@ function isStepValid(
provider: LlmProvider
modelName: string
connectionRef?: string
+ codexModels?: string[]
selectedUserIds: string[]
selectedTeamIds: string[]
directoryLoadFailed: boolean
@@ -280,7 +282,8 @@ function isStepValid(
if (
state.provider === 'codex-subscription' &&
(!state.connectionRef?.trim() ||
- state.connectionRef.trim() === CODEX_UNASSIGNED_CONNECTION_KEY)
+ state.connectionRef.trim() === CODEX_UNASSIGNED_CONNECTION_KEY ||
+ !state.codexModels?.includes(state.modelName.trim()))
) {
return false
}
@@ -463,18 +466,9 @@ export function HostWizard({
setExistingSecret(secretName)
const parsed = parseCredentialSelect(secretName)
if (parsed.kind === 'subscription') {
- const grant = codexConnections.find(row => row.connectionKey === parsed.connectionKey)
setConnectionRef(parsed.connectionKey)
setProvider('codex-subscription')
- void listCodexConnectionModels(parsed.connectionKey)
- .then(models => {
- const offered = models.filter(row => row.enabled && !row.stale).map(row => row.model)
- setCodexModels(offered)
- setModelName(resolveCodexGrantModel(grant?.defaultModel ?? '', offered))
- })
- .catch(() => {
- setCodexModels([])
- })
+ setModelName('')
return
}
setConnectionRef(CODEX_UNASSIGNED_CONNECTION_KEY)
@@ -505,13 +499,37 @@ export function HostWizard({
.then(rows => {
if (!cancelled) setCodexConnections(rows)
})
- .catch(() => {
- if (!cancelled) setCodexConnections([])
+ .catch(err => {
+ if (!cancelled) {
+ setCodexConnections([])
+ setError(err instanceof Error ? err.message : 'Could not load ChatGPT subscriptions')
+ }
})
return () => {
cancelled = true
}
}, [])
+ useEffect(() => {
+ if (!connectionRef.trim() || connectionRef === CODEX_UNASSIGNED_CONNECTION_KEY) {
+ setCodexModels([])
+ return
+ }
+ let cancelled = false
+ void listCodexConnectionModels(connectionRef)
+ .then(models => {
+ if (!cancelled) setCodexModels(offeredCodexModelNames(models))
+ })
+ .catch(() => {
+ if (!cancelled) {
+ setCodexModels([])
+ setModelName('')
+ setError('Could not load ChatGPT grant models')
+ }
+ })
+ return () => {
+ cancelled = true
+ }
+ }, [connectionRef])
// Keep the selected model valid for the current provider's enabled models:
// seed the default once the allowlist loads, and re-default if a provider
// switch left the model out of range.
@@ -519,7 +537,9 @@ export function HostWizard({
if (modelsLoading) return
if (provider === 'codex-subscription') {
const offered = constrainModelOptions(catalogForEditor, allowedModels, provider)
- const next = resolveCodexGrantModel(modelName, offered)
+ if (offered.length === 0) return
+ const grant = codexConnections.find(row => row.connectionKey === connectionRef)
+ const next = resolveCodexGrantModel(modelName, offered, grant?.defaultModel)
if (next !== modelName) setModelName(next)
return
}
@@ -586,6 +606,7 @@ export function HostWizard({
provider,
modelName,
connectionRef,
+ codexModels,
selectedUserIds,
selectedTeamIds,
directoryLoadFailed: directoryLoadError.length > 0,
@@ -606,6 +627,7 @@ export function HostWizard({
provider,
modelName,
connectionRef,
+ codexModels,
selectedUserIds,
selectedTeamIds,
directoryLoadError,
@@ -681,6 +703,7 @@ export function HostWizard({
provider,
modelName,
connectionRef,
+ codexModels,
selectedUserIds,
selectedTeamIds,
directoryLoadFailed: directoryLoadError.length > 0,
@@ -1224,6 +1247,9 @@ export function HostWizard({
if (next.provider !== 'codex-subscription') {
setConnectionRef(CODEX_UNASSIGNED_CONNECTION_KEY)
setCodexModels([])
+ if (parseCredentialSelect(existingSecret).kind === 'subscription') {
+ setExistingSecret('')
+ }
}
}}
policy={llmPolicy}
diff --git a/control-ui/components/LlmProviderConfig/index.tsx b/control-ui/components/LlmProviderConfig/index.tsx
index cd2e38ffa..a10e298c6 100644
--- a/control-ui/components/LlmProviderConfig/index.tsx
+++ b/control-ui/components/LlmProviderConfig/index.tsx
@@ -254,15 +254,11 @@ export function LlmProviderConfig({
const nextProviderValue = next[0]
if (!nextProviderValue) return
const nextProvider = normalizeProvider(nextProviderValue)
- const resolved =
- nextProvider === 'openai' && provider === OPENAI_SUBSCRIPTION_PROVIDER
- ? OPENAI_SUBSCRIPTION_PROVIDER
- : nextProvider
onPrimaryChange({
- provider: resolved,
+ provider: nextProvider,
model: resolveDefaultModel(
- resolved,
- constrainModelOptions(catalog, allowedModels, resolved)
+ nextProvider,
+ constrainModelOptions(catalog, allowedModels, nextProvider)
),
})
}}
diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
index 3650fa09f..98dc331c1 100644
--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
@@ -4,7 +4,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render as rtlRender, screen, waitFor } from '@testing-library/react'
import HostDetailsPage from '../../app/hosts/[name]/page'
import * as api from '../../lib/api'
-import { listCodexSubscriptionConnections } from '../../lib/codexSubscription'
+import {
+ listCodexConnectionModels,
+ listCodexSubscriptionConnections,
+} from '../../lib/codexSubscription'
import { ToastProvider } from '../Toast'
const replaceMock = vi.fn()
@@ -178,6 +181,9 @@ describe('HostDetailsPage identity integration', () => {
defaultModel: 'gpt-5.1',
},
])
+ vi.mocked(listCodexConnectionModels).mockResolvedValue([
+ { model: 'gpt-5.1', enabled: true, stale: false },
+ ])
const codexHost = {
...host,
spec: {
@@ -445,23 +451,17 @@ describe('HostDetailsPage identity integration', () => {
fireEvent.click(screen.getByRole('button', { name: 'Edit' }))
expect(screen.getByLabelText('Credential')).toBeInTheDocument()
expect(screen.queryByRole('radio', { name: /ChatGPT subscription/i })).not.toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled()
fireEvent.click(screen.getByRole('button', { name: 'Save' }))
-
- await waitFor(() =>
- expect(api.apiSend).toHaveBeenCalledWith('PUT', '/api/v1/admin/hosts/foo', expect.any(Object))
+ expect(api.apiSend).not.toHaveBeenCalledWith(
+ 'PUT',
+ '/api/v1/admin/hosts/foo',
+ expect.objectContaining({
+ spec: expect.objectContaining({
+ model: expect.objectContaining({ connectionRef: 'unassigned' }),
+ }),
+ })
)
- const putCall = (api.apiSend as unknown as ReturnType<typeof vi.fn>).mock.calls.find(
- c => c[0] === 'PUT' && c[1] === '/api/v1/admin/hosts/foo'
- )
- const payload = putCall![2]
- expect(payload.spec.model).toEqual({
- provider: 'codex-subscription',
- name: 'gpt-5.1',
- connectionRef: 'unassigned',
- })
- expect(payload.spec.secretRef).toBeUndefined()
- expect(payload.spec.hostRef).toBeUndefined()
- expect(payload.spec.userId).toBeUndefined()
- expect(payload.metadata?.name).toBeUndefined()
+ expect(screen.queryByText('OpenAI Codex Subscription')).not.toBeInTheDocument()
})
})
diff --git a/control-ui/lib/__tests__/llm.codexGrantModel.test.ts b/control-ui/lib/__tests__/llm.codexGrantModel.test.ts
index d17dfe664..9136e1298 100644
--- a/control-ui/lib/__tests__/llm.codexGrantModel.test.ts
+++ b/control-ui/lib/__tests__/llm.codexGrantModel.test.ts
@@ -23,8 +23,8 @@ describe('resolveCodexGrantModel', () => {
)
})
- it('keeps a named draft when the grant catalog is empty so Save is not an empty-name 422', () => {
- expect(resolveCodexGrantModel('gpt-5.4-mini', [])).toBe('gpt-5.4-mini')
+ it('invents nothing when the grant catalog is empty', () => {
+ expect(resolveCodexGrantModel('gpt-5.4-mini', [])).toBe('')
expect(resolveCodexGrantModel('', [])).toBe('')
})
})
diff --git a/control-ui/lib/codexSubscription.ts b/control-ui/lib/codexSubscription.ts
index e25f870af..74d1587ee 100644
--- a/control-ui/lib/codexSubscription.ts
+++ b/control-ui/lib/codexSubscription.ts
@@ -68,7 +68,7 @@ export type CodexCatalogSyncView = {
added: number
refreshed: number
staled: number
- connection: CodexSubscriptionConnectionView
+ connection: CodexSubscriptionConnectionView | null
}
const FORBIDDEN_KEY =
@@ -223,7 +223,7 @@ export function sanitizeCodexCatalogSync(raw: unknown): CodexCatalogSyncView {
added: pickNumber(raw.added),
refreshed: pickNumber(raw.refreshed),
staled: pickNumber(raw.staled),
- connection: sanitizeCodexConnection(raw.connection),
+ connection: raw.connection == null ? null : sanitizeCodexConnection(raw.connection),
}
}
@@ -276,44 +276,6 @@ export async function listCodexSubscriptionFleet(): Promise<{
}
}
-export async function unbindCodexHost(
- connectionKey: string,
- hostRef: string
-): Promise<{ host: string; connectionRef: string; model?: string }> {
- const raw = (await apiSend(
- 'POST',
- `${CODEX_SUBSCRIPTION_API_BASE}/connections/${encodeURIComponent(connectionKey)}/hosts/${encodeURIComponent(hostRef)}/unbind`
- )) as { host?: unknown; connectionRef?: unknown; model?: unknown }
- const model = pickString(raw.model)
- return {
- host: pickString(raw.host) ?? hostRef,
- connectionRef: pickString(raw.connectionRef) ?? CODEX_UNASSIGNED_CONNECTION_KEY,
- ...(model ? { model } : {}),
- }
-}
-
-export async function bindCodexHost(
- connectionKey: string,
- hostRef: string
-): Promise<{ host: string; connectionRef: string; model?: string }> {
- const raw = (await apiSend(
- 'POST',
- `${CODEX_SUBSCRIPTION_API_BASE}/connections/${encodeURIComponent(connectionKey)}/hosts/${encodeURIComponent(hostRef)}/bind`
- )) as { host?: unknown; connectionRef?: unknown; model?: unknown }
- const model = pickString(raw.model)
- return {
- host: pickString(raw.host) ?? hostRef,
- connectionRef: (() => {
- const next = pickString(raw.connectionRef)
- if (!next) {
- throw new Error('Codex subscription bind did not return connectionRef')
- }
- return next
- })(),
- ...(model ? { model } : {}),
- }
-}
-
export async function createCodexSubscriptionConnection(input: {
displayName: string
connectionKey?: string
diff --git a/control-ui/lib/codexSubscriptionFeature.ts b/control-ui/lib/codexSubscriptionFeature.ts
index 669a1cbe8..19177cc60 100644
--- a/control-ui/lib/codexSubscriptionFeature.ts
+++ b/control-ui/lib/codexSubscriptionFeature.ts
@@ -2,6 +2,7 @@ import { getCodexSubscriptionConnection } from './codexSubscription'
export type CodexSubscriptionCapability = {
enabled: boolean
+ error?: string
}
const DISABLED_CAPABILITY: CodexSubscriptionCapability = { enabled: false }
@@ -23,7 +24,7 @@ export async function loadCodexSubscriptionCapability(): Promise<CodexSubscripti
return { enabled: true }
} catch (error) {
if (isDisabledCapabilityError(error)) return DISABLED_CAPABILITY
- return DISABLED_CAPABILITY
+ throw error
}
}
diff --git a/control-ui/lib/llm.ts b/control-ui/lib/llm.ts
index 217c2c240..1ee0c0525 100644
--- a/control-ui/lib/llm.ts
+++ b/control-ui/lib/llm.ts
@@ -545,17 +545,26 @@ export function hostModelNameError(name: string): string | null {
}
/**
- * ChatGPT grants still need a concrete spec.model.name. Keep the draft only
- * when it is already in the offered grant list (or the list is empty, so a
- * named draft can save before catalog sync). Otherwise seed the first offered
- * model — never resolveDefaultModel, which is always '' for oauth-broker.
+ * ChatGPT grants still need a concrete spec.model.name. Same policy as
+ * control-api pickCodexGrantModel: current if offered, else grant default if
+ * offered, else first offered. An empty catalog invents nothing.
*/
-export function resolveCodexGrantModel(current: string, grantModels: string[]): string {
+export function resolveCodexGrantModel(
+ current: string,
+ grantModels: string[],
+ grantDefault?: string | null
+): string {
const trimmed = current.trim()
- if (trimmed && (grantModels.length === 0 || grantModels.includes(trimmed))) {
- return trimmed
- }
- return grantModels[0] ?? trimmed
+ if (trimmed && grantModels.includes(trimmed)) return trimmed
+ const fallback = grantDefault?.trim() ?? ''
+ if (fallback && grantModels.includes(fallback)) return fallback
+ return grantModels[0] ?? ''
+}
+
+export function offeredCodexModelNames(
+ rows: Array<{ model: string; enabled: boolean; stale: boolean }>
+): string[] {
+ return rows.filter(row => row.enabled && !row.stale).map(row => row.model)
}
// ── Per-host model allowlist subset (spec Topic 3a) ───────────────────────
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index ecd63b31d..96ceb6eb7 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.461",
+ "version": "0.1.462",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.461",
+ "version": "0.1.462",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-ui/package.json b/control-ui/package.json
index e949ea249..7e7e7836b 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.461",
+ "version": "0.1.462",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/docs/deploy/llm-providers.md b/docs/deploy/llm-providers.md
index cb2e31cf1..0c9f0e8da 100644
--- a/docs/deploy/llm-providers.md
+++ b/docs/deploy/llm-providers.md
@@ -5,7 +5,7 @@ credentials (including the multi-slot providers **Google Vertex AI** and
**Amazon Bedrock**), how to manage the operator-declared model allowlist, and how
the per-session model selector behaves in the desktop app.
-The canonical provider set — **22 providers**, from `openai`, `claude`
+The canonical provider set — **23 providers**, from `openai`, `claude`
(Anthropic), `zai` and `bailian` through the own-SDK `vertex` / `bedrock` to the
OpenAI-compatible additions and `azure` — and their credential slots live in the
shared `@clerum/llm-providers` package, which the Control UI, control-api,
diff --git a/docs/llm-providers/README.md b/docs/llm-providers/README.md
index 16cbb565d..8de8e0063 100644
--- a/docs/llm-providers/README.md
+++ b/docs/llm-providers/README.md
@@ -51,7 +51,7 @@ A few rules that follow from this split, and that surprise people:
## 2. Which providers are supported
-**22 providers**, defined once in
+**23 providers**, defined once in
[`packages/llm-providers/index.cjs`](../../packages/llm-providers/index.cjs) —
the single source of truth consumed by mcp-host, control-api, the workflow
runtime, the host controller and the Control UI.
diff --git a/docs/llms.txt b/docs/llms.txt
index 1c1cc2a37..306380b4e 100644
--- a/docs/llms.txt
+++ b/docs/llms.txt
@@ -35,7 +35,7 @@
- Connect Microsoft Teams (Teams CLI registration, derived endpoint, single-tenant requirement, verify flow): how-to/connect-teams.md
- Configure approvals: how-to/configure-approvals.md
- Add MCP server: how-to/add-mcp-server.md
-- LLM providers overview (the 22 providers, mental model, support matrix): llm-providers/README.md
+- LLM providers overview (the 23 providers, including oauth-broker ChatGPT, mental model, support matrix): llm-providers/README.md
- Configure LLM providers (credentials, model allowlist, session selector): deploy/llm-providers.md
- Add an LLM provider (data-only vs driver-based integration): llm-providers/adding-a-provider.md
- Desktop setup & updates (environments, invitation, updates): how-to/desktop-setup-and-updates.md
diff --git a/docs/meta/claims-guardrails.md b/docs/meta/claims-guardrails.md
index f5c8d1ed7..9c0b89967 100644
--- a/docs/meta/claims-guardrails.md
+++ b/docs/meta/claims-guardrails.md
@@ -11,8 +11,8 @@ caveats over absolute language.
| Do not write | Prefer |
| ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| Per-domain egress allowlisting for SaaS connectors | Port/CIDR egress with documented FQDN limits |
-| “Any model” / every provider under the sun | The 22 canonical providers (README table); OpenAI-compatible entries are config |
-| A provider outside the shared package as shipped | Only the 22 ids in `packages/llm-providers/index.cjs` ([overview](../llm-providers/README.md)) |
+| “Any model” / every provider under the sun | The 23 canonical providers (README table); OpenAI-compatible entries are config |
+| A provider outside the shared package as shipped | Only the 23 ids in `packages/llm-providers/index.cjs` ([overview](../llm-providers/README.md)) |
| Context memory always-on | Built-in pre-pruning + tiered compaction; **configurable** |
| Usage/cost in Grafana / `monitoring/` | control-api + control-ui (token dashboards, prices, budgets) |
| Token budgets as a security boundary | Cost control; fail-open |
diff --git a/docs/testing/codex-subscription-validation.md b/docs/testing/codex-subscription-validation.md
index f69bd0208..f414205de 100644
--- a/docs/testing/codex-subscription-validation.md
+++ b/docs/testing/codex-subscription-validation.md
@@ -37,9 +37,6 @@ cd tests/e2e
npm test -- --run integration/codex-subscription-contract-freeze.test.ts
```
-Live upstream (Task 25):
-
-```bash
-KUBECONTEXT="$KUBECONTEXT" CODEX_REAL_UPSTREAM_CONFIRM=1 \
- bash scripts/e2e/e2e-codex-subscription-real-upstream.sh
-```
+Live upstream is the Playwright connection lane (`codex-subscription-connection.spec.ts`)
+against a signed-in Control UI. There is no standalone
+`e2e-codex-subscription-real-upstream.sh` script.
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index 665d49863..9f10b8432 100644
--- a/host-context-controller/package-lock.json
+++ b/host-context-controller/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-host-context-controller",
- "version": "0.1.238",
+ "version": "0.1.239",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.238",
+ "version": "0.1.239",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@clerum/image-policy": "file:../packages/image-policy",
diff --git a/host-context-controller/package.json b/host-context-controller/package.json
index 68fdd2e0e..37be548c1 100644
--- a/host-context-controller/package.json
+++ b/host-context-controller/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-host-context-controller",
- "version": "0.1.238",
+ "version": "0.1.239",
"description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API",
"main": "dist/main.js",
"engines": {
diff --git a/host-context-controller/src/llmAllowedModelsSnapshot.test.ts b/host-context-controller/src/llmAllowedModelsSnapshot.test.ts
index 19bce8bdf..1256e8285 100644
--- a/host-context-controller/src/llmAllowedModelsSnapshot.test.ts
+++ b/host-context-controller/src/llmAllowedModelsSnapshot.test.ts
@@ -66,6 +66,19 @@ describe('parseAllowedModelsSnapshot per assigned connection', () => {
)
})
+ it('drops the union when the reserved grant omits models[]', () => {
+ const cm = multiGrantConfigMap()
+ const parsed = JSON.parse(
+ String(cm.metadata.annotations['clerum.io/codex-connections'])
+ ) as Record<string, { models?: string[] }>
+ delete parsed['deployment-default'].models
+ cm.metadata.annotations['clerum.io/codex-connections'] = JSON.stringify(parsed)
+ const snapshot = parseAllowedModelsSnapshot(cm, 'deployment-default')
+ expect(Array.from(snapshot.enabledModels ?? [])).not.toContain(
+ 'codex-subscription:gpt-5.3-codex'
+ )
+ })
+
it('does not rematch a missing deployment-default onto another grant in the map', () => {
const cm = multiGrantConfigMap()
const parsed = JSON.parse(
diff --git a/host-context-controller/src/llmAllowedModelsSnapshot.ts b/host-context-controller/src/llmAllowedModelsSnapshot.ts
index 2ae8da7ee..aea82b2e7 100644
--- a/host-context-controller/src/llmAllowedModelsSnapshot.ts
+++ b/host-context-controller/src/llmAllowedModelsSnapshot.ts
@@ -28,10 +28,10 @@ function intersectCodexModels(
enabledModels: Set<string>,
staleModels: Set<string>,
models: string[] | undefined,
- connectionKey: string
+ _connectionKey: string
): void {
if (!Array.isArray(models)) {
- if (connectionKey !== 'deployment-default') dropCodexModels(enabledModels, staleModels)
+ dropCodexModels(enabledModels, staleModels)
return
}
const allowed = new Set(models.filter(model => typeof model === 'string' && model.trim()))
@@ -56,7 +56,7 @@ function parseOptionalIntegerAnnotation(
export function parseAllowedModelsSnapshot(
cm: V1ConfigMap | undefined,
- connectionKey = 'deployment-default'
+ connectionKey = 'unassigned'
): CodexCatalogSnapshot {
if (!cm) return snapshotFromConfigMapError('missing')
const annotations = cm.metadata?.annotations ?? {}
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 15d287a3d..7417d2180 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.285",
+ "version": "0.1.286",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.285",
+ "version": "0.1.286",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index fc7c53e05..d721a713b 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.285",
+ "version": "0.1.286",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/config/configStore.ts b/mcp-host/src/config/configStore.ts
index 0abf0b44f..4bc7a5bd5 100644
--- a/mcp-host/src/config/configStore.ts
+++ b/mcp-host/src/config/configStore.ts
@@ -30,7 +30,7 @@
* backoff; on "too old" the watch falls back to a fresh list and resumes.
*/
import * as k8s from '@kubernetes/client-node'
-import { assignedConnectionRef } from '../llm/hostLlmBinding'
+import { CODEX_UNASSIGNED_CONNECTION_KEY, assignedConnectionRef } from '../llm/hostLlmBinding'
import {
ALL_PROVIDERS,
ALL_PROVIDER_SLOT_ENV_NAMES,
@@ -627,13 +627,14 @@ export class ConfigStore {
entry.contextWindowTokens = rec.contextWindowTokens as number
}
if (typeof rec.vendor === 'string') entry.vendor = rec.vendor
+ if (rec.stale === true) continue
entries.push(entry)
}
if (provider === 'codex-subscription') {
if (Array.isArray(binding?.models)) {
const allowed = new Set(binding.models)
entries = entries.filter(entry => allowed.has(entry.model))
- } else if (!binding || binding.connectionKey !== 'deployment-default') {
+ } else {
entries = []
}
}
@@ -933,9 +934,9 @@ function parseOptionalIntegerAnnotation(
function parseCodexPolicyBinding(
annotations: Record<string, string> | undefined,
- connectionKey = 'deployment-default'
+ connectionKey = CODEX_UNASSIGNED_CONNECTION_KEY
): CodexPolicyBinding | null {
- if (!annotations) return null
+ if (!annotations || connectionKey === CODEX_UNASSIGNED_CONNECTION_KEY) return null
let catalogRevision = parseOptionalIntegerAnnotation(annotations, CATALOG_REVISION_ANNOTATION)
let credentialRevision = parseOptionalIntegerAnnotation(
annotations,
diff --git a/scripts/tests/test-codex-subscription-t0.sh b/scripts/tests/test-codex-subscription-t0.sh
index 027566fd0..7b35f8724 100755
--- a/scripts/tests/test-codex-subscription-t0.sh
+++ b/scripts/tests/test-codex-subscription-t0.sh
@@ -155,6 +155,7 @@ run_group "shared-contract" "packages/llm-provider-attempt-contract" "index.test
run_group "control-api" "control-api" \
"test/codexSubscriptionRedirectUri.test.ts" \
"test/routes.admin.codexSubscription.test.ts" \
+ "test/routes.admin.codexSubscription.hostWrite.test.ts" \
"test/routes.auth.codexSubscriptionCallback.test.ts" \
"test/routes.mcp-host.llmProviderAttempts.test.ts" \
"test/hostSpecValidation.codexSubscription.test.ts" \
@@ -178,25 +179,30 @@ run_group "mcp-host" "mcp-host" \
"src/llm/__tests__/codexSubscription.test.ts" \
"src/llm/__tests__/codexLlmProxyClient.test.ts" \
"src/llm/__tests__/providerAttemptAuthorizer.test.ts" \
+ "src/llm/hostLlmBinding.test.ts" \
+ "src/config/configStore.test.ts" \
"src/llm/failover/__tests__/engine.test.ts" \
"src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.ts"
run_group "host-context-controller" "host-context-controller" \
"src/codexExecutionProjection.test.ts" \
"src/hostReconciler.codexScopeProvenance.test.ts" \
+ "src/llmAllowedModelsSnapshot.test.ts" \
"src/networkPolicyReconciler.test.ts"
run_group "workflow-recipes" "workflow-recipes" \
"src/workflow/codexExecutionProjection.test.ts" \
"src/workflow/workflowReconciler.codexScopeProvenance.test.ts" \
+ "src/workflow/llmAllowedModelsSnapshot.test.ts" \
"src/workflow/networkPolicyFactory.codex.test.ts"
run_group "control-ui" "control-ui" \
- "components/__tests__/CodexAgentAssignment.test.tsx" \
"components/__tests__/CodexSubscriptionHub.test.tsx" \
"components/__tests__/LlmProviderConfig.test.tsx" \
"lib/__tests__/llm.codexGrantModel.test.ts" \
+ "lib/__tests__/llmCredentialSelect.test.ts" \
"components/__tests__/HostWizard.test.tsx" \
+ "components/__tests__/HostDetailsPage.identity.test.tsx" \
"components/__tests__/RecipeEditor.test.tsx"
node_major=$(node --version | sed -n 's/^v\([0-9][0-9]*\).*/\1/p')
diff --git a/tests/e2e/playwright/control-ui/codex-subscription-connection.spec.ts b/tests/e2e/playwright/control-ui/codex-subscription-connection.spec.ts
index ec97e87b1..fbd3f5087 100644
--- a/tests/e2e/playwright/control-ui/codex-subscription-connection.spec.ts
+++ b/tests/e2e/playwright/control-ui/codex-subscription-connection.spec.ts
@@ -162,15 +162,15 @@ test.describe('Codex subscription connection', () => {
const grantKey = connected!.connectionKey
const displayName = connected!.displayName || grantKey
- await hub.openGrant(displayName)
const modelsGet = page.waitForResponse(
response =>
new RegExp(
`/api/v1/admin/llm/providers/codex-subscription/connections/${grantKey}/models$`
).test(new URL(response.url()).pathname) && response.request().method() === 'GET'
)
+ await hub.openGrant(displayName)
await modelsGet
- const firstToggle = page.locator('dialog input[type="checkbox"]').first()
+ const firstToggle = page.getByRole('dialog').locator('input[type="checkbox"]').first()
await expect(firstToggle, 'grant modal must list catalog models').toBeVisible()
const modelName = (
(await firstToggle.evaluate(node => node.closest('label')?.textContent)) ?? ''
@@ -207,13 +207,13 @@ test.describe('Codex subscription connection', () => {
true
)
- await hub.openGrant(displayName)
const reopened = page.waitForResponse(
response =>
new RegExp(
`/api/v1/admin/llm/providers/codex-subscription/connections/${grantKey}/models$`
).test(new URL(response.url()).pathname) && response.request().method() === 'GET'
)
+ await hub.openGrant(displayName)
const modelsRes = await reopened
const modelsBody = (await modelsRes.json()) as {
models?: Array<{ model?: string; enabled?: boolean }>
diff --git a/tests/e2e/playwright/control-ui/codex-subscription-host-workflow.spec.ts b/tests/e2e/playwright/control-ui/codex-subscription-host-workflow.spec.ts
index 4b54d5002..db6b60f1e 100644
--- a/tests/e2e/playwright/control-ui/codex-subscription-host-workflow.spec.ts
+++ b/tests/e2e/playwright/control-ui/codex-subscription-host-workflow.spec.ts
@@ -3,9 +3,9 @@
*
* Contract:
* - Entry point: application root `/` (E2E_GUARDIAN_ENTRY_POINT).
- * - Actions: visible login, open Agents, start Create agent, choose Codex.
- * - Route/state: `/agents/new` Model & credentials step.
- * - UI: OpenAI + ChatGPT subscription is selectable and requires no LLM secret.
+ * - Actions: visible login, open Agents, start Create agent, choose a ChatGPT grant.
+ * - Route/state: `/agents/new` Model & Credentials step.
+ * - UI: mixed Credential select (API key secret or ChatGPT subscription).
* - Business signal: waitForResponse on the allowlist catalog used to populate models.
*
* A live catalog model is not asserted: Sync/enable is the connection lane.
@@ -14,7 +14,7 @@ import { expect, test } from '@playwright/test'
import { loginControlUiVisible } from '../helpers/visible-login'
test.describe('Codex subscription host and workflow authoring', () => {
- test('operator can select Codex Subscription without a Host Secret', async ({ page }) => {
+ test('operator can choose a ChatGPT subscription without a Host Secret', async ({ page }) => {
// E2E_GUARDIAN_ENTRY_POINT
await page.goto('/')
await loginControlUiVisible(page)
@@ -40,17 +40,14 @@ test.describe('Codex subscription host and workflow authoring', () => {
await page.getByText('Create new context', { exact: true }).click()
await page.getByPlaceholder('context-name').fill('e2e-codex-ctx')
await page.getByRole('button', { name: 'Next' }).click()
- await expect(page.getByText('Model & credentials', { exact: true })).toBeVisible()
+ await expect(page.getByText('Model & Credentials', { exact: true })).toBeVisible()
- await page.getByLabel('Provider').click()
- await page.getByRole('option', { name: 'OpenAI', exact: true }).click()
- await expect(page.getByRole('option', { name: 'OpenAI Codex Subscription' })).toHaveCount(0)
- await page.getByRole('radio', { name: 'ChatGPT subscription' }).check()
- await expect(
- page.getByText(/This OpenAI credential authenticates through a ChatGPT subscription/)
- ).toBeVisible()
+ await expect(page.getByRole('radio', { name: /ChatGPT subscription/i })).toHaveCount(0)
+ await expect(page.getByTestId('codex-agent-assignment')).toHaveCount(0)
+ await expect(page.getByText('Use an existing secret')).toBeVisible()
+ await expect(page.getByText('Credential')).toBeVisible()
await expect(page.getByLabel('Secret name')).toHaveCount(0)
await expect(page.getByLabel(/OpenAI API key/i)).toHaveCount(0)
- await expect(page.getByTestId('codex-agent-assignment')).toBeVisible()
+ await expect(page.getByRole('button', { name: 'Next' })).toBeDisabled()
})
})
diff --git a/tests/e2e/playwright/package-lock.json b/tests/e2e/playwright/package-lock.json
index 99e9584e0..0429aa18d 100644
--- a/tests/e2e/playwright/package-lock.json
+++ b/tests/e2e/playwright/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-playwright-tests",
- "version": "0.1.33",
+ "version": "0.1.34",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-playwright-tests",
- "version": "0.1.33",
+ "version": "0.1.34",
"devDependencies": {
"@playwright/test": "^1.50.0",
"@types/node": "^22.0.0"
diff --git a/tests/e2e/playwright/package.json b/tests/e2e/playwright/package.json
index 1fac92c88..234fd06e7 100644
--- a/tests/e2e/playwright/package.json
+++ b/tests/e2e/playwright/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-playwright-tests",
- "version": "0.1.33",
+ "version": "0.1.34",
"private": true,
"description": "Playwright E2E tests for Control UI and Desktop App",
"scripts": {
diff --git a/tests/e2e/playwright/pages/codex-subscription.ts b/tests/e2e/playwright/pages/codex-subscription.ts
index 6806b9839..8bf7c1a8b 100644
--- a/tests/e2e/playwright/pages/codex-subscription.ts
+++ b/tests/e2e/playwright/pages/codex-subscription.ts
@@ -127,12 +127,18 @@ export class SecretsLlmSubscriptionsPage {
constructor(readonly page: Page) {}
async expectTable() {
- await expect(this.page.getByRole('columnheader', { name: 'Name' })).toBeVisible()
- await expect(this.page.getByRole('columnheader', { name: 'Status' })).toBeVisible()
- await expect(this.page.getByRole('columnheader', { name: 'Agents' })).toHaveCount(0)
- await expect(this.page.getByRole('tab', { name: /^Subscription$/ })).toHaveCount(0)
await expect(this.page.getByRole('tab', { name: 'API-KEY' })).toBeVisible()
await expect(this.page.getByRole('tab', { name: 'Subscriptions' })).toBeVisible()
+ await expect(this.page.getByRole('tab', { name: /^Subscription$/ })).toHaveCount(0)
+ await expect(this.page.getByRole('columnheader', { name: 'Agents' })).toHaveCount(0)
+ const hasHeaders = (await this.page.getByRole('columnheader', { name: 'Name' }).count()) > 0
+ if (hasHeaders) {
+ await expect(this.page.getByRole('columnheader', { name: 'Status' })).toBeVisible()
+ } else {
+ await expect(
+ this.page.getByText(/No ChatGPT subscriptions|Add subscription/i).first()
+ ).toBeVisible()
+ }
}
grantRow(displayName: string): Locator {
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index cabd1ecf7..ae2f4932d 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.307",
+ "version": "0.1.308",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.307",
+ "version": "0.1.308",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@aws-sdk/client-s3": "^3.1009.0",
diff --git a/workflow-recipes/package.json b/workflow-recipes/package.json
index 9e808e715..2546f6c4f 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.307",
+ "version": "0.1.308",
"description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface",
"main": "dist/main.js",
"engines": {
diff --git a/workflow-recipes/src/workflow/llmAllowedModelsSnapshot.test.ts b/workflow-recipes/src/workflow/llmAllowedModelsSnapshot.test.ts
index 3043571e0..f3c7c3c03 100644
--- a/workflow-recipes/src/workflow/llmAllowedModelsSnapshot.test.ts
+++ b/workflow-recipes/src/workflow/llmAllowedModelsSnapshot.test.ts
@@ -34,11 +34,19 @@ function multiGrantConfigMap() {
describe('WRC parseAllowedModelsSnapshot per assigned connection', () => {
it('reads clerum.io/codex-connections instead of the flat status annotation', () => {
- const snapshot = parseAllowedModelsSnapshot(multiGrantConfigMap())
+ const snapshot = parseAllowedModelsSnapshot(multiGrantConfigMap(), 'deployment-default')
expect(snapshot.connectionStatus).toBe('revoked')
expect(snapshot.connectionRevision).toBe(9)
})
+ it('does not inherit a reserved grant when the recipe has no assigned key', () => {
+ const snapshot = parseAllowedModelsSnapshot(multiGrantConfigMap())
+ expect(snapshot.connectionStatus).toBe('disconnected')
+ expect(Array.from(snapshot.enabledModels ?? [])).not.toContain(
+ 'codex-subscription:gpt-5.3-codex'
+ )
+ })
+
it('can project a non-default grant when a recipe is later bound to one', () => {
const snapshot = parseAllowedModelsSnapshot(multiGrantConfigMap(), 'personal-pro')
expect(snapshot.connectionStatus).toBe('connected')
diff --git a/workflow-recipes/src/workflow/llmAllowedModelsSnapshot.ts b/workflow-recipes/src/workflow/llmAllowedModelsSnapshot.ts
index eb6ead455..b17fca862 100644
--- a/workflow-recipes/src/workflow/llmAllowedModelsSnapshot.ts
+++ b/workflow-recipes/src/workflow/llmAllowedModelsSnapshot.ts
@@ -29,10 +29,10 @@ function intersectCodexModels(
enabledModels: Set<string>,
staleModels: Set<string>,
models: string[] | undefined,
- connectionKey: string
+ _connectionKey: string
): void {
if (!Array.isArray(models)) {
- if (connectionKey !== 'deployment-default') dropCodexModels(enabledModels, staleModels)
+ dropCodexModels(enabledModels, staleModels)
return
}
const allowed = new Set(models.filter(model => typeof model === 'string' && model.trim()))
@@ -57,7 +57,7 @@ function parseOptionalIntegerAnnotation(
export function parseAllowedModelsSnapshot(
cm: V1ConfigMap | undefined,
- connectionKey = 'deployment-default'
+ connectionKey = 'unassigned'
): CodexCatalogSnapshot {
if (!cm) return snapshotFromConfigMapError('missing')
const annotations = cm.metadata?.annotations ?? {}