ultra-builder-pro-cli 0.9.0 → 0.11.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.
Files changed (119) hide show
  1. package/CHANGELOG.md +92 -1
  2. package/README.md +11 -6
  3. package/adapters/_shared/codex-assets.cjs +23 -331
  4. package/adapters/_shared/handbook.cjs +2 -0
  5. package/adapters/_shared/runtime-assets.cjs +25 -0
  6. package/adapters/_shared/tests/handbook.test.cjs +3 -0
  7. package/adapters/_shared/tests/runtime-assets.test.cjs +12 -4
  8. package/adapters/claude.js +28 -5
  9. package/adapters/kimi.js +15 -138
  10. package/adapters/opencode.js +59 -63
  11. package/adapters/tests/claude.test.cjs +26 -9
  12. package/adapters/tests/codex.test.cjs +23 -9
  13. package/adapters/tests/kimi.test.cjs +15 -11
  14. package/adapters/tests/opencode.test.cjs +57 -10
  15. package/agents/code-reviewer.md +24 -85
  16. package/agents/debugger.md +30 -132
  17. package/agents/review-code.md +24 -104
  18. package/agents/review-comments.md +20 -83
  19. package/agents/review-coordinator.md +40 -137
  20. package/agents/review-design.md +21 -118
  21. package/agents/review-errors.md +22 -70
  22. package/agents/review-spec.md +36 -0
  23. package/agents/review-tests.md +20 -76
  24. package/agents/tdd-runner.md +26 -84
  25. package/commands/learn.md +5 -36
  26. package/commands/ultra-change.md +5 -43
  27. package/commands/ultra-deliver.md +4 -46
  28. package/commands/ultra-dev.md +4 -48
  29. package/commands/ultra-doctor.md +4 -30
  30. package/commands/ultra-init.md +5 -47
  31. package/commands/ultra-plan.md +5 -48
  32. package/commands/ultra-research.md +5 -54
  33. package/commands/ultra-status.md +5 -44
  34. package/commands/ultra-test.md +5 -45
  35. package/commands/ultra-think.md +5 -40
  36. package/docs/AGENT-CONTEXT.md +34 -12
  37. package/docs/ARCHITECTURE.md +31 -5
  38. package/docs/PLAN.zh-CN.md +3 -2
  39. package/docs/ROADMAP.md +5 -4
  40. package/docs/RUNTIME-COMPAT-MATRIX.md +7 -5
  41. package/docs/SKILL-AUTHORING.md +75 -0
  42. package/docs/USER-HANDBOOK-CONTRACT.md +9 -2
  43. package/hooks/README.md +6 -4
  44. package/hooks/active_task_context.py +14 -0
  45. package/hooks/context_spine.py +218 -0
  46. package/hooks/health_check.py +1 -1
  47. package/hooks/workflow_context.py +16 -123
  48. package/hooks/workflow_resume.py +21 -0
  49. package/mcp-server/lib/change-workflow.cjs +89 -11
  50. package/mcp-server/lib/change-workflow.test.cjs +202 -7
  51. package/mcp-server/lib/context-spine.cjs +331 -0
  52. package/mcp-server/lib/context-spine.test.cjs +73 -0
  53. package/mcp-server/lib/spec-learning.cjs +191 -0
  54. package/mcp-server/lib/spec-learning.test.cjs +62 -0
  55. package/mcp-server/lib/state-db.cjs +72 -10
  56. package/mcp-server/lib/state-db.test.cjs +7 -2
  57. package/mcp-server/server.cjs +31 -1
  58. package/mcp-server/tests/db-ops.test.cjs +3 -3
  59. package/mcp-server/tests/server-contract.test.cjs +74 -0
  60. package/mcp-server/tests/state-db.test.cjs +20 -3
  61. package/package.json +3 -2
  62. package/skills/cc-collab/SKILL.md +16 -18
  63. package/skills/code-review-expert/SKILL.md +39 -114
  64. package/skills/code-review-expert/references/correctness-reliability.md +30 -0
  65. package/skills/code-review-expert/references/design-boundaries.md +26 -0
  66. package/skills/code-review-expert/references/removal-plan.md +17 -45
  67. package/skills/codex-collab/SKILL.md +23 -28
  68. package/skills/codex-collab/evals/evals.json +18 -23
  69. package/skills/integration-rules/SKILL.md +28 -67
  70. package/skills/learn/SKILL.md +46 -105
  71. package/skills/security-rules/SKILL.md +34 -56
  72. package/skills/testing-rules/SKILL.md +28 -52
  73. package/skills/ultra-change/SKILL.md +61 -145
  74. package/skills/ultra-deliver/SKILL.md +63 -229
  75. package/skills/ultra-dev/SKILL.md +46 -338
  76. package/skills/ultra-doctor/SKILL.md +39 -71
  77. package/skills/ultra-init/SKILL.md +59 -139
  78. package/skills/ultra-plan/SKILL.md +50 -310
  79. package/skills/ultra-research/SKILL.md +59 -152
  80. package/skills/ultra-research/references/architecture.md +38 -0
  81. package/skills/ultra-research/references/problem-product.md +39 -0
  82. package/skills/ultra-research/references/quality-delivery.md +34 -0
  83. package/skills/ultra-research/references/synthesis.md +38 -0
  84. package/skills/ultra-research/references/users-scope.md +40 -0
  85. package/skills/ultra-review/SKILL.md +55 -427
  86. package/skills/ultra-review/references/unified-schema.md +76 -101
  87. package/skills/ultra-review/scripts/review_wait.py +242 -77
  88. package/skills/ultra-status/SKILL.md +38 -173
  89. package/skills/ultra-test/SKILL.md +41 -195
  90. package/skills/ultra-think/SKILL.md +43 -101
  91. package/skills/ultra-verify/SKILL.md +44 -84
  92. package/skills/ultra-verify/evals/evals.json +24 -27
  93. package/spec/cli-protocol.md +3 -0
  94. package/spec/mcp-tools.yaml +133 -4
  95. package/spec/schemas/command-manifest.schema.json +7 -25
  96. package/spec/schemas/skill-manifest.schema.json +9 -79
  97. package/spec/schemas/state-db.sql +31 -0
  98. package/skills/code-review-expert/references/code-quality-checklist.md +0 -112
  99. package/skills/code-review-expert/references/integration-checklist.md +0 -46
  100. package/skills/code-review-expert/references/security-checklist.md +0 -100
  101. package/skills/code-review-expert/references/solid-checklist.md +0 -65
  102. package/skills/ultra-research/steps/step-00-problem-validation.md +0 -154
  103. package/skills/ultra-research/steps/step-01-opportunity-discovery.md +0 -172
  104. package/skills/ultra-research/steps/step-02-market-assessment.md +0 -195
  105. package/skills/ultra-research/steps/step-03-competitive-landscape.md +0 -197
  106. package/skills/ultra-research/steps/step-04-product-strategy.md +0 -196
  107. package/skills/ultra-research/steps/step-05-assumptions-validation.md +0 -234
  108. package/skills/ultra-research/steps/step-10-user-personas.md +0 -169
  109. package/skills/ultra-research/steps/step-11-user-scenarios.md +0 -181
  110. package/skills/ultra-research/steps/step-20-user-stories.md +0 -156
  111. package/skills/ultra-research/steps/step-21-features-scope.md +0 -157
  112. package/skills/ultra-research/steps/step-22-success-metrics.md +0 -195
  113. package/skills/ultra-research/steps/step-30-architecture-context.md +0 -154
  114. package/skills/ultra-research/steps/step-31-solution-strategy.md +0 -172
  115. package/skills/ultra-research/steps/step-32-building-blocks.md +0 -188
  116. package/skills/ultra-research/steps/step-40-deployment.md +0 -123
  117. package/skills/ultra-research/steps/step-41-quality-risks.md +0 -135
  118. package/skills/ultra-research/steps/step-99-synthesis.md +0 -188
  119. package/skills/ultra-review/scripts/review_verdict_update.py +0 -99
