Related
Follow-up to #1391 (wrong MCP tool prefix in hive-mind prompt). This issue covers the underlying tracking pipeline that makes workers permanently show idle with 0 completed tasks.
Summary
When using hive-mind spawn --claude, the spawned queen is instructed to coordinate virtual workers via task tools. However, nothing connects the task system to the agent system:
task_assign writes agent IDs to tasks/store.json but never updates agents.json → workers stay idle forever, currentTask stays null
task_complete marks the task done but never increments the worker's taskCount → Completed column in rf-status stays at 0
hive-mind_status reports queen.load as 0.3 + Math.random() * 0.4 (line 266 of hive-mind-tools.js) — a random number, not derived from actual task state
queen.tasksQueued reads from consensus.pending.length instead of pending tasks
The result: hive-mind status always shows all workers as idle / 0 completed regardless of actual work done, and queen load is random noise.
Version
ruflo v3.5.41
Steps to Reproduce
ruflo hive-mind init -t hierarchical-mesh
ruflo hive-mind spawn -n 3
# Use MCP tools:
# 1. task_create → get taskId
# 2. task_assign(taskId, [workerId])
# 3. task_complete(taskId)
# 4. Check: ruflo hive-mind status
Expected Behavior
After task_assign, the assigned worker should show status: active and currentTask: <taskId>. After task_complete, the worker should return to idle with taskCount incremented. Queen load should reflect active tasks / worker count.
Actual Behavior
Workers permanently show idle, Completed: 0, Current Task: -. Queen load is Math.random().
Root Cause
task-tools.ts and hive-mind-tools.ts operate on separate JSON files (tasks/store.json vs agents.json) with zero cross-references:
task_assign handler (task-tools.ts ~L279-300): writes task.assignedTo = agentIds, saves task store. Does NOT touch agent store.
task_complete handler (task-tools.ts ~L194-216): sets task.status = 'completed', saves task store. Does NOT update agent taskCount or status.
hive-mind_status handler (hive-mind-tools.ts ~L266): load: 0.3 + Math.random() * 0.4
The v2 codebase (v2/src/hive-mind/core/HiveMind.ts) had EventEmitter-based lifecycle events, a SwarmOrchestrator, and auto-assignment. The v3 rewrite replaced this with flat JSON CRUD that lost the cross-system linkage.
Suggested Fix
task_assign handler — sync agent state on assignment
When a task is assigned to workers:
- Set
agent.status = 'active' and agent.currentTask = taskId in agents.json
- Auto-transition task to
in_progress if it was pending
- On unassign: revert worker to
idle
task_complete handler — sync agent state on completion
When a task completes:
- Set assigned agents back to
status: 'idle', currentTask: null
- Increment
agent.taskCount
hive-mind_status handler — real metrics
Replace:
load: 0.3 + Math.random() * 0.4
tasksQueued: state.consensus.pending.length
With:
load: activeTaskCount / Math.max(1, workerCount)
tasksQueued: pendingTaskCount // from tasks/store.json
Prompt — explicit lifecycle instructions
The queen prompt (generateHiveMindPrompt()) should explicitly instruct: task_create → task_assign(workerId) → [do work] → task_complete for every subtask, with round-robin worker selection.
Files to Fix
v3/@claude-flow/cli/src/mcp-tools/task-tools.ts — task_assign and task_complete handlers
v3/@claude-flow/cli/src/mcp-tools/hive-mind-tools.ts — hive-mind_status handler (line ~266)
v3/@claude-flow/cli/src/commands/hive-mind.ts — generateHiveMindPrompt() execution protocol
Local Patch Verified
I've patched all three files locally on v3.5.41 and verified the full cycle works:
task_assign → worker goes active, shows currentTask
task_complete → worker returns idle, Completed increments
- Queen load shows real ratio (e.g., 33.3% = 1 active task / 3 workers)
Happy to submit a PR if the approach is acceptable.
Related
Follow-up to #1391 (wrong MCP tool prefix in hive-mind prompt). This issue covers the underlying tracking pipeline that makes workers permanently show
idlewith0completed tasks.Summary
When using
hive-mind spawn --claude, the spawned queen is instructed to coordinate virtual workers via task tools. However, nothing connects the task system to the agent system:task_assignwrites agent IDs totasks/store.jsonbut never updatesagents.json→ workers stayidleforever,currentTaskstaysnulltask_completemarks the task done but never increments the worker'staskCount→Completedcolumn inrf-statusstays at0hive-mind_statusreportsqueen.loadas0.3 + Math.random() * 0.4(line 266 ofhive-mind-tools.js) — a random number, not derived from actual task statequeen.tasksQueuedreads fromconsensus.pending.lengthinstead of pending tasksThe result:
hive-mind statusalways shows all workers asidle / 0 completedregardless of actual work done, and queen load is random noise.Version
ruflo v3.5.41
Steps to Reproduce
Expected Behavior
After
task_assign, the assigned worker should showstatus: activeandcurrentTask: <taskId>. Aftertask_complete, the worker should return toidlewithtaskCountincremented. Queen load should reflect active tasks / worker count.Actual Behavior
Workers permanently show
idle,Completed: 0,Current Task: -. Queen load isMath.random().Root Cause
task-tools.tsandhive-mind-tools.tsoperate on separate JSON files (tasks/store.jsonvsagents.json) with zero cross-references:task_assignhandler (task-tools.ts ~L279-300): writestask.assignedTo = agentIds, saves task store. Does NOT touch agent store.task_completehandler (task-tools.ts ~L194-216): setstask.status = 'completed', saves task store. Does NOT update agenttaskCountorstatus.hive-mind_statushandler (hive-mind-tools.ts ~L266):load: 0.3 + Math.random() * 0.4The v2 codebase (
v2/src/hive-mind/core/HiveMind.ts) had EventEmitter-based lifecycle events, a SwarmOrchestrator, and auto-assignment. The v3 rewrite replaced this with flat JSON CRUD that lost the cross-system linkage.Suggested Fix
task_assignhandler — sync agent state on assignmentWhen a task is assigned to workers:
agent.status = 'active'andagent.currentTask = taskIdinagents.jsonin_progressif it waspendingidletask_completehandler — sync agent state on completionWhen a task completes:
status: 'idle',currentTask: nullagent.taskCounthive-mind_statushandler — real metricsReplace:
With:
Prompt — explicit lifecycle instructions
The queen prompt (
generateHiveMindPrompt()) should explicitly instruct:task_create → task_assign(workerId) → [do work] → task_completefor every subtask, with round-robin worker selection.Files to Fix
v3/@claude-flow/cli/src/mcp-tools/task-tools.ts—task_assignandtask_completehandlersv3/@claude-flow/cli/src/mcp-tools/hive-mind-tools.ts—hive-mind_statushandler (line ~266)v3/@claude-flow/cli/src/commands/hive-mind.ts—generateHiveMindPrompt()execution protocolLocal Patch Verified
I've patched all three files locally on v3.5.41 and verified the full cycle works:
task_assign→ worker goesactive, showscurrentTasktask_complete→ worker returnsidle,CompletedincrementsHappy to submit a PR if the approach is acceptable.