Repository navigation
Description
Problem
The action deadline can close every normal recovery path while an operation remains running in the agent's durable journal. An interrupted step returns without compensation when its context ends; the agent rejects an overdue redelivery before consulting the journal, and the control plane makes the action terminal as expired. At startup the agent counts unfinished operations but does not independently resume or compensate them.
The journal therefore records an uncertain effect without ensuring that it will be resolved. Depending on the handler and interruption point, partial resources can remain and the control plane's terminal state can diverge from the node's actual state.
Audited revision: 1295e534d7a1c3cd0a492449de8806aa532a4924.
A pre-publication comparison of this snapshot with main 2ee78ff1e96118b1732b98bc54c99f5f91b95a32 found that the only intervening change was to apps/api/src/modules/deployments/application/exec-sessions.spec.ts. None of the affected production paths changed.
Scenario and evidence
- An action begins a step that may have external effects.
- Its deadline expires during that step, or the agent stops and returns only after the deadline.
- The operation remains unfinished in SQLite.
- The control plane expires the action instead of replaying it; even a delivery carrying the original deadline is rejected by the agent.
- Restarting the agent alone does not start recovery of that operation.
Source references:
- The executor returns on cancellation/deadline before entering compensation.
- The dispatcher rejects a past deadline before execution/journal lookup.
- The control plane expires overdue actions before querying deliverable work; expiration writes a terminal state.
- Startup reads unfinished operations and logs their count.
- SPEC describes resumable/compensatable interrupted operations and compensation after
CancelAction.
Verification and limits
An isolated Go test exercised the production dispatcher and SQLite journal with a synthetic step that recorded entry, waited for its action deadline, and exposed a compensation counter. Under go test -race, the observation after expiration and redelivery was:
journal=running; applied=1; compensated=0
replay error=action deadline exceeded
This is a component-level demonstration of the recovery gap, not a real process crash, gRPC reconnection, Docker leak, or VM test. Some handlers perform their own bounded cleanup, for example the release-task wait path; the finding is not that every timeout leaves a running container. Cleanup by a deployment also does not replace a general journal recovery contract.
Proposed correction
Separate the execution deadline from recovery/compensation authority. Do not allow an expired request to start new forward effects, but retain a bounded path to inspect a completed result or compensate an interrupted operation. Distinguish process shutdown from explicit cancellation and timeout, and make the resulting terminal or operator-recovery state visible to the control plane. Persist only the minimum recovery data needed, without plaintext secrets.
Acceptance criteria
- Test deadline expiry during a side effect and agent restart after the original deadline, including an uncertain non-retry-safe step.
- Verify bounded compensation, crash during compensation, and safe retry without duplicating forward effects.
- Verify explicit cancellation has the documented outcome; recovery has a separate bounded context.
- The agent and control plane agree on the terminal result or expose a specific unresolved recovery state requiring operator attention.
- Rejecting overdue forward execution cannot silently strand a previously journaled operation.
Related work
Follow-up to closed #15 and #134. #18 concerns periodic container reconciliation; this issue concerns unfinished action recovery across deadlines, not restarting a crashed managed container or future cross-node failover.
Activity