@laitszkin/apollo-toolkit 5.0.4 → 5.0.5

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this repository are documented in this file.
4
4
 
5
+ ## [v5.0.5] - 2026-06-07
6
+
7
+ ### Changed
8
+
9
+ - **P1-P5 prompt architecture**: `plan` and `qa` coordinator prompt templates (PROMPT.md, FIX.md) restructured into 5-section architecture: Your Role & Rules → Context → Execution Plan → Final Verification → References. All behavioral rules consolidated into Section 1.
10
+ - **Dual parallelism gate**: Both `plan` and `qa` skills' parallelism conditions updated to require BOTH zero file overlap AND no logical dependency. Previous versions only enforced file overlap as the hard gate.
11
+ - **Independent worker prompt templates**: Worker prompt formats extracted from inline SKILL.md blocks into dedicated template files (`WORKER_PROMPT.md`, `FIX_WORKER.md`, `REGTEST_WORKER.md`), each following the P1-P5 architecture.
12
+ - **References section cleaned**: Hard-coded project file names removed from template placeholders, using generic descriptions with `— e.g.,` pattern consistent with other skills.
13
+
5
14
  ## [v5.0.4] - 2026-06-07
6
15
 
7
16
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laitszkin/apollo-toolkit",
3
- "version": "5.0.4",
3
+ "version": "5.0.5",
4
4
  "description": "Apollo Toolkit npm installer for managed skill copying across Codex, OpenClaw, and Trae.",
5
5
  "license": "MIT",
6
6
  "author": "LaiTszKin",
@@ -60,7 +60,7 @@ Decompose the architecture design from DESIGN.md into tasks precise to the file
60
60
 
61
61
  **Decide whether each task needs an independent worker:**
62
62
  - Touches ≥2 files → needs independent worker
63
- - **No file overlap between tasks → workers may run in parallel.** This is permitted ONLY when file lists have ZERO overlap across all workers within the same batch. Any shared file between tasks means sequential execution — this is a hard constraint to prevent overwrite conflicts.
63
+ - **Workers may run in parallel only when BOTH conditions are met:** (1) file lists have ZERO overlap across all workers within the same batch, AND (2) no logical dependency exists between the tasks. If either condition is violated, the tasks must run sequentially.
64
64
  - File overlap or logical dependency between tasks → must run sequentially
65
65
  - Purely procedural operations (lockfile update, merge, commit) → no worker needed; coordinator handles directly
66
66
 
@@ -85,13 +85,13 @@ Analyze dependencies between specs:
85
85
 
86
86
  Output: Spec DAG.
87
87
 
88
- ### 5. Detect File Overlap (Parallelism Gate)
88
+ ### 5. Parallelism Gate (File Overlap + Logical Dependency)
89
89
 
90
- File overlap detection is the **gate that determines parallelism**. Perform this across all task units:
90
+ File overlap detection and dependency analysis form the **dual gate that determines parallelism**. Parallel execution is only permitted when BOTH conditions are met:
91
91
 
92
92
  1. Collect the file list each task unit is expected to modify
93
- 2. Compare file lists and mark overlaps — zero overlap is the **only** condition for parallel execution
94
- 3. Any file overlap at all must be sequential. This is a hard constraint never dispatch parallel workers for tasks sharing a file
93
+ 2. Compare file lists and mark overlaps — zero overlap is required for parallel execution. Any file overlap at all → must be sequential. This is a hard constraint — never dispatch parallel workers for tasks sharing a file.
94
+ 3. Check for logical dependencies between task units even with no file overlap, tasks that depend on each other's output must run sequentially.
95
95
 
96
96
  ### 6. Write Worker Prompts (One Per Dispatchable Task)
97
97
 
@@ -99,17 +99,15 @@ For each task that needs an independent worker, write a self-contained worker pr
99
99
 
100
100
  **Worker prompt file naming**: `plan/T{batch}.{sequence}-{kebab-case-name}.md`
101
101
 
102
- Each worker prompt must include:
102
+ Use `assets/templates/WORKER_PROMPT.md`. The template follows the P1-P5 architecture:
103
103
 
