ADE-58: Orchestration claimTask: reject claims against terminal (done/failed) tasks#420
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
📝 WalkthroughWalkthroughThe PR adds a guard to prevent claiming tasks in terminal statuses. The ChangesTerminal task claim prevention
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@copilot review but do not make fixes |
|
Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews. |
There was a problem hiding this comment.
PR Review
Scope: 2 file(s), +129 / −0
Verdict: Looks good
This PR adds an early guard in claimTask so tasks in terminal done or failed status cannot be re-claimed, and adds parametrized service tests that release a task to each terminal state then assert both the original assignee and another worker get a stable rejection with an unchanged manifest.
Notes
- The guard is placed in the right spot: after task/agent lookup and before lease/assignee logic, so an expired
claimLeaseUntilon a terminal task can no longer resurrect work throughclaimTask. - Tests cover both
doneandfailed, same-session vs other-worker claims, and assert manifest fields (status,claimLeaseUntil) stay unchanged on failure — good regression coverage for the reported bug. - Workers are steered to
claimTaskin tool prompts; this closes the primary mutation path.manifestPatchstill allows an owning worker toreplace/tasks/{id}/statuswithout a terminal check — that looks pre-existing and out of this PR’s stated scope, but worth a follow-up if you want terminal immutability everywhere. - No renderer/IPC contract changes; trust boundary remains local desktop orchestration over lane worktrees.
Sent by Cursor Automation: BUGBOT in Versic
55ff53b to
ecb24e9
Compare
|
@copilot review but do not make fixes |


Refs ADE-58
Summary
Describe the change.
What Changed
Key files and behaviors.
Validation
How you tested.
Risks
Anything to watch.
Linked Linear issues
Summary by CodeRabbit
Greptile Summary
This PR adds a guard in
claimTaskto reject claim attempts on tasks that are already in a terminal state (doneorfailed), preventing re-assignment of completed work. A comprehensive parameterized test covers both terminal states and verifies rejection from both the original assignee and other workers.orchestrationService.ts: New guard inserted after the task-not-found check; returnsok: falsewith a descriptive reason string (\"task X is terminal (done|failed) and cannot be claimed\") before any lease or assignee mutation is attempted.orchestrationService.test.ts:it.eachtest seeds a task, transitions it to the target terminal state viareleaseTask, then verifies two separateclaimTaskcalls are rejected with the expected reason and that the task's status andclaimLeaseUntilremain unchanged.Confidence Score: 5/5
Safe to merge — the guard is minimal, correctly placed, and well-tested.
The change is a small, focused early-return that prevents state mutation on terminal tasks. It does not alter any existing code paths and is covered by a thorough parameterized test for both terminal states and both claimant types.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[claimTask request] --> B{Session registered?} B -- No --> C[return ok:false\n'session not registered'] B -- Yes --> D{Task exists?} D -- No --> E[return ok:false\n'task not found'] D -- Yes --> F{Task status is\ndone or failed?} F -- Yes --> G[return ok:false\n'task is terminal'] F -- No --> H{Claimed by another\nsession with active lease?} H -- Yes --> I[return ok:false\n'already claimed by X'] H -- No --> J[Apply claim patches\nstatus=claimed, assignee, lease] J --> K[return ok:true]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "Fix terminal orchestration task claims" | Re-trigger Greptile