Skip to content

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

TypeScript

fix(wrc): decide the Codex configure skip from eligibility, not from readOk

Alfredo Lopezbbe13c346bb5
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index 94d2451be..5dba5dd9f 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.332",
+ "version": "0.1.333",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.332",
+ "version": "0.1.333",
"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 acce42898..2726ba936 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.332",
+ "version": "0.1.333",
"description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface",
"main": "dist/main.js",
"engines": {
diff --git a/workflow-recipes/src/workflow/modelConfigHandler.ts b/workflow-recipes/src/workflow/modelConfigHandler.ts
index b71e0de08..04fed8e7a 100644
--- a/workflow-recipes/src/workflow/modelConfigHandler.ts
+++ b/workflow-recipes/src/workflow/modelConfigHandler.ts
@@ -314,7 +314,12 @@ export class ModelConfigHandler {
// Shape alone is not proof: re-derive the policy hash and pin the model
// so a host cannot echo a well-formed binding for another model or with
// a hash that does not match its own five fields.
- const verifiedCodexBinding = readVerifiedSdkOnlyCodexBinding(result.body.codexBinding, model)
+ // R4-L1: without a model there is no pin to apply, and an unpinned
+ // binding could be for another model. Refuse it rather than accept it
+ // blind — the pin is the point of this call.
+ const verifiedCodexBinding = model
+ ? readVerifiedSdkOnlyCodexBinding(result.body.codexBinding, model)
+ : null
return {
status: 202,
body: {
diff --git a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.codexPolicy.test.ts b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.codexPolicy.test.ts
index 493dfca51..f892fe56a 100644
--- a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.codexPolicy.test.ts
+++ b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.codexPolicy.test.ts
@@ -127,7 +127,7 @@ function makeHarness(configureResult: unknown) {
const reconcile = (opts: {
codexBinding?: PluginWorkloadSdkCodexBindingProof | null
- codexSnapshotUnavailable?: boolean
+ codexBindingUndecidable?: boolean
}) =>
provisioner.ensureEagerSdkMcpHost(
RECIPE,
@@ -173,7 +173,7 @@ describe('eager Codex policy gate', () => {
// ConfigMap read fails on the next pass: the live host still holds the
// binding this same pod was configured with, so the recipe stays ready and
// WRC must NOT re-broker with a binding it can no longer justify.
- expect(await harness.reconcile({ codexSnapshotUnavailable: true })).toBe('ready')
+ expect(await harness.reconcile({ codexBindingUndecidable: true })).toBe('ready')
expect(harness.configure).toHaveBeenCalledTimes(1)
})
@@ -190,7 +190,7 @@ describe('eager Codex policy gate', () => {
harness.configure.mockClear()
harness.signWrcConfigureToken.mockClear()
- expect(await harness.reconcile({ codexSnapshotUnavailable: true })).toBe('awaiting_policy')
+ expect(await harness.reconcile({ codexBindingUndecidable: true })).toBe('awaiting_policy')
expect(harness.provisioner.getBootstrapProof(RECIPE)).toBeUndefined()
expect(harness.configure).not.toHaveBeenCalled()
expect(harness.signWrcConfigureToken).not.toHaveBeenCalled()
@@ -249,7 +249,7 @@ describe('eager Codex policy gate', () => {
},
})
- expect(await harness.reconcile({ codexBinding: null, codexSnapshotUnavailable: false })).toBe(
+ expect(await harness.reconcile({ codexBinding: null, codexBindingUndecidable: false })).toBe(
'awaiting_policy'
)
expect(harness.configure).toHaveBeenCalledWith(
@@ -309,7 +309,7 @@ describe('eager Codex policy gate', () => {
expect(harness.provisioner.getBootstrapProof(RECIPE)).toMatchObject({ contractVersion: 2 })
harness.configure.mockClear()
- expect(await harness.reconcile({ codexSnapshotUnavailable: true })).toBe('awaiting_policy')
+ expect(await harness.reconcile({ codexBindingUndecidable: true })).toBe('awaiting_policy')
// The early-return short-circuits before configure either way, so the
// status above is the whole assertion: 'ready' would be the regression.
expect(harness.configure).not.toHaveBeenCalled()
diff --git a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.imageDrift.test.ts b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.imageDrift.test.ts
index 48ceeacee..be39b61d8 100644
--- a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.imageDrift.test.ts
+++ b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.imageDrift.test.ts
@@ -682,7 +682,7 @@ describe('ensureEagerSdkMcpHost ConfigMap snapshot skip', () => {
RECIPE,
CODEX_SPEC,
RUNTIME,
- { mcpHostPhase: 'Running', codexSnapshotUnavailable: true }
+ { mcpHostPhase: 'Running', codexBindingUndecidable: true }
)
).resolves.toBe('awaiting_policy')
expect(configure).not.toHaveBeenCalled()
diff --git a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts
index f13816e2e..5ff884a5b 100644
--- a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts
+++ b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts
@@ -217,7 +217,7 @@ export class PluginWorkloadSdkProvisioner {
* Do not send a binding-less v3 configure that would clear a live host
* binding.
*/
- codexSnapshotUnavailable?: boolean
+ codexBindingUndecidable?: boolean
}
): Promise<EagerSdkMcpHostStatus> {
const log = createLogger('wrc', recipeName)
@@ -387,7 +387,7 @@ export class PluginWorkloadSdkProvisioner {
if (promptBridge && !mcpHostAgent) return 'failed'
if (
- opts.codexSnapshotUnavailable === true &&
+ opts.codexBindingUndecidable === true &&
promptBridge &&
mcpHostAgent?.provider === 'codex-subscription'
) {
@@ -415,7 +415,7 @@ export class PluginWorkloadSdkProvisioner {
return 'ready'
}
// The caller derives the binding from the same allowlist view it used for
- // `codexSnapshotUnavailable`; the provisioner never re-reads that state
+ // `codexBindingUndecidable`; the provisioner never re-reads that state
// after its own awaits (see the reconciler's `codexView`).
const resolvedCodexBinding = opts.codexBinding ?? null
const capabilityFamily = promptBridge ? 'promptBridge' : 'clientNotifications'
@@ -694,7 +694,7 @@ function parseEagerSdkBootstrapProof(
body: Record<string, unknown>,
podUid: string,
/** Agent model WRC bootstrapped; a binding for another model is not ours. */
- expectedModel?: string
+ expectedModel: string | undefined
): EagerSdkBootstrapProof | null {
if (body.capabilityFamily === 'clientNotifications') {
if (
@@ -801,7 +801,10 @@ function parseEagerSdkBootstrapProof(
function parseCodexBindingProof(
value: unknown,
- expectedModel?: string
+ expectedModel: string | undefined
): PluginWorkloadSdkCodexBindingProof | undefined {
+ // No expected model means no pin is possible, and an unpinned binding could
+ // be for another model. Refuse the proof instead of accepting it blind.
+ if (!expectedModel) return undefined
return readVerifiedSdkOnlyCodexBinding(value, expectedModel) ?? undefined
}
diff --git a/workflow-recipes/src/workflow/sdkOnlyCodexBinding.test.ts b/workflow-recipes/src/workflow/sdkOnlyCodexBinding.test.ts
index a71e47a39..57c7de647 100644
--- a/workflow-recipes/src/workflow/sdkOnlyCodexBinding.test.ts
+++ b/workflow-recipes/src/workflow/sdkOnlyCodexBinding.test.ts
@@ -4,6 +4,7 @@ import {
deriveSdkOnlyCodexBinding,
isPluginWorkloadSdkCodexBindingProof,
readVerifiedSdkOnlyCodexBinding,
+ resolveSdkOnlyCodexBinding,
verifySdkOnlyCodexBindingHash,
} from './sdkOnlyCodexBinding'
@@ -198,6 +199,47 @@ describe('deriveSdkOnlyCodexBinding', () => {
).toBeNull()
})
+ // R4-B1: the reconciler used to answer "was the catalog decidable?" from a
+ // pure IO flag, which is true for a ConfigMap that reads fine and parses
+ // badly. These pin the single verdict both paths now share: an unreadable
+ // ConfigMap and a malformed one are equally `uncertain`, while a deliberate
+ // "Codex is off" is `ineligible` — a decision, not a doubt.
+ it('reports an unreadable ConfigMap as uncertain', () => {
+ expect(
+ resolveSdkOnlyCodexBinding({
+ provider: 'codex-subscription',
+ model: MODEL,
+ connectionKey: 'team-plus',
+ configMap: undefined,
+ })
+ ).toMatchObject({ binding: null, eligibility: 'uncertain' })
+ })
+
+ it('reports a readable but malformed ConfigMap as uncertain, not as a decision', () => {
+ const malformed = eligibleLegacyConfigMap()
+ malformed.metadata!.annotations!['clerum.io/catalog-revision'] = 'not-a-number'
+
+ expect(
+ resolveSdkOnlyCodexBinding({
+ provider: 'codex-subscription',
+ model: MODEL,
+ connectionKey: 'team-plus',
+ configMap: malformed,
+ })
+ ).toMatchObject({ binding: null, eligibility: 'uncertain' })
+ })
+
+ it('reports a non-Codex provider as ineligible rather than uncertain', () => {
+ expect(
+ resolveSdkOnlyCodexBinding({
+ provider: 'openai',
+ model: MODEL,
+ connectionKey: 'team-plus',
+ configMap: eligibleLegacyConfigMap(),
+ })
+ ).toMatchObject({ binding: null, eligibility: 'ineligible' })
+ })
+
it('returns null for non-Codex providers and unassigned grants', () => {
expect(
deriveSdkOnlyCodexBinding({
@@ -243,7 +285,9 @@ describe('deriveSdkOnlyCodexBinding', () => {
bindingHash: HASH,
extra: true,
}
- expect(readVerifiedSdkOnlyCodexBinding(proof)).toEqual({
+ // R4-L1: the model is a required argument now. This call used to omit it,
+ // which silently skipped the pin — the very gap the change closes.
+ expect(readVerifiedSdkOnlyCodexBinding(proof, MODEL)).toEqual({
connectionKey: 'team-plus',
catalogRevision: 3,
credentialRevision: 1,
diff --git a/workflow-recipes/src/workflow/workflowReconciler.codexUncertainScope.test.ts b/workflow-recipes/src/workflow/workflowReconciler.codexUncertainScope.test.ts
index 0d05f660e..bd66edacf 100644
--- a/workflow-recipes/src/workflow/workflowReconciler.codexUncertainScope.test.ts
+++ b/workflow-recipes/src/workflow/workflowReconciler.codexUncertainScope.test.ts
@@ -412,7 +412,7 @@ describe('Codex allowlist view across interleaved recipes', () => {
// N-08. Recipe B captured a readable catalog; while B is inside
// ensureEagerSdkMcpHost, recipe A's refresh fails and clears the shared
// state. Resolving the binding from that shared state after the awaits gave
- // B a null binding while `codexSnapshotUnavailable` still said false — a
+ // B a null binding while `codexBindingUndecidable` still said false — a
// binding-less v3 configure that wipes the live host binding. B must
// configure from the view it captured, or not configure at all.
const { reconciler, coreApi, configure } = createHarness()
diff --git a/workflow-recipes/src/workflow/workflowReconciler.ts b/workflow-recipes/src/workflow/workflowReconciler.ts
index ed5887c6e..edd29cfcd 100644
--- a/workflow-recipes/src/workflow/workflowReconciler.ts
+++ b/workflow-recipes/src/workflow/workflowReconciler.ts
@@ -141,7 +141,7 @@ import {
deleteScheduling,
reconcileScheduling,
} from './schedulingHandler'
-import { deriveSdkOnlyCodexBinding } from './sdkOnlyCodexBinding'
+import { resolveSdkOnlyCodexBinding } from './sdkOnlyCodexBinding'
import {
MCP_HOST_RUNTIME_TOKEN_GENERATION_ANNOTATION,
buildMcpHostRuntimeTokenSecret,
@@ -901,13 +901,20 @@ export class WorkflowReconciler {
/**
* The last allowlist refresh as ONE value. `configMap` is kept raw so each
* recipe's projection can re-parse it with that recipe's assigned grant key
- * (HCC keeps the same shape for Hosts); `readOk` says whether the triple
- * comes from a successful read. They are a single field because they must be
- * read together: a `configMap` from one refresh combined with a `readOk`
- * from another is how a concurrently-reconciled recipe turns a failed read
- * into a binding-less v3 configure that wipes a live mcp-host binding.
+ * (HCC keeps the same shape for Hosts), and it is cleared on a failed read so
+ * the projection sees `missing`. They are a single field because they must be
+ * read together: a `configMap` from one refresh paired with a verdict from
+ * another is how a concurrently-reconciled recipe turns a failed read into a
+ * binding-less v3 configure that wipes a live mcp-host binding.
* Readers capture `this.codexView` once and use only that snapshot.
*
+ * There is deliberately NO separate "was the read OK?" boolean here (R4-B1).
+ * A ConfigMap that reads fine but parses badly is just as undecidable as one
+ * that never arrived, and an IO-only flag said otherwise — so the scope path
+ * withheld the grant while the configure path wiped the binding. The single
+ * verdict is `resolveSdkOnlyCodexBinding(...).eligibility === 'uncertain'`,
+ * which strictly subsumes the old flag.
+ *
* Cleared on a failed read so grant decisions stay fail-closed. Do not send
* a binding-less v3 configure in that window — skip configure so mcp-host
* keeps a live binding. Symmetrically (see `resolveEffectiveControlScopes`),
@@ -917,8 +924,7 @@ export class WorkflowReconciler {
private codexView: {
configMap?: k8s.V1ConfigMap
snapshot: CodexCatalogSnapshot
- readOk: boolean
- } = { snapshot: { flagEnabled: false }, readOk: true }
+ } = { snapshot: { flagEnabled: false } }
private readonly codexContexts = new Map<string, CodexReconcileContext>()
constructor(private readonly deps: WorkflowReconcilerDeps) {
@@ -1044,18 +1050,17 @@ export class WorkflowReconciler {
private async refreshCodexSnapshot(): Promise<{
configMap?: k8s.V1ConfigMap
snapshot: CodexCatalogSnapshot
- readOk: boolean
}> {
try {
const cm = await this.deps.coreApi.readNamespacedConfigMap({
name: ALLOWED_MODELS_CONFIGMAP_NAME,
namespace: ALLOWLIST_CONFIGMAP_NAMESPACE,
})
- this.codexView = { configMap: cm, snapshot: parseAllowedModelsSnapshot(cm), readOk: true }
+ this.codexView = { configMap: cm, snapshot: parseAllowedModelsSnapshot(cm) }
return this.codexView
} catch (err) {
if (isCodexSnapshotTimeout(err)) {
- this.codexView = { snapshot: snapshotFromConfigMapError('timeout'), readOk: false }
+ this.codexView = { snapshot: snapshotFromConfigMapError('timeout') }
this.log.warn('Codex allowlist ConfigMap read timed out; failing closed', {
configMap: ALLOWED_MODELS_CONFIGMAP_NAME,
namespace: ALLOWLIST_CONFIGMAP_NAMESPACE,
@@ -1064,7 +1069,7 @@ export class WorkflowReconciler {
}
const code = getErrorCode(err)
if (code === 401 || code === 403) {
- this.codexView = { snapshot: snapshotFromConfigMapError('forbidden'), readOk: false }
+ this.codexView = { snapshot: snapshotFromConfigMapError('forbidden') }
this.log.warn('Codex allowlist ConfigMap read forbidden; failing closed', {
configMap: ALLOWED_MODELS_CONFIGMAP_NAME,
namespace: ALLOWLIST_CONFIGMAP_NAMESPACE,
@@ -1072,7 +1077,7 @@ export class WorkflowReconciler {
})
return this.codexView
}
- this.codexView = { snapshot: snapshotFromConfigMapError('missing'), readOk: false }
+ this.codexView = { snapshot: snapshotFromConfigMapError('missing') }
this.log.warn('Codex allowlist ConfigMap unavailable; failing closed', {
configMap: ALLOWED_MODELS_CONFIGMAP_NAME,
namespace: ALLOWLIST_CONFIGMAP_NAMESPACE,
@@ -1149,9 +1154,13 @@ export class WorkflowReconciler {
const codexView = await this.refreshCodexSnapshot()
const agent = resolveEagerSdkMcpHostAgent(spec)
const context = this.resolveCodexContext(recipeUid, recipeName, runtimeScopeRecipeName)
- const codexBinding =
+ // R4-B1: the binding and the "was this decidable?" signal come from the
+ // same call. Deriving the second from `codexView.readOk` made a readable
+ // but malformed ConfigMap look decidable here while the scope path called
+ // it uncertain, and a binding-less v3 configure then wiped the live one.
+ const codexResolution =
agent?.provider && agent.model
- ? deriveSdkOnlyCodexBinding({
+ ? resolveSdkOnlyCodexBinding({
provider: agent.provider,
model: agent.model,
connectionKey: context.connectionKey,
@@ -1159,6 +1168,8 @@ export class WorkflowReconciler {
log: this.log,
})
: null
+ const codexBinding = codexResolution?.binding ?? null
+ const codexBindingUndecidable = codexResolution?.eligibility === 'uncertain'
const runtime = deriveWorkflowRuntimePlan(spec, {
recipeName,
@@ -1177,7 +1188,7 @@ export class WorkflowReconciler {
runtimeScopeRecipeName,
spec,
runtime,
- { mcpHostPhase, codexBinding, codexSnapshotUnavailable: !codexView.readOk }
+ { mcpHostPhase, codexBinding, codexBindingUndecidable }
)
const bootstrapProof = this.pluginWorkloadSdkProvisioner.getBootstrapProof(recipeName)
switch (status) {
@@ -1637,9 +1648,11 @@ export class WorkflowReconciler {
recipeName,
runtimeScopeRecipeName
)
- const eagerCodexBinding =
+ // R4-B1: see the sibling call above — one resolution answers both
+ // "which binding?" and "was the catalog decidable?".
+ const eagerCodexResolution =
eagerAgent?.provider && eagerAgent.model
- ? deriveSdkOnlyCodexBinding({
+ ? resolveSdkOnlyCodexBinding({
provider: eagerAgent.provider,
model: eagerAgent.model,
connectionKey: eagerCodexContext.connectionKey,
@@ -1647,6 +1660,8 @@ export class WorkflowReconciler {
log: this.log,
})
: null
+ const eagerCodexBinding = eagerCodexResolution?.binding ?? null
+ const eagerCodexBindingUndecidable = eagerCodexResolution?.eligibility === 'uncertain'
const eagerStatus = await this.pluginWorkloadSdkProvisioner.ensureEagerSdkMcpHost(
recipeName,
recipeUid,
@@ -1657,7 +1672,7 @@ export class WorkflowReconciler {
{
mcpHostPhase,
codexBinding: eagerCodexBinding,
- codexSnapshotUnavailable: !eagerCodexView.readOk,
+ codexBindingUndecidable: eagerCodexBindingUndecidable,
}
)
const eagerBootstrapProof =