@@ -1,453 +1,81 @@
1
1
  ---
2
2
  name: ultra-review
3
- description: "Parallel code review orchestration with 5 specialized reviewers + coordinator. Zero context pollution - all output via JSON files."
4
- user-invocable: true
5
- runtime: all
6
- mcp_tools_required:
7
- - change.list
8
- - task.list
3
+ description: Run independent specification-fidelity and engineering reviews over one current diff using bounded workers and file-based evidence. Use when implementation needs a read-only review gate before task completion or delivery.
9
4
  ---
10
5
 
11
- # /ultra-review - Ultra Review System
6
+ # Review one current diff
12
7
 
13
- Orchestrates parallel code review using specialized agents. All findings written to JSON files to prevent context window pollution.
8
+ Keep two verdict axes independent:
14
9
 
15
- ## Workflow Tracking (MANDATORY)
10
+ 1. `spec_fidelity`: intent, acceptance, delta, documentation impact, and public seam;
11
+ 2. `engineering_standards`: correctness, safety, maintainability, testing,
12
+ observability, and recovery.
16
13
 
17
- **On command start**, create tasks for each major step using `TaskCreate`:
14
+ One axis cannot compensate for the other. Preserve each finding's source, severity,
15
+ file and line, and axis during coordination.
18
16
 
