Check @IMPLEMENTATION_PLAN.md that the worker agent should also have the ability to…
- User
Check @IMPLEMENTATION_PLAN.md that the worker agent should also have the ability to determine if it a ticket given to it Needs Research, Needs Specification, Needs Plan, Needs Implement, Needs Validate, and the same for In Progress Statuses, and also should have Intervention Statuses for when requiring human action.
Assistant
Let me look at the current worker prompts and the Horizon reference to understand the existing stage system before proposing changes.
Assistant
Good finding. The plan currently uses a flat 4-status model (
Backlog,In Progress,Done,Blocked), but the Horizon reference has granular per-stage statuses. The worker needs to know which stage to execute and report back the next status. Here's what's missing:Current plan (line 90):
Replace Linear status names (
∞ Backlog,∞ Research In Progress, etc.) with simple statuses:Backlog,In Progress,Done,BlockedThis oversimplifies it — collapsing all stages into a single
In Progressmeans the orchestrator can't route the worker to the correct stage prompt.Let me update the plan to add the granular status model.
Assistant
Now let me make the changes. I'll update three sections:
- Adaptation Guidelines — replace the "simple statuses" guidance with the full stage-based status model
- TaskRequest interface — change
status: stringto use the stage-aware status enum - Add a new section documenting the status model and stage transitions
Assistant
Now add the full Task Status Model section after the
TaskRequestinterface section:Assistant
Now update the Orchestrator section (Phase 3) to reflect the stage-aware dispatch instead of the single-shot worker model:
Assistant
Now update the Spec Agent ticket writing to use
Needs Researchinstead ofBacklog:Assistant
Now update the
executeWorkersection to reflect stage-aware dispatch:Assistant
Now update the Files table at the bottom to reflect the new
TaskStatusenum file:Assistant
Now update the Variant Support table to reflect the stage-aware changes:
Assistant
Let me verify the full updated plan reads coherently:
Assistant
The plan is coherent. Let me also check that the Verification section reflects stage-aware testing:
Assistant
Here's a summary of what I added to the plan:
Changes Made to
IMPLEMENTATION_PLAN.md-
Task Status Model section (new) — Full
TaskStatusenum with 16 statuses across 4 categories:- Stage statuses:
Needs Research/Research In Progress,Needs Specification/Specification In Progress,Needs Plan/Plan In Progress,Needs Implement/Implement In Progress,Needs Validate/Validate In Progress,Oneshot In Progress - Terminal statuses:
Done,Awaiting Merge - Intervention statuses:
Blocked,Needs Human Review,
- Stage statuses:
-
- User
that being said, does the current implementation plan allow the Spec Agent to judge if a ticket needs research/specification/plan/implement/validate, and say after the worker completes research/specification/plan/implement/validate, and updates to a non-terminal status, this same ticket can continue to be worked on by the next independent worker agent that picks up this ticket?
currently this is how Horizon Agent works, and napoli-matcha should also have this capability.
Assistant
Good question. Let me re-read the relevant sections to check both points.
Assistant
Here's my analysis:
Point 2 (independent worker per stage): YES, it works. The
processQueueloop already supports this. After Worker A finishes the Research stage and setsnext_status: "Needs Plan", the orchestrator updates the MD file, and the next loop iteration finds it vialoadActionableTasks()and dispatches a fresh Worker B for the Plan stage. Each stage is a separate, independent worker invocation — no session affinity.Point 1 (Spec Agent judging initial stage): NO, it's missing. The plan hard-codes
status: Needs Researchfor all new tickets (line 354-356). The Spec Agent does thorough quality assessment (5 criteria, clarification loop), but then always forces every ticket through Research anyway — which is redundant for well-specified tickets.There are two things to fix:
- Spec Agent should set the initial
statusbased on how well-specified the ticket is (e.g., a ticket with detailed implementation steps can start atNeeds Implement) - Make it explicit that each stage is a separate, independent worker invocation (the architecture supports it but the plan doesn't call it out clearly as a design principle)
- Spec Agent should set the initial
Assistant
Now update the Spec Agent prompt to include the
start_statusfield in its ticket output:Assistant
Now update the ticket MD example to include
start_status:Assistant
Now update the
TaskRequestinterface to includestartStatus:Assistant
Let me verify the final state of the full plan is consistent:
Assistant
The plan now covers both capabilities. Let me do a quick consistency check on the verification section:
Assistant
Let me fix the numbering:
Assistant
Here's a summary of what was missing and what I added:
What was missing
-
No independent worker handoff — The plan had the architecture for it (loop + stage dispatch) but never explicitly stated that each stage is a separate, stateless worker invocation. This is the core Horizon pattern.
-
Spec Agent couldn't set initial stage — All tickets were hard-coded to start at
Needs Research, even when the Spec Agent had already done thorough quality assessment and the human provided detailed implementation steps.
What I added
"Independent Worker Per Stage (Horizon Pattern)" section — Explicit 7-step walkthrough of how Worker A hands off to Worker B via the MD file status field. Calls out that workers are stateless, parallelizable, and crash-recoverable.
"Spec Agent Sets Initial Stage" section — The Spec Agent now outputs a
start_statusper ticket with 4 levels of stage-skipping:-
- User
Double check that even with this new enhancement, chain group dependencies implementation will still be robust.
Assistant
Let me trace through the chain group logic with the new stage-aware model to find any inconsistencies.
Assistant
Now let me read the variant example to trace through with the new model:
Assistant
Now let me also check the
loadActionableTasksandactivemap logic:Assistant
I've traced through the full chain group flow with the stage-aware model. I found 3 bugs:
Bug 1:
isTerminal()uses stale status namestypescript["Backlog", "In Progress"].includes(t.status)With the new model, there's no single
"In Progress"status — there are"Research In Progress","Plan In Progress", etc. And"Backlog"is barely used (tickets start at"Needs Research"or later). This would incorrectly mark non-terminal tickets as terminal because the downstream dependent ticket (e.g., in"Needs Research") wouldn't match"Backlog"or"In Progress".Bug 2: Variant example doesn't account for multi-stage cycling
The example at line 786 shows
t=0: AGI-5 dispatched → t=1: AGI-5 Done → AGI-6 eligible. But with stage-aware dispatch, AGI-5 goes through Research → Plan → Implement → Validate → Done, which is 4+ dispatch cycles, not 1. The example is misleading and the dependency check for AGI-6 won't trigger until AGI-5 reaches — but the example implies it happens in one step.Assistant
Now fix the variant example to show the multi-stage reality:
Assistant
Now let me also check if there's a subtle issue with the
loadActionableTasks+filterEligibleinteraction when a ticket in a chain is mid-stage:Assistant
There's one more subtle issue I want to check. The
filterEligibledependency check does:typescriptconst dep = tasks.find(t => t.id === depId); return !dep || dep.status === "Done";But
tasksis loaded fromloadActionableTasks()which only returnsNeeds *statuses. A dependency inResearch In Progresswouldn't be intasks(it's not aNeeds *status), AND it wouldn't be in theactivemap if there's a process restart. Let me check this edge case.Assistant
Found Bug 3 (a real one this time):
filterEligiblecan't see dependencies in* In Progressor intervention statuses after a process restart.The issue:
loadActionableTasks()only returns tasks inNeeds *statusesactivemap is in-memory only — lost on process restart- A dependency in
Research In Progresswould be: NOT intasks(not aNeeds *status), NOT inactive(lost on restart) →!depreturnstrue→ incorrectly treated as satisfied
This means: if the orchestrator crashes and restarts while AGI-5 is in
Research In Progress, the dependent AGI-6 would see AGI-5 as "satisfied" and start prematurely.The fix:
filterEligibleneeds to check dependencies against all tasks (all statuses), not just the actionable ones.Assistant
Now update the
processQueuecode to match:Assistant
Also update the
loadActionableTaskssection to mention that both loaders are needed:Assistant
Let me do a final read-through of the chain-critical sections to make sure everything is consistent:
Assistant
Everything is now consistent. Let me summarize the bugs found and fixed:
Here's what I found and fixed:
Bug 1:
isTerminal()used stale status whitelist (FIXED)Before:
["Backlog", "In Progress"].includes(t.status)— only matched 2 of 16+ statuses. A dependent ticket inNeeds ResearchorPlan In Progresswould be invisible, causing premature PR creation on non-terminal tickets.After:
t.status !== TaskStatus.Done— the only status that means "dependency chain complete" isDone. Everything else blocks.