104
- ```
105
- ## Mission — What to do and why
106
- ## Input Which files to read
107
- ## What to do Concrete steps, each specifying the exact file path, the function or line range, and what specific change to make (add/delete/modify). Never leave the change description vague.
108
- ## Scope Allowed and forbidden files
109
- ## Output What to report on completion (file list, change summary, test results, risks)
110
- ## Verify Verification commands and expected results
111
- ## Boundaries — Constraints (don't touch other workers' files, don't add dependencies, report blockers)
112
- ```
104
+ | Section | Purpose (P#) |
105
+ |---------|--------------|
106
+ | 1. Mission & Rules | Goal + behavioral rules |
107
+ | 2. Context | Files to read, background knowledge |
108
+ | 3. Tasks | Concrete file-level instructions (file, line range, change) |
109
+ | 4. Verification | Commands and expected results |
110
+ | 5. Scope & References | Allowed/forbidden files, related references |
113
111
 
114
112
  **Writing principles (move these to your process, not the template):**
115
113
  - **Self-contained**: Workers do not see the coordinator's context. The prompt must include everything necessary. Do not rely on shared context or assume the worker has read other documents.
@@ -123,8 +121,8 @@ Tasks that do not need a worker (purely procedural operations) do not get a work
123
121
 
124
122
  Based on dependency analysis and file overlap detection, build the batch schedule → PROMPT.md Section 7 (Batch Schedule).
125
123
 
126
- **Batch partitioning principles (file overlap is the hard gate):**
127
- - Within the same batch: tasks must have ZERO file overlap — only then may they dispatch workers in parallel. File-overlapping tasks must be placed in separate sequential batches regardless of dependency
124
+ **Batch partitioning principles (file overlap and logical dependency are the hard gates):**
125
+ - Within the same batch: tasks must have ZERO file overlap AND no logical dependency — only then may they dispatch workers in parallel. Tasks with file overlap or logical dependency must be placed in separate sequential batches regardless.
128
126
  - Between batches: the previous batch must complete and pass its gate before the next batch begins
129
127
  - A final integration batch handles housekeeping tasks (lockfile update, final test suite)
130
128
 
@@ -151,17 +149,11 @@ Use `assets/templates/PROMPT.md`. Fill each section according to the table below
151
149
 
152
150
  | Section | Content Source |
153
151
  |---------|---------------|
154
- | 1. Your Role | Fixed template (no modification needed) |
155
- | 2. Mission | SPEC.md Goal + business value |
156
- | 3. Scope & Boundaries | SPEC.md In/Out of Scope |
157
- | 4. Technical Context | DESIGN.md: module list with responsibilities, interaction anchors (INT-###) and dependency order, external dependency setup order (EXT-###), system invariants, technical decisions and trade-offs |
158
- | 5. Task Units | Step 3 (task decomposition) + Step 4 (dependency analysis) |
159
- | 6. Worker Prompt Index | Step 6 — list of `plan/*.md` files with task ID mapping |
160
- | 7. Batch Schedule | Step 7 (batch schedule) |
161
- | 8. Verification Checkpoints | CHECKLIST.md: behavior-to-test mapping (CL-###), hardening requirements, test execution commands |
162
- | 9. Error Recovery | Fixed template — populate spec-specific test commands from CHECKLIST.md |
163
- | 10. Boundaries | Fixed template + spec-specific rules (including worktree cleanup after each batch) |
164
- | 11. References | Worker prompt file paths (`plan/*.md`), all code file paths that need modification across all tasks, project context files (CLAUDE.md, AGENTS.md, architecture atlas, codegraph index) |
152
+ | 1. Your Role & Rules | Fixed template (Mission from SPEC.md Goal + business value; Boundaries + Error Recovery are fixed scaffold; add spec-specific rules) |
153
+ | 2. Context | SPEC.md In/Out of Scope + DESIGN.md: module list with responsibilities, interaction anchors (INT-###) and dependency order, external dependency setup order (EXT-###), system invariants, technical decisions and trade-offs |
154
+ | 3. Execution Plan | Step 3 (task decomposition) + Step 4 (dependency analysis) + Step 6 (worker prompts per `assets/templates/WORKER_PROMPT.md`) + Step 7 (batch schedule). Per-batch verification commands from CHECKLIST.md |
155
+ | 4. Final Verification | Fixed scaffold (meta-checks) |
156
+ | 5. References | Worker prompt file paths (`plan/*.md`), all code file paths that need modification across all tasks, project context files, related documents |
165
157
 
166
158
  ### 11. Pre-delivery Self-Review
167
159
 
@@ -176,16 +168,16 @@ Before delivering PROMPT.md, verify all of the following.
176
168
 
177
169
  **Coverage completeness:**
178
170
 
179
- - Every BDD requirement from SPEC.md is addressed by at least one task in Section 5. If a requirement has no task, add one or document why it is already satisfied by existing code.
171
+ - Every BDD requirement from SPEC.md is addressed by at least one task in Section 3 (Task Units). If a requirement has no task, add one or document why it is already satisfied by existing code.
180
172
  - Every module from DESIGN.md has a corresponding task or is explicitly noted as unchanged.
181
- - Every hardening requirement from CHECKLIST.md appears in Section 8.
173
+ - Every hardening requirement from CHECKLIST.md appears in Section 4 (Final Verification) or in the Batch Schedule gates.
182
174
 
183
175
  **Structural consistency:**
184
176
 
185
- - Each task's Depends on field in Section 5 matches the batch ordering in Section 7. No task scheduled in a batch before its dependencies are met.
186
- - Every task listed in Section 7 (Batch Schedule) has a worker prompt in `plan/*.md` — unless it is explicitly marked as coordinator-handled.
187
- - No orphaned tasks (a task listed in Section 5 that never appears in any batch), no missing dependencies (a Depends on field referencing a task ID that does not exist).
188
- - PROMPT.md References section lists all worker prompt paths and all code file paths.
177
+ - Each task's Depends on field matches the batch ordering. No task scheduled in a batch before its dependencies are met.
178
+ - Every task listed in Batch Schedule has a worker prompt in `plan/*.md` — unless it is explicitly marked as coordinator-handled.
179
+ - No orphaned tasks (a task listed in Task Units that never appears in any batch), no missing dependencies (a Depends on field referencing a task ID that does not exist).
180
+ - Section 5 (References) lists all worker prompt paths and all code file paths.
189
181
 
190
182
  ### 12. Produce PROMPT.md and Worker Prompts
191
183
 
@@ -200,4 +192,5 @@ Place worker prompts in `<spec_dir>/plan/` or `<batch_dir>/plan/`.
200
192
 
201
193
  ## References
202
194
 
203
- - `assets/templates/PROMPT.md` — PROMPT.md template
195
+ - `assets/templates/PROMPT.md` — Coordinator prompt template
196
+ - `assets/templates/WORKER_PROMPT.md` — Worker prompt template (used in Step 6)
@@ -8,91 +8,124 @@
8
8
 
9
9
  ---
10
10
 
11
- ## 1. Your Role
11
+ ## 1. Your Role & Rules
12
12
 
13
- **You are the implementation coordinator.** You do not write code. Your job is to think, plan, delegate, synthesize, and verify.
13
+ [P1: Rules and regulations the agent needs to follow; Goal of the coordinator.]
14
+
15
+ ### Mission
16
+
17
+ [One paragraph telling the coordinator what we are building and why. Distilled from SPEC.md's Goal and business value.]
18
+
19
+ **Success looks like**: [One sentence describing the observable result when all batches complete.]
14
20
 
15
- ### What you do
21
+ ### Your Role
16
22
 
23
+ **You are the implementation coordinator.** You do not write code. Your job is to think, plan, delegate, synthesize, and verify.
24
+
25
+ **What you do:**
17
26
  - Read and understand the mission, scope, technical context, and task definitions below
18
- - Spawn workers to execute individual tasks, giving each a self-contained prompt (provided in Section 6)
27
+ - Spawn workers to execute individual tasks, giving each a self-contained prompt (provided in Section 3 Worker Prompt Index)
19
28
  - Wait for all workers in a batch to complete, then digest their results
20
29
  - Run verification commands at each checkpoint
21
30
  - Decide whether to proceed to the next batch, retry a failed worker, or halt
22
- - Handle lightweight coordination tasks: resolving merge conflicts, updating lockfiles, cleaning up worktrees
23
- - Commit all changes in a single commit after the final verification gate passes
24
-
25
- ### What you NEVER do
31
+ - Handle lightweight coordination tasks: resolving merge conflicts, cleaning up worktrees
32
+ - Commit all changes in a single commit after final verification passes
26
33
 
34
+ **What you NEVER do:**
27
35
  - Write implementation logic or modify source code beyond resolving merge conflict markers
28
36
  - Skip a verification checkpoint
29
37
  - Proceed to the next batch when the current batch has not passed verification
30
38
  - Delegate comprehension — digest every worker result yourself before deciding next steps
31
39
  - Let workers spawn their own workers (workers are leaf nodes)
32
40
 
33
- ---
41
+ ### Boundaries
34
42
 
35
- ## 2. Mission
43
+ **ALWAYS**
44
+ - Run gate verification immediately after every batch
45
+ - Extract worker prompts verbatim from `plan/*.md` files — do not rewrite them
46
+ - After a worker reports, digest the results before deciding next steps
47
+ - Follow the File Ownership implied by task assignments — do not let two workers modify the same file
48
+ - Resolve merge conflicts yourself — the coordinator handles them
49
+ - After each batch completes, clean up any temporary branches or worktrees created by workers
50
+ - After two failures, pause and ask — do not keep retrying
36
51
 
37
- [One paragraph telling the coordinator what we are building and why. Distilled from SPEC.md's Goal and business value.]
52
+ **ASK FIRST** pause and confirm with the user:
53
+ - Need to modify a file not defined in SPEC/DESIGN
54
+ - Need to add a new external dependency
55
+ - Worker has failed twice
56
+ - Test regression cannot be quickly diagnosed
38
57
 
39
- **Success looks like**: [One sentence describing the observable result when all batches complete.]
58
+ **NEVER**
59
+ - Write implementation logic or modify source code beyond resolving merge conflict markers
60
+ - Let workers spawn sub-workers
61
+ - Skip verification and proceed to the next batch
62
+ - Give workers vague instructions (e.g., "fix it" or "based on what you found")
63
+ - Expand implementation scope beyond what is defined in Section 2 Scope
64
+ - Proceed to the next batch when the current batch's gate has not passed
65
+
66
+ ### Error Recovery
67
+
68
+ | Scenario | Response |
69
+ |---|---|
70
+ | A single worker reports failure | Retry with the worker's existing context (do not create a new one), giving more specific guidance. At most one retry. |
71
+ | Same worker fails twice | Pause the entire flow. Preserve successful results from other workers in the same batch. Report to the user: which task failed, what was tried, suggested next steps. |
72
+ | Merge conflict (merging worker results) | Coordinator resolves the conflict, then re-runs the batch gate verification. |
73
+ | Test regression (new code breaks existing tests) | Pause. Report to the user: which test failed, likely cause, which worker was involved. Do not weaken the test to make it pass. |
74
+ | Contradiction in SPEC/DESIGN or infeasible design found during implementation | Pause. Document the specific contradiction and notify the user. |
40
75
 
41
76
  ---
42
77
 
43
- ## 3. Scope & Boundaries
78
+ ## 2. Context
44
79
 
45
- ### What we WILL implement
80
+ [P2: What the agent needs to read before it starts working.]
46
81
 
47
- [Distilled from SPEC.md's In Scope and BDD requirements. Bullet list.]
82
+ ### Scope
48
83
 
49
- ### What we will NOT implement
84
+ **What we WILL implement:**
85
+ [Distilled from SPEC.md's In Scope and BDD requirements. Bullet list.]
50
86
 
87
+ **What we will NOT implement:**
51
88
  [Distilled from SPEC.md's Out of Scope. Every worker must respect these boundaries.]
52
89
 
53
- ---
54
-
55
- ## 4. Technical Context
90
+ ### Technical Context
56
91
 
57
92
  [Enough context for the coordinator to understand worker reports and make decisions. Not every detail from DESIGN.md — just what the coordinator needs.]
58
93
 
59
- ### Modules involved
94
+ **Modules involved:**
60
95
 
61
96
  | Module | Responsibility |
62
97
  |---|---|
63
- | `[module-key]` | [One sentence] |
64
-
65
- ### Invariants — must never be broken
98
+ | [module-key] | [One sentence] |
66
99
 
67
- - [Invariant statement]
100
+ **Invariants must never be broken:**
68
101
  - [Invariant statement]
69
102
 
70
- ### Technical decisions to follow
71
-
72
- - **[Decision]** — [Rationale]. Workers must: [constraint].
103
+ **Technical decisions to follow:**
73
104
  - **[Decision]** — [Rationale]. Workers must: [constraint].
74
105
 
75
106
  ---
76
107
 
77
- ## 5. Task Units
108
+ ## 3. Execution Plan
78
109
 
79
- [Each task is an atomic work unit. Task ID format: `T{batch}.{sequence}`.]
110
+ [P3: Batch tasks which workers to dispatch in each batch, per-batch verification gates.]
80
111
 
81
- ### Task details
112
+ ### Task Units
113
+
114
+ [Each task is an atomic work unit. Task ID format: `T{batch}.{sequence}`.]
82
115
 
83
116
  #### T{batch}.{sequence}: [Task name]
84
117
 
85
118
  - **Goal**: [One sentence]
86
- - **Files**: `[file list]`
119
+ - **Files**: `[file path]`
87
120
  - **Worker prompt**: `plan/T{batch}.{sequence}-[name].md`
88
121
  - **Depends on**: [Task ID, or — (no dependency)]
89
122
  - **Verify**:
90
123
  - Command: `[command]`
91
124
  - Expected: [what you should see]
92
125
 
93
- ---
126
+ [Repeat for each task unit.]
94
127
 
95
- ## 6. Worker Prompt Index
128
+ ### Worker Prompt Index
96
129
 
97
130
  [Each dispatchable task has a pre-written self-contained worker prompt in a separate file under `plan/`. The coordinator reads the corresponding file and dispatches it without modification.]
98
131
 
@@ -103,37 +136,31 @@
103
136
 
104
137
  [Tasks handled directly by the coordinator (purely procedural operations) do not have an entry here.]
105
138
 
106
- ---
107
-
108
- ## 7. Batch Schedule
139
+ ### Batch Schedule
109
140
 
110
- [Batched according to the dependency graph. Tasks within the same batch have no file overlap and no logical dependency — they can run in parallel.]
141
+ *Tasks within the same batch have no file overlap and no logical dependency — they may be dispatched in parallel.*
111
142
 
112
- ### Batch 1 — [name]
143
+ #### Batch 1 — [name]
113
144
 
114
- - **Tasks**: T1.1, T1.2, T1.3
115
- - **Strategy**: [Dispatch N workers in parallel / Sequential]
116
- - **Gate** (all items must pass before next batch):
145
+ - **Tasks**: T1.1, T1.2
146
+ - **Strategy**: Parallel
147
+ - **Gate** (all must pass before next batch):
117
148
  - [ ] T1.1 worker reports success
118
149
  - [ ] T1.2 worker reports success
119
- - [ ] Run verification: `[command]`
150
+ - [ ] Verification: `[command]` → [expected result]
120
151
 
121
- ---
122
-
123
- ### Batch 2 — [name]
152
+ #### Batch 2 — [name]
124
153
 
125
154
  - **Tasks**: T2.1
126
- - **Strategy**: [Parallel / Sequential]
155
+ - **Strategy**: Sequential
127
156
  - **Depends on**: Batch 1
128
157
  - **Gate**:
129
158
  - [ ] T2.1 worker reports success
130
- - [ ] Run verification: `[command]`
131
-
132
- ---
159
+ - [ ] Verification: `[command]` → [expected result]
133
160
 
134
- ### Batch N — Final Integration
161
+ #### Batch N — Final Integration
135
162
 
136
- - **Tasks**: [Integration tasks, lockfile update, final test suite]
163
+ - **Tasks**: [Integration tasks, lockfile update, full test suite]
137
164
  - **Strategy**: Sequential (coordinator handles directly or dispatches a single worker)
138
165
  - **Depends on**: All preceding batches
139
166
  - **Gate**:
@@ -142,76 +169,24 @@
142
169
 
143
170
  ---
144
171
 
145
- ## 8. Verification Checkpoints
146
-
147
- ### Per-batch
148
-
149
- | Batch | Verification Command | Expected Result |
150
- |---|---|---|
151
- | Batch 1 | `[command]` | [expected] |
152
- | Batch 2 | `[command]` | [expected] |
153
-
154
- ### Key behavior checks (from CHECKLIST.md)
172
+ ## 4. Final Verification
155
173
 
156
- | ID | Observable Behavior | How to verify |
157
- |---|---|---|
158
- | CL-01 | [Behavior description] | `[test command]` |
159
- | CL-02 | [Behavior description] | `[test command]` |
174
+ [P4: Meta-checks after all batches complete. These verify completeness beyond what per-batch gates already cover.]
160
175
 
161
- ### Final verification
162
-
163
- - [ ] Full test suite passes: `[command]`
164
- - [ ] Lint passes: `[command]`
176
+ - [ ] Every BDD requirement from SPEC.md is addressed by a completed task
177
+ - [ ] All worker prompts in Section 3 have been dispatched and returned success
178
+ - [ ] No orphaned tasks every Task Unit defined in Section 3 has been completed
179
+ - [ ] All changes committed in a single commit
165
180
 
166
181
  ---
167
182
 
168
- ## 9. Error Recovery
169
-
170
- | Scenario | Response |
171
- |---|---|
172
- | A single worker reports failure | Retry with the worker's existing context (do not create a new one), giving more specific guidance. At most one retry. |
173
- | Same worker fails twice | Pause the entire flow. Preserve successful results from other workers in the same batch. Report to the user: which task failed, what was tried, suggested next steps. |
174
- | Merge conflict (merging worker results) | Coordinator resolves the conflict, then re-runs the batch gate verification. |
175
- | Test regression (new code breaks existing tests) | Pause. Report to the user: which test failed, likely cause, which worker was involved. Do not weaken the test to make it pass. |
176
- | Contradiction in SPEC/DESIGN or infeasible design found during implementation | Pause. Document the specific contradiction and notify the user. |
177
-
178
- ---
179
-
180
- ## 10. Boundaries
181
-
182
- ### ALWAYS
183
-
184
- - Run gate verification immediately after every batch
185
- - Extract worker prompts verbatim from `plan/*.md` files — do not rewrite them
186
- - After a worker reports, digest the results before deciding next steps
187
- - Follow the File Ownership implied by task assignments — do not let two workers modify the same file
188
- - **Resolve merge conflicts yourself** — when combining worker results, the coordinator handles conflict resolution. This is coordination, not implementation.
189
- - **After each batch completes, clean up any temporary branches or worktrees created by workers** — no ephemeral worktree should be left orphaned.
190
- - After two failures, pause and ask — do not keep retrying
191
-
192
- ### ASK FIRST — pause and confirm with the user
193
-
194
- - Need to modify a file not defined in SPEC/DESIGN
195
- - Need to add a new external dependency
196
- - Worker has failed twice
197
- - Test regression cannot be quickly diagnosed
198
-
199
- ### NEVER
200
-
201
- - Write implementation logic or modify source code beyond resolving merge conflict markers
202
- - Workers spawn sub-workers
203
- - Skip verification and proceed to the next batch
204
- - Give workers vague instructions (e.g., "fix it" or "based on what you found")
205
- - Expand implementation scope beyond Section 3
206
- - Proceed to the next batch when the current batch's gate has not passed
207
-
208
- ---
183
+ ## 5. References
209
184
 
210
- ## 11. References
185
+ [P5: Reference files for coordinator and workers.]
211
186
 
212
187
  - **Worker prompt files**: [List all `plan/*.md` files — e.g., `plan/T1.1-implement-login.md`, `plan/T1.2-implement-logout.md`]
213
188
  - **Code files to modify** (across all tasks):
214
189
  - [File path — e.g., `src/auth/login.ts`]
215
190
  - [File path — e.g., `src/auth/logout.ts`]
216
- - **Project context files**: [List important project files — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`, codegraph index files]
217
- - **Related documents**: [Links to related specs, design docs, or external documentation]
191
+ - **Project context files**: [List project context files the coordinator may need — e.g., CLAUDE.md, AGENTS.md, project architecture files]
192
+ - **Related documents**: [Links to SPEC.md, DESIGN.md, or external documentation]
@@ -0,0 +1,92 @@
1
+ # Worker Prompt: T{batch}.{sequence}-{kebab-case-name}
2
+
3
+ - **Source task**: [Task ID and name from coordinator]
4
+
5
+ ---
6
+
7
+ ## 1. Mission & Rules
8
+
9
+ [P1: Goal of this task and behavioral rules.]
10
+
11
+ ### Mission
12
+
13
+ [One sentence — what to implement and why.]
14
+
15
+ ### Rules
16
+
17
+ - Follow the Scope in Section 5 — only modify files listed as Allowed
18
+ - If a file or function cannot be found, or the implementation is blocked, report it immediately — do not guess or work around it
19
+ - Do not add new dependencies without reporting to the coordinator first
20
+ - Workers are leaf nodes — do not spawn sub-workers
21
+
22
+ ---
23
+
24
+ ## 2. Context
25
+
26
+ [P2: Files to read before starting, background information.]
27
+
28
+ ### Input Files
29
+
30
+ - [File path] — [what to look for in this file]
31
+ - [File path] — [what to look for in this file]
32
+
33
+ ### Background
34
+
35
+ [Design context, relevant spec requirements, or patterns to follow that help the worker understand what to build and why.]
36
+
37
+ ---
38
+
39
+ ## 3. Tasks
40
+
41
+ [P3: Concrete, file-level instructions. Each entry specifies the exact file path, function or line range, and what to add/delete/modify.]
42
+
43
+ ### [File path] — [what to do]
44
+
45
+ 1. Open `[file path]`
46
+ 2. Locate `[function / class / line range]`
47
+ 3. [Add / Modify / Delete] the following:
48
+ - **Before** (what currently exists): [current code or description]
49
+ - **After** (what it should become): [new code or description]
50
+ 4. [Additional step if needed]
51
+
52
+ [Repeat for each file or logical change group.]
53
+
54
+ ### Output
55
+
56
+ When done, report back to the coordinator:
57
+ - **Files modified**: [list of files]
58
+ - **Change summary**: [brief description]
59
+ - **Test results**: [pass/fail]
60
+ - **Risks or concerns**: [or "None"]
61
+
62
+ ---
63
+
64
+ ## 4. Verification
65
+
66
+ [P4: How to confirm the changes work correctly.]
67
+
68
+ 1. Run: `[command]`
69
+ - Expected: [result]
70
+ 2. Run: `[command]`
71
+ - Expected: [result]
72
+
73
+ ---
74
+
75
+ ## 5. Scope & References
76
+
77
+ [P5: Allowed/forbidden files and related reference files.]
78
+
79
+ ### Allowed Files
80
+
81
+ - [file path] — [reason]
82
+ - [file path] — [reason]
83
+
84
+ ### Forbidden Files
85
+
86
+ - [file path] — [reason, e.g., "owned by another worker"]
87
+ - [file path] — [reason]
88
+
89
+ ### Related References
90
+
91
+ - [file path] — [what it provides]
92
+ - [file path] — [what it provides]
@@ -97,13 +97,13 @@ Design principles:
97
97
  - **Independent issues**: No file overlap and no logical dependency → can be parallel
98
98
  - **Regression test dependency**: Regression tests must run after their corresponding fix is complete (tests verify the fixed code)
99
99
 
100
- ### 6. Detect File Overlap (Parallelism Gate)
100
+ ### 6. Parallelism Gate (File Overlap + Logical Dependency)
101
101
 
102
- File overlap detection is the **gate that determines parallel vs sequential execution**. Perform this across all fixes and regression tests:
102
+ File overlap detection and dependency analysis form the **dual gate that determines parallel vs sequential execution**. Parallel execution is only permitted when BOTH conditions are met:
103
103
 
104
104
  1. Collect the file list for each fix and regression test
105
- 2. Compare file lists and mark overlaps — zero overlap is the only condition for parallel execution
106
- 3. Any file overlap at all must be sequential. This is a hard constraint never dispatch parallel workers for overlapping files
105
+ 2. Compare file lists and mark overlaps — zero overlap is required for parallel execution. Any file overlap at all → must be sequential. This is a hard constraint — never dispatch parallel workers for tasks sharing a file.
106
+ 3. Check for logical dependencies between fixes even with no file overlap, a fix that depends on another fix's output must run sequentially.
107
107
 
108
108
  ### 7. Write Worker Prompts
109
109
 
@@ -113,18 +113,15 @@ Write a self-contained worker prompt for each fix issue. Save each prompt to a s
113
113
 
114
114
  **Worker prompt file naming**: `fix/FIX-{sequence}-{kebab-case-name}.md`
115
115
 
116
- Each fix worker prompt must include:
116
+ Use `assets/templates/FIX_WORKER.md`. The template follows the P1-P5 architecture:
117
117
 
118
- ```
119
- ## Mission — What to fix and why
120
- ## Context Which review dimension, which spec requirement
121
- ## Input Which files to read
122
- ## What to do Concrete fix steps, each specifying the exact file path, the function or line range, and what specific change to make (add/delete/modify). Never leave the change description vague.
123
- ## Scope Allowed and forbidden files
124
- ## Output What to report on completion
125
- ## Verify — Verification commands and expected results
126
- ## Boundaries — Constraints (don't conflict with spec, preserve existing test semantics, report blockers)
127
- ```
118
+ | Section | Purpose (P#) |
119
+ |---------|--------------|
120
+ | 1. Mission & Rules | Goal + behavioral rules (preserve tests, no scope creep) |
121
+ | 2. Context | Input files, root cause analysis |
122
+ | 3. Tasks | Concrete fix steps (file, line range, before/after) |
123
+ | 4. Verification | Commands and expected results |
124
+ | 5. Scope & References | Allowed/forbidden files, related documents |
128
125
 
129
126
  **Simple fixes can be merged**: Multiple simple, non-conflicting fixes can be combined into one worker prompt.
130
127
  **Complex fixes stand alone**: Complex fixes (requiring systematic debug) must have independent worker prompts.
@@ -135,19 +132,15 @@ Write a self-contained worker prompt for each regression test. The regression te
135
132
 
136
133
  **Worker prompt file naming**: `fix/REGTEST-{sequence}-{kebab-case-name}.md`
137
134
 
138
- Each regression test worker prompt must include:
135
+ Use `assets/templates/REGTEST_WORKER.md`. The template follows the P1-P5 architecture:
139
136
 
140
- ```
141
- ## Mission — Which fix needs a regression test and why
142
- ## Context What the fix addressed (summary), root cause
143
- ## Input Which files to read (fix-related files + existing test files as format reference)
144
- ## What to do Concrete test writing steps:
145
- 1. Create the test at the specified location
146
- 2. Test scenario (GIVEN/WHEN/THEN)
147
- 3. Oracle (must fail before fix, must pass after fix)
148
- ## Scope — Allowed test files only
149
- ## Verify — Run the test, confirm it passes (proving the fix works)
150
- ```
137
+ | Section | Purpose (P#) |
138
+ |---------|--------------|
139
+ | 1. Mission & Rules | Goal + behavioral rules (test-only, oracle must fail before fix) |
140
+ | 2. Context | Input files, test design (type, location, scenario, oracle) |
141
+ | 3. Tasks | Concrete test writing steps |
142
+ | 4. Verification | Confirm test fails before fix, passes after |
143
+ | 5. Scope & References | Allowed test files, forbidden source files |
151
144
 
152
145
  **Writing principles (move these to your process, not the template):**
153
146
  - Writing clear worker prompts means being concrete, not declarative. For every file the worker must modify, specify: (1) the exact file path, (2) the function or line range, (3) what to add, delete, or change.
@@ -162,8 +155,8 @@ Each regression test worker prompt must include:
162
155
 
163
156
  ### 8. Create Batch Schedule → FIX.md Section 7
164
157
 
165
- **Batch partitioning principles (file overlap is the hard gate):**
166
- - Fix batches: Ordered by dependencies. P0 issues first. Within each batch, workers require ZERO file overlap to run in parallel — overlapping fixes must be sequentialized across sub-batches
158
+ **Batch partitioning principles (file overlap and logical dependency are the hard gates):**
159
+ - Fix batches: Ordered by dependencies. P0 issues first. Within each batch, workers require ZERO file overlap AND no logical dependency to run in parallel — fixes with file overlap or logical dependency must be sequentialized across sub-batches.
167
160
  - Regression test batches: Dispatched **after all fixes are complete**, because tests verify the fixed code. Regression tests without file overlap can run in parallel; those sharing files must be sequential
168
161
  - Final batch: Full test suite + lint + confirmation that all issues are resolved.
169
162
 
@@ -192,19 +185,11 @@ Use `assets/templates/FIX.md`. Fill according to the table below.
192
185
 
193
186
  | Section | Content Source |
194
187
  |---------|---------------|
195
- | 1. Your Role | Fixed template (no modification needed) |
196
- | 2. Mission | REPORT.md verdict + total issue count |
197
- | 3. Issue Inventory | REPORT.md issue list (condensed to NL one-liners) |
198
- | 4. Fix Dependency Analysis | Steps 5-6 (dependency analysis + file overlap) |
199
- | 5. Fix Details (with regression test design) | Step 3 (fix plan) + Step 4 (regression test design) |
200
- | 6. Worker Prompt Index | Step 7 — list of `fix/*.md` files with FIX/REGTEST ID mapping |
201
- | 7. Fix Batch Schedule | Step 8 (batch schedule) |
202
- | 8. Regression Test Inventory | Step 4 full list. If regtests ≤ 3, omit (Section 5 is sufficient). If ≥ 4, include a condensed NL list. |
203
- | 9. Verification Checkpoints | Fixed scaffold, customized with spec-specific commands |
204
- | 10. Error Recovery | Fixed scaffold (natural language) |
205
- | 11. Fix History | Fixed scaffold (history entries only, no instructions) |
206
- | 12. References | Worker prompt file paths (`fix/*.md`), all code file paths that need modification across all fixes/regtests, project context files |
207
- | 13. Boundaries | Fixed scaffold + spec-specific rules (including worktree cleanup after each batch) |
188
+ | 1. Your Role & Rules | Fixed template (Mission from REPORT.md verdict + total issue count; Boundaries + Error Recovery are fixed scaffold; add spec-specific rules) |
189
+ | 2. Context | Step 3 (issue inventory from REPORT.md) + Steps 5-6 (dependency analysis + file overlap) + Steps 3-4 (fix details + regression test design) |
190
+ | 3. Execution Plan | Step 7 (worker prompts per `assets/templates/FIX_WORKER.md` and `assets/templates/REGTEST_WORKER.md`) + Step 8 (batch schedule). Per-batch verification commands from CHECKLIST.md |
191
+ | 4. Final Verification | Fixed scaffold (meta-checks) |
192
+ | 5. References | Worker prompt file paths (`fix/*.md`), all code file paths that need modification across all fixes/regtests, project context files, Fix History |
208
193
 
209
194
  ### 11. Pre-delivery Self-Review
210
195
 
@@ -225,7 +210,7 @@ Before delivering FIX.md, verify all of the following.
225
210
 
226
211
  - Each fix's dependency analysis matches the batch ordering. No fix scheduled before its dependencies are met.
227
212
  - Regression tests are scheduled after all fix batches complete.
228
- - FIX.md References section lists all worker prompt paths and all code file paths.
213
+ - Section 5 (References) lists all worker prompt paths and all code file paths.
229
214
 
230
215
  ### 12. Produce FIX.md and Worker Prompts
231
216
 
@@ -240,4 +225,6 @@ Place worker prompts in `<spec_dir>/fix/` or `<batch_dir>/fix/`.
240
225
 
241
226
  ## References
242
227
 
243
- - `assets/templates/FIX.md` — FIX.md template
228
+ - `assets/templates/FIX.md` — Coordinator prompt template
229
+ - `assets/templates/FIX_WORKER.md` — Fix worker prompt template (used in Step 7a)
230
+ - `assets/templates/REGTEST_WORKER.md` — Regression test worker prompt template (used in Step 7b)
@@ -8,14 +8,23 @@
8
8
 
9
9
  ---
10
10
 
11
- ## 1. Your Role
11
+ ## 1. Your Role & Rules
12
12
 
13
- **You are the fix coordinator.** You do not write code. Your job is to understand the issues found in code review, delegate each fix and regression test to a worker, and verify that every issue is resolved without introducing regressions.
13
+ [P1: Rules and regulations the agent needs to follow; Goal of the coordinator.]
14
+
15
+ ### Mission
16
+
17
+ [One paragraph summarizing the scope, total issues, regression test count, and overall execution strategy.]
18
+
19
+ **Success looks like**: All issues in REPORT.md are fixed, all regression tests pass, full test suite passes, no regressions.
14
20
 
15
- ### What you do
21
+ ### Your Role
16
22
 
23
+ **You are the fix coordinator.** You do not write code. Your job is to understand the issues found in code review, delegate each fix and regression test to a worker, and verify that every issue is resolved without introducing regressions.
24
+
25
+ **What you do:**
17
26
  - Read and understand the issue inventory, dependency analysis, and fix details below
18
- - Spawn workers to execute individual fixes, giving each a self-contained prompt (provided in Section 6)
27
+ - Spawn workers to execute individual fixes, giving each a self-contained prompt (provided in Section 3 Worker Prompt Index)
19
28
  - After all fixes pass verification, spawn workers to implement regression tests
20
29
  - Wait for all workers in a batch to complete, then digest their results
21
30
  - Run verification commands at each checkpoint
@@ -23,8 +32,7 @@
23
32
  - Handle lightweight coordination tasks: resolving merge conflicts, updating lockfiles
24
33
  - Commit all changes in a single commit after the final verification gate passes
25
34
 
26
- ### What you NEVER do
27
-
35
+ **What you NEVER do:**
28
36
  - Write, edit, or modify any source-code or test file directly
29
37
  - Skip a verification checkpoint
30
38
  - Proceed to the next batch when the current batch has not passed verification
@@ -33,107 +41,134 @@
33
41
  - Start regression tests before all fixes in scope are verified
34
42
  - Defer any REPORT.md issue to a future round — every issue has a complete plan here
35
43
 
36
- ---
44
+ ### Boundaries
37
45
 
38
- ## 2. Mission
46
+ **ALWAYS**
47
+ - Run gate verification immediately after every batch
48
+ - Extract worker prompts verbatim from `fix/*.md` files — do not rewrite them
49
+ - After a worker reports, digest the results before deciding next steps
50
+ - Fixes must not conflict with the original spec requirements
51
+ - Regression tests must not start before all fix batches pass
52
+ - Resolve merge conflicts yourself — the coordinator handles them
53
+ - For fixes marked as Complex: ensure the worker performs systematic debugging (reading related code, tracing execution paths) before applying the fix
54
+ - After each batch completes, clean up any temporary branches or worktrees created by workers
39
55
 
40
- [One paragraph summarizing the scope, total issues, regression test count, and overall execution strategy.]
56
+ **ASK FIRST** pause and confirm with the user:
57
+ - Fix approach conflicts with spec design intent
58
+ - Need to add a new external dependency
59
+ - Worker has failed twice
60
+ - Test regression cannot be quickly diagnosed
41
61
 
42
- **Success looks like**: All issues in REPORT.md are fixed, all regression tests pass, full test suite passes, no regressions.
62
+ **NEVER**
63
+ - Write implementation logic or modify source code beyond resolving merge conflict markers
64
+ - Let workers spawn sub-workers
65
+ - Skip verification and proceed to the next batch
66
+ - Modify spec documents (unless the fix reveals a spec error — report it instead)
67
+ - Start regression tests before all fixes are verified
68
+ - Defer any REPORT.md issue to a future round
69
+
70
+ ### Error Recovery
71
+
72
+ | Scenario | Response |
73
+ |---|---|
74
+ | Fix worker reports failure | Retry with the worker's existing context (do not create a new one), giving more specific guidance. At most one retry. |
75
+ | Same fix worker fails twice | Pause the entire flow. Preserve successful results from other workers in the same batch. Report to the user. |
76
+ | Regression test worker reports failure (test cannot pass) | Check whether the test code is wrong or the fix is incomplete. If test code is wrong, continue the worker to fix it. If the fix is incomplete, go back to the corresponding fix worker. |
77
+ | Regression test passes on the unfixed code | The test design is invalid — redesign the oracle and dispatch a new worker. |
78
+ | Merge conflicts | Coordinator resolves the conflict, then re-runs the batch gate verification. |
79
+ | Fix or regression test breaks existing tests | Pause. Report which test failed and which worker's change caused it. |
43
80
 
44
81
  ---
45
82
 
46
- ## 3. Issue Inventory
83
+ ## 2. Context
47
84
 
48
- - FIX-01 (P0, 簡單, 幻覺代碼): [Brief description] src/a.ts
49
- - FIX-02 (P0, 複雜, 實作遺漏): [Brief description] — src/b.ts, src/c.ts
50
- - FIX-03 (P1, 簡單, 架構瑕疵): [Brief description] — src/d.ts
85
+ [P2: What the agent needs to read before it starts working.]
51
86
 
52
- ---
87
+ ### Issue Inventory
53
88
 
54
- ## 4. Fix Dependency Analysis
89
+ - FIX-01 (P0, Simple): [Brief description] — src/a.ts
90
+ - FIX-02 (P0, Complex): [Brief description] — src/b.ts, src/c.ts
91
+ - FIX-03 (P1, Simple): [Brief description] — src/d.ts
55
92
 
56
- ### Dependencies
93
+ [All REPORT.md issues (P0–P3) listed here. The "no-defer" rule applies — every issue has a complete fix plan.]
57
94
 
95
+ ### Fix Dependency Analysis
96
+
97
+ **Dependencies:**
58
98
  - FIX-02 depends on FIX-01 (FIX-01 refactors the interface FIX-02 needs)
59
99
  - FIX-03 is independent
60
100
  - All REGTESTs depend on their corresponding FIX completing first
61
101
 
62
- ### File overlaps
63
-
102
+ **File overlaps:**
64
103
  - FIX-04, FIX-05 both modify `src/e.ts` → must be sequential
65
- - FIX-01, FIX-03: no overlap → can run in parallel
104
+ - FIX-01, FIX-03: no overlap, no logical dependency → can run in parallel
66
105
 
67
- ---
68
-
69
- ## 5. Fix Details (with Regression Test Design)
106
+ ### Fix Details (with Regression Test Design)
70
107
 
71
108
  [Each issue's fix information + corresponding regression test design.]
72
109
 
73
- ### FIX-01: [Issue title] (P0)
110
+ #### FIX-01: [Issue title] (P0)
74
111
 
75
112
  **Root cause**: [Root cause of the issue]
76
113
  **Files involved**: `[path]` > `[functionName()]` (L[N]-[N])
77
114
  **Fix approach**: [How to modify]
78
115
  **Complexity**: Simple
79
116
 
80
- **Regression test:** REGTEST-01 ([Unit test / Integration test / E2E] → `[test/file/path.test.ts]`)
117
+ **Regression test:** REGTEST-01 ([Unit test] → `[test/file/path.test.ts]`)
81
118
  - GIVEN [precondition] WHEN [trigger] THEN [expected result]
82
- - Oracle: This test must fail on the unfixed code and pass after the fix is applied
119
+ - Oracle: Must fail on unfixed code, pass after fix
83
120
 
84
- ---
121
+ #### FIX-02: [Issue title] (P0)
85
122
 
86
- ### FIX-02: [Issue title] (P0)
87
-
88
- **Root cause**: [Root cause]
123
+ **Root cause**: [Root cause of the issue]
89
124
  **Files involved**: `[path]` > `[functionName()]` (L[N]-[N])
90
125
  **Fix approach**: [How to modify]
91
126
  **Complexity**: Complex — needs systematic debug
92
127
 
93
128
  **Regression test:** REGTEST-02 ([Integration test] → `[test/file/path.test.ts]`)
94
129
  - GIVEN [precondition] WHEN [trigger] THEN [expected result]
95
- - Oracle: [pass condition]
130
+ - Oracle: Must fail on unfixed code, pass after fix
131
+
132
+ [Repeat the above block for each issue. If an issue cannot be automatically tested (e.g., visual-only), note manual verification steps in the regression test field.]
96
133
 
97
134
  ---
98
135
 
99
- [Repeat the above block for each issue. If an issue cannot be automatically tested (e.g., visual-only), note manual verification steps in the regression test.]
136
+ ## 3. Execution Plan
100
137
 
101
- ---
138
+ [P3: Batch tasks — which workers to dispatch in each batch, per-batch verification gates.]
102
139
 
103
- ## 6. Worker Prompt Index
140
+ ### Worker Prompt Index
104
141
 
105
142
  [Each dispatchable fix and regression test has a pre-written self-contained worker prompt in a separate file under `fix/`. The coordinator reads the corresponding file and dispatches it without modification.]
106
143
 
107
- ### Fix Worker Prompts
144
+ **Fix Worker Prompts:**
108
145
 
109
146
  | Fix ID | Worker Prompt File | Description |
110
147
  |---|---|---|
111
148
  | FIX-01 | `fix/FIX-01-[name].md` | [Brief description] |
112
149
  | FIX-02 | `fix/FIX-02-[name].md` | [Brief description] |
113
150
 
114
- ### Regression Test Worker Prompts
151
+ **Regression Test Worker Prompts:**
115
152
 
116
153
  | Test ID | Worker Prompt File | Related Fix | Description |
117
154
  |---|---|---|---|
118
155
  | REGTEST-01 | `fix/REGTEST-01-[name].md` | FIX-01 | [Brief description] |
119
156
  | REGTEST-02 | `fix/REGTEST-02-[name].md` | FIX-02 | [Brief description] |
120
157
 
121
- ---
158
+ ### Batch Schedule
122
159
 
123
- ## 7. Fix Batch Schedule
160
+ *Tasks within the same batch have no file overlap and no logical dependency — they may be dispatched in parallel.*
124
161
 
125
- ### Batch 1 — Independent P0 Fixes
162
+ #### Batch 1 — Independent P0 Fixes
126
163
 
127
164
  - **Issues**: FIX-01, FIX-03
128
- - **Strategy**: Dispatch 2 workers in parallel
165
+ - **Strategy**: Parallel
129
166
  - **Gate**:
130
167
  - [ ] FIX-01 worker reports success
131
168
  - [ ] FIX-03 worker reports success
132
- - [ ] Run verification: `[command]`
133
-
134
- ---
169
+ - [ ] Verification: `[command]` → [expected result]
135
170
 
136
- ### Batch 2 — Dependent Fixes
171
+ #### Batch 2 — Dependent Fixes
137
172
 
138
173
  - **Issues**: FIX-02 → FIX-04 → FIX-05
139
174
  - **Strategy**: Sequential (file overlap or logical dependency)
@@ -142,26 +177,25 @@
142
177
  - [ ] FIX-02 worker reports success
143
178
  - [ ] FIX-04 worker reports success
144
179
  - [ ] FIX-05 worker reports success
145
- - [ ] Run verification: `[command]`
180
+ - [ ] Verification: `[command]` → [expected result]
146
181
 
147
- ---
148
-
149
- ### Batch N — Regression Test Implementation
182
+ #### Batch 3 — Regression Test Implementation
150
183
 
151
- - **Tasks**: REGTEST-01, REGTEST-02, REGTEST-03, REGTEST-04, REGTEST-05
152
- - **Strategy**: Parallel dispatch (no file overlap = full parallel; overlap = sub-batches)
184
+ - **Tasks**: REGTEST-01, REGTEST-02, REGTEST-03
185
+ - **Strategy**: Parallel (no file overlap = full parallel; overlap = sub-batches)
153
186
  - **Depends on**: All fix batches completed
154
187
  - **Gate**:
155
188
  - [ ] All REGTEST workers report success
156
189
  - [ ] All new regression tests pass
190
+ - [ ] Logical check: each REGTEST oracle must be "fails on unfixed code, passes after fix" — if a test also passes on unfixed code, it is not a valid regression test
157
191
  - [ ] Existing test suite passes (confirm no regression)
158
192
 
159
- ---
193
+ > If property-based testing is required by the original CHECKLIST.md, implement it alongside the regression tests listed here. Property-based tests serve as additional hardening for business-logic changes.
160
194
 
161
- ### Batch Final — Integration
195
+ #### Batch 4Final Integration
162
196
 
163
- - **Tasks**: Final test suite, lint, cross-check REPORT.md
164
- - **Strategy**: Sequential (coordinator handles directly or dispatches a single worker)
197
+ - **Tasks**: Full test suite, lint, cross-check REPORT.md
198
+ - **Strategy**: Sequential
165
199
  - **Depends on**: All preceding batches
166
200
  - **Gate**:
167
201
  - [ ] Full test suite passes: `[command]`
@@ -170,94 +204,32 @@
170
204
 
171
205
  ---
172
206
 
173
- ## 8. Regression Test Inventory
174
-
175
- If property-based testing is required by the original CHECKLIST.md, implement it alongside the regression tests listed here. Property-based tests serve as additional hardening for business-logic changes.
176
-
177
- - REGTEST-01 → FIX-01: [Unit] [test/unit/foo.test.ts] — GIVEN X WHEN Y THEN Z
178
- - REGTEST-02 → FIX-02: [Integration] [test/integration/bar.test.ts] — GIVEN A WHEN B THEN C
179
- - REGTEST-03 → FIX-03: [Unit] [test/unit/baz.test.ts] — GIVEN P WHEN Q THEN R
180
-
181
- If there are no entries here, see Section 5 for each fix's regression test design.
182
-
183
- ---
184
-
185
- ## 9. Verification Checkpoints
186
-
187
- ### Checkpoint 1 — After fix batches complete (before regression tests)
188
- - Run: `[command]`
189
- - Expected: All existing tests pass, all fixes confirmed
207
+ ## 4. Final Verification
190
208
 
191
- ### Checkpoint 2 After regression tests are implemented
192
- - Run: `[command]`
193
- - Expected: All new regression tests pass, confirming each fix is effective
194
- - Logical check: Each REGTEST oracle must be "fails on unfixed code, passes after fix" — if a test also passes on the unfixed code, it is not a valid regression test
209
+ [P4: Meta-checks after all batches complete. These verify completeness beyond what per-batch gates already cover.]
195
210
 
196
- ### Checkpoint 3 Final verification
197
- - Run full test suite: `[command]`
198
- - Confirm lint passes
199
- - Cross-check REPORT.md: every issue resolved
211
+ - [ ] Every issue in REPORT.md (P0–P3) has a completed fix
212
+ - [ ] Every fix has a regression test that passes
213
+ - [ ] All worker prompts in Section 3 have been dispatched and returned success
214
+ - [ ] Full test suite passes with no regressions
215
+ - [ ] All changes committed in a single commit
200
216
 
201
217
  ---
202
218
 
203
- ## 10. Error Recovery
219
+ ## 5. References
204
220
 
205
- - **If a fix worker fails**: Retry with the worker's existing context (do not create a new one), giving more specific guidance. At most one retry.
206
- - **If a fix worker fails twice**: Pause the entire flow. Preserve successful results from other workers in the same batch. Report to the user.
207
- - **If a regression test worker reports failure (test cannot pass)**: Check whether the test code is wrong or the fix is incomplete. If the test code is wrong, continue the worker to fix it. If the fix is incomplete, go back to the corresponding fix worker.
208
- - **If a regression test passes on the unfixed code**: The test design is invalid — redesign the oracle and dispatch a new worker.
209
- - **If merge conflicts occur**: The coordinator resolves the conflict, then re-runs the batch gate verification.
210
- - **If a fix or regression test breaks existing tests**: Pause. Report which test failed and which worker's change caused it.
211
-
212
- ---
213
-
214
- ## 11. Fix History
215
-
216
- <!--
217
- ### Round N — [YYYY-MM-DD]
218
- - **Issues fixed**: FIX-01, FIX-02, ... (P0:X, P1:X, P2:X, P3:X)
219
- - **Outcome**: [All resolved / Partial — X issues remaining]
220
- - **Key notes**: [1-2 sentence summary of important decisions or residual risks]
221
- -->
222
-
223
- ---
224
-
225
- ## 12. References
221
+ [P5: Reference files for coordinator and workers.]
226
222
 
227
223
  - **Worker prompt files**: [List all `fix/*.md` files — e.g., `fix/FIX-01-*.md`, `fix/REGTEST-01-*.md`]
228
224
  - **Code files to modify** (across all fixes and regression tests):
229
225
  - [File path — e.g., `src/auth/login.ts`]
230
226
  - [File path — e.g., `src/auth/logout.ts`]
231
- - **Project context files**: [List important project files the fix coordinator and workers may need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`, codegraph index files]
232
- - **Related documents**: [Links to REPORT.md, SPEC.md, DESIGN.md, or external documentation]
233
-
234
- ---
235
-
236
- ## 13. Boundaries
237
-
238
- ### ALWAYS
239
-
240
- - Run gate verification immediately after every batch
241
- - Extract worker prompts verbatim from `fix/*.md` files — do not rewrite them
242
- - After a worker reports, digest the results before deciding next steps
243
- - Fixes must not conflict with the original spec requirements
244
- - Regression tests must not start before all fix batches pass
245
- - Resolve merge conflicts yourself — the coordinator handles them. This is coordination, not implementation.
246
- - **For fixes marked as Complex**: ensure the worker performs systematic debugging (reading related code, tracing execution paths) before applying the fix. Do not let the worker guess the fix.
247
- - **After each batch completes, clean up any temporary branches or worktrees created by workers** — no ephemeral worktree should be left orphaned.
248
-
249
- ### ASK FIRST — pause and confirm with the user
250
-
251
- - Fix approach conflicts with spec design intent
252
- - Need to add a new external dependency
253
- - Worker has failed twice
254
- - Test regression cannot be quickly diagnosed
255
-
256
- ### NEVER
257
-
258
- - Write implementation logic or modify source code beyond resolving merge conflict markers
259
- - Let workers spawn sub-workers
260
- - Skip verification and proceed to the next batch
261
- - Modify spec documents (unless the fix reveals a spec error — report it instead)
262
- - Start regression tests before all fixes are verified
263
- - **Defer any REPORT.md issue to a future round** — every issue has a complete fix plan in this FIX.md
227
+ - **Project context files**: [List project context files the fix coordinator may need — e.g., CLAUDE.md, AGENTS.md, project architecture files]
228
+ - **Related documents**: [Paths to source documents — e.g., the paths to REPORT.md, SPEC.md, and DESIGN.md for this spec]
229
+ - **Fix History**:
230
+ <!--
231
+ ### Round N — [YYYY-MM-DD]
232
+ - **Issues fixed**: FIX-01, FIX-02, ... (P0:X, P1:X, P2:X, P3:X)
233
+ - **Outcome**: [All resolved / Partial — X issues remaining]
234
+ - **Key notes**: [1-2 sentence summary of important decisions or residual risks]
235
+ -->
@@ -0,0 +1,96 @@
1
+ # Fix Worker Prompt: FIX-{sequence}-{kebab-case-name}
2
+
3
+ - **Related issue**: [FIX ID from coordinator — e.g., FIX-01]
4
+
5
+ ---
6
+
7
+ ## 1. Mission & Rules
8
+
9
+ [P1: Goal of this fix and behavioral rules.]
10
+
11
+ ### Mission
12
+
13
+ [One sentence — which issue to fix and why.]
14
+
15
+ ### Context
16
+
17
+ [Which review dimension flagged this issue, which spec requirement it relates to.]
18
+
19
+ ### Rules
20
+
21
+ - Follow the Scope in Section 5 — only modify files listed as Allowed
22
+ - Preserve existing test semantics — do not weaken, skip, or remove existing tests
23
+ - If the fix approach conflicts with the original spec design intent, pause and report to the coordinator
24
+ - Do not add new dependencies without reporting to the coordinator first
25
+ - Workers are leaf nodes — do not spawn sub-workers
26
+
27
+ ---
28
+
29
+ ## 2. Context
30
+
31
+ [P2: Files to read before starting, root cause analysis.]
32
+
33
+ ### Input Files
34
+
35
+ - [File path] — [what to read from it]
36
+ - [File path] — [what to read from it]
37
+
38
+ ### Root Cause
39
+
40
+ [Brief description of the root cause, determined during QA analysis.]
41
+
42
+ ---
43
+
44
+ ## 3. Tasks
45
+
46
+ [P3: Concrete fix steps. Each entry specifies the exact file path, function or line range, and what to add/delete/modify.]
47
+
48
+ ### [File path] — [what to fix]
49
+
50
+ 1. Open `[file path]`
51
+ 2. Locate `[function / class / line range]`
52
+ 3. [Add / Modify / Delete] the following:
53
+ - **Before** (current code): [current code or description]
54
+ - **After** (fixed code): [new code or description]
55
+ 4. [Additional step if needed]
56
+
57
+ [Repeat for each file or logical change group.]
58
+
59
+ ### Output
60
+
61
+ When done, report back to the coordinator:
62
+ - **Files modified**: [list of files]
63
+ - **Change summary**: [brief description]
64
+ - **Test results**: [pass/fail]
65
+ - **Risks or concerns**: [or "None"]
66
+
67
+ ---
68
+
69
+ ## 4. Verification
70
+
71
+ [P4: How to confirm the fix works correctly.]
72
+
73
+ 1. Run: `[command]`
74
+ - Expected: [result]
75
+ 2. Run: `[command]`
76
+ - Expected: [result]
77
+
78
+ ---
79
+
80
+ ## 5. Scope & References
81
+
82
+ [P5: Allowed/forbidden files and related reference files.]
83
+
84
+ ### Allowed Files
85
+
86
+ - [file path] — [reason]
87
+ - [file path] — [reason]
88
+
89
+ ### Forbidden Files
90
+
91
+ - [file path] — [reason, e.g., "owned by another fix worker"]
92
+ - [file path] — [reason]
93
+
94
+ ### Related Documents
95
+
96
+ - [path to SPEC.md, DESIGN.md, or relevant files]
@@ -0,0 +1,98 @@
1
+ # Regression Test Worker Prompt: REGTEST-{sequence}-{kebab-case-name}
2
+
3
+ - **Related fix**: FIX-{sequence} — [fix title]
4
+
5
+ ---
6
+
7
+ ## 1. Mission & Rules
8
+
9
+ [P1: Goal of this regression test and behavioral rules.]
10
+
11
+ ### Mission
12
+
13
+ [Which fix needs a regression test and why.]
14
+
15
+ ### Context
16
+
17
+ [What the fix addressed — summary, root cause.]
18
+
19
+ ### Rules
20
+
21
+ - Only create or modify test files — never modify source code
22
+ - The test must fail on the unfixed code and pass after the fix is applied — this is the core oracle
23
+ - Follow the existing test patterns and style of the reference test files
24
+ - If the test cannot be designed to fail before the fix, report to the coordinator — do not write a weak test
25
+ - Workers are leaf nodes — do not spawn sub-workers
26
+
27
+ ---
28
+
29
+ ## 2. Context
30
+
31
+ [P2: Files to read before starting, test design.]
32
+
33
+ ### Input Files
34
+
35
+ - Fix-related files: [path to the fixed code — understand what was changed]
36
+ - Existing test files (as format reference): [path — follow the same style and patterns]
37
+
38
+ ### Test Design
39
+
40
+ - **Test ID**: REGTEST-{sequence}
41
+ - **Type**: [Unit / Integration / E2E]
42
+ - **Location**: [file path where the test will be written]
43
+ - **Scenario**: GIVEN [precondition] WHEN [trigger] THEN [expected result]
44
+ - **Oracle**: Must fail on unfixed code, must pass after fix
45
+
46
+ ---
47
+
48
+ ## 3. Tasks
49
+
50
+ [P3: Concrete steps for writing the regression test.]
51
+
52
+ 1. Create the test at `[test file path]`
53
+ - Write the test according to the Test Design above
54
+ - Follow the format and naming conventions of [reference test file]
55
+ 2. Run the test on the unfixed code — confirm it fails
56
+ 3. [If the fix is already applied: temporarily revert the fix, run the test to confirm failure, then restore the fix]
57
+ 4. [Additional steps if needed]
58
+
59
+ ### Output
60
+
61
+ When done, report back to the coordinator:
62
+ - **Test file**: [path]
63
+ - **Test name**: [test name or description]
64
+ - **Oracle confirmed**: [test fails before fix / test passes after fix]
65
+ - **Risks or concerns**: [or "None"]
66
+
67
+ ---
68
+
69
+ ## 4. Verification
70
+
71
+ [P4: How to verify the regression test is valid.]
72
+
73
+ 1. Run: `[test command for the specific test]` before the fix is applied
74
+ - Expected: Test fails (confirming the oracle detects the bug)
75
+ 2. Run: `[test command for the specific test]` after the fix is applied
76
+ - Expected: Test passes (proving the fix resolves the issue)
77
+ 3. Run: `[relevant subset of the full test suite]`
78
+ - Expected: All tests pass (no regression to other tests)
79
+
80
+ ---
81
+
82
+ ## 5. Scope & References
83
+
84
+ [P5: Allowed/forbidden files and related references.]
85
+
86
+ ### Allowed Files
87
+
88
+ - [test file path] — write the regression test here
89
+ - [reference test file] — use as format reference
90
+
91
+ ### Forbidden Files
92
+
93
+ - All source code files (`.ts`, `.js`, `.py`, etc.) — the regression test worker must not modify source code
94
+
95
+ ### Related Documents
96
+
97
+ - [path to FIX_WORKER prompt for the related fix — understand what was fixed]
98
+ - [path to SPEC.md or DESIGN.md — understand the expected behavior]