@laitszkin/apollo-toolkit 5.0.3 → 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.
@@ -8,180 +8,159 @@
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
14
16
 
15
- ### What you do
17
+ [One paragraph telling the coordinator what we are building and why. Distilled from SPEC.md's Goal and business value.]
16
18
 
19
+ **Success looks like**: [One sentence describing the observable result when all batches complete.]
20
+
21
+ ### Your Role
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 7)
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
42
+
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
34
51
 
35
- ## 2. Mission
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
36
57
 
37
- [One paragraph telling the coordinator what we are building and why. Distilled from SPEC.md's Goal and business value.]
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
38
65
 
39
- **Success looks like**: [One sentence describing the observable result when all batches complete.]
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. References
108
+ ## 3. Execution Plan
78
109
 
79
- - **Project context files**: [List important project files the coordinator and workers may need e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`, codegraph index files]
80
- - **Related documents**: [Links to related specs, design docs, or external documentation]
110
+ [P3: Batch tasks which workers to dispatch in each batch, per-batch verification gates.]
81
111
 
82
- ---
83
-
84
- ## 6. Task Units
112
+ ### Task Units
85
113
 
86
114
  [Each task is an atomic work unit. Task ID format: `T{batch}.{sequence}`.]
87
115
 
88
- ### Task details
89
-
90
- #### T{batch}.{sequence}: [Task name]
91
-
92
- - **Goal**: [One sentence]
93
- - **Files**: `[file list]`
94
- - **Depends on**: [Task ID, or — (no dependency)]
95
- - **Verify**:
96
- - Command: `[command]`
97
- - Expected: [what you should see]
98
-
99
116
  #### T{batch}.{sequence}: [Task name]
100
117
 
101
118
  - **Goal**: [One sentence]
102
- - **Files**: `[file list]`
119
+ - **Files**: `[file path]`
120
+ - **Worker prompt**: `plan/T{batch}.{sequence}-[name].md`
103
121
  - **Depends on**: [Task ID, or — (no dependency)]
104
122
  - **Verify**:
105
123
  - Command: `[command]`
106
124
  - Expected: [what you should see]
107
125
 
108
- ---
109
-
110
- ## 7. Worker Prompt Library
111
-
112
- [Each dispatchable task has a pre-written self-contained worker prompt. The coordinator extracts the corresponding block and dispatches it without modification.]
113
-
114
- ### T{batch}.{sequence}: [Task name]
115
-
116
- ```
117
- ## Mission
118
- [Brief description of what to do and why. Enough context for the worker to understand the task's purpose.]
119
-
120
- ## Input
121
- - Read the following files: [list]
126
+ [Repeat for each task unit.]
122
127
 
123
- ## What to do
124
- 1. [Specify the exact file path, the function or line range, and what specific change to make (add/delete/modify). Example: "In src/auth/login.ts, function validateToken() (line 42-58): add a null check for the token parameter before calling decode()."]
125
- 2. [Repeat for each file — never leave the change description vague]
128
+ ### Worker Prompt Index
126
129
 
127
- ## Scope
128
- - Allowed files:
129
- - `[path]` — [explanation]
130
- - Forbidden files:
131
- - `[path]` — (belongs to another worker)
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.]
132
131
 
133
- ## Output
134
- On completion, report:
135
- - Which files were modified (absolute paths)
136
- - Change summary for each file
137
- - Test results (pass/fail)
138
- - Any blockers or risks encountered
139
-
140
- ## Verify
141
- - Run: `[command]`
142
- - Expected: [what you should see]
143
-
144
- ## Boundaries
145
- - Do not modify any file in the forbidden list
146
- - Do not introduce new external dependencies
147
- - If you encounter an unexpected blocker, stop and report — do not invent alternative approaches
148
- ```
149
-
150
- ---
151
-
152
- [Repeat the above block for each dispatchable task. Tasks handled directly by the coordinator (purely procedural operations) do not need a worker prompt.]
132
+ | Task ID | Worker Prompt File | Description |
133
+ |---|---|---|
134
+ | T1.1 | `plan/T1.1-implement-login.md` | [Brief description] |
135
+ | T1.2 | `plan/T1.2-implement-logout.md` | [Brief description] |
153
136
 
154
- ---
137
+ [Tasks handled directly by the coordinator (purely procedural operations) do not have an entry here.]
155
138
 
156
- ## 8. Batch Schedule
139
+ ### Batch Schedule
157
140
 
158
- [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.*
159
142
 
160
- ### Batch 1 — [name]
143
+ #### Batch 1 — [name]
161
144
 
162
- - **Tasks**: T1.1, T1.2, T1.3
163
- - **Strategy**: [Dispatch N workers in parallel / Sequential]
164
- - **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):
165
148
  - [ ] T1.1 worker reports success
166
149
  - [ ] T1.2 worker reports success
167
- - [ ] Run verification: `[command]`
168
-
169
- ---
150
+ - [ ] Verification: `[command]` → [expected result]
170
151
 
171
- ### Batch 2 — [name]
152
+ #### Batch 2 — [name]
172
153
 
173
154
  - **Tasks**: T2.1
174
- - **Strategy**: [Parallel / Sequential]
155
+ - **Strategy**: Sequential
175
156
  - **Depends on**: Batch 1
176
157
  - **Gate**:
177
158
  - [ ] T2.1 worker reports success
178
- - [ ] Run verification: `[command]`
159
+ - [ ] Verification: `[command]` → [expected result]
179
160
 
180
- ---
161
+ #### Batch N — Final Integration
181
162
 
182
- ### Batch N Final Integration
183
-
184
- - **Tasks**: [Integration tasks, lockfile update, final test suite]
163
+ - **Tasks**: [Integration tasks, lockfile update, full test suite]
185
164
  - **Strategy**: Sequential (coordinator handles directly or dispatches a single worker)
186
165
  - **Depends on**: All preceding batches
187
166
  - **Gate**:
@@ -190,65 +169,24 @@ On completion, report:
190
169
 
191
170
  ---
192
171
 
193
- ## 9. Verification Checkpoints
194
-
195
- ### Per-batch
196
-
197
- | Batch | Verification Command | Expected Result |
198
- |---|---|---|
199
- | Batch 1 | `[command]` | [expected] |
200
- | Batch 2 | `[command]` | [expected] |
201
-
202
- ### Key behavior checks (from CHECKLIST.md)
203
-
204
- | ID | Observable Behavior | How to verify |
205
- |---|---|---|
206
- | CL-01 | [Behavior description] | `[test command]` |
207
- | CL-02 | [Behavior description] | `[test command]` |
208
-
209
- ### Final verification
210
-
211
- - [ ] Full test suite passes: `[command]`
212
- - [ ] Lint passes: `[command]`
172
+ ## 4. Final Verification
213
173
 
214
- ---
174
+ [P4: Meta-checks after all batches complete. These verify completeness beyond what per-batch gates already cover.]
215
175
 
216
- ## 10. Error Recovery
217
-
218
- | Scenario | Response |
219
- |---|---|
220
- | 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. |
221
- | 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. |
222
- | Merge conflict (merging worker results) | Coordinator resolves the conflict, then re-runs the batch gate verification. |
223
- | 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. |
224
- | Contradiction in SPEC/DESIGN or infeasible design found during implementation | Pause. Document the specific contradiction and notify the user. |
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
225
180
 
226
181
  ---
227
182
 
228
- ## 11. Boundaries
229
-
230
- ### ALWAYS
231
-
232
- - Run gate verification immediately after every batch
233
- - Extract worker prompts verbatim from Section 7 — do not rewrite them
234
- - After a worker reports, digest the results before deciding next steps
235
- - Follow the File Ownership implied by task assignments — do not let two workers modify the same file
236
- - **Resolve merge conflicts yourself** — when combining worker results, the coordinator handles conflict resolution. This is coordination, not implementation.
237
- - **After each batch completes, clean up any temporary branches or worktrees created by workers** — no ephemeral worktree should be left orphaned.
238
- - After two failures, pause and ask — do not keep retrying
239
-
240
- ### ASK FIRST — pause and confirm with the user
241
-
242
- - Need to modify a file not defined in SPEC/DESIGN
243
- - Need to add a new external dependency
244
- - Worker has failed twice
245
- - Test regression cannot be quickly diagnosed
183
+ ## 5. References
246
184
 
247
- ### NEVER
185
+ [P5: Reference files for coordinator and workers.]
248
186
 
249
- - Write implementation logic or modify source code beyond resolving merge conflict markers
250
- - Workers spawn sub-workers
251
- - Skip verification and proceed to the next batch
252
- - Give workers vague instructions (e.g., "fix it" or "based on what you found")
253
- - Expand implementation scope beyond Section 3
254
- - Proceed to the next batch when the current batch's gate has not passed
187
+ - **Worker prompt files**: [List all `plan/*.md` files e.g., `plan/T1.1-implement-login.md`, `plan/T1.2-implement-logout.md`]
188
+ - **Code files to modify** (across all tasks):
189
+ - [File path e.g., `src/auth/login.ts`]
190
+ - [File path e.g., `src/auth/logout.ts`]
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]
@@ -13,18 +13,25 @@ This prompt defines a fix coordinator agent:
13
13
 
14
14
  This skill is responsible for "planning the fix strategy" — extracting information from REPORT.md + SPEC/DESIGN/CHECKLIST, writing worker prompts for each fix and regression test, and scheduling batch execution order.
15
15
 
16
+ Worker prompts are written to individual files under `<spec_dir>/fix/` (single spec) or `<batch_dir>/fix/` (batch spec) instead of inline in FIX.md. This keeps FIX.md focused on coordination strategy while each fix/regression worker prompt is independently dispatchable.
17
+
16
18
  ## Acceptance Criteria
17
19
 
18
20
  - `docs/plans/<YYYY-MM-DD>/<spec_name>/FIX.md` is produced and placed in the spec directory (same level as REPORT.md)
19
21
  - FIX.md is a **self-contained fix coordinator prompt**, containing:
20
22
  - Coordinator role definition
21
23
  - Issue inventory with dependency analysis
22
- - Pre-written worker prompt for every fix issue
23
- - Regression test design and worker prompt for every fix
24
+ - Worker prompt index referencing `fix/*.md` files
25
+ - Pre-written worker prompts for every fix and regression test (stored in `fix/*.md`)
26
+ - Regression test design for every fix
24
27
  - Batch schedule (fix batches + regression test batches + final verification)
25
28
  - Error recovery strategy
26
29
  - Boundary rules
27
- - **Every issue in REPORT.md (including P2/P3) has a complete fix plan with a corresponding worker prompt in FIX.md.** No issue may be deferred to a future round or marked as "handle later."
30
+ - Worker prompts are stored in `<spec_dir>/fix/*.md` or `<batch_dir>/fix/*.md`, one prompt per file
31
+ - FIX.md References section cites:
32
+ - Worker prompt file paths (`fix/*.md`)
33
+ - All code file paths that need modification across all fixes and regression tests
34
+ - **Every issue in REPORT.md (including P2/P3) has a complete fix plan with a corresponding worker prompt.** No issue may be deferred to a future round or marked as "handle later."
28
35
 
29
36
  ## Workflow
30
37
 
@@ -36,6 +43,7 @@ Read all of the following:
36
43
 
37
44
  - **SPEC.md + DESIGN.md + CHECKLIST.md**: Full spec and design documentation
38
45
  - **REPORT.md**: Review findings (verdict + P0-P3 issue list + dimension summary)
46
+ - `<spec_dir>/references/` or `<batch_dir>/references/` — External method/API reference documents
39
47
 
40
48
  Understand the original design intent of the spec and the nature of each issue in REPORT.md.
41
49
 
@@ -59,7 +67,7 @@ For each issue in REPORT.md (in P0 → P1 → P2 → P3 order) → FIX.md Sectio
59
67
 
60
68
  ### 4. Design Regression Tests for Each Fix
61
69
 
62
- For every fix issue, design a concrete regression test → FIX.md Section 5 (Fix Details, regression test field) → FIX.md Section 6 (Worker Prompt Library, REGTEST entries).
70
+ For every fix issue, design a concrete regression test → FIX.md Section 5 (Fix Details, regression test field) → worker prompt in `fix/*REGtest*.md`.
63
71
 
64
72
  Design principles:
65
73
  - **Every P0/P1 issue needs at least one regression test.** For P2/P3 issues, if automated testing is impractical, define manual verification steps.
@@ -89,53 +97,55 @@ Design principles:
89
97
  - **Independent issues**: No file overlap and no logical dependency → can be parallel
90
98
  - **Regression test dependency**: Regression tests must run after their corresponding fix is complete (tests verify the fixed code)
91
99
 
92
- ### 6. Detect File Overlap (Parallelism Gate)
100
+ ### 6. Parallelism Gate (File Overlap + Logical Dependency)
93
101
 
94
- 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:
95
103
 
96
104
  1. Collect the file list for each fix and regression test
97
- 2. Compare file lists and mark overlaps — zero overlap is the only condition for parallel execution
98
- 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.
99
107
 
100
108
  ### 7. Write Worker Prompts
101
109
 
102
- #### 7a. Fix Worker Prompts → FIX.md Section 6
110
+ #### 7a. Fix Worker Prompts
103
111
 
104
- Write a self-contained worker prompt for each fix issue.
112
+ Write a self-contained worker prompt for each fix issue. Save each prompt to a separate file under `<spec_dir>/fix/` or `<batch_dir>/fix/`.
105
113
 
106
- Each fix worker prompt must include:
114
+ **Worker prompt file naming**: `fix/FIX-{sequence}-{kebab-case-name}.md`
107
115
 
108
- ```
109
- ## Mission — What to fix and why
110
- ## Context Which review dimension, which spec requirement
111
- ## Input — Which files to read
112
- ## 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.
113
- ## Scope Allowed and forbidden files
114
- ## Output What to report on completion
115
- ## Verify Verification commands and expected results
116
- ## Boundaries Constraints (don't conflict with spec, preserve existing test semantics, report blockers)
117
- ```
116
+ Use `assets/templates/FIX_WORKER.md`. The template follows the P1-P5 architecture:
117
+
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 |
118
125
 
119
126
  **Simple fixes can be merged**: Multiple simple, non-conflicting fixes can be combined into one worker prompt.
120
127
  **Complex fixes stand alone**: Complex fixes (requiring systematic debug) must have independent worker prompts.
121
128
 
122
- #### 7b. Regression Test Worker Prompts → FIX.md Section 6
129
+ #### 7b. Regression Test Worker Prompts
123
130
 
124
131
  Write a self-contained worker prompt for each regression test. The regression test worker is responsible for **writing test code**.
125
132
 
126
- Each regression test worker prompt must include:
133
+ **Worker prompt file naming**: `fix/REGTEST-{sequence}-{kebab-case-name}.md`
127
134
 
128
- ```
129
- ## Mission — Which fix needs a regression test and why
130
- ## Context What the fix addressed (summary), root cause
131
- ## Input — Which files to read (fix-related files + existing test files as format reference)
132
- ## What to do Concrete test writing steps:
133
- 1. Create the test at the specified location
134
- 2. Test scenario (GIVEN/WHEN/THEN)
135
- 3. Oracle (must fail before fix, must pass after fix)
136
- ## Scope Allowed test files only
137
- ## Verify — Run the test, confirm it passes (proving the fix works)
138
- ```
135
+ Use `assets/templates/REGTEST_WORKER.md`. The template follows the P1-P5 architecture:
136
+
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 |
144
+
145
+ **Writing principles (move these to your process, not the template):**
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.
147
+ - Workers do not see the coordinator's context. The prompt must include everything necessary.
148
+ - A regression test that passes before the fix is not a valid test. Always design the oracle so it fails on unfixed code.
139
149
 
140
150
  #### 7c. Cases That Do Not Need a Worker
141
151
 
@@ -145,8 +155,8 @@ Each regression test worker prompt must include:
145
155
 
146
156
  ### 8. Create Batch Schedule → FIX.md Section 7
147
157
 
148
- **Batch partitioning principles (file overlap is the hard gate):**
149
- - 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.
150
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
151
161
  - Final batch: Full test suite + lint + confirmation that all issues are resolved.
152
162
 
@@ -175,30 +185,46 @@ Use `assets/templates/FIX.md`. Fill according to the table below.
175
185
 
176
186
  | Section | Content Source |
177
187
  |---------|---------------|
178
- | 1. Your Role | Fixed template (no modification needed) |
179
- | 2. Mission | REPORT.md verdict + total issue count |
180
- | 3. Issue Inventory | REPORT.md issue list (condensed to NL one-liners) |
181
- | 4. Fix Dependency Analysis | Steps 5-6 (dependency analysis + file overlap) |
182
- | 5. Fix Details (with regression test design) | Step 3 (fix plan) + Step 4 (regression test design) |
183
- | 6. Worker Prompt Library | Step 7a (fix prompts) + Step 7b (regression test prompts) |
184
- | 7. Fix Batch Schedule | Step 8 (batch schedule) |
185
- | 8. Regression Test Inventory | Step 4 full list. If regtests ≤ 3, omit (Section 5 is sufficient). If ≥ 4, include a condensed NL list. |
186
- | 9. Verification Checkpoints | Fixed scaffold, customized with spec-specific commands |
187
- | 10. Error Recovery | Fixed scaffold (natural language) |
188
- | 11. Fix History | Fixed scaffold (history entries only, no instructions) |
189
- | 12. References | Important project context files (CLAUDE.md, AGENTS.md, architecture atlas, codegraph index) — reduces LLM search overhead |
190
- | 13. Boundaries | Fixed scaffold + spec-specific rules (including worktree cleanup after each batch) |
191
-
192
- ### 11. Produce FIX.md
193
-
194
- Place FIX.md in the spec directory (same level as REPORT.md).
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 |
193
+
194
+ ### 11. Pre-delivery Self-Review
195
+
196
+ Before delivering FIX.md, verify all of the following.
197
+
198
+ **Worker prompt quality:**
199
+
200
+ - Every worker prompt in `fix/*.md` is self-contained. Scan for phrases like "based on your findings", "fix it appropriately", "as discussed above" — these leak shared context assumptions.
201
+ - Every fix worker prompt has concrete file-level Scope and a specific Verify command.
202
+ - Worker prompt filenames match their fix IDs (`fix/FIX-{sequence}-*.md`, `fix/REGTEST-{sequence}-*.md`).
203
+
204
+ **Coverage completeness:**
205
+
206
+ - Every issue in REPORT.md (P0–P3) has a corresponding worker prompt. No deferred issues.
207
+ - Every fix has a corresponding regression test (or documented manual verification steps for P2/P3 where automated testing is impractical).
208
+
209
+ **Structural consistency:**
210
+
211
+ - Each fix's dependency analysis matches the batch ordering. No fix scheduled before its dependencies are met.
212
+ - Regression tests are scheduled after all fix batches complete.
213
+ - Section 5 (References) lists all worker prompt paths and all code file paths.
214
+
215
+ ### 12. Produce FIX.md and Worker Prompts
216
+
217
+ Place the FIX.md in the spec directory (same level as REPORT.md).
218
+ Place worker prompts in `<spec_dir>/fix/` or `<batch_dir>/fix/`.
195
219
 
196
220
  ## Examples
197
221
 
198
- - REPORT.md has 3 P0 issues (hallucinated code, deviation, omission) and 2 P1 issues → Each P0/P1 gets 1+ regression test → FIX.md has 3 fix workers + 5 regression test workers → Schedule: Batch 1 parallel fix 3 P0 → Batch 2 fix 2 P1 → Batch 3 parallel 5 regtests → Batch 4 final
199
- - Two P0 issues both modify `src/auth.ts` → File overlap → Separate into sequential batches → Regression tests run after all fix batches complete
200
- - A P0 logic error: `getDiscount()` does not handle negative input → Regression test: unit test with GIVEN negative input WHEN calling getDiscount THEN return 0 (before fix, returns incorrect negative discount)
222
+ - REPORT.md has 3 P0 issues (hallucinated code, deviation, omission) and 2 P1 issues → Each P0/P1 gets 1+ regression test → FIX.md + fix/ with 3 fix workers + 5 regression test workers → Schedule: Batch 1 parallel fix 3 P0 → Batch 2 fix 2 P1 → Batch 3 parallel 5 regtests → Batch 4 final
223
+ - Two P0 issues both modify `src/auth.ts` → File overlap → Separate into sequential batches → Regression tests run after all fix batches complete → Worker prompts in `fix/FIX-01-*.md` and `fix/FIX-02-*.md`
224
+ - A P0 logic error: `getDiscount()` does not handle negative input → Regression test: unit test with GIVEN negative input WHEN calling getDiscount THEN return 0 (before fix, returns incorrect negative discount) → Worker prompt in `fix/REGTEST-01-discount.md`
201
225
 
202
226
  ## References
203
227
 
204
- - `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)