Repository navigation
Description
Problem
An action can complete successfully on the agent after a connection interruption without reporting its outcome to the replacement connection. If the control plane redelivers the action while it is still running, the dispatcher ignores that delivery, but the running action still sends updates to its original, disconnected session.
This can leave the control plane waiting until the action expires and make a deployment fail despite a completed local effect. A further reconnection after completion can recover the journaled outcome; that extra reconnection should not be necessary.
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
- The agent starts an action on connection A. Its effect remains in progress.
- Connection A ends. The action continues, as intended, under the agent's lifetime.
- The agent opens connection B. The control plane redelivers the unfinished action once.
- The dispatcher sees that the same action ID is running and returns without subscribing connection B to its progress or result.
- The action succeeds in the local journal. Its updates still target A, so B receives no terminal update.
The relevant code paths are:
- The session creates its own update channel and drops updates after that session ends.
- An in-flight duplicate returns immediately.
- The control plane records each action as sent on the current stream, and excludes those IDs from further deliveries on that stream.
- SPEC 3.4 promises that redelivery recovers the journaled outcome after a dropped connection.
Verification and limits
An isolated Go test used the production Dispatcher and SQLite journal, with a blocked step and two simulated session callbacks. The first callback was disabled, the same action was delivered to the second callback while still running, and the step was released. With the race detector enabled, the test observed:
- zero updates on the replacement callback;
- a completed local operation;
- the durable success returned by a further delivery after completion, without rerunning the effect.
This was a bounded component test, not a real gRPC reconnection or VM test. The control plane's once-per-stream behavior was verified in source. No production deployment was interrupted.
Proposed correction
Make action progress/result delivery independent of the session that started execution. A replacement session should attach to an existing action and receive its latest durable state and subsequent outcome. Alternatively, use explicit acknowledgements and bounded redelivery until a terminal result is acknowledged. Preserve idempotency and release subscriptions when streams end.
Acceptance criteria
- A transport integration test disconnects during an action, reconnects before it finishes, then observes the terminal result on the replacement stream without a third connection.
- The side effect executes once; concurrent duplicate deliveries do not create duplicate execution.
- Reconnection after completion still replays the stored result, including the action result payload.
- Repeated stream replacement does not retain obsolete callbacks or block the executor.
Related work
Follow-up to closed #14, #15, and #134. Those cover enrollment, journaling and basic replay; this issue specifically covers redelivery while the original execution is still running. It does not require the future failover/lease implementation in #227.
Activity
fix: an action left unfinished past its deadline is undone and its en…