Skip to content

Commit 0b418d1

Browse files
committed
refactor: Switch review-resolve to per-specialist batched verification
Step 1 returns by_assignee instead of writing findings.json; Step 2 launches one Sub per specialist that batch-verifies its assigned ids. review-rounds SKILL and the sequencer program are updated to match. Also trim redundant preambles and chat-context-dependent wording from the review-resolve SKILL and sequencer prompts per .claude/rules/prompt.md.
1 parent d27ca54 commit 0b418d1

3 files changed

Lines changed: 59 additions & 60 deletions

File tree

.claude/sequencer/programs/review_rounds.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,8 @@
193193
_TPL_REVIEW_INIT = textwrap.dedent("""\
194194
[Round 1/{max_rounds} Step 1: parallel-review (with initialization)]
195195
Skill: {skill}
196-
Run parallel-review against the branch diff for {base_clause}. Following the
197-
skill body, reviewers Write to individual files and an aggregator sub-agent
198-
consolidates them. The orchestrator (you) does not load review-finding bodies
199-
into context.
196+
Run parallel-review against the branch diff for {base_clause}. The
197+
orchestrator (you) does not load review-finding bodies into context.
200198
201199
Initialization:
202200
- Obtain the current branch name: git branch --show-current
@@ -228,10 +226,8 @@
228226
_TPL_REVIEW = textwrap.dedent("""\
229227
[Round {round_num}/{max_rounds} Step 1: parallel-review]
230228
Skill: {skill}
231-
Run parallel-review against the branch diff for {base_clause}. Following the
232-
skill body, reviewers Write to individual files and an aggregator sub-agent
233-
consolidates them. The orchestrator (you) does not load review-finding bodies
234-
into context.
229+
Run parallel-review against the branch diff for {base_clause}. The
230+
orchestrator (you) does not load review-finding bodies into context.
235231
236232
File-naming rules:
237233
- Output path: {output_base}/{branch_dir}/review-round{round_num}.md
@@ -261,11 +257,9 @@
261257
_TPL_RESPOND = textwrap.dedent("""\
262258
[Round {round_num}/{max_rounds} Step 2: review-respond]
263259
Skill: {skill}
264-
Respond to the findings in review document {doc_path}. Following the skill
265-
body, delegate parsing / triage / estimate / fix / format verification /
266-
build verification / aggregation to sub-agents. The orchestrator (you) only
267-
orchestrates the retry loop and does not load verdict bodies or finding
268-
bodies into context.
260+
Respond to the findings in review document {doc_path}. The orchestrator
261+
(you) only orchestrates the retry loop and does not load verdict bodies or
262+
finding bodies into context.
269263
{confirm_clause}
270264
{commit_clause}
271265
@@ -303,10 +297,8 @@
303297
_TPL_RESOLVE = textwrap.dedent("""\
304298
[Round {round_num}/{max_rounds} Step 3: review-resolve]
305299
Skill: {skill}
306-
Verify the resolution status of review document {doc_path}. Following the
307-
skill body, delegate parsing / per-finding verification / aggregation to
308-
sub-agents. The orchestrator (you) does not load verification bodies into
309-
context.
300+
Verify the resolution status of review document {doc_path}. The
301+
orchestrator (you) does not load verification bodies into context.
310302
311303
Reporting format (JSON):
312304
{{
@@ -318,8 +310,7 @@
318310
- unresolved_count: aggregator sub-agent's return value feedback_count
319311
(number of findings whose Verification still reads 💬 Feedback).
320312
- resolved_count: aggregator sub-agent's return value resolved_count.
321-
- feedback_count: synonymous with unresolved_count (both included for
322-
backward compatibility).
313+
- feedback_count: synonymous with unresolved_count.
323314
- summary_line: 1-line summary for user notification.\
324315
""")
325316

@@ -349,7 +340,7 @@
349340
current_meta.verification into account.
350341
351342
Step 4.{attempt}.4 Feedback verify
352-
Re-run {resolve_skill} (parsing Sub → verification Sub group → aggregator Sub).
343+
Re-run {resolve_skill}.
353344
354345
Reporting format (JSON):
355346
{{

.claude/skills/review-resolve/SKILL.md

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Review documents are generated by parallel-review and contain metadata markers a
3434
---
3535
```
3636

37-
The current state of each finding is determined from **the fields present between the markers**:
37+
The current state of each finding is determined from the fields present between the markers:
3838

3939
- Markers are empty → not yet triaged.
4040
- `Triage: 🔧 Will Fix` only → triaged, estimate not yet completed.
@@ -62,7 +62,7 @@ For common prohibitions, see `.claude/rules/sub-agent.md`. The leader appends th
6262

6363
## Internal Processing (Intermediate Files)
6464

65-
Each finding's verification verdict is written to an intermediate file, and the aggregator sub-agent consolidates them. The leader (you) does not load verification bodies into context.
65+
The leader (you) does not load verification bodies into context.
6666

6767
### Working Directory
6868

@@ -75,7 +75,7 @@ The leader creates `{tmp_dir}` with `mkdir -p {tmp_dir}/verifications` at the st
7575

7676
### events.jsonl
7777

78-
Final markdown reflection still uses **`{basename}.events.jsonl` in the same directory as the markdown** (e.g., `review-round1.md``review-round1.events.jsonl`; referred to as `{events_path}` below). The **aggregator sub-agent** generates events.jsonl in one shot from the files under `{tmp_dir}/verifications/` (Step 4). Format:
78+
events.jsonl is `{basename}.events.jsonl` in the same directory as the markdown (e.g., `review-round1.md``review-round1.events.jsonl`; referred to as `{events_path}` below). Format:
7979

8080
```jsonl
8181
{"id":"C-1","field":"verification","value":"✅ Verified — Null check fix is correct"}
@@ -88,50 +88,61 @@ Use the **Write tool** for the file. Bash cat heredoc is unusable because apostr
8888

8989
## Step 1 — Parse (Delegated to Parsing Sub-Agent)
9090

91-
Launch the parsing sub-agent to extract findings. The leader (you) receives only the result file path, the count, and the dispatch `items`; do not load the review document body into context.
92-
Use the same prompt template as review-respond Step 1 to generate `{tmp_dir}/findings.json` (see review-respond § Step 1).
91+
Launch the parsing sub-agent to extract findings and assign verification specialists.
92+
93+
Example prompt:
9394

94-
Return value (the leader receives this JSON):
95-
```
96-
{
97-
"path": "{tmp_dir}/findings.json",
98-
"total": <int>,
99-
"by_stage": {...},
100-
"items": [{"id": "C-1", "stage": "fixed_skip"}, ...]
101-
}
10295
```
96+
Read review document {document_path} and extract id / stage / verification assignee for each finding (no file output).
10397
104-
Each element of `items` (only `id` and `stage`) is used as the dispatch list for launching verification sub-agents in the next step.
98+
Extraction targets: Critical / Major / Minor (skip Info).
10599
106-
## Step 2 — Verify Each Finding (Delegated in Parallel to Verification Sub-Agents)
100+
stage classification (based on the latest values in current_meta):
101+
- markers empty → pending_triage
102+
- triage: 🔧 Will Fix, no estimate → pending_estimate
103+
- estimate: ▶️ Maintain or 🚧 Alternative, no status → pending_fix
104+
- verification last value is 💬 Feedback → feedback
105+
- triage: 🚫 Won't Fix → wontfix_skip
106+
- estimate: 🔻 Downgrade → downgrade_skip
107+
- status: 🟢 Fixed, no verification or last value is ✅ Verified → fixed_skip
107108
108-
Loop over the `items` array received in Step 1 and launch a verification sub-agent in parallel for each `id` via the Agent tool. Findings have no inter-dependencies, so parallel launch is allowed. Each sub-agent looks up its id in `{tmp_dir}/findings.json` to obtain the trailing metadata, and Writes the result to `{tmp_dir}/verifications/{id}.json`.
109+
Verification assignee determination:
110+
- If the Triage line includes "(assignee: {specialist})", use that specialist.
111+
- If no assignee is present, pick one specialist from the finding's Reviewers, preferring required reviewers (cpp-sensei / qt-sensei / obs-sensei / network-sensei). If none of the required reviewers are listed, use the first Reviewer.
109112
110-
Launch procedure:
113+
Return value: {total, by_stage: {<stage>: <int>}, by_assignee: [{assignee, ids: [id, ...]}]}
114+
```
111115

112-
1. Launch a verification sub-agent in parallel for each element of `items` via the Agent tool. Example prompt:
116+
## Step 2 — Verify Each Finding (Delegated in Parallel per Specialist)
117+
118+
Loop over Step 1's `by_assignee` and launch a verification sub-agent in parallel for each `{assignee, ids}` via `Agent(subagent_type=assignee, prompt=...)` (the agent definition's persona and specialty perspective load automatically). Each specialist processes all assigned ids in a single launch, writing one `{tmp_dir}/verifications/{id}.json` per id.
119+
120+
Example prompt (do not include persona):
113121

114122
```
115-
Verify the resolution of finding {finding-id} (verification and JSON Write only).
123+
Verify the assigned findings {ids} in a single batch.
116124
117-
Input: the item with id == "{finding-id}" in {tmp_dir}/findings.json (read trailing field from current_meta).
118-
Output: {tmp_dir}/verifications/{finding-id}.json
125+
Input: review document {document_path} (Read to obtain severity / location / description / trailing metadata for each id).
119126
120-
Decision: based on the trailing field (final value of triage / estimate / status / verification), apply the rules in this SKILL § "Step 2 § Verification Logic" to determine Resolved / Feedback / Unresolved.
127+
For each id:
128+
1. Based on the trailing field (final value of triage / estimate / status / verification), apply the rules in this SKILL § "Step 2 § Verification Logic" to determine Resolved / Feedback / Unresolved.
129+
2. Write to {tmp_dir}/verifications/{id}.json.
121130
122-
{tmp_dir}/verifications/{finding-id}.json: {id, outcome (Resolved | Feedback | Unresolved), reason (1–3 sentences), memo_value, feedback_detail}
131+
{tmp_dir}/verifications/{id}.json: {id, severity, trailing_field, outcome (Resolved | Feedback | Unresolved), reason (1–3 sentences), memo_value, feedback_detail}
132+
133+
trailing_field: the literal last metadata line inside the markers (e.g., "Status: 🟢 Fixed" / "Triage: 🚫 Won't Fix" / "(empty)")
123134
124135
memo_value:
125136
- Resolved: "✅ Verified — {verification result}"
126137
- Feedback: "💬 Feedback — {what is missing and what is needed for full resolution}"
127138
- Unresolved: ""
128139
129-
feedback_detail (include only when outcome == Feedback): {current_state, issue, suggestion}
140+
feedback_detail (include only when outcome == Feedback): {description, current_state, issue, suggestion}
130141
131-
Return value: {path, outcome}
142+
Return value: [{id, outcome}, ...]
132143
```
133144

134-
2. Receive the return values (`{path, outcome}` only) from all verification agents. **Do not load verification bodies into context.**
145+
**Do not load verification bodies into context** (return values are `[{id, outcome}, ...]` only).
135146

136147
### Verification Logic
137148

@@ -175,7 +186,7 @@ Apply in each of `Status: 🟢 Fixed` / `Triage: 🚫 Won't Fix` / `Estimate:
175186

176187
## Step 3 — Verification Report and Reflection (Delegated to Aggregator Sub-Agent)
177188

178-
The aggregator sub-agent consolidates the verification results under `{tmp_dir}/verifications/` and performs verification-report generation, events.jsonl write, and `render-review.py` execution in one shot. The leader (you) does not load verification bodies into context.
189+
The leader (you) does not load verification bodies into context.
179190

180191
Launch procedure:
181192

@@ -185,8 +196,7 @@ Launch procedure:
185196
You are responsible for review-verification aggregation. Generate the verification report and events.jsonl from the intermediate files, and reflect them into the markdown.
186197
187198
Input:
188-
- {tmp_dir}/verifications/ — verification result for each finding
189-
- {tmp_dir}/findings.json — severity / trailing field reference
199+
- {tmp_dir}/verifications/ — verification result for each finding (includes severity / trailing_field / feedback_detail)
190200
- Target markdown: {document_path}
191201
192202
Output:
@@ -196,15 +206,15 @@ Output:
196206
197207
What to do:
198208
199-
1. Read {tmp_dir}/verifications/*.json, cross-reference with findings.json, and Write the verification report to {tmp_dir}/resolve-summary.md. Format:
209+
1. Read {tmp_dir}/verifications/*.json and Write the verification report to {tmp_dir}/resolve-summary.md. Format:
200210
- Heading: "# Review Verification Report"
201211
- Meta info: "Review document: {document_path}", "Verification date: YYYY-MM-DD" (bold)
202212
- Under "## Verification Results", three tables:
203213
- "### Resolved": # / Severity / Trailing field / Verdict (outcome == Resolved)
204214
- "### Feedback Required": # / Severity / Trailing field / Issue (outcome == Feedback)
205215
- "### Unresolved": # / Severity / Trailing field / Note (outcome == Unresolved)
206216
- "## Summary": findings verified / Resolved / Feedback required / Unresolved as a bullet list
207-
- "## Feedback Details": for each outcome == Feedback finding, write "### {finding-id} — Feedback", "Original finding", "Trailing field", "Actual state (feedback_detail.current_state)", "Issue (feedback_detail.issue)", "Suggestion (feedback_detail.suggestion)"; separate entries with ---
217+
- "## Feedback Details": for each outcome == Feedback finding, write "### {finding-id} — Feedback", "Original finding (feedback_detail.description)", "Trailing field", "Actual state (feedback_detail.current_state)", "Issue (feedback_detail.issue)", "Suggestion (feedback_detail.suggestion)"; separate entries with ---
208218
209219
2. Write verification events to {events_path} as JSONL (one event per line). Format: {"id":"...","field":"verification","value":"<memo_value>"}. Do not write events for outcome == Unresolved.
210220
@@ -214,14 +224,11 @@ What to do:
214224
Return value: {events_path, summary_path, summary_line (<=200 chars; e.g., "3 resolved, 1 feedback (M-1), 2 unresolved"), resolved_count, feedback_count, unresolved_count}
215225
```
216226

217-
2. The leader holds the return value (`{events_path, summary_path, summary_line, resolved_count, feedback_count, unresolved_count}`) in context.
218-
219-
3. The leader removes `{tmp_dir}` in one shot:
227+
2. The leader removes `{tmp_dir}` in one shot:
220228
```bash
221229
.claude/scripts/rm-tmp.sh {tmp_dir}
222230
```
223231

224232
## Step 4 — Completion Report
225233

226-
The leader prints the `summary_line` received from the aggregator sub-agent to the console.
227-
If a detailed report is needed, Read `summary_path` (`resolve-summary.md` while `{tmp_dir}` still exists). Usually the `summary_line` alone is sufficient.
234+
The leader prints the `summary_line` received from the aggregator sub-agent to the console. If a detailed report is needed, Read `summary_path` (`resolve-summary.md` while `{tmp_dir}` still exists).

.claude/skills/review-rounds/SKILL.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ Write the review document in the user's chat language.
4040
- **Most work, including aggregation and consolidation, is delegated to sub-agents** (one level of nesting is allowed):
4141
- Individual reviewers (Step 2.1) — launch cpp-sensei / qt-sensei / obs-sensei / network-sensei, etc. in parallel for individual reviews. Each reviewer Writes findings to a file; the return value is only the path and counts.
4242
- Aggregator sub-agent (Step 2.1) — Read the individual reviewer output files and consolidate them into the review document (parallel-review § Step 3).
43-
- Parsing sub-agent (Steps 2.2 / 2.3 / 2.4) — Read the review document and Write `findings.json`. Subsequent sub-agents take this JSON as input (review-respond § Step 1 / review-resolve § Step 1).
43+
- Parsing sub-agent (review-respond, Steps 2.2 / 2.4) — Read the review document and Write `findings.json`. Subsequent sub-agents take this JSON as input (review-respond § Step 1).
44+
- Parsing sub-agent (review-resolve, Steps 2.3 / 2.4) — Read the review document and return verification assignments (by_assignee) (review-resolve § Step 1; no file output).
4445
- Triage sub-agent (Steps 2.2 / 2.4) — render verdicts in a separate context to avoid bias (review-respond § Step 2).
4546
- Individual estimates (Steps 2.2 / 2.4) — delegate each Will Fix in parallel to its assigned specialist sub-agent (read-only).
4647
- Estimate aggregator sub-agent (Steps 2.2 / 2.4) — generate a summary of individual estimate results (review-respond § Step 3).
4748
- Individual fixes (Steps 2.2 / 2.4) — delegate each finding to the appropriate specialist sub-agent.
4849
- Format & build verification sub-agent (Steps 2.2 / 2.4) — run clang-format / cmake-format + build once; on failure, analyze code and determine the responsible specialist (no fix; recommendation only).
4950
- Build-fix specialist sub-agent (Steps 2.2 / 2.4) — fix build errors as the specialist determined by the format & build verification sub-agent. The leader re-launches the format & build verification sub-agent afterwards (review-respond § Step 5).
50-
- Verification sub-agent (Steps 2.3 / 2.4) — verify each finding in parallel (review-resolve § Step 2; read-only).
51+
- Verification sub-agent (Steps 2.3 / 2.4) — launched in parallel per specialist; each batch-verifies its assigned findings (review-resolve § Step 2; read-only).
5152
- Aggregator sub-agent (Steps 2.2 / 2.3 / 2.4) — generate events.jsonl from intermediate files and run render-review.py (review-respond § Step 6 / review-resolve § Step 3).
5253
- Final-report aggregator sub-agent (Step 3) — generate the final report from all rounds' review documents.
5354
- **The orchestrator (you) directly handles only the following**:
@@ -75,8 +76,8 @@ Round 1 starts
7576
│ [format & build verification Sub] ⇄ [build-fix specialist Sub] loop (max 5, leader-controlled)
7677
│ [aggregator Sub] triage.json + estimates/*.json + statuses/*.json → events.jsonl → render-review.py
7778
├─ 2.3 review-resolve
78-
│ [parsing Sub] Reads round1.md → emits findings.json
79-
│ [verification Sub group] verifies each finding in parallel → emits verifications/{id}.json
79+
│ [parsing Sub] Reads round1.md → returns by_assignee (no file output)
80+
│ [verification Sub group] launched per specialist; each batch-verifies its assigned findings → emits verifications/{id}.json
8081
│ [aggregator Sub] verifications/*.json → events.jsonl → render-review.py
8182
├─ 2.4 Feedback re-fix loop (up to 3 iterations)
8283
│ [parsing Sub] → [triage Sub] → [estimate Sub group] → [fix Sub group]

0 commit comments

Comments
 (0)