19
- | Step | Subject | activeForm |
20
- |------|---------|------------|
21
- | 1 | Setup & Scope Detection | Detecting diff scope... |
22
- | 2 | Agent Selection | Selecting review agents... |
23
- | 3 | Background Execution | Running review agents... |
24
- | 4 | Wait & Coordinate | Waiting for agent results... |
25
- | 5 | Report to User | Generating review report... |
17
+ ## Scope and context
26
18
 
27
- **Before each step**: `TaskUpdate` → `status: "in_progress"`
28
- **After each step**: `TaskUpdate` → `status: "completed"`
29
- **On context recovery**: `TaskList` → resume from last incomplete step
19
+ 1. Resolve one explicit diff range and file set. Include staged and unstaged changes
20
+ for a default working-tree review.
21
+ 2. Bind the single matching change through `change.list` and `task.list`; require an id
22
+ when ambiguous.
23
+ 3. Compile `change.context` for the review role and gate with only the intent, delta,
24
+ acceptance, tests, diff paths, and public-seam contract needed for this review.
25
+ 4. Stop on stale HEAD, blocked readiness, empty scope, or missing acceptance evidence.
26
+ 5. Create `.ultra/reviews/<session-id>/` with the reviewed HEAD, range, change id,
27
+ selected workers, and a pending verdict.
30
28
 
31
- ## Usage
29
+ ## Run the independent fidelity axis
32
30
 
33
- ```
34
- /ultra-review # Full review (smart skip based on diff content)
35
- /ultra-review all # Force ALL 5 reviewers, no auto-skip (pre-merge gate)
36
- /ultra-review quick # Quick review (review-code only)
37
- /ultra-review security # Security focus (review-code + review-errors)
38
- /ultra-review tests # Test quality focus (review-tests only)
39
- /ultra-review recheck # Re-check only P0/P1 files from last session
40
- /ultra-review delta # Review only changes since last review session
41
- /ultra-review <agents...> # Custom: e.g., /ultra-review tests errors types
42
- ```
31
+ Always dispatch `review-spec` with only the accepted intent, delta, acceptance criteria,
32
+ public-seam context, current HEAD, and diff scope. Do not give it engineering findings
33
+ or an implementation rationale that is not part of the accepted contract. It writes
34
+ `spec-fidelity.json` with `axis: spec_fidelity`.
43
35
 
44
- ### Scope Options (combinable with any mode)
36
+ ## Select engineering specialists
45
37
 
46
- ```
47
- /ultra-review --pr 123 # Review PR #123 diff (base...head)
48
- /ultra-review --range main..HEAD # Review specific commit range
49
- /ultra-review --range abc123 # Review single commit
50
- /ultra-review security --pr 42 # Security review scoped to PR #42
51
- ```
38
+ Use the smallest set that covers the diff. The delivery gate runs all five:
52
39
 
53
- ## Orchestration Flow
40
+ - `review-code`: correctness, security, and live-path reachability;
41
+ - `review-tests`: behavioral coverage and feedback-loop evidence;
42
+ - `review-errors`: hidden failures, recovery, and observability;
43
+ - `review-design`: types, boundaries, complexity, and coupling;
44
+ - `review-comments`: stale or misleading comments and documentation.
54
45
 
