Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(workflow-recipes): pin the token ADDED handler for a recipe not yet cached
Alfredo Lopezf391a728a2fd
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex 7ed9095c8..254f8a086 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.432",+ "version": "0.1.433","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.432",+ "version": "0.1.433","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 8ce678ea1..54067fa46 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.432",+ "version": "0.1.433","description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface","main": "dist/main.js","engines": {diff --git a/workflow-recipes/src/k8sClient.test.ts b/workflow-recipes/src/k8sClient.test.tsindex 3438c3fb8..71028f7b2 100644--- a/workflow-recipes/src/k8sClient.test.ts+++ b/workflow-recipes/src/k8sClient.test.ts@@ -3341,6 +3341,14 @@ describe('handleOAuthBrokerTokenAdded', () => {expect(enqueue).not.toHaveBeenCalled()})+ it('only re-arms the ledger for a recipe not yet cached: its own queued event reaps', () => {+ const { internal, invalidate, enqueue } = setup()+ internal.handleOAuthBrokerTokenAdded(internal.config.sandboxNamespace, 'not-cached')+ // Liveness witness: the handler ran and armed the ledger for that recipe.+ expect(invalidate).toHaveBeenCalledWith('not-cached')+ expect(enqueue).not.toHaveBeenCalled()+ })+it('startSecretWatch wires each namespace watcher to the handler with its own namespace', async () => {const { internal, invalidate, enqueue } = setup()secretLoops.length = 0diff --git a/workflow-recipes/src/k8sClient.ts b/workflow-recipes/src/k8sClient.tsindex 2299de08e..d7450be8b 100644--- a/workflow-recipes/src/k8sClient.ts+++ b/workflow-recipes/src/k8sClient.ts@@ -930,6 +930,15 @@ export class WorkflowRecipeWatcher implements WorkflowRecipeProvider {* issue the delete before the next CRD event. An opted-in recipe legitimately* owns its token and only invalidates, because a watch reconnect replays* ADDED for every broker token and must not force a reconcile storm.+ *+ * A recipe not yet in the cache is only re-armed, not enqueued. At startup+ * `startWatch` returns once the watch is open, without waiting for the+ * queued recipe ADDED events to run, and the Secret watch starts right+ * after, so a token ADDED can land first. The recipe's own queued event then reconciles with+ * the ledger armed. A pass that returns before the token reap leaves the+ * token to the next one that reaches it: after a CRD event, a recipe watch+ * restart replaying ADDED, or a Secret watch reconnect replaying the token+ * ADDED once the recipe is cached.*/private handleOAuthBrokerTokenAdded(namespace: string, recipeName: string): void {if (namespace !== this.config.sandboxNamespace) return