Skip to content

Commit 56c0429

Browse files
catlog22claude
andcommitted
fix: enable dynamic inner_loop for parallel task execution across 6 team skills
- team-lifecycle-v4: executor inner_loop true→dynamic, add dynamicImplDispatch for PLAN-001 callback - team-testing: executor inner_loop true→dynamic for comprehensive pipeline parallel TESTRUN - team-quality-assurance: executor inner_loop true→dynamic for full mode parallel QARUN - team-perf-opt: optimizer inner_loop true→dynamic for fan-out/independent parallel IMPL branches - team-arch-opt: refactorer inner_loop true→dynamic for fan-out/independent parallel REFACTOR branches - team-coordinate: fix dependency_graph schema mismatch, needs_research sequencing, handleSpawnNext role→task level check, add output_tag to template, precise inner_loop rules All handleSpawnNext now read task description InnerLoop: field instead of role-level default, enabling same-role workers to run in parallel when tasks have no mutual dependencies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 885eb18 commit 56c0429

26 files changed

Lines changed: 117 additions & 54 deletions

File tree

.claude/skills/team-arch-opt/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Execute built-in Phase 1 (task discovery) -> role Phase 2-4 -> built-in Phase 5
7878
})
7979
```
8080

81-
**Inner Loop roles** (refactorer): Set `inner_loop: true`.
81+
**Inner Loop roles** (refactorer): Set `inner_loop` dynamically — `true` for single mode, `false` for fan-out/independent (parallel branches).
8282
**Single-task roles** (analyzer, designer, validator, reviewer): Set `inner_loop: false`.
8383

8484
## User Commands

.claude/skills/team-arch-opt/roles/coordinator/commands/monitor.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ Find ready tasks, spawn workers, STOP.
8282
2. No ready + work in progress -> report waiting, STOP
8383
3. No ready + nothing in progress -> handleComplete
8484
4. Has ready -> for each:
85-
a. Check if inner loop role with active worker -> skip (worker picks up)
85+
a. Check inner_loop: parse task description `InnerLoop:` field (NOT role.md default)
86+
- InnerLoop: true AND same-role worker already active -> skip (worker picks up)
87+
- InnerLoop: false OR no active same-role worker -> spawn new worker
8688
b. TaskUpdate -> in_progress
8789
c. team_msg log -> task_unblocked
8890
d. Spawn team-worker (see SKILL.md Spawn Template):

.claude/skills/team-arch-opt/roles/refactorer/role.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
---
22
role: refactorer
33
prefix: REFACTOR
4-
inner_loop: true
4+
inner_loop: dynamic
55
message_types: [state_update]
66
---
77

88
# Code Refactorer
99

10+
> **inner_loop: dynamic** — Dispatch sets per-task: `true` for single mode (one REFACTOR task with iterative fix cycles), `false` for fan-out/independent modes (REFACTOR-B01..N run as separate parallel workers). When false, each branch gets its own worker.
11+
1012
Implement architecture refactoring changes following the design plan. For FIX tasks, apply targeted corrections based on review/validation feedback.
1113

1214
## Modes

.claude/skills/team-arch-opt/specs/team-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@
6464
"type": "code_generation",
6565
"description": "Implements architecture refactoring changes following the design plan",
6666
"role_spec": "roles/refactorer/role.md",
67-
"inner_loop": true,
67+
"inner_loop": "dynamic",
6868
"frontmatter": {
6969
"prefix": "REFACTOR",
70-
"inner_loop": true,
70+
"inner_loop": "dynamic",
7171
"additional_prefixes": ["FIX"],
7272
"discuss_rounds": [],
7373
"cli_tools": ["explore"],

.claude/skills/team-coordinate/SKILL.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ Execute built-in Phase 1 (task discovery) -> role-spec Phase 2-4 -> built-in Pha
130130
})
131131
```
132132

133-
**Inner Loop roles** (role has 2+ serial same-prefix tasks): Set `inner_loop: true`. The team-worker agent handles the loop internally.
134-
135-
**Single-task roles**: Set `inner_loop: false`.
133+
**Inner Loop**: Determined per-task from task description `InnerLoop:` field, not per-role:
134+
- Serial chain (2+ tasks, each blockedBy previous): `inner_loop: true` — single worker loops
135+
- Parallel tasks (no mutual blockedBy): `inner_loop: false` — separate workers per task
136+
- Single-task roles: `inner_loop: false`
136137