55
- ### Phase 1: Setup & Scope Detection
46
+ Record why any engineering specialist is skipped. The independent specification
47
+ worker is required for every change-linked review.
56
48
 
57
- ```python
58
- # 1. Determine session context
59
- BRANCH = git branch --show-current # e.g., "feat/task-3-auth"
60
- ITER = count existing sessions matching this branch + 1 # iteration number
61
- CHANGE_ID = active change whose linked tasks/diff match this scope, else null
49
+ ## Execute bounded workers
62
50
 
63
- # 2. Create session directory with full context
64
- SESSION_ID = "<YYYYMMDD-HHmmss>-<branch>-iter<N>"
65
- # e.g., "20260214-103000-feat-task-3-auth-iter2"
66
- SESSION_PATH = ".ultra/reviews/{SESSION_ID}/"
67
- mkdir -p SESSION_PATH
51
+ Use the current host's native bounded-worker mechanism. Dispatch `review-spec` and the
52
+ selected engineering workers independently. Each worker must inspect only the supplied
53
+ diff and role context. Resolve `references/unified-schema.md` from this
54
+ Skill directory and pass that absolute path as `SCHEMA_PATH`; never make a worker infer
55
+ the plugin installation root. Each worker writes `<session>/<worker>.json` following
56
+ that contract, limits output to actionable findings, and returns only a short file
57
+ acknowledgement to the parent context.
68
58
 
69
- # 3. Update session index (placeholder — verdict filled in Phase 5)
70
- # Append entry to .ultra/reviews/index.json with verdict="pending"
71
- # See Session Index below for full schema
72
-
73
- # 4. Cleanup (see Lifecycle Management below)
74
-
75
- # 5. Detect diff scope (priority order)
76
- ```
59
+ Resolve bundled paths relative to this skill directory. Validate the exact expected
60
+ artifacts before coordination:
77
61
 
78
- **Scope resolution priority:**
79
-
80
- | Flag | Diff Command | DIFF_RANGE |
81
- |------|-------------|------------|
82
- | `--pr NUMBER` | `gh pr diff NUMBER --name-only` | PR base...head |
83
- | `--range RANGE` | `git diff RANGE --name-only` | Specified range |
84
- | _(default)_ | `git diff --name-only HEAD` + `git diff --cached --name-only` | HEAD (unstaged + staged) |
85
-
86
- **PR scope details** (`--pr NUMBER`):
87
- ```bash
88
- # Get PR metadata for session naming
89
- gh pr view NUMBER --json headRefName,baseRefName,title
90
- # Get changed files
91
- gh pr diff NUMBER --name-only
92
- # Set DIFF_RANGE to base...head for agents
93
- DIFF_RANGE="$(gh pr view NUMBER --json baseRefName -q .baseRefName)..HEAD"
94
- ```
95
-
96
- **Range scope details** (`--range RANGE`):
97
62
  ```bash
98
- git diff RANGE --name-only
99
- DIFF_RANGE="RANGE"
63
+ python3 scripts/review_wait.py <session-path> agents spec-fidelity review-code review-tests
100
64
  ```
101
65
 
102
- **Continuous-change linkage**:
103
-
104
- Call `change.list` and `task.list`, then bind the review to the single active or
105
- blocked change whose linked task files intersect `DIFF_FILES`. If multiple
106
- changes match, require an explicit scope instead of guessing. Write
107
- `change_id` and reviewed HEAD into `SUMMARY.json` and the session index so
108
- `/ultra-deliver` can use this artifact as review evidence. Initial-baseline
109
- reviews may use `change_id: null`.
66
+ Pass only the engineering worker stems actually selected. Missing or invalid required
67
+ artifacts make the corresponding axis incomplete; a partial set is never a pass.
110
68
 
111
- ### Phase 2: Agent Selection
69
+ Run `review-coordinator` only after validation. It may merge duplicate root causes but
70
+ must retain source identifiers and the highest original severity.
71
+ Validate its summary with the same waiter.
112
72
 
