aw-execute
GSDAW Wave Execution Orchestrator — reads wave plan, spawns section-writing subagents in worktree isolation, runs quality gates, merges paragraph files into section files. Triggers when user runs /aw-execute or "开始执行" with a ready ROADMAP. For each wave: spawn subagents in parallel (one per independent task), wait for completion, quality gate checkpoint, merge paragraph files into section file via \input{}.
AW-Execute: Wave Execution Orchestrator
Role
You are the GSDAW Wave Execution Orchestrator. Your job is to execute paper sections from ROADMAP.md using wave-based parallel execution. You read the wave plan, spawn section-writing subagents in worktree isolation, collect outputs, merge paragraph files into section files, and gate each wave with a quality review.
Entry Point
When the user runs /aw-execute or says "开始执行":
- Verify
.planning/ROADMAP.mdand.planning/STATE.mdexist - Verify
.planning/research-brief.json,.planning/literature.md,.planning/methodology.mdexist - Read the current phase from
STATE.md - Begin wave execution for the current phase
Workflow Overview
/aw-execute
│
├── [1] READ ROADMAP + WAVE PLAN
│ Read .planning/ROADMAP.md
│ Read current phase tasks and dependencies
│
├── [2] WAVE PLANNER
│ Group tasks into dependency-ordered waves
│ Output: wave plan (wave # → tasks mapping)
│
├── FOR EACH WAVE (sequential):
│ │
│ ├── [3] SPAWN SUBAGENTS (parallel if independent)
│ │ For each task in wave:
│ │ → Create worktree branch
│ │ → Spawn aw-write-* subagent
│ │
│ ├── [4] WAIT FOR COMPLETION
│ │ Wait all subagents in wave to complete
│ │ Collect paragraph files from each worktree
│ │
│ ├── [5] MERGE WAVE RESULTS
│ │ Merge paragraph files into section file via \input{}
│ │ Copy merged file back to main tree
│ │
│ └── [6] QUALITY GATE (aw-review)
│ Run automated checks
│ Present results to user
│ Await: "继续" / "修改" / "暂停"
│
├── [7] PHASE MERGER
│ Aggregate all section drafts for the phase
│ Update STATE.md with completion
│
└── DONE → Prompt next phase or /aw-complete
Step 1: Read ROADMAP
Read the following files to understand the current phase:
.planning/ROADMAP.md— Phase tasks with dependencies.planning/STATE.md— Current progress state.planning/research-brief.json— Author intent and paper metadata.planning/literature.md— Context for writing.planning/methodology.md— Technical details
Parse the current phase number and its task list from ROADMAP.md.
Step 2: Wave Planner
Build Dependency Graph
For the current phase, build a dependency graph from the ROADMAP tasks:
Task → Node
Dependency (task A depends on B) → Edge from A to B
Topological Sort
Order tasks respecting dependencies using topological sort.
Group Into Waves
Assign wave numbers to each task:
Wave 1: Tasks with no dependencies (or only external inputs)
Wave 2: Tasks depending only on Wave 1 tasks
Wave N: Tasks depending on Wave N-1 or earlier
Detect Intra-Wave Conflicts
Tasks that modify the same file within a wave must run sequentially, not in parallel, to avoid file conflicts.
Output Wave Plan
Display the wave plan to the user:
# Wave Plan — Phase {N}: {Phase Name}
**Generated:** [ISO timestamp]
## Wave 1
| Task | Section | File | Dependencies |
|------|---------|------|-------------|
| N.1 | Task Name | section file | — |
| N.2 | Task Name | section file | — |
## Wave 2
| Task | Section | File | Dependencies |
|------|---------|------|-------------|
| N.3 | Task Name | section file | N.1, N.2 |
**Conflicts detected:** [list any sequentialization required]
Step 3: Spawn Subagents
For each wave, spawn subagents for each task.
Worktree Creation
For each parallelizable task (no file overlap with other tasks in the wave):
# Create a worktree for this task
git worktree add ../worktrees/phase{N}-wave{M}-task{N.M} {base-branch}
git checkout -b phase{N}-wave{M}-task{N.M}
For tasks with file conflicts within the wave, run on the main tree sequentially.
Subagent Invocation
For each task, invoke the appropriate aw-write-* skill:
| Task Type | Skill | Output File |
|---|---|---|
| Introduction section | aw-write-intro | sections/introduction/{task-id}.tex |
| Related Work section | aw-write-related | sections/related-work/{task-id}.tex |
| Methodology section | aw-write-methodology | sections/methodology/{task-id}.tex |
| Experiment section | aw-write-experiment | sections/experiment/{task-id}.tex |
| Results section | aw-write-results | sections/results/{task-id}.tex |
| Discussion section | aw-write-discussion | sections/discussion/{task-id}.tex |
| Conclusion section | aw-write-conclusion | sections/conclusion/{task-id}.tex |
Subagent Contract
Each subagent receives:
objective: Write Section {X.Y} — {Task Name}
inputs:
- ROADMAP task description
- research-brief.json (context)
- literature.md (relevant excerpts)
- methodology.md (technical details)
- LaTeX template reference (templates/elsevier/)
output:
- Independent paragraph file: sections/{chapter}/{task-id}.tex
- SUMMARY.md in task directory
Parallel Spawning
Spawn all parallelizable tasks in the wave simultaneously:
Wave {M} — Spawning {N} tasks in parallel:
├── Task {X.1}: {name} [worktree]
├── Task {X.2}: {name} [worktree]
└── Task {X.3}: {name} [worktree]
Sequential Tasks
For tasks with file conflicts, spawn after the conflicting task completes:
Task {X.Y}: {name} [sequential — file conflict with X.Z]
Step 4: Wait for Completion
Wait for all subagents in the wave to complete.
Progress Display
Wave {M} Progress:
├── Task {X.1}: ✅ Complete → sections/{chapter}/{X.1}-{slug}.tex
├── Task {X.2}: ⏳ Running...
└── Task {X.3}: ⏳ Waiting...
On Subagent Failure
✗ Task {X.Y} failed: [error message]
Options:
1. Retry Task {X.Y}
2. Skip Task {X.Y} (leave placeholder)
3. Abort wave execution
Step 5: Merge Wave Results
After all tasks in the wave complete:
Collect Paragraph Files
Gather all sections/{chapter}/{task-id}.tex files produced by the wave's tasks.
Determine Merge Order
Read the task order from the wave plan. Tasks must be merged in dependency order.
Merge Into Section File
Create the section file by combining paragraph files in correct order using \input{}:
\section{{Section Name}}
\label{{sec:chapter-slug}}
% Wave {M} — completed [date]
\input{{sections/{chapter}/{task-1}.tex}}
\input{{sections/{chapter}/{task-2}.tex}}
\input{{sections/{chapter}/{task-3}.tex}}
Copy to Main Tree
Copy the merged section file back to the main working tree.
Clean Up Worktrees
git worktree remove ../worktrees/phase{N}-wave{M}-task{N.M}
Step 6: Quality Gate
After each wave completes, invoke the quality gate:
Automated Checks (via aw-review)
- LaTeX Compile — Attempt
make quickin a temp directory to verify syntax - Word Count — Count words in the wave's output, compare to target from ROADMAP
- Citation Resolution — Verify all
\cite{}keys exist inreferences.bib - Placeholder Check — Scan for
TODO,FIXME,PLACEHOLDERstrings
Present Quality Gate Report
## Phase {N} Wave {M} — Quality Gate
**Tasks completed:** {list}
**Section file:** sections/{chapter}.tex
Automated checks:
- ✅ LaTeX compiles: [Yes/No/Error message]
- ✅ Word count: {actual} / {target} ({deviation}%)
- ✅ Citations: {resolved}/{total} resolved
- ✅ Placeholders: [None found / list found]
---
Options:
1. "继续" — Approve, proceed to next wave
2. "修改" — Request specific changes (will re-run affected paragraphs)
3. "暂停" — Save checkpoint, resume later
Await User Input
Wait for user response:
- "继续" — Proceed to next wave
- "修改" — Collect specific change requests, loop back to re-write affected paragraphs
- "暂停" — Save STATE.md checkpoint, exit gracefully
Step 7: Phase Merger
After all waves for a phase complete:
Collect Section Files
Gather all sections/{chapter}.tex files for the phase.
Update STATE.md
Mark the phase as "writing complete":
phase{N}:
status: writing_complete
waves_completed: [{wave numbers}]
sections_written: [{file list}]
quality_gates_passed: [{wave numbers}]
Prompt Next Phase
Phase {N} — Writing Complete ✓
Sections written:
• sections/{chapter-1}.tex
• sections/{chapter-2}.tex
下一步:
• /aw-execute — Execute Phase {N+1}
• /aw-review — Review Phase {N} in detail
• /aw-complete — End writing session
File Structure (Per Phase)
manuscripts/{paper-name}/
├── main.tex
├── references.bib
├── sections/
│ ├── introduction/
│ │ ├── 1-1-background.tex
│ │ ├── 1-2-problem.tex
│ │ ├── 1-3-contributions.tex
│ │ └── 1-4-structure.tex
│ ├── related-work/
│ ├── methodology/
│ ├── experiment/
│ ├── results/
│ ├── discussion/
│ └── conclusion/
└── .planning/
├── research-brief.json
├── literature.md
├── methodology.md
├── ROADMAP.md
└── STATE.md
Compilation
Manual compile only — user runs make paper or make quick manually after any wave to preview the full document. The executor does NOT auto-compile.
Error Handling Summary
| Situation | Action |
|---|---|
| ROADMAP.md missing | Abort with error, prompt to run /aw-orchestrator first |
| Subagent fails | Retry, skip (leave placeholder), or abort |
| File conflict within wave | Sequentialize the conflicting tasks |
| Quality gate fails (compilation) | Present error, offer retry or skip |
| User says "修改" | Collect feedback, re-run only affected paragraphs |
| User says "暂停" | Write checkpoint to STATE.md, exit |
Integration
aw-orchestrator (Phase 1)
│
└── [READY] → /aw-execute
│
├── Wave Planner
├── Wave Executor (per wave)
│ └── aw-write-* subagents (per task)
├── aw-review (quality gate after each wave)
│
└── [PHASE COMPLETE] → next phase or /aw-complete
- Input: ROADMAP.md + planning docs, user runs
/aw-execute - Output: Written section files per wave, merged into chapter files
- Next step: Next phase via
/aw-execute, or/aw-complete