137138
---
138139

.claude/skills/team-coordinate/roles/coordinator/commands/analyze-task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ For each role, determine frontmatter and generation hints:
130130
| Field | Derivation |
131131
|-------|------------|
132132
| `prefix` | From capability prefix (e.g., RESEARCH, DRAFT, IMPL) |
133-
| `inner_loop` | `true` if role has 2+ serial same-prefix tasks |
133+
| `inner_loop` | `true` if role has 2+ same-prefix tasks AND they form a serial chain (each blockedBy the previous). `false` if tasks are parallel (no mutual blockedBy) or role has only 1 task |
134134
| `CLI tools` | Suggested, not mandatory — coordinator may adjust based on task needs |
135135
| `pattern_hint` | Reference pattern name from role-spec-template (research/document/code/analysis/validation) — guides coordinator's Phase 2-4 composition, NOT a rigid template selector |
136136
| `output_type` | `artifact` (new files in session/artifacts/) / `codebase` (modify existing project files) / `mixed` (both) — determines verification strategy in Behavioral Traits |

.claude/skills/team-coordinate/roles/coordinator/commands/dispatch.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ RoleSpec: <session-folder>/role-specs/<role-name>.md
9595

9696
| Condition | InnerLoop |
9797
|-----------|-----------|
98-
| Role has 2+ serial same-prefix tasks | true |
98+
| Role has 2+ same-prefix tasks forming a serial chain (each blockedBy the previous) | true |
9999
| Role has 1 task | false |
100-
| Tasks are parallel (no dependency between them) | false |
100+
| Role has 2+ same-prefix tasks but they are parallel (no mutual blockedBy) | false |
101+
| Mixed: some serial, some parallel within same role | Set per-task: true for serial chain members, false for parallel members |
101102

102103
### Dependency Validation
103104

.claude/skills/team-coordinate/roles/coordinator/commands/monitor.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ Ready tasks found?
144144
+- NONE + work in progress -> report waiting -> STOP
145145
+- NONE + nothing in progress -> PIPELINE_COMPLETE -> handleComplete
146146
+- HAS ready tasks -> for each:
147-
+- Is task owner an Inner Loop role AND that role already has an active_worker?
147+
+- Parse task description `InnerLoop:` field (NOT session.roles[].inner_loop)
148+
+- InnerLoop: true AND same-role worker already in active_workers?
148149
| +- YES -> SKIP spawn (existing worker will pick it up via inner loop)
149-
| +- NO -> normal spawn below
150+
| +- NO -> normal spawn below (InnerLoop: false OR no active same-role worker)
150151
+- TaskUpdate -> in_progress
151152
+- team_msg log -> task_unblocked (session_id=<session-id>)
152153
+- Spawn team-worker (see spawn tool call below)

.claude/skills/team-coordinate/roles/coordinator/role.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,9 @@ Regardless of complexity score or role count, coordinator MUST:
207207
- `project_root` = result of `Bash({ command: "pwd" })`
208208
- `skill_root` = `<project_root>/.claude/skills/team-coordinate`
209209

210-
2. **Check `needs_research` flag** from task-analysis.json:
211-
- If `true`: **Spawn researcher worker first** to gather codebase context
212-
- Wait for researcher callback
213-
- Merge research findings into task context
214-
- Update task-analysis.json with enriched context
210+
2. **Generate session ID**: `TC-<slug>-<date>` (slug from first 3 meaningful words of task)
215211

216-
3. **Generate session ID**: `TC-<slug>-<date>` (slug from first 3 meaningful words of task)
217-
218-
4. **Create session folder structure**:
212+
3. **Create session folder structure**:
219213
```
220214
.workflow/.team/<session-id>/
221215
+-- role-specs/
@@ -226,11 +220,11 @@ Regardless of complexity score or role count, coordinator MUST:
226220
+-- .msg/
227221
```
228222