113
- Based on the mode argument and file classification:
73
+ ## Report and handoff
114
74
 
115
- **Mode: `full` (default)**
116
- Select all applicable agents based on diff content:
75
+ Report both axis verdicts first, followed by blocking findings and artifact paths.
76
+ Review is read-only except for review artifacts; fixes are a separate implementation
77
+ action. Recheck only unresolved or changed scope after fixes.
117
78
 
118
- | Agent | Skip Condition | Warning |
119
- |-------|---------------|---------|
120
- | review-code | Never skip | - |
121
- | review-tests | No test files in diff AND no source files without tests | WARN: "Code changed without test updates" |
122
- | review-errors | No error handling code detected | - |
123
- | review-design | No type definitions AND no function-level changes in diff | - |
124
- | review-comments | No comment changes in diff | - |
125
-
126
- **Auto-skip detection commands:**
127
- ```bash
128
- # Has type definitions?
129
- grep -l "interface \|type \|class \|enum " <diff_files>
130
-
131
- # Has comment changes?
132
- git diff HEAD -- <diff_files> | grep "^[+-].*//\|^[+-].*\*\|^[+-].*#"
133
-
134
- # Has test files?
135
- echo "<diff_files>" | grep -E "\.(test|spec)\.(ts|tsx|js|jsx)$|test_.*\.py$|.*_test\.go$"
136
-
137
- # Has error handling?
138
- grep -l "try\|catch\|\.catch\|throw\|Error(" <diff_files>
139
- ```
140
-
141
- **Mode: `all`** → Force ALL 5 reviewers, no auto-skip. Use for pre-merge gates (`/ultra-dev`).
142
- **Mode: `quick`** → review-code only
143
- **Mode: `security`** → review-code + review-errors
144
- **Mode: `tests`** → review-tests only
145
- **Mode: `recheck`** → See Recheck Logic below
146
- **Mode: `delta`** → See Delta Logic below
147
- **Mode: custom** → Parse agent names from arguments
148
-
149
- ### Phase 3: Background Execution (Zero Context Pollution)
150
-
151
- Launch ALL selected agents in **background mode** (`run_in_background: true`) using multiple Task tool calls in a single message. This prevents agent output from polluting the main conversation context.
152
-
153
- Each agent receives this prompt template:
154
-
155
- ```
156
- You are running as part of /ultra-review pipeline.
157
-
158
- SESSION_PATH: {SESSION_PATH}
159
- OUTPUT_FILE: {agent-name}.json
160
- DIFF_FILES: {comma-separated file list}
161
- DIFF_RANGE: {resolved DIFF_RANGE from Phase 1}
162
-
163
- Review the changed files and write your findings as JSON to:
164
- {SESSION_PATH}/{agent-name}.json
165
-
166
- Follow the ultra-review-findings-v1 schema exactly. Read the schema from:
167
- $CLAUDE_PLUGIN_ROOT/skills/ultra-review/references/unified-schema.md
168
-
169
- Only report findings with confidence >= 75.
170
-
171
- After writing the JSON file, output one line: "Wrote N findings (P0:X P1:X P2:X P3:X) to <filepath>"
172
- ```
173
-
174
- **Important**: Use `subagent_type` matching the agent name (e.g., `review-code`, `review-tests`, etc.).
175
-
176
- **Important**: Set `run_in_background: true` on every Task call. Do NOT read TaskOutput — this avoids injecting agent results into main context.
177
-
178
- Maximum 12 findings per agent. If you find more, report only the top 12 by severity (P0 first),
179
- then confidence. Note total count in your output line: "Wrote 12/23 findings..."
180
-
181
- **CRITICAL PROHIBITION**: After launching background agents, you MUST:
182
- 1. Call `review_wait.py` IMMEDIATELY — do NOT process idle notifications
183
- 2. NEVER call TaskOutput for any review agent — their output goes to JSON files only
184
- 3. Ignore all agent idle/completion messages between launch and wait script return
185
- 4. The ONLY information path from agents is: wait script → Read SUMMARY.json
186
-
187
- Violation of these rules causes context overflow. The review agents write to files; you read from files.
188
-
189
- ### Phase 4: Wait & Coordinate (File-Based)
190
-
191
- **Step 4a: Wait for agents** — Use Bash to block until all agents finish writing:
192
-
193
- ```bash
194
- python3 "$CLAUDE_PLUGIN_ROOT/skills/ultra-review/scripts/review_wait.py" {SESSION_PATH} agents {AGENT_COUNT}
195
- ```
196
-
197
- This polls for `review-*.json` files every 2 seconds. Timeout: 5 minutes.
198
- Output is structured JSON on stdout:
199
- - `status: "complete"` → all agents done, proceed normally
200
- - `status: "partial"` → timeout, log missing agents, pass only `agents_done` to coordinator, note partial review in SUMMARY
201
- - Exit code 1 (0 agents) → skip review, warn user, allow ultra-dev to continue
202
-
203
- **Step 4b: Launch coordinator in background:**
204
-
205
- Launch review-coordinator with `run_in_background: true`:
206
-
207
- ```
208
- You are the review coordinator.
209
-
210
- SESSION_PATH: {SESSION_PATH}
211
- AGENTS_RUN: {list of agents from wait output}
212
-
213
- Read all review-*.json files in the session directory, deduplicate findings,
214
- compute verdict, and generate SUMMARY.md + SUMMARY.json.
215
- ```
216
-
217
- **Step 4c: Wait for coordinator:**
218
-
219
- ```bash
220
- python3 "$CLAUDE_PLUGIN_ROOT/skills/ultra-review/scripts/review_wait.py" {SESSION_PATH} summary
221
- ```
222
-
223
- Output is a single verdict line (~15 tokens).
224
-
225
- ### Phase 5: Report to User
226
-
227
- After `review_wait.py summary` returns:
228
-
229
- 1. **Read SUMMARY.json** (one Read call, ~500 tokens) to get verdict and counts
230
- 2. **Update index.json** — fill in the placeholder entry with actual verdict, p0, p1, total from SUMMARY.json
231
- 3. Present a concise summary:
232
-
233
- ```markdown
234
- ## Review Complete
235
-
236
- **Verdict**: {APPROVE | COMMENT | REQUEST_CHANGES}
237
- **Findings**: X total (P0: A, P1: B, P2: C, P3: D)
238
- **Agents**: N ran, M succeeded
239
-
240
- ### Top Findings
241
- 1. [P0] {title} - {file}:{line}
242
- 2. [P1] {title} - {file}:{line}
243
- 3. ...
244
- (show up to 5 most critical findings)
245
-
246
- Full report: {SESSION_PATH}/SUMMARY.md
247
- ```
248
-
249
- Then ask the user:
250
- 1. **Fix all** - Fix all P0 and P1 issues
251
- 2. **Fix P0 only** - Fix only critical issues
252
- 3. **View full report** - Read SUMMARY.md
253
- 4. **Skip** - No fixes needed
254
-
255
- ## Recheck Logic
256
-
257
- When mode is `recheck`:
258
- 1. Find the most recent session **for the current branch** in `index.json`
259
- 2. Read its `SUMMARY.json`
260
- 3. Extract files with P0 or P1 findings
261
- 4. Run review-code only on those specific files
262
- 5. Compare with previous findings to show delta (resolved / new / unchanged)
263
-
264
- ## Delta Logic
265
-
266
- When mode is `delta`:
267
- 1. Find the most recent session **for the current branch** in `index.json`
268
- 2. Read its `SUMMARY.json` to get the scope of last review
269
- 3. Identify files changed since the last review:
270
- ```bash
271
- # If last session was commit-based, diff from that commit
272
- git diff --name-only <last-reviewed-commit>..HEAD
273
- # If last session was working-tree-based, diff current unstaged + staged
274
- git diff --name-only HEAD
275
- ```
276
- 4. **Exclude** files that have NOT changed since last review (already reviewed)
277
- 5. Run full agent set only on the newly changed files
278
- 6. In coordinator, merge with previous session findings (carry forward unresolved P0/P1)
279
-
280
- **Use case**: Iterative development — fix issues, add code, only review what's new.
281
-
282
- ## Session Index
283
-
284
- A lightweight index file tracks all sessions for cross-referencing:
285
-
286
- **File**: `.ultra/reviews/index.json`
287
-
288
- ```json
289
- {
290
- "sessions": [
291
- {
292
- "id": "20260214-103000-feat-task-3-auth-iter1",
293
- "branch": "feat/task-3-auth",
294
- "change_id": "auth-change",
295
- "iteration": 1,
296
- "mode": "full",
297
- "timestamp": "2026-02-14T10:30:00Z",
298
- "verdict": "REQUEST_CHANGES",
299
- "p0": 2,
300
- "p1": 3,
301
- "total": 12,
302
- "parent": null
303
- },
304
- {
305
- "id": "20260214-113000-feat-task-3-auth-iter2",
306
- "branch": "feat/task-3-auth",
307
- "iteration": 2,
308
- "mode": "recheck",
309
- "timestamp": "2026-02-14T11:30:00Z",
310
- "verdict": "COMMENT",
311
- "p0": 0,
312
- "p1": 1,
313
- "total": 4,
314
- "parent": "20260214-103000-feat-task-3-auth-iter1"
315
- }
316
- ]
317
- }
318
- ```
319
-
320
- **Fields**:
321
-
322
- | Field | Description |
323
- |-------|-------------|
324
- | `id` | Session directory name |
325
- | `branch` | Git branch at review time |
326
- | `change_id` | Continuous change reviewed, or null for initial baseline |
327
- | `iteration` | Nth review for this branch (auto-incremented) |
328
- | `mode` | Review mode used (full/quick/security/recheck/delta) |
329
- | `timestamp` | ISO 8601 |
330
- | `verdict` | APPROVE / COMMENT / REQUEST_CHANGES |
331
- | `p0`, `p1`, `total` | Finding counts from SUMMARY.json |
332
- | `parent` | Previous session ID for this branch (forms iteration chain) |
333
-
334
- **Branch-scoped queries**:
335
- - `recheck` / `delta`: filter `index.json` by `branch == current branch`, take latest
336
- - Avoids cross-task pollution when multiple branches are active
337
-
338
- ## Lifecycle Management
339
-
340
- **Cleanup strategy** (runs at Phase 1 of every `/ultra-review`):
341
-
342
- | Rule | Action |
343
- |------|--------|
344
- | Session > 7 days AND verdict = APPROVE | Delete directory + remove from index |
345
- | Session > 7 days AND verdict = COMMENT | Delete directory + remove from index |
346
- | Session > 7 days AND verdict = REQUEST_CHANGES | **Keep** (unresolved P0s should not be silently deleted) |
347
- | Session > 30 days (any verdict) | Delete directory + remove from index |
348
- | Per-branch limit: > 5 sessions | Delete oldest APPROVE/COMMENT sessions for that branch |
349
-
350
- **Implementation**:
351
- ```python
352
- # In Phase 1, after creating session directory:
353
- index = read index.json (or create if missing)
354
-
355
- # 1. Remove stale sessions
356
- now = current_time()
357
- for session in index.sessions:
358
- age_days = (now - session.timestamp).days
359
- if age_days > 30:
360
- delete(session)
361
- elif age_days > 7 and session.verdict != 'REQUEST_CHANGES':
362
- delete(session)
363
-
364
- # 2. Per-branch cap (keep latest 5)
365
- branch_sessions = [s for s in index.sessions if s.branch == current_branch]
366
- if len(branch_sessions) > 5:
367
- # Sort by timestamp, keep latest 5, delete rest (except REQUEST_CHANGES)
368
- to_remove = sorted(branch_sessions, key=timestamp)[:-5]
369
- for s in to_remove:
370
- if s.verdict != 'REQUEST_CHANGES':
371
- delete(s)
372
-
373
- # 3. Write updated index
374
- write index.json
375
- ```
376
-
377
- ## Fix Flow
378
-
379
- When user selects "Fix all" or "Fix P0 only" after review:
380
-
381
- **Step 0: Context Reset** (if verdict is REQUEST_CHANGES):
382
- - Run `/compact` to clear TDD cycle history from context
383
- - After compact, read `.ultra/workflow-state.json` to restore task context
384
- - Read `SUMMARY.json` fresh to get actionable findings
385
- - Then proceed with fixes below
386
-
387
- 1. **Read SUMMARY.json** — extract actionable P0/P1 items, sort by severity (P0 first)
388
- 2. **Group by file** — organize findings per file
389
- 3. **For each file with findings** (with circuit breaker tracking):
390
- a. Read the file once
391
- b. Apply ALL P0/P1 fixes for that file (batch within same file)
392
- c. Run the RELEVANT test file only:
393
- - Detect: `foo.ts` → `foo.test.ts` / `foo.spec.ts`
394
- - Run: `npx jest <test-file> --bail` or `pytest <test-file> -x`
395
- d. If test passes → mark findings as addressed, move to next file
396
- e. If test fails from THIS fix → increment per-file failure counter, revert, try alternative approach
397
- f. If test fails from pre-existing issue → note it, continue
398
- g. **Circuit Breaker**: If same file has 3 consecutive fix failures (test fails after each attempt):
399
- - Display: "Circuit breaker: {filename} — 3 consecutive fix failures. Likely architectural issue, not isolated bug."
400
- - Use AskUserQuestion:
401
- - A) "Skip this file, continue with others"
402
- - B) "Manually inspect this file" (exit auto-fix, user takes over)
403
- - C) "Abandon this fix round" (end fix flow, write UNRESOLVED.md)
404
- h. **Global Circuit Breaker**: If 3+ files trigger per-file circuit breaker:
405
- - Display: "Multiple files failing repeatedly — suggests systematic issue, not isolated bugs."
406
- - Recommend ending fix flow, write all unresolved findings to UNRESOLVED.md with tag `ARCHITECTURAL_CONCERN`
407
- 4. **After all files fixed**: run FULL test suite once as validation
408
- 5. **Update verdict** — after all P0 fixes applied and tests pass:
409
- ```bash
410
- python3 "$CLAUDE_PLUGIN_ROOT/skills/ultra-review/scripts/review_verdict_update.py" {SESSION_PATH}
411
- ```
412
- This recalculates the verdict from current P0/P1 counts and updates both SUMMARY.json and index.json.
413
- Without this step, pre_stop_check will block on stale REQUEST_CHANGES verdict.
414
- 6. **Optionally**: `/ultra-review recheck` (counts as iteration, respects max 2 cap)
415
-
416
- **Important**: The main agent (not review agents) performs fixes. Review agents are read-only by design.
417
-
418
- ## Integration with ultra-dev
419
-
420
- This skill integrates with the TDD workflow:
421
- - After `tdd-runner` confirms tests pass
422
- - Before `commit` or PR creation
423
- - Quick mode for iterative development
424
- - Full mode for pre-merge gate
425
- - Recheck mode after fixing review findings
426
- - Delta mode for incremental review during long development sessions
427
-
428
- ## Error Handling
429
-
430
- - If no diff detected: inform user, suggest using `--range` or `--pr` to specify scope
431
- - If `--pr` fails (no gh CLI or no PR): fall back to default diff and warn user
432
- - If an agent fails to write JSON: note in coordinator input, skip that agent's findings
433
- - If coordinator fails: fall back to reading individual JSON files and presenting raw findings
434
- - If no agents selected (all skipped): inform user with skip reasons
435
-
436
- ## Directory Structure
437
-
438
- ```
439
- .ultra/reviews/
440
- ├── index.json # Session index (all sessions metadata)
441
- ├── 20260214-103000-feat-task-3-auth-iter1/ # First review
442
- │ ├── review-code.json
443
- │ ├── review-tests.json
444
- │ ├── review-errors.json
445
- │ ├── review-design.json
446
- │ ├── review-comments.json
447
- │ ├── SUMMARY.json
448
- │ └── SUMMARY.md
449
- └── 20260214-113000-feat-task-3-auth-iter2/ # Recheck after fixes
450
- ├── review-code.json
451
- ├── SUMMARY.json
452
- └── SUMMARY.md
453
- ```
79
+ At the final HEAD, compile review context with one convergence action. Delivery must
80
+ submit separate review evidence rows for `spec_fidelity` and
81
+ `engineering_standards`; a single aggregate pass is invalid.