maestro-flow 0.4.16 → 0.4.18

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 (105) hide show
  1. package/.agents/skills/maestro/SKILL.md +1 -1
  2. package/.agents/skills/maestro-analyze/SKILL.md +5 -0
  3. package/.agents/skills/maestro-blueprint/SKILL.md +5 -0
  4. package/.agents/skills/maestro-brainstorm/SKILL.md +5 -0
  5. package/.agents/skills/maestro-init/SKILL.md +1 -1
  6. package/.agents/skills/maestro-next/SKILL.md +219 -0
  7. package/.agents/skills/maestro-ralph-beta/SKILL.md +893 -0
  8. package/.agy/skills/maestro/SKILL.md +1 -1
  9. package/.agy/skills/maestro-analyze/SKILL.md +5 -0
  10. package/.agy/skills/maestro-blueprint/SKILL.md +5 -0
  11. package/.agy/skills/maestro-brainstorm/SKILL.md +5 -0
  12. package/.agy/skills/maestro-init/SKILL.md +1 -1
  13. package/.agy/skills/maestro-next/SKILL.md +215 -0
  14. package/.agy/skills/maestro-ralph-beta/SKILL.md +889 -0
  15. package/.claude/commands/maestro-analyze.md +5 -0
  16. package/.claude/commands/maestro-blueprint.md +5 -0
  17. package/.claude/commands/maestro-brainstorm.md +5 -0
  18. package/.claude/commands/maestro-init.md +1 -1
  19. package/.claude/commands/maestro-next.md +217 -0
  20. package/.claude/commands/maestro-ralph-beta.md +891 -0
  21. package/.claude/commands/maestro.md +1 -1
  22. package/.codex/skills/learn-decompose/SKILL.md +34 -3
  23. package/.codex/skills/learn-retro/SKILL.md +31 -1
  24. package/.codex/skills/learn-second-opinion/SKILL.md +34 -4
  25. package/.codex/skills/maestro-analyze/SKILL.md +44 -5
  26. package/.codex/skills/maestro-blueprint/SKILL.md +5 -0
  27. package/.codex/skills/maestro-brainstorm/SKILL.md +46 -0
  28. package/.codex/skills/maestro-execute/SKILL.md +61 -5
  29. package/.codex/skills/maestro-milestone-audit/SKILL.md +64 -13
  30. package/.codex/skills/maestro-milestone-complete/SKILL.md +12 -0
  31. package/.codex/skills/maestro-plan/SKILL.md +36 -1
  32. package/.codex/skills/maestro-player/SKILL.md +25 -6
  33. package/.codex/skills/maestro-ralph/SKILL.md +108 -81
  34. package/.codex/skills/maestro-ralph-beta/SKILL.md +891 -0
  35. package/.codex/skills/maestro-ralph-execute/SKILL.md +244 -0
  36. package/.codex/skills/maestro-roadmap/SKILL.md +35 -4
  37. package/.codex/skills/maestro-ui-codify/SKILL.md +38 -10
  38. package/.codex/skills/maestro-verify/SKILL.md +40 -5
  39. package/.codex/skills/manage-codebase-rebuild/SKILL.md +52 -5
  40. package/.codex/skills/manage-issue-discover/SKILL.md +106 -15
  41. package/.codex/skills/quality-auto-test/SKILL.md +70 -16
  42. package/.codex/skills/quality-debug/SKILL.md +139 -28
  43. package/.codex/skills/quality-refactor/SKILL.md +61 -11
  44. package/.codex/skills/quality-review/SKILL.md +45 -9
  45. package/.codex/skills/quality-test/SKILL.md +58 -3
  46. package/.codex/skills/security-audit/SKILL.md +38 -0
  47. package/.codex/skills/spec-map/SKILL.md +65 -8
  48. package/.codex/skills/team-coordinate/SKILL.md +28 -11
  49. package/.codex/skills/team-coordinate/specs/role-catalog.md +20 -0
  50. package/.codex/skills/team-lifecycle-v4/SKILL.md +23 -7
  51. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +20 -0
  52. package/.codex/skills/team-quality-assurance/SKILL.md +40 -2
  53. package/.codex/skills/team-review/SKILL.md +42 -2
  54. package/.codex/skills/team-tech-debt/SKILL.md +45 -2
  55. package/.codex/skills/team-testing/SKILL.md +42 -2
  56. package/dashboard/dist-server/dashboard/src/server/wiki/search.d.ts +6 -4
  57. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +50 -8
  58. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  59. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +32 -0
  60. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +294 -0
  61. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  62. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  63. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +35 -1
  64. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  65. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js +235 -0
  66. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js.map +1 -1
  67. package/dist/src/commands/install-backend.d.ts.map +1 -1
  68. package/dist/src/commands/install-backend.js +23 -4
  69. package/dist/src/commands/install-backend.js.map +1 -1
  70. package/dist/src/commands/ralph.d.ts.map +1 -1
  71. package/dist/src/commands/ralph.js +3 -1
  72. package/dist/src/commands/ralph.js.map +1 -1
  73. package/dist/src/ralph/cmd-check.js +1 -1
  74. package/dist/src/ralph/cmd-check.js.map +1 -1
  75. package/dist/src/ralph/cmd-complete.js +1 -1
  76. package/dist/src/ralph/cmd-complete.js.map +1 -1
  77. package/dist/src/ralph/cmd-next.d.ts.map +1 -1
  78. package/dist/src/ralph/cmd-next.js +56 -5
  79. package/dist/src/ralph/cmd-next.js.map +1 -1
  80. package/dist/src/ralph/cmd-session.js +2 -2
  81. package/dist/src/ralph/cmd-session.js.map +1 -1
  82. package/dist/src/ralph/cmd-skills.d.ts +2 -0
  83. package/dist/src/ralph/cmd-skills.d.ts.map +1 -1
  84. package/dist/src/ralph/cmd-skills.js +11 -4
  85. package/dist/src/ralph/cmd-skills.js.map +1 -1
  86. package/dist/src/ralph/skill-scanner.d.ts +7 -2
  87. package/dist/src/ralph/skill-scanner.d.ts.map +1 -1
  88. package/dist/src/ralph/skill-scanner.js +39 -24
  89. package/dist/src/ralph/skill-scanner.js.map +1 -1
  90. package/dist/src/ralph/status-schema.d.ts +2 -0
  91. package/dist/src/ralph/status-schema.d.ts.map +1 -1
  92. package/dist/src/ralph/status-store.d.ts +8 -1
  93. package/dist/src/ralph/status-store.d.ts.map +1 -1
  94. package/dist/src/ralph/status-store.js +12 -2
  95. package/dist/src/ralph/status-store.js.map +1 -1
  96. package/dist/src/tools/store-knowhow.d.ts.map +1 -1
  97. package/dist/src/tools/store-knowhow.js +51 -64
  98. package/dist/src/tools/store-knowhow.js.map +1 -1
  99. package/dist/src/utils/update-notices.js +12 -0
  100. package/dist/src/utils/update-notices.js.map +1 -1
  101. package/package.json +1 -1
  102. package/templates/config.json +21 -33
  103. package/workflows/finish-work.md +119 -0
  104. package/workflows/init.md +11 -11
  105. package/workflows/milestone-complete.md +23 -1
