Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(codex): close jozer seams on factory, leftover spend, and live-row getSafe
Alfredo Lopezc2b0d63b55d9
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex 53ec2ad80..e32dc2841 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.513",+ "version": "0.1.514","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.513",+ "version": "0.1.514","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.jsonindex eeb81d295..0454b18e2 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.513",+ "version": "0.1.514","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/mcp-host/llmProviderAttempts.routes.ts b/control-api/src/routes/mcp-host/llmProviderAttempts.routes.tsindex ac655008d..e8f949828 100644--- a/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts+++ b/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts@@ -6,6 +6,7 @@ import { requireMcpHostJwt } from '../../middleware/mcpHostJwtAuth.js'import { rootLogger } from '../../observability/logger.js'import {CODEX_CONNECTION_REF_ANNOTATION,+ CODEX_UNASSIGNED_CONNECTION_KEY,readHostCodexConnectionRef,} from '../../services/codexSubscriptionConnection.js'import {@@ -33,6 +34,11 @@ const ERROR_STATUS: Record<string, number> = {provider_unavailable: 503,}+function recipeHasPluginWorkloadSdk(spec?: Record<string, unknown>): boolean {+ const sdk = spec?.pluginWorkloadSdk+ return Boolean(sdk && typeof sdk === 'object' && !Array.isArray(sdk))+}+function sendAuthorizeError(res: Response, err: unknown): void {if (err instanceof LlmProviderAttemptAuthorizeError) {const status = ERROR_STATUS[err.code] ?? 400@@ -67,7 +73,7 @@ export async function resolveHostAssignedConnectionKey('workflowrecipes',recipeName,recipeNamespace- )) as { metadata?: { annotations?: Record<string, string> } }+ )) as { metadata?: { annotations?: Record<string, string> }; spec?: Record<string, unknown> }const annotated = readHostCodexConnectionRef(recipe?.metadata?.annotations?.[CODEX_CONNECTION_REF_ANNOTATION])@@ -79,6 +85,18 @@ export async function resolveHostAssignedConnectionKey(.filter(Boolean)),]+ // Recipes-only keep the annotation when grantRefs is empty. An SDK+ // recipe with a leftover named annotation and no grant must not spend.+ if (+ recipeHasPluginWorkloadSdk(recipe.spec) &&+ grantRefs.length === 0 &&+ annotated !== CODEX_UNASSIGNED_CONNECTION_KEY+ ) {+ throw new LlmProviderAttemptAuthorizeError(+ 'host_binding_mismatch',+ 'SDK grant connectionRef does not match the recipe annotation'+ )+ }if (grantRefs.length > 1 || (grantRefs.length === 1 && grantRefs[0] !== annotated)) {throw new LlmProviderAttemptAuthorizeError('host_binding_mismatch',diff --git a/control-api/src/services/codexSubscriptionConnection.ts b/control-api/src/services/codexSubscriptionConnection.tsindex 4dc59368c..610cf9019 100644--- a/control-api/src/services/codexSubscriptionConnection.ts+++ b/control-api/src/services/codexSubscriptionConnection.ts@@ -280,7 +280,8 @@ export async function getSafeCodexSubscriptionConnection(const result = await db.query(`SELECT ${SAFE_CONNECTION_COLUMNS}FROM codex_subscription_connections- WHERE connection_key = $1`,+ WHERE connection_key = $1+ AND revoked_at IS NULL`,[normalizeCodexConnectionKey(connectionKey)])const row = result.rows[0] as SafeConnectionRow | undefineddiff --git a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts b/control-api/test/routes.mcp-host.llmProviderAttempts.test.tsindex b350be05f..2087cf60b 100644--- a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts+++ b/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts@@ -267,4 +267,32 @@ describe('resolveHostAssignedConnectionKey', () => {})).resolves.toBe('team-plus')})++ it('keeps a recipes-only annotation when grant listing is empty', async () => {+ const gateway = {+ getResource: vi.fn().mockResolvedValue({+ metadata: { annotations: { 'clerum.io/codex-connection-ref': 'team-plus' } },+ spec: { agent: { provider: 'codex-subscription', model: 'gpt-5.3-codex' } },+ }),+ }+ await expect(+ resolveHostAssignedConnectionKey(gateway, 'sandbox-recipes/codex-recipe', {+ listSdkCodexConnectionRefs: async () => [],+ })+ ).resolves.toBe('team-plus')+ })++ it('fails closed when an SDK recipe has a leftover annotation and no grant', async () => {+ const gateway = {+ getResource: vi.fn().mockResolvedValue({+ metadata: { annotations: { 'clerum.io/codex-connection-ref': 'team-plus' } },+ spec: { pluginWorkloadSdk: { family: 'promptBridge' } },+ }),+ }+ await expect(+ resolveHostAssignedConnectionKey(gateway, 'sandbox-recipes/codex-recipe', {+ listSdkCodexConnectionRefs: async () => [],+ })+ ).rejects.toMatchObject({ code: 'host_binding_mismatch' })+ })})diff --git a/control-api/test/services.codexSubscriptionConnection.test.ts b/control-api/test/services.codexSubscriptionConnection.test.tsindex fe64fe255..1a8e292a4 100644--- a/control-api/test/services.codexSubscriptionConnection.test.ts+++ b/control-api/test/services.codexSubscriptionConnection.test.ts@@ -75,6 +75,14 @@ describe('codex subscription connection repository', () => {expect(metadata).not.toHaveProperty('accessTokenEncrypted')expect(metadata).not.toHaveProperty('refreshToken')expect(metadata).not.toHaveProperty('accessToken')+ expect(String(query.mock.calls[0]?.[0])).toContain('revoked_at IS NULL')+ })++ it('does not return a revoked tombstone when looking up a reusable connection key', async () => {+ query.mockResolvedValueOnce({ rows: [], rowCount: 0 })+ await expect(getSafeCodexSubscriptionConnection({ query }, 'team-plus')).resolves.toBeNull()+ expect(String(query.mock.calls[0]?.[0])).toContain('revoked_at IS NULL')+ expect(String(query.mock.calls[0]?.[0])).toContain('connection_key = $1')})it('inserts encrypted credentials and never binds plaintext tokens', async () => {diff --git a/control-ui/app/plugin-workload-sdk/page.tsx b/control-ui/app/plugin-workload-sdk/page.tsxindex 43f18516e..114e0b684 100644--- a/control-ui/app/plugin-workload-sdk/page.tsx+++ b/control-ui/app/plugin-workload-sdk/page.tsx@@ -35,6 +35,7 @@ import {listCodexConnectionModels,listCodexSubscriptionConnections,} from '@lib/codexSubscription'+import { isDisabledCapabilityError } from '@lib/codexSubscriptionFeature'import { useLlmAllowedModels } from '@lib/hooks/useLlmAllowedModels'import {LLM_PROVIDER_OPTIONS,@@ -537,10 +538,12 @@ function GrantFormModal({if (cancelled) returnsetCodexConnections(connections.filter(isAssignableCodexGrant))})- .catch(() => {- // Fail closed: without a readable connection list no Codex target can- // be added; the save endpoint stays the source of truth.- if (!cancelled) setCodexConnections([])+ .catch(err => {+ if (cancelled) return+ setCodexConnections([])+ if (!isDisabledCapabilityError(err)) {+ setError(err instanceof Error ? err.message : 'Could not load ChatGPT subscriptions')+ }})return () => {cancelled = truediff --git a/control-ui/components/RecipeEditor.tsx b/control-ui/components/RecipeEditor.tsxindex 1ed943690..a1f5a1205 100644--- a/control-ui/components/RecipeEditor.tsx+++ b/control-ui/components/RecipeEditor.tsx@@ -30,6 +30,7 @@ import {isAssignableCodexGrant,listCodexSubscriptionConnections,} from '../lib/codexSubscription'+import { isDisabledCapabilityError } from '../lib/codexSubscriptionFeature'import { analyzeWorkflowRecipeEgress } from '../lib/egressModel'import type { EgressBinding, EgressEditorStatus } from '../lib/egressModel'import { OPENAI_SUBSCRIPTION_PROVIDER, brokerBackedRecipeAuthoringError } from '../lib/llm'@@ -1585,10 +1586,22 @@ export function RecipeEditor({ initial, onSaved, onCancel, pageHeader }: Props)let cancelled = falsevoid listCodexSubscriptionConnections().then(rows => {- if (!cancelled) setCodexConnections(rows)+ if (!cancelled) {+ setCodexConnections(rows)+ setCodexGrantLoadError('')+ }})- .catch(() => {- if (!cancelled) setCodexConnections([])+ .catch(err => {+ if (!cancelled) {+ setCodexConnections([])+ if (!isDisabledCapabilityError(err)) {+ setCodexGrantLoadError(+ err instanceof Error ? err.message : 'Could not load ChatGPT subscriptions'+ )+ } else {+ setCodexGrantLoadError('')+ }+ }})return () => {cancelled = true@@ -1614,6 +1627,7 @@ export function RecipeEditor({ initial, onSaved, onCancel, pageHeader }: Props)return EXAMPLE_JSON})const [codexConnections, setCodexConnections] = useState<CodexSubscriptionConnectionView[]>([])+ const [codexGrantLoadError, setCodexGrantLoadError] = useState('')const [codexConnectionRef, setCodexConnectionRef] = useState(() =>readRecipeCodexGrantAnnotation(initial))@@ -2541,6 +2555,11 @@ export function RecipeEditor({ initial, onSaved, onCancel, pageHeader }: Props)options={codexGrantOptions}placeholder="Choose a ChatGPT grant"/>+ {codexGrantLoadError ? (+ <div className="cu-banner cu-banner--error" role="alert" style={{ marginTop: 10 }}>+ {codexGrantLoadError}+ </div>+ ) : null}</div>) : null}diff --git a/control-ui/components/__tests__/RecipeEditor.test.tsx b/control-ui/components/__tests__/RecipeEditor.test.tsxindex 778a87b48..898cde097 100644--- a/control-ui/components/__tests__/RecipeEditor.test.tsx+++ b/control-ui/components/__tests__/RecipeEditor.test.tsx@@ -4,6 +4,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'import { cleanup, fireEvent, render as rtlRender, screen, waitFor } from '@testing-library/react'import * as api from '../../lib/api'import type { WorkflowRecipeResource } from '../../lib/api'+import { listCodexSubscriptionConnections } from '../../lib/codexSubscription'import { validateRecipe } from '../../lib/recipeValidator'import { RecipeEditor } from '../RecipeEditor'import { ToastProvider } from '../Toast'@@ -1710,6 +1711,32 @@ describe('RecipeEditor — grants in editor', () => {expect(screen.getByText(/could not be saved/)).toBeInTheDocument()})+ it('surfaces a non-disabled ChatGPT grant list failure', async () => {+ vi.mocked(listCodexSubscriptionConnections).mockRejectedValueOnce(+ Object.assign(new Error('Could not load ChatGPT subscriptions'), { status: 500 })+ )+ render(<RecipeEditor onSaved={vi.fn()} onCancel={vi.fn()} />)+ fireEvent.change(screen.getByRole('combobox'), {+ target: { value: 'Agentic Workflow (Codex Subscription)' },+ })+ reviewAndProceedToDeploy()+ expect(await screen.findByText('Could not load ChatGPT subscriptions')).toBeInTheDocument()+ })++ it('does not surface a grant-list error when ChatGPT subscriptions are disabled', async () => {+ vi.mocked(listCodexSubscriptionConnections).mockRejectedValueOnce(+ Object.assign(new Error('disabled'), { status: 404, code: 'disabled' })+ )+ render(<RecipeEditor onSaved={vi.fn()} onCancel={vi.fn()} />)+ fireEvent.change(screen.getByRole('combobox'), {+ target: { value: 'Agentic Workflow (Codex Subscription)' },+ })+ reviewAndProceedToDeploy()+ await screen.findByTestId('codex-recipe-grant')+ expect(screen.queryByText('Could not load ChatGPT subscriptions')).not.toBeInTheDocument()+ expect(screen.queryByText('disabled')).not.toBeInTheDocument()+ })+it('deploys a Codex-only recipe without an LLM secretRef', async () => {const onSaved = vi.fn()render(<RecipeEditor onSaved={onSaved} onCancel={vi.fn()} />)diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 364ead2b7..8d1df5173 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.473",+ "version": "0.1.474","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.473",+ "version": "0.1.474","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.jsonindex 9e778dced..b9587d5ad 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.473",+ "version": "0.1.474","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 64b419081..4a7a1abf2 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.260",+ "version": "0.1.261","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.260",+ "version": "0.1.261","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.jsonindex 95556c9a5..c880b3031 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.260",+ "version": "0.1.261","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/hostReconciler.codexScopeProvenance.test.ts b/host-context-controller/src/hostReconciler.codexScopeProvenance.test.tsindex f2bb44de9..fde11b049 100644--- a/host-context-controller/src/hostReconciler.codexScopeProvenance.test.ts+++ b/host-context-controller/src/hostReconciler.codexScopeProvenance.test.ts@@ -276,6 +276,26 @@ describe('HostReconciler Codex scope provenance', () => {expect(proxyPolicyBodies(networkingApi)).toEqual([])})+ it('keeps the runtime scope hash when only connectionRevision changes', async () => {+ const { reconciler, coreApi } = createReconciler()+ wireAllowlist(coreApi, eligibleCodexConfigMap())+ await reconciler.reconcile(makeCodexHost())+ const firstHash = scopeHashFromSecretWrites(coreApi).at(-1)+ expect(firstHash).toBeTruthy()++ const bumped = eligibleCodexConfigMap()+ bumped.metadata.annotations['clerum.io/connection-revision'] = '2'+ const map = JSON.parse(bumped.metadata.annotations['clerum.io/codex-connections']) as Record<+ string,+ { connectionRevision: number }+ >+ map['deployment-default'].connectionRevision = 2+ bumped.metadata.annotations['clerum.io/codex-connections'] = JSON.stringify(map)+ wireAllowlist(coreApi, bumped)+ await reconciler.reconcile(makeCodexHost())+ expect(scopeHashFromSecretWrites(coreApi).at(-1)).toBe(firstHash)+ })+it('keeps a Host on a live grant eligible when another assigned grant is revoked', async () => {const { reconciler, coreApi, networkingApi } = createReconciler()wireAllowlist(coreApi, eligibleCodexConfigMap())diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 4ded691e4..d1e8a65ee 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.293",+ "version": "0.1.294","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.293",+ "version": "0.1.294","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex d79f3f060..c41892d9d 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.293",+ "version": "0.1.294","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.tsindex 2ecb98952..799203fea 100644--- a/mcp-host/src/config/configStore.test.ts+++ b/mcp-host/src/config/configStore.test.ts@@ -918,6 +918,34 @@ describe('ConfigStore — allowlist tier (R3)', () => {])})+ it('keeps the legacy flat catalog for a named grant when the ConfigMap has no connections map', async () => {+ const built = build({+ provider: 'codex-subscription',+ connectionRef: 'personal-pro',+ secrets: { 'chatllm-api-keys': { 'openai-api-key': 'sk' } },+ allowlistConfigMapName: ALLOWLIST_CM,+ configMaps: {+ [ALLOWLIST_CM]: {+ 'codex-subscription': JSON.stringify([{ model: 'gpt-5.3-codex' }, { model: 'gpt-5.1' }]),+ },+ },+ configMapAnnotations: {+ [ALLOWLIST_CM]: {+ 'clerum.io/catalog-revision': '4',+ 'clerum.io/connection-revision': '2',+ },+ },+ })+ store = built.store+ await store.start()+ expect(store.codexPolicyBinding()?.connectionKey).toBe('personal-pro')+ expect(store.codexPolicyBinding()?.models).toBeUndefined()+ expect(store.allowedModels().get('codex-subscription')).toEqual([+ { model: 'gpt-5.3-codex' },+ { model: 'gpt-5.1' },+ ])+ })+it('does not inherit the reserved-grant union when a map entry omits models[]', async () => {const built = build({provider: 'codex-subscription',diff --git a/mcp-host/src/config/configStore.ts b/mcp-host/src/config/configStore.tsindex 3d1d3cc02..1bbb8ede0 100644--- a/mcp-host/src/config/configStore.ts+++ b/mcp-host/src/config/configStore.ts@@ -972,7 +972,9 @@ function parseCodexPolicyBinding(return null}}- if (connectionKey !== 'deployment-default') return null+ // No connections map: keep the flat catalog for any assigned grant (legacy+ // single-grant). Do not invent deployment-default for unassigned — that+ // already returned null above. Named keys must match HCC/WRC.if (catalogRevision === null ||catalogRevision === 'invalid' ||diff --git a/mcp-host/src/workflow/__tests__/configureHandler.test.ts b/mcp-host/src/workflow/__tests__/configureHandler.test.tsindex 8a89cf97e..9a821dba3 100644--- a/mcp-host/src/workflow/__tests__/configureHandler.test.ts+++ b/mcp-host/src/workflow/__tests__/configureHandler.test.ts@@ -131,6 +131,48 @@ describe('POST /configure — provider hot-swap', () => {})expect(factory).toHaveBeenLastCalledWith('codex-subscription', 'gpt-5.3-codex', '')})++ it('does not leave the prior provider ready when a Codex configure fails', () => {+ const factory = vi+ .fn()+ .mockImplementationOnce(mockLlmFactory())+ .mockImplementationOnce(() => {+ throw new Error('static slot')+ })+ const svc = new WorkflowService('test', { llmFactory: factory })+ expect(svc.configure({ provider: 'openai', model: 'gpt-4', apiKey: 'sk-123' }).configured).toBe(+ true+ )+ const result = svc.configure({+ provider: 'codex-subscription',+ model: 'gpt-5.3-codex',+ soulContent: 'must not stick on a failed bind',+ } as ConfigureRequest)+ expect(result.configured).toBe(false)+ expect(svc.isReady()).toBe(false)+ expect(svc.isSoulOverrideActive()).toBe(false)+ })++ it('constructs keyless Codex through the default factory without throwing on primarySlot', () => {+ const previous = process.env.MCP_HOST_CODEX_SUBSCRIPTION_ENABLED+ process.env.MCP_HOST_CODEX_SUBSCRIPTION_ENABLED = 'true'+ try {+ const svc = new WorkflowService('test')+ const result = svc.configure({+ provider: 'codex-subscription',+ model: 'gpt-5.3-codex',+ } as ConfigureRequest)+ expect(result).toEqual({+ configured: true,+ provider: 'codex-subscription',+ model: 'gpt-5.3-codex',+ })+ expect(svc.isReady()).toBe(true)+ } finally {+ if (previous === undefined) delete process.env.MCP_HOST_CODEX_SUBSCRIPTION_ENABLED+ else process.env.MCP_HOST_CODEX_SUBSCRIPTION_ENABLED = previous+ }+ })})describe('POST /configure — SOUL override', () => {diff --git a/mcp-host/src/workflow/__tests__/workflowServiceUsageReporting.test.ts b/mcp-host/src/workflow/__tests__/workflowServiceUsageReporting.test.tsindex e38bcfd9a..ea79de0ac 100644--- a/mcp-host/src/workflow/__tests__/workflowServiceUsageReporting.test.ts+++ b/mcp-host/src/workflow/__tests__/workflowServiceUsageReporting.test.ts@@ -3,6 +3,7 @@ import { LlmErrorCode } from '../../core/errors'import type { SingleTurnProvider } from '../../llm'import type { LlmUsageEvent, UsageReporter } from '../../usage/usageReporter'import type { McpClientConnection, McpClientFactory } from '../stepRouter'+import type { ConfigureRequest } from '../types'import type { McpHostRuntimeAuth } from '../userApprovalRequester'import { WorkflowService } from '../workflowService'@@ -275,6 +276,35 @@ describe('WorkflowService — UsageReporter integration', () => {expect(enqueued).toHaveLength(0)})+ it('reports Codex workflow usage without an llmSecretName', async () => {+ const llm = mockLlmProvider([{ content: 'final answer', tool_calls: null }])+ llm.getProviderType = () => 'codex-subscription'+ const { reporter, enqueued } = makeReporter()+ const svc = new WorkflowService('my-recipe-12345', {+ llmFactory: () => llm,+ mcpClientFactory: mockMcpFactory(),+ usageReporter: reporter,+ runtimeAuth: mockRuntimeAuth('my-recipe'),+ })+ const configured = svc.configure({+ provider: 'codex-subscription',+ model: 'gpt-5.3-codex',+ } as ConfigureRequest)+ expect(configured.configured).toBe(true)+ const res = await svc.executeStep({+ stepId: 's1',+ instruction: 'hello',+ contextVars: { workflowExecutionId, workflowTeamId, workflowUserId },+ })+ expect(res.status).toBe('completed')+ expect(enqueued).toHaveLength(1)+ expect(enqueued[0]).toMatchObject({+ provider: 'codex-subscription',+ model: 'gpt-5.3-codex',+ llm_secret_name: null,+ })+ })+it('does NOT enqueue when no reporter is wired (workflow mode without ingest)', async () => {const llm = mockLlmProvider([{ content: 'ok', tool_calls: null }])const svc = new WorkflowService('rec', {diff --git a/mcp-host/src/workflow/workflowService.ts b/mcp-host/src/workflow/workflowService.tsindex 8076479b6..ab2fc650a 100644--- a/mcp-host/src/workflow/workflowService.ts+++ b/mcp-host/src/workflow/workflowService.ts@@ -59,6 +59,13 @@ function monoCredentialBag(provider: LlmProvider, apiKey: string): ApiKeys {return { [provider]: { [primarySlot(descriptorFor(provider)).dataKey]: apiKey } }}+function credentialBagForProvider(provider: LlmProvider, apiKey: string): ApiKeys {+ // oauth-broker has no static slot. primarySlot → requireStaticCredentialSlot+ // throws; a keyless Codex configure must not take that path.+ if (descriptorFor(provider).authMode === 'oauth-broker') return {}+ return monoCredentialBag(provider, apiKey)+}+const MAX_SOUL_BYTES = 64 * 1024 // 64KBconst DEFAULT_TIMEOUT_SECONDS = 300const MAX_WORKFLOW_OUTPUT_TOKENS_CEILING = 65_536@@ -167,7 +174,7 @@ function defaultLlmFactory(): SingleTurnProvider | null {// The provider id IS the ApiKeys record key; validate before indexing.if (!isLlmProvider(provider)) return null- const keys = monoCredentialBag(provider, apiKey)+ const keys = credentialBagForProvider(provider, apiKey)const modelConfig: import('../types').ModelConfig = {provider: provider as import('../types').ModelConfig['provider'],name: model,@@ -364,7 +371,7 @@ export class WorkflowService {// The provider id IS the ApiKeys record key; validate before indexing.if (!isLlmProvider(provider)) returnthis.onLlmConfigured({- keys: monoCredentialBag(provider, apiKey),+ keys: credentialBagForProvider(provider, apiKey),provider: provider as import('../types').ModelConfig['provider'],defaultModel: model,})@@ -618,16 +625,15 @@ export class WorkflowService {return { configured: false, message: 'model is required' }}- // SOUL override+ let pendingSoul: string | undefinedif (req.soulContent !== undefined) {if (Buffer.byteLength(req.soulContent, 'utf-8') > MAX_SOUL_BYTES) {return { configured: false, message: 'soulContent exceeds 64KB limit' }}- this.stepSoulContent = req.soulContent- this.soulOverrideActive = true+ pendingSoul = req.soulContent}- const model = req.model ?? 'default'+ const model = brokerBacked ? (req.model ?? '').trim() : (req.model ?? 'default')const apiKey = brokerBacked ? '' : (req.apiKey ?? '')const llmSecretName = WorkflowService.normalizeLlmSecretName(req.llmSecretName)if (req.llmSecretName !== undefined && llmSecretName === null) {@@ -644,11 +650,22 @@ export class WorkflowService {this.configured) {this.currentLlmSecretName = llmSecretName+ if (pendingSoul !== undefined) {+ this.stepSoulContent = pendingSoul+ this.soulOverrideActive = true+ }return { configured: true, provider: req.provider, model }}- const provider = this.llmFactory(req.provider, model, apiKey)+ let provider: SingleTurnProvider | null+ try {+ provider = this.llmFactory(req.provider, model, apiKey)+ } catch {+ this.clearConfiguredProvider()+ return { configured: false, message: `Failed to create provider: ${req.provider}` }+ }if (!provider) {+ this.clearConfiguredProvider()return { configured: false, message: `Failed to create provider: ${req.provider}` }}@@ -664,11 +681,24 @@ export class WorkflowService {this.currentApiKey = apiKeythis.currentLlmSecretName = llmSecretNamethis.configured = true+ if (pendingSoul !== undefined) {+ this.stepSoulContent = pendingSoul+ this.soulOverrideActive = true+ }this.notifyLlmConfigured(req.provider, model, apiKey)return { configured: true, provider: req.provider, model }}+ private clearConfiguredProvider(): void {+ this.currentProvider = null+ this.currentProviderName = null+ this.currentModel = null+ this.currentApiKey = ''+ this.currentLlmSecretName = null+ this.configured = false+ }+/*** Wrap `primary` with {@link FailoverSingleTurnProvider} when `rawPolicy`* parses to at least one usable, resolved fallback; otherwise return `primary`@@ -858,7 +888,11 @@ export class WorkflowService {durationMs: Date.now() - startTime,}}- if (usageReportingEnabled && !this.currentLlmSecretName) {+ const brokerUsage =+ Boolean(this.currentProviderName) &&+ isLlmProvider(this.currentProviderName) &&+ descriptorFor(this.currentProviderName).authMode === 'oauth-broker'+ if (usageReportingEnabled && !this.currentLlmSecretName && !brokerUsage) {clearTimeout(timeout)return {stepId: req.stepId,diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex 55ecd6f83..534f9a340 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.312",+ "version": "0.1.313","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.312",+ "version": "0.1.313","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 d76e25cc4..8c4307ca8 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.312",+ "version": "0.1.313","description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface","main": "dist/main.js","engines": {diff --git a/workflow-recipes/src/workflow/podFactory.ts b/workflow-recipes/src/workflow/podFactory.tsindex 7a688fb9d..07d6401ca 100644--- a/workflow-recipes/src/workflow/podFactory.ts+++ b/workflow-recipes/src/workflow/podFactory.ts@@ -745,6 +745,14 @@ export function buildMcpHostPod(name: 'MCP_HOST_GATEWAY_URL',value: 'http://nginx-workflow-approval-gateway.control-plane.svc.cluster.local:8092',},+ // Recipe pods do not mount the Host mcp-host-config ConfigMap.+ // WRC keyless-configures oauth-broker against this process, so the+ // Codex factory kill-switch and proxy URL must be on the pod.+ { name: 'MCP_HOST_CODEX_SUBSCRIPTION_ENABLED', value: 'true' },+ {+ name: 'CODEX_LLM_PROXY_RUNTIME_URL',+ value: 'http://codex-llm-proxy.control-plane.svc.cluster.local:8080',+ },// PromptBridge resolves exactly one signed target credential per// attempt through WRC. Notification-only hosts are provider-free// and deliberately receive no broker URL.diff --git a/workflow-recipes/src/workflow/workflowReconciler.codexScopeProvenance.test.ts b/workflow-recipes/src/workflow/workflowReconciler.codexScopeProvenance.test.tsindex c7fe49600..ac8d394cc 100644--- a/workflow-recipes/src/workflow/workflowReconciler.codexScopeProvenance.test.ts+++ b/workflow-recipes/src/workflow/workflowReconciler.codexScopeProvenance.test.ts@@ -357,6 +357,47 @@ describe('WorkflowReconciler Codex scope provenance', () => {expect(createdPolicyNames).toContain('child-run-mcp-host-to-codex-proxy')})+ it('keeps recipe A parent grant after recipe B binds on the same reconciler', async () => {+ const { reconciler } = createHarness()+ bindNamedGrant(reconciler, 'child-a', {+ runtimeScopeRecipeName: 'parent-a',+ claimedParent: true,+ parentSpec: makeCodexSpec(),+ connectionKey: 'team-plus',+ })+ bindNamedGrant(reconciler, 'child-b', {+ runtimeScopeRecipeName: 'parent-b',+ claimedParent: true,+ parentSpec: makeCodexSpec(),+ connectionKey: 'personal-pro',+ })++ await reconcileRecipe(+ reconciler,+ makeCodexSpec({ agent: { provider: 'openai', model: 'gpt-5.4-mini' } }),+ 'child-a',+ 'parent-a'+ )+ expect(issuedScopes()).toContain('llm:codex:execute')++ await reconcileRecipe(+ reconciler,+ makeCodexSpec({ agent: { provider: 'openai', model: 'gpt-5.4-mini' } }),+ 'child-b',+ 'parent-b'+ )+ expect(issuedScopes()).toContain('llm:codex:execute')++ runtimeTokenIssuerMocks.issueMcpHostRuntimeTokens.mockClear()+ await reconcileRecipe(+ reconciler,+ makeCodexSpec({ agent: { provider: 'openai', model: 'gpt-5.4-mini' } }),+ 'child-a',+ 'parent-a'+ )+ expect(issuedScopes()).toContain('llm:codex:execute')+ })+it('does not mint Codex when a claimed parent fails provenance', async () => {const { reconciler, networkingApi } = createHarness()bindNamedGrant(reconciler, 'child-run', {diff --git a/workflow-recipes/tests/unit/workflow/podFactory.mcpHostRuntimeEnvVars.test.ts b/workflow-recipes/tests/unit/workflow/podFactory.mcpHostRuntimeEnvVars.test.tsindex ca54e243f..3063ec255 100644--- a/workflow-recipes/tests/unit/workflow/podFactory.mcpHostRuntimeEnvVars.test.ts+++ b/workflow-recipes/tests/unit/workflow/podFactory.mcpHostRuntimeEnvVars.test.ts@@ -94,6 +94,13 @@ describe('Pod Factory — mcpHost Runtime Env Vars', () => {)})+ it('mcp-host pod enables Codex construction without the Host ConfigMap', () => {+ expect(envByName(mcpHostPod, 'MCP_HOST_CODEX_SUBSCRIPTION_ENABLED')?.value).toBe('true')+ expect(envByName(mcpHostPod, 'CODEX_LLM_PROXY_RUNTIME_URL')?.value).toBe(+ 'http://codex-llm-proxy.control-plane.svc.cluster.local:8080'+ )+ })+it('mcp-host pod uses the WorkflowRecipe caller key as runtime edge host name', () => {const env = envByName(mcpHostPod, 'CLERUM_HOST_NAME')expect(env!.value).toBe('sandbox-recipes/test-recipe')