@dug-21/unimatrix 0.5.8 → 0.6.0
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/package.json +5 -4
- package/protocols/README.md +126 -0
- package/protocols/uni-agent-routing.md +187 -0
- package/protocols/uni-bugfix-protocol.md +547 -0
- package/protocols/uni-delivery-protocol.md +607 -0
- package/protocols/uni-design-protocol.md +379 -0
- package/skills/retro/SKILL.md +2 -2
- package/skills/uni-init/SKILL.md +12 -2
- package/skills/uni-knowledge-lookup/SKILL.md +21 -13
- package/skills/uni-knowledge-search/SKILL.md +14 -8
- package/skills/uni-query-patterns/SKILL.md +22 -22
- package/skills/uni-release/SKILL.md +68 -1
- package/skills/uni-retro/SKILL.md +46 -85
- package/skills/uni-review-pr/SKILL.md +14 -0
- package/skills/uni-seed/SKILL.md +20 -14
- package/skills/uni-store-adr/SKILL.md +18 -18
- package/skills/uni-store-lesson/SKILL.md +19 -19
- package/skills/uni-store-pattern/SKILL.md +18 -18
- package/skills/uni-store-procedure/SKILL.md +18 -18
- package/skills/uni-zero/SKILL.md +235 -0
- package/skills/uni-record-outcome/SKILL.md +0 -96
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
# Bug Fix Protocol (Single-Session)
|
|
2
|
+
|
|
3
|
+
Triggers on: bug, fix, bugfix, defect, regression, broken, failing, error, crash.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Execution Model
|
|
8
|
+
|
|
9
|
+
A single-session workflow that takes a bug report from diagnosis through merge. The session includes a human checkpoint after diagnosis — the human must agree with the root cause analysis before any code changes are made.
|
|
10
|
+
|
|
11
|
+
**You become the Bugfix Leader(uni-scrum-master).** Read the SM agent definition (`.claude/agents/uni/uni-scrum-master.md`) for your role boundaries. You orchestrate — you NEVER generate content. Spawn specialist agents for all work.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Bugfix Leader (you) Specialist Agents
|
|
15
|
+
─────────────────── ─────────────────
|
|
16
|
+
read protocol + bug report
|
|
17
|
+
spawn investigator (Phase 1) ───────────────────────► diagnosis + proposed fix
|
|
18
|
+
◄────────────────────────────────────────────────────
|
|
19
|
+
spawn architect (Phase 1b) ─────────────────────────► design review of proposed fix
|
|
20
|
+
◄────────────────────────────────────────────────────
|
|
21
|
+
present diagnosis + design review to human
|
|
22
|
+
★ HUMAN CHECKPOINT ★
|
|
23
|
+
human approves diagnosis + design
|
|
24
|
+
create branch (Phase 2)
|
|
25
|
+
spawn rust-dev ─────────────────────────────────────► implement fix + tests
|
|
26
|
+
◄────────────────────────────────────────────────────
|
|
27
|
+
spawn tester (Phase 3) ─────────────────────────────► full test suite results
|
|
28
|
+
◄────────────────────────────────────────────────────
|
|
29
|
+
spawn validator (Gate 3) ───────────────────────────► validate fix
|
|
30
|
+
◄──────────────────────────────────────────────────── PASS / REWORKABLE FAIL / SCOPE FAIL
|
|
31
|
+
on PASS: open PR
|
|
32
|
+
spawn security-reviewer ────────────────────────────► review PR diff (fresh context)
|
|
33
|
+
◄────────────────────────────────────────────────────
|
|
34
|
+
◄────────────────────────────── present PR + security assessment
|
|
35
|
+
human reviews and merges
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**The Bugfix Manager runs the session autonomously after human approves diagnosis and design.** Human re-enters only on scope/feasibility failures, rework exhaustion, or final PR review.
|
|
39
|
+
|
|
40
|
+
### Concurrency Rules
|
|
41
|
+
|
|
42
|
+
- ALWAYS batch ALL file reads/writes/edits in ONE message
|
|
43
|
+
- ALWAYS batch ALL Bash commands in ONE message
|
|
44
|
+
- Bug fix phases are mostly sequential — only one specialist active at a time
|
|
45
|
+
|
|
46
|
+
### Bugfix Rules
|
|
47
|
+
|
|
48
|
+
- Agents return: file paths + test pass/fail + issues (NOT file contents)
|
|
49
|
+
- Max 2 rework iterations at the validation gate — protects context window
|
|
50
|
+
- Cargo output truncated to first error + summary line
|
|
51
|
+
- The coordinator never generates fix code or diagnoses bugs — only orchestrates
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Initialization
|
|
56
|
+
|
|
57
|
+
The human starts a bug fix session by providing a bug report. This can be:
|
|
58
|
+
- A GH Issue URL
|
|
59
|
+
- A description of the bug (symptoms, reproduction steps, affected area)
|
|
60
|
+
|
|
61
|
+
The Bugfix Manager:
|
|
62
|
+
1. Reads the bug report (fetches GH Issue if URL provided)
|
|
63
|
+
2. Identifies the feature area and any related feature directories
|
|
64
|
+
3. **Declares feature cycle** — before any agent spawning:
|
|
65
|
+
```
|
|
66
|
+
mcp__unimatrix__context_cycle({
|
|
67
|
+
"type": "start",
|
|
68
|
+
"topic": "bugfix-{issue-number}",
|
|
69
|
+
"goal": "{1-2 sentence summary of the goal or problem to be fixed}",
|
|
70
|
+
"next_phase": "discovery",
|
|
71
|
+
"agent_id": "{issue-number}-bugfix-leader"
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
4. Passes relevant info & goal to the investigator in Phase 1
|
|
75
|
+
|
|
76
|
+
Worker agents are spawned with `isolation: "worktree"` for branch isolation (see `/uni-git` Worktree Isolation).
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Phase 1: Discovery
|
|
81
|
+
|
|
82
|
+
**Agent**: uni-bug-investigator
|
|
83
|
+
|
|
84
|
+
The Bugfix Manager spawns `uni-bug-investigator` to diagnose the root cause:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
Task(subagent_type: "uni-bug-investigator",
|
|
88
|
+
prompt: "Your agent ID: {issue-number}-investigator
|
|
89
|
+
|
|
90
|
+
Bug report:
|
|
91
|
+
{bug description or GH Issue URL}
|
|
92
|
+
|
|
93
|
+
Affected area (if known): {area hint}
|
|
94
|
+
|
|
95
|
+
Explore the codebase, trace the affected code paths,
|
|
96
|
+
identify the root cause, and propose a targeted fix.
|
|
97
|
+
|
|
98
|
+
Return: root cause analysis, affected files, proposed fix approach,
|
|
99
|
+
risk assessment, missing test identification.")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Wait for the investigator to complete.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Phase 1b: Design Review
|
|
107
|
+
|
|
108
|
+
**Agent**: uni-architect
|
|
109
|
+
|
|
110
|
+
After the investigator returns, the Bugfix Manager spawns `uni-architect` to review the proposed fix design **before any human checkpoint or code changes**:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
Task(subagent_type: "uni-architect",
|
|
114
|
+
prompt: "Your agent ID: {issue-number}-design-reviewer
|
|
115
|
+
|
|
116
|
+
DESIGN REVIEW — proposed bug fix approach only. Do NOT implement.
|
|
117
|
+
|
|
118
|
+
Bug report: {bug description}
|
|
119
|
+
Investigator's proposed fix: {proposed fix approach from investigator}
|
|
120
|
+
Affected files: {from investigator}
|
|
121
|
+
|
|
122
|
+
Review the proposed fix for:
|
|
123
|
+
1. Hot-path risks — does the fix introduce DB reads, locks, or I/O on a
|
|
124
|
+
background tick, request handler, or other hot path? If so, flag and
|
|
125
|
+
propose a safer alternative (cache, pagination, SQL filter pushed down).
|
|
126
|
+
2. Blast radius — what is the worst case if the fix has a subtle bug?
|
|
127
|
+
3. Architectural fit — does the approach follow established patterns for
|
|
128
|
+
this subsystem? Query Unimatrix for relevant ADRs and conventions.
|
|
129
|
+
4. Missing constraints — are there caps, idempotency guards, or error
|
|
130
|
+
recovery steps missing from the proposed approach?
|
|
131
|
+
5. Security surface — any new trust boundaries, input validation gaps, or
|
|
132
|
+
privilege changes introduced by the approach?
|
|
133
|
+
|
|
134
|
+
Return:
|
|
135
|
+
- Design assessment: APPROVED / APPROVED WITH NOTES / REWORK NEEDED
|
|
136
|
+
- Findings: list of concerns with severity (blocking / non-blocking)
|
|
137
|
+
- Revised fix approach (if REWORK NEEDED): concrete amendments to the
|
|
138
|
+
investigator's proposal that address the findings
|
|
139
|
+
- ## Knowledge Stewardship block with Queried: and Stored:/Declined: entries")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Wait for the architect to complete.
|
|
143
|
+
|
|
144
|
+
**If REWORK NEEDED**: The Bugfix Manager incorporates the architect's revised approach into the fix plan presented to the human. The investigator is NOT re-spawned — the architect's revised approach supersedes the investigator's proposal for the affected parts.
|
|
145
|
+
|
|
146
|
+
### Human Checkpoint (MANDATORY — do NOT proceed without human approval)
|
|
147
|
+
|
|
148
|
+
After both investigator and architect return, the Bugfix Manager presents the combined diagnosis and design review to the human:
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
DIAGNOSIS + DESIGN REVIEW COMPLETE — Awaiting approval.
|
|
152
|
+
|
|
153
|
+
Root Cause: {summary from investigator}
|
|
154
|
+
Affected Files: {list from investigator}
|
|
155
|
+
Proposed Fix: {approach — investigator's if APPROVED, architect's revised approach if REWORK NEEDED}
|
|
156
|
+
Design Review: {APPROVED | APPROVED WITH NOTES | REWORK NEEDED} — {architect findings summary}
|
|
157
|
+
Risk Assessment: {from investigator + architect}
|
|
158
|
+
Missing Test: {what test should have caught this}
|
|
159
|
+
|
|
160
|
+
Human action required: Review diagnosis and design, then approve to proceed with fix.
|
|
161
|
+
If either the diagnosis or design is wrong, provide feedback and I will re-investigate.
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
On human approval:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
mcp__unimatrix__context_cycle({
|
|
168
|
+
"type": "phase-end",
|
|
169
|
+
"topic": "bugfix-{issue-number}",
|
|
170
|
+
"phase": "discovery",
|
|
171
|
+
"outcome": {1-2 sentence brief summary of phase result},
|
|
172
|
+
"next_phase": "fix",
|
|
173
|
+
"agent_id": "{issue-number}-bugfix-leader"
|
|
174
|
+
})
|
|
175
|
+
```
|
|
176
|
+
then proceed to Phase 2
|
|
177
|
+
|
|
178
|
+
**If the human disagrees**: Re-spawn the investigator with the human's feedback:
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
Task(subagent_type: "uni-bug-investigator",
|
|
182
|
+
prompt: "Your agent ID: {issue-number}-investigator-v2
|
|
183
|
+
|
|
184
|
+
REWORK: Human disagrees with initial diagnosis.
|
|
185
|
+
|
|
186
|
+
Human feedback: {feedback}
|
|
187
|
+
Previous diagnosis report: {path to investigator report}
|
|
188
|
+
|
|
189
|
+
Read your previous report first from issue, then re-investigate
|
|
190
|
+
with the human's feedback in mind.
|
|
191
|
+
|
|
192
|
+
Return: revised root cause analysis, affected files,
|
|
193
|
+
revised fix approach, risk assessment.")
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Phase 2: Fix Execution
|
|
199
|
+
|
|
200
|
+
**Prerequisite**: Human has approved the diagnosis. You are STILL the scrum master.
|
|
201
|
+
|
|
202
|
+
**Agent**: uni-rust-dev
|
|
203
|
+
|
|
204
|
+
The Bugfix Manager:
|
|
205
|
+
1. Creates the bug fix branch: `git checkout -b bugfix/{issue-number}-{short-description}`
|
|
206
|
+
2. Spawns `uni-rust-dev` with the agreed fix approach:
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
Task(subagent_type: "uni-rust-dev",
|
|
210
|
+
prompt: "Your agent ID: {issue-number}-agent-1-fix
|
|
211
|
+
|
|
212
|
+
BUG FIX — not a feature implementation.
|
|
213
|
+
|
|
214
|
+
Bug report: {bug description}
|
|
215
|
+
Root cause: {from approved diagnosis}
|
|
216
|
+
Affected files: {from diagnosis}
|
|
217
|
+
Proposed fix approach: {from approved diagnosis}
|
|
218
|
+
Missing test: {from diagnosis}
|
|
219
|
+
|
|
220
|
+
YOUR TASK:
|
|
221
|
+
1. Implement the fix as described in the approved approach
|
|
222
|
+
2. Write targeted test(s) that reproduce the bug and verify the fix
|
|
223
|
+
3. Ensure the fix is minimal — do not include unrelated changes
|
|
224
|
+
4. Run component-level tests during development
|
|
225
|
+
|
|
226
|
+
RETURN FORMAT:
|
|
227
|
+
1. Files modified: [paths]
|
|
228
|
+
2. New tests: [test function names]
|
|
229
|
+
3. Tests: pass/fail count
|
|
230
|
+
4. Issues: [blockers]")
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Wait for the rust-dev to complete. Provide updates back to the GH issue periodically.
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
mcp__unimatrix__context_cycle({
|
|
237
|
+
"type": "phase-end",
|
|
238
|
+
"topic": "bugfix-{issue-number}",
|
|
239
|
+
"phase": "fix",
|
|
240
|
+
"outcome": {1-2 sentence brief summary of phase result},
|
|
241
|
+
"next_phase": "testing",
|
|
242
|
+
"agent_id": "{issue-number}-bugfix-leader"
|
|
243
|
+
})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Phase 3: Testing
|
|
249
|
+
|
|
250
|
+
**Agent**: uni-tester (execution mode)
|
|
251
|
+
|
|
252
|
+
The Bugfix Manager spawns `uni-tester` to run the full test suite:
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
Task(subagent_type: "uni-tester",
|
|
256
|
+
prompt: "Your agent ID: {issue-number}-agent-2-verify
|
|
257
|
+
|
|
258
|
+
PHASE: Test Execution (Bug Fix Verification)
|
|
259
|
+
|
|
260
|
+
Read: product/test/infra-001/USAGE-PROTOCOL.md
|
|
261
|
+
|
|
262
|
+
Execute:
|
|
263
|
+
1. The new bug-specific tests written by the developer
|
|
264
|
+
2. Full workspace test suite (cargo test --workspace)
|
|
265
|
+
3. Clippy check (cargo clippy --workspace -- -D warnings)
|
|
266
|
+
4. Integration smoke tests (MANDATORY):
|
|
267
|
+
cd product/test/infra-001 && python -m pytest suites/ -v -m smoke --timeout=60
|
|
268
|
+
5. Integration suites relevant to the bug area (see USAGE-PROTOCOL.md suite table)
|
|
269
|
+
|
|
270
|
+
INTEGRATION TEST FAILURE TRIAGE (CRITICAL):
|
|
271
|
+
- CAUSED BY THIS BUG FIX → Report back to Bugfix Leader for rework.
|
|
272
|
+
- PRE-EXISTING / UNRELATED → Do NOT fix. File a GH Issue, mark the test
|
|
273
|
+
@pytest.mark.xfail(reason='Pre-existing: GH#NNN — description').
|
|
274
|
+
- BAD TEST ASSERTION → Fix the test. Document in results.
|
|
275
|
+
Agents must NEVER fix integration test failures unrelated to the bug fix.
|
|
276
|
+
|
|
277
|
+
If the bug was discovered by an integration test (GH Issue references
|
|
278
|
+
a specific test), verify that specific test now passes and remove its
|
|
279
|
+
@pytest.mark.xfail marker.
|
|
280
|
+
|
|
281
|
+
Return: test results summary, any failures, clippy warnings,
|
|
282
|
+
integration test counts, any GH Issues filed.")
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Wait for the tester to complete.
|
|
286
|
+
Write updates back to GH issue
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Gate 3: Validation
|
|
291
|
+
|
|
292
|
+
**Agent**: uni-validator
|
|
293
|
+
|
|
294
|
+
Spawn `uni-validator` with the bugfix check set:
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
Task(subagent_type: "uni-validator",
|
|
298
|
+
prompt: "Your agent ID: {issue-number}-gate-bugfix
|
|
299
|
+
|
|
300
|
+
GATE: Bug Fix Validation
|
|
301
|
+
Issue: #{issue-number}
|
|
302
|
+
|
|
303
|
+
Validate:
|
|
304
|
+
- Fix addresses the diagnosed root cause (not just symptoms)
|
|
305
|
+
- No todo!(), unimplemented!(), TODO, FIXME, or placeholder functions
|
|
306
|
+
- All tests pass (new bug-specific tests + existing suite)
|
|
307
|
+
- No new clippy warnings
|
|
308
|
+
- No unsafe code introduced
|
|
309
|
+
- Fix is minimal (no unrelated changes included)
|
|
310
|
+
- New test(s) would have caught the original bug
|
|
311
|
+
- Integration smoke tests passed
|
|
312
|
+
- Any xfail markers added have corresponding GH Issues
|
|
313
|
+
- If bug was discovered by integration test, that test's xfail marker was removed
|
|
314
|
+
- Knowledge stewardship: investigator and rust-dev reports contain ## Knowledge Stewardship block with Queried/Stored/Declined entries
|
|
315
|
+
|
|
316
|
+
Bug report: {bug description}
|
|
317
|
+
Root cause diagnosis: {from approved diagnosis}
|
|
318
|
+
Changed files: {from rust-dev return}
|
|
319
|
+
New tests: {from rust-dev return}
|
|
320
|
+
|
|
321
|
+
Post report as a comment on GH Issue #{issue-number}.
|
|
322
|
+
|
|
323
|
+
Return: PASS / REWORKABLE FAIL / SCOPE FAIL, specific issues.")
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Gate results:**
|
|
327
|
+
- **PASS** →
|
|
328
|
+
1. ```
|
|
329
|
+
mcp__unimatrix__context_cycle({
|
|
330
|
+
"type": "phase-end",
|
|
331
|
+
"topic": "bugfix-{issue-number}",
|
|
332
|
+
"phase": "testing",
|
|
333
|
+
"outcome": {1-2 sentence brief summary of phase result},
|
|
334
|
+
"next_phase": "bug-review",
|
|
335
|
+
"agent_id": "{issue-number}-bugfix-leader"
|
|
336
|
+
})
|
|
337
|
+
```
|
|
338
|
+
2. Commit fix code + tests, open PR, proceed to Phase 4
|
|
339
|
+
- **REWORKABLE FAIL** → Loop back to Phase 2 with failure details (max 2 iterations). Include the gate report path in the re-spawn prompt.
|
|
340
|
+
- **SCOPE FAIL** → Session stops. Return to human with recommendation.
|
|
341
|
+
|
|
342
|
+
On PASS, the Bugfix Manager:
|
|
343
|
+
1. Stages and commits fix code, tests, and feature artifacts:
|
|
344
|
+
```bash
|
|
345
|
+
git add product/features/{issue-number}/
|
|
346
|
+
git commit -m "fix: {description} (#{issue-number})"
|
|
347
|
+
```
|
|
348
|
+
2. Pushes branch: `git push -u origin bugfix/{issue-number}-{short-description}`
|
|
349
|
+
3. Opens PR: `gh pr create --title "fix: {description} (#{issue-number})" --body "..."`
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## Phase 4: PR Review (bug-review)
|
|
354
|
+
|
|
355
|
+
After the PR is opened, invoke `/uni-review-pr` with the PR number, feature/issue ID, and GH Issue number. This spawns a fresh-context security reviewer and assesses merge readiness.
|
|
356
|
+
|
|
357
|
+
For bugfix PRs, the review verifies the single gate report (not three delivery gates).
|
|
358
|
+
|
|
359
|
+
When the security review returns with no blocking findings:
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
mcp__unimatrix__context_cycle({
|
|
363
|
+
"type": "phase-end",
|
|
364
|
+
"topic": "bugfix-{issue-number}",
|
|
365
|
+
"phase": "bug-review",
|
|
366
|
+
"outcome": {1-2 sentence brief summary of phase result},
|
|
367
|
+
"agent_id": "{issue-number}-bugfix-leader"
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
mcp__unimatrix__context_cycle({
|
|
371
|
+
"type": "stop",
|
|
372
|
+
"topic": "bugfix-{issue-number}",
|
|
373
|
+
"outcome": "Bugfix complete. Root cause: {summary}. PR: {url}",
|
|
374
|
+
"agent_id": "{issue-number}-bugfix-leader"
|
|
375
|
+
})
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
If the review returns blocking findings, resolve them before stopping the cycle.
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## Phase 5: Human Review & Merge
|
|
383
|
+
|
|
384
|
+
The Bugfix Manager presents the PR and security assessment to the human:
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
BUG FIX COMPLETE — PR ready for review.
|
|
388
|
+
|
|
389
|
+
PR: {PR URL}
|
|
390
|
+
Branch: bugfix/{issue-number}-{short-description}
|
|
391
|
+
|
|
392
|
+
Fix Summary:
|
|
393
|
+
- Root cause: {summary}
|
|
394
|
+
- Files changed: {list}
|
|
395
|
+
- New tests: {list}
|
|
396
|
+
- All tests passing: yes/no
|
|
397
|
+
|
|
398
|
+
Gate: Bug Fix Validation — PASS
|
|
399
|
+
Security Review: {risk level} — {summary of findings}
|
|
400
|
+
Blocking findings: {yes/no + details}
|
|
401
|
+
|
|
402
|
+
Reports:
|
|
403
|
+
- Link to GH issue
|
|
404
|
+
|
|
405
|
+
Human action required: Review PR and approve merge.
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
On human approval to merge, the Bugfix Manager:
|
|
409
|
+
1. Merges the PR with `gh pr merge --rebase` (if human requests it)
|
|
410
|
+
2. Closes the GH Issue with reference to the PR (if applicable)
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## GH Issue Lifecycle
|
|
415
|
+
|
|
416
|
+
If the bug has a GH Issue:
|
|
417
|
+
|
|
418
|
+
1. **Phase 1 complete**: Comment with diagnosis summary
|
|
419
|
+
2. **Phase 2 complete**: Comment with fix summary and changed files
|
|
420
|
+
3. **Gate PASS**: Comment with gate result and PR link
|
|
421
|
+
4. **Merge**: Close issue with reference to merged PR
|
|
422
|
+
|
|
423
|
+
**Comment format** (post after each phase):
|
|
424
|
+
```
|
|
425
|
+
## {Phase Name} — {Status}
|
|
426
|
+
- Summary: {brief description}
|
|
427
|
+
- Files: [paths]
|
|
428
|
+
- Tests: X passed, Y new
|
|
429
|
+
- Issues: [if any]
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## Rework Protocol
|
|
435
|
+
|
|
436
|
+
### Reworkable Failures
|
|
437
|
+
Fix doesn't address root cause, test gaps exist, code quality issues. Loop back to Phase 2 agents with failure details.
|
|
438
|
+
|
|
439
|
+
**Max 2 rework iterations.** If still failing after 2 iterations, escalate as SCOPE FAIL.
|
|
440
|
+
|
|
441
|
+
When re-spawning agents for rework:
|
|
442
|
+
1. Include the gate report path in the prompt
|
|
443
|
+
2. List specific failures to address
|
|
444
|
+
3. Instruct agent to read the gate report first
|
|
445
|
+
|
|
446
|
+
### Scope/Feasibility Failures
|
|
447
|
+
Root cause is deeper than expected, fix requires architectural changes, bug is actually a design issue.
|
|
448
|
+
|
|
449
|
+
**Session stops immediately.** The Bugfix Manager returns to the human with:
|
|
450
|
+
- What failed and why
|
|
451
|
+
- Recommendation: simple fix insufficient, needs feature work or design change
|
|
452
|
+
- All artifacts produced so far
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## Cargo Output Truncation (CRITICAL)
|
|
457
|
+
|
|
458
|
+
Always truncate cargo output:
|
|
459
|
+
```bash
|
|
460
|
+
# Build: first error + summary
|
|
461
|
+
cargo build --workspace 2>&1 | grep -A5 "^error" | head -20
|
|
462
|
+
cargo build --workspace 2>&1 | tail -3
|
|
463
|
+
|
|
464
|
+
# Test: summary only
|
|
465
|
+
cargo test --workspace 2>&1 | tail -30
|
|
466
|
+
|
|
467
|
+
# Clippy: first warnings only
|
|
468
|
+
cargo clippy --workspace -- -D warnings 2>&1 | head -30
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
NEVER pipe full cargo output into context.
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## Agent Polling (CRITICAL)
|
|
476
|
+
|
|
477
|
+
Never use `sleep` to wait for background agents or tasks. Use `run_in_background` + `TaskOutput`:
|
|
478
|
+
|
|
479
|
+
```
|
|
480
|
+
# Launch agent in background
|
|
481
|
+
Task(subagent_type: "uni-tester", run_in_background: true, ...)
|
|
482
|
+
# -> returns task ID, e.g. "btask123"
|
|
483
|
+
|
|
484
|
+
# Read output when notified
|
|
485
|
+
TaskOutput("btask123")
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
You will be automatically notified when a background task completes. Do NOT sleep, poll, or proactively check before the notification arrives.
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## Quick Reference: Message Map
|
|
493
|
+
|
|
494
|
+
```
|
|
495
|
+
BUGFIX LEADER (you):
|
|
496
|
+
Init: /uni-query-patterns + /uni-knowledge-search — prior knowledge
|
|
497
|
+
mcp__unimatrix__context_cycle({ "type": "start", "topic": "bugfix-{issue-number}",
|
|
498
|
+
"goal": "{summary}", "next_phase": "discovery", "agent_id": "{issue-number}-bugfix-leader" })
|
|
499
|
+
Phase 1: Task(uni-bug-investigator) — diagnose root cause → GH Issue comment
|
|
500
|
+
...wait...
|
|
501
|
+
Phase 1b: Task(uni-architect) — design review of proposed fix
|
|
502
|
+
...present diagnosis + design review to human...
|
|
503
|
+
★ HUMAN CHECKPOINT — human approves diagnosis + design ★
|
|
504
|
+
mcp__unimatrix__context_cycle({ "type": "phase-end", "topic": "bugfix-{issue-number}",
|
|
505
|
+
"phase": "discovery", "next_phase": "fix", "agent_id": "{issue-number}-bugfix-leader" })
|
|
506
|
+
Phase 2: git checkout -b bugfix/{issue}-{desc}
|
|
507
|
+
Task(uni-rust-dev) — implement fix + tests → GH Issue comment
|
|
508
|
+
...wait...
|
|
509
|
+
mcp__unimatrix__context_cycle({ "type": "phase-end", "topic": "bugfix-{issue-number}",
|
|
510
|
+
"phase": "fix", "next_phase": "testing", "agent_id": "{issue-number}-bugfix-leader" })
|
|
511
|
+
Phase 3: Task(uni-tester) — full test suite verification → GH Issue comment
|
|
512
|
+
...wait...
|
|
513
|
+
Gate 3: Task(uni-validator, bugfix check set) → GH Issue comment
|
|
514
|
+
...PASS → mcp__unimatrix__context_cycle({ "type": "phase-end", "topic": "bugfix-{issue-number}",
|
|
515
|
+
"phase": "testing", "next_phase": "bug-review", "agent_id": "..." })
|
|
516
|
+
→ commit + push + PR
|
|
517
|
+
...FAIL → rework or stop...
|
|
518
|
+
Phase 4: /uni-review-pr — security review + merge readiness → GH Issue comment
|
|
519
|
+
...wait...
|
|
520
|
+
...no blocking findings →
|
|
521
|
+
mcp__unimatrix__context_cycle({ "type": "phase-end", "topic": "bugfix-{issue-number}",
|
|
522
|
+
"phase": "bug-review", "agent_id": "{issue-number}-bugfix-leader" })
|
|
523
|
+
mcp__unimatrix__context_cycle({ "type": "stop", "topic": "bugfix-{issue-number}",
|
|
524
|
+
"outcome": "Bugfix complete. Root cause: {summary}. PR: {url}", "agent_id": "..." })
|
|
525
|
+
/uni-store-lesson (if generalizable)
|
|
526
|
+
Phase 5: Present PR + security assessment to human — SESSION ENDS
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
531
|
+
## Outcome Recording
|
|
532
|
+
|
|
533
|
+
After the security review returns with no blocking findings (Phase 4), close the bug-review phase and stop the cycle. See Phase 4 for the full call syntax.
|
|
534
|
+
|
|
535
|
+
Then use Unimatrix skills as applicable:
|
|
536
|
+
|
|
537
|
+
1. **If root cause is generalizable**: `/uni-store-lesson` — persist the root cause pattern so future investigators find it via `/uni-knowledge-search`. Tag with `caused_by_feature:{feature-id}` when applicable. Include what could have been done during the originating feature's design phase to prevent the bug.
|
|
538
|
+
2. **If diagnostic/repair sequence is reproducible**: `/uni-store-procedure` — store the technique so future agents can find it.
|
|
539
|
+
|
|
540
|
+
### Stewardship Compliance
|
|
541
|
+
|
|
542
|
+
The bugfix gate validator checks stewardship compliance for investigator and rust-dev agents:
|
|
543
|
+
- Investigator report must include `## Knowledge Stewardship` with `Queried:` and `Stored:`/`Declined:` entries
|
|
544
|
+
- Rust-dev report must include `## Knowledge Stewardship` with `Queried:` and `Stored:`/`Declined:` entries
|
|
545
|
+
- Missing stewardship block = REWORKABLE FAIL
|
|
546
|
+
|
|
547
|
+
All phase outputs (diagnosis, fix summary, gate results, security review) are posted as **GH Issue comments** — never written to the filesystem.
|