Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(wrc): close the five reservations from the R5 closing audit
Alfredo Lopezb5f18af771e9
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex 32a88a9bb..b1f8cded0 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.335",+ "version": "0.1.336","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.335",+ "version": "0.1.336","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 9a1d3a85e..8da4b420d 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.335",+ "version": "0.1.336","description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface","main": "dist/main.js","engines": {diff --git a/workflow-recipes/src/workflow/codexRecipeVerdict.ts b/workflow-recipes/src/workflow/codexRecipeVerdict.tsindex 3328d43b0..1d36ac7f2 100644--- a/workflow-recipes/src/workflow/codexRecipeVerdict.ts+++ b/workflow-recipes/src/workflow/codexRecipeVerdict.ts@@ -118,11 +118,19 @@ export function projectCodexRecipeVerdict(input: {} as constif (projection.eligibility !== 'eligible') {- if (projection.eligibility === 'uncertain') {- // A recipe stuck in awaiting_policy because of a stray parent label or an- // unreadable ConfigMap must be visible to an operator; this used to be a- // debug line, which is why the state was only ever found by reading code.- input.log?.warn('Codex verdict is undecidable; withholding scope and binding', {+ // R5-B1 audit (R4): warn ONLY for a recipe that actually targets Codex, and+ // only when the doubt is about provenance. An unreadable ConfigMap already+ // produces three warns in `refreshCodexSnapshot`, and it makes EVERY recipe+ // uncertain — including those with no Codex target — because the shared+ // projection checks `snapshotError` before it checks whether the spec has+ // any Codex target at all. Warning there buried the case this line exists+ // to surface: a recipe wedged in awaiting_policy by a stray parent label.+ if (+ projection.eligibility === 'uncertain' &&+ resolved.provenance !== 'authoritative' &&+ input.hostAgent?.provider === CODEX_PROVIDER+ ) {+ input.log?.warn('Codex provenance is undecidable; withholding scope and binding', {recipeName: context.recipeName,connectionKey: context.connectionKey,provenanceReason: resolved.reason,diff --git a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.tsindex 411c25a5f..3b71936c5 100644--- a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts+++ b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts@@ -133,6 +133,7 @@ export type PluginWorkloadSdkProvisionerDeps = {spec: WorkflowRecipeSpec,runtime: WorkflowRuntimePlan,awaitsTriggeredRun: boolean,+ codexProjection: CodexRecipeVerdict['projection'],eagerSdkMcpHost: boolean) => Promise<void>ensureMcpHostHeadlessService: (recipeName: string) => Promise<void>@@ -251,6 +252,7 @@ export class PluginWorkloadSdkProvisioner {spec,runtime,/* awaitsTriggeredRun */ true,+ opts.codexVerdict.projection,/* eagerSdkMcpHost */ true)diff --git a/workflow-recipes/src/workflow/workflowReconciler.codexUncertainScope.test.ts b/workflow-recipes/src/workflow/workflowReconciler.codexUncertainScope.test.tsindex 95701234b..017d4d1f1 100644--- a/workflow-recipes/src/workflow/workflowReconciler.codexUncertainScope.test.ts+++ b/workflow-recipes/src/workflow/workflowReconciler.codexUncertainScope.test.ts@@ -534,6 +534,44 @@ describe('Codex allowlist view across interleaved recipes', () => {expect(configure.mock.calls[0]?.[5] ?? null).toBeNull()})+ it('keeps binding and scope on the captured view when another recipe wipes it mid-pass', async () => {+ // The audit's missing case (T2b). The existing interleaving test fires+ // during createNamespacedService, which happens AFTER+ // ensureMcpHostSecrets — so a recomputation there would still have seen+ // the same view and the test would pass anyway. The real window is+ // between the capture and the provisioner's first await: getPodPhase.+ const { reconciler, coreApi, configure } = createHarness()+ bindGrant(reconciler, RECIPE)+ bindGrant(reconciler, 'other-recipe', 'personal-pro')++ let interleaved = false+ crashRecoveryMocks.getPodPhase.mockImplementation(async () => {+ if (!interleaved) {+ interleaved = true+ coreApi.readNamespacedConfigMap.mockRejectedValue(+ Object.assign(new Error('Kubernetes request timed out'), { code: 'ETIMEDOUT' })+ )+ await reconciler.reconcilePluginWorkloadSdkOnly(+ 'other-recipe',+ 'uid-other-recipe',+ sandboxNamespace,+ codexSdkSpec({ steps: undefined }),+ 'other-recipe'+ )+ }+ return undefined+ })++ await reconcileRecipe(reconciler, codexSdkSpec())++ expect(builtMcpHostPodFrom(coreApi)).toBeDefined()+ // Both sides must still come from the view this pass captured, and the+ // TRUE side is pinned so the agreement is not vacuous.+ const carriedBinding = (configure.mock.calls[0]?.[5] ?? null) !== null+ expect(carriedBinding).toBe(true)+ expect(issuedScopes()).toContain(CODEX_SCOPE)+ })+it('agrees on binding and scope in the eligible case', async () => {// R5-B1's real invariant, asserted as a biconditional rather than as two// independent facts: a configure that carries a binding must come with@@ -545,6 +583,9 @@ describe('Codex allowlist view across interleaved recipes', () => {expect(builtMcpHostPodFrom(coreApi)).toBeDefined()const carriedBinding = (configure.mock.calls[0]?.[5] ?? null) !== null+ // Pin the TRUE side first: a biconditional over two falses is vacuous,+ // and this case exists to prove agreement in the eligible direction.+ expect(carriedBinding).toBe(true)expect(carriedBinding).toBe(issuedScopes().includes(CODEX_SCOPE))})})diff --git a/workflow-recipes/src/workflow/workflowReconciler.ts b/workflow-recipes/src/workflow/workflowReconciler.tsindex 1c7d76bff..25de87bb6 100644--- a/workflow-recipes/src/workflow/workflowReconciler.ts+++ b/workflow-recipes/src/workflow/workflowReconciler.ts@@ -42,8 +42,7 @@ import { resolveEagerSdkMcpHostAgent, resolveMcpHostAgent } from './agentResolutimport {CODEX_EXECUTE_SCOPE,type CodexCatalogSnapshot,- projectRecipeCodexExecution,- resolveCodexAuthoritativeSpec,+ type CodexExecutionProjection,} from './codexExecutionProjection'import {type CodexAllowlistView,@@ -68,7 +67,6 @@ import {ALLOWLIST_CONFIGMAP_NAMESPACE,CODEX_UNASSIGNED_CONNECTION_KEY,parseAllowedModelsSnapshot,- snapshotForAssignedCodexGrant,snapshotFromConfigMapError,} from './llmAllowedModelsSnapshot'import {@@ -947,6 +945,7 @@ export class WorkflowReconciler {spec,runtime,awaitsTriggeredRun,+ codexProjection,eagerSdkMcpHost) =>this.applyWorkflowNetworkPolicies(@@ -955,6 +954,7 @@ export class WorkflowReconciler {spec,runtime,awaitsTriggeredRun,+ codexProjection,eagerSdkMcpHost),ensureMcpHostHeadlessService: recipeName => this.ensureMcpHostHeadlessService(recipeName),@@ -1008,10 +1008,7 @@ export class WorkflowReconciler {const context = this.resolveCodexContext(recipeUid, recipeName, runtimeScopeRecipeName)return projectCodexRecipeVerdict({ownSpec: spec,- context: {- ...context,- connectionKey: context.connectionKey ?? CODEX_UNASSIGNED_CONNECTION_KEY,- },+ context,hostAgent: resolveEagerSdkMcpHostAgent(spec),view,log: this.log,@@ -1456,7 +1453,19 @@ export class WorkflowReconciler {): Promise<WorkflowReconcileResult> {const preflightError = this.validateWorkflowSpec(spec)if (preflightError) return { phase: 'failed', message: preflightError, workflowPhase: 'failed' }- await this.refreshCodexSnapshot()+ // R5-B1 audit (R3): capture the allowlist refresh ONCE for this pass and+ // compute the verdict from it. Every consumer below — eager configure, the+ // run path's secrets, and the NetworkPolicy decision — reads this object+ // instead of `this.codexView`, which a concurrent recipe can replace+ // between two of them.+ const codexView = await this.refreshCodexSnapshot()+ const codexVerdict = this.codexVerdictFor(+ spec,+ recipeUid,+ recipeName,+ runtimeScopeRecipeName,+ codexView+ )const secretPreflightError = await this.validateSnippetSecretRefs(recipeName,spec,@@ -1635,7 +1644,7 @@ export class WorkflowReconciler {recipeUid,recipeName,runtimeScopeRecipeName,- this.codexView+ codexView)const eagerStatus = await this.pluginWorkloadSdkProvisioner.ensureEagerSdkMcpHost(recipeName,@@ -1884,7 +1893,7 @@ export class WorkflowReconciler {runtimeScopeRecipeName,spec,recipeUid,- this.codexVerdictFor(spec, recipeUid, recipeName, runtimeScopeRecipeName, this.codexView)+ codexVerdict)}@@ -2125,7 +2134,8 @@ export class WorkflowReconciler {recipeUid,spec,runtime,- awaitsTriggeredRun+ awaitsTriggeredRun,+ codexVerdict.projection)// 6. Create Pods — mcp-host FIRST, then coordinator. If the coordinator@@ -2897,6 +2907,12 @@ export class WorkflowReconciler {spec: WorkflowRecipeSpec,runtime: WorkflowRuntimePlan,awaitsTriggeredRun: boolean,+ /**+ * The pass's Codex projection. R5-B1 audit: recomputing it here read the+ * live allowlist view after this method's own awaits, so a NetworkPolicy+ * decision could rest on a different snapshot than the binding did.+ */+ codexProjection: CodexExecutionProjection,eagerSdkMcpHost = false): Promise<k8s.V1NetworkPolicy[]> {const runtimeHttpEgressPolicyNames = this.runtimeHttpEgressPolicyNames(recipeName, spec)@@ -2917,13 +2933,7 @@ export class WorkflowReconciler {// triggered. The artifact-reader/snippet-runner stay run-only.const mcpHostLaneLive = !awaitsTriggeredRun || eagerSdkMcpHostconst includeMcpHost = runtime.network.includeMcpHost && mcpHostLaneLive- const codexProjection = this.codexVerdictFor(- spec,- recipeUid,- recipeName,- this.resolveCodexContext(recipeUid, recipeName, recipeName).runtimeScopeRecipeName,- this.codexView- ).projection+const npConfig: NetworkPolicyConfig = {recipeName,sandboxNamespace: this.deps.config.sandboxNamespace,@@ -3026,6 +3036,7 @@ export class WorkflowReconciler {spec: WorkflowRecipeSpec,runtime: WorkflowRuntimePlan,awaitsTriggeredRun: boolean,+ codexProjection: CodexExecutionProjection,eagerSdkMcpHost = false): Promise<void> {const policies = await this.buildWorkflowNetworkPoliciesForSpec(@@ -3034,6 +3045,7 @@ export class WorkflowReconciler {spec,runtime,awaitsTriggeredRun,+ codexProjection,eagerSdkMcpHost)for (const policy of policies) {@@ -3041,13 +3053,7 @@ export class WorkflowReconciler {}const policyNames = new Set(policies.map(policy => policy.metadata?.name))const codexProxyPolicyName = `${recipeName}-mcp-host-to-codex-proxy`- const codexProjection = this.codexVerdictFor(- spec,- recipeUid,- recipeName,- this.resolveCodexContext(recipeUid, recipeName, recipeName).runtimeScopeRecipeName,- this.codexView- ).projection+if (!policyNames.has(codexProxyPolicyName) && codexProjection.eligibility !== 'uncertain') {await this.safeDelete(() =>this.deps.networkingApi.deleteNamespacedNetworkPolicy({