Repository navigation
fix(swarm): release stale task owners on terminal states - #4272
Merged
Merged
Conversation
assignTaskToDomain() can leave two AgentState owners after retargeting (ruvnet#4245 keeps the previous owner busy until a terminal report). The terminal handlers only cleared the reporting or assignedTo agent, leaving the other owner busy with currentTask === taskId forever. Clear and release every remaining owner once the task is completed, terminally failed or cancelled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and change
assignTaskToDomain()can leave a task with twoAgentStateowners. #4245 deliberately keeps the previous generic owner busy when a task is retargeted to another domain because the retarget does not prove that worker stopped executing; its regression test asserts both agents arebusywithcurrentTaskpointing at the same task.The terminal handlers only cleared one side:
handleTaskComplete()cleared and released the reporting agent;handleTaskFail()'s terminal branch cleared and released the reporting agent;cancelTask()cleared and releasedtask.assignedTo.The other owner kept
currentTask === taskIdforever. It stayedbusy, its domain-pool slot stayed reserved, and the shared reservation could never be resolved even though the task was already completed/failed/cancelled.Change: add a private
releaseStaleTaskOwners(taskId, exceptAgentId?)that runs after a task reaches a terminal state and clears + releases every other agent whosecurrentTaskstill points at that task. The reporting (orassignedTo) agent remains handled by the existing path; retries are deliberately untouched because the task is still live and another owner may still be executing it.This completes the multi-owner model introduced by #4245 without changing retargeting semantics.
Validation
v3/@claude-flow/swarm/__tests__/terminal-task-stale-owners.test.ts:b93144803: 3/3 fail (the non-reporting owner staysbusywithcurrentTask === taskId).@claude-flow/swarmsuite 335/335, 28/28 files;tsc --noEmit0 errors;git diff --checkclean.v3vitest config also collects and passes the new file (3/3).Scope / known limitations
Compatibility
AgentState/existing domain release paths.releaseDomainAgent()and their pool state self-heals throughreconcileReservations().