229-
5. **Call TeamCreate** with team name derived from session ID
223+
4. **Call TeamCreate** with team name derived from session ID
230224

231-
6. **Read `specs/role-spec-template.md`** for Behavioral Traits + Reference Patterns
225+
5. **Read `specs/role-spec-template.md`** for Behavioral Traits + Reference Patterns
232226

233-
7. **For each role in task-analysis.json#roles**:
227+
6. **For each role in task-analysis.json#roles**:
234228
- Fill YAML frontmatter: role, prefix, inner_loop, additional_members, message_types
235229
- **Compose Phase 2-4 content** (NOT copy from template):
236230
- Phase 2: Derive input sources and context loading steps from **task description + upstream dependencies**
@@ -239,14 +233,14 @@ Regardless of complexity score or role count, coordinator MUST:
239233
- Reference Patterns may guide phase structure, but task description determines specific content
240234
- Write generated role-spec to `<session>/role-specs/<role-name>.md`
241235

242-
8. **Register roles** in team-session.json#roles (with `role_spec` path instead of `role_file`)
236+
7. **Register roles** in team-session.json#roles (with `role_spec` path instead of `role_file`)
243237

244-
9. **Initialize shared infrastructure**:
238+
8. **Initialize shared infrastructure**:
245239
- `wisdom/learnings.md`, `wisdom/decisions.md`, `wisdom/issues.md` (empty with headers)
246240
- `explorations/cache-index.json` (`{ "entries": [] }`)
247241
- `discussions/` (empty directory)
248242

249-
10. **Initialize pipeline metadata** via team_msg:
243+
9. **Initialize pipeline metadata** via team_msg:
250244
```typescript
251245
// 使用 team_msg 将 pipeline 元数据写入 .msg/meta.json
252246
// 注意: 此处为动态角色,执行时需将 <placeholders> 替换为 task-analysis.json 中生成的实际角色列表
@@ -265,7 +259,14 @@ mcp__ccw-tools__team_msg({
265259
})
266260
```
267261

268-
11. **Write team-session.json** with: session_id, task_description, status="active", roles, pipeline (empty), active_workers=[], completion_action="interactive", created_at
262+
10. **Write team-session.json** with: session_id, task_description, status="active", roles, pipeline (empty), active_workers=[], completion_action="interactive", created_at
263+
264+
11. **Check `needs_research` flag** from task-analysis.json:
265+
- If `true`: Spawn researcher worker (role-spec now exists from step 6) to gather codebase context
266+
- Wait for researcher callback
267+
- Merge research findings into task context
268+
- Update task-analysis.json with enriched context
269+
- If `false`: Skip, proceed to Phase 3
269270

270271
**Success**: Session created, role-spec files generated, shared infrastructure initialized.
271272

.claude/skills/team-coordinate/specs/pipelines.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,20 @@ Phase 3-N: monitor.md
3838

3939
## Dependency Graph Structure
4040

41-
task-analysis.json encodes the pipeline:
41+
task-analysis.json encodes the pipeline as adjacency list (task ID -> blockedBy array):
4242

4343
```json
4444
{
4545
"dependency_graph": {
46-
"RESEARCH-001": { "role": "researcher", "blockedBy": [], "priority": "P0" },
47-
"IMPL-001": { "role": "developer", "blockedBy": ["RESEARCH-001"], "priority": "P1" },
48-
"TEST-001": { "role": "tester", "blockedBy": ["IMPL-001"], "priority": "P2" }
46+
"RESEARCH-001": [],
47+
"IMPL-001": ["RESEARCH-001"],
48+
"TEST-001": ["IMPL-001"]
4949
}
5050
}
5151
```
5252

53+
Role mapping comes from `task-analysis.json#capabilities[].tasks[]`, not from the dependency graph itself.
54+
5355
## Role-Worker Map
5456

5557
Dynamic — loaded from session role-specs at runtime:
@@ -64,6 +66,7 @@ Role-spec files contain YAML frontmatter:
6466
role: <role-name>
6567
prefix: <PREFIX>
6668
inner_loop: <true|false>
69+
output_tag: "[<role-name>]"
6770
message_types:
6871
success: <type>
6972
error: error

0 commit comments

Comments
 (0)