claude-code-workflow 7.2.23 → 7.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/.codex/skills/team-arch-opt/SKILL.md +242 -175
  2. package/.codex/skills/team-arch-opt/roles/analyzer/role.md +78 -78
  3. package/.codex/skills/team-arch-opt/roles/coordinator/commands/analyze.md +57 -57
  4. package/.codex/skills/team-arch-opt/roles/coordinator/commands/monitor.md +246 -204
  5. package/.codex/skills/team-arch-opt/roles/coordinator/role.md +196 -184
  6. package/.codex/skills/team-arch-opt/roles/designer/role.md +115 -115
  7. package/.codex/skills/team-arch-opt/roles/refactorer/role.md +102 -102
  8. package/.codex/skills/team-arch-opt/roles/reviewer/role.md +111 -111
  9. package/.codex/skills/team-arch-opt/roles/validator/role.md +115 -115
  10. package/.codex/skills/team-arch-opt/specs/pipelines.md +102 -102
  11. package/.codex/skills/team-brainstorm/SKILL.md +72 -4
  12. package/.codex/skills/team-brainstorm/roles/challenger/role.md +61 -61
  13. package/.codex/skills/team-brainstorm/roles/coordinator/commands/analyze.md +58 -58
  14. package/.codex/skills/team-brainstorm/roles/coordinator/commands/monitor.md +212 -171
  15. package/.codex/skills/team-brainstorm/roles/coordinator/role.md +172 -160
  16. package/.codex/skills/team-brainstorm/roles/evaluator/role.md +56 -56
  17. package/.codex/skills/team-brainstorm/roles/ideator/role.md +69 -69
  18. package/.codex/skills/team-brainstorm/roles/synthesizer/role.md +57 -57
  19. package/.codex/skills/team-brainstorm/specs/pipelines.md +72 -72
  20. package/.codex/skills/team-coordinate/SKILL.md +71 -3
  21. package/.codex/skills/team-coordinate/roles/coordinator/commands/monitor.md +45 -5
  22. package/.codex/skills/team-coordinate/roles/coordinator/role.md +402 -389
  23. package/.codex/skills/team-coordinate/specs/knowledge-transfer.md +111 -111
  24. package/.codex/skills/team-coordinate/specs/pipelines.md +97 -97
  25. package/.codex/skills/team-coordinate/specs/quality-gates.md +112 -112
  26. package/.codex/skills/team-designer/SKILL.md +153 -153
  27. package/.codex/skills/team-designer/phases/01-requirements-analysis.md +250 -250
  28. package/.codex/skills/team-designer/phases/02-scaffold-generation.md +228 -228
  29. package/.codex/skills/team-designer/phases/03-content-generation.md +330 -330
  30. package/.codex/skills/team-designer/phases/04-validation.md +320 -320
  31. package/.codex/skills/team-executor/SKILL.md +29 -2
  32. package/.codex/skills/team-executor/roles/executor/commands/monitor.md +23 -15
  33. package/.codex/skills/team-frontend/SKILL.md +77 -3
  34. package/.codex/skills/team-frontend/roles/analyst/role.md +92 -92
  35. package/.codex/skills/team-frontend/roles/architect/role.md +86 -86
  36. package/.codex/skills/team-frontend/roles/coordinator/commands/analyze.md +52 -52
  37. package/.codex/skills/team-frontend/roles/coordinator/commands/monitor.md +222 -188
  38. package/.codex/skills/team-frontend/roles/coordinator/role.md +189 -177
  39. package/.codex/skills/team-frontend/roles/developer/role.md +93 -93
  40. package/.codex/skills/team-frontend/roles/qa/role.md +79 -79
  41. package/.codex/skills/team-frontend/specs/pipelines.md +76 -76
  42. package/.codex/skills/team-frontend-debug/SKILL.md +66 -3
  43. package/.codex/skills/team-frontend-debug/roles/analyzer/role.md +208 -208
  44. package/.codex/skills/team-frontend-debug/roles/coordinator/commands/analyze.md +174 -174
  45. package/.codex/skills/team-frontend-debug/roles/coordinator/commands/dispatch.md +198 -198
  46. package/.codex/skills/team-frontend-debug/roles/coordinator/commands/monitor.md +177 -143
  47. package/.codex/skills/team-frontend-debug/roles/coordinator/role.md +164 -152
  48. package/.codex/skills/team-frontend-debug/roles/fixer/role.md +147 -147
  49. package/.codex/skills/team-frontend-debug/roles/reproducer/role.md +147 -147
  50. package/.codex/skills/team-frontend-debug/roles/tester/role.md +231 -231
  51. package/.codex/skills/team-frontend-debug/roles/verifier/role.md +172 -172
  52. package/.codex/skills/team-frontend-debug/specs/debug-tools.md +215 -215
  53. package/.codex/skills/team-frontend-debug/specs/pipelines.md +94 -94
  54. package/.codex/skills/team-issue/SKILL.md +83 -4
  55. package/.codex/skills/team-issue/roles/coordinator/commands/analyze.md +64 -64
  56. package/.codex/skills/team-issue/roles/coordinator/commands/dispatch.md +273 -273
  57. package/.codex/skills/team-issue/roles/coordinator/commands/monitor.md +235 -194
  58. package/.codex/skills/team-issue/roles/coordinator/role.md +206 -194
  59. package/.codex/skills/team-issue/roles/explorer/role.md +94 -94
  60. package/.codex/skills/team-issue/roles/implementer/role.md +87 -87
  61. package/.codex/skills/team-issue/roles/integrator/role.md +84 -84
  62. package/.codex/skills/team-issue/roles/planner/role.md +81 -81
  63. package/.codex/skills/team-issue/roles/reviewer/role.md +86 -86
  64. package/.codex/skills/team-issue/specs/pipelines.md +124 -124
  65. package/.codex/skills/team-iterdev/SKILL.md +64 -3
  66. package/.codex/skills/team-iterdev/roles/architect/role.md +65 -65
  67. package/.codex/skills/team-iterdev/roles/coordinator/commands/analyze.md +62 -62
  68. package/.codex/skills/team-iterdev/roles/coordinator/commands/monitor.md +227 -186
  69. package/.codex/skills/team-iterdev/roles/coordinator/role.md +193 -181
  70. package/.codex/skills/team-iterdev/roles/developer/role.md +74 -74
  71. package/.codex/skills/team-iterdev/roles/reviewer/role.md +66 -66
  72. package/.codex/skills/team-iterdev/roles/tester/role.md +88 -88
  73. package/.codex/skills/team-iterdev/specs/pipelines.md +94 -94
  74. package/.codex/skills/team-lifecycle-v4/MIGRATION-PLAN.md +6 -6
  75. package/.codex/skills/team-lifecycle-v4/SKILL.md +305 -242
  76. package/.codex/skills/team-lifecycle-v4/roles/coordinator/commands/dispatch.md +1 -1
  77. package/.codex/skills/team-lifecycle-v4/roles/coordinator/commands/monitor.md +66 -24
  78. package/.codex/skills/team-lifecycle-v4/roles/coordinator/role.md +13 -1
  79. package/.codex/skills/team-lifecycle-v4/roles/supervisor/role.md +1 -1
  80. package/.codex/skills/team-lifecycle-v4/templates/architecture.md +254 -254
  81. package/.codex/skills/team-lifecycle-v4/templates/epics.md +196 -196
  82. package/.codex/skills/team-lifecycle-v4/templates/product-brief.md +133 -133
  83. package/.codex/skills/team-lifecycle-v4/templates/requirements.md +224 -224
  84. package/.codex/skills/team-perf-opt/SKILL.md +68 -3
  85. package/.codex/skills/team-perf-opt/roles/benchmarker/role.md +89 -89
  86. package/.codex/skills/team-perf-opt/roles/coordinator/commands/analyze.md +61 -61
  87. package/.codex/skills/team-perf-opt/roles/coordinator/commands/monitor.md +35 -1
  88. package/.codex/skills/team-perf-opt/roles/coordinator/role.md +179 -167
  89. package/.codex/skills/team-perf-opt/roles/optimizer/role.md +97 -97
  90. package/.codex/skills/team-perf-opt/roles/profiler/role.md +73 -73
  91. package/.codex/skills/team-perf-opt/roles/reviewer/role.md +75 -75
  92. package/.codex/skills/team-perf-opt/roles/strategist/role.md +94 -94
  93. package/.codex/skills/team-perf-opt/specs/pipelines.md +65 -65
  94. package/.codex/skills/team-planex/SKILL.md +65 -3
  95. package/.codex/skills/team-planex/roles/coordinator/commands/analyze.md +52 -52
  96. package/.codex/skills/team-planex/roles/coordinator/commands/monitor.md +210 -164
  97. package/.codex/skills/team-planex/roles/coordinator/role.md +171 -159
  98. package/.codex/skills/team-planex/roles/executor/role.md +91 -91
  99. package/.codex/skills/team-planex/roles/planner/role.md +112 -112
  100. package/.codex/skills/team-planex/specs/pipelines.md +93 -93
  101. package/.codex/skills/team-quality-assurance/SKILL.md +60 -3
  102. package/.codex/skills/team-quality-assurance/roles/analyst/role.md +80 -80
  103. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/analyze.md +72 -72
  104. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/dispatch.md +108 -108
  105. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/monitor.md +243 -209
  106. package/.codex/skills/team-quality-assurance/roles/coordinator/role.md +176 -164
  107. package/.codex/skills/team-quality-assurance/roles/executor/role.md +66 -66
  108. package/.codex/skills/team-quality-assurance/roles/generator/role.md +68 -68
  109. package/.codex/skills/team-quality-assurance/roles/scout/role.md +67 -67
  110. package/.codex/skills/team-quality-assurance/roles/strategist/role.md +71 -71
  111. package/.codex/skills/team-quality-assurance/specs/pipelines.md +115 -115
  112. package/.codex/skills/team-review/SKILL.md +58 -3
  113. package/.codex/skills/team-review/roles/coordinator/commands/analyze.md +71 -71
  114. package/.codex/skills/team-review/roles/coordinator/commands/dispatch.md +90 -90
  115. package/.codex/skills/team-review/roles/coordinator/commands/monitor.md +225 -185
  116. package/.codex/skills/team-review/roles/coordinator/role.md +175 -163
  117. package/.codex/skills/team-review/roles/fixer/role.md +76 -76
  118. package/.codex/skills/team-review/roles/reviewer/role.md +68 -68
  119. package/.codex/skills/team-review/roles/scanner/role.md +71 -71
  120. package/.codex/skills/team-review/specs/pipelines.md +102 -102
  121. package/.codex/skills/team-roadmap-dev/SKILL.md +55 -3
  122. package/.codex/skills/team-roadmap-dev/roles/coordinator/commands/analyze.md +61 -61
  123. package/.codex/skills/team-roadmap-dev/roles/coordinator/commands/monitor.md +502 -468
  124. package/.codex/skills/team-roadmap-dev/roles/coordinator/role.md +335 -322
  125. package/.codex/skills/team-roadmap-dev/roles/executor/role.md +71 -71
  126. package/.codex/skills/team-roadmap-dev/roles/planner/role.md +76 -76
  127. package/.codex/skills/team-roadmap-dev/roles/verifier/role.md +74 -74
  128. package/.codex/skills/team-roadmap-dev/specs/pipelines.md +93 -93
  129. package/.codex/skills/team-tech-debt/SKILL.md +56 -3
  130. package/.codex/skills/team-tech-debt/roles/assessor/role.md +69 -69
  131. package/.codex/skills/team-tech-debt/roles/coordinator/commands/analyze.md +47 -47
  132. package/.codex/skills/team-tech-debt/roles/coordinator/commands/monitor.md +272 -231
  133. package/.codex/skills/team-tech-debt/roles/coordinator/role.md +172 -160
  134. package/.codex/skills/team-tech-debt/roles/executor/role.md +76 -76
  135. package/.codex/skills/team-tech-debt/roles/planner/role.md +69 -69
  136. package/.codex/skills/team-tech-debt/roles/scanner/role.md +82 -82
  137. package/.codex/skills/team-tech-debt/roles/validator/role.md +75 -75
  138. package/.codex/skills/team-tech-debt/specs/pipelines.md +47 -47
  139. package/.codex/skills/team-testing/SKILL.md +72 -3
  140. package/.codex/skills/team-testing/roles/analyst/role.md +95 -95
  141. package/.codex/skills/team-testing/roles/coordinator/commands/analyze.md +70 -70
  142. package/.codex/skills/team-testing/roles/coordinator/commands/dispatch.md +106 -106
  143. package/.codex/skills/team-testing/roles/coordinator/commands/monitor.md +283 -242
  144. package/.codex/skills/team-testing/roles/coordinator/role.md +184 -172
  145. package/.codex/skills/team-testing/roles/executor/role.md +96 -96
  146. package/.codex/skills/team-testing/roles/generator/role.md +95 -95
  147. package/.codex/skills/team-testing/roles/strategist/role.md +83 -83
  148. package/.codex/skills/team-testing/specs/pipelines.md +101 -101
  149. package/.codex/skills/team-uidesign/SKILL.md +65 -3
  150. package/.codex/skills/team-uidesign/roles/coordinator/commands/analyze.md +59 -59
  151. package/.codex/skills/team-uidesign/roles/coordinator/commands/dispatch.md +156 -156
  152. package/.codex/skills/team-uidesign/roles/coordinator/commands/monitor.md +234 -194
  153. package/.codex/skills/team-uidesign/roles/coordinator/role.md +211 -199
  154. package/.codex/skills/team-uidesign/roles/designer/role.md +69 -69
  155. package/.codex/skills/team-uidesign/roles/implementer/role.md +72 -72
  156. package/.codex/skills/team-uidesign/roles/researcher/role.md +82 -82
  157. package/.codex/skills/team-uidesign/roles/reviewer/role.md +67 -67
  158. package/.codex/skills/team-uidesign/specs/pipelines.md +76 -76
  159. package/.codex/skills/team-ultra-analyze/SKILL.md +73 -3
  160. package/.codex/skills/team-ultra-analyze/roles/analyst/role.md +90 -90
  161. package/.codex/skills/team-ultra-analyze/roles/coordinator/commands/analyze.md +73 -73
  162. package/.codex/skills/team-ultra-analyze/roles/coordinator/commands/monitor.md +50 -9
  163. package/.codex/skills/team-ultra-analyze/roles/coordinator/role.md +255 -243
  164. package/.codex/skills/team-ultra-analyze/roles/discussant/role.md +104 -104
  165. package/.codex/skills/team-ultra-analyze/roles/explorer/role.md +74 -74
  166. package/.codex/skills/team-ultra-analyze/roles/synthesizer/role.md +78 -78
  167. package/.codex/skills/team-ultra-analyze/specs/pipelines.md +64 -64
  168. package/.codex/skills/team-ux-improve/SKILL.md +64 -3
  169. package/.codex/skills/team-ux-improve/roles/coordinator/commands/analyze.md +62 -62
  170. package/.codex/skills/team-ux-improve/roles/coordinator/commands/dispatch.md +233 -233
  171. package/.codex/skills/team-ux-improve/roles/coordinator/commands/monitor.md +195 -160
  172. package/.codex/skills/team-ux-improve/roles/coordinator/role.md +170 -158
  173. package/.codex/skills/team-ux-improve/roles/designer/role.md +122 -122
  174. package/.codex/skills/team-ux-improve/roles/diagnoser/role.md +93 -93
  175. package/.codex/skills/team-ux-improve/roles/explorer/role.md +77 -77
  176. package/.codex/skills/team-ux-improve/roles/implementer/role.md +102 -102
  177. package/.codex/skills/team-ux-improve/roles/scanner/role.md +93 -93
  178. package/.codex/skills/team-ux-improve/roles/tester/role.md +84 -84
  179. package/.codex/skills/team-ux-improve/specs/pipelines.md +54 -54
  180. package/README.md +1 -0
  181. package/package.json +1 -1
