fix(skills): replace polling/pre-spawning with Stop-Wait pattern across all team coordinators

All team coordinator roles now follow the Stop-Wait design principle:
- Phase 2: Remove worker pre-spawning, workers are spawned per-stage in Phase 4
- Phase 4: Add Stop-Wait principle note (synchronous Task calls instead of polling)
- monitor.md: Replace while+sleep polling loops with synchronous Task execution

Teams updated: team-brainstorm, team-frontend, team-issue, team-iterdev,
team-lifecycle, team-lifecycle-v2, team-quality-assurance, team-tech-debt,
team-testing, team-uidesign, team-ultra-analyze
This commit is contained in:
catlog22
2026-02-24 00:05:29 +08:00
parent 695045787f
commit e92c6ce0b1
17 changed files with 616 additions and 445 deletions

View File

@@ -188,15 +188,11 @@ if (isResume) {
if (meta) neededRoles.add(meta.owner)
})
// Spawn only needed workers using Phase 2 spawn template (see SKILL.md Coordinator Spawn Template)
// Each worker is spawned with prompt that:
// 1. Identifies their role
// 2. Instructs to call Skill(skill="team-lifecycle", args="--role=<name>")
// 3. Includes session context: taskDescription, sessionFolder, constraints
// 4. Instructs immediate TaskList polling on startup
// Spawn only needed workers using Phase 4 Stop-Wait pattern (see SKILL.md Coordinator Spawn Template)
// Workers are spawned per-stage via Task(run_in_background: false) in Phase 4 coordination loop.
// neededRoles is used to determine which workers will be spawned on-demand.
neededRoles.forEach(role => {
// → Use SKILL.md Coordinator Spawn Template for each role
// → Worker prompt includes: "Session: ${sessionFolder}", "需求: ${taskDescription}"
// → Worker prompt template in SKILL.md (spawned per-stage in Phase 4, not pre-spawned here)
})
// ============================================================
@@ -419,7 +415,7 @@ if (mode === 'impl-only' || mode === 'full-lifecycle') {
}
```
### Phase 2: Create Team + Spawn Workers
### Phase 2: Create Team + Initialize Session
```javascript
TeamCreate({ team_name: teamName })
@@ -462,9 +458,11 @@ const teamSession = {
Write(`${sessionFolder}/team-session.json`, JSON.stringify(teamSession, null, 2))
```
**Conditional spawn based on mode** (see SKILL.md Coordinator Spawn Template for full prompts):
**Workers are NOT pre-spawned here.** Workers are spawned per-stage in Phase 4 via Stop-Wait `Task(run_in_background: false)`. See SKILL.md Coordinator Spawn Template for worker prompt templates.
| Mode | Spawned Workers |
Worker roles by mode (spawned on-demand):
| Mode | Worker Roles |
|------|-----------------|
| spec-only | analyst, writer, discussant, reviewer (4) |
| impl-only | planner, executor, tester, reviewer (4) |
@@ -562,6 +560,13 @@ TaskUpdate({ taskId: planId, owner: "planner", addBlockedBy: [discuss6Id] })
### Phase 4: Coordination Loop
> **设计原则Stop-Wait**: 模型执行没有时间概念,禁止任何形式的轮询等待。
> - ❌ 禁止: `while` 循环 + `sleep` + 检查状态
> - ✅ 采用: 同步 `Task(run_in_background: false)` 调用Worker 返回 = 阶段完成信号
>
> 按 Phase 3 创建的任务链顺序,逐阶段 spawn worker 同步执行。
> Worker prompt 使用 SKILL.md Coordinator Spawn Template。
Receive teammate messages and make dispatch decisions. **Before each decision: `team_msg list` to review recent messages. After each decision: `team_msg log` to record.**
#### Spec Messages