gru-ai 0.1.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.
- package/.claude/skills/brainstorm/SKILL.md +340 -0
- package/.claude/skills/code-review-excellence/SKILL.md +198 -0
- package/.claude/skills/directive/SKILL.md +121 -0
- package/.claude/skills/directive/docs/pipeline/00-delegation-and-triage.md +181 -0
- package/.claude/skills/directive/docs/pipeline/01-checkpoint.md +34 -0
- package/.claude/skills/directive/docs/pipeline/02-read-directive.md +38 -0
- package/.claude/skills/directive/docs/pipeline/03-read-context.md +15 -0
- package/.claude/skills/directive/docs/pipeline/04-challenge.md +38 -0
- package/.claude/skills/directive/docs/pipeline/05-planning.md +64 -0
- package/.claude/skills/directive/docs/pipeline/06-technical-audit.md +88 -0
- package/.claude/skills/directive/docs/pipeline/07-plan-approval.md +145 -0
- package/.claude/skills/directive/docs/pipeline/07b-project-brainstorm.md +85 -0
- package/.claude/skills/directive/docs/pipeline/08-worktree-and-state.md +50 -0
- package/.claude/skills/directive/docs/pipeline/09-execute-projects.md +709 -0
- package/.claude/skills/directive/docs/pipeline/10-wrapup.md +242 -0
- package/.claude/skills/directive/docs/pipeline/11-completion-gate.md +75 -0
- package/.claude/skills/directive/docs/reference/rules/casting-rules.md +78 -0
- package/.claude/skills/directive/docs/reference/rules/failure-handling.md +20 -0
- package/.claude/skills/directive/docs/reference/rules/phase-definitions.md +42 -0
- package/.claude/skills/directive/docs/reference/rules/scope-and-dod.md +30 -0
- package/.claude/skills/directive/docs/reference/schemas/audit-output.md +44 -0
- package/.claude/skills/directive/docs/reference/schemas/brainstorm-output.md +52 -0
- package/.claude/skills/directive/docs/reference/schemas/challenger-output.md +13 -0
- package/.claude/skills/directive/docs/reference/schemas/checkpoint.md +18 -0
- package/.claude/skills/directive/docs/reference/schemas/current-json.md +5 -0
- package/.claude/skills/directive/docs/reference/schemas/directive-json.md +143 -0
- package/.claude/skills/directive/docs/reference/schemas/investigation-output.md +37 -0
- package/.claude/skills/directive/docs/reference/schemas/plan-schema.md +103 -0
- package/.claude/skills/directive/docs/reference/templates/architect-prompt.md +66 -0
- package/.claude/skills/directive/docs/reference/templates/auditor-prompt.md +53 -0
- package/.claude/skills/directive/docs/reference/templates/brainstorm-prompt.md +68 -0
- package/.claude/skills/directive/docs/reference/templates/challenger-prompt.md +35 -0
- package/.claude/skills/directive/docs/reference/templates/digest.md +134 -0
- package/.claude/skills/directive/docs/reference/templates/investigator-prompt.md +51 -0
- package/.claude/skills/directive/docs/reference/templates/planner-prompt.md +130 -0
- package/.claude/skills/frontend-design/SKILL.md +42 -0
- package/.claude/skills/gruai-agents/SKILL.md +161 -0
- package/.claude/skills/gruai-config/SKILL.md +61 -0
- package/.claude/skills/healthcheck/SKILL.md +216 -0
- package/.claude/skills/report/SKILL.md +380 -0
- package/.claude/skills/scout/SKILL.md +452 -0
- package/.claude/skills/seo-audit/SKILL.md +107 -0
- package/.claude/skills/walkthrough/SKILL.md +274 -0
- package/.claude/skills/webapp-testing/SKILL.md +96 -0
- package/LICENSE +21 -0
- package/README.md +206 -0
- package/cli/templates/CLAUDE.md.template +57 -0
- package/cli/templates/agent-roles/backend.md +47 -0
- package/cli/templates/agent-roles/cmo.md +52 -0
- package/cli/templates/agent-roles/content.md +48 -0
- package/cli/templates/agent-roles/coo.md +66 -0
- package/cli/templates/agent-roles/cpo.md +52 -0
- package/cli/templates/agent-roles/cto.md +63 -0
- package/cli/templates/agent-roles/data.md +46 -0
- package/cli/templates/agent-roles/design.md +46 -0
- package/cli/templates/agent-roles/frontend.md +47 -0
- package/cli/templates/agent-roles/fullstack.md +47 -0
- package/cli/templates/agent-roles/qa.md +46 -0
- package/cli/templates/backlog.json.template +3 -0
- package/cli/templates/directive.json.template +9 -0
- package/cli/templates/directive.md.template +23 -0
- package/cli/templates/goals-index.md +21 -0
- package/cli/templates/gruai.config.json.template +12 -0
- package/cli/templates/lessons.md +16 -0
- package/cli/templates/vision.md +35 -0
- package/cli/templates/welcome-directive/directive.json +9 -0
- package/cli/templates/welcome-directive/directive.md +53 -0
- package/dist/assets/GamePage-C5XQQOQH.js +49 -0
- package/dist/assets/README.md +17 -0
- package/dist/assets/characters/char_0.png +0 -0
- package/dist/assets/characters/char_1.png +0 -0
- package/dist/assets/characters/char_10.png +0 -0
- package/dist/assets/characters/char_11.png +0 -0
- package/dist/assets/characters/char_2.png +0 -0
- package/dist/assets/characters/char_3.png +0 -0
- package/dist/assets/characters/char_4.png +0 -0
- package/dist/assets/characters/char_5.png +0 -0
- package/dist/assets/characters/char_6.png +0 -0
- package/dist/assets/characters/char_7.png +0 -0
- package/dist/assets/characters/char_8.png +0 -0
- package/dist/assets/characters/char_9.png +0 -0
- package/dist/assets/index-CnTPDqpP.js +12 -0
- package/dist/assets/index-gR5q7ikB.css +1 -0
- package/dist/assets/office/furniture.png +0 -0
- package/dist/assets/office/room-builder.png +0 -0
- package/dist/index.html +16 -0
- package/dist-server/scripts/intelligence-trends.d.ts +100 -0
- package/dist-server/scripts/intelligence-trends.js +365 -0
- package/dist-server/server/actions/cleanup.d.ts +4 -0
- package/dist-server/server/actions/cleanup.js +30 -0
- package/dist-server/server/actions/send-input.d.ts +6 -0
- package/dist-server/server/actions/send-input.js +147 -0
- package/dist-server/server/actions/terminal.d.ts +4 -0
- package/dist-server/server/actions/terminal.js +427 -0
- package/dist-server/server/config.d.ts +9 -0
- package/dist-server/server/config.js +217 -0
- package/dist-server/server/db.d.ts +7 -0
- package/dist-server/server/db.js +79 -0
- package/dist-server/server/hooks/event-receiver.d.ts +11 -0
- package/dist-server/server/hooks/event-receiver.js +36 -0
- package/dist-server/server/index.d.ts +1 -0
- package/dist-server/server/index.js +552 -0
- package/dist-server/server/notifications/macos.d.ts +5 -0
- package/dist-server/server/notifications/macos.js +22 -0
- package/dist-server/server/notifications/notifier.d.ts +17 -0
- package/dist-server/server/notifications/notifier.js +110 -0
- package/dist-server/server/parsers/process-discovery.d.ts +39 -0
- package/dist-server/server/parsers/process-discovery.js +776 -0
- package/dist-server/server/parsers/session-scanner.d.ts +56 -0
- package/dist-server/server/parsers/session-scanner.js +390 -0
- package/dist-server/server/parsers/session-state.d.ts +68 -0
- package/dist-server/server/parsers/session-state.js +696 -0
- package/dist-server/server/parsers/session-state.test.d.ts +1 -0
- package/dist-server/server/parsers/session-state.test.js +950 -0
- package/dist-server/server/parsers/task-parser.d.ts +10 -0
- package/dist-server/server/parsers/task-parser.js +97 -0
- package/dist-server/server/parsers/team-parser.d.ts +3 -0
- package/dist-server/server/parsers/team-parser.js +67 -0
- package/dist-server/server/platform/__tests__/claude-code.test.d.ts +1 -0
- package/dist-server/server/platform/__tests__/claude-code.test.js +311 -0
- package/dist-server/server/platform/claude-code.d.ts +34 -0
- package/dist-server/server/platform/claude-code.js +94 -0
- package/dist-server/server/platform/index.d.ts +5 -0
- package/dist-server/server/platform/index.js +1 -0
- package/dist-server/server/platform/types.d.ts +190 -0
- package/dist-server/server/platform/types.js +9 -0
- package/dist-server/server/state/aggregator.d.ts +42 -0
- package/dist-server/server/state/aggregator.js +1080 -0
- package/dist-server/server/state/work-item-types.d.ts +555 -0
- package/dist-server/server/state/work-item-types.js +168 -0
- package/dist-server/server/types.d.ts +237 -0
- package/dist-server/server/types.js +1 -0
- package/dist-server/server/watchers/claude-watcher.d.ts +17 -0
- package/dist-server/server/watchers/claude-watcher.js +130 -0
- package/dist-server/server/watchers/context-watcher.d.ts +22 -0
- package/dist-server/server/watchers/context-watcher.js +125 -0
- package/dist-server/server/watchers/directive-watcher.d.ts +46 -0
- package/dist-server/server/watchers/directive-watcher.js +497 -0
- package/dist-server/server/watchers/session-watcher.d.ts +18 -0
- package/dist-server/server/watchers/session-watcher.js +126 -0
- package/dist-server/server/watchers/state-watcher.d.ts +36 -0
- package/dist-server/server/watchers/state-watcher.js +369 -0
- package/package.json +68 -0
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
<!-- Pipeline doc: 09-execute-projects.md | Source: SKILL.md restructure -->
|
|
2
|
+
|
|
3
|
+
## Execute: Execute Projects
|
|
4
|
+
|
|
5
|
+
### Multi-Project Execution
|
|
6
|
+
|
|
7
|
+
**For multi-project plans** (where the COO's plan produced a `projects` array): Run the ENTIRE execute step once per project, sequentially by priority tier (all P0 projects before P1). Each project has its own project.json, its own brainstorm, its own task loop, and its own review verification. Treat each project as an independent execution unit.
|
|
8
|
+
|
|
9
|
+
**Cross-project dependencies:** Projects can declare `depends_on` in the COO's plan to specify execution order. The wave analysis algorithm (below) uses `depends_on` + file overlap to compute which projects can run in parallel. Projects without `depends_on` and with no file overlap run in the same wave. Tightly coupled work that shares code dependencies should still be ONE project with ordered tasks -- use `depends_on` for genuinely separate projects where one must complete before another starts.
|
|
10
|
+
|
|
11
|
+
**For single-project plans** (flat `tasks` array): Run the execute step once for the single project.json.
|
|
12
|
+
|
|
13
|
+
### Pre-execution Gate: Validate project.json
|
|
14
|
+
|
|
15
|
+
**Before any task executes**, validate that project.json exists and has required fields (output of project-brainstorm step):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
echo '{"directive_dir":"'"$DIRECTIVE_DIR"'","directive_name":"'"$DIRECTIVE_NAME"'"}' | .claude/hooks/validate-project-json.sh
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If `valid: false`, **STOP**. Do not proceed to execution. Fix the violations first -- either create the project.json (approve step should have done this) or fill in missing fields. This is a hard gate, not a warning.
|
|
22
|
+
|
|
23
|
+
Execute each task from the project's `tasks` array **in priority order** (P0 first, then P1, then P2). Note: in a well-formed plan, all tasks should be `simple` complexity. If any are moderate/complex, the complexity floor (approve step) should have caught this and triggered re-decomposition.
|
|
24
|
+
|
|
25
|
+
### Wave Analysis (before execution loop)
|
|
26
|
+
|
|
27
|
+
Before executing tasks, compute execution waves. This is a deterministic algorithm -- no LLM involved. The orchestrator computes it from project.json tasks and audit data.
|
|
28
|
+
|
|
29
|
+
**Inputs:**
|
|
30
|
+
- `tasks[]` from project.json (with optional `depends_on` per task — defaults to `[]` since the brainstorm prompt does not produce it; array ordering is the primary sequencing mechanism, and file-overlap checks handle the rest)
|
|
31
|
+
- `active_files[]` from audit output (per task)
|
|
32
|
+
|
|
33
|
+
**Global sequential files** -- any task touching these files CANNOT run in parallel with any other task, regardless of other overlap checks:
|
|
34
|
+
- `package.json`, `package-lock.json` (npm)
|
|
35
|
+
- `tsconfig.json` (TypeScript config)
|
|
36
|
+
- `prisma/schema.prisma` (database schema)
|
|
37
|
+
- `.env*` (environment config)
|
|
38
|
+
|
|
39
|
+
**Algorithm (greedy wave computation):**
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
MAX_PARALLEL = 3 // tunable -- start conservative, increase if no rate-limit issues
|
|
43
|
+
|
|
44
|
+
function computeWaves(tasks, auditResults):
|
|
45
|
+
remaining = set(all task IDs)
|
|
46
|
+
completed = set()
|
|
47
|
+
waves = []
|
|
48
|
+
|
|
49
|
+
while remaining is not empty:
|
|
50
|
+
eligible = []
|
|
51
|
+
for task in remaining:
|
|
52
|
+
// Check explicit dependencies
|
|
53
|
+
if all of task.depends_on are in completed:
|
|
54
|
+
eligible.append(task)
|
|
55
|
+
|
|
56
|
+
if eligible is empty:
|
|
57
|
+
// Circular dependency or unresolvable depends_on
|
|
58
|
+
ERROR: "Circular dependency detected in remaining tasks"
|
|
59
|
+
break
|
|
60
|
+
|
|
61
|
+
// Within eligible tasks, group by priority tier
|
|
62
|
+
// P0 eligible tasks go before P1 eligible tasks
|
|
63
|
+
eligible.sort(by priority)
|
|
64
|
+
currentPriority = eligible[0].priority
|
|
65
|
+
|
|
66
|
+
// Take only the highest-priority eligible tasks
|
|
67
|
+
tierEligible = eligible.filter(t => t.priority == currentPriority)
|
|
68
|
+
|
|
69
|
+
// Within the tier, check file overlap to form parallel groups
|
|
70
|
+
wave = []
|
|
71
|
+
occupiedFiles = set()
|
|
72
|
+
GLOBAL_SEQUENTIAL = {"package.json", "package-lock.json", "tsconfig.json",
|
|
73
|
+
"prisma/schema.prisma", ".env", ".env.*"}
|
|
74
|
+
waveHasGlobalFile = false
|
|
75
|
+
|
|
76
|
+
for task in tierEligible:
|
|
77
|
+
if len(wave) >= MAX_PARALLEL:
|
|
78
|
+
break // defer remaining to next wave
|
|
79
|
+
taskFiles = auditResults[task.id].active_files
|
|
80
|
+
taskTouchesGlobal = taskFiles INTERSECT GLOBAL_SEQUENTIAL is NOT EMPTY
|
|
81
|
+
|
|
82
|
+
// Global sequential files: only one task touching them per wave
|
|
83
|
+
if taskTouchesGlobal and (waveHasGlobalFile or len(wave) > 0):
|
|
84
|
+
continue // defer -- can't parallelize with global file tasks
|
|
85
|
+
if not taskTouchesGlobal and waveHasGlobalFile:
|
|
86
|
+
continue // defer -- wave already has a global file task
|
|
87
|
+
|
|
88
|
+
if taskFiles INTERSECT occupiedFiles is EMPTY:
|
|
89
|
+
wave.append(task)
|
|
90
|
+
occupiedFiles.addAll(taskFiles)
|
|
91
|
+
if taskTouchesGlobal:
|
|
92
|
+
waveHasGlobalFile = true
|
|
93
|
+
else:
|
|
94
|
+
// This task overlaps -- defer to next wave
|
|
95
|
+
continue
|
|
96
|
+
|
|
97
|
+
waves.append(wave)
|
|
98
|
+
for task in wave:
|
|
99
|
+
remaining.remove(task.id)
|
|
100
|
+
completed.add(task.id)
|
|
101
|
+
|
|
102
|
+
return waves
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Key properties:**
|
|
106
|
+
|
|
107
|
+
1. **Priority ordering preserved.** P0 tasks always schedule before P1, even if P1 tasks have no dependencies.
|
|
108
|
+
2. **File overlap prevents parallel execution.** Even if two tasks have no `depends_on` relationship, overlapping `active_files` forces them into separate waves.
|
|
109
|
+
3. **Greedy packing.** Each wave grabs as many non-overlapping tasks as possible (up to MAX_PARALLEL). Maximizes parallelism.
|
|
110
|
+
4. **Deterministic.** Same input always produces the same waves.
|
|
111
|
+
|
|
112
|
+
**Wave manifest artifact:** Write the computed waves to the project directory as `wave-manifest.json`:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"computed_at": "2026-03-06T10:00:00Z",
|
|
117
|
+
"max_parallel": 3,
|
|
118
|
+
"total_tasks": 8,
|
|
119
|
+
"total_waves": 3,
|
|
120
|
+
"waves": [
|
|
121
|
+
{
|
|
122
|
+
"wave": 1,
|
|
123
|
+
"tasks": [
|
|
124
|
+
{ "id": "update-types", "builder": "backend-engineer-id", "priority": "P0", "active_files": ["src/types.ts"] }
|
|
125
|
+
],
|
|
126
|
+
"parallel": false
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"wave": 2,
|
|
130
|
+
"tasks": [
|
|
131
|
+
{ "id": "build-component-a", "builder": "frontend-engineer-id", "priority": "P0", "active_files": ["src/components/A.tsx"] },
|
|
132
|
+
{ "id": "build-component-b", "builder": "frontend-engineer-id", "priority": "P0", "active_files": ["src/components/B.tsx"] }
|
|
133
|
+
],
|
|
134
|
+
"parallel": true
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"wave": 3,
|
|
138
|
+
"tasks": [
|
|
139
|
+
{ "id": "integration-test", "builder": "qa-engineer-id", "priority": "P1", "active_files": ["tests/integration.test.ts"] }
|
|
140
|
+
],
|
|
141
|
+
"parallel": false
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Same builder in parallel tasks:** If a wave has two tasks both cast to the same builder (e.g., the frontend engineer), they still run in parallel as separate agent instances. Each instance gets its own scope, files, and context. The personality file makes them behave consistently, not identically.
|
|
148
|
+
|
|
149
|
+
### Wave-Based Execution Loop
|
|
150
|
+
|
|
151
|
+
Execute the computed waves sequentially. Within each wave, tasks run in parallel (if more than one).
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
for each wave in wave manifest:
|
|
155
|
+
if wave has 1 task:
|
|
156
|
+
execute task sequentially (build phases as normal)
|
|
157
|
+
if wave has multiple tasks:
|
|
158
|
+
spawn all build phases in parallel (each as CLI agent)
|
|
159
|
+
wait for all builds to complete
|
|
160
|
+
post-wave diff check (see below)
|
|
161
|
+
|
|
162
|
+
// Review phase: SEQUENTIAL per task within the wave
|
|
163
|
+
for each completed task in this wave:
|
|
164
|
+
run code-review phase (if in task phases)
|
|
165
|
+
run review phase
|
|
166
|
+
if review fails -> fix cycle -> re-review
|
|
167
|
+
|
|
168
|
+
advance to next wave
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Parallel builds use CLI spawns** (`claude -p --agent`), NOT the Agent tool with `run_in_background`. Background agents get Bash permission auto-rejected. CLI sessions can use Bash. See "Agent Spawn Rules" below for the spawn pattern with CHILD_PIDS + trap cleanup.
|
|
172
|
+
|
|
173
|
+
**Reviews stay sequential per task** within each wave. Rationale:
|
|
174
|
+
- Reviews read the full file -- parallel reviews could see inconsistent state
|
|
175
|
+
- Fix cycles modify files -- sequential ensures each fixer sees current state
|
|
176
|
+
- Build is the bottleneck (3-10 min), not review (1-2 min)
|
|
177
|
+
|
|
178
|
+
**Post-wave diff check:** After each wave's builds complete, before starting reviews:
|
|
179
|
+
1. Run `git diff --name-only` to see what files were actually modified
|
|
180
|
+
2. Compare against the wave manifest's predicted `active_files`
|
|
181
|
+
3. If a task modified a file not in its `active_files`, log a warning:
|
|
182
|
+
`[DRIFT] {task title} modified {file} not in predicted active_files`
|
|
183
|
+
4. The warning does not block -- the review phase catches inconsistencies
|
|
184
|
+
|
|
185
|
+
**Progress display format:**
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
Wave 1/3: [1 task, sequential]
|
|
189
|
+
[1/8] Update types (P0, backend-engineer) -- building...
|
|
190
|
+
[1/8] Update types -- completed
|
|
191
|
+
|
|
192
|
+
Wave 2/3: [2 tasks, PARALLEL]
|
|
193
|
+
[2/8] Build component A (P0, frontend-engineer) -- building...
|
|
194
|
+
[3/8] Build component B (P0, frontend-engineer) -- building...
|
|
195
|
+
[3/8] Build component B -- completed (2m 14s)
|
|
196
|
+
[2/8] Build component A -- completed (3m 01s)
|
|
197
|
+
[2/8] Build component A -- reviewing...
|
|
198
|
+
[3/8] Build component B -- reviewing...
|
|
199
|
+
|
|
200
|
+
Wave 3/3: [1 task, sequential]
|
|
201
|
+
[4/8] Integration test (P1, qa-engineer) -- building...
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
For each task, execute its `phases` array in order. Each phase has specific agent assignments and artifact outputs.
|
|
205
|
+
|
|
206
|
+
### Phase Execution Reference
|
|
207
|
+
|
|
208
|
+
For each phase in the task's `phases` array, execute it according to these rules:
|
|
209
|
+
|
|
210
|
+
**Phase: `research`**
|
|
211
|
+
Spawn researcher agent (the CMO or CTO per cast) to investigate and produce findings. **Artifact:** the project directory as `research.md`.
|
|
212
|
+
|
|
213
|
+
**Phase: `product-spec`**
|
|
214
|
+
Spawn the CPO to write product requirements + acceptance criteria. **Artifact:** the project directory as `product-spec.md`.
|
|
215
|
+
|
|
216
|
+
**Phase: `design`**
|
|
217
|
+
Spawn designer agent (the CTO for technical design, the UI/UX designer for UI design) to read the codebase and write a technical approach. For UI-touching tasks, spawn both: the CTO produces the technical design, the UI/UX designer produces the visual design prototype (wireframes, component specs, interaction notes). Include any prior phase artifacts (research, product-spec) as context. If a design prototype exists from the audit step (`.context/directives/{id}/design-prototype.md`), include it as the starting point. **Artifact:** the project directory as `design.md`.
|
|
218
|
+
|
|
219
|
+
**Phase: `keyword-research`**
|
|
220
|
+
Spawn the CMO to research target keywords, search intent, competitor content gaps, and recommended topics. **Artifact:** the project directory as `keyword-research.md`.
|
|
221
|
+
|
|
222
|
+
**Phase: `outline`**
|
|
223
|
+
Spawn the CMO to create a content outline -- structure, headings, target keywords per section, internal linking strategy. Include keyword research artifact as context. **Artifact:** the project directory as `outline.md`.
|
|
224
|
+
|
|
225
|
+
**Phase: `clarification`**
|
|
226
|
+
Pre-build Q&A stolen from ChatDev's dual-agent dehallucination pattern (40% error reduction). Spawn the engineer with all context (scope, design output, audit findings). Engineer outputs 3-5 specific clarifying questions about scope boundaries, edge cases, integration points, and ambiguous requirements. Spawn the designer/auditor from the previous phase to respond. **Artifact:** the project directory as `clarification.md`.
|
|
227
|
+
|
|
228
|
+
**Phase: `build`**
|
|
229
|
+
Spawn engineer agent(s) with task scope + all prior phase artifacts + audit findings. For migration tasks (phases include research + design + build), the build is INCREMENTAL: engineer executes one step at a time. **Artifact:** the project directory as `build.md`.
|
|
230
|
+
|
|
231
|
+
**Phase: `draft`**
|
|
232
|
+
Spawn engineer agent to write the actual content (MDX files, page components) following the outline artifact. **Artifact:** the project directory as `draft.md`.
|
|
233
|
+
|
|
234
|
+
**Phase: `seo-review`**
|
|
235
|
+
Spawn the CMO to review the draft for SEO quality -- meta tags, keyword density, structured data, internal links, readability. **Artifact:** the project directory as `seo-review.md`.
|
|
236
|
+
|
|
237
|
+
**Phase: `code-review`** (independent review with fresh context -- inspired by [Anthropic's official code-review plugin](https://github.com/anthropics/claude-code/tree/main/plugins/code-review))
|
|
238
|
+
|
|
239
|
+
Spawn the reviewer(s) from the project's `reviewers` array -- the SAME agents the COO assigned, but with a **fresh-context prompt** that strips all builder reasoning. They get full file contents + diff but NO design docs, scope, or builder intent. This is NOT hardcoded to any specific agent. If the builder IS one of the reviewers (conflict of interest), skip that reviewer for this phase.
|
|
240
|
+
|
|
241
|
+
The reviewer gets:
|
|
242
|
+
1. The **full contents** of files touched by this task (so they can see surrounding context)
|
|
243
|
+
2. The **git diff** highlighting what changed
|
|
244
|
+
3. The architect's **recommended approach** (from audit output -- so they can spot unjustified deviations)
|
|
245
|
+
4. The contents of `.claude/skills/code-review-excellence/SKILL.md` -- read this file and include it as review methodology guidance
|
|
246
|
+
5. The code-review prompt below
|
|
247
|
+
|
|
248
|
+
They do NOT get: design docs, scope description, builder reasoning, or prior phase artifacts. The one exception: they DO get the architect's `recommended_approach` (a brief implementation spec from the audit). This lets them flag cases where the builder ignored the architect's guidance without justification. The fresh-eyes benefit comes from not knowing the builder's intent, not from being blind to surrounding code or the implementation spec.
|
|
249
|
+
|
|
250
|
+
Code-review prompt (given to each reviewer):
|
|
251
|
+
```
|
|
252
|
+
MODE: Independent Code Review (fresh context, no builder bias)
|
|
253
|
+
|
|
254
|
+
You are reviewing code changes. You have no context about the builder's reasoning or intent.
|
|
255
|
+
You DO have the architect's recommended approach (the implementation spec the builder was given).
|
|
256
|
+
Your job is to find bugs and flag unjustified deviations from the spec. Assume the code is broken until proven otherwise.
|
|
257
|
+
|
|
258
|
+
THE CHANGED FILES (full contents):
|
|
259
|
+
{full file contents for each file touched by this task}
|
|
260
|
+
|
|
261
|
+
THE DIFF (what changed):
|
|
262
|
+
{output of `git diff` for files touched by this task}
|
|
263
|
+
|
|
264
|
+
ARCHITECT'S RECOMMENDED APPROACH:
|
|
265
|
+
{recommended_approach from audit output -- the implementation spec the builder was given as context}
|
|
266
|
+
|
|
267
|
+
REVIEW STEPS:
|
|
268
|
+
1. Read the diff. Judge the code on its own merits -- no design doc, no scope, no intent.
|
|
269
|
+
2. For every function/component changed: does it handle empty/null/error cases?
|
|
270
|
+
3. For every state change: trace the data flow end-to-end. Where does it come from? Where does it go? Can it be stale?
|
|
271
|
+
4. For every UI change: what happens if data is loading? Empty? Error? What does the user see at each state?
|
|
272
|
+
5. For every integration point: does the caller handle all return values? Are error paths covered?
|
|
273
|
+
6. Trace code paths manually -- call functions with edge-case inputs in your head.
|
|
274
|
+
7. REACHABILITY CHECK (mandatory): For every new artifact (component, endpoint, handler, config option, state field, command), trace its reachability: what user action or system event triggers it -> through what layers -> to what outcome. "Code exists" is NOT "code is reachable." Trace from entry point through every mapping/routing/dispatch layer to verify the new code is actually invoked. Report anything unreachable as a bug -- dead code that was supposed to be live is a wiring failure, not a style nit.
|
|
275
|
+
|
|
276
|
+
CRITICAL: We only want HIGH SIGNAL issues. Flag issues where:
|
|
277
|
+
- The code will fail to compile or parse
|
|
278
|
+
- The code will definitely produce wrong results
|
|
279
|
+
- Clear data flow bugs (stale state, missing null checks on paths that will hit null)
|
|
280
|
+
- Integration mismatches (caller expects X, callee returns Y)
|
|
281
|
+
|
|
282
|
+
Do NOT flag: style concerns, potential issues that depend on specific inputs, subjective improvements.
|
|
283
|
+
|
|
284
|
+
OUTPUT (JSON):
|
|
285
|
+
{
|
|
286
|
+
"code_review_outcome": "pass | fail | critical",
|
|
287
|
+
"bugs_found": [{"file": "...", "line": "...", "severity": "high|medium|low", "description": "..."}],
|
|
288
|
+
"approach_deviation": "none | justified | unjustified -- did the builder follow the architect's recommended approach? If not, does the code suggest a valid reason?",
|
|
289
|
+
"suspicious_patterns": ["things that smell wrong but you can't prove are bugs"],
|
|
290
|
+
"data_flow_issues": ["stale data, race conditions, missing validation"],
|
|
291
|
+
"reachability_check": ["for each new artifact: 'ArtifactName: entry_point -> layer1 -> layer2 -> outcome -- REACHABLE' or 'ArtifactName: UNREACHABLE -- no user action/system event invokes it'"],
|
|
292
|
+
"verdict": "1-2 sentence summary -- would you ship this?"
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
If `approach_deviation` is "unjustified" (builder ignored the architect's spec without apparent reason), this alone warrants `code_review_outcome: "fail"` -- it signals the builder satisficed rather than engaging with the problem.
|
|
296
|
+
|
|
297
|
+
A review that finds zero issues is SUSPICIOUS. Real code changes almost always have at least one edge case worth noting. Double-check before reporting all-clear.
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
This phase is separate from the standard `review` phase. `code-review` catches bugs through fresh eyes; `review` checks DOD compliance and user perspective. Both are valuable for different reasons.
|
|
301
|
+
|
|
302
|
+
**When to include `code-review`:** The COO includes it when the task touches integration points (data flows, state management, API boundaries) or has >3 DOD criteria. Skip for trivial fixes. Pattern: `["build", "code-review", "review"]`.
|
|
303
|
+
|
|
304
|
+
**Artifact:** the project directory as `code-review.md`.
|
|
305
|
+
|
|
306
|
+
**Phase: `review`**
|
|
307
|
+
For each reviewer in the project's `reviewers` array, spawn the reviewer agent to review the changes. Collect all review JSONs. If ANY reviewer returns "critical", trigger the retry logic. **Artifact:** the project directory as `review.md`.
|
|
308
|
+
|
|
309
|
+
**Phase: `design-review`**
|
|
310
|
+
Spawn the UI/UX designer to review the UI implementation against the design prototype. The designer compares the running UI against the wireframes, component specs, and interaction notes from the design prototype (`design-prototype.md`) and evaluates layout fidelity, visual consistency, usability, responsiveness, and polish. **Artifact:** the project directory as `design-review.md`. Include this phase for any UI-touching task — pattern: `["build", "code-review", "design-review", "review"]`.
|
|
311
|
+
|
|
312
|
+
**Phase: `tech-review`**
|
|
313
|
+
Spawn the CTO to review code quality + architecture. **Artifact:** the project directory as `tech-review.md`.
|
|
314
|
+
|
|
315
|
+
**Phase: `product-review`**
|
|
316
|
+
Spawn the CPO to verify it meets the product spec. **Artifact:** the project directory as `product-review.md`.
|
|
317
|
+
|
|
318
|
+
**After the last phase:** If any task phase produced UI changes, trigger UX verification (see "UX Verification Phase" below).
|
|
319
|
+
|
|
320
|
+
**For research-only tasks** (phases = `["research"]`): After the research phase, write the report to `.context/reports/` as well.
|
|
321
|
+
|
|
322
|
+
### Agent Spawn Rules
|
|
323
|
+
|
|
324
|
+
> **Process cleanup:** When spawning CLI agents (`claude -p --agent ...`), track child PIDs so they get killed if the directive session exits unexpectedly. Without this, orphaned agent processes accumulate and saturate API rate limits.
|
|
325
|
+
|
|
326
|
+
**CLI spawn pattern with cleanup trap:**
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
# Set up cleanup trap ONCE at the start of execute step
|
|
330
|
+
CHILD_PIDS=()
|
|
331
|
+
cleanup_children() {
|
|
332
|
+
for pid in "${CHILD_PIDS[@]}"; do
|
|
333
|
+
kill "$pid" 2>/dev/null
|
|
334
|
+
done
|
|
335
|
+
}
|
|
336
|
+
trap cleanup_children EXIT
|
|
337
|
+
|
|
338
|
+
# For each CLI spawn, track the PID:
|
|
339
|
+
CLAUDECODE= claude -p --agent {agent-id} --model sonnet --dangerously-skip-permissions --no-session-persistence "prompt" > /tmp/{agent-id}-output.txt 2>&1 &
|
|
340
|
+
CHILD_PIDS+=($!)
|
|
341
|
+
wait $!
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
If the session gets killed (context limit, timeout, user cancels), the trap fires and kills all child processes. No more zombies.
|
|
345
|
+
|
|
346
|
+
**All named agents** (C-suite and specialists): Use the agent's `id` from `.claude/agent-registry.json` as the `subagent_type`. The personality file is auto-loaded by the agent system. Do NOT manually paste personality file contents into the prompt -- just use the named type.
|
|
347
|
+
|
|
348
|
+
Available `subagent_type` values are the `id` fields from the agent registry. Resolve roles to IDs by reading the registry at runtime:
|
|
349
|
+
- **C-suite**: CTO, CPO, CMO, COO
|
|
350
|
+
- **Specialists**: frontend engineer, UI/UX designer, backend engineer, data engineer, content builder, QA engineer, full-stack engineer
|
|
351
|
+
|
|
352
|
+
Specialists receive engineer-style instructions (scope, DOD, audit findings) in their task prompt -- the personality is already loaded via the type.
|
|
353
|
+
|
|
354
|
+
**Fallback assignments** (when no specific specialist is assigned):
|
|
355
|
+
- No specific builder assigned -> use the full-stack engineer (handles broad/cross-domain scope)
|
|
356
|
+
- Unnamed auditor (no named auditor assigned) -> use the CTO (handles unassigned audits)
|
|
357
|
+
- Unnamed reviewer (no named reviewer assigned) -> use the QA engineer (handles unassigned reviews)
|
|
358
|
+
|
|
359
|
+
All agents are named agents with personality files. There are no generic role agents.
|
|
360
|
+
|
|
361
|
+
**Engineer/builder agents** (any specialist or the full-stack engineer): Spawn with:
|
|
362
|
+
- Task scope (from the COO's plan)
|
|
363
|
+
- Task definition_of_done (from the COO's plan) -- the engineer must know acceptance criteria BEFORE building
|
|
364
|
+
- Audit findings (from audit step): active file list, baseline, dead code flags
|
|
365
|
+
- **Recommended approach** (from the architect's audit output) -- include the `recommended_approach` field verbatim as implementation context. This is guidance, not a mandate -- the builder can deviate if they discover a better path during implementation, but they should note deviations in their build report.
|
|
366
|
+
- Design output (if available from earlier phases)
|
|
367
|
+
- **Design prototype** (if `.context/directives/{id}/design-prototype.md` exists -- the UI/UX designer's wireframes and specs from the audit step). Include it as the visual spec the builder must follow for UI layout, components, and interactions.
|
|
368
|
+
- Brainstorm output (if this task's project had a brainstorm phase -- see brainstorm constraint below)
|
|
369
|
+
- Instruction: "The architect's recommended approach is provided as context. Use it as your starting point -- it's based on real codebase investigation. If you find a better approach during implementation, go with it but explain why in your build report."
|
|
370
|
+
|
|
371
|
+
**Brainstorm constraint prompt** (when the project had a brainstorm phase -- prepend to the engineer's build prompt):
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
BRAINSTORM CONSTRAINT -- READ BEFORE WRITING ANY CODE:
|
|
375
|
+
|
|
376
|
+
The team brainstormed this task's approach before you were assigned. Their analysis is below.
|
|
377
|
+
|
|
378
|
+
{brainstorm output from the project's brainstorm.md}
|
|
379
|
+
|
|
380
|
+
Before writing any code, you MUST:
|
|
381
|
+
1. Read the brainstorm analysis above
|
|
382
|
+
2. In your build report, include a `brainstorm_alignment` section that states:
|
|
383
|
+
- Which brainstorm recommendations you followed
|
|
384
|
+
- Which you deviated from and WHY
|
|
385
|
+
- What the brainstorm missed that you discovered during implementation
|
|
386
|
+
|
|
387
|
+
This is not optional. If your build report has no `brainstorm_alignment` section, the review will flag it.
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
This forces the builder to engage with the brainstorm output rather than ignoring it. The reviewer can then check whether deviations were justified.
|
|
391
|
+
- **Task instruction**: "After completing the build, report BOTH what you built AND what you think is still missing or broken. List specific follow-ups you'd propose -- gaps in the UX, edge cases not covered, related features that should exist but don't. This is not optional -- every build report must include a `proposed_improvements` section."
|
|
392
|
+
- **User-perspective instruction**: "Before reporting completion, mentally walk through the feature as if you are the CEO using it for the first time. Ask yourself: Can I click this? Where does it go? Does the number match reality? Is anything a dead end? Include a `user_walkthrough` section in your build report describing what the CEO would experience step-by-step."
|
|
393
|
+
|
|
394
|
+
**Engineer clarification prompt** (for complex processes only -- prepend to the engineer's build prompt when a clarification phase precedes the build):
|
|
395
|
+
|
|
396
|
+
```
|
|
397
|
+
Before building, you reviewed the scope and design and asked clarifying questions. Here are the answers:
|
|
398
|
+
|
|
399
|
+
{clarification Q&A from the clarification phase artifact}
|
|
400
|
+
|
|
401
|
+
Use these clarifications to guide your implementation. If the answers revealed scope changes or additional requirements, incorporate them.
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**All agents** get:
|
|
405
|
+
- `subagent_type`: the agent's named type (see above) -- always use a named agent, never generic types
|
|
406
|
+
- `model: "opus"`
|
|
407
|
+
- `.context/preferences.md` -- CEO standing orders
|
|
408
|
+
- `.context/vision.md` guardrails section -- hard constraints
|
|
409
|
+
- `.context/lessons/` topic files (load only what's relevant to the agent's role):
|
|
410
|
+
- **Engineers**: `.context/lessons/agent-behavior.md` + `.context/lessons/skill-design.md`
|
|
411
|
+
- **CTO (auditor/reviewer)**: `.context/lessons/agent-behavior.md` + `.context/lessons/review-quality.md`
|
|
412
|
+
- **CPO (product reviewer)**: `.context/lessons/review-quality.md`
|
|
413
|
+
- **COO (process reviewer)**: `.context/lessons/orchestration.md` + `.context/lessons/review-quality.md`
|
|
414
|
+
- **CMO (content/growth)**: `.context/lessons/agent-behavior.md`
|
|
415
|
+
|
|
416
|
+
### UX Verification Phase (mandatory for UI work)
|
|
417
|
+
|
|
418
|
+
**When:** After the build + review phases complete for any task where the audit's `active_files` list contains files matching UI patterns: `*.tsx`, `*.jsx`, `*.css`, `*.scss`, `*.html`, `tailwind.config.*`, `globals.css`, or files under `pages/`, `app/`, `components/`, `layouts/`, or `styles/` directories. This is NOT a subjective judgment call -- if the file patterns match, UX verification is REQUIRED.
|
|
419
|
+
|
|
420
|
+
**How:** The orchestrator (you) must personally verify the changes work from the CEO's perspective using browser automation tools (mcp__claude-in-chrome__*). This is NOT delegated to a subagent -- Chrome MCP tools only work in the main session.
|
|
421
|
+
|
|
422
|
+
**UX verification checklist:**
|
|
423
|
+
1. Navigate to every page/component that was modified
|
|
424
|
+
2. Click every clickable element -- verify it does something useful (no dead-end UI)
|
|
425
|
+
3. Check that data displayed matches the backend (numbers, counts, lists)
|
|
426
|
+
4. Test the "9am CEO workflow": open dashboard -> see what happened -> click into detail -> know what to do
|
|
427
|
+
5. Take screenshots as evidence
|
|
428
|
+
|
|
429
|
+
**If UX verification fails:** Fix the issues immediately (spawn another engineer if needed), then re-verify. Do NOT skip to the next task with broken UI.
|
|
430
|
+
|
|
431
|
+
**Visual feedback loop (MANDATORY for game category):** When the directive's category is `game` AND the task touches visual rendering (sprites, tiles, furniture, Canvas drawing), the standard UX verification is NOT sufficient. Instead:
|
|
432
|
+
1. After the build phase, take screenshots of the game at multiple zoom levels (1x, 2x, 4x)
|
|
433
|
+
2. Compare visually against the quality bar in `.context/directives/game-visual-quality-overhaul/` context
|
|
434
|
+
3. If the visual quality doesn't match the reference repos (pixel-agents, claw-empire), spawn the builder again with the screenshot and specific feedback ("the desk needs wood grain texture", "the character needs more detail in the hair", etc.)
|
|
435
|
+
4. Iterate until the visual quality matches. There is no maximum iteration count -- keep going until it looks right.
|
|
436
|
+
5. This applies to every visual change, not just the first build.
|
|
437
|
+
|
|
438
|
+
This is a CEO mandate. Slow is fine. Ugly is not.
|
|
439
|
+
|
|
440
|
+
**Skip UX verification if:** The task is backend-only, research-only, or doesn't touch any user-facing code.
|
|
441
|
+
|
|
442
|
+
**When running as a CLI session (no Chrome MCP):** Log the UI checks that need manual verification in the directive digest. The CEO can run them from the dashboard or game UI. The directive is NOT complete until UI review passes.
|
|
443
|
+
|
|
444
|
+
### User-Perspective Review (mandatory for all tasks)
|
|
445
|
+
|
|
446
|
+
Separate from code review. After the reviewer checks code quality, the reviewer ALSO evaluates the work from the end-user's perspective. This catches the gap where code compiles but the user experience is broken.
|
|
447
|
+
|
|
448
|
+
**Add to every reviewer prompt:**
|
|
449
|
+
|
|
450
|
+
```
|
|
451
|
+
SEPARATE FROM CODE REVIEW -- also evaluate this work from the CEO/end-user perspective:
|
|
452
|
+
1. Walk through the task's `user_scenario`: "{user_scenario from the COO's plan}". Does the build actually deliver this experience?
|
|
453
|
+
2. If this were shipped today, would the CEO's workflow actually improve?
|
|
454
|
+
3. What did the engineer build that technically works but misses the user's real need?
|
|
455
|
+
4. What's MISSING that the directive didn't ask for but the user clearly needs?
|
|
456
|
+
5. Are there dead-end UI elements (clickable-looking things that do nothing)?
|
|
457
|
+
6. Does the data flow make sense end-to-end (not just "does the component render")?
|
|
458
|
+
|
|
459
|
+
Include a `user_perspective` section in your review JSON:
|
|
460
|
+
{
|
|
461
|
+
"user_perspective": {
|
|
462
|
+
"workflow_improvement": "yes | partial | no -- does this actually help the user?",
|
|
463
|
+
"missing_features": ["things the user needs but weren't built"],
|
|
464
|
+
"dead_ends": ["UI elements that look interactive but aren't"],
|
|
465
|
+
"data_integrity": ["data that displays but doesn't match reality"]
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
**DOD verification** (mandatory if task has definition_of_done):
|
|
471
|
+
|
|
472
|
+
```
|
|
473
|
+
DEFINITION OF DONE VERIFICATION -- check EVERY criterion:
|
|
474
|
+
For each item in this task's definition_of_done array, verify whether it has been met.
|
|
475
|
+
|
|
476
|
+
Include a `dod_verification` section in your review JSON:
|
|
477
|
+
{
|
|
478
|
+
"dod_verification": {
|
|
479
|
+
"criteria": [
|
|
480
|
+
{"criterion": "the DOD text", "met": true, "evidence": "what you observed that confirms/denies this"}
|
|
481
|
+
],
|
|
482
|
+
"all_met": true
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
If ANY criterion is not met, set review_outcome to "fail". If a criterion violation would breach a guardrail (SEO, security, data integrity), set review_outcome to "critical".
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**Brainstorm alignment check** (mandatory when task had a brainstorm phase):
|
|
490
|
+
|
|
491
|
+
```
|
|
492
|
+
BRAINSTORM ALIGNMENT CHECK:
|
|
493
|
+
If this task's project had a brainstorm phase, the builder was required to include a `brainstorm_alignment` section in their build report.
|
|
494
|
+
|
|
495
|
+
1. Does the build report include a `brainstorm_alignment` section? If not, flag as "fail".
|
|
496
|
+
2. Read the brainstorm output (provided below) and compare against the builder's claimed alignment.
|
|
497
|
+
3. Did the builder deviate from brainstorm recommendations? If so, is the deviation justified by what the code actually does?
|
|
498
|
+
4. Did the builder claim to follow a recommendation but the code doesn't reflect it?
|
|
499
|
+
|
|
500
|
+
Include a `brainstorm_check` section in your review JSON:
|
|
501
|
+
{
|
|
502
|
+
"brainstorm_check": {
|
|
503
|
+
"alignment_section_present": true,
|
|
504
|
+
"unjustified_deviations": ["list any deviations not justified by the code"],
|
|
505
|
+
"claimed_but_not_implemented": ["recommendations builder said they followed but didn't"]
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
Skip this check if the task had no brainstorm phase.
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
**CEO corrections check** (mandatory for all reviews):
|
|
513
|
+
|
|
514
|
+
```
|
|
515
|
+
CEO CORRECTIONS CHECK -- MANDATORY:
|
|
516
|
+
Read .context/preferences.md (specifically the ## Standing Corrections section). For each standing correction:
|
|
517
|
+
1. Does this task's work touch anything related to this correction?
|
|
518
|
+
2. If yes, does the implementation respect the correction?
|
|
519
|
+
3. If it violates a correction, this is automatically review_outcome: "critical".
|
|
520
|
+
|
|
521
|
+
Include a `corrections_check` section in your review JSON:
|
|
522
|
+
{
|
|
523
|
+
"corrections_check": {
|
|
524
|
+
"corrections_reviewed": 4,
|
|
525
|
+
"violations": []
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
**Review completeness** (mandatory for all reviews):
|
|
531
|
+
|
|
532
|
+
```
|
|
533
|
+
REVIEW COMPLETENESS -- use this structured output:
|
|
534
|
+
{
|
|
535
|
+
"review_outcome": "pass | fail | critical",
|
|
536
|
+
"code_quality": {"issues": [], "severity": "none | minor | major"},
|
|
537
|
+
"user_perspective": { ... },
|
|
538
|
+
"dod_verification": { ... },
|
|
539
|
+
"corrections_check": { ... },
|
|
540
|
+
"surfaces_checked": ["list every file, endpoint, UI surface, or data flow you actually inspected"],
|
|
541
|
+
"what_is_missing": ["things the directive asked for that aren't present in the build"],
|
|
542
|
+
"regression_risks": ["existing functionality that could break from these changes"]
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
A review_outcome of "pass" requires: ALL DOD criteria met, ZERO corrections violations, user_perspective.workflow_improvement is "yes" or "partial", and no major code quality issues.
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
**This is NOT optional.** Every review must include user-perspective evaluation. A review that only checks code quality but ignores user experience is incomplete.
|
|
549
|
+
|
|
550
|
+
Check the audit findings for this task. If `active_files` is empty and findings indicate nothing to fix, **skip the task** -- set status to `skipped` and continue to the next. Log: `[N/M] {title} -- skipped (audit found nothing to fix)`.
|
|
551
|
+
|
|
552
|
+
**Update directive.json:** Update this task's `status` to `"in_progress"` and `current_phase` to the first phase. Update `pipeline.execute.output` with current progress.
|
|
553
|
+
|
|
554
|
+
### After Each Phase
|
|
555
|
+
|
|
556
|
+
- If an agent fails or reports a blocker: **skip remaining phases for this task**, log the error, continue to next task
|
|
557
|
+
- If a **standard review** finds issues: **log them as non-fatal findings** (don't block). Include in digest.
|
|
558
|
+
|
|
559
|
+
### After code-review Phase Specifically
|
|
560
|
+
|
|
561
|
+
Code-review findings are NOT non-fatal. The code-review phase exists to catch bugs the builder missed -- ignoring its findings defeats the purpose.
|
|
562
|
+
|
|
563
|
+
- If `code_review_outcome` is `"fail"` or `"critical"`: **trigger a fix cycle** before proceeding to the standard `review` phase:
|
|
564
|
+
1. Re-spawn the builder with the code-review findings as fix instructions (bugs_found, data_flow_issues)
|
|
565
|
+
2. Re-run the code-review with the updated diff
|
|
566
|
+
3. Maximum 1 fix cycle per task -- if still failing after retry, log findings and proceed to standard review (which will likely also catch them)
|
|
567
|
+
- If `code_review_outcome` is `"pass"`: proceed to the next phase normally
|
|
568
|
+
|
|
569
|
+
**Artifact:** Write the phase output to the directive's project directory: `.context/directives/{directive-id}/projects/{project-id}/build-{task-id}.md` (for build phase) or `review-{task-id}.md` (for review phase). The validate-gate.sh script checks for these files at step boundaries.
|
|
570
|
+
|
|
571
|
+
**Update directive.json:** Update the task's `phases_completed`, `current_phase`, and `artifact_paths`. Set `current_step: "execute"`.
|
|
572
|
+
|
|
573
|
+
**After the review phase specifically:** Also write the reviewer's `dod_verification` output to the task entry in directive.json. This is MANDATORY for heavyweight/strategic directives -- the review-gate checks this field. If the reviewer's JSON output includes a `dod_verification` section, copy it into `tasks[].dod_verification`. If the reviewer did not include `dod_verification`, write `null` (the review-gate will flag this as a violation).
|
|
574
|
+
|
|
575
|
+
### Conditional Retry (review_outcome = critical)
|
|
576
|
+
|
|
577
|
+
If ANY reviewer returns `review_outcome: "critical"`, attempt ONE retry:
|
|
578
|
+
1. Re-spawn the engineer with the critical reviewer's issues as fix instructions
|
|
579
|
+
2. Re-run ONLY the reviewer(s) that returned "critical" -- don't re-run reviewers that already passed
|
|
580
|
+
3. If still critical after retry, mark task as `partial` and continue
|
|
581
|
+
|
|
582
|
+
Maximum 1 retry per task. If all reviewers passed or got non-critical issues, no retry.
|
|
583
|
+
|
|
584
|
+
**What constitutes "critical":**
|
|
585
|
+
- Any DOD criterion not met that relates to a guardrail (SEO, security, data integrity)
|
|
586
|
+
- Any Standing Correction violation
|
|
587
|
+
- Security vulnerability introduced by the build
|
|
588
|
+
- Data loss or corruption risk
|
|
589
|
+
- Build that's fundamentally wrong approach (not just missing polish)
|
|
590
|
+
|
|
591
|
+
**What is NOT critical (just "fail"):**
|
|
592
|
+
- DOD criteria not met but no guardrail impact
|
|
593
|
+
- Missing edge case handling
|
|
594
|
+
- Code quality issues (naming, complexity, duplication)
|
|
595
|
+
- Incomplete coverage of scope (partial work)
|
|
596
|
+
|
|
597
|
+
### After Each Task
|
|
598
|
+
|
|
599
|
+
Log completion status: completed / partial / skipped / failed.
|
|
600
|
+
|
|
601
|
+
**Update directive.json:** Update the task's `status` to its final value (`completed`, `partial`, `skipped`, or `failed`). Set `current_phase: null`. Update `pipeline.execute.output` with overall progress. If this is the last task, set `current_step: "review-gate"` and `pipeline.execute.status` to `"completed"`.
|
|
602
|
+
|
|
603
|
+
**Stop-on-failure for dependent tasks:** If a task ends with `failed` or `partial` status, check which later tasks depend on it (via `depends_on` or array position). Mark those dependent tasks as `blocked`. Non-dependent tasks proceed normally. Log: `[BLOCKED] {task title} blocked by {failed task title} ({status})`.
|
|
604
|
+
|
|
605
|
+
- `failed` -> block dependents. The task didn't produce working code.
|
|
606
|
+
- `partial` -> block dependents. Known critical issues survived retry -- dependent tasks would inherit the bugs.
|
|
607
|
+
- `skipped` -> continue. Audit found nothing to fix -- not a failure.
|
|
608
|
+
- `completed` -> continue.
|
|
609
|
+
|
|
610
|
+
### Failure Handling for Parallel Waves
|
|
611
|
+
|
|
612
|
+
Extends the stop-on-failure rules above for wave-based execution.
|
|
613
|
+
|
|
614
|
+
**Within a wave (parallel tasks):** Parallel task failures do NOT cascade within the same wave. If task A fails and task B succeeds (both in wave 2):
|
|
615
|
+
- Task A is marked `failed`
|
|
616
|
+
- Task B proceeds to review normally
|
|
617
|
+
- The wave is considered partially complete
|
|
618
|
+
|
|
619
|
+
**Across waves:** After a wave completes, check which tasks in LATER waves have `depends_on` references to failed tasks:
|
|
620
|
+
1. Mark dependent tasks as `blocked`
|
|
621
|
+
2. Non-dependent tasks in later waves proceed normally
|
|
622
|
+
3. The pipeline does NOT stop entirely -- only the dependency chain of the failed task is blocked
|
|
623
|
+
|
|
624
|
+
Example:
|
|
625
|
+
```
|
|
626
|
+
Wave 1: [task-1 (SUCCESS), task-2 (FAILED)]
|
|
627
|
+
Wave 2: [task-3 depends_on task-1, task-4 depends_on task-2]
|
|
628
|
+
-> task-3 runs normally, task-4 is blocked
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
**Timeout handling:** Each parallel task gets a 10-minute timeout. If a task times out:
|
|
632
|
+
- Kill the process (`kill $PID`)
|
|
633
|
+
- Mark as `failed`
|
|
634
|
+
- Log: `[TIMEOUT] {task title} -- exceeded 10m, marked failed`
|
|
635
|
+
- Other parallel tasks in the wave are NOT affected
|
|
636
|
+
|
|
637
|
+
**Merge conflict recovery:** All parallel tasks work on the same working tree. If two tasks modify the same file (audit missed the overlap):
|
|
638
|
+
1. Last-write-wins on the working tree -- the second task's changes overwrite the first
|
|
639
|
+
2. The review phase catches inconsistencies -- the reviewer sees the full file including modifications from both tasks
|
|
640
|
+
3. If the reviewer flags a conflict, the fix cycle re-spawns the builder with the current file state
|
|
641
|
+
4. Worst case: one task's changes need re-application -- a single re-build, not a cascade
|
|
642
|
+
|
|
643
|
+
This is acceptable because the wave algorithm prevents most conflicts by construction (file overlap check), and reviews catch the rest.
|
|
644
|
+
|
|
645
|
+
Collect `proposed_improvements` from the engineer's build report. These are ideas the builder had while working -- features that should exist, edge cases not covered, UX gaps. Include them in the digest and present to the CEO in the wrapup step.
|
|
646
|
+
|
|
647
|
+
### Finalize project.json (after all tasks complete)
|
|
648
|
+
|
|
649
|
+
The project.json was created in the approve step (after CEO approval) with tasks in `pending` status. Now finalize it with execution results.
|
|
650
|
+
|
|
651
|
+
**For multi-project plans:** Repeat this finalization for EACH project's project.json. Multi-project plans create separate project directories at `.context/directives/{directive-id}/projects/{project-id}/` -- finalize each one independently.
|
|
652
|
+
|
|
653
|
+
1. **Read the existing project.json** -- for single-project plans: `.context/directives/{directive-id}/projects/{directive-name}/project.json`. For multi-project plans: `.context/directives/{directive-id}/projects/{project-id}/project.json` (one per project)
|
|
654
|
+
|
|
655
|
+
2. **Update each task** with execution results:
|
|
656
|
+
- `status`: `"completed"` | `"failed"` | `"partial"` | `"skipped"` | `"blocked"` based on task outcome
|
|
657
|
+
- `agent`: array of agent names who performed the work (from the cast -- NEVER leave as `[]` for completed tasks)
|
|
658
|
+
- `dod`: update each criterion's `met` from the reviewer's `dod_verification` output
|
|
659
|
+
|
|
660
|
+
3. **Update project-level DOD criteria** with verification results:
|
|
661
|
+
- `met`: true/false based on reviewer's `dod_verification` output
|
|
662
|
+
|
|
663
|
+
4. **Update project status**: if all tasks completed, set `"status": "completed"` and `"completed": "{current ISO timestamp}"`. Do NOT leave as `"in_progress"` when all work is done.
|
|
664
|
+
|
|
665
|
+
5. **If project.json doesn't exist** (legacy directive or pipeline error): create it from scratch using the COO's plan + execution results. Log a warning -- this should not happen if the approve step ran correctly.
|
|
666
|
+
|
|
667
|
+
6. **For each completed task, also update directive.json:**
|
|
668
|
+
- Add `goal-id/project-id` to `produced_projects` array
|
|
669
|
+
|
|
670
|
+
This ensures bidirectional links: project -> directive (via `source_directive`) and directive -> project (via `produced_projects`).
|
|
671
|
+
|
|
672
|
+
### Review-Gate: Review Verification (MANDATORY -- HARD GATE)
|
|
673
|
+
|
|
674
|
+
**Reviews MUST happen DURING execution, not after.** Each task's review phase runs immediately after its build phase, BEFORE the next task starts. The orchestrator MUST NOT batch all builds first and skip reviews -- that is the #1 failure mode (see Phase 3 post-mortem in lessons/agent-behavior.md).
|
|
675
|
+
|
|
676
|
+
**Execution loop for each task:**
|
|
677
|
+
1. Build phase -> spawn builder
|
|
678
|
+
2. Review phase -> spawn reviewer(s) from cast -- THIS IS NOT OPTIONAL
|
|
679
|
+
3. Fix cycle if review fails -> re-spawn builder with findings
|
|
680
|
+
4. Mark task complete only after review passes
|
|
681
|
+
5. Next task
|
|
682
|
+
|
|
683
|
+
**If the orchestrator realizes it skipped reviews after building multiple tasks**, it MUST stop and run reviews for all completed-but-unreviewed tasks before continuing. Do NOT finalize project.json until reviews are done.
|
|
684
|
+
|
|
685
|
+
**Post-execution hard gate -- run BEFORE finalizing project.json:**
|
|
686
|
+
|
|
687
|
+
```bash
|
|
688
|
+
echo '{"directive_dir":"'"$DIRECTIVE_DIR"'","directive_name":"'"$DIRECTIVE_NAME"'"}' | .claude/hooks/validate-reviews.sh
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
If `valid: false`, **STOP**. Do not finalize. Run the missing reviews first.
|
|
692
|
+
|
|
693
|
+
**Manual verification checklist** (the orchestrator must confirm each):
|
|
694
|
+
|
|
695
|
+
For each task that has status `completed` or `partial`:
|
|
696
|
+
|
|
697
|
+
1. **Was a reviewer agent spawned?** -- not "did I read the code myself" but "did I spawn the named reviewer from the cast"
|
|
698
|
+
2. **Did the reviewer produce a structured review output?** -- with `review_outcome`, `dod_verification`, `user_perspective` sections
|
|
699
|
+
3. **Did the reviewer's DOD verification mark each criterion?** -- not the builder self-certifying, not the orchestrator rubber-stamping
|
|
700
|
+
4. **For code-review phases: was a separate fresh-context review spawned?** -- builder != reviewer
|
|
701
|
+
|
|
702
|
+
**If any check fails:**
|
|
703
|
+
- Log which task is missing reviews: `[REVIEW MISSING] {task title} -- no review / no DOD verification`
|
|
704
|
+
- **Do NOT proceed to finalization.** Go back and run the missing review phase for that task.
|
|
705
|
+
- If the review was skipped because the build failed, that's acceptable -- log it and continue.
|
|
706
|
+
|
|
707
|
+
**If all checks pass:**
|
|
708
|
+
- Log: `[REVIEWS VERIFIED] All {N} tasks have review artifacts and DOD verification`
|
|
709
|
+
- Proceed to finalize project.json, then wrapup.
|