azclaude-copilot 0.5.9 → 0.6.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.
@@ -9,7 +9,7 @@
9
9
  {
10
10
  "name": "azclaude",
11
11
  "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 39 commands, 10 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
12
- "version": "0.5.9",
12
+ "version": "0.6.0",
13
13
  "source": {
14
14
  "source": "github",
15
15
  "repo": "haytamAroui/AZ-CLAUDE-COPILOT",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azclaude",
3
- "version": "0.5.9",
3
+ "version": "0.6.0",
4
4
  "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 39 commands, 10 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
5
5
  "author": {
6
6
  "name": "haytamAroui",
package/README.md CHANGED
@@ -624,11 +624,11 @@ AZCLAUDE is a lazy-loaded environment of 48 capability modules. It only loads wh
624
624
 
625
625
  ## Verified
626
626
 
627
- 1810 tests. Every template, command, capability, agent, hook, and CLI feature verified.
627
+ 1836 tests. Every template, command, capability, agent, hook, and CLI feature verified.
628
628
 
629
629
  ```bash
630
630
  bash tests/test-features.sh
631
- # Results: 1810 passed, 0 failed, 1810 total
631
+ # Results: 1836 passed, 0 failed, 1836 total
632
632
  ```
633
633
 
634
634
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azclaude-copilot",
3
- "version": "0.5.9",
3
+ "version": "0.6.0",
4
4
  "description": "AI coding environment — 39 commands, 10 skills, 15 agents, memory, reflexes, evolution. Install: npx azclaude-copilot@latest, then open Claude Code.",
5
5
  "bin": {
6
6
  "azclaude": "bin/cli.js",
@@ -55,23 +55,51 @@ Follow the Resume Protocol from `capabilities/shared/parallel-coordination.md`:
55
55
 
56
56
  ---
57
57
 
58
- ### Step 2: Select Next Milestone Wave
58
+ ### Step 2: Select Next Milestones (DAG Dispatch)
59
+
60
+ **DAG readiness check** — a milestone is **ready** when:
61
+ 1. `status = pending` in plan.md
62
+ 2. ALL milestones listed in its `Depends:` field have `status = done`
63
+
64
+ That's it. Ignore `Wave:` fields for dispatch decisions — they are informational (for visualization and estimation only). The dependency graph is the truth.
59
65
 
60
- **If plan.md has `Wave:` fields** (blueprint wrote them — read directly):
61
66
  ```bash
62
- grep "Wave:" .claude/plan.md
67
+ # Find all ready milestones
68
+ grep -B2 "Status: pending" .claude/plan.md | grep "^## M"
69
+ # For each, check its Depends: are all done
70
+ ```
71
+
72
+ **Step 2a: Foundation Detection (auto-Wave 0)**
73
+
74
+ Before dispatching any parallel agents, scan ALL ready milestones' Team Specs for shared files:
75
+
63
76
  ```
64
- Find the lowest wave number where all milestones have `status = pending` and all `Depends:` are `done`.
65
- This is the next wave to dispatch.
77
+ For each pair (A, B) in ready milestones:
78
+ shared_files = Files Written(A) Files Written(B)
79
+ If shared_files is not empty:
80
+ → Extract shared file edits into a FOUNDATION milestone
81
+ → Dispatch foundation sequentially FIRST
82
+ → Remove shared-file edits from A and B's scope
83
+ → Re-check readiness after foundation completes
84
+ ```
85
+
86
+ If no shared files → skip foundation, go directly to parallel dispatch.
87
+
88
+ **Step 2b: Parallel safety check**
66
89
 
67
- **If plan.md has NO `Wave:` fields** (older plan formatcompute from scratch):
68
- Find milestones where `status = pending` AND all dependencies have `status = done`.
90
+ From the ready set (after foundation), verify `Files Written` from problem-architect for each pair don't overlap. `Files Written` is more precise than `Files:` use it.
91
+ If any two candidates share a written file dispatch the conflicting one sequentially after the other.
69
92
 
70
- **Parallel candidates:** milestones in the same wave with `Parallel: yes` (or computed as independent).
93
+ **Step 2c: Classify milestones**
71
94
 
72
- **REQUIRED parallel safety check:** Even if `Parallel: yes`, verify `Files Written` from problem-architect
73
- for each candidate don't overlap. `Files Written` is more precise than `Files:` — use it.
74
- If any two candidates share a written file dispatch sequentially. Silent file corruption otherwise.
95
+ | Type | Definition | Dispatch rule |
96
+ |------|-----------|---------------|
97
+ | Foundation | Touches files needed by 2+ milestones | Sequential, before all others |
98
+ | Test-only | Creates new test files, never writes production code | Safe alongside ANY milestone |
99
+ | Standard | Writes to unique files | Parallel with worktree isolation |
100
+
101
+ **Max parallel agents:** 6 (default). Override with `max_parallel` in plan.md frontmatter.
102
+ If ready milestones exceed max_parallel → dispatch highest-priority first, queue the rest.
75
103
 
76
104
  - All done → SHIP
77
105
  - All remaining blocked → BLOCKER RECOVERY
@@ -123,16 +151,19 @@ If verdict is `APPROVED` or `APPROVED (no constitution found)`: proceed to Step
123
151
 
124
152
  ### Step 4: Dispatch Milestone Builder(s)
125
153
 
126
- **Parallel dispatch (2+ milestones in wave with disjoint Files Written):**
154
+ **Parallel dispatch (2+ ready milestones with disjoint Files Written):**
127
155
 
128
156
  Load `capabilities/shared/parallel-coordination.md` first.
129
157
  Load `capabilities/shared/context-inoculation.md` and prepend its Required Preamble to every agent prompt below.
130
158
 
131
- 1. Write `.claude/ownership.md` table (branch, directories, status) for every agent in this wave
132
- 2. Spawn each builder via Task with `isolation: "worktree"` in the same message (true parallel)
133
- 3. Include worktree rules in every parallel prompt (see parallel-coordination.md Step 3)
134
- 4. Wait for ALL agents in the wave before merging
135
- 5. Merge branches sequentially (simplest milestone first) following the Merge Protocol
159
+ 1. Write `.claude/ownership.md` table (branch, directories, status) for every agent in this batch
160
+ 2. Write `.claude/parallel-wave-state.md` with `dispatch_mode: dag` (see parallel-coordination.md)
161
+ 3. **Pre-read shared files** (models, schemas, configs referenced by 2+ agents) and inject their content inline into each agent's prompt eliminates redundant file reads across agents
162
+ 4. Spawn each builder via Task with `isolation: "worktree"` in the same message (true parallel)
163
+ 5. Include worktree rules + **test scope** (`Test scope: {test-dir}`) in every parallel prompt
164
+ 6. **Merge-on-complete**: as each agent reports done, merge its branch immediately (don't wait for all)
165
+ 7. After each merge: check if newly-unblocked milestones exist → dispatch them immediately
166
+ 8. If `max_parallel <= 3` or merge conflicts detected: fall back to batch-merge (wait for all, then merge)
136
167
 
137
168
  **Sequential dispatch (single milestone OR overlapping files):**
138
169
 
@@ -173,13 +204,18 @@ Dependent milestones, overlapping `Files Written`, or `Parallel Safe: NO` → sp
173
204
 
174
205
  ---
175
206
 
176
- ### Step 5: Monitor Results
207
+ ### Step 5: Monitor Results + Merge-on-Complete
208
+
209
+ **When an agent reports PASS (parallel mode):**
210
+ 1. Merge its branch to main immediately: `git merge parallel/{slug} --no-ff`
211
+ 2. Run tests for the merged module: `{test command} tests/{agent-scope}/ 2>&1 | tail -10`
212
+ 3. If tests pass → update plan.md status → `done`, update `.claude/parallel-wave-state.md`
213
+ 4. **Check DAG for newly-unblocked milestones** — any milestone whose `Depends:` are now ALL `done` becomes ready. Dispatch it immediately (back to Step 3 → Step 4).
214
+ 5. New pattern emerged? → append to patterns.md
177
215
 
178
- **PASS:**
216
+ **When an agent reports PASS (sequential mode):**
179
217
  - Approve commit
180
218
  - Update plan.md status → `done`
181
- - New pattern emerged? → append to patterns.md
182
- - Compromise made? → append to antipatterns.md
183
219
 
184
220
  **FAIL — attempt 1:**
185
221
  - Read exact error
@@ -190,6 +226,11 @@ Dependent milestones, overlapping `Files Written`, or `Parallel Safe: NO` → sp
190
226
  - Log to blockers.md with full context
191
227
  - Set plan.md status → `blocked`
192
228
  - Move to next milestone
229
+ - In parallel mode: do NOT block other agents — continue merging completed branches
230
+
231
+ **Merge conflict during merge-on-complete:**
232
+ - Read both versions, apply correct merge (keep both feature additions)
233
+ - If unresolvable: fall back to batch-merge for remaining agents in this dispatch
193
234
 
194
235
  ---
195
236
 
@@ -40,26 +40,35 @@ Rules:
40
40
 
41
41
  ---
42
42
 
43
- ## Dispatch Protocol (Orchestrator)
43
+ ## Dispatch Protocol (DAG-Based)
44
44
 
45
- ### Step 1: Confirm Parallel Safety
45
+ ### Step 1: Build Dependency Graph + Confirm Parallel Safety
46
46
 
47
- Before spawning any parallel agents for a wave, verify from problem-architect Team Specs:
47
+ Parse `plan.md` into a DAG. A milestone is **ready** when all its `Depends:` have `status = done`.
48
+
49
+ Before spawning any parallel agents, verify from problem-architect Team Specs:
48
50
 
49
51
  ```
50
- For each pair (A, B) in the wave:
52
+ For each pair (A, B) in ready milestones:
51
53
  - Files Written(A) ∩ Files Written(B) = empty set? → safe
52
54
  - Parent directories of A and B do not overlap? → safe
53
55
  - No shared schema/config files (prisma.schema, package.json, tsconfig)? → safe
54
56
  - No runtime dependency (A's output is B's input)? → safe
55
57
 
56
- If any check fails → remove the conflicting milestone from the wave, dispatch sequentially
58
+ If any check fails → remove the conflicting milestone from parallel batch, dispatch sequentially after
57
59
  ```
58
60
 
59
61
  ### Step 2: Write Ownership Map
60
62
 
61
63
  Write `.claude/ownership.md` before spawning any agents.
62
64
 
65
+ ### Step 2b: Foundation Detection (Auto-Wave 0)
66
+
67
+ Scan all ready milestones for shared-file bottlenecks:
68
+ - If 2+ milestones need to write the same file → extract those changes into a foundation milestone
69
+ - Dispatch foundation sequentially FIRST, before any parallel agents
70
+ - After foundation completes: re-check readiness (more milestones may now be ready)
71
+
63
72
  ### Step 3: Dispatch with Worktree Isolation
64
73
 
65
74
  Spawn each agent via Task with `isolation: "worktree"`:
@@ -69,9 +78,13 @@ Task: Implement Milestone {N} — {title}
69
78
 
70
79
  [worktree mode]
71
80
  Branch: parallel/{milestone-slug}
81
+ Test scope: {test-dir} — run ONLY these tests, not the full suite
72
82
  Do NOT push to origin. Commit locally only.
73
83
  Report branch name in completion message.
74
84
 
85
+ ## Pre-loaded Context (do NOT re-read these files)
86
+ {orchestrator pre-reads shared files and injects content here}
87
+
75
88
  {standard milestone context from orchestrator Step 4}
76
89
  ```
77
90
 
@@ -79,50 +92,74 @@ Include in every parallel dispatch:
79
92
  ```
80
93
  Worktree rules:
81
94
  - You are in an isolated git worktree on branch: parallel/{slug}
82
- - Run all tests they test YOUR changes in isolation only
95
+ - Run ONLY tests in your Test scope not the full suite
83
96
  - If you see errors in files outside your owned directories: STOP, report to orchestrator
84
97
  - Do NOT run git push — commit locally only
85
98
  - Your completion message MUST include: "Branch: parallel/{slug}" for merge tracking
86
99
  ```
87
100
 
88
- ### Step 4: Wait for All Agents in the Wave
101
+ **Max parallel agents:** 6 (default). Test-only milestones do NOT count toward the limit.
102
+
103
+ ### Step 4: Merge-on-Complete (Default) or Batch-Merge (Fallback)
104
+
105
+ **Merge-on-complete (default when max_parallel > 3):**
106
+ As each agent reports `COMPLETE`, merge immediately:
107
+ 1. `git checkout main && git merge parallel/{slug} --no-ff -m "merge: M{N} {title} [dag]"`
108
+ 2. Run scoped tests: `{test command} tests/{scope}/ 2>&1 | tail -10`
109
+ 3. Update plan.md status → `done`, update DAG state file
110
+ 4. **Check DAG for newly-unblocked milestones** → dispatch them immediately (back to Step 1)
111
+ 5. Clean up branch: `git branch -d parallel/{slug}`
112
+
113
+ **Batch-merge fallback (max_parallel <= 3 OR merge conflict detected):**
114
+ Wait for ALL dispatched agents to complete, then merge sequentially (simplest first).
89
115
 
90
- Do NOT start the merge until ALL parallel agents in this wave have reported:
91
- - `COMPLETE` proceed with merge
92
- - `FAILED` merge all completed branches first, then handle the failure as a blocked milestone
116
+ When agent reports `FAILED`:
117
+ - Do NOT block other agents — continue merging completed branches
118
+ - Log failure to blockers.md, set plan.md status `blocked`
93
119
 
94
120
  ---
95
121
 
96
122
  ## Merge Protocol (Orchestrator)
97
123
 
98
- After all parallel agents report done, merge sequentially:
124
+ Two modes, selected automatically based on `max_parallel` and conflict state:
125
+
126
+ ### Mode A: Merge-on-Complete (default, max_parallel > 3)
127
+
128
+ Each agent's branch is merged as soon as it completes — no waiting for others:
99
129
 
100
130
  ```bash
101
- # Step 1: Return to main branch
102
- git checkout main # or master / development
131
+ # Agent M3 reports COMPLETE:
132
+ git checkout main
133
+ git merge parallel/m3-auth --no-ff -m "merge: M3 auth endpoints [dag]"
134
+ {test command} tests/auth/ 2>&1 | tail -10 # scoped test only
135
+ git branch -d parallel/m3-auth
136
+
137
+ # Check DAG: M5 depends on M3 → M5 is now ready → dispatch M5 immediately
138
+ # Meanwhile M4 is still running in its worktree — no interference
139
+ ```
103
140
 
104
- # Step 2: Merge each branch in completion order
105
- git merge parallel/m3-auth --no-ff -m "merge: M3 auth endpoints [parallel wave N]"
106
- git merge parallel/m4-profile --no-ff -m "merge: M4 user profile [parallel wave N]"
141
+ **After all agents in batch complete:** run full test suite once on merged main.
142
+ If full suite passes `git push origin main`.
107
143
 
108
- # Step 3: If merge conflict on step N:
109
- # - Identify which files conflict
110
- # - Read both versions
111
- # - Apply the correct merge (usually: keep both feature additions, not one-or-other)
112
- # - Mark conflict resolved, continue with remaining branches
144
+ ### Mode B: Batch-Merge (fallback, max_parallel <= 3 or conflict detected)
113
145
 
114
- # Step 4: Run full test suite on merged main
115
- npm test 2>&1 | tail -20
146
+ Wait for ALL dispatched agents, then merge sequentially:
116
147
 
117
- # Step 5: If tests pass → push
148
+ ```bash
149
+ git checkout main
150
+ git merge parallel/m3-auth --no-ff -m "merge: M3 auth endpoints [dag]"
151
+ git merge parallel/m4-profile --no-ff -m "merge: M4 user profile [dag]"
152
+ {test command} 2>&1 | tail -20 # full suite after all merges
118
153
  git push origin main
119
-
120
- # Step 6: Clean up worktree branches
121
- git branch -d parallel/m3-auth parallel/m4-profile parallel/m5-email
154
+ git branch -d parallel/m3-auth parallel/m4-profile
122
155
  ```
123
156
 
124
- **Merge order matters**: merge the branch with the fewest cross-dependencies first.
125
- When uncertain: sort by `Estimated Complexity` ascending (simpler merges first).
157
+ ### Merge Rules (both modes)
158
+
159
+ - **Merge order**: simplest milestone first (sort by `Estimated Complexity` ascending)
160
+ - **If merge conflict**: read both versions, apply correct merge (keep both feature additions)
161
+ - **If conflict is unresolvable**: switch from Mode A to Mode B for remaining branches
162
+ - **If tests fail after merge**: identify which merge broke it → revert that branch → add to blocked
126
163
 
127
164
  ---
128
165
 
@@ -134,7 +171,7 @@ These rules are injected by orchestrator into every parallel milestone-builder p
134
171
 
135
172
  2. **Never push** — commit locally on your worktree branch. Do not run `git push`.
136
173
 
137
- 3. **Test in isolation** — your test run should only test what you changed. If the test suite has cross-cutting failures, filter to your files: `pytest tests/auth/ -v` not `pytest .`
174
+ 3. **Test in isolation** — run ONLY the tests in your `Test scope` (injected by orchestrator). Example: `pytest tests/auth/ -v` not `pytest .`. Cross-cutting failures are expected from other agents' work.
138
175
 
139
176
  4. **Errors outside your files = not your problem** — if you see compilation errors or test failures in files you didn't modify, that's a parallel agent's in-progress state. Report to orchestrator: "Test failures in {file} — outside my scope, may be parallel agent interference."
140
177
 
@@ -240,17 +277,18 @@ During parallel execution, the orchestrator writes `.claude/parallel-wave-state.
240
277
 
241
278
  ```markdown
242
279
  ---
243
- wave: {N}
280
+ dispatch_mode: dag
244
281
  started: {ISO timestamp}
245
282
  status: in-flight
283
+ max_parallel: 6
246
284
  milestones: [M3, M4, M5]
247
285
  ---
248
286
 
249
- | Milestone | Branch | Status | Commit | Notes |
250
- |-----------|--------|--------|--------|-------|
251
- | M3 — Auth endpoints | parallel/m3-auth | running | — | P1 slot |
252
- | M4 — User profile | parallel/m4-profile | done | a1b2c3d | merged to worktree |
253
- | M5 — Email service | parallel/m5-email | failed | — | timeout on test suite |
287
+ | Milestone | Branch | Status | Commit | Depends | Unblocks |
288
+ |-----------|--------|--------|--------|---------|----------|
289
+ | M3 — Auth endpoints | parallel/m3-auth | running | — | [M0] | [M5, M6] |
290
+ | M4 — User profile | parallel/m4-profile | done | a1b2c3d | [M0] | [] |
291
+ | M5 — Email service | parallel/m5-email | failed | — | [M3] | [M7] |
254
292
  ```
255
293
 
256
294
  ### Lifecycle
@@ -229,7 +229,7 @@ runs after plan.md is written and handles the cases Layer 1 misses.
229
229
  - Dirs: top-level directories this milestone exclusively owns
230
230
  - Parallel: yes — safe at directory level + no shared utility writes
231
231
  - Parallel: no — touches shared config, shared utility, schema, or depends on sibling
232
- - Wave: {N}
232
+ - Wave: {N} (informational — orchestrator uses Depends: for dispatch, not Wave:)
233
233
  ```
234
234
 
235
235
  A well-designed plan for a 6-feature product:
@@ -115,7 +115,9 @@ This file survives context compaction. If the session dies mid-wave, the next se
115
115
 
116
116
  ---
117
117
 
118
- ## Step 5: Dispatch All Agents Simultaneously
118
+ ## Step 5: Dispatch All Agents Simultaneously (DAG Mode)
119
+
120
+ **Pre-read shared files** — read files referenced by 2+ agents (models, schemas, configs) and inject their content into each agent's prompt. This eliminates redundant file reads across agents.
119
121
 
120
122
  Spawn all milestone-builder agents **in a single message** (true parallel — one Task call per agent in the same response):
121
123
 
@@ -124,56 +126,60 @@ For each milestone, Task with `isolation: "worktree"`:
124
126
  ```
125
127
  Task: Implement Milestone {N} — {title}
126
128
 
127
- [PARALLEL MODE — WORKTREE ISOLATED]
129
+ [PARALLEL MODE — WORKTREE ISOLATED — DAG DISPATCH]
128
130
  Branch: parallel/{milestone-slug}
131
+ Test scope: {test-dir} — run ONLY these tests
129
132
 
130
133
  Agent role: {from Team Spec}
131
134
  Directories owned: {from Team Spec}
132
135
 
136
+ ## Pre-loaded Context (do NOT re-read these files)
137
+ {content of shared files injected by orchestrator}
138
+
133
139
  {standard context from orchestrator Step 4}
134
140
 
135
141
  Worktree rules (MANDATORY):
136
142
  - Only write files within your "Directories owned"
137
143
  - DO NOT run git push — commit locally only
144
+ - Run ONLY tests in your Test scope — not the full suite
138
145
  - If you see errors in files outside your directories: STOP, report "scope violation"
139
146
  - End your report with: "Branch: parallel/{slug}"
140
147
  ```
141
148
 
149
+ **Max parallel agents:** 6 (default). Test-only milestones don't count toward the limit.
150
+
142
151
  ---
143
152
 
144
- ## Step 6: Wait and Monitor
153
+ ## Step 6: Merge-on-Complete + Monitor
145
154
 
146
- After all agents complete:
147
- - Collect all completion reports
148
- - Mark each as COMPLETE or FAILED in ownership.md
149
- - **Update `.claude/parallel-wave-state.md`** set each milestone's Status to `done`/`failed`, fill Commit hash
155
+ **Default (DAG mode, max_parallel > 3):** As each agent reports done, merge immediately:
156
+ 1. `git checkout main && git merge parallel/{slug} --no-ff`
157
+ 2. Run scoped tests for the merged module
158
+ 3. Update ownership.md and `.claude/parallel-wave-state.md` (status `done`, fill commit hash)
159
+ 4. **Check DAG for newly-unblocked milestones** → dispatch them immediately (back to Step 3)
150
160
 
151
- ---
161
+ **Fallback (max_parallel <= 3 or merge conflict):** Wait for all, then merge sequentially.
152
162
 
153
- ## Step 7: Merge Sequentially
163
+ Mark FAILED agents as `blocked` in plan.md — do NOT hold up other agents.
154
164
 
155
- Follow the Merge Protocol from `capabilities/shared/parallel-coordination.md`:
165
+ ---
156
166
 
157
- ```bash
158
- git checkout main
167
+ ## Step 7: Final Verification + Push
159
168
 
160
- # Merge branches one at a time (simplest first)
161
- git merge parallel/{slug-1} --no-ff -m "merge: M{N} {title} [parallel wave]"
162
- # Run tests after each merge
163
- {test command} 2>&1 | tail -10
169
+ After all agents in this dispatch have completed and been merged:
164
170
 
165
- git merge parallel/{slug-2} --no-ff -m "merge: M{N} {title} [parallel wave]"
166
- {test command} 2>&1 | tail -10
171
+ ```bash
172
+ # Run full test suite on merged main (covers cross-module interactions)
173
+ {test command} 2>&1 | tail -20
167
174
 
168
- # Push once all merges pass
175
+ # If all pass → push
169
176
  git push origin main
170
177
 
171
- # Cleanup
172
- git branch -d parallel/{slug-1} parallel/{slug-2}
178
+ # Clean up any remaining worktree branches
179
+ git branch -d parallel/{slug-1} parallel/{slug-2} 2>/dev/null
173
180
  ```
174
181
 
175
- **If merge conflict**: read both versions, apply correct merge (keep both feature additions), continue.
176
- **If tests fail after a merge**: identify which merge broke it → revert that branch → add milestone to blocked.
182
+ **If full suite fails**: identify which merge introduced the break revert that branch → add to blocked.
177
183
 
178
184
  ---
179
185
 
@@ -70,12 +70,12 @@ Check file collisions:
70
70
 
71
71
  ---
72
72
 
73
- ## Step 4: Identify Parallel Groups
73
+ ## Step 4: Identify Parallel Groups (DAG Analysis)
74
74
 
75
75
  Tasks with no dependencies between them AND no file collisions can run in parallel.
76
- Group them into "waves":
76
+ Group them into "waves" for visualization (the orchestrator uses the DAG directly, not wave numbers):
77
77
 
78
- **Wave = a set of tasks that can all run simultaneously**
78
+ **Wave = a set of tasks that can all run simultaneously (informational grouping)**
79
79
 
80
80
  Algorithm:
81
81
  1. Wave 1 = tasks with no `Depends:` and status `pending`
@@ -83,6 +83,8 @@ Algorithm:
83
83
  3. Wave N = tasks that only depend on tasks in waves 1 through N-1
84
84
  4. A wave cannot contain tasks that share files
85
85
 
86
+ **DAG dispatch note:** The orchestrator dispatches based on `Depends:` satisfaction, not wave numbers. A task in "Wave 3" may launch as soon as its specific dependencies are done — it does NOT wait for all of Wave 2.
87
+
86
88
  ---
87
89
 
88
90
  ## Step 5: Output the Task Graph
@@ -119,14 +121,15 @@ Total tasks: {N} | Done: {N} | Pending: {N} | Blocked: {N}
119
121
  ```
120
122
  Parallelism Analysis
121
123
  ════════════════════
122
- Max parallel at once: {N tasks in largest wave}
124
+ Max parallel at once: {N tasks in largest wave} (default limit: 6)
123
125
  Critical path length: {N waves minimum to complete}
124
126
  File collision pairs: {N pairs that cannot run simultaneously}
127
+ DAG dispatch mode: merge-on-complete (agents unblock dependents immediately)
125
128
 
126
129
  Suggested dispatch order for /copilot:
127
- 1. Start Wave 1 tasks simultaneously (or sequentially if no orchestrator)
128
- 2. On Wave 1 complete start Wave 2
129
- 3. ...
130
+ 1. Foundation first (shared files: models, schemas) sequential
131
+ 2. Launch all ready tasks simultaneously (DAG readiness, not wave number)
132
+ 3. As each task completes → merge → check for newly-unblocked → dispatch immediately
130
133
  ```
131
134
 
132
135
  ---
@@ -134,10 +137,10 @@ Suggested dispatch order for /copilot:
134
137
  ## Copilot Mode Integration
135
138
 
136
139
  If `.claude/agents/orchestrator.md` exists:
137
- → Note: "The orchestrator will use this graph to dispatch milestone-builder agents in parallel"
140
+ → Note: "The orchestrator uses DAG dispatch each milestone launches when its Depends: are satisfied, with merge-on-complete to unblock dependents immediately"
138
141
 
139
142
  If no orchestrator:
140
- → Note: "Copilot will process waves sequentially — Wave 1 first, then Wave 2, etc."
143
+ → Note: "Copilot will process tasks by wave grouping — Wave 1 first, then Wave 2, etc."
141
144
 
142
145
  ---
143
146