@dug-21/unimatrix 0.5.9 → 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.
@@ -0,0 +1,607 @@
1
+ # Delivery Session Protocol (Session 2)
2
+
3
+ Triggers on: implement, build, code, deliver, TDD, refactor, "proceed with implementation".
4
+
5
+ ---
6
+
7
+ ## Execution Model
8
+
9
+ Session 2 reads the IMPLEMENTATION-BRIEF.md produced in Session 1 and runs three stages autonomously, each with a validation gate. If all gates pass, the feature is delivered. If any gate fails beyond rework, the session stops and returns to the human.
10
+
11
+ ```
12
+ SESSION 2 — DELIVERY
13
+ ════════════════════
14
+
15
+ Stage 3a: Component Design (pseudocode + test plans)
16
+ ↓ Update Component Map in IMPLEMENTATION-BRIEF.md
17
+ ★ Gate 3a: Design Review (MANDATORY BLOCK) ★
18
+
19
+ Stage 3b: Code Implementation (parallelized by component)
20
+ ★ Gate 3b: Code Review ★
21
+
22
+ Stage 3c: Testing & Risk Validation
23
+ ★ Gate 3c: Risk Validation ★
24
+
25
+ Phase 4: Delivery
26
+ ★ RETURN TO HUMAN ★
27
+ ```
28
+
29
+ **Critical sequence**: Stage 3a produces pseudocode + test plans → Delivery Leader updates the Component Map → Gate 3a validates designs → ONLY THEN does Stage 3b begin. Stage 3b agents each receive their specific component's validated pseudocode and test plan.
30
+
31
+ **You are the Delivery Leader.** Read the SM agent definition (`.claude/agents/uni/uni-scrum-master.md`) for role boundaries. You orchestrate — you NEVER generate content. Spawn specialist agents for all work. Run all stages autonomously. Human re-enters only on scope/feasibility failures or when rework iterations are exhausted.
32
+
33
+ ### Concurrency Rules
34
+
35
+ - ALWAYS spawn all agents WITHIN each stage in ONE message via Task tool
36
+ - ALWAYS batch ALL file reads/writes/edits in ONE message
37
+ - ALWAYS batch ALL Bash commands in ONE message
38
+
39
+ ### Delivery Rules
40
+
41
+ - Agents return: file paths + test pass/fail + issues (NOT file contents)
42
+ - Max 2 rework iterations per gate — protects context window
43
+ - Cargo output truncated to first error + summary line
44
+ - The three source documents (Architecture, Specification, Risk Strategy) are sacred — all work traces back to them
45
+
46
+ ---
47
+
48
+ ## Initialization
49
+
50
+ The human starts Session 2 by providing the IMPLEMENTATION-BRIEF.md path (or GH Issue number).
51
+
52
+ **Precondition**: If `product/features/{feature-id}/IMPLEMENTATION-BRIEF.md` does not exist → **STOP**. Return to human: "Design session has not run for {feature-id}. Run the design session first."
53
+
54
+ The Delivery Leader:
55
+ 1. Reads `product/features/{feature-id}/IMPLEMENTATION-BRIEF.md` — Component Map, ADR references, constraints
56
+ 2. Reads `product/features/{feature-id}/ACCEPTANCE-MAP.md` — AC verification methods
57
+ 3. Reads paths to the three source documents (listed in the brief)
58
+ 4. **Creates feature branch**: `git checkout -b feature/{phase}-{NNN}` (see `/uni-git`)
59
+ 5. **Commits design artifacts** — Session 1 left these as untracked files; commit them now before any agents run:
60
+ ```bash
61
+ git add product/features/{feature-id}/
62
+ git commit -m "design: {feature-id} artifacts (#{issue})"
63
+ ```
64
+ Use only the targeted path above — never `git add .` or `git add product/`, which could pick up unrelated in-progress design for other features.
65
+ 6. **Declares feature cycle** — before any agent spawning:
66
+ ```
67
+ context_cycle(
68
+ type: "start",
69
+ topic: "{feature-id}",
70
+ next_phase: "spec",
71
+ agent_id: "{feature-id}-delivery-leader"
72
+ )
73
+ ```
74
+ 7. Plans Stage 3b waves from the IMPLEMENTATION-BRIEF before spawning any implementation agents
75
+
76
+ ---
77
+
78
+ ## Stage 3a: Component Design & Pseudocode
79
+
80
+ **Agents**: uni-pseudocode + uni-tester (test plan design)
81
+
82
+ The Delivery Leader spawns both agents in parallel (ONE message):
83
+
84
+ ```
85
+ Task(subagent_type: "uni-pseudocode",
86
+ prompt: "Your agent ID: {feature-id}-agent-1-pseudocode
87
+
88
+ Before starting, search Unimatrix for relevant patterns and this feature's ADRs:
89
+ - context_search(query: '{feature area} patterns conventions', category: 'pattern')
90
+ - context_search(query: '{feature-id} architectural decisions', category: 'decision', topic: '{feature-id}')
91
+ Fall back to reading ADR files in product/features/{id}/architecture/ if results are insufficient.
92
+
93
+ Read these files before starting:
94
+ - product/features/{id}/IMPLEMENTATION-BRIEF.md
95
+ - product/features/{id}/architecture/ARCHITECTURE.md
96
+ - product/features/{id}/specification/SPECIFICATION.md
97
+ - product/features/{id}/RISK-TEST-STRATEGY.md
98
+
99
+ Decompose the feature into components per the architecture.
100
+ For each component, produce pseudocode files.
101
+
102
+ Output:
103
+ - pseudocode/OVERVIEW.md (component interaction, data flow, shared types)
104
+ - pseudocode/{component}.md (per-component pseudocode)
105
+
106
+ Return: file paths, component list, open questions.")
107
+
108
+ Task(subagent_type: "uni-tester",
109
+ prompt: "Your agent ID: {feature-id}-agent-2-testplan
110
+
111
+ PHASE: Test Plan Design (Stage 3a)
112
+
113
+ Before starting, search Unimatrix for this feature's ADRs and relevant test patterns:
114
+ - context_search(query: '{feature-id} architectural decisions', category: 'decision', topic: '{feature-id}')
115
+ - context_search(query: '{feature area} testing patterns edge cases')
116
+ Fall back to reading ADR files in product/features/{id}/architecture/ if results are insufficient.
117
+
118
+ Read these files before starting:
119
+ - product/features/{id}/IMPLEMENTATION-BRIEF.md
120
+ - product/features/{id}/architecture/ARCHITECTURE.md
121
+ - product/features/{id}/specification/SPECIFICATION.md
122
+ - product/features/{id}/RISK-TEST-STRATEGY.md
123
+
124
+ Produce per-component test plans rooted in the Risk Strategy.
125
+ Integration test planning is a required part of test plans —
126
+ your agent definition has the full suite catalog and planning
127
+ guidance. OVERVIEW.md MUST include an integration harness section.
128
+
129
+ Output:
130
+ - test-plan/OVERVIEW.md (test strategy, risk mapping, integration harness plan)
131
+ - test-plan/{component}.md (per-component test expectations)
132
+
133
+ Return: file paths, risk coverage mapping, integration suite plan, open questions.")
134
+ ```
135
+
136
+ Wait for both agents to complete.
137
+
138
+ ```
139
+ context_cycle(type: "phase-end", phase: "spec", next_phase: "spec-review", agent_id: "{feature-id}-delivery-leader")
140
+ ```
141
+
142
+ ### Component Map Update (MANDATORY — between Stage 3a and Gate 3a)
143
+
144
+ After Stage 3a agents return, the Delivery Leader MUST update the IMPLEMENTATION-BRIEF.md with actual file paths before proceeding to Gate 3a.
145
+
146
+ 1. Collect component lists and file paths from both agents' returns
147
+ 2. Update the **Component Map** table in `product/features/{id}/IMPLEMENTATION-BRIEF.md`:
148
+ ```
149
+ | Component | Pseudocode | Test Plan |
150
+ |-----------|-----------|-----------|
151
+ | {component-1} | pseudocode/{component-1}.md | test-plan/{component-1}.md |
152
+ | {component-2} | pseudocode/{component-2}.md | test-plan/{component-2}.md |
153
+ ```
154
+ 3. Update the **Cross-Cutting Artifacts** section with actual paths:
155
+ ```
156
+ | Artifact | Path | Consumed By |
157
+ |----------|------|-------------|
158
+ | Pseudocode Overview | pseudocode/OVERVIEW.md | Stage 3b (all agents), Gate 3a |
159
+ | Test Strategy + Integration Plan | test-plan/OVERVIEW.md | Stage 3c (tester), Gate 3a, Gate 3c |
160
+ ```
161
+ 4. The Component Map drives Stage 3b per-component routing. The Cross-Cutting Artifacts drive Stage 3c routing — the integration harness plan in `test-plan/OVERVIEW.md` tells the Stage 3c tester which suites to run and what new integration tests to write.
162
+
163
+ **Do NOT skip this step.** The IMPLEMENTATION-BRIEF from Session 1 has placeholder components from the architecture. Stage 3a produces the actual pseudocode/test-plan files. Both tables must reflect reality before validation or implementation begins.
164
+
165
+ ### Gate 3a: Design Review (MANDATORY BLOCK — do NOT proceed to Stage 3b without PASS)
166
+
167
+ Spawn `uni-validator` in Gate 3a mode:
168
+
169
+ ```
170
+ Task(subagent_type: "uni-validator",
171
+ prompt: "Your agent ID: {feature-id}-gate-3a
172
+
173
+ GATE: 3a (Component Design Review)
174
+ Feature: {feature-id}
175
+
176
+ Validate:
177
+ - Does each component align with approved Architecture?
178
+ - Does pseudocode implement what Specification requires?
179
+ - Do test plans address risks from Risk-Based Test Strategy?
180
+ - Are component interfaces consistent with architecture contracts?
181
+
182
+ Source documents:
183
+ - product/features/{id}/architecture/ARCHITECTURE.md
184
+ - product/features/{id}/specification/SPECIFICATION.md
185
+ - product/features/{id}/RISK-TEST-STRATEGY.md
186
+
187
+ Artifacts to validate:
188
+ - product/features/{id}/pseudocode/ (all files)
189
+ - product/features/{id}/test-plan/ (all files)
190
+
191
+ Write report to: product/features/{id}/reports/gate-3a-report.md
192
+ Return: PASS / REWORKABLE FAIL / SCOPE FAIL, report path, issues.")
193
+ ```
194
+
195
+ **Gate results:**
196
+ - **PASS** →
197
+ 1. `context_cycle(type: "phase-end", phase: "spec-review", next_phase: "develop", agent_id: "{feature-id}-delivery-leader")`
198
+ 2. Commit pseudocode + test plans + updated brief (`pseudocode: component design + test plans (#{issue})`), then proceed to Stage 3b
199
+ - **REWORKABLE FAIL** → Loop back to Stage 3a agents (max 2 iterations). Include failure details in re-spawn prompt.
200
+ - **SCOPE FAIL** → Session stops. Return to human with recommendation.
201
+
202
+ ---
203
+
204
+ ## Stage 3b: Code Implementation (Wave-Based)
205
+
206
+ **Agents**: uni-rust-dev (one per component per wave)
207
+
208
+ **Prerequisite**: Gate 3a PASSED. Component Map in IMPLEMENTATION-BRIEF.md is updated with actual pseudocode/test-plan file paths.
209
+
210
+ ### Wave Planning (MANDATORY — before spawning any agent)
211
+
212
+ The Delivery Leader reads the IMPLEMENTATION-BRIEF and groups components into **waves** based on dependency order. Components in the same wave are independent of each other and can be implemented in parallel. Components in later waves depend on earlier waves being committed first.
213
+
214
+ **How to identify waves:**
215
+ 1. Read the IMPLEMENTATION-BRIEF for any mandatory ordering: numbered steps, "must be first", "blocking prerequisite", or explicit dependency statements.
216
+ 2. Group components: Wave 1 = components with no dependencies on other components. Wave 2 = components that require Wave 1 to be complete. And so on.
217
+ 3. If no ordering constraints exist, all components are Wave 1.
218
+
219
+ **One wave = current parallel behavior.** Multiple waves = execute sequentially, committing between each.
220
+
221
+ ### Wave Execution
222
+
223
+ For each wave (in order):
224
+
225
+ 1. **Spawn all agents in the wave in ONE message** — one agent per component, no worktree isolation (agents work directly on the feature branch):
226
+
227
+ ```
228
+ Task(subagent_type: "uni-rust-dev",
229
+ prompt: "Your agent ID: {feature-id}-agent-3-{component-1}
230
+
231
+ Before implementing, search Unimatrix for relevant patterns and this feature's ADRs:
232
+ - context_search(query: '{component area} implementation patterns', category: 'pattern')
233
+ - context_search(query: '{feature-id} architectural decisions', category: 'decision', topic: '{feature-id}')
234
+ Fall back to reading ADR files in product/features/{id}/architecture/ if results are insufficient.
235
+
236
+ Read these files before starting:
237
+ - product/features/{id}/IMPLEMENTATION-BRIEF.md
238
+ - product/features/{id}/architecture/ARCHITECTURE.md
239
+ - product/features/{id}/pseudocode/OVERVIEW.md
240
+ - product/features/{id}/pseudocode/{component-1}.md ← YOUR component
241
+ - product/features/{id}/test-plan/{component-1}.md ← YOUR component's test plan
242
+
243
+ YOUR TASK: Implement {component-1} from validated pseudocode.
244
+ Build test cases per the component test plan.
245
+ Execute component-level tests during development.
246
+ Keep files modular — no file should exceed 500 lines.
247
+
248
+ Files to create/modify: {paths from brief for this component}
249
+
250
+ RETURN FORMAT:
251
+ 1. Files modified: [paths]
252
+ 2. Tests: pass/fail count
253
+ 3. Issues: [blockers]")
254
+
255
+ Task(subagent_type: "uni-rust-dev",
256
+ prompt: "Your agent ID: {feature-id}-agent-4-{component-2}
257
+ ...same structure, with {component-2}'s pseudocode and test plan...")
258
+ ```
259
+
260
+ 2. **Wait for all agents in the wave to complete.**
261
+ 3. **Commit the wave**: `git add -p && git commit -m "impl: wave {N} — {component list} (#{issue})"`
262
+ 4. **Spawn the next wave**, which now builds on the committed state.
263
+
264
+ Each agent receives ONLY its component's pseudocode and test plan — not every file. Stage 3b agents do NOT run or modify integration tests — that is Stage 3c.
265
+
266
+ ### Gate 3b: Code Review
267
+
268
+ **Pre-gate (Delivery Leader):** Before spawning the validator, run `git status --short` and commit any modified production files that are not yet committed. Gates check committed HEAD — working tree changes are invisible to them.
269
+
270
+ Spawn `uni-validator` in Gate 3b mode:
271
+
272
+ ```
273
+ Task(subagent_type: "uni-validator",
274
+ prompt: "Your agent ID: {feature-id}-gate-3b
275
+
276
+ GATE: 3b (Code Review)
277
+ Feature: {feature-id}
278
+
279
+ Validate:
280
+ - Does code match validated pseudocode from Stage 3a?
281
+ - Does implementation align with approved Architecture?
282
+ - Are component interfaces implemented as specified?
283
+ - Do test cases match component test plans?
284
+ - Does code compile? Are there stubs or placeholders?
285
+
286
+ Source documents:
287
+ - product/features/{id}/architecture/ARCHITECTURE.md
288
+ - product/features/{id}/specification/SPECIFICATION.md
289
+ - product/features/{id}/pseudocode/ (all files)
290
+ - product/features/{id}/test-plan/ (all files)
291
+
292
+ Write report to: product/features/{id}/reports/gate-3b-report.md
293
+ Return: PASS / REWORKABLE FAIL / SCOPE FAIL, report path, issues.")
294
+ ```
295
+
296
+ **Gate results:**
297
+ - **PASS** →
298
+ 1. `context_cycle(type: "phase-end", phase: "develop", next_phase: "test", agent_id: "{feature-id}-delivery-leader")`
299
+ 2. Commit all implementation code (`impl: Stage 3b complete (#{issue})`), then proceed to Stage 3c
300
+ - **REWORKABLE FAIL** / **SCOPE FAIL** → Same as Gate 3a
301
+
302
+ ---
303
+
304
+ ## Stage 3c: Testing & Risk Validation
305
+
306
+ **Agents**: uni-tester (test execution)
307
+
308
+ ```
309
+ Task(subagent_type: "uni-tester",
310
+ prompt: "Your agent ID: {feature-id}-agent-4-tester
311
+
312
+ PHASE: Test Execution (Stage 3c)
313
+
314
+ Read these files:
315
+ - product/features/{id}/IMPLEMENTATION-BRIEF.md (Cross-Cutting Artifacts section for your inputs)
316
+ - product/features/{id}/RISK-TEST-STRATEGY.md
317
+ - product/features/{id}/test-plan/OVERVIEW.md (contains the integration harness plan from Stage 3a)
318
+ - product/features/{id}/test-plan/{component}.md (per-component test plans)
319
+ - product/features/{id}/ACCEPTANCE-MAP.md
320
+ - product/test/infra-001/USAGE-PROTOCOL.md
321
+
322
+ Execute unit tests, integration smoke tests (mandatory gate), and
323
+ relevant integration suites per the integration harness plan in
324
+ test-plan/OVERVIEW.md. Write new integration tests identified in that
325
+ plan. Triage any integration failures per USAGE-PROTOCOL.md rules.
326
+
327
+ Output:
328
+ - testing/RISK-COVERAGE-REPORT.md (risk mapping, unit + integration counts, xfail references)
329
+ - All unit tests pass
330
+ - Integration smoke tests pass (xfail markers acceptable with GH Issues)
331
+
332
+ Return: test results summary, risk coverage gaps (if any), report path,
333
+ any GH Issues filed for pre-existing failures.")
334
+
335
+ ### Gate 3c: Final Risk-Based Validation
336
+
337
+ Spawn `uni-validator` in Gate 3c mode:
338
+
339
+ ```
340
+ Task(subagent_type: "uni-validator",
341
+ prompt: "Your agent ID: {feature-id}-gate-3c
342
+
343
+ GATE: 3c (Final Risk-Based Validation)
344
+ Feature: {feature-id}
345
+
346
+ Validate:
347
+ - Do test results prove identified risks are mitigated?
348
+ - Does test coverage match Risk-Based Test Strategy?
349
+ - Are there risks from Phase 2 lacking test coverage?
350
+ - Does delivered code match approved Specification?
351
+ - Does system architecture match approved Architecture?
352
+
353
+ INTEGRATION TEST VALIDATION (MANDATORY):
354
+ - Verify integration smoke tests (pytest -m smoke) passed
355
+ - Verify relevant integration suites were run for this feature
356
+ - Verify any @pytest.mark.xfail markers have corresponding GH Issues
357
+ - Verify no integration tests were deleted or commented out
358
+ - Verify RISK-COVERAGE-REPORT.md includes integration test counts
359
+ - If integration failures were marked xfail, confirm the failures are
360
+ genuinely unrelated to the feature (not masking feature bugs)
361
+
362
+ Source documents:
363
+ - product/features/{id}/architecture/ARCHITECTURE.md
364
+ - product/features/{id}/specification/SPECIFICATION.md
365
+ - product/features/{id}/RISK-TEST-STRATEGY.md
366
+ - product/features/{id}/ACCEPTANCE-MAP.md
367
+
368
+ Artifacts to validate:
369
+ - product/features/{id}/testing/RISK-COVERAGE-REPORT.md
370
+ - All implemented code
371
+
372
+ Write report to: product/features/{id}/reports/gate-3c-report.md
373
+ Return: PASS / REWORKABLE FAIL / SCOPE FAIL, report path, issues.")
374
+ ```
375
+
376
+ **Gate results:**
377
+ - **PASS** →
378
+ 1. `context_cycle(type: "phase-end", phase: "test", next_phase: "pr-review", agent_id: "{feature-id}-delivery-leader")`
379
+ 2. Proceed to Phase 4
380
+ - **REWORKABLE FAIL** / **SCOPE FAIL** → Same as Gates 3a/3b.
381
+
382
+ ---
383
+
384
+ ## Phase 4: Delivery
385
+
386
+ **Prerequisite**: All three gates (3a, 3b, 3c) have passed.
387
+
388
+ The Delivery Leader:
389
+ 1. Commits final artifacts (`test: risk coverage + gate reports (#{issue})`)
390
+ 2. Pushes feature branch and opens PR (see `/uni-git` for PR template)
391
+ 3. Updates GH Issue with PR link
392
+ 4. Evaluates documentation trigger criteria (see below) — spawns `uni-docs` if mandatory
393
+ 5. Invokes `/uni-review-pr` for security review and merge readiness
394
+ 6. Combines impl + deploy results in the return to human
395
+
396
+ ```bash
397
+ # Commit final artifacts
398
+ git add product/features/{id}/testing/ product/features/{id}/reports/
399
+ git commit -m "test: risk coverage + gate reports (#{issue})"
400
+ git push -u origin feature/{phase}-{NNN}
401
+
402
+ # Open PR (see uni-git skill for full template)
403
+ gh pr create --title "[{feature-id}] {title}" --body "..."
404
+ ```
405
+
406
+ ### Documentation Update (conditional — after PR opens)
407
+
408
+ Evaluate whether the feature requires a README update using the trigger criteria table below.
409
+
410
+ #### Trigger Criteria
411
+
412
+ | Feature Change Type | Documentation Step |
413
+ |--------------------|--------------------|
414
+ | New or modified MCP tool | **MANDATORY** |
415
+ | New or modified skill | **MANDATORY** |
416
+ | New CLI subcommand or flag | **MANDATORY** |
417
+ | New knowledge category | **MANDATORY** |
418
+ | New operational constraint for users | **MANDATORY** |
419
+ | Schema change with user-visible behavior change | **MANDATORY** |
420
+ | Internal refactor (no user-visible change) | SKIP |
421
+ | Test-only feature | SKIP |
422
+ | Documentation-only feature | SKIP |
423
+
424
+ **Decision rule**: Read the feature's SCOPE.md Goals section. If any goal matches a MANDATORY trigger, spawn `uni-docs`. If all goals are internal, skip.
425
+
426
+ #### Spawn Template
427
+
428
+ ```
429
+ Task(subagent_type: "uni-docs",
430
+ prompt: "Your agent ID: {feature-id}-docs
431
+
432
+ Feature: {feature-id}
433
+ Issue: #{issue}
434
+
435
+ Read these files:
436
+ - product/features/{id}/SCOPE.md
437
+ - product/features/{id}/specification/SPECIFICATION.md
438
+ - README.md
439
+
440
+ Identify README sections affected by this feature.
441
+ Propose and commit targeted edits to the feature branch.
442
+ Commit message: docs: update README for {feature-id} (#{issue})
443
+
444
+ Return: sections modified, commit hash, or 'no changes needed'.")
445
+ ```
446
+
447
+ **No gate.** This step is advisory — it does not block delivery. If `uni-docs` fails to produce useful output, proceed to `/uni-review-pr` without documentation updates. Documentation changes are part of the reviewed PR.
448
+
449
+ ---
450
+
451
+ ### PR Review (after PR opens)
452
+
453
+ Invoke `/uni-review-pr` with the PR number, feature ID, and GH Issue number. This spawns a fresh-context security reviewer and assesses merge readiness.
454
+
455
+ **Error handling:**
456
+ - Review fails → return delivery results only, note "PR review failed"
457
+ - Review returns BLOCKED → include blocking items in combined return
458
+
459
+ **Return format:**
460
+ ```
461
+ SESSION 2 COMPLETE — Feature delivered.
462
+
463
+ Gates: 3a PASS, 3b PASS, 3c PASS
464
+ Security Review: {risk level} — {summary}
465
+ Merge readiness: {READY | BLOCKED}
466
+
467
+ Files created/modified: [paths]
468
+ Tests: X passed, Y new
469
+ Risk coverage: [summary]
470
+ PR: {URL}
471
+ GH Issue: {URL} (updated)
472
+
473
+ Human action required: {Approve and merge | Address blocking items}.
474
+ ```
475
+
476
+ After returning to the human, close the pr-review phase and stop the cycle:
477
+
478
+ ```
479
+ context_cycle(type: "phase-end", phase: "pr-review", agent_id: "{feature-id}-delivery-leader")
480
+ context_cycle(type: "stop", topic: "{feature-id}", outcome: "Session 2 complete. All gates passed. PR: {url}", agent_id: "{feature-id}-delivery-leader")
481
+ ```
482
+
483
+ ### Post-Delivery Review (Optional)
484
+
485
+ After Phase 4, the Delivery Leader may optionally review for tech debt or cleanup opportunities discovered during implementation. If found, file GH Issues — do not include in this PR.
486
+
487
+ If a reusable multi-step technique was used or discovered during this session, store it via `/uni-store-procedure`.
488
+
489
+ ---
490
+
491
+ ## Rework Protocol
492
+
493
+ At every gate, two failure types:
494
+
495
+ ### Reworkable Failures
496
+ Component design doesn't match spec, code doesn't match pseudocode, test gaps exist. Loop back to the previous stage's agents with failure details.
497
+
498
+ **Max 2 rework iterations per gate.** If still failing after 2 iterations, escalate as SCOPE FAIL.
499
+
500
+ When re-spawning agents for rework:
501
+ 1. Include the gate report path in the prompt
502
+ 2. List specific failures to address
503
+ 3. Instruct agent to read the gate report first
504
+
505
+ ### Scope/Feasibility Failures
506
+ Original scope was wrong, technology doesn't work as assumed, architecture can't support a requirement.
507
+
508
+ **Session stops immediately.** The Delivery Leader returns to the human with:
509
+ - Which gate failed and why
510
+ - Recommendation: adjust scope (Phase 1), revise design (Phase 2), or approve modified approach
511
+ - All artifacts produced so far
512
+
513
+ ---
514
+
515
+ ## Cargo Output Truncation (CRITICAL)
516
+
517
+ Always truncate cargo output:
518
+ ```bash
519
+ # Build: first error + summary
520
+ cargo build --workspace 2>&1 | grep -A5 "^error" | head -20
521
+ cargo build --workspace 2>&1 | tail -3
522
+
523
+ # Test: summary only (prefer JSON when available)
524
+ cargo test --workspace 2>&1 | tail -30
525
+ # Or: cargo test --workspace -- --format json 2>&1 | tail -30
526
+
527
+ # Clippy: first warnings only
528
+ cargo clippy --workspace -- -D warnings 2>&1 | head -30
529
+
530
+ # Dependency audit (run during Gate 3b)
531
+ cargo audit 2>&1 | tail -20
532
+ ```
533
+
534
+ NEVER pipe full cargo output into context.
535
+
536
+ ---
537
+
538
+ ## Quick Reference: Message Map
539
+
540
+ ```
541
+ DELIVERY LEADER (you):
542
+ Init: Read IMPLEMENTATION-BRIEF.md + ACCEPTANCE-MAP.md
543
+ context_cycle(type: "start", topic: "{feature-id}", next_phase: "spec", agent_id: "{feature-id}-delivery-leader")
544
+ Stage 3a: Task(uni-pseudocode) + Task(uni-tester) — parallel, ONE message
545
+ ...wait for both to complete...
546
+ context_cycle(type: "phase-end", phase: "spec", next_phase: "spec-review", ...)
547
+ UPDATE Component Map in IMPLEMENTATION-BRIEF.md with actual file paths
548
+ Task(uni-validator, Gate 3a) — MANDATORY BLOCK
549
+ ...PASS → context_cycle(phase-end, spec-review → develop)
550
+ → commit → Stage 3b
551
+ ...FAIL → rework or stop...
552
+ Stage 3b: PLAN waves from IMPLEMENTATION-BRIEF (1 wave = all parallel, N waves = sequential)
553
+ FOR EACH WAVE: Task(uni-rust-dev × components-in-wave) — ONE message, no worktree isolation
554
+ Each agent gets ONLY its component's pseudocode + test plan
555
+ ...wait for wave... commit wave... spawn next wave...
556
+ ...wait...
557
+ Task(uni-validator, Gate 3b)
558
+ ...PASS → context_cycle(phase-end, develop → test)
559
+ → commit → Stage 3c
560
+ ...FAIL → rework or stop...
561
+ Stage 3c: Task(uni-tester, execution mode)
562
+ ...wait...
563
+ Task(uni-validator, Gate 3c)
564
+ ...PASS → context_cycle(phase-end, test → pr-review)
565
+ → Phase 4
566
+ ...FAIL → rework or stop...
567
+ Phase 4: git commit + push + gh pr create
568
+ [CONDITIONAL] uni-docs — documentation update (if trigger criteria met)
569
+ /uni-review-pr — security review + merge readiness
570
+ Combined return — SESSION 2 ENDS
571
+ context_cycle(type: "phase-end", phase: "pr-review", ...)
572
+ context_cycle(type: "stop", topic: "{feature-id}", outcome: "...", agent_id: "{feature-id}-delivery-leader")
573
+ ```
574
+
575
+ ---
576
+
577
+ ## Integration Test Harness
578
+
579
+ **Authoritative reference**: `product/test/infra-001/USAGE-PROTOCOL.md` — contains commands, suite descriptions, failure triage decision tree, GH Issue templates, and xfail workflow.
580
+
581
+ The uni-tester agent has full integration harness knowledge (suite selection, triage rules, commands). The delivery protocol does not duplicate those details. Key rules for the Design Leader:
582
+
583
+ - **uni-rust-dev** (Stage 3b): Do NOT run or modify integration tests. Stage 3c handles this.
584
+ - **uni-tester** (Stage 3a): Include integration harness plan in test-plan/OVERVIEW.md — which suites apply, new tests needed.
585
+ - **uni-tester** (Stage 3c): Run smoke (mandatory gate) + relevant suites. Triage failures per USAGE-PROTOCOL.md. Report results in RISK-COVERAGE-REPORT.md.
586
+ - **uni-validator** (Gate 3c): Verify smoke passed, xfail markers have GH Issues, no tests deleted, RISK-COVERAGE-REPORT includes integration counts.
587
+
588
+ ---
589
+
590
+ ## Outcome Recording
591
+
592
+ After Phase 4, close the feature cycle:
593
+
594
+ ```
595
+ context_cycle(
596
+ type: "phase-end",
597
+ phase: "pr-review",
598
+ agent_id: "{feature-id}-delivery-leader"
599
+ )
600
+
601
+ context_cycle(
602
+ type: "stop",
603
+ topic: "{feature-id}",
604
+ outcome: "Session 2 complete. All gates passed. PR: {url}",
605
+ agent_id: "{feature-id}-delivery-leader"
606
+ )
607
+ ```