Skip to content

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

TypeScript

test(workflow-recipes): clear the marker once the SDK teardown ran (R4-L3)

Alfredo Lopez3ab18608d4e7
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index 220ccb252..b0c54174e 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.440",
+ "version": "0.1.441",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.440",
+ "version": "0.1.441",
"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 7676bc953..07d28ab83 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.440",
+ "version": "0.1.441",
"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.ts
index e2ad0ba39..de13328f7 100644
--- a/workflow-recipes/src/reconciler/reconciler.test.ts
+++ b/workflow-recipes/src/reconciler/reconciler.test.ts
@@ -1746,6 +1746,70 @@ describe('WorkflowRecipeReconciler', () => {
'WorkflowNetworkPolicyOwnership'
)
})
+
+ // R4-L3: the teardown removed every SDK-owned policy, including the
+ // legacy one by name, so the lane without an SDK runtime is `unmanaged`:
+ // a prune it can no longer finish is not carried as PrunePending.
+ const prunePendingMarker = () =>
+ buildNetworkPolicyConvergedCondition(
+ { apply: 'converged', prune: 'pending' },
+ '2026-09-23T10:00:00.000Z',
+ undefined
+ )!
+ const capabilityRemovedRecipe = (phase: string, conditions: unknown[]) =>
+ makeRecipe({
+ spec: {
+ workloads: [{ id: 'app', type: 'deployment', image: 'nginx:1.30.1-alpine', port: 8080 }],
+ },
+ status: {
+ phase,
+ pluginWorkloadSdk: { state: 'validated', promptBridge: true, clientNotifications: false },
+ conditions,
+ },
+ } as Partial<WorkflowRecipeCRD>)
+ const stubCapabilityRemovalTeardown = () => {
+ stubSdkOnly({})
+ const cleanupPluginWorkloadSdk = vi.fn().mockResolvedValue(undefined)
+ ;(
+ reconciler as unknown as {
+ workflowReconciler: { cleanupPluginWorkloadSdk: typeof cleanupPluginWorkloadSdk }
+ }
+ ).workflowReconciler.cleanupPluginWorkloadSdk = cleanupPluginWorkloadSdk
+ return cleanupPluginWorkloadSdk
+ }
+
+ it('R4-L3: clears a published PrunePending marker once the SDK capability is removed from the spec', async () => {
+ const cleanupPluginWorkloadSdk = stubCapabilityRemovalTeardown()
+ const recipe = capabilityRemovedRecipe('active', [ownershipCondition, prunePendingMarker()])
+
+ const result = await reconciler.reconcile(recipe)
+
+ // Liveness witness: the capability-removal teardown ran.
+ expect(cleanupPluginWorkloadSdk).toHaveBeenCalledWith('test-recipe', {
+ preserveWorkflowRuntime: false,
+ })
+ expect(result.phase).not.toBe('failed')
+ expect(result.networkPolicyOwnershipConditions).toEqual([])
+ })
+
+ it('R4-L3: clears a published PrunePending marker when the SDK capability is removed from a failed recipe', async () => {
+ const cleanupPluginWorkloadSdk = stubCapabilityRemovalTeardown()
+ const recipe = capabilityRemovedRecipe('failed', [ownershipCondition, prunePendingMarker()])
+
+ await reconciler.reconcile(recipe)
+
+ // Liveness witness: the capability-removal teardown ran.
+ expect(cleanupPluginWorkloadSdk).toHaveBeenCalledWith('test-recipe', {
+ preserveWorkflowRuntime: false,
+ })
+ const conditionPatches = mockCustomApi.patchNamespacedCustomObjectStatus.mock.calls
+ .map(call => call[0].body.status)
+ .filter(status => Object.keys(status).length === 1 && 'conditions' in status)
+ expect(conditionPatches).toHaveLength(1)
+ const types = (conditionPatches[0].conditions as Array<{ type: string }>).map(c => c.type)
+ expect(types).not.toContain('WorkflowNetworkPoliciesConverged')
+ expect(types).not.toContain('WorkflowNetworkPolicyOwnership')
+ })
})
// awaiting_policy waits for an operator grant. The grant arrives by event
diff --git a/workflow-recipes/src/workflow/workflowReconciler.test.ts b/workflow-recipes/src/workflow/workflowReconciler.test.ts
index d0fa0b1f9..7e7e99708 100644
--- a/workflow-recipes/src/workflow/workflowReconciler.test.ts
+++ b/workflow-recipes/src/workflow/workflowReconciler.test.ts
@@ -2125,6 +2125,68 @@ describe('WorkflowReconciler — Plugin Workload SDK eager mcp-host', () => {
expect(mockCoreApi.createNamespacedPod).not.toHaveBeenCalled()
})
+ // R4-L3: the SDK-only teardown is what makes the `unmanaged` marker writer
+ // true. The legacy mcp-servers internet policy may carry no labels, so the
+ // label sweep cannot be trusted to remove it; the teardown deletes it by name.
+ it('R4-L3: deletes the legacy internet policy by name in the SDK-only teardown, next to the label sweep', async () => {
+ const reconciler = new WorkflowReconciler(makeDeps())
+
+ await expect(reconciler.cleanupPluginWorkloadSdk('sdk-only')).resolves.toBeUndefined()
+
+ // Liveness witness: the label sweep ran in both namespaces.
+ expect(mockNetworkingApi.listNamespacedNetworkPolicy).toHaveBeenCalledWith({
+ namespace: sandboxNamespace,
+ labelSelector: 'clerum.io/recipe=sdk-only,clerum.io/managed-by=wrc',
+ })
+ expect(mockNetworkingApi.listNamespacedNetworkPolicy).toHaveBeenCalledWith({
+ namespace: mcpServerNamespace,
+ labelSelector: 'clerum.io/recipe=sdk-only,clerum.io/managed-by=wrc',
+ })
+ expect(mockNetworkingApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith({
+ name: 'sdk-only-mcp-servers-egress-internet',
+ namespace: mcpServerNamespace,
+ })
+ })
+
+ it('R4-L3: fails the SDK-only teardown when the legacy internet policy DELETE fails', async () => {
+ mockNetworkingApi.deleteNamespacedNetworkPolicy.mockImplementation(
+ async ({ name }: { name: string }) => {
+ if (name === 'sdk-only-mcp-servers-egress-internet') {
+ throw { code: 403, message: 'forbidden' }
+ }
+ return {}
+ }
+ )
+ const reconciler = new WorkflowReconciler(makeDeps())
+
+ await expect(reconciler.cleanupPluginWorkloadSdk('sdk-only')).rejects.toMatchObject({
+ code: 403,
+ })
+ // Liveness witness: the failure is the legacy DELETE's, not an earlier one.
+ expect(mockNetworkingApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith({
+ name: 'sdk-only-mcp-servers-egress-internet',
+ namespace: mcpServerNamespace,
+ })
+ })
+
+ it('R4-L3: keeps the legacy internet policy in a hybrid teardown, which preserves the workflow runtime', async () => {
+ const reconciler = new WorkflowReconciler(makeDeps())
+
+ await expect(
+ reconciler.cleanupPluginWorkloadSdk('hybrid', { preserveWorkflowRuntime: true })
+ ).resolves.toBeUndefined()
+
+ // Liveness witness: the SDK-owned policies were deleted.
+ expect(mockNetworkingApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith({
+ name: 'hybrid-workload-to-mcp-host-sdk-ingress',
+ namespace: sandboxNamespace,
+ })
+ expect(mockNetworkingApi.deleteNamespacedNetworkPolicy).not.toHaveBeenCalledWith({
+ name: 'hybrid-mcp-servers-egress-internet',
+ namespace: mcpServerNamespace,
+ })
+ })
+
it('forgets the legacy internet policy ledger entry when an SDK-only recipe is cleaned up', async () => {
const reconciler = new WorkflowReconciler(makeDeps())
const legacyDeletes = () =>