workflow status/get --verbose show a stage reset on resume as still completed
Problem
When a resumed run re-runs a stage (an always_run: true node, or a node whose cached success was invalidated), Archon first writes node_always_run_reset / node_prior_cache_invalidated for it. workflow status --json --verbose and the nodes array of workflow get --json --verbose ignore those two events, so they keep showing the stage's result from the previous attempt (completed) until the new node_started arrives. terminal_record.nodes handles them and shows pending.
In a healthy resume the gap is milliseconds. If the process dies in that gap, the stale state stays: the same workflow get output then disagrees with itself, completed in nodes and pending in terminal_record.nodes.
Found while building a run view on workflow status --json --verbose (one dot per stage).
Version
Archon CLI v0.11.1, run from source at a55637f4c. The code is unchanged on dev at 879c99fe4: buildNodeSummaries (packages/cli/src/commands/workflow.ts:3750) has no case for either event, while packages/workflows/src/terminal-record.ts:50 resets the node to pending.
Repro
Bash-only, no model calls, in a scratch ARCHON_HOME.
- A workflow with an
always_runstage and a stage that fails the first time:
# .archon/workflows/stale-stage.yaml
name: stale-stage
description: "an always_run stage reset on resume"
nodes:
- id: prepare
bash: "echo prepared"
always_run: true
- id: flaky
bash: "if [ -f /tmp/repro/second-try ]; then echo ok; else touch /tmp/repro/second-try; exit 1; fi"
depends_on: [prepare]export ARCHON_HOME=/tmp/repro-home
cd /tmp/repro && git init -q && git commit -q --allow-empty -m init
archon workflow run stale-stage "repro" --no-worktree # flaky fails
archon workflow resume <run-id> # completesThe resume writes these events, in order:
workflow_resumed
workflow_started
node_always_run_reset | prepare
node_started | prepare
node_completed | prepare
node_started | flaky
node_completed | flaky
workflow_completed- The engine writes
node_startedabout a millisecond after the reset, so I could not kill the process between the two by hand. To reproduce "the process died right after the reset", I copiedARCHON_HOME. In the copy I deleted the events afternode_always_run_resetand put the run back torunning, which is what the database holds at that moment:
sqlite3 "$ARCHON_HOME/archon.db" "
delete from remote_agent_workflow_events
where workflow_run_id = '<run-id>'
and event_order > (select event_order from remote_agent_workflow_events
where workflow_run_id = '<run-id>' and event_type = 'node_always_run_reset');
update remote_agent_workflow_runs set status = 'running', completed_at = null where id = '<run-id>';"- Read the stages:
archon workflow status --json --verbose{ "status": "running",
"nodes": [ { "nodeId": "prepare", "state": "completed" },
{ "nodeId": "flaky", "state": "failed" } ] }(trimmed to status and each node's nodeId/state)
archon workflow abandon <run-id>
archon workflow get <run-id> --json --verbosestatus cancelled
nodes prepare: completed flaky: failed
terminal_record.nodes prepare: pending flaky: failed(nodes[].state and terminal_record.nodes[].state from the same response)
Expected
After node_always_run_reset or node_prior_cache_invalidated, the stage reads pending in workflow status --verbose and in workflow get --verbose's nodes, as it already does in terminal_record.nodes.
Actual
It reads completed, the previous attempt's result. If the process never reaches node_started, it keeps reading completed, and workflow get shows completed and pending for the same stage.
Possible fix: buildNodeSummaries resets the node to pending on those two events, as terminal-record.ts does.
Source: coleam00/Archon