@@ -23,7 +23,7 @@ Entry points:
23
23
  - **`/maestro --dry-run "intent"`** — Show chain, no execution
24
24
  - **`/maestro --super "intent"`** — Production-ready mode (read maestro-super.md)
25
25
 
26
- Session: `.workflow/.maestro/{session_id}/status.json`
26
+ **Session**: `.workflow/.maestro/{session_id}/status.json` — 工作流唯一真源。session_id 格式 `maestro-{YYYYMMDD-HHmmss}`(本 command 创建,静态链)或 `ralph-{YYYYMMDD-HHmmss}`(`/maestro-ralph` 创建,自适应链)。两类都由 `/maestro-ralph-execute` 推进;schema 与 ralph 共用(含 `ralph_protocol_version: "1"` + `active_step_index`)。
27
27
  </purpose>
28
28
 
29
29
  <deferred_reading>
@@ -54,7 +54,7 @@ Resolve target to file list. Load coding specs: `maestro spec load --category co
54
54
 
55
55
  ### Phase 2: Wave 1 — Parallel Dimension Scans
56
56
 
57
- Generate `tasks.csv` with 4 dimension rows (wave 1) + 1 cross-ref row (wave 2):
57
+ Generate `tasks.csv` with 4 dimension rows (wave 1) + 1 cross-ref row (wave 2). Initialize every row with `status="pending"`. Filter `wave==N AND status=="pending"` when writing each wave CSV.
58
58
 
59
59
  | id | dimension | focus |
60
60
  |----|-----------|-------|
@@ -64,7 +64,38 @@ Generate `tasks.csv` with 4 dimension rows (wave 1) + 1 cross-ref row (wave 2):
64
64
  | 4 | error | Boundaries, retry/backoff, fallbacks, guards, logging |
65
65
  | 5 | cross-ref | Dedup + catalog from wave 1 findings |
66
66
 
67
- Each dimension agent returns:
67
+ **output_schema** (both waves):
68
+
69
+ ```json
70
+ {
71
+ "type": "object",
72
+ "properties": {
73
+ "id": { "type": "string" },
74
+ "result_status": { "type": "string", "enum": ["completed", "failed"] },
75
+ "dimension": { "type": "string", "enum": ["structural", "behavioral", "data", "error", "cross-ref"] },
76
+ "patterns": { "type": "string", "description": "JSON array string: [{name, dimension, confidence, anchors, description, rationale, tradeoffs}]" },
77
+ "findings": { "type": "string", "maxLength": 500 },
78
+ "error": { "type": "string" }
79
+ },
80
+ "required": ["id", "result_status", "findings"]
81
+ }
82
+ ```
83
+
84
+ Merge: `result_status` → master `status`; copy `dimension`, `patterns`, `findings`, `error`.
85
+
86
+ **Shared termination contract** (embed in every instruction):
87
+ ```
88
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
89
+ - Success → result_status=completed (patterns may be empty array if nothing found)
90
+ - Failure → result_status=failed with error message
91
+ - Timeout → near max_runtime_seconds → result_status=completed with partial patterns
92
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
93
+ - Every finding MUST include file:line anchors. No speculation.
94
+ - Read-only analysis. Do NOT modify source.
95
+ Do NOT write to tasks.csv, wave-*.csv, results.csv. Do NOT call spawn_agents_on_csv (no recursion).
96
+ ```
97
+
98
+ Each dimension agent populates `patterns` as a JSON array string of:
68
99
  ```json
