Problem
cancelTask() can mutate terminal tasks, and runTask() can still mark a task succeeded while cancellation is in progress.
Relevant code:
src/runtime.ts:133-150
src/runtime.ts:196-205
Issues:
- A completed or failed task can be moved to
cancelling, then cancelled/failed.
runTask() only treats cancelled/failed as terminal before marking success; cancelling can still become succeeded.
Impact
Final task state is nondeterministic and can regress from terminal states.
Suggested fix
- Make
cancelTask() no-op or throw for succeeded, failed, and cancelled.
- Treat
cancelling as a finalization blocker in runTask().
- Consider atomic/compare-and-set style state transitions in the store contract.
Acceptance criteria
- Cancelling a terminal task cannot change its terminal status.
- Race tests cover cancellation while
runTask() is near success finalization.
Problem
cancelTask()can mutate terminal tasks, andrunTask()can still mark a task succeeded while cancellation is in progress.Relevant code:
src/runtime.ts:133-150src/runtime.ts:196-205Issues:
cancelling, thencancelled/failed.runTask()only treatscancelled/failedas terminal before marking success;cancellingcan still becomesucceeded.Impact
Final task state is nondeterministic and can regress from terminal states.
Suggested fix
cancelTask()no-op or throw forsucceeded,failed, andcancelled.cancellingas a finalization blocker inrunTask().Acceptance criteria
runTask()is near success finalization.