@@ -1,468 +1,502 @@
1
- # Command: Monitor
2
-
3
- Handle all coordinator monitoring events for the roadmap-dev pipeline using the async Spawn-and-Stop pattern. Multi-phase execution with gap closure expressed as event-driven state machine transitions. One operation per invocation, then STOP and wait for the next callback.
4
-
5
- ## Constants
6
-
7
- | Key | Value | Description |
8
- |-----|-------|-------------|
9
- | SPAWN_MODE | background | All workers spawned via `spawn_agent()` |
10
- | ONE_STEP_PER_INVOCATION | true | Coordinator does one operation then STOPS |
11
- | WORKER_AGENT | team_worker | All workers spawned as team_worker agents |
12
- | MAX_GAP_ITERATIONS | 3 | Maximum gap closure re-plan/exec/verify cycles per phase |
13
-
14
- ### Role-Worker Map
15
-
16
- | Prefix | Role | Role Spec | inner_loop |
17
- |--------|------|-----------|------------|
18
- | PLAN | planner | `~ or <project>/.codex/skills/team-roadmap-dev/roles/planner/role.md` | true (cli_tools: gemini --mode analysis) |
19
- | EXEC | executor | `~ or <project>/.codex/skills/team-roadmap-dev/roles/executor/role.md` | true (cli_tools: gemini --mode write) |
20
- | VERIFY | verifier | `~ or <project>/.codex/skills/team-roadmap-dev/roles/verifier/role.md` | true |
21
-
22
- ### Pipeline Structure
23
-
24
- Per-phase task chain: `PLAN-{phase}01 -> EXEC-{phase}01 -> VERIFY-{phase}01`
25
-
26
- Gap closure creates: `PLAN-{phase}0N -> EXEC-{phase}0N -> VERIFY-{phase}0N` (N = iteration + 1)
27
-
28
- Multi-phase: Phases execute sequentially. Each phase completes its full PLAN/EXEC/VERIFY cycle (including gap closure) before the next phase is dispatched.
29
-
30
- ### State Machine Coordinates
31
-
32
- The coordinator tracks its position using these state variables in `meta.json`:
33
-
34
- ```
35
- session.coordinates = {
36
- current_phase: <number>, // Active phase (1-based)
37
- total_phases: <number>, // Total phases from roadmap
38
- gap_iteration: <number>, // Current gap closure iteration within phase (0 = initial)
39
- step: <string>, // Current step: "plan" | "exec" | "verify" | "gap_closure" | "transition"
40
- status: <string> // "running" | "paused" | "complete"
41
- }
42
- ```
43
-
44
- ## Phase 2: Context Loading
45
-
46
- | Input | Source | Required |
47
- |-------|--------|----------|
48
- | Session file | `<session-folder>/.msg/meta.json` | Yes |
49
- | Task list | `<session>/tasks.json` | Yes |
50
- | Active workers | session.active_workers[] | Yes |
51
- | Coordinates | session.coordinates | Yes |
52
- | Config | `<session-folder>/config.json` | Yes |
53
- | State | `<session-folder>/state.md` | Yes |
54
-
55
- ```
56
- Load session state:
57
- 1. Read <session-folder>/.msg/meta.json -> session
58
- 2. Read <session-folder>/config.json -> config
59
- 3. Read <session>/tasks.json -> allTasks
60
- 4. Extract coordinates from session (current_phase, gap_iteration, step)
61
- 5. Extract active_workers[] from session (default: [])
62
- 6. Parse $ARGUMENTS to determine trigger event
63
- ```
64
-
65
- ## Phase 3: Event Handlers
66
-
67
- ### Wake-up Source Detection
68
-
69
- Parse `$ARGUMENTS` to determine handler:
70
-
71
- | Priority | Condition | Handler |
72
- |----------|-----------|---------|
73
- | 1 | Message contains `[planner]`, `[executor]`, or `[verifier]` | handleCallback |
74
- | 2 | Contains "check" or "status" | handleCheck |
75
- | 3 | Contains "resume", "continue", or "next" | handleResume |
76
- | 4 | Pipeline detected as complete (all phases done) | handleComplete |
77
- | 5 | None of the above (initial spawn after dispatch) | handleSpawnNext |
78
-
79
- ---
80
-
81
- ### Handler: handleCallback
82
-
83
- Worker completed a task. Determine which step completed via prefix, apply pipeline logic, advance.
84
-
85
- ```
86
- Receive callback from [<role>]
87
- +- Find matching active worker by role tag
88
- +- Is this a progress update (not final)? (Inner Loop intermediate)
89
- | +- YES -> Update session state -> STOP
90
- +- Task status = completed?
91
- | +- YES -> remove from active_workers -> update session
92
- | | +- Update task in tasks.json: set status = "completed"
93
- | | +- Determine completed step from task prefix:
94
- | | |
95
- | | +- PLAN-* completed:
96
- | | | +- Update coordinates.step = "plan_done"
97
- | | | +- Is this initial plan (gap_iteration === 0)?
98
- | | | | +- YES + config.gates.plan_check?
99
- | | | | | +- request_user_input:
100
- | | | | | prompt: "Phase <N> plan ready. Proceed with execution?
101
- | | | | | Options:
102
- | | | | | 1. Proceed - Continue to execution
103
- | | | | | 2. Revise - Create new PLAN task with incremented suffix
104
- | | | | | 3. Skip phase - Delete all phase tasks"
105
- | | | | | -> "Proceed": -> handleSpawnNext (spawns EXEC)
106
- | | | | | -> "Revise": Create new PLAN task in tasks.json
107
- | | | | | blockedBy: [] (immediate), -> handleSpawnNext
108
- | | | | | -> "Skip phase": Remove all phase tasks from tasks.json
109
- | | | | | -> advanceToNextPhase
110
- | | | | +- NO (gap closure plan) -> handleSpawnNext (spawns EXEC)
111
- | | | +- -> handleSpawnNext
112
- | | |
113
- | | +- EXEC-* completed:
114
- | | | +- Update coordinates.step = "exec_done"
115
- | | | +- -> handleSpawnNext (spawns VERIFY)
116
- | | |
117
- | | +- VERIFY-* completed:
118
- | | +- Update coordinates.step = "verify_done"
119
- | | +- Read verification result from:
120
- | | | <session-folder>/phase-<N>/verification.md
121
- | | +- Parse gaps from verification
122
- | | +- Gaps found?
123
- | | +- NO -> Phase passed
124
- | | | +- -> advanceToNextPhase
125
- | | +- YES + gap_iteration < MAX_GAP_ITERATIONS?
126
- | | | +- -> triggerGapClosure
127
- | | +- YES + gap_iteration >= MAX_GAP_ITERATIONS?
128
- | | +- request_user_input:
129
- | | prompt: "Phase <N> still has <count> gaps after <max> attempts.
130
- | | Options:
131
- | | 1. Continue anyway - Accept and advance to next phase
132
- | | 2. Retry once more - Increment max and try again
133
- | | 3. Stop - Pause session"
134
- | | -> "Continue anyway": Accept, -> advanceToNextPhase
135
- | | -> "Retry once more": Increment max, -> triggerGapClosure
136
- | | -> "Stop": -> pauseSession
137
- | |
138
- | +- NO -> progress message -> STOP
139
- +- No matching worker found
140
- +- Scan all active workers for completed tasks
141
- +- Found completed -> process each (same logic above) -> handleSpawnNext
142
- +- None completed -> STOP
143
- ```
144
-
145
- **Sub-procedure: advanceToNextPhase**
146
-
147
- ```
148
- advanceToNextPhase:
149
- +- Update state.md: mark current phase completed
150
- +- current_phase < total_phases?
151
- | +- YES:
152
- | | +- config.mode === "interactive"?
153
- | | | +- request_user_input:
154
- | | | prompt: "Phase <N> complete. Proceed to phase <N+1>?
155
- | | | Options:
156
- | | | 1. Proceed - Dispatch next phase tasks
157
- | | | 2. Review results - Output phase summary, re-ask
158
- | | | 3. Stop - Pause session"
159
- | | | -> "Proceed": Dispatch next phase tasks, -> handleSpawnNext
160
- | | | -> "Review results": Output phase summary, re-ask
161
- | | | -> "Stop": -> pauseSession
162
- | | +- Auto mode: Dispatch next phase tasks directly
163
- | | +- Update coordinates:
164
- | | current_phase++, gap_iteration=0, step="plan"
165
- | | +- Dispatch new phase tasks (PLAN/EXEC/VERIFY with blockedBy) to tasks.json
166
- | | +- -> handleSpawnNext
167
- | +- NO -> All phases done -> handleComplete
168
- ```
169
-
170
- **Sub-procedure: triggerGapClosure**
171
-
172
- ```
173
- triggerGapClosure:
174
- +- Increment coordinates.gap_iteration
175
- +- suffix = "0" + (gap_iteration + 1)
176
- +- phase = coordinates.current_phase
177
- +- Read gaps from verification.md
178
- +- Log: team_msg gap_closure
179
- +- Create gap closure task chain in tasks.json:
180
- |
181
- | Add to tasks.json: {
182
- | id: "PLAN-{phase}{suffix}",
183
- | subject: "PLAN-{phase}{suffix}: Gap closure for phase {phase} (iteration {gap_iteration})",
184
- | status: "pending",
185
- | owner: "planner",
186
- | blockedBy: [],
187
- | description: includes gap list, references to previous verification
188
- | }
189
- |
190
- | Add to tasks.json: {
191
- | id: "EXEC-{phase}{suffix}",
192
- | subject: "EXEC-{phase}{suffix}: Execute gap fixes for phase {phase}",
193
- | status: "pending",
194
- | owner: "executor",
195
- | blockedBy: ["PLAN-{phase}{suffix}"]
196
- | }
197
- |
198
- | Add to tasks.json: {
199
- | id: "VERIFY-{phase}{suffix}",
200
- | subject: "VERIFY-{phase}{suffix}: Verify gap closure for phase {phase}",
201
- | status: "pending",
202
- | owner: "verifier",
203
- | blockedBy: ["EXEC-{phase}{suffix}"]
204
- | }
205
- |
206
- | Write updated tasks.json
207
- |
208
- +- Update coordinates.step = "gap_closure"
209
- +- -> handleSpawnNext (picks up the new PLAN task)
210
- ```
211
-
212
- **Sub-procedure: pauseSession**
213
-
214
- ```
215
- pauseSession:
216
- +- Save coordinates to meta.json (phase, step, gap_iteration)
217
- +- Update coordinates.status = "paused"
218
- +- Update state.md with pause marker
219
- +- team_msg log -> session_paused
220
- +- Output: "Session paused at phase <N>, step <step>. Resume with 'resume'."
221
- +- STOP
222
- ```
223
-
224
- ---
225
-
226
- ### Handler: handleSpawnNext
227
-
228
- Find all ready tasks, spawn team_worker agent, update session, STOP.
229
-
230
- ```
231
- Read tasks from <session>/tasks.json
232
- +- completedSubjects: status = completed
233
- +- inProgressSubjects: status = in_progress
234
- +- readySubjects: status = pending
235
- AND (no blockedBy OR all blockedBy in completedSubjects)
236
-
237
- Ready tasks found?
238
- +- NONE + work in progress -> report waiting -> STOP
239
- +- NONE + nothing in progress:
240
- | +- More phases to dispatch? -> advanceToNextPhase
241
- | +- No more phases -> handleComplete
242
- +- HAS ready tasks -> take first ready task:
243
- +- Is task owner an Inner Loop role AND that role already has active_worker?
244
- | +- YES -> SKIP spawn (existing worker picks it up via inner loop)
245
- | +- NO -> normal spawn below
246
- +- Determine role from prefix:
247
- | PLAN-* -> planner
248
- | EXEC-* -> executor
249
- | VERIFY-* -> verifier
250
- +- Update task status to "in_progress" in tasks.json
251
- +- team_msg log -> task_unblocked (team_session_id=<session-id>)
252
- +- Spawn team_worker (see spawn call below)
253
- +- Add to session.active_workers
254
- +- Update session file
255
- +- Output: "[coordinator] Spawned <role> for <subject>"
256
- +- STOP
257
- ```
258
-
259
- **Spawn worker call** (one per ready task):
260
-
261
- ```
262
- spawn_agent({
263
- agent_type: "team_worker",
264
- items: [{
265
- description: "Spawn <role> worker for <subject>",
266
- team_name: "roadmap-dev",
267
- name: "<role>",
268
- prompt: `## Role Assignment
269
- role: <role>
270
- role_spec: ~ or <project>/.codex/skills/team-roadmap-dev/roles/<role>/role.md
271
- session: <session-folder>
272
- session_id: <session-id>
273
- team_name: roadmap-dev
274
- requirement: <task-description>
275
- inner_loop: true
276
-
277
- ## Current Task
278
- - Task ID: <task-id>
279
- - Task: <subject>
280
- - Phase: <current_phase>
281
- - Gap Iteration: <gap_iteration>
282
-
283
- Read role_spec file to load Phase 2-4 domain instructions.
284
- Execute built-in Phase 1 -> role-spec Phase 2-4 -> built-in Phase 5.`
285
- }]
286
- })
287
- ```
288
-
289
- Workers report results via `report_agent_job_result()`. Coordinator receives results via `wait_agent({ ids })`.
290
-
291
- ---
292
-
293
- ### Handler: handleCheck
294
-
295
- Read-only status report. No pipeline advancement.
296
-
297
- **Output format**:
298
-
299
- ```
300
- [coordinator] Roadmap Pipeline Status
301
- [coordinator] Phase: <current>/<total> | Gap Iteration: <N>/<max>
302
- [coordinator] Progress: <completed>/<total tasks> (<percent>%)
303
-
304
- [coordinator] Current Phase <N> Graph:
305
- PLAN-{N}01: <status-icon> <summary>
306
- EXEC-{N}01: <status-icon> <summary>
307
- VERIFY-{N}01: <status-icon> <summary>
308
- [PLAN-{N}02: <status-icon> (gap closure #1)]
309
- [EXEC-{N}02: <status-icon>]
310
- [VERIFY-{N}02:<status-icon>]
311
-
312
- done=completed >>>=running o=pending x=deleted .=not created
313
-
314
- [coordinator] Phase Summary:
315
- Phase 1: completed
316
- Phase 2: in_progress (step: exec)
317
- Phase 3: not started
318
-
319
- [coordinator] Active Workers:
320
- > <subject> (<role>) - running [inner-loop: N/M tasks done]
321
-
322
- [coordinator] Ready to spawn: <subjects>
323
- [coordinator] Coordinates: phase=<N> step=<step> gap=<iteration>
324
- [coordinator] Commands: 'resume' to advance | 'check' to refresh
325
- ```
326
-
327
- Then STOP.
328
-
329
- ---
330
-
331
- ### Handler: handleResume
332
-
333
- Check active worker completion, process results, advance pipeline. Also handles resume from paused state.
334
-
335
- ```
336
- Check coordinates.status:
337
- +- "paused" -> Restore coordinates, resume from saved position
338
- | Reset coordinates.status = "running"
339
- | -> handleSpawnNext (picks up where it left off)
340
- +- "running" -> Normal resume:
341
- Load active_workers from session
342
- +- No active workers -> handleSpawnNext
343
- +- Has active workers -> check each:
344
- +- status = completed -> mark done, remove from active_workers, log
345
- +- status = in_progress -> still running, log
346
- +- other status -> worker failure -> reset to pending
347
- After processing:
348
- +- Some completed -> handleSpawnNext
349
- +- All still running -> report status -> STOP
350
- +- All failed -> handleSpawnNext (retry)
351
- ```
352
-
353
- ---
354
-
355
- ### Handler: handleComplete
356
-
357
- All phases done. Generate final project summary and finalize session.
358
-
359
- ```
360
- All phases completed (no pending, no in_progress across all phases)
361
- +- Generate project-level summary:
362
- | - Roadmap overview (phases completed)
363
- | - Per-phase results:
364
- | - Gap closure iterations used
365
- | - Verification status
366
- | - Key deliverables
367
- | - Overall stats (tasks completed, phases, total gap iterations)
368
- |
369
- +- Update session:
370
- | coordinates.status = "complete"
371
- | session.completed_at = <timestamp>
372
- | Write meta.json
373
- |
374
- +- Update state.md: mark all phases completed
375
- +- team_msg log -> project_complete
376
- +- Output summary to user
377
- +- STOP
378
- ```
379
-
380
- ---
381
-
382
- ### Worker Failure Handling
383
-
384
- When a worker has unexpected status (not completed, not in_progress):
385
-
386
- 1. Reset task -> pending in tasks.json
387
- 2. Remove from active_workers
388
- 3. Log via team_msg (type: error)
389
- 4. Report to user: task reset, will retry on next resume
390
-
391
- ## Phase 4: State Persistence
392
-
393
- After every handler action, before STOP:
394
-
395
- | Check | Action |
396
- |-------|--------|
397
- | Coordinates updated | current_phase, step, gap_iteration reflect actual state |
398
- | Session state consistent | active_workers matches tasks.json in_progress tasks |
399
- | No orphaned tasks | Every in_progress task has an active_worker entry |
400
- | Meta.json updated | Write updated session state and coordinates |
401
- | State.md updated | Phase progress reflects actual completion |
402
- | Completion detection | All phases done + no pending + no in_progress -> handleComplete |
403
-
404
- ```
405
- Persist:
406
- 1. Update coordinates in meta.json
407
- 2. Reconcile active_workers with actual tasks.json states
408
- 3. Remove entries for completed/deleted tasks
409
- 4. Write updated meta.json
410
- 5. Update state.md if phase status changed
411
- 6. Verify consistency
412
- 7. STOP (wait for next callback)
413
- ```
414
-
415
- ## State Machine Diagram
416
-
417
- ```
418
- [dispatch] -> PLAN-{N}01 spawned
419
- |
420
- [planner callback]
421
- |
422
- plan_check gate? --YES--> request_user_input --> "Revise" --> new PLAN task --> [spawn]
423
- | "Skip" --> advanceToNextPhase
424
- | "Proceed" / no gate
425
- v
426
- EXEC-{N}01 spawned
427
- |
428
- [executor callback]
429
- |
430
- v
431
- VERIFY-{N}01 spawned
432
- |
433
- [verifier callback]
434
- |
435
- gaps found? --NO--> advanceToNextPhase
436
- |
437
- YES + iteration < MAX
438
- |
439
- v
440
- triggerGapClosure:
441
- PLAN-{N}02 -> EXEC-{N}02 -> VERIFY-{N}02
442
- |
443
- [repeat verify check]
444
- |
445
- gaps found? --NO--> advanceToNextPhase
446
- |
447
- YES + iteration >= MAX
448
- |
449
- v
450
- request_user_input: "Continue anyway" / "Retry" / "Stop"
451
-
452
- advanceToNextPhase:
453
- +- phase < total? --YES--> interactive gate? --> dispatch phase+1 --> [spawn PLAN]
454
- +- phase = total? --> handleComplete
455
- ```
456
-
457
- ## Error Handling
458
-
459
- | Scenario | Resolution |
460
- |----------|------------|
461
- | Session file not found | Error, suggest re-initialization |
462
- | Worker callback from unknown role | Log info, scan for other completions |
463
- | All workers still running on resume | Report status, suggest check later |
464
- | Pipeline stall (no ready, no running, has pending) | Check blockedBy chains, report to user |
465
- | Verification file missing | Treat as gap -- verifier may have crashed, re-spawn |
466
- | Phase dispatch fails | Check roadmap integrity, report to user |
467
- | Max gap iterations exceeded | Ask user: continue / retry / stop |
468
- | User chooses "Stop" at any gate | Pause session with coordinates, exit cleanly |
1
+ # Command: Monitor
2
+
3
+ Handle all coordinator monitoring events for the roadmap-dev pipeline using the async Spawn-and-Stop pattern. Multi-phase execution with gap closure expressed as event-driven state machine transitions. One operation per invocation, then STOP and wait for the next callback.
4
+
5
+ ## Constants
6
+
7
+ | Key | Value | Description |
8
+ |-----|-------|-------------|
9
+ | SPAWN_MODE | background | All workers spawned via `spawn_agent()` |
10
+ | ONE_STEP_PER_INVOCATION | true | Coordinator does one operation then STOPS |
11
+ | WORKER_AGENT | team_worker | All workers spawned as team_worker agents |
12
+ | MAX_GAP_ITERATIONS | 3 | Maximum gap closure re-plan/exec/verify cycles per phase |
13
+
14
+ ### Role-Worker Map
15
+
16
+ | Prefix | Role | Role Spec | inner_loop |
17
+ |--------|------|-----------|------------|
18
+ | PLAN | planner | `~ or <project>/.codex/skills/team-roadmap-dev/roles/planner/role.md` | true (cli_tools: gemini --mode analysis) |
19
+ | EXEC | executor | `~ or <project>/.codex/skills/team-roadmap-dev/roles/executor/role.md` | true (cli_tools: gemini --mode write) |
20
+ | VERIFY | verifier | `~ or <project>/.codex/skills/team-roadmap-dev/roles/verifier/role.md` | true |
21
+
22
+ ### Pipeline Structure
23
+
24
+ Per-phase task chain: `PLAN-{phase}01 -> EXEC-{phase}01 -> VERIFY-{phase}01`
25
+
26
+ Gap closure creates: `PLAN-{phase}0N -> EXEC-{phase}0N -> VERIFY-{phase}0N` (N = iteration + 1)
27
+
28
+ Multi-phase: Phases execute sequentially. Each phase completes its full PLAN/EXEC/VERIFY cycle (including gap closure) before the next phase is dispatched.
29
+
30
+ ### State Machine Coordinates
31
+
32
+ The coordinator tracks its position using these state variables in `meta.json`:
33
+
34
+ ```
35
+ session.coordinates = {
36
+ current_phase: <number>, // Active phase (1-based)
37
+ total_phases: <number>, // Total phases from roadmap
38
+ gap_iteration: <number>, // Current gap closure iteration within phase (0 = initial)
39
+ step: <string>, // Current step: "plan" | "exec" | "verify" | "gap_closure" | "transition"
40
+ status: <string> // "running" | "paused" | "complete"
41
+ }
42
+ ```
43
+
44
+ ## Phase 2: Context Loading
45
+
46
+ | Input | Source | Required |
47
+ |-------|--------|----------|
48
+ | Session file | `<session-folder>/.msg/meta.json` | Yes |
49
+ | Task list | `<session>/tasks.json` | Yes |
50
+ | Active workers | session.active_workers[] | Yes |
51
+ | Coordinates | session.coordinates | Yes |
52
+ | Config | `<session-folder>/config.json` | Yes |
53
+ | State | `<session-folder>/state.md` | Yes |
54
+
55
+ ```
56
+ Load session state:
57
+ 1. Read <session-folder>/.msg/meta.json -> session
58
+ 2. Read <session-folder>/config.json -> config
59
+ 3. Read <session>/tasks.json -> allTasks
60
+ 4. Extract coordinates from session (current_phase, gap_iteration, step)
61
+ 5. Extract active_workers[] from session (default: [])
62
+ 6. Parse $ARGUMENTS to determine trigger event
63
+ ```
64
+
65
+ ## Phase 3: Event Handlers
66
+
67
+ ### Wake-up Source Detection
68
+
69
+ Parse `$ARGUMENTS` to determine handler:
70
+
71
+ | Priority | Condition | Handler |
72
+ |----------|-----------|---------|
73
+ | 1 | Message contains `[planner]`, `[executor]`, or `[verifier]` | handleCallback |
74
+ | 2 | Contains "check" or "status" | handleCheck |
75
+ | 3 | Contains "resume", "continue", or "next" | handleResume |
76
+ | 4 | Pipeline detected as complete (all phases done) | handleComplete |
77
+ | 5 | None of the above (initial spawn after dispatch) | handleSpawnNext |
78
+
79
+ ---
80
+
81
+ ### Handler: handleCallback
82
+
83
+ Worker completed a task. Determine which step completed via prefix, apply pipeline logic, advance.
84
+
85
+ ```
86
+ Receive callback from [<role>]
87
+ +- Find matching active worker by role tag
88
+ +- Is this a progress update (not final)? (Inner Loop intermediate)
89
+ | +- YES -> Update session state -> STOP
90
+ +- Task status = completed?
91
+ | +- YES -> remove from active_workers -> update session
92
+ | | +- Update task in tasks.json: set status = "completed"
93
+ | | +- Determine completed step from task prefix:
94
+ | | |
95
+ | | +- PLAN-* completed:
96
+ | | | +- Update coordinates.step = "plan_done"
97
+ | | | +- Is this initial plan (gap_iteration === 0)?
98
+ | | | | +- YES + config.gates.plan_check?
99
+ | | | | | +- request_user_input:
100
+ | | | | | prompt: "Phase <N> plan ready. Proceed with execution?
101
+ | | | | | Options:
102
+ | | | | | 1. Proceed - Continue to execution
103
+ | | | | | 2. Revise - Create new PLAN task with incremented suffix
104
+ | | | | | 3. Skip phase - Delete all phase tasks"
105
+ | | | | | -> "Proceed": -> handleSpawnNext (spawns EXEC)
106
+ | | | | | -> "Revise": Create new PLAN task in tasks.json
107
+ | | | | | blockedBy: [] (immediate), -> handleSpawnNext
108
+ | | | | | -> "Skip phase": Remove all phase tasks from tasks.json
109
+ | | | | | -> advanceToNextPhase
110
+ | | | | +- NO (gap closure plan) -> handleSpawnNext (spawns EXEC)
111
+ | | | +- -> handleSpawnNext
112
+ | | |
113
+ | | +- EXEC-* completed:
114
+ | | | +- Update coordinates.step = "exec_done"
115
+ | | | +- -> handleSpawnNext (spawns VERIFY)
116
+ | | |
117
+ | | +- VERIFY-* completed:
118
+ | | +- Update coordinates.step = "verify_done"
119
+ | | +- Read verification result from:
120
+ | | | <session-folder>/phase-<N>/verification.md
121
+ | | +- Parse gaps from verification
122
+ | | +- Gaps found?
123
+ | | +- NO -> Phase passed
124
+ | | | +- -> advanceToNextPhase
125
+ | | +- YES + gap_iteration < MAX_GAP_ITERATIONS?
126
+ | | | +- -> triggerGapClosure
127
+ | | +- YES + gap_iteration >= MAX_GAP_ITERATIONS?
128
+ | | +- request_user_input:
129
+ | | prompt: "Phase <N> still has <count> gaps after <max> attempts.
130
+ | | Options:
131
+ | | 1. Continue anyway - Accept and advance to next phase
132
+ | | 2. Retry once more - Increment max and try again
133
+ | | 3. Stop - Pause session"
134
+ | | -> "Continue anyway": Accept, -> advanceToNextPhase
135
+ | | -> "Retry once more": Increment max, -> triggerGapClosure
136
+ | | -> "Stop": -> pauseSession
137
+ | |
138
+ | +- NO -> progress message -> STOP
139
+ +- No matching worker found
140
+ +- Scan all active workers for completed tasks
141
+ +- Found completed -> process each (same logic above) -> handleSpawnNext
142
+ +- None completed -> STOP
143
+ ```
144
+
145
+ **Sub-procedure: advanceToNextPhase**
146
+
147
+ ```
148
+ advanceToNextPhase:
149
+ +- Update state.md: mark current phase completed
150
+ +- current_phase < total_phases?
151
+ | +- YES:
152
+ | | +- config.mode === "interactive"?
153
+ | | | +- request_user_input:
154
+ | | | prompt: "Phase <N> complete. Proceed to phase <N+1>?
155
+ | | | Options:
156
+ | | | 1. Proceed - Dispatch next phase tasks
157
+ | | | 2. Review results - Output phase summary, re-ask
158
+ | | | 3. Stop - Pause session"
159
+ | | | -> "Proceed": Dispatch next phase tasks, -> handleSpawnNext
160
+ | | | -> "Review results": Output phase summary, re-ask
161
+ | | | -> "Stop": -> pauseSession
162
+ | | +- Auto mode: Dispatch next phase tasks directly
163
+ | | +- Update coordinates:
164
+ | | current_phase++, gap_iteration=0, step="plan"
165
+ | | +- Dispatch new phase tasks (PLAN/EXEC/VERIFY with blockedBy) to tasks.json
166
+ | | +- -> handleSpawnNext
167
+ | +- NO -> All phases done -> handleComplete
168
+ ```
169
+
170
+ **Sub-procedure: triggerGapClosure**
171
+
172
+ ```
173
+ triggerGapClosure:
174
+ +- Increment coordinates.gap_iteration
175
+ +- suffix = "0" + (gap_iteration + 1)
176
+ +- phase = coordinates.current_phase
177
+ +- Read gaps from verification.md
178
+ +- Log: team_msg gap_closure
179
+ +- Create gap closure task chain in tasks.json:
180
+ |
181
+ | Add to tasks.json: {
182
+ | id: "PLAN-{phase}{suffix}",
183
+ | subject: "PLAN-{phase}{suffix}: Gap closure for phase {phase} (iteration {gap_iteration})",
184
+ | status: "pending",
185
+ | owner: "planner",
186
+ | blockedBy: [],
187
+ | description: includes gap list, references to previous verification
188
+ | }
189
+ |
190
+ | Add to tasks.json: {
191
+ | id: "EXEC-{phase}{suffix}",
192
+ | subject: "EXEC-{phase}{suffix}: Execute gap fixes for phase {phase}",
193
+ | status: "pending",
194
+ | owner: "executor",
195
+ | blockedBy: ["PLAN-{phase}{suffix}"]
196
+ | }
197
+ |
198
+ | Add to tasks.json: {
199
+ | id: "VERIFY-{phase}{suffix}",
200
+ | subject: "VERIFY-{phase}{suffix}: Verify gap closure for phase {phase}",
201
+ | status: "pending",
202
+ | owner: "verifier",
203
+ | blockedBy: ["EXEC-{phase}{suffix}"]
204
+ | }
205
+ |
206
+ | Write updated tasks.json
207
+ |
208
+ +- Update coordinates.step = "gap_closure"
209
+ +- -> handleSpawnNext (picks up the new PLAN task)
210
+ ```
211
+
212
+ **Sub-procedure: pauseSession**
213
+
214
+ ```
215
+ pauseSession:
216
+ +- Save coordinates to meta.json (phase, step, gap_iteration)
217
+ +- Update coordinates.status = "paused"
218
+ +- Update state.md with pause marker
219
+ +- team_msg log -> session_paused
220
+ +- Output: "Session paused at phase <N>, step <step>. Resume with 'resume'."
221
+ +- STOP
222
+ ```
223
+
224
+ ---
225
+
226
+ ### Handler: handleSpawnNext
227
+
228
+ Find all ready tasks, spawn team_worker agent, update session, STOP.
229
+
230
+ ```
231
+ Read tasks from <session>/tasks.json
232
+ +- completedSubjects: status = completed
233
+ +- inProgressSubjects: status = in_progress
234
+ +- readySubjects: status = pending
235
+ AND (no blockedBy OR all blockedBy in completedSubjects)
236
+
237
+ Ready tasks found?
238
+ +- NONE + work in progress -> report waiting -> STOP
239
+ +- NONE + nothing in progress:
240
+ | +- More phases to dispatch? -> advanceToNextPhase
241
+ | +- No more phases -> handleComplete
242
+ +- HAS ready tasks -> take first ready task:
243
+ +- Is task owner an Inner Loop role AND that role already has active_worker?
244
+ | +- YES -> SKIP spawn (existing worker picks it up via inner loop)
245
+ | +- NO -> normal spawn below
246
+ +- Determine role from prefix:
247
+ | PLAN-* -> planner
248
+ | EXEC-* -> executor
249
+ | VERIFY-* -> verifier
250
+ +- Update task status to "in_progress" in tasks.json
251
+ +- team_msg log -> task_unblocked (team_session_id=<session-id>)
252
+ +- Spawn team_worker (see spawn call below)
253
+ +- Add to session.active_workers
254
+ +- Update session file
255
+ +- Output: "[coordinator] Spawned <role> for <subject>"
256
+ +- STOP
257
+ ```
258
+
259
+ **Spawn worker call** (one per ready task):
260
+
261
+ ```
262
+ spawn_agent({
263
+ agent_type: "team_worker",
264
+ task_name: taskId, // e.g., "PLAN-101" — enables named targeting
265
+ items: [{
266
+ description: "Spawn <role> worker for <subject>",
267
+ team_name: "roadmap-dev",
268
+ name: "<role>",
269
+ prompt: `## Role Assignment
270
+ role: <role>
271
+ role_spec: ~ or <project>/.codex/skills/team-roadmap-dev/roles/<role>/role.md
272
+ session: <session-folder>
273
+ session_id: <session-id>
274
+ team_name: roadmap-dev
275
+ requirement: <task-description>
276
+ inner_loop: true
277
+
278
+ ## Current Task
279
+ - Task ID: <task-id>
280
+ - Task: <subject>
281
+ - Phase: <current_phase>
282
+ - Gap Iteration: <gap_iteration>
283
+
284
+ Read role_spec file to load Phase 2-4 domain instructions.
285
+ Execute built-in Phase 1 -> role-spec Phase 2-4 -> built-in Phase 5.`
286
+ }]
287
+ })
288
+ ```
289
+
290
+ Workers report results via `report_agent_job_result()`. Coordinator receives results via `wait_agent({ targets: [taskId], timeout_ms: 900000 })`. If `result.timed_out`, mark tasks as `timed_out` and close agents. Use `close_agent({ target: taskId })` with task_name for cleanup.
291
+
292
+ **Cross-Agent Supplementary Context** (v4):
293
+
294
+ When spawning workers in a later pipeline phase, send upstream results as supplementary context to already-running workers:
295
+
296
+ ```
297
+ // Example: Send planning results to running executor
298
+ send_message({
299
+ target: "<running-agent-task-name>",
300
+ items: [{ type: "text", text: `## Supplementary Context\n${upstreamFindings}` }]
301
+ })
302
+ // Note: send_message queues info without interrupting the agent's current work
303
+ ```
304
+
305
+ Use `send_message` (not `assign_task`) for supplementary info that enriches but doesn't redirect the agent's current task.
306
+
307
+ ---
308
+
309
+ ### Handler: handleCheck
310
+
311
+ Read-only status report. No pipeline advancement.
312
+
313
+ **Output format**:
314
+
315
+ ```
316
+ [coordinator] Roadmap Pipeline Status
317
+ [coordinator] Phase: <current>/<total> | Gap Iteration: <N>/<max>
318
+ [coordinator] Progress: <completed>/<total tasks> (<percent>%)
319
+
320
+ [coordinator] Current Phase <N> Graph:
321
+ PLAN-{N}01: <status-icon> <summary>
322
+ EXEC-{N}01: <status-icon> <summary>
323
+ VERIFY-{N}01: <status-icon> <summary>
324
+ [PLAN-{N}02: <status-icon> (gap closure #1)]
325
+ [EXEC-{N}02: <status-icon>]
326
+ [VERIFY-{N}02:<status-icon>]
327
+
328
+ done=completed >>>=running o=pending x=deleted .=not created
329
+
330
+ [coordinator] Phase Summary:
331
+ Phase 1: completed
332
+ Phase 2: in_progress (step: exec)
333
+ Phase 3: not started
334
+
335
+ [coordinator] Active Workers:
336
+ > <subject> (<role>) - running [inner-loop: N/M tasks done]
337
+
338
+ [coordinator] Ready to spawn: <subjects>
339
+ [coordinator] Coordinates: phase=<N> step=<step> gap=<iteration>
340
+ [coordinator] Commands: 'resume' to advance | 'check' to refresh
341
+ ```
342
+
343
+ Then STOP.
344
+
345
+ ---
346
+
347
+ ### Handler: handleResume
348
+
349
+ **Agent Health Check** (v4):
350
+ ```
351
+ // Verify actual running agents match session state
352
+ const runningAgents = list_agents({})
353
+ // For each active_agent in tasks.json:
354
+ // - If agent NOT in runningAgents -> agent crashed
355
+ // - Reset that task to pending, remove from active_agents
356
+ // This prevents stale agent references from blocking the pipeline
357
+ ```
358
+
359
+ Check active worker completion, process results, advance pipeline. Also handles resume from paused state.
360
+
361
+ ```
362
+ Check coordinates.status:
363
+ +- "paused" -> Restore coordinates, resume from saved position
364
+ | Reset coordinates.status = "running"
365
+ | -> handleSpawnNext (picks up where it left off)
366
+ +- "running" -> Normal resume:
367
+ Load active_workers from session
368
+ +- No active workers -> handleSpawnNext
369
+ +- Has active workers -> check each:
370
+ +- status = completed -> mark done, remove from active_workers, log
371
+ +- status = in_progress -> still running, log
372
+ +- other status -> worker failure -> reset to pending
373
+ After processing:
374
+ +- Some completed -> handleSpawnNext
375
+ +- All still running -> report status -> STOP
376
+ +- All failed -> handleSpawnNext (retry)
377
+ ```
378
+
379
+ ---
380
+
381
+ ### Handler: handleComplete
382
+
383
+ **Cleanup Verification** (v4):
384
+ ```
385
+ // Verify all agents are properly closed
386
+ const remaining = list_agents({})
387
+ // If any team agents still running -> close_agent each
388
+ // Ensures clean session shutdown
389
+ ```
390
+
391
+ All phases done. Generate final project summary and finalize session.
392
+
393
+ ```
394
+ All phases completed (no pending, no in_progress across all phases)
395
+ +- Generate project-level summary:
396
+ | - Roadmap overview (phases completed)
397
+ | - Per-phase results:
398
+ | - Gap closure iterations used
399
+ | - Verification status
400
+ | - Key deliverables
401
+ | - Overall stats (tasks completed, phases, total gap iterations)
402
+ |
403
+ +- Update session:
404
+ | coordinates.status = "complete"
405
+ | session.completed_at = <timestamp>
406
+ | Write meta.json
407
+ |
408
+ +- Update state.md: mark all phases completed
409
+ +- team_msg log -> project_complete
410
+ +- Output summary to user
411
+ +- STOP
412
+ ```
413
+
414
+ ---
415
+
416
+ ### Worker Failure Handling
417
+
418
+ When a worker has unexpected status (not completed, not in_progress):
419
+
420
+ 1. Reset task -> pending in tasks.json
421
+ 2. Remove from active_workers
422
+ 3. Log via team_msg (type: error)
423
+ 4. Report to user: task reset, will retry on next resume
424
+
425
+ ## Phase 4: State Persistence
426
+
427
+ After every handler action, before STOP:
428
+
429
+ | Check | Action |
430
+ |-------|--------|
431
+ | Coordinates updated | current_phase, step, gap_iteration reflect actual state |
432
+ | Session state consistent | active_workers matches tasks.json in_progress tasks |
433
+ | No orphaned tasks | Every in_progress task has an active_worker entry |
434
+ | Meta.json updated | Write updated session state and coordinates |
435
+ | State.md updated | Phase progress reflects actual completion |
436
+ | Completion detection | All phases done + no pending + no in_progress -> handleComplete |
437
+
438
+ ```
439
+ Persist:
440
+ 1. Update coordinates in meta.json
441
+ 2. Reconcile active_workers with actual tasks.json states
442
+ 3. Remove entries for completed/deleted tasks
443
+ 4. Write updated meta.json
444
+ 5. Update state.md if phase status changed
445
+ 6. Verify consistency
446
+ 7. STOP (wait for next callback)
447
+ ```
448
+
449
+ ## State Machine Diagram
450
+
451
+ ```
452
+ [dispatch] -> PLAN-{N}01 spawned
453
+ |
454
+ [planner callback]
455
+ |
456
+ plan_check gate? --YES--> request_user_input --> "Revise" --> new PLAN task --> [spawn]
457
+ | "Skip" --> advanceToNextPhase
458
+ | "Proceed" / no gate
459
+ v
460
+ EXEC-{N}01 spawned
461
+ |
462
+ [executor callback]
463
+ |
464
+ v
465
+ VERIFY-{N}01 spawned
466
+ |
467
+ [verifier callback]
468
+ |
469
+ gaps found? --NO--> advanceToNextPhase
470
+ |
471
+ YES + iteration < MAX
472
+ |
473
+ v
474
+ triggerGapClosure:
475
+ PLAN-{N}02 -> EXEC-{N}02 -> VERIFY-{N}02
476
+ |
477
+ [repeat verify check]
478
+ |
479
+ gaps found? --NO--> advanceToNextPhase
480
+ |
481
+ YES + iteration >= MAX
482
+ |
483
+ v
484
+ request_user_input: "Continue anyway" / "Retry" / "Stop"
485
+
486
+ advanceToNextPhase:
487
+ +- phase < total? --YES--> interactive gate? --> dispatch phase+1 --> [spawn PLAN]
488
+ +- phase = total? --> handleComplete
489
+ ```
490
+
491
+ ## Error Handling
492
+
493
+ | Scenario | Resolution |
494
+ |----------|------------|
495
+ | Session file not found | Error, suggest re-initialization |
496
+ | Worker callback from unknown role | Log info, scan for other completions |
497
+ | All workers still running on resume | Report status, suggest check later |
498
+ | Pipeline stall (no ready, no running, has pending) | Check blockedBy chains, report to user |
499
+ | Verification file missing | Treat as gap -- verifier may have crashed, re-spawn |
500
+ | Phase dispatch fails | Check roadmap integrity, report to user |
501
+ | Max gap iterations exceeded | Ask user: continue / retry / stop |
502
+ | User chooses "Stop" at any gate | Pause session with coordinates, exit cleanly |