Skip to content

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

TypeScript

fix: reconcile stale sdk status messages

Alfredo Lopezedd342a9491a
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index b854b5f02..36054c2c4 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.269",
+ "version": "0.1.270",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.269",
+ "version": "0.1.270",
"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 ad2e74f24..14374f790 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.269",
+ "version": "0.1.270",
"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.ts
index 4d650ded5..6e06b8fac 100644
--- a/workflow-recipes/src/k8sClient.test.ts
+++ b/workflow-recipes/src/k8sClient.test.ts
@@ -264,6 +264,40 @@ describe('shouldPatchRecipeStatus', () => {
).toBe(false)
})
+ it('patches a contradictory persisted SDK capability message', () => {
+ expect(
+ shouldPatchRecipeStatus(
+ makeWorkflowRecipe({
+ spec: { steps: [], pluginWorkloadSdk: { promptBridge: {} } },
+ status: {
+ phase: 'active',
+ message: 'All workloads deployed',
+ pluginWorkloadSdk: {
+ state: 'validated',
+ promptBridge: true,
+ clientNotifications: false,
+ message: 'promptBridge bootstrap policy proof is not ready',
+ },
+ conditions: [
+ {
+ type: 'PluginWorkloadSdkCapability',
+ status: 'True',
+ reason: 'Validated',
+ message: 'Capability validated (promptBridge)',
+ lastTransitionTime: 'now',
+ },
+ ],
+ },
+ }),
+ {
+ phase: 'active',
+ message: 'All workloads deployed',
+ workloadStatuses: [],
+ }
+ )
+ ).toBe(true)
+ })
+
it('patches when only the persisted workload status projection changes', () => {
expect(
shouldPatchRecipeStatus(
diff --git a/workflow-recipes/src/k8sClient.ts b/workflow-recipes/src/k8sClient.ts
index d97309593..591cec3af 100644
--- a/workflow-recipes/src/k8sClient.ts
+++ b/workflow-recipes/src/k8sClient.ts
@@ -103,6 +103,12 @@ export function shouldPatchRecipeStatus(
if (recipe.status?.message !== result.message) return true
if (workloadStatusesChanged(recipe, result)) return true
+ // Merge-patching status maps preserves fields omitted by the next patch.
+ // Keep the SDK capability message aligned with its owned condition so a
+ // previous status-only refresh cannot leave a contradictory
+ // `state=validated` + `message=bootstrap not ready` record behind.
+ if (pluginWorkloadSdkStatusMessageChanged(recipe)) return true
+
if (
ownedConditionsChanged(recipe.status?.conditions, result.internalDependencyConditions, [
'InternalDependenciesReady',
@@ -118,6 +124,16 @@ export function shouldPatchRecipeStatus(
return false
}
+function pluginWorkloadSdkStatusMessageChanged(recipe: WorkflowRecipeCRD): boolean {
+ const capability = recipe.status?.pluginWorkloadSdk
+ if (!capability) return false
+ const condition = recipe.status?.conditions?.find(
+ candidate => candidate.type === 'PluginWorkloadSdkCapability'
+ )
+ if (typeof condition?.message !== 'string') return false
+ return capability.message !== condition.message
+}
+
function workflowRunIdForTelemetry(recipe: WorkflowRecipeCRD): string | undefined {
const runId = recipe.metadata.labels?.[WORKFLOW_RUN_ID_LABEL]?.trim()
return runId || undefined