69
100
  [{
70
101
  "name": "pattern name",
@@ -79,7 +110,7 @@ Each dimension agent returns:
79
110
 
80
111
  ### Phase 3: Wave 2 — Cross-Reference + Catalog
81
112
 
82
- Single agent receives all wave 1 findings via `prev_context`. Tasks:
113
+ Single agent receives all wave 1 findings via `prev_context`. Uses same `output_schema` + termination contract above. Tasks:
83
114
  - Match against dedup set → mark as `documented`, `known`, or `new`
84
115
  - Merge duplicates across dimensions (same pattern found by multiple agents)
85
116
  - Flag contradictions with documented conventions
@@ -44,7 +44,7 @@ $ARGUMENTS — lens selection and scope flags.
44
44
  **3a: Collect decisions** from wiki, specs, git log, phase context, .workflow/specs/learnings.md.
45
45
  **3b: Build decision registry** per decision (id, title, source, rationale, alternatives, evidence).
46
46
 
47
- **3c: Multi-perspective evaluation** via spawn_agents_on_csv (3 parallel agents):
47
+ **3c: Multi-perspective evaluation** via spawn_agents_on_csv (3 parallel agents; filter `wave==1 AND status=="pending"`):
48
48
 
49
49
  | id | perspective | focus |
50
50
  |----|------------|-------|
@@ -52,6 +52,36 @@ $ARGUMENTS — lens selection and scope flags.
52
52
  | 2 | cost | Complexity added, coupling, tech debt. Grade: low-cost/acceptable/expensive |
53
53
  | 3 | hindsight | Right call with current knowledge? Grade: confirmed/questionable/should-revisit |
54
54
 
55
+ **output_schema**:
56
+
57
+ ```json
58
+ {
59
+ "type": "object",
60
+ "properties": {
61
+ "id": { "type": "string" },
62
+ "result_status": { "type": "string", "enum": ["completed", "failed"] },
63
+ "perspective": { "type": "string", "enum": ["technical", "cost", "hindsight"] },
64
+ "grade": { "type": "string" },
65
+ "findings": { "type": "string", "maxLength": 500 },
66
+ "error": { "type": "string" }
67
+ },
68
+ "required": ["id", "result_status", "grade", "findings"]
69
+ }
70
+ ```
71
+
72
+ Merge: `result_status` → master `status`; copy `perspective`, `grade`, `findings`, `error`.
73
+
74
+ **Shared termination contract** (embed in every instruction):
75
+ ```
76
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
77
+ - Success → result_status=completed with concrete grade
78
+ - Failure → result_status=failed with error message
79
+ - Timeout → near max_runtime_seconds → result_status=failed, error="timeout (partial)"
80
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
81
+ - Read-only analysis. Do NOT modify source files.
82
+ Do NOT write to tasks.csv, wave-*.csv, results.csv. Do NOT call spawn_agents_on_csv (no recursion).
83
+ ```
84
+
55
85
  **3d: Classify lifecycle**: Validated / Aging / Questionable / Stale / Reversed.
56
86
 
57
87
  ### Phase 4: Unified Report
@@ -47,12 +47,42 @@ Resolve target to content. Load specs, wiki search, prior lessons for context br
47
47
  | 3 | strategist | Scalability, extensibility, architecture alignment | coupling, cohesion |
48
48
  | 4 | synthesis | Merge verdicts → agreements, disagreements, top 3 recommendations | combined verdict |
49
49
 
50
- Wave 1: 3 persona agents in parallel. Wave 2: synthesis agent with wave 1 findings as prev_context.
51
-
52
- Each persona returns: `{ persona, verdict: approve|concern|reject, confidence, findings: [{severity, description, location, suggestion}], summary }`
50
+ Wave 1: 3 persona agents in parallel (filter `wave==1 AND status=="pending"`). Wave 2: synthesis agent with wave 1 findings as prev_context.
51
+
52
+ **output_schema** (both waves):
53
+
54
+ ```json
55
+ {
56
+ "type": "object",
57
+ "properties": {
58
+ "id": { "type": "string" },
59
+ "result_status": { "type": "string", "enum": ["completed", "failed"] },
60
+ "persona": { "type": "string" },
61
+ "verdict": { "type": "string", "enum": ["approve", "concern", "reject", ""] },
62
+ "confidence": { "type": "string", "description": "0-100" },
63
+ "findings": { "type": "string", "description": "JSON array of {severity, description, location, suggestion}, max 500 chars summary" },
64
+ "summary": { "type": "string", "maxLength": 500 },
65
+ "error": { "type": "string" }
66
+ },
67
+ "required": ["id", "result_status", "summary"]
68
+ }
69
+ ```
70
+
71
+ Merge: `result_status` → master `status`; copy `persona`, `verdict`, `confidence`, `findings`, `summary`, `error`.
72
+
73
+ **Shared termination contract** (embed in every instruction):
74
+ ```
75
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
76
+ - Success → result_status=completed with concrete verdict
77
+ - Failure → result_status=failed with error message
78
+ - Timeout → near max_runtime_seconds → result_status=failed, error="timeout (partial)"
79
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
80
+ - Read-only analysis. Do NOT modify source files.
81
+ Do NOT write to tasks.csv, wave-*.csv, results.csv. Do NOT call spawn_agents_on_csv (no recursion).
82
+ ```
53
83
 
54
84
  #### Challenge Mode
55
- Single agent via spawn_agents_on_csv (1 worker). Adversarial analysis with forcing questions:
85
+ Single agent via spawn_agents_on_csv (max_concurrency: 1) with the same `output_schema` + termination contract above. Adversarial analysis with forcing questions:
56
86
  - "What assumption would invalidate this entire approach?"
57
87
  - "What's the simplest thing that breaks this?"
58
88
  - "What's the implicit contract that isn't enforced?"
@@ -152,29 +152,63 @@ S_AGGREGATE:
152
152
 
153
153
  <actions>
154
154
 
155
+ ### Shared Spawn Contract (all three waves)
156
+
157
+ Every `spawn_agents_on_csv` call in this skill MUST use the strict JSON Schema below and the shared termination contract.
158
+
159
+ **Output Schema**:
160
+
161
+ ```json
162
+ {
163
+ "type": "object",
164
+ "properties": {
165
+ "id": { "type": "string" },
166
+ "result_status": { "type": "string", "enum": ["completed", "failed", "blocked"] },
167
+ "findings": { "type": "string", "maxLength": 500 },
168
+ "score": { "type": "string", "description": "0-100 (wave 2 scoring only)" },
169
+ "evidence": { "type": "string", "description": "Code refs file:line (wave 1/2)" },
170
+ "error": { "type": "string" }
171
+ },
172
+ "required": ["id", "result_status", "findings"]
173
+ }
174
+ ```
175
+
176
+ Merge step: `result_status` → master `status`; copy `findings`, `score`, `evidence`, `error`.
177
+
178
+ **Termination contract** (embed in every instruction):
179
+ ```
180
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
181
+ - Success → result_status=completed
182
+ - Failure → result_status=failed with error message
183
+ - Blocked → upstream missing → result_status=blocked
184
+ - Timeout → near max_runtime_seconds → result_status=blocked, error="timeout"
185
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
186
+ Do NOT write to tasks.csv, wave-*.csv, results.csv. Do NOT call spawn_agents_on_csv (no recursion).
187
+ ```
188
+
155
189
  ### A_SPAWN_WAVE_1
156
190
 
157
- Filter wave==1 -> write wave-1.csv -> `spawn_agents_on_csv({ csv_path, max_concurrency })`.
191
+ Filter `wave==1 AND status=="pending"` -> write wave-1.csv -> `spawn_agents_on_csv({ csv_path, id_column:"id", instruction: EXPLORATION_INSTRUCTION + SHARED_TERMINATION_CONTRACT, max_concurrency, max_runtime_seconds: 3600, output_csv_path, output_schema })`.
158
192
 
159
193
  **Exploration agent** (3-layer per dimension):
160
194
  1. Module Discovery (breadth): keyword search, relevant files, module boundaries
161
195
  2. Structure Tracing (depth): top 3-5 files, call chains 2-3 levels, data flow
162
196
  3. Code Anchor Extraction (detail): code snippet 20-50 lines with file:line per finding
163
197
 
164
- Share via discovery board. Merge results -> master tasks.csv.
198
+ Share via discovery board. Merge results -> master tasks.csv (map `result_status` → master `status`).
165
199
 
166
200
  ### A_SPAWN_WAVE_2
167
201
 
168
- Filter wave==2 -> build prev_context from wave 1 findings -> write wave-2.csv -> spawn.
202
+ Filter `wave==2 AND status=="pending"` -> build prev_context from wave 1 findings -> write wave-2.csv -> spawn with `SCORING_INSTRUCTION + SHARED_TERMINATION_CONTRACT`.
169
203
 
170
204
  **Scoring agent** (6 dimensions: feasibility, impact, risk, complexity, alignment, maintainability):
171
205
  Score 0-100 with specific evidence (code refs from exploration). Each score MUST reference exploration findings.
172
206
 
173
- Merge results -> master tasks.csv.
207
+ Merge results -> master tasks.csv (map `result_status` → master `status`).
174
208
 
175
209
  ### A_SPAWN_WAVE_3
176
210
 
177
- Filter wave==3 -> build prev_context from wave 2 scores (or project context for quick mode) -> spawn.
211
+ Filter `wave==3 AND status=="pending"` -> build prev_context from wave 2 scores (or project context for quick mode) -> spawn with `SYNTHESIS_INSTRUCTION + SHARED_TERMINATION_CONTRACT`.
178
212
 
179
213
  **Synthesis agent**:
180
214
  - Full mode: analysis.md (executive summary, per-dimension scores, risk matrix, Go/No-Go), context.md (Locked/Free/Deferred decisions), context-package.json, conclusions.json (with `scope_verdict` + `implementation_scope[]`)
@@ -262,5 +296,10 @@ Protocol: read before analysis, append-only, dedup by type+key.
262
296
  - [ ] Upstream context loaded via `--from` when specified
263
297
  - [ ] discoveries.ndjson append-only throughout
264
298
  - [ ] Next step routed (plan for Go, brainstorm for No-Go, plan --gaps for Gaps)
299
+ - [ ] Session sealed via finish-work (archive.json written, optional spec/knowhow extraction)
265
300
  </success_criteria>
301
+
302
+ <on_complete>
303
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR=OUTPUT_DIR, SESSION_TYPE=analyze, SESSION_ID={artifact_id}, LINKED_MILESTONE={target_milestone or null}
304
+ </on_complete>
266
305
  </output>
@@ -120,4 +120,9 @@ P6 gate: Pass (>=80%) → Handoff | Review (60-79%) → Handoff w/caveats | Fail
120
120
  - [ ] Readiness gate: Pass (>=80%) or Review (>=60%) with documented caveats
121
121
  - [ ] Artifact registered in state.json (type=blueprint)
122
122
  - [ ] context-package.json generated for downstream consumption
123
+ - [ ] On gate Pass/Review: session sealed via finish-work (archive.json + optional spec/knowhow extraction). On Fail: skip — session stays active, excluded from wiki search.
123
124
  </success_criteria>
125
+
126
+ <on_complete>
127
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR={session_dir}, SESSION_TYPE=blueprint, SESSION_ID={session_id}, LINKED_MILESTONE=null
128
+ </on_complete>
@@ -212,6 +212,47 @@ CONSTRAINTS:
212
212
  7. **DO NOT STOP**: Continuous until all waves complete; only pause at [CHECKPOINT] (skipped with -y).
213
213
  </invariants>
214
214
 
215
+ <spawn_contract>
216
+
217
+ All three waves invoke `spawn_agents_on_csv` with the same shape — only `instruction` (inflated from `<agent_prompt_template>`) and `max_concurrency` differ. The orchestrator MUST:
218
+
219
+ 1. Filter master tasks.csv to `wave==N AND status=="pending"` before writing `wave-{N}.csv`.
220
+ 2. Use the strict JSON Schema below for `output_schema`.
221
+ 3. Append the shared termination contract to every inflated `description`.
222
+ 4. Merge: map `result_status` → master `status`; copy `findings`, `output_path`, `error`.
223
+
224
+ **output_schema** (all waves):
225
+
226
+ ```json
227
+ {
228
+ "type": "object",
229
+ "properties": {
230
+ "id": { "type": "string" },
231
+ "result_status": { "type": "string", "enum": ["completed", "failed", "blocked"] },
232
+ "findings": { "type": "string", "maxLength": 500 },
233
+ "output_path": { "type": "string", "description": "Primary deliverable absolute path (W1: guidance-specification.md; W2: {role}/analysis.md; W3: review-findings.json)" },
234
+ "error": { "type": "string" }
235
+ },
236
+ "required": ["id", "result_status", "findings"]
237
+ }
238
+ ```
239
+
240
+ **Shared termination contract** (append to every inflated W1/W2/W3 description):
241
+
242
+ ```
243
+ TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
244
+ - Success path → all required files written AND verified via Glob → result_status=completed, output_path set
245
+ - Failure path → unrecoverable error (write fail, missing input file) → result_status=failed
246
+ - Blocked path → upstream missing (W2 cannot read guidance-spec; W3 cannot read analysis.md) → result_status=blocked
247
+ - Timeout path → near max_runtime_seconds → finalize current write if safe → otherwise report blocked with error="timeout"
248
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
249
+ - NEVER return analysis as chat text — files on disk are the ONLY valid deliverable.
250
+ - Do NOT write to tasks.csv, wave-*.csv, results.csv.
251
+ - Do NOT call spawn_agents_on_csv (no recursion).
252
+ ```
253
+
254
+ </spawn_contract>
255
+
215
256
  <state_machine>
216
257
 
217
258
  <states>
@@ -387,4 +428,9 @@ Protocol: read before analysis, append-only, dedup by type+key.
387
428
  - [ ] context-package.json generated with per-item `ref` traceability
388
429
  - [ ] discoveries.ndjson append-only throughout
389
430
  - [ ] context.md aggregates session results with next-step routing
431
+ - [ ] Session sealed via finish-work (auto mode only)
390
432
  </success_criteria>
433
+
434
+ <on_complete>
435
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR={output_dir}, SESSION_TYPE=brainstorm, SESSION_ID={artifact_id}, LINKED_MILESTONE=null
436
+ </on_complete>
@@ -257,16 +257,72 @@ For each wave N in ascending order:
257
257
 
258
258
  ```javascript
259
259
  spawn_agents_on_csv({
260
- csv_path: `${sessionFolder}/wave-${N}.csv`,
260
+ csv_path: `${sessionFolder}/wave-${N}.csv`, // only rows where wave==N AND status=="pending"
261
261
  id_column: "id",
262
- instruction: buildExecutorInstruction(sessionFolder, phaseDir, autoCommit, specsContent), // agent: ~/.codex/agents/workflow-executor.toml
263
- max_concurrency: maxConcurrency, max_runtime_seconds: 3600,
262
+ instruction: EXECUTOR_INSTRUCTION, // see "Executor Worker Contract" below
263
+ max_concurrency: maxConcurrency,
264
+ max_runtime_seconds: 3600,
264
265
  output_csv_path: `${sessionFolder}/wave-${N}-results.csv`,
265
- output_schema: { id, result_status: [completed|failed|blocked], findings, files_modified, tests_passed, error }
266
+ output_schema: {
267
+ type: "object",
268
+ properties: {
269
+ id: { type: "string" },
270
+ result_status: { type: "string", enum: ["completed", "failed", "blocked"] },
271
+ findings: { type: "string", maxLength: 500 },
272
+ files_modified: { type: "string", description: "Semicolon-separated paths" },
273
+ tests_passed: { type: "string", enum: ["true", "false", "n/a"] },
274
+ error: { type: "string" }
275
+ },
276
+ required: ["id", "result_status", "findings"]
277
+ }
266
278
  })
267
279
  ```
268
280
 
269
- 4. Merge results into master `tasks.csv`: map `result_status` from `wave-{N}-results.csv` to the `status` column in master CSV. Delete `wave-{N}.csv` AND `wave-{N}-results.csv` after merge.
281
+ 4. Merge results into master `tasks.csv`: map `result_status` from `wave-{N}-results.csv` to the `status` column in master CSV; copy `findings`, `files_modified`, `tests_passed`, `error`. Delete `wave-{N}.csv` AND `wave-{N}-results.csv` after merge.
282
+
283
+ #### Executor Worker Contract (EXECUTOR_INSTRUCTION)
284
+
285
+ The literal `instruction` string passed to `spawn_agents_on_csv` MUST include the following contract (substitute `{sessionFolder}`, `{phaseDir}`, `{autoCommit}`, `{specsContent}` at build time):
286
+
287
+ ```
288
+ You are a task executor. ONE task row is assigned to you.
289
+
290
+ INPUT (from your CSV row):
291
+ - id, title, description, prev_context (findings from upstream tasks)
292
+ - meta.tdd_phase (red|green|refactor) if TDD mode is enabled
293
+
294
+ REQUIRED STEPS:
295
+ 1. Read prev_context — depend on upstream findings, not memory
296
+ 2. Read shared discoveries: {sessionFolder}/discoveries.ndjson
297
+ 3. Implement the task: edit/create files per description
298
+ 4. Run verification — relevant tests; if TDD, honor tdd_phase semantics
299
+ 5. If autoCommit and task succeeded → commit changes with task ID in message
300
+ 6. Append discoveries (type=implementation_note / pattern) to discoveries.ndjson
301
+ 7. Call report_agent_job_result EXACTLY ONCE
302
+
303
+ TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
304
+ - Success path → all files written, tests pass → result_status=completed, tests_passed="true"
305
+ - Blocked path → cannot proceed (missing dep, unclear requirement, contract violation) → result_status=blocked with error explaining what is needed
306
+ - Failure path → unrecoverable error (build error, file write fail) → result_status=failed with error message
307
+ - Timeout path → approaching max_runtime_seconds → revert partial work, report blocked with error="timeout"
308
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
309
+
310
+ OUTPUT (return via report_agent_job_result; must match output_schema):
311
+ {
312
+ "id": "<your row id>",
313
+ "result_status": "completed" | "failed" | "blocked",
314
+ "findings": "<one-sentence summary, max 500 chars>",
315
+ "files_modified": "<semicolon-separated paths or empty>",
316
+ "tests_passed": "true" | "false" | "n/a",
317
+ "error": "<message if not completed, else empty>"
318
+ }
319
+
320
+ CONSTRAINTS:
321
+ - Modify ONLY files implicated by the task description and prev_context.
322
+ - Do NOT write to tasks.csv, wave-*.csv, results.csv, plan.json, or state.json — orchestrator owns those.
323
+ - Do NOT call spawn_agents_on_csv (no recursion).
324
+ - Honor specs loaded by orchestrator (passed via instruction context).
325
+ ```
270
326
 
271
327
  #### Blocked Task Handling
272
328
 
@@ -28,9 +28,9 @@ $maestro-milestone-audit "M1"
28
28
  ### tasks.csv (Master State)
29
29
 
30
30
  ```csv
31
- id,title,description,scope,check_targets,deps,wave
32
- "integ-1","Interface & dependency chains","Verify shared interfaces are consistent across phases: re-exports match, dependency chains unbroken, no circular imports between phase outputs","cross-phase imports, shared types, re-exports","grep for shared type names across phase output dirs; verify export/import consistency","","1"
33
- "integ-2","Data contracts & API consistency","Verify request/response schemas match across phases: API signatures consistent, error codes aligned, no contract drift","request/response schemas, API signatures, error codes","diff API type definitions across phases; check error code enum consistency","","1"
31
+ id,title,description,scope,check_targets,deps,wave,status,findings,gaps_found,severity,error
32
+ "integ-1","Interface & dependency chains","Verify shared interfaces are consistent across phases: re-exports match, dependency chains unbroken, no circular imports between phase outputs","cross-phase imports, shared types, re-exports","grep for shared type names across phase output dirs; verify export/import consistency","","1","pending","","","",""
33
+ "integ-2","Data contracts & API consistency","Verify request/response schemas match across phases: API signatures consistent, error codes aligned, no contract drift","request/response schemas, API signatures, error codes","diff API type definitions across phases; check error code enum consistency","","1","pending","","","",""
34
34
  ```
35
35
 
36
36
  **Columns**:
@@ -44,13 +44,13 @@ id,title,description,scope,check_targets,deps,wave
44
44
  | `check_targets` | Input | Specific verification commands/grep patterns |
45
45
  | `deps` | Input | Dependencies (empty — all wave 1) |
46
46
  | `wave` | Computed | Wave number (always 1 — single parallel wave) |
47
- | `result_status` | Output | `pass` / `fail` / `warning` |
48
- | `findings` | Output | Detailed findings per dimension (max 500 chars) |
49
- | `gaps_found` | Output | Semicolon-separated list of integration gaps |
50
- | `severity` | Output | `critical` / `warning` / `info` per gap |
51
- | `error` | Output | Error message if check failed |
47
+ | `status` | Lifecycle | `pending` (initial) `pass`/`fail`/`warning`/`failed` (set by merge step from worker's `result_status`) |
48
+ | `findings` | Lifecycle | Detailed findings per dimension (max 500 chars; merged) |
49
+ | `gaps_found` | Lifecycle | Semicolon-separated list of integration gaps (merged) |
50
+ | `severity` | Lifecycle | `critical` / `warning` / `info` per gap (merged) |
51
+ | `error` | Lifecycle | Error message if check failed (merged) |
52
52
 
53
- **Column separation rule**: Input columns and Output columns MUST NOT share names. Wave CSV only contains Input columns. Output columns are returned exclusively via output_schema.
53
+ **Column separation rule**: Wave CSV (input to `spawn_agents_on_csv`) contains Input columns only. Workers return Output columns exclusively via `output_schema` using `result_status` (NOT `status`). Merge maps `result_status` master `status`.
54
54
 
55
55
  ### Session Structure
56
56
 
@@ -95,16 +95,67 @@ Verify all adhoc-scoped artifacts completed. For each execute artifact, verify a
95
95
 
96
96
  ```javascript
97
97
  spawn_agents_on_csv({
98
- csv_path: `${sessionFolder}/wave-1.csv`,
98
+ csv_path: `${sessionFolder}/wave-1.csv`, // rows where wave==1 AND status=="pending"
99
99
  id_column: "id",
100
- instruction: `You are an integration checker for milestone ${milestone}. For each row, examine the scope and check_targets. Search the codebase for inconsistencies, contract drift, and broken dependencies across phase outputs. Report findings with file:line references. Set result_status to pass/fail/warning. List specific gaps in gaps_found (semicolon-separated).`,
101
- max_concurrency: 2, max_runtime_seconds: 600,
100
+ instruction: AUDIT_INTEGRATION_INSTRUCTION, // see "Integration Checker Worker Contract" below
101
+ max_concurrency: 2,
102
+ max_runtime_seconds: 600,
102
103
  output_csv_path: `${sessionFolder}/wave-1-results.csv`,
103
- output_schema: { id, result_status: [pass|fail|warning], findings, gaps_found, severity, error }
104
+ output_schema: {
105
+ type: "object",
106
+ properties: {
107
+ id: { type: "string" },
108
+ result_status: { type: "string", enum: ["pass", "fail", "warning", "failed"] },
109
+ findings: { type: "string", maxLength: 500 },
110
+ gaps_found: { type: "string", description: "Semicolon-separated list of gaps" },
111
+ severity: { type: "string", enum: ["critical", "warning", "info", ""] },
112
+ error: { type: "string" }
113
+ },
114
+ required: ["id", "result_status", "findings", "severity"]
115
+ }
104
116
  })
105
117
  ```
106
118
 
107
119
  4. Merge results into master `tasks.csv`: map `result_status` → master `status` column, copy `findings`, `gaps_found`, `severity`, `error`. Delete temporary files (`wave-1.csv`, `wave-1-results.csv`) after merge.
120
+
121
+ #### Integration Checker Worker Contract (AUDIT_INTEGRATION_INSTRUCTION)
122
+
123
+ ```
124
+ You are an integration checker for milestone {milestone}. ONE integration dimension row is assigned to you.
125
+
126
+ INPUT (from your CSV row):
127
+ - id (integ-N), title, description, scope, check_targets
128
+
129
+ REQUIRED STEPS:
130
+ 1. Examine scope and check_targets fields
131
+ 2. Run check_targets — grep / read phase output dirs / diff API definitions
132
+ 3. Identify inconsistencies, contract drift, broken dependencies across phase outputs
133
+ 4. Record findings with file:line references for every gap
134
+ 5. Call report_agent_job_result EXACTLY ONCE
135
+
136
+ TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
137
+ - Pass path → no gaps found → result_status=pass, severity="info"
138
+ - Warning path → minor gaps → result_status=warning, severity="warning"
139
+ - Fail path → critical contract drift or broken dependencies → result_status=fail, severity="critical"
140
+ - Failure path → cannot read scope, tool error → result_status=failed with error message
141
+ - Timeout path → near 600s, finalize current findings → report with what was collected
142
+ - NEVER skip report_agent_job_result.
143
+
144
+ OUTPUT (must match output_schema):
145
+ {
146
+ "id": "<your row id>",
147
+ "result_status": "pass" | "warning" | "fail" | "failed",
148
+ "findings": "<one-sentence summary, max 500 chars>",
149
+ "gaps_found": "<semicolon-separated list of gaps, each with file:line; empty if pass>",
150
+ "severity": "critical" | "warning" | "info" | "",
151
+ "error": "<message if failed, else empty>"
152
+ }
153
+
154
+ CONSTRAINTS:
155
+ - Read-only inspection. Do NOT modify phase outputs.
156
+ - Do NOT write to tasks.csv, wave-*.csv, audit-report.md (orchestrator owns those).
157
+ - Do NOT call spawn_agents_on_csv (no recursion).
158
+ ```
108
159
  5. Parse `gaps_found` from all workers — aggregate into `.workflow/milestones/{milestone}/audit-report.md`
109
160
  6. Any worker with `result_status == fail` and `severity == critical` → milestone verdict = FAIL
110
161
 
@@ -51,6 +51,18 @@ Copy each milestone artifact's directory to `.workflow/milestones/{milestone}/ar
51
51
  - If `artifact.path` is absolute, use as-is
52
52
  - Copy the entire resolved directory to `.workflow/milestones/{milestone}/artifacts/{artifact.name}/`
53
53
 
54
+ **After each copy** (per archived session dir):
55
+
56
+ a. If destination contains `archive.json` with `lifecycle.status == "sealed"`:
57
+ - Set `lifecycle.status = "archived"`, `lifecycle.archived_at = now`, `lifecycle.linked_milestone = {milestone}` (if null).
58
+
59
+ b. If destination contains `context-package.json`, prune (scheme C — non-destructive):
60
+ - Compute `pruned` = { `open_questions` without answer/resolved_in; `constraints` status=open; `insights` beyond top 20; `references` whose path does not exist on disk }
61
+ - If any `pruned.*` non-empty: write `context-package.pruned.json` with the dropped items; rewrite `context-package.json` keeping only answered/resolved questions, locked constraints, `insights[0..20]`, valid-path references; update `archive.json.pruned = { at: now, counts, ref: "context-package.pruned.json" }`
62
+ - Otherwise: set `archive.json.pruned = { at: now, counts: zeros, ref: null }`
63
+
64
+ c. If session dir lacks `archive.json` (legacy): skip a+b silently — legacy sessions are not indexed.
65
+
54
66
  Snapshot `roadmap.md` as `roadmap-snapshot.md` in the milestone archive.
55
67
 
56
68
  ### Step 3: Extract Learnings
@@ -154,8 +154,41 @@ S_REGISTER → END DO: A_REGISTER
154
154
 
155
155
  <actions>
156
156
 
157
+ ### Shared Spawn Contract (W1 and W2)
158
+
159
+ Every `spawn_agents_on_csv` call MUST filter `wave==N AND status=="pending"` rows from master tasks.csv, use the strict JSON Schema below, and embed the termination contract.
160
+
161
+ **Output Schema**:
162
+
163
+ ```json
164
+ {
165
+ "type": "object",
166
+ "properties": {
167
+ "id": { "type": "string" },
168
+ "result_status": { "type": "string", "enum": ["completed", "failed", "blocked"] },
169
+ "findings": { "type": "string", "maxLength": 500 },
170
+ "files_modified":{ "type": "string", "description": "Semicolon-separated paths (W2 writes plan.json + .task/*)" },
171
+ "error": { "type": "string" }
172
+ },
173
+ "required": ["id", "result_status", "findings"]
174
+ }
175
+ ```
176
+
177
+ Merge: `result_status` → master `status`; copy `findings`, `files_modified`, `error`.
178
+
179
+ **Termination contract** (embed in every instruction):
180
+ ```
181
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
182
+ - Success → result_status=completed (W2: plan.json AND .task/* MUST exist on disk before reporting completed)
183
+ - Failure → result_status=failed with error message
184
+ - Blocked → upstream context insufficient → result_status=blocked
185
+ - Timeout → near max_runtime_seconds → result_status=blocked, error="timeout"
186
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
187
+ Do NOT write to tasks.csv, wave-*.csv, results.csv, state.json. Do NOT call spawn_agents_on_csv (no recursion).
188
+ ```
189
+
157
190
  ### Exploration agent responsibilities (W1)
158
- Each explores one angle: architecture (module boundaries, deps), patterns (similar implementations), tests (framework, conventions), risks (complexity, blockers). Reads files, maps dependencies, shares via discoveries.ndjson.
191
+ Each explores one angle: architecture (module boundaries, deps), patterns (similar implementations), tests (framework, conventions), risks (complexity, blockers). Reads files, maps dependencies, shares via discoveries.ndjson. Read-only — does NOT write plan.json.
159
192
 
160
193
  ### Planning agent responsibilities (W2)
161
194
  Consumes all exploration findings + context.md + specs. Produces:
@@ -163,6 +196,8 @@ Consumes all exploration findings + context.md + specs. Produces:
163
196
  - `.task/TASK-*.json`: each with read_first[], convergence.criteria[] (grep-verifiable), concrete action/implementation
164
197
  - Deep Work Rules: every task has read_first with file being modified + source of truth files
165
198
 
199
+ Verifies plan.json and every .task/*.json exists on disk before reporting completed; else report blocked.
200
+
166
201
  ### A_PLAN_CHECK
167
202
  Run plan-checker: coverage, dependency validity, criteria quality, pressure pass on highest-complexity task.
168
203
  Confidence: 5-dimension factor model + readiness gate.
@@ -137,17 +137,17 @@ S_COMPLETE:
137
137
 
138
138
  1. **Checkpoint**: handle inline — save snapshot, update context.last_checkpoint, mark completed. If auto_continue==false: AskUserQuestion (Continue/Pause/Abort).
139
139
 
140
- 2. **Skill nodes**: resolve runtime references → write wave-{N}.csv → spawn:
140
+ 2. **Skill nodes**: resolve runtime references → write wave-{N}.csv (only rows with status == "pending") → spawn:
141
141
  ```
142
142
  spawn_agents_on_csv({
143
143
  csv_path: "wave-{N}.csv", id_column: "id",
144
144
  instruction: SUB_AGENT_INSTRUCTION,
145
- max_workers: waveSteps.length, max_runtime_seconds: 3600,
145
+ max_concurrency: waveSteps.length, max_runtime_seconds: 3600,
146
146
  output_csv_path: "wave-{N}-results.csv", output_schema: RESULT_SCHEMA
147
147
  })
148
148
  ```
149
149
 
150
- 3. Read results → update step status/findings/artifacts
150
+ 3. Read results → map `result_status` → master step `status`; copy `summary` into findings and `artifacts` into the step artifact list
151
151
  4. **Barrier analysis**: read artifacts, update context per barrier table
152
152
  5. Append wave record to state.waves[], persist state.json
153
153
 
@@ -158,14 +158,33 @@ spawn_agents_on_csv({
158
158
  先原样执行技能调用:{skill_call}
159
159
  然后基于结果完成任务说明:{topic}
160
160
  限制:不要修改 .workflow/.maestro/ 下的 state 文件
161
- 最后调用 report_agent_job_result,返回 JSON:
162
- {"status":"completed|failed","skill_call":"...","summary":"一句话","artifacts":"路径或空","error":"原因或空"}
161
+ 最后必须调用 report_agent_job_result(无论成功/失败/超时都必须上报)。
162
+
163
+ TERMINATION CONTRACT(强制):
164
+ - 成功:result_status = completed,summary 描述产出
165
+ - 失败:result_status = failed,error 写明原因
166
+ - 超时:临近 max_runtime_seconds 时立即上报 result_status = failed,error = "timeout"
167
+ - 禁止:无限循环、静默退出、跳过 report_agent_job_result
168
+
169
+ OUTPUT(必须匹配 output_schema):
170
+ {"id":"<row id>","result_status":"completed|failed","skill_call":"...","summary":"一句话","artifacts":"路径或空","error":"原因或空"}
163
171
  ```
164
172
 
165
173
  ### RESULT_SCHEMA
166
174
 
167
175
  ```json
168
- { "status": "completed|failed", "skill_call": "", "summary": "", "artifacts": "", "error": "" }
176
+ {
177
+ "type": "object",
178
+ "properties": {
179
+ "id": { "type": "string" },
180
+ "result_status": { "type": "string", "enum": ["completed", "failed"] },
181
+ "skill_call": { "type": "string" },
182
+ "summary": { "type": "string", "maxLength": 500 },
183
+ "artifacts": { "type": "string" },
184
+ "error": { "type": "string" }
185
+ },
186
+ "required": ["id", "result_status", "summary"]
187
+ }
169
188
  ```
170
189
 
171
190
  </actions>