Skip to content

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

TypeScript

fix(codex): treat a missing Host connectionRef as unassigned

Alfredo Lopezfecfa2d135c1
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index fd00bd22d..54a6a0334 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.500",
+ "version": "0.1.501",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.500",
+ "version": "0.1.501",
"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 c493a107b..e1c71717b 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.500",
+ "version": "0.1.501",
"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/hostSpecValidation.ts b/control-api/src/routes/admin/hostSpecValidation.ts
index 5d15131fe..0d0562b4b 100644
--- a/control-api/src/routes/admin/hostSpecValidation.ts
+++ b/control-api/src/routes/admin/hostSpecValidation.ts
@@ -9,6 +9,7 @@ import type { DbClient } from '../../db.js'
import { rootLogger } from '../../observability/logger.js'
import { isCodexAssignmentAllowed } from '../../services/codexSubscriptionCatalog.js'
import {
+ CODEX_UNASSIGNED_CONNECTION_KEY,
isCodexUnassignedConnectionKey,
readHostCodexConnectionRef,
} from '../../services/codexSubscriptionConnection.js'
@@ -184,7 +185,7 @@ export function createHostValidationDeps(db: DbClient): HostSpecValidationDeps {
return {
isModelAllowed: (provider, model, connectionRef) =>
provider === 'codex-subscription'
- ? isCodexAssignmentAllowed(db, connectionRef ?? 'deployment-default', model)
+ ? isCodexAssignmentAllowed(db, readHostCodexConnectionRef(connectionRef), model)
: isModelAllowedDefault(provider, model, db),
getModelAllowlistState: (provider, model) => getModelAllowlistStateDefault(provider, model, db),
}
@@ -361,6 +362,10 @@ export async function validateHostSpec(
}
const connectionRef =
provider === 'codex-subscription' ? resolvedCodexConnectionRef(model) : undefined
+ if (provider === 'codex-subscription' && isCodexUnassignedConnectionKey(connectionRef)) {
+ // Persist the sentinel so empty and unassigned are not two Host states.
+ model.connectionRef = CODEX_UNASSIGNED_CONNECTION_KEY
+ }
const skipCodexAllowlist =
provider === 'codex-subscription' && isCodexUnassignedConnectionKey(connectionRef)
const allowed = skipCodexAllowlist
@@ -568,7 +573,7 @@ async function maybeWarnStale(
* the gate skips its rejection.
*/
function resolvedCodexConnectionRef(model: unknown): string {
- if (!isPlainObject(model)) return 'deployment-default'
+ if (!isPlainObject(model)) return CODEX_UNASSIGNED_CONNECTION_KEY
return readHostCodexConnectionRef(
typeof model.connectionRef === 'string' ? model.connectionRef : null
)
diff --git a/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts b/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts
index 462d798fd..6765ec1f6 100644
--- a/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts
+++ b/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts
@@ -6,7 +6,7 @@ import { requireMcpHostJwt } from '../../middleware/mcpHostJwtAuth.js'
import { rootLogger } from '../../observability/logger.js'
import {
CODEX_SUBSCRIPTION_CONNECTION_KEY,
- normalizeCodexConnectionKey,
+ readHostCodexConnectionRef,
} from '../../services/codexSubscriptionConnection.js'
import {
LlmProviderAttemptAuthorizeError,
@@ -53,7 +53,7 @@ export async function resolveHostAssignedConnectionKey(
const host = (await gateway.getResource('hosts', hostRef, config.hostsNamespace)) as {
spec?: { model?: { connectionRef?: string } }
}
- return normalizeCodexConnectionKey(host?.spec?.model?.connectionRef)
+ return readHostCodexConnectionRef(host?.spec?.model?.connectionRef)
} catch {
throw new LlmProviderAttemptAuthorizeError(
'host_binding_mismatch',
diff --git a/control-api/src/services/codexSubscriptionCatalog.ts b/control-api/src/services/codexSubscriptionCatalog.ts
index f064879a0..eb7e25832 100644
--- a/control-api/src/services/codexSubscriptionCatalog.ts
+++ b/control-api/src/services/codexSubscriptionCatalog.ts
@@ -8,7 +8,9 @@ import {
type CodexSubscriptionConnectionStatus,
type CodexSubscriptionSafeConnection,
getSafeCodexSubscriptionConnection,
+ isCodexUnassignedConnectionKey,
normalizeCodexConnectionKey,
+ readHostCodexConnectionRef,
recordCodexCatalogOutcome,
} from './codexSubscriptionConnection.js'
@@ -159,10 +161,9 @@ export async function isCodexAssignmentAllowed(
connectionRef: string,
model: string
): Promise<boolean> {
- const connection = await getSafeCodexSubscriptionConnection(
- db,
- normalizeCodexConnectionKey(connectionRef)
- )
+ const key = readHostCodexConnectionRef(connectionRef)
+ if (isCodexUnassignedConnectionKey(key)) return false
+ const connection = await getSafeCodexSubscriptionConnection(db, key)
if (
!connection ||
connection.status !== 'connected' ||
diff --git a/control-api/src/services/codexSubscriptionConnection.ts b/control-api/src/services/codexSubscriptionConnection.ts
index ed917eaf4..cef7d24d1 100644
--- a/control-api/src/services/codexSubscriptionConnection.ts
+++ b/control-api/src/services/codexSubscriptionConnection.ts
@@ -13,14 +13,16 @@ export function isCodexUnassignedConnectionKey(value?: string | null): boolean {
}
/**
- * Host spec reader: empty/missing becomes deployment-default; `unassigned` stays.
+ * Host spec reader. Empty/missing is `unassigned`, never the reserved grant.
+ * Only an explicit connectionRef may spend a ChatGPT subscription.
*/
export function readHostCodexConnectionRef(value?: string | null): string {
const trimmed = typeof value === 'string' ? value.trim() : ''
- if (!trimmed) return CODEX_SUBSCRIPTION_CONNECTION_KEY
+ if (!trimmed) return CODEX_UNASSIGNED_CONNECTION_KEY
return trimmed
}
+/** Grant-row key. Empty aliases the reserved OAuth/DB row, not a Host spec field. */
export function normalizeCodexConnectionKey(value?: string | null): string {
const trimmed = typeof value === 'string' ? value.trim() : ''
if (isCodexUnassignedConnectionKey(trimmed)) return CODEX_UNASSIGNED_CONNECTION_KEY
diff --git a/control-api/test/hostSpecValidation.codexSubscription.test.ts b/control-api/test/hostSpecValidation.codexSubscription.test.ts
index 2d4361aed..2170607c0 100644
--- a/control-api/test/hostSpecValidation.codexSubscription.test.ts
+++ b/control-api/test/hostSpecValidation.codexSubscription.test.ts
@@ -97,18 +97,14 @@ describe('codex-subscription Host admission', () => {
expect(isModelAllowed).not.toHaveBeenCalled()
})
- it('defaults a missing connectionRef to deployment-default and checks that grant', async () => {
+ it('materializes a missing connectionRef as unassigned and does not check a grant', async () => {
process.env.CONTROL_API_CODEX_SUBSCRIPTION_ENABLED = 'true'
const isModelAllowed = vi.fn().mockResolvedValue(true)
const spec = { model: { provider: 'codex-subscription', name: 'gpt-5.1' } }
const res = await validateHostSpec(spec, { isModelAllowed })
expect(res).toBeNull()
- expect(isModelAllowed).toHaveBeenCalledWith(
- 'codex-subscription',
- 'gpt-5.1',
- 'deployment-default'
- )
- expect((spec.model as { connectionRef?: string }).connectionRef).toBeUndefined()
+ expect(isModelAllowed).not.toHaveBeenCalled()
+ expect((spec.model as { connectionRef?: string }).connectionRef).toBe('unassigned')
})
it('evaluates allowedModels and fallbacks against the Host connectionRef', async () => {
diff --git a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts b/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts
index b9b7bca69..3d27a6d83 100644
--- a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts
+++ b/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts
@@ -145,7 +145,7 @@ describe('POST /api/v1/mcp-host/llm/provider-attempts/authorize', () => {
})
describe('resolveHostAssignedConnectionKey', () => {
- it('reads the Host connectionRef and defaults a Phase 1 Host', async () => {
+ it('reads the Host connectionRef and treats a missing field as unassigned', async () => {
const gateway = {
getResource: vi.fn().mockResolvedValue({
spec: { model: { provider: 'codex-subscription', connectionRef: 'team-plus' } },
@@ -156,14 +156,19 @@ describe('resolveHostAssignedConnectionKey', () => {
gateway.getResource.mockResolvedValueOnce({
spec: { model: { provider: 'codex-subscription' } },
})
- await expect(resolveHostAssignedConnectionKey(gateway, 'agent-b')).resolves.toBe(
- 'deployment-default'
- )
+ await expect(resolveHostAssignedConnectionKey(gateway, 'agent-b')).resolves.toBe('unassigned')
gateway.getResource.mockResolvedValueOnce({
spec: { model: { provider: 'codex-subscription', connectionRef: 'unassigned' } },
})
await expect(resolveHostAssignedConnectionKey(gateway, 'agent-c')).resolves.toBe('unassigned')
+
+ gateway.getResource.mockResolvedValueOnce({
+ spec: { model: { provider: 'codex-subscription', connectionRef: 'deployment-default' } },
+ })
+ await expect(resolveHostAssignedConnectionKey(gateway, 'agent-d')).resolves.toBe(
+ 'deployment-default'
+ )
})
it('aliases a recipe caller to deployment-default without a Host GET', async () => {
diff --git a/control-api/test/services.codexSubscriptionConnection.test.ts b/control-api/test/services.codexSubscriptionConnection.test.ts
index 571995eb6..7d2cd3a64 100644
--- a/control-api/test/services.codexSubscriptionConnection.test.ts
+++ b/control-api/test/services.codexSubscriptionConnection.test.ts
@@ -174,8 +174,10 @@ describe('codex subscription connection repository', () => {
CodexSubscriptionInvalidConnectionKeyError
)
expect(readHostCodexConnectionRef('unassigned')).toBe('unassigned')
- expect(readHostCodexConnectionRef('')).toBe('deployment-default')
+ expect(readHostCodexConnectionRef('')).toBe('unassigned')
+ expect(readHostCodexConnectionRef(undefined)).toBe('unassigned')
expect(readHostCodexConnectionRef('codex-aaa')).toBe('codex-aaa')
+ expect(readHostCodexConnectionRef('deployment-default')).toBe('deployment-default')
expect(normalizeCodexConnectionKey('unassigned')).toBe('unassigned')
expect(normalizeCodexConnectionKey('')).toBe('deployment-default')
})
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index 9783bd956..665d49863 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.237",
+ "version": "0.1.238",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.237",
+ "version": "0.1.238",
"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 63f7ecdd8..68fdd2e0e 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.237",
+ "version": "0.1.238",
"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/codexExecutionProjection.test.ts b/host-context-controller/src/codexExecutionProjection.test.ts
index c62420120..d6caa7c91 100644
--- a/host-context-controller/src/codexExecutionProjection.test.ts
+++ b/host-context-controller/src/codexExecutionProjection.test.ts
@@ -3,8 +3,10 @@ import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import {
CODEX_EXECUTE_SCOPE,
+ CODEX_UNASSIGNED_CONNECTION_KEY,
type CodexCatalogSnapshot,
type CodexHostSpec,
+ assignedHostCodexConnectionRef,
projectCodexExecution,
} from './codexExecutionProjection'
@@ -101,6 +103,12 @@ describe('projectCodexExecution', () => {
expect(first.catalogContentHash).not.toBe(second.catalogContentHash)
})
+ it('treats a missing Host connectionRef as unassigned, not the reserved grant', () => {
+ expect(assignedHostCodexConnectionRef(undefined)).toBe(CODEX_UNASSIGNED_CONNECTION_KEY)
+ expect(assignedHostCodexConnectionRef('')).toBe(CODEX_UNASSIGNED_CONNECTION_KEY)
+ expect(assignedHostCodexConnectionRef('deployment-default')).toBe('deployment-default')
+ })
+
it('anti-false-positive: uncertain never defaults to eligible', () => {
// A reversible mutation that defaulted eligibility to `eligible` must make
// this assertion RED. The committed code stays fail-closed.
diff --git a/host-context-controller/src/codexExecutionProjection.ts b/host-context-controller/src/codexExecutionProjection.ts
index 685ea7e86..f8486ae06 100644
--- a/host-context-controller/src/codexExecutionProjection.ts
+++ b/host-context-controller/src/codexExecutionProjection.ts
@@ -1,5 +1,16 @@
export const CODEX_EXECUTE_SCOPE = 'llm:codex:execute'
export const CODEX_PROVIDER = 'codex-subscription'
+/** Fail-closed Host sentinel. Empty/missing is not the reserved grant. */
+export const CODEX_UNASSIGNED_CONNECTION_KEY = 'unassigned' as const
+
+export function assignedHostCodexConnectionRef(value?: string | null): string {
+ const trimmed = typeof value === 'string' ? value.trim() : ''
+ return trimmed || CODEX_UNASSIGNED_CONNECTION_KEY
+}
+
+export function isCodexUnassignedConnectionRef(value?: string | null): boolean {
+ return assignedHostCodexConnectionRef(value) === CODEX_UNASSIGNED_CONNECTION_KEY
+}
export type CodexTargetSource = 'primary' | 'allowed' | 'fallback'
diff --git a/host-context-controller/src/hostReconciler.codexScopeProvenance.test.ts b/host-context-controller/src/hostReconciler.codexScopeProvenance.test.ts
index 6d98aa3e1..f2bb44de9 100644
--- a/host-context-controller/src/hostReconciler.codexScopeProvenance.test.ts
+++ b/host-context-controller/src/hostReconciler.codexScopeProvenance.test.ts
@@ -129,7 +129,11 @@ function makeCodexHost(overrides?: Partial<HostCRD['spec']>): HostCRD {
host: 'codex-host',
contextRef: 'context-a',
channels: ['channel-a'],
- model: { provider: 'codex-subscription', name: 'gpt-5.3-codex' },
+ model: {
+ provider: 'codex-subscription',
+ name: 'gpt-5.3-codex',
+ connectionRef: 'deployment-default',
+ },
...overrides,
},
}
@@ -302,6 +306,21 @@ describe('HostReconciler Codex scope provenance', () => {
expect(issuedScopes()).not.toContain('llm:codex:execute')
})
+ it('does not mint Codex scope or egress when connectionRef is missing', async () => {
+ const { reconciler, coreApi, networkingApi } = createReconciler()
+ wireAllowlist(coreApi, eligibleCodexConfigMap())
+
+ await reconciler.reconcile(
+ makeCodexHost({
+ model: { provider: 'codex-subscription', name: 'gpt-5.3-codex' },
+ })
+ )
+
+ expect(issueMcpHostRuntimeTokens).toHaveBeenCalled()
+ expect(issuedScopes()).not.toContain('llm:codex:execute')
+ expect(proxyPolicyBodies(networkingApi)).toEqual([])
+ })
+
it('does not mint Codex scope or egress when the allowlist ConfigMap times out', async () => {
const { reconciler, coreApi, networkingApi } = createReconciler()
wireAllowlist(
diff --git a/host-context-controller/src/hostReconciler.ts b/host-context-controller/src/hostReconciler.ts
index 2558ff3fe..c8b7436c9 100644
--- a/host-context-controller/src/hostReconciler.ts
+++ b/host-context-controller/src/hostReconciler.ts
@@ -7,6 +7,8 @@ import type { AdministrativeOutcomeReporter } from './administrativeOutcomeRepor
import {
type CodexCatalogSnapshot,
type CodexExecutionProjection,
+ assignedHostCodexConnectionRef,
+ isCodexUnassignedConnectionRef,
projectCodexExecution,
} from './codexExecutionProjection'
import { config } from './config'
@@ -1377,7 +1379,17 @@ export class HostReconciler {
}
private projectCodexForHost(host: HostCRD): CodexExecutionProjection {
- const connectionKey = host.spec.model?.connectionRef?.trim() || 'deployment-default'
+ const connectionKey = assignedHostCodexConnectionRef(host.spec.model?.connectionRef)
+ if (isCodexUnassignedConnectionRef(connectionKey)) {
+ // Missing/empty is not the reserved grant. Do not project execute scope
+ // or proxy egress from deployment-default just because the field was omitted.
+ return projectCodexExecution(host.spec, {
+ flagEnabled: this.codexSnapshot.flagEnabled,
+ connectionStatus: 'disconnected',
+ enabledModels: [],
+ staleModels: [],
+ })
+ }
const snapshot = this.lastCodexConfigMap
? parseAllowedModelsSnapshot(this.lastCodexConfigMap, connectionKey)
: this.codexSnapshot
diff --git a/host-context-controller/src/llmAllowedModelsSnapshot.test.ts b/host-context-controller/src/llmAllowedModelsSnapshot.test.ts
index 9410730fa..19bce8bdf 100644
--- a/host-context-controller/src/llmAllowedModelsSnapshot.test.ts
+++ b/host-context-controller/src/llmAllowedModelsSnapshot.test.ts
@@ -55,10 +55,15 @@ describe('parseAllowedModelsSnapshot per assigned connection', () => {
expect(projectCodexExecution(spec, live).eligibility).toBe('eligible')
})
- it('defaults a Phase 1 Host without connectionRef to deployment-default', () => {
- const snapshot = parseAllowedModelsSnapshot(multiGrantConfigMap())
+ it('parses the reserved grant when that key is requested, not when a Host omits connectionRef', () => {
+ const snapshot = parseAllowedModelsSnapshot(multiGrantConfigMap(), 'deployment-default')
expect(snapshot.connectionStatus).toBe('connected')
expect(snapshot.catalogRevision).toBe(1)
+ const unassigned = parseAllowedModelsSnapshot(multiGrantConfigMap(), 'unassigned')
+ expect(unassigned.connectionStatus).toBe('disconnected')
+ expect(Array.from(unassigned.enabledModels ?? [])).not.toContain(
+ 'codex-subscription:gpt-5.3-codex'
+ )
})
it('does not rematch a missing deployment-default onto another grant in the map', () => {
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index b659839cb..15d287a3d 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.284",
+ "version": "0.1.285",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.284",
+ "version": "0.1.285",
"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 91ba30c2c..fc7c53e05 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.284",
+ "version": "0.1.285",
"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.test.ts b/mcp-host/src/config/configStore.test.ts
index 34faf1c4a..97776597d 100644
--- a/mcp-host/src/config/configStore.test.ts
+++ b/mcp-host/src/config/configStore.test.ts
@@ -562,6 +562,7 @@ describe('ConfigStore — allowlist tier (R3)', () => {
it('exposes Codex catalog/credential revisions from allowlist annotations', async () => {
const built = build({
provider: 'openai',
+ connectionRef: 'deployment-default',
secrets: { 'chatllm-api-keys': { 'openai-api-key': 'sk' } },
allowlistConfigMapName: ALLOWLIST_CM,
configMaps: {
@@ -858,4 +859,34 @@ describe('ConfigStore — allowlist tier (R3)', () => {
expect(store.codexPolicyBinding()).toBeNull()
expect(store.allowedModels().get('codex-subscription')).toEqual([])
})
+
+ it('does not inherit deployment-default when the Host has no connectionRef', async () => {
+ const built = build({
+ provider: 'codex-subscription',
+ secrets: { 'chatllm-api-keys': { 'openai-api-key': 'sk' } },
+ allowlistConfigMapName: ALLOWLIST_CM,
+ configMaps: {
+ [ALLOWLIST_CM]: {
+ 'codex-subscription': JSON.stringify([{ model: 'gpt-5.3-codex' }]),
+ },
+ },
+ configMapAnnotations: {
+ [ALLOWLIST_CM]: {
+ 'clerum.io/catalog-revision': '4',
+ 'clerum.io/connection-revision': '2',
+ 'clerum.io/codex-connections': JSON.stringify({
+ 'deployment-default': {
+ catalogRevision: 4,
+ connectionRevision: 2,
+ models: ['gpt-5.3-codex'],
+ },
+ }),
+ },
+ },
+ })
+ store = built.store
+ await store.start()
+ expect(store.codexPolicyBinding()).toBeNull()
+ expect(store.allowedModels().get('codex-subscription')).toEqual([])
+ })
})
diff --git a/mcp-host/src/config/configStore.ts b/mcp-host/src/config/configStore.ts
index db57da08a..0abf0b44f 100644
--- a/mcp-host/src/config/configStore.ts
+++ b/mcp-host/src/config/configStore.ts
@@ -30,6 +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 {
ALL_PROVIDERS,
ALL_PROVIDER_SLOT_ENV_NAMES,
@@ -135,7 +136,7 @@ export interface ConfigStoreOptions {
llmSecretRef: string | null
/** Configured LLM provider — selects which key inside the LLM Secret is exposed. */
provider: LlmProvider | null
- /** Assigned Codex grant; defaults to deployment-default. */
+ /** Assigned Codex grant. Empty/missing is unassigned and must not spend. */
connectionRef?: string | null
/**
* Name of the operator-managed LLM allowlist ConfigMap to watch (R3). When
@@ -561,7 +562,7 @@ export class ConfigStore {
}): boolean {
const nextBinding = parseCodexPolicyBinding(
cm.metadata?.annotations,
- this.opts.connectionRef?.trim() || 'deployment-default'
+ assignedConnectionRef(this.opts.connectionRef)
)
const modelsChanged = this.applyAllowlistData(cm.data ?? {}, nextBinding)
const bindingChanged = !codexBindingsEqual(this.codexBinding, nextBinding)
diff --git a/mcp-host/src/llm/hostLlmBinding.test.ts b/mcp-host/src/llm/hostLlmBinding.test.ts
index 98af2abf2..eb7c99e24 100644
--- a/mcp-host/src/llm/hostLlmBinding.test.ts
+++ b/mcp-host/src/llm/hostLlmBinding.test.ts
@@ -23,7 +23,7 @@ describe('hostPrimaryLlmBindingChanged', () => {
expect(change.connectionRefChanged).toBe(true)
})
- it('does not treat a Phase 1 missing ref as a change from deployment-default', () => {
+ it('treats a missing ref as unassigned, not as the reserved grant', () => {
const change = hostPrimaryLlmBindingChanged(
{
provider: 'codex-subscription',
@@ -36,7 +36,9 @@ describe('hostPrimaryLlmBindingChanged', () => {
connectionRef: 'deployment-default',
}
)
- expect(change.connectionRefChanged).toBe(false)
- expect(assignedConnectionRef(undefined)).toBe('deployment-default')
+ expect(change.connectionRefChanged).toBe(true)
+ expect(assignedConnectionRef(undefined)).toBe('unassigned')
+ expect(assignedConnectionRef('')).toBe('unassigned')
+ expect(assignedConnectionRef('deployment-default')).toBe('deployment-default')
})
})
diff --git a/mcp-host/src/llm/hostLlmBinding.ts b/mcp-host/src/llm/hostLlmBinding.ts
index ecc2148cc..291f699e0 100644
--- a/mcp-host/src/llm/hostLlmBinding.ts
+++ b/mcp-host/src/llm/hostLlmBinding.ts
@@ -5,8 +5,12 @@ export type HostPrimaryLlmBinding = {
secretRef?: string | null
}
+/** Fail-closed Host sentinel. Empty/missing is not the reserved grant. */
+export const CODEX_UNASSIGNED_CONNECTION_KEY = 'unassigned' as const
+
export function assignedConnectionRef(connectionRef?: string | null): string {
- return connectionRef?.trim() || 'deployment-default'
+ const trimmed = typeof connectionRef === 'string' ? connectionRef.trim() : ''
+ return trimmed || CODEX_UNASSIGNED_CONNECTION_KEY
}
export function hostPrimaryLlmBindingChanged(