Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(codex): gate execute on grantRedeemable and key WRC context by uid
Alfredo Lopeze67f4899afdb
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 9674fa520..f044f0c0b 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.296",+ "version": "0.1.297","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.296",+ "version": "0.1.297","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex ce39a7318..3f19863e6 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.296",+ "version": "0.1.297","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/workflow/__tests__/configureHandler.test.ts b/mcp-host/src/workflow/__tests__/configureHandler.test.tsindex 9a821dba3..83848ccb4 100644--- a/mcp-host/src/workflow/__tests__/configureHandler.test.ts+++ b/mcp-host/src/workflow/__tests__/configureHandler.test.ts@@ -128,10 +128,25 @@ describe('POST /configure — provider hot-swap', () => {configured: true,provider: 'codex-subscription',model: 'gpt-5.3-codex',+ identityBound: true,})+ expect(result.grantRedeemable).toBeUndefined()expect(factory).toHaveBeenLastCalledWith('codex-subscription', 'gpt-5.3-codex', '')})+ it('treats a 200 Codex configure as identity-bound, not execute-ready', () => {+ const svc = new WorkflowService('test', { llmFactory: mockLlmFactory() })+ const result = svc.configure({+ provider: 'codex-subscription',+ model: 'gpt-5.3-codex',+ } as ConfigureRequest)+ expect(result.configured).toBe(true)+ expect(result.identityBound).toBe(true)+ expect(result.grantRedeemable).not.toBe(true)+ expect(result).not.toHaveProperty('connectionRef')+ expect(result).not.toHaveProperty('apiKey')+ })+it('does not leave the prior provider ready when a Codex configure fails', () => {const factory = vi.fn()@@ -166,7 +181,9 @@ describe('POST /configure — provider hot-swap', () => {configured: true,provider: 'codex-subscription',model: 'gpt-5.3-codex',+ identityBound: true,})+ expect(result.grantRedeemable).toBeUndefined()expect(svc.isReady()).toBe(true)} finally {if (previous === undefined) delete process.env.MCP_HOST_CODEX_SUBSCRIPTION_ENABLEDdiff --git a/mcp-host/src/workflow/types.ts b/mcp-host/src/workflow/types.tsindex a1761baf6..89ed6501e 100644--- a/mcp-host/src/workflow/types.ts+++ b/mcp-host/src/workflow/types.ts@@ -103,6 +103,13 @@ export interface ConfigureRequest {export interface ConfigureResponse {configured: boolean+ /**+ * oauth-broker identity is bound in-process. This is not execute permission;+ * spend still requires a redeemable grant (WRC + authorize).+ */+ identityBound?: boolean+ /** Present only when WRC observes a live redeemable grant. mcp-host omits it. */+ grantRedeemable?: booleancapabilityFamily?: 'promptBridge' | 'clientNotifications'provider?: stringmodel?: stringdiff --git a/mcp-host/src/workflow/workflowService.ts b/mcp-host/src/workflow/workflowService.tsindex 31c79f42d..cd7590cf4 100644--- a/mcp-host/src/workflow/workflowService.ts+++ b/mcp-host/src/workflow/workflowService.ts@@ -655,7 +655,12 @@ export class WorkflowService {this.stepSoulContent = pendingSoulthis.soulOverrideActive = true}- return { configured: true, provider: req.provider, model }+ return {+ configured: true,+ provider: req.provider,+ model,+ ...oauthIdentityReadiness(req.provider),+ }}let provider: SingleTurnProvider | null@@ -688,7 +693,12 @@ export class WorkflowService {}this.notifyLlmConfigured(req.provider, model, apiKey)- return { configured: true, provider: req.provider, model }+ return {+ configured: true,+ provider: req.provider,+ model,+ ...oauthIdentityReadiness(req.provider),+ }}private clearConfiguredProvider(): void {@@ -1479,3 +1489,9 @@ function extractHttpStatus(err: unknown): number | undefined {const match = msg.match(/\b(4\d{2}|5\d{2})\b/)return match ? parseInt(match[1], 10) : undefined}++function oauthIdentityReadiness(provider: string): { identityBound: true } | Record<string, never> {+ return isLlmProvider(provider) && descriptorFor(provider).authMode === 'oauth-broker'+ ? { identityBound: true }+ : {}+}diff --git a/packages/workflow-runtime-core/src/injection/model.ts b/packages/workflow-runtime-core/src/injection/model.tsindex f27da64cc..3697f1ef9 100644--- a/packages/workflow-runtime-core/src/injection/model.ts+++ b/packages/workflow-runtime-core/src/injection/model.ts@@ -1,4 +1,4 @@-import type { LlmProviderId } from '@clerum/llm-providers'+import { PROVIDER_AUTH_MODE, isLlmProviderId, type LlmProviderId } from '@clerum/llm-providers'import type { RuntimeTokenProvider } from '../runtime-token-provider/provider'import { requireRuntimeToken } from '../runtime-token-provider/provider'import { sendWithAuthRetryOn401 } from '../status-reporter/authRetry'@@ -52,4 +52,20 @@ export async function requestModelInjection(emitLog('error', msg, { stepId: req.stepId })throw new Error(msg)}+ let payload: Record<string, unknown> = {}+ try {+ const parsed: unknown = await resp.json()+ if (parsed && typeof parsed === 'object') payload = parsed as Record<string, unknown>+ } catch {+ payload = {}+ }+ if (+ isLlmProviderId(req.provider) &&+ PROVIDER_AUTH_MODE[req.provider] === 'oauth-broker' &&+ payload.grantRedeemable !== true+ ) {+ const msg = 'Model injection refused: Codex grant is not redeemable'+ emitLog('error', msg, { stepId: req.stepId })+ throw new Error(msg)+ }}diff --git a/packages/workflow-runtime-core/tests/unit/injection.test.ts b/packages/workflow-runtime-core/tests/unit/injection.test.tsindex e07023b9e..d2da6caa9 100644--- a/packages/workflow-runtime-core/tests/unit/injection.test.ts+++ b/packages/workflow-runtime-core/tests/unit/injection.test.ts@@ -182,6 +182,66 @@ describe('requestModelInjection()', () => {expect(body.model).toBe('glm-4.7')})+ it('refuses a Codex step when grantRedeemable is absent even if WRC returned 2xx', async () => {+ const fetchMock = vi.fn().mockResolvedValue({+ ok: true,+ status: 202,+ json: async () => ({ configured: true, identityBound: true }),+ })+ vi.stubGlobal('fetch', fetchMock)+ await expect(+ requestModelInjection('http://wrc:8082', 'wf', provider(), {+ stepId: 's1',+ provider: 'codex-subscription',+ model: 'gpt-5.1',+ })+ ).rejects.toThrow('Codex grant is not redeemable')+ })++ it('executes an OpenAI step on 2xx even when grantRedeemable is absent', async () => {+ const fetchMock = vi.fn().mockResolvedValue({+ ok: true,+ status: 202,+ json: async () => ({ configured: true }),+ })+ vi.stubGlobal('fetch', fetchMock)+ await expect(+ requestModelInjection('http://wrc:8082', 'wf', provider(), {+ stepId: 's1',+ provider: 'openai',+ model: 'gpt-4',+ })+ ).resolves.toBeUndefined()+ })++ it('executes an Anthropic step on 2xx without a Codex readiness field', async () => {+ const fetchMock = vi.fn().mockResolvedValue({ ok: true, status: 202 })+ vi.stubGlobal('fetch', fetchMock)+ await expect(+ requestModelInjection('http://wrc:8082', 'wf', provider(), {+ stepId: 's1',+ provider: 'claude',+ model: 'claude-3',+ })+ ).resolves.toBeUndefined()+ })++ it('executes a Codex step only when WRC marks the grant redeemable', async () => {+ const fetchMock = vi.fn().mockResolvedValue({+ ok: true,+ status: 202,+ json: async () => ({ configured: true, identityBound: true, grantRedeemable: true }),+ })+ vi.stubGlobal('fetch', fetchMock)+ await expect(+ requestModelInjection('http://wrc:8082', 'wf', provider(), {+ stepId: 's1',+ provider: 'codex-subscription',+ model: 'gpt-5.1',+ })+ ).resolves.toBeUndefined()+ })+it('throws when WRC returns non-ok', async () => {vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: false, status: 500, statusText: 'ISE' }))await expect(diff --git a/scripts/tests/test-codex-subscription-t0.sh b/scripts/tests/test-codex-subscription-t0.shindex 23c30ee40..eb7365a61 100755--- a/scripts/tests/test-codex-subscription-t0.sh+++ b/scripts/tests/test-codex-subscription-t0.sh@@ -193,6 +193,7 @@ run_group "mcp-host" "mcp-host" \"src/config/configStore.test.ts" \"src/llm/failover/__tests__/engine.test.ts" \"src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.ts" \+ "src/workflow/__tests__/configureHandler.test.ts" \"src/workflow/__tests__/workflowServiceUsageReporting.test.ts" \"src/pluginWorkloadSdk/server/index.test.ts" \"src/core/adapters/__tests__/llmPortAdapter.test.ts"@@ -203,6 +204,9 @@ run_group "host-context-controller" "host-context-controller" \"src/llmAllowedModelsSnapshot.test.ts" \"src/networkPolicyReconciler.test.ts"+run_group "workflow-runtime-core" "packages/workflow-runtime-core" \+ "tests/unit/injection.test.ts"+run_group "workflow-recipes" "workflow-recipes" \"src/workflow/codexExecutionProjection.test.ts" \"src/workflow/workflowReconciler.codexScopeProvenance.test.ts" \diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex 5cb5c84f8..db25b8153 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.314",+ "version": "0.1.315","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.314",+ "version": "0.1.315","license": "SEE LICENSE IN LICENSE","dependencies": {"@aws-sdk/client-s3": "^3.1009.0",diff --git a/workflow-recipes/package.json b/workflow-recipes/package.jsonindex 2cf833dc4..e827edc73 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.314",+ "version": "0.1.315","description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface","main": "dist/main.js","engines": {diff --git a/workflow-recipes/src/reconciler/reconciler.test.ts b/workflow-recipes/src/reconciler/reconciler.test.tsindex cccd6fdc5..f17cc671f 100644--- a/workflow-recipes/src/reconciler/reconciler.test.ts+++ b/workflow-recipes/src/reconciler/reconciler.test.ts@@ -5885,7 +5885,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','child-run',recipe.spec,- 'parent-recipe'+ 'parent-recipe',+ 'uid-child')expect(mockVerifyWorkflowRunProvenance).toHaveBeenCalledWith({runId: 'run-child',@@ -6170,7 +6171,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','child-run',recipe.spec,- 'parent-recipe'+ 'parent-recipe',+ 'uid-child')})@@ -6214,7 +6216,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','child-run',recipe.spec,- 'child-run'+ 'child-run',+ 'uid-child')})@@ -6540,7 +6543,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','child-run',recipe.spec,- 'child-run'+ 'child-run',+ 'uid-child')})@@ -6592,7 +6596,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','child-run',recipe.spec,- 'child-run'+ 'child-run',+ 'uid-child')})@@ -6652,7 +6657,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','child-run',recipe.spec,- 'child-run'+ 'child-run',+ 'uid-child')})@@ -6692,7 +6698,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','child-run',recipe.spec,- 'child-run'+ 'child-run',+ 'uid-child')})@@ -6730,7 +6737,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','child-run',recipe.spec,- 'child-run'+ 'child-run',+ 'uid-child')})@@ -6768,6 +6776,7 @@ describe('WorkflowRecipeReconciler', () => {await reconciler.reconcile(recipe)expect(setCodexReconcileContext).toHaveBeenCalledWith({+ recipeUid: 'uid-child',recipeName: 'child-run',runtimeScopeRecipeName: 'child-run',claimedParent: true,@@ -6825,6 +6834,7 @@ describe('WorkflowRecipeReconciler', () => {await reconciler.reconcile(recipe)expect(setCodexReconcileContext).toHaveBeenCalledWith({+ recipeUid: 'uid-child',recipeName: 'child-run',runtimeScopeRecipeName: 'parent-recipe',claimedParent: true,@@ -6885,6 +6895,7 @@ describe('WorkflowRecipeReconciler', () => {await reconciler.reconcile(recipe)expect(setCodexReconcileContext).toHaveBeenCalledWith({+ recipeUid: 'uid-child',recipeName: 'child-run',runtimeScopeRecipeName: 'parent-recipe',claimedParent: true,@@ -7144,7 +7155,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','test-recipe',recipe.spec,- 'test-recipe'+ 'test-recipe',+ 'uid-123')})@@ -7193,7 +7205,8 @@ describe('WorkflowRecipeReconciler', () => {'sandbox-recipes','test-recipe',recipe.spec,- 'test-recipe'+ 'test-recipe',+ 'uid-123')})diff --git a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts b/workflow-recipes/src/reconciler/workflowRecipeReconciler.tsindex 9ac8bd92b..7a03f2770 100644--- a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts+++ b/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts@@ -1050,6 +1050,7 @@ export class WorkflowRecipeReconciler {? parent.annotations: recipe.metadata.annotationssetter.call(this.workflowReconciler, {+ recipeUid: recipe.metadata.uid,recipeName: recipe.metadata.name,runtimeScopeRecipeName,claimedParent: this.claimedCodexParent(recipe),@@ -1172,7 +1173,8 @@ export class WorkflowRecipeReconciler {recipe.metadata.namespace,recipe.metadata.name,recipe.spec,- runtimeScopeRecipeName+ runtimeScopeRecipeName,+ recipe.metadata.uid)} catch (error) {console.error(diff --git a/workflow-recipes/src/workflow/modelConfigHandler.ts b/workflow-recipes/src/workflow/modelConfigHandler.tsindex 45699db8c..302f58bac 100644--- a/workflow-recipes/src/workflow/modelConfigHandler.ts+++ b/workflow-recipes/src/workflow/modelConfigHandler.ts@@ -431,6 +431,7 @@ export class ModelConfigHandler {CONFIGMAP_NAMESPACE,ALLOWLIST_CONFIGMAP_NAME)+ const brokerBacked = PROVIDER_AUTH_MODE[req.provider] === 'oauth-broker'if (allowlistCm.exists) {const allowed = isCodexModelAllowed(req.provider,@@ -438,7 +439,9 @@ export class ModelConfigHandler {allowlistCm,opts?.codexConnectionKey)- if (!allowed) {+ // oauth-broker configure is identity-only. Spend is gated by+ // grantRedeemable on the coordinator and by authorize, not by 4xx here.+ if (!allowed && !brokerBacked) {return {status: 403,body: {@@ -462,7 +465,7 @@ export class ModelConfigHandler {// Broker-backed providers never resolve or mount a Secret. Control API// remains the OAuth custodian; WRC only forwards provider/model identity.- if (PROVIDER_AUTH_MODE[req.provider] === 'oauth-broker') {+ if (brokerBacked) {const configureBody: Record<string, unknown> = {provider: req.provider,model: req.model,@@ -498,7 +501,15 @@ export class ModelConfigHandler {}return {status: 202,- body: { configured: true, provider: req.provider, model: req.model },+ body: {+ configured: true,+ provider: req.provider,+ model: req.model,+ identityBound: true,+ grantRedeemable:+ allowlistCm.exists &&+ isCodexModelAllowed(req.provider, req.model, allowlistCm, opts?.codexConnectionKey),+ },}}diff --git a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.tsindex 6e585fcf1..2c52fe184 100644--- a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts+++ b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts@@ -86,7 +86,8 @@ export type PluginWorkloadSdkProvisionerDeps = {namespace: string,recipeName: string,runtimeScopeRecipeName: string,- spec: WorkflowRecipeSpec+ spec: WorkflowRecipeSpec,+ recipeUid?: string) => Promise<void>applyWorkflowNetworkPolicies: (recipeName: string,@@ -189,7 +190,13 @@ export class PluginWorkloadSdkProvisioner {return 'failed'}- await this.deps.ensureMcpHostSecrets(namespace, recipeName, runtimeScopeRecipeName, spec)+ await this.deps.ensureMcpHostSecrets(+ namespace,+ recipeName,+ runtimeScopeRecipeName,+ spec,+ recipeUid+ )await this.deps.applyWorkflowNetworkPolicies(recipeName,diff --git a/workflow-recipes/src/workflow/restEndpoints.ts b/workflow-recipes/src/workflow/restEndpoints.tsindex b3bafb6ba..fb892887d 100644--- a/workflow-recipes/src/workflow/restEndpoints.ts+++ b/workflow-recipes/src/workflow/restEndpoints.ts@@ -6,6 +6,7 @@ import {CODEX_CONNECTION_REF_ANNOTATION,assignedCodexConnectionKey,} from '@clerum/codex-catalog-projection'+import { PROVIDER_AUTH_MODE, isLlmProviderId } from '@clerum/llm-providers'import { loadConfig } from '../config'import type {GovernedTraceReporter,@@ -706,6 +707,21 @@ export function createWorkflowEndpointHandlers(wrcConfigureToken,handleOpts)+ if (+ isLlmProviderId(body.provider) &&+ PROVIDER_AUTH_MODE[body.provider] === 'oauth-broker' &&+ result.status >= 200 &&+ result.status < 300+ ) {+ return {+ status: result.status,+ body: {+ ...result.body,+ identityBound: result.body.identityBound === true,+ grantRedeemable: result.body.grantRedeemable === true,+ },+ }+ }return { status: result.status, body: result.body }}diff --git a/workflow-recipes/src/workflow/workflowReconciler.codexScopeProvenance.test.ts b/workflow-recipes/src/workflow/workflowReconciler.codexScopeProvenance.test.tsindex ac8d394cc..feb44b088 100644--- a/workflow-recipes/src/workflow/workflowReconciler.codexScopeProvenance.test.ts+++ b/workflow-recipes/src/workflow/workflowReconciler.codexScopeProvenance.test.ts@@ -1,5 +1,9 @@import { beforeEach, describe, expect, it, vi } from 'vitest'import type { WorkflowRecipeSpec } from '../types'+import {+ CODEX_CONNECTION_REF_ANNOTATION,+ readRecipeCodexConnectionRef,+} from './llmAllowedModelsSnapshot'import { issueMcpHostRuntimeTokens } from './mcpHostRuntimeTokenIssuerClient'import {type CodexReconcileContext,@@ -77,18 +81,45 @@ function makeCodexSpec(overrides?: Partial<WorkflowRecipeSpec>): WorkflowRecipeS}}+function recipeUidFor(recipeName: string): string {+ return `uid-${recipeName}`+}++function bindFromCr(+ reconciler: WorkflowReconciler,+ cr: {+ name: string+ uid?: string+ annotations?: Record<string, string>+ runtimeScopeRecipeName?: string+ claimedParent?: boolean+ parentSpec?: WorkflowRecipeSpec | null+ connectionKey?: string+ }+) {+ const recipeName = cr.name+ reconciler.setCodexReconcileContext({+ recipeUid: cr.uid ?? recipeUidFor(recipeName),+ recipeName,+ runtimeScopeRecipeName: cr.runtimeScopeRecipeName ?? recipeName,+ claimedParent: cr.claimedParent ?? false,+ parentSpec: cr.parentSpec ?? null,+ connectionKey: cr.connectionKey ?? readRecipeCodexConnectionRef(cr.annotations),+ })+}+function bindNamedGrant(reconciler: WorkflowReconciler,recipeName = 'codex-recipe',extras: Partial<CodexReconcileContext> = {}) {- reconciler.setCodexReconcileContext({- recipeName,- runtimeScopeRecipeName: extras.runtimeScopeRecipeName ?? recipeName,- claimedParent: extras.claimedParent ?? false,+ bindFromCr(reconciler, {+ name: recipeName,+ uid: extras.recipeUid,+ runtimeScopeRecipeName: extras.runtimeScopeRecipeName,+ claimedParent: extras.claimedParent,parentSpec: extras.parentSpec ?? null,connectionKey: extras.connectionKey ?? 'team-plus',- ...extras,})}@@ -224,9 +255,53 @@ describe('WorkflowReconciler Codex scope provenance', () => {})})+ it('issues derived Codex scope from a live CR annotation without bindNamedGrant', async () => {+ const { reconciler, networkingApi } = createHarness()+ bindFromCr(reconciler, {+ name: 'codex-recipe',+ annotations: { [CODEX_CONNECTION_REF_ANNOTATION]: 'team-plus' },+ })++ await reconcileRecipe(reconciler, makeCodexSpec())++ expect(issueMcpHostRuntimeTokens).toHaveBeenCalled()+ expect(issuedScopes()).toContain('llm:codex:execute')+ expect(proxyPolicyBodies(networkingApi)[0]).toBeDefined()+ })++ it('does not mint Codex when the live CR has no grant annotation', async () => {+ const { reconciler, networkingApi } = createHarness()+ bindFromCr(reconciler, { name: 'codex-recipe', annotations: {} })++ await reconcileRecipe(reconciler, makeCodexSpec())++ expect(issuedScopes()).not.toContain('llm:codex:execute')+ expect(proxyPolicyBodies(networkingApi)).toEqual([])+ })++ it('does not reuse a leftover setter after the recipe uid is recycled', async () => {+ const { reconciler, networkingApi } = createHarness()+ bindFromCr(reconciler, {+ name: 'codex-recipe',+ uid: 'uid-stale-name-reuse',+ annotations: { [CODEX_CONNECTION_REF_ANNOTATION]: 'team-plus' },+ })++ await reconcileRecipe(reconciler, makeCodexSpec())++ expect(issuedScopes()).not.toContain('llm:codex:execute')+ expect(proxyPolicyBodies(networkingApi)).toEqual([])+ reconciler.setCodexReconcileContext(null, 'uid-stale-name-reuse')+ await reconcileRecipe(reconciler, makeCodexSpec())+ expect(issuedScopes()).not.toContain('llm:codex:execute')+ })+it('issues derived Codex scope and proxy egress from the same reconcile projection', async () => {const { reconciler, networkingApi } = createHarness()- bindNamedGrant(reconciler)+ bindFromCr(reconciler, {+ name: 'codex-recipe',+ annotations: { [CODEX_CONNECTION_REF_ANNOTATION]: 'team-plus' },+ })await reconcileRecipe(reconciler, makeCodexSpec())diff --git a/workflow-recipes/src/workflow/workflowReconciler.ts b/workflow-recipes/src/workflow/workflowReconciler.tsindex 48edd7a1e..8825f9331 100644--- a/workflow-recipes/src/workflow/workflowReconciler.ts+++ b/workflow-recipes/src/workflow/workflowReconciler.ts@@ -354,6 +354,7 @@ const EFFECTIVE_WORKFLOW_CONTROL_SCOPE_ORDER: EffectiveWorkflowControlScope[] =]export type CodexReconcileContext = {+ recipeUid: stringrecipeName: stringruntimeScopeRecipeName: stringclaimedParent: boolean@@ -903,8 +904,8 @@ export class WorkflowReconciler {tokenFactory: deps.tokenFactory,modelConfigHandler: deps.modelConfigHandler,log: this.log,- ensureMcpHostSecrets: (namespace, recipeName, runtimeScopeRecipeName, spec) =>- this.ensureMcpHostSecrets(namespace, recipeName, runtimeScopeRecipeName, spec),+ ensureMcpHostSecrets: (namespace, recipeName, runtimeScopeRecipeName, spec, recipeUid) =>+ this.ensureMcpHostSecrets(namespace, recipeName, runtimeScopeRecipeName, spec, recipeUid),applyWorkflowNetworkPolicies: (recipeName,recipeUid,@@ -927,31 +928,39 @@ export class WorkflowReconciler {})}- setCodexReconcileContext(context: CodexReconcileContext | null): void {- if (!context) return- this.codexContexts.set(context.recipeName, context)+ setCodexReconcileContext(context: CodexReconcileContext | null, recipeUid?: string): void {+ if (!context) {+ const uid = recipeUid?.trim()+ if (uid) this.codexContexts.delete(uid)+ return+ }+ this.codexContexts.set(context.recipeUid, context)}private resolveCodexContext(+ recipeUid: string,recipeName: string,runtimeScopeRecipeName: string): CodexReconcileContext {- const stored = this.codexContexts.get(recipeName)+ const stored = this.codexContexts.get(recipeUid)if (stored) return storedreturn {+ recipeUid,recipeName,runtimeScopeRecipeName,claimedParent: false,parentSpec: null,+ connectionKey: CODEX_UNASSIGNED_CONNECTION_KEY,}}private projectCodex(spec: WorkflowRecipeSpec,+ recipeUid: string,recipeName: string,runtimeScopeRecipeName: string) {- const context = this.resolveCodexContext(recipeName, runtimeScopeRecipeName)+ const context = this.resolveCodexContext(recipeUid, recipeName, runtimeScopeRecipeName)const resolved = resolveCodexAuthoritativeSpec({recipeName: context.recipeName,runtimeScopeRecipeName: context.runtimeScopeRecipeName,@@ -978,6 +987,7 @@ export class WorkflowReconciler {private resolveEffectiveControlScopes(spec: WorkflowRecipeSpec,+ recipeUid: string,recipeName: string,runtimeScopeRecipeName: string): EffectiveWorkflowControlScope[] {@@ -986,6 +996,7 @@ export class WorkflowReconciler {})const derived = this.projectCodex(spec,+ recipeUid,recipeName,runtimeScopeRecipeName).derivedScopes.filter(scope => !workflow.includes(scope as WorkflowControlScope))@@ -1798,7 +1809,13 @@ export class WorkflowReconciler {}if (needsMcpHost && !awaitsTriggeredRun) {- await this.ensureMcpHostSecrets(namespace, recipeName, runtimeScopeRecipeName, spec)+ await this.ensureMcpHostSecrets(+ namespace,+ recipeName,+ runtimeScopeRecipeName,+ spec,+ recipeUid+ )}if (runtime.output.ensurePvc) {@@ -2589,7 +2606,8 @@ export class WorkflowReconciler {recipeNamespace: string,recipeName: string,spec: WorkflowRecipeSpec,- runtimeScopeRecipeName = recipeName+ runtimeScopeRecipeName = recipeName,+ recipeUid?: string): Promise<void> {const runtime = deriveWorkflowRuntimePlan(spec, {recipeName,@@ -2598,7 +2616,13 @@ export class WorkflowReconciler {})if (!runtime.mcpHost.required) returnawait this.refreshCodexSnapshot()- await this.ensureMcpHostSecrets(recipeNamespace, recipeName, runtimeScopeRecipeName, spec)+ await this.ensureMcpHostSecrets(+ recipeNamespace,+ recipeName,+ runtimeScopeRecipeName,+ spec,+ recipeUid+ )}async ensureCoordinatorRuntimeCredentials(@@ -2824,8 +2848,9 @@ export class WorkflowReconciler {const includeMcpHost = runtime.network.includeMcpHost && mcpHostLaneLiveconst codexProjection = this.projectCodex(spec,+ recipeUid,recipeName,- this.resolveCodexContext(recipeName, recipeName).runtimeScopeRecipeName+ this.resolveCodexContext(recipeUid, recipeName, recipeName).runtimeScopeRecipeName)const npConfig: NetworkPolicyConfig = {recipeName,@@ -2946,8 +2971,9 @@ export class WorkflowReconciler {const codexProxyPolicyName = `${recipeName}-mcp-host-to-codex-proxy`const codexProjection = this.projectCodex(spec,+ recipeUid,recipeName,- this.resolveCodexContext(recipeName, recipeName).runtimeScopeRecipeName+ this.resolveCodexContext(recipeUid, recipeName, recipeName).runtimeScopeRecipeName)if (!policyNames.has(codexProxyPolicyName) && codexProjection.eligibility !== 'uncertain') {await this.safeDelete(() =>@@ -3657,13 +3683,14 @@ export class WorkflowReconciler {namespace: string,recipeName: string,runtimeScopeRecipeName: string,- spec: WorkflowRecipeSpec+ spec: WorkflowRecipeSpec,+ recipeUid?: string): Promise<void> {await this.ensureMcpHostRuntimeTokenSecret(namespace,recipeName,runtimeScopeRecipeName,- this.resolveEffectiveControlScopes(spec, recipeName, runtimeScopeRecipeName),+ this.resolveEffectiveControlScopes(spec, recipeUid ?? '', recipeName, runtimeScopeRecipeName),deriveRecipeHostGfsScopes(spec))if (this.deps.config.pluginWorkloadSdkEnabled && spec.pluginWorkloadSdk) {diff --git a/workflow-recipes/tests/unit/workflow/modelConfigHandler.test.ts b/workflow-recipes/tests/unit/workflow/modelConfigHandler.test.tsindex 0192dafa7..9d853165b 100644--- a/workflow-recipes/tests/unit/workflow/modelConfigHandler.test.ts+++ b/workflow-recipes/tests/unit/workflow/modelConfigHandler.test.ts@@ -457,6 +457,8 @@ describe('POST /configure-model — R3 allowlist gate', () => {configured: true,provider: 'codex-subscription',model: 'gpt-5.3-codex',+ identityBound: true,+ grantRedeemable: true,})expect(k8s.readSecret).not.toHaveBeenCalled()expect(mcpHost.configure).toHaveBeenCalledWith('http://mcp:8080', 'tok', {@@ -728,8 +730,9 @@ describe('POST /configure-model — security invariants', () => {'tok',{ codexConnectionKey: 'personal-pro' })- expect(denied.status).toBe(403)- expect(denied.body.code).toBe('model_not_allowed')+ expect(denied.status).toBe(202)+ expect(denied.body.identityBound).toBe(true)+ expect(denied.body.grantRedeemable).toBe(false)const allowed = await handler.handle({ stepId: 's1', provider: 'codex-subscription', model: 'gpt-5.1' },@@ -739,6 +742,7 @@ describe('POST /configure-model — security invariants', () => {)expect(allowed.status).toBe(202)expect(allowed.body.configured).toBe(true)+ expect(allowed.body.grantRedeemable).toBe(true)})it('does not let an unassigned recipe inherit the flat Codex catalog', async () => {@@ -747,12 +751,14 @@ describe('POST /configure-model — security invariants', () => {}const k8s = mockK8s({}, null, allowlist)const handler = new ModelConfigHandler(k8s, mockMcpHost())- const denied = await handler.handle(+ const identityOnly = await handler.handle({ stepId: 's1', provider: 'codex-subscription', model: 'gpt-5.3-codex' },'http://mcp:8080','tok')- expect(denied.status).toBe(403)- expect(denied.body.code).toBe('model_not_allowed')+ expect(identityOnly.status).toBe(202)+ expect(identityOnly.body.configured).toBe(true)+ expect(identityOnly.body.identityBound).toBe(true)+ expect(identityOnly.body.grantRedeemable).toBe(false)})})