@tekyzinc/gsd-t 3.29.11 → 4.0.12
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/CHANGELOG.md +146 -0
- package/bin/gsd-t-parallel.cjs +64 -13
- package/bin/gsd-t.js +48 -376
- package/bin/journey-coverage.cjs +6 -3
- package/bin/parallel-cli.cjs +13 -1
- package/commands/gsd-t-debug.md +47 -533
- package/commands/gsd-t-design-decompose.md +24 -497
- package/commands/gsd-t-doc-ripple.md +23 -139
- package/commands/gsd-t-execute.md +41 -958
- package/commands/gsd-t-help.md +0 -2
- package/commands/gsd-t-impact.md +26 -295
- package/commands/gsd-t-integrate.md +44 -369
- package/commands/gsd-t-milestone.md +25 -124
- package/commands/gsd-t-partition.md +28 -539
- package/commands/gsd-t-plan.md +26 -472
- package/commands/gsd-t-prd.md +25 -311
- package/commands/gsd-t-quick.md +1 -1
- package/commands/gsd-t-resume.md +0 -33
- package/commands/gsd-t-verify.md +52 -569
- package/commands/gsd-t-wave.md +41 -430
- package/package.json +1 -1
- package/scripts/gsd-t-calibration-hook.js +3 -1
- package/scripts/hooks/pre-commit-journey-coverage +0 -2
- package/scripts/hooks/pre-commit-playwright-gate +0 -2
- package/templates/CLAUDE-global.md +43 -173
- package/templates/CLAUDE-project.md +118 -104
- package/templates/prompts/design-verify-subagent.md +3 -0
- package/templates/prompts/qa-subagent.md +3 -0
- package/templates/prompts/red-team-subagent.md +5 -2
- package/templates/workflows/_lib.js +176 -0
- package/templates/workflows/gsd-t-debug.workflow.js +86 -0
- package/templates/workflows/gsd-t-execute.workflow.js +206 -0
- package/templates/workflows/gsd-t-integrate.workflow.js +71 -0
- package/templates/workflows/gsd-t-phase.workflow.js +94 -0
- package/templates/workflows/gsd-t-quick.workflow.js +72 -0
- package/templates/workflows/gsd-t-verify.workflow.js +348 -0
- package/templates/workflows/gsd-t-wave.workflow.js +43 -0
- package/bin/check-headless-sessions.js +0 -140
- package/bin/context-budget-audit.cjs +0 -447
- package/bin/context-meter-config.cjs +0 -101
- package/bin/context-meter-config.test.cjs +0 -101
- package/bin/event-stream.cjs +0 -205
- package/bin/gsd-t-benchmark-orchestrator.js +0 -437
- package/bin/gsd-t-capture-lint.cjs +0 -440
- package/bin/gsd-t-economics.cjs +0 -315
- package/bin/gsd-t-in-session-usage.cjs +0 -213
- package/bin/gsd-t-orchestrator-config.cjs +0 -161
- package/bin/gsd-t-orchestrator-queue.cjs +0 -180
- package/bin/gsd-t-orchestrator-recover.cjs +0 -231
- package/bin/gsd-t-orchestrator-worker.cjs +0 -219
- package/bin/gsd-t-orchestrator.js +0 -535
- package/bin/gsd-t-parallel-probe.cjs +0 -132
- package/bin/gsd-t-ratelimit-probe-worker.cjs +0 -237
- package/bin/gsd-t-ratelimit-probe.cjs +0 -648
- package/bin/gsd-t-report-tokens.cjs +0 -549
- package/bin/gsd-t-stream-feed-client.cjs +0 -151
- package/bin/gsd-t-token-backfill.cjs +0 -366
- package/bin/gsd-t-token-capture.cjs +0 -321
- package/bin/gsd-t-token-dashboard.cjs +0 -353
- package/bin/gsd-t-token-regenerate-log.cjs +0 -129
- package/bin/gsd-t-tool-attribution.cjs +0 -377
- package/bin/gsd-t-tool-cost.cjs +0 -195
- package/bin/gsd-t-transcript-tee.cjs +0 -246
- package/bin/gsd-t-unattended-heartbeat.cjs +0 -188
- package/bin/gsd-t-unattended-platform.cjs +0 -551
- package/bin/gsd-t-unattended-platform.js +0 -381
- package/bin/gsd-t-unattended-safety.cjs +0 -773
- package/bin/gsd-t-unattended-safety.js +0 -788
- package/bin/gsd-t-unattended.cjs +0 -2109
- package/bin/gsd-t-unattended.js +0 -1367
- package/bin/gsd-t-worker-dispatch.cjs +0 -211
- package/bin/handoff-lock.cjs +0 -249
- package/bin/handoff-lock.js +0 -249
- package/bin/headless-auto-spawn.cjs +0 -711
- package/bin/headless-auto-spawn.js +0 -373
- package/bin/headless-exit-codes.cjs +0 -67
- package/bin/live-activity-report.cjs +0 -615
- package/bin/log-tail.cjs +0 -81
- package/bin/m44-proof-measure.cjs +0 -285
- package/bin/m46-iter-proof.cjs +0 -149
- package/bin/m46-worker-proof.cjs +0 -201
- package/bin/m55-substrate-proof.cjs +0 -134
- package/bin/metrics-rollup.js +0 -200
- package/bin/model-windows.cjs +0 -99
- package/bin/model-windows.test.cjs +0 -75
- package/bin/parallelism-report.cjs +0 -535
- package/bin/runway-estimator.cjs +0 -242
- package/bin/spawn-plan-derive.cjs +0 -163
- package/bin/spawn-plan-status-updater.cjs +0 -292
- package/bin/spawn-plan-writer.cjs +0 -204
- package/bin/supervisor-pid-fingerprint.cjs +0 -126
- package/bin/token-budget.cjs +0 -265
- package/bin/unattended-watch-format.cjs +0 -178
- package/bin/watch-progress.js +0 -155
- package/commands/gsd-t-unattended-stop.md +0 -85
- package/commands/gsd-t-unattended-watch.md +0 -465
- package/commands/gsd-t-unattended.md +0 -476
- package/commands/gsd-t-visualize.md +0 -116
- package/scripts/gsd-t-context-meter.e2e.test.js +0 -364
- package/scripts/gsd-t-context-meter.js +0 -341
- package/scripts/gsd-t-context-meter.test.js +0 -471
- package/scripts/gsd-t-dashboard-server.js +0 -1203
- package/scripts/gsd-t-post-commit-spawn-plan.sh +0 -86
- package/scripts/gsd-t-transcript.html +0 -1821
- package/scripts/hooks/gsd-t-conversation-capture.js +0 -439
- package/scripts/hooks/gsd-t-in-session-usage-hook.js +0 -84
- package/scripts/spawn-plan-fmt-tokens.cjs +0 -80
- package/templates/hooks/post-commit-spawn-plan.sh +0 -85
|
@@ -1,984 +1,67 @@
|
|
|
1
|
-
# GSD-T: Execute — Run Domain Tasks
|
|
1
|
+
# GSD-T: Execute — Run Domain Tasks
|
|
2
2
|
|
|
3
|
-
You are the lead agent
|
|
3
|
+
You are the lead agent. Execute the current milestone by invoking the canonical Workflow script at `templates/workflows/gsd-t-execute.workflow.js`.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## What this command does
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spawn Primitive — Always Headless (M43 D4, v2.0.0)
|
|
10
|
-
|
|
11
|
-
Per `.gsd-t/contracts/headless-default-contract.md` v2.0.0. Every Task-subagent spawn below goes headless unconditionally. Classification is kept only for downstream logging:
|
|
12
|
-
|
|
13
|
-
- `spawnType: 'primary'` — domain task-dispatcher (Step 3 fresh-dispatch)
|
|
14
|
-
- `spawnType: 'validation'` — Step 2 QA, Step 5.25 Design Verification, Step 5.5 Red Team, Step 7 doc-ripple
|
|
15
|
-
|
|
16
|
-
**Spawn path** (unconditional):
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
SESSION=$(node -e "
|
|
20
|
-
const has = require('./bin/headless-auto-spawn.cjs');
|
|
21
|
-
const r = has.autoSpawnHeadless({
|
|
22
|
-
command: 'gsd-t-execute',
|
|
23
|
-
args: [], // optional per-spawn args
|
|
24
|
-
projectDir: process.cwd(),
|
|
25
|
-
spawnType: '{primary|validation}',
|
|
26
|
-
sessionContext: { step: '{step-id}', domain: '{domain-name}', task: '{task-id}' }
|
|
27
|
-
});
|
|
28
|
-
process.stdout.write(JSON.stringify(r));
|
|
29
|
-
")
|
|
30
|
-
echo "⚙ [${MODEL:-sonnet}] gsd-t-execute → ${DESC:-subagent} (headless)"
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Then `bin/check-headless-sessions.js printBannerIfAny()` surfaces the completion on the next user message.
|
|
34
|
-
|
|
35
|
-
## Model Assignment
|
|
36
|
-
|
|
37
|
-
Per `.gsd-t/contracts/model-selection-contract.md` v1.0.0. Selection is deterministic via `bin/model-selector.js` — never runtime-overridden by context pressure.
|
|
38
|
-
|
|
39
|
-
- **Default**: `sonnet` — routine task execution (`selectModel({phase: "execute"})`). Sonnet is the M35 routine tier.
|
|
40
|
-
- **Mechanical subroutines** (demote to `haiku`):
|
|
41
|
-
- Test runners (`selectModel({phase: "execute", task_type: "test_runner"})`)
|
|
42
|
-
- Branch guards (`selectModel({phase: "execute", task_type: "branch_guard"})`)
|
|
43
|
-
- File-existence checks (`selectModel({phase: "execute", task_type: "file_check"})`)
|
|
44
|
-
- **QA subagent (Step 2)**: `sonnet` — evaluation needs judgment per M31 tier refinement (`selectModel({phase: "execute", task_type: "qa"})`).
|
|
45
|
-
- **Red Team (Step 5.5)**: `opus` — adversarial reasoning benefits most from top tier (`selectModel({phase: "execute", task_type: "red_team"})`).
|
|
46
|
-
- **Escalation points**: at any declared high-stakes sub-decision (cross-module refactor, contract design, security-boundary change), invoke the convention-based `/advisor` fallback from `bin/advisor-integration.js`. If the `/advisor` tool is unavailable, the caller proceeds at the assigned model and logs a missed escalation to `.gsd-t/token-log.md` (see `.gsd-t/M35-advisor-findings.md`). Never silently downgrade the model or skip Red Team / doc-ripple under context pressure — M35 removed that behavior.
|
|
47
|
-
|
|
48
|
-
## Step 0.1: Verify Context Gate Readiness (MANDATORY — first thing in a fresh session)
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 0 --step-label ".1: Verify Context Gate Readiness (MANDATORY — first thing in a fresh session)" 2>/dev/null || true
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Run via Bash:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
node -e "const tb = require('./bin/token-budget.cjs'); const s = tb.getSessionStatus('.'); console.log(JSON.stringify(s));"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
This calls `getSessionStatus()` (v2.0.0) which reads `.gsd-t/.context-meter-state.json` produced by the Context Meter PostToolUse hook. If the state file is fresh (timestamp within 5 min), you get real `pct` and `threshold` values; if missing or stale, the call falls back to the historical heuristic from `.gsd-t/token-log.md`.
|
|
61
|
-
|
|
62
|
-
Use the returned `threshold` as the gate signal for the rest of this run. The gate logic is in Step 3.5; do NOT skip it. If the Context Meter hook isn't installed (`.gsd-t/.context-meter-state.json` missing and doctor reports it), run `gsd-t doctor` to diagnose — the gate still works via the heuristic fallback but real-time readings give much better guardrails.
|
|
63
|
-
|
|
64
|
-
Why: every `/gsd-t-execute` invocation is a fresh orchestrator session and needs a current reading of context utilization before spawning any subagents. The authoritative source is the Context Meter state file; the fallback keeps the gate functional on projects that haven't installed the hook yet.
|
|
65
|
-
|
|
66
|
-
## Step 1: Load State
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 1 --step-label "Load State" 2>/dev/null || true
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Read:
|
|
73
|
-
1. `CLAUDE.md` — check for **Branch Guard** (`Expected branch` field)
|
|
74
|
-
2. `.gsd-t/progress.md`
|
|
75
|
-
3. `.gsd-t/contracts/` — all contracts
|
|
76
|
-
4. `.gsd-t/contracts/integration-points.md` — dependency graph
|
|
77
|
-
5. `.gsd-t/domains/*/tasks.md` — all task lists
|
|
78
|
-
|
|
79
|
-
**Branch check (before any work):**
|
|
80
|
-
Run `git branch --show-current`. If CLAUDE.md declares an expected branch and you're on a different branch, STOP and warn the user. Do NOT execute tasks on the wrong branch.
|
|
81
|
-
|
|
82
|
-
Identify:
|
|
83
|
-
- Which tasks are already complete (check progress.md)
|
|
84
|
-
- Which tasks are unblocked (no pending dependencies)
|
|
85
|
-
- Which tasks are blocked (waiting on checkpoints)
|
|
86
|
-
|
|
87
|
-
<!-- M55-D5: preflight + brief wire-in -->
|
|
88
|
-
**M55 Preflight + Context-Brief (mandatory before fan-out):**
|
|
89
|
-
|
|
90
|
-
Once per execute invocation, before spawning ANY worker subagent:
|
|
91
|
-
|
|
92
|
-
1. Run state preflight:
|
|
93
|
-
```bash
|
|
94
|
-
gsd-t preflight --json > /tmp/gsd-t-preflight.json || true
|
|
95
|
-
```
|
|
96
|
-
If exit code is `4`, STOP. Read `/tmp/gsd-t-preflight.json`, surface the failed
|
|
97
|
-
`severity:"error"` checks (wrong branch, occupied port, etc.) to the user, and
|
|
98
|
-
do NOT spawn any workers. The verify-gate (Track 1) will hard-fail the same
|
|
99
|
-
way at verify time — fail-early here saves the round-trip.
|
|
100
|
-
|
|
101
|
-
2. For each domain `D` about to receive a worker spawn, generate a context brief
|
|
102
|
-
ONCE per domain per spawn (replaces 30–60k context re-read with ≤2,500-token
|
|
103
|
-
JSON snapshot — M55 charter Pattern B):
|
|
104
|
-
```bash
|
|
105
|
-
SPAWN_ID="execute-${D}-$(date -u +%Y%m%dT%H%M%SZ)"
|
|
106
|
-
gsd-t brief --kind execute --domain "${D}" --spawn-id "${SPAWN_ID}" --out ".gsd-t/briefs/${SPAWN_ID}.json"
|
|
107
|
-
export BRIEF_PATH=".gsd-t/briefs/${SPAWN_ID}.json"
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
3. Pass `$BRIEF_PATH` into each worker's prompt scaffold so the worker greps the
|
|
111
|
-
brief instead of re-walking the repo. Workers receive the canonical
|
|
112
|
-
instruction "check the brief first" via the subagent protocols
|
|
113
|
-
(`templates/prompts/{qa,red-team,design-verify}-subagent.md`).
|
|
114
|
-
|
|
115
|
-
The `.gsd-t/briefs/` directory is gitignored — briefs are per-spawn ephemera,
|
|
116
|
-
not committed artifacts.
|
|
117
|
-
|
|
118
|
-
## Step 1.5: Graph-Enhanced Domain Isolation Check (if available)
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 1 --step-label ".5: Graph-Enhanced Domain Isolation Check (if available)" 2>/dev/null || true
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
If `.gsd-t/graph/meta.json` exists, run graph queries before execution begins:
|
|
125
|
-
|
|
126
|
-
1. **Reindex** (if stale): `query('reindex', { force: false })` — ensure graph reflects current code
|
|
127
|
-
2. **Domain boundary check**: For each domain about to execute, `query('getEntitiesByDomain', { domain })` — verify the domain's entities match its scope.md
|
|
128
|
-
3. **Pre-execution snapshot**: Record entity counts per domain — after execution, compare to detect scope creep (domain agent modified entities outside its domain)
|
|
129
|
-
4. **Cross-domain dependencies**: `query('getDomainBoundaryViolations', {})` — flag existing violations before work begins so they aren't confused with new violations introduced during execution
|
|
130
|
-
|
|
131
|
-
After each domain completes, re-run `getDomainBoundaryViolations` and diff against pre-execution snapshot. If new violations appear, flag them immediately before proceeding to the next domain.
|
|
132
|
-
|
|
133
|
-
## Step 2: QA Subagent
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 2 --step-label "QA Subagent" 2>/dev/null || true
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
In solo mode, QA runs inside each domain subagent (see Step 3). In team mode, the lead spawns QA subagents at each domain checkpoint using the pattern below.
|
|
140
|
-
|
|
141
|
-
**QA subagent prompt** — `spawnType: 'validation'` (always headless per headless-default-contract v2.0.0):
|
|
142
|
-
```
|
|
143
|
-
Task subagent (spawnType: validation, general-purpose, model: sonnet):
|
|
144
|
-
"Run the full test suite for this project and report pass/fail counts.
|
|
145
|
-
Read .gsd-t/contracts/ for contract definitions.
|
|
146
|
-
Write edge case tests for any new code paths in this task: {task description}.
|
|
147
|
-
Report: test pass/fail status and any coverage gaps found."
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
If QA found issues, append each to `.gsd-t/qa-issues.md` (create with header `| Date | Command | Step | Model | Duration(s) | Severity | Finding |` if missing):
|
|
151
|
-
`| {DT_START} | gsd-t-execute | Step 2 | haiku | {DURATION}s | {severity} | {finding} |`
|
|
152
|
-
|
|
153
|
-
## Step 3: Choose Execution Mode
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 3 --step-label "Choose Execution Mode" 2>/dev/null || true
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Parallel Dispatch (MANDATORY — single instrument)
|
|
160
|
-
|
|
161
|
-
Delegate the parallel-vs-sequential decision to `gsd-t parallel --command` — do NOT re-implement probe-and-branch logic here. The CLI is the single instrument per M44 D9 Step 3 (user directive: "create 1 instrument that accomplishes this instead of implementing it in all the commands").
|
|
162
|
-
|
|
163
|
-
```bash
|
|
164
|
-
node bin/gsd-t.js parallel --milestone {milestone} --command gsd-t-execute && exit 0 || true
|
|
165
|
-
# Exit 0 → fan-out happened; N detached headless children are running
|
|
166
|
-
# disjoint task subsets. This agent is done.
|
|
167
|
-
# Exit 2 → sequential (N<2 or gate veto). Fall through to Wave Scheduling below.
|
|
168
|
-
# Exit 3+ → invalid/other; fall through to sequential.
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
The CLI internally runs `runDispatch()` which: (1) probes the planner via `runParallel({dryRun:true})`, (2) if `workerCount ≥ 2` with D4/D5/D6 gates green, partitions task ids round-robin and spawns N detached headless children via `autoSpawnHeadless()` — each gets `GSD_T_WORKER_TASK_IDS`/`_WORKER_INDEX`/`_WORKER_TOTAL` env vars so the child handles only its assigned subset, (3) else exits 2 so this agent falls through to the legacy single-worker path. Mode is auto-detected from `GSD_T_UNATTENDED=1`. No user prompt. No opt-out flag (parallel-when-safe + headless-when-possible are both the default per headless-default-contract v2.0.0).
|
|
172
|
-
|
|
173
|
-
Contract: `.gsd-t/contracts/wave-join-contract.md` v1.1.0; `.gsd-t/contracts/headless-default-contract.md` v2.0.0.
|
|
174
|
-
|
|
175
|
-
### Wave Scheduling (read first)
|
|
176
|
-
|
|
177
|
-
Before choosing solo or team mode, read the `## Wave Execution Groups` section in `.gsd-t/contracts/integration-points.md` (added by the plan phase).
|
|
178
|
-
|
|
179
|
-
**If wave groups are present**:
|
|
180
|
-
- Execute wave-by-wave: complete all tasks in Wave 1 before starting Wave 2
|
|
181
|
-
- Within each wave, tasks marked as parallel-safe can run concurrently (team mode) or be interleaved (solo mode)
|
|
182
|
-
- At each wave boundary: run the CHECKPOINT — verify contract compliance — before proceeding
|
|
183
|
-
- **Design Hierarchy Checkpoint** (when `.gsd-t/contracts/design/INDEX.md` exists):
|
|
184
|
-
At each wave boundary for design hierarchy waves (elements → widgets → pages):
|
|
185
|
-
- **After element wave**: For each built element component, verify it renders and matches
|
|
186
|
-
its element contract (chart type, dimensions, colors, props). Spot-check in a browser
|
|
187
|
-
or headless render. Any element that doesn't match its contract → fix before widget wave.
|
|
188
|
-
- **After widget wave**: For each built widget, verify it imports (not rebuilds) its element
|
|
189
|
-
components and assembles them per the widget contract layout. Check: does the widget
|
|
190
|
-
import from src/components/elements/? If it contains inline chart/card implementations
|
|
191
|
-
that duplicate element components → FAIL the checkpoint, fix before page wave.
|
|
192
|
-
- **After page wave**: Proceed to full Design Verification Agent (Step 5.25) for Figma comparison.
|
|
193
|
-
These checkpoints are MANDATORY gates — not advisory. The entire point of hierarchical
|
|
194
|
-
execution is that each layer is correct before the next layer builds on it.
|
|
195
|
-
- File conflict detection: if two tasks in the same wave list the same file in their `scope.md` ownership, move one to the next wave
|
|
196
|
-
|
|
197
|
-
**If no wave groups are defined** (older plans): fall back to the `Execution Order` list.
|
|
198
|
-
|
|
199
|
-
### Solo Mode (default) — Domain Task-Dispatcher Pattern
|
|
200
|
-
|
|
201
|
-
Each domain's work runs via a lightweight domain task-dispatcher. The dispatcher spawns one Task subagent PER TASK within that domain, giving each task a completely fresh context window with only the minimum required context. The orchestrator (this agent) stays lightweight — it only spawns dispatchers, collects summaries, verifies checkpoints, and updates progress.
|
|
202
|
-
|
|
203
|
-
**Context provided to each task subagent (fresh-dispatch-contract.md payload):**
|
|
204
|
-
- `scope.md` for the domain
|
|
205
|
-
- Relevant contracts (only those referenced by the task)
|
|
206
|
-
- The single task from `tasks.md`
|
|
207
|
-
- Graph context for the task's files (if available)
|
|
208
|
-
- Up to 5 prior task summaries (10-20 lines each, most recent first)
|
|
209
|
-
- Past failure/learning entries for this domain (max 5 lines)
|
|
210
|
-
|
|
211
|
-
**OBSERVABILITY LOGGING (MANDATORY) — wrap every task subagent spawn with `captureSpawn`:**
|
|
212
|
-
|
|
213
|
-
Route the spawn through `bin/gsd-t-token-capture.cjs` so the real `usage` envelope is parsed. The wrapper owns banner + timing + envelope parse + row write + JSONL record. Example for a per-task dispatch:
|
|
7
|
+
Replaces the M40-era orchestrator/worker/parallel/spawn-plan shell with a single deterministic Workflow:
|
|
214
8
|
|
|
215
9
|
```
|
|
216
|
-
|
|
217
|
-
const { captureSpawn } = require('./bin/gsd-t-token-capture.cjs');
|
|
218
|
-
(async () => {
|
|
219
|
-
await captureSpawn({
|
|
220
|
-
command: 'gsd-t-execute',
|
|
221
|
-
step: 'task:{task-id}',
|
|
222
|
-
model: 'sonnet',
|
|
223
|
-
description: 'domain: {domain-name} task: {task-id}',
|
|
224
|
-
projectDir: '.',
|
|
225
|
-
domain: '{domain-name}',
|
|
226
|
-
task: '{task-id}',
|
|
227
|
-
notes: '{pass/fail}',
|
|
228
|
-
spawnFn: async () => { /* Task(...) or spawn('claude', ...) call */ },
|
|
229
|
-
});
|
|
230
|
-
})();
|
|
231
|
-
"
|
|
10
|
+
preflight → brief → file-disjointness → parallel(domain workers) → integrate → verify-gate
|
|
232
11
|
```
|
|
233
12
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
**For each domain (in wave order), run the domain task-dispatcher:**
|
|
237
|
-
|
|
238
|
-
**Token Budget Check (before dispatching each domain's tasks):**
|
|
239
|
-
|
|
240
|
-
Run via Bash:
|
|
241
|
-
`node -e "const tb = require('./bin/token-budget.cjs'); const s = tb.getSessionStatus('.'); process.stdout.write(JSON.stringify(s));" 2>/dev/null`
|
|
242
|
-
|
|
243
|
-
Capture `pct` as `{CTX_PCT}` for the token-log `Ctx%` column on the next spawn. The reading is observational only — under headless-default-contract v2.0.0 the spawn decision is no longer gated on `threshold`; every task-dispatcher spawn goes through `autoSpawnHeadless()` regardless of band.
|
|
244
|
-
|
|
245
|
-
**Pre-dispatch experience retrieval (before dispatching each domain's tasks):**
|
|
246
|
-
Run via Bash:
|
|
247
|
-
`grep -i "\[failure\]\|\[learning\]" .gsd-t/progress.md | grep -i "{domain-name}" | tail -5`
|
|
248
|
-
|
|
249
|
-
If results found:
|
|
250
|
-
- Store as `PAST_FAILURES` — prepend to each task subagent prompt (max 5 lines)
|
|
251
|
-
- Write event via Bash: `node ~/.claude/scripts/gsd-t-event-writer.js --type experience_retrieval --command gsd-t-execute --reasoning "{N past failures found for {domain-name}}" --outcome null || true`
|
|
13
|
+
Each domain worker is a schema-validated `agent()` call. Domain workers run concurrently up to the Workflow runtime's concurrency cap. File-disjointness is proved BEFORE fan-out as defense in depth. The brief (M55-D2) is generated once and threaded into every worker.
|
|
252
14
|
|
|
253
|
-
|
|
15
|
+
## Step 1: Read the current milestone state
|
|
254
16
|
|
|
255
|
-
|
|
256
|
-
Run via Bash:
|
|
257
|
-
`node -e "const m = require('./bin/metrics-collector.js'); const w = m.getPreFlightWarnings('{domain-name}'); if(w.length) w.forEach(x => console.log('⚠️ ' + x));" 2>/dev/null || true`
|
|
17
|
+
Read `.gsd-t/progress.md` to determine the active milestone. Read each domain's `tasks.md` to determine the worker set. Use the domain list from `.gsd-t/contracts/m{NN}-integration-points.md` for the current wave, NOT the full domain set.
|
|
258
18
|
|
|
259
|
-
|
|
19
|
+
## Step 2: Invoke the execute Workflow
|
|
260
20
|
|
|
261
|
-
|
|
262
|
-
Run via Bash:
|
|
263
|
-
`node -e "const re = require('./bin/rule-engine.js'); const m = re.evaluateRules('{domain-name}', { projectDir: '.' }); if(m.length) m.forEach(x => console.log('RULE: ' + x.rule.name + ' — ' + x.rule.description + ' [' + x.severity + ']')); else console.log('No active rules for {domain-name}');" 2>/dev/null || true`
|
|
21
|
+
Call the `Workflow` tool with:
|
|
264
22
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
STACKS_DIR="$GSD_T_DIR/templates/stacks"
|
|
275
|
-
LOCAL_STACKS=".gsd-t/stacks"
|
|
276
|
-
STACK_RULES=""
|
|
277
|
-
|
|
278
|
-
# Helper: read local override if exists, else global
|
|
279
|
-
_sf() { local n=$(basename "$1"); [ -f "$LOCAL_STACKS/$n" ] && cat "$LOCAL_STACKS/$n" || cat "$1"; }
|
|
280
|
-
|
|
281
|
-
# Helper: append a stack file to STACK_RULES
|
|
282
|
-
_add() { [ -f "$STACKS_DIR/$1" ] && STACK_RULES="${STACK_RULES}$(_sf "$STACKS_DIR/$1")"$'\n\n'; }
|
|
283
|
-
|
|
284
|
-
if [ -d "$STACKS_DIR" ]; then
|
|
285
|
-
# Universal rules (_ prefix — always injected)
|
|
286
|
-
for f in "$STACKS_DIR"/_*.md; do [ -f "$f" ] && STACK_RULES="${STACK_RULES}$(_sf "$f")"$'\n\n'; done
|
|
287
|
-
|
|
288
|
-
# Package.json-based detection
|
|
289
|
-
if [ -f "package.json" ]; then
|
|
290
|
-
grep -q '"react-native"' package.json 2>/dev/null && _add react-native.md
|
|
291
|
-
grep -q '"react"' package.json 2>/dev/null && ! grep -q '"react-native"' package.json 2>/dev/null && _add react.md
|
|
292
|
-
grep -q '"next"' package.json 2>/dev/null && _add nextjs.md
|
|
293
|
-
grep -q '"vue"' package.json 2>/dev/null && _add vue.md
|
|
294
|
-
(grep -q '"typescript"' package.json 2>/dev/null || [ -f "tsconfig.json" ]) && _add typescript.md
|
|
295
|
-
grep -qE '"(express|fastify|hono|koa)"' package.json 2>/dev/null && _add node-api.md && _add rest-api.md
|
|
296
|
-
grep -q '"tailwindcss"' package.json 2>/dev/null && _add tailwind.md
|
|
297
|
-
grep -q '"vite"' package.json 2>/dev/null && _add vite.md
|
|
298
|
-
grep -q '"@supabase/supabase-js"' package.json 2>/dev/null && _add supabase.md
|
|
299
|
-
grep -q '"firebase"' package.json 2>/dev/null && _add firebase.md
|
|
300
|
-
grep -qE '"(graphql|@apollo/client|urql)"' package.json 2>/dev/null && _add graphql.md
|
|
301
|
-
grep -q '"zustand"' package.json 2>/dev/null && _add zustand.md
|
|
302
|
-
grep -q '"@reduxjs/toolkit"' package.json 2>/dev/null && _add redux.md
|
|
303
|
-
grep -q '"neo4j-driver"' package.json 2>/dev/null && _add neo4j.md
|
|
304
|
-
grep -qE '"(pg|prisma|drizzle-orm|knex)"' package.json 2>/dev/null && _add postgresql.md
|
|
305
|
-
grep -qE '"(prisma|@prisma/client)"' package.json 2>/dev/null && _add prisma.md
|
|
306
|
-
grep -qE '"(bullmq|bull|amqplib|@aws-sdk/client-sqs|bee-queue|agenda)"' package.json 2>/dev/null && _add queues.md
|
|
307
|
-
grep -qE '"(openai|anthropic|@anthropic-ai/sdk|langchain|llama-index|@google/generative-ai)"' package.json 2>/dev/null && _add llm.md
|
|
308
|
-
fi
|
|
309
|
-
|
|
310
|
-
# File-based detection (no package.json needed)
|
|
311
|
-
([ -f "requirements.txt" ] || [ -f "pyproject.toml" ] || [ -f "Pipfile" ]) && _add python.md
|
|
312
|
-
([ -f "requirements.txt" ] && grep -q "psycopg" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -q "psycopg" pyproject.toml 2>/dev/null) && _add postgresql.md
|
|
313
|
-
([ -f "requirements.txt" ] && grep -q "neo4j" requirements.txt 2>/dev/null) && _add neo4j.md
|
|
314
|
-
([ -f "requirements.txt" ] && grep -q "fastapi" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -q "fastapi" pyproject.toml 2>/dev/null) && _add fastapi.md
|
|
315
|
-
([ -f "requirements.txt" ] && grep -qE "(celery|dramatiq|rq|arq)" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -qE "(celery|dramatiq|rq|arq)" pyproject.toml 2>/dev/null) && _add queues.md
|
|
316
|
-
([ -f "requirements.txt" ] && grep -qE "(openai|anthropic|langchain|llama.index)" requirements.txt 2>/dev/null || [ -f "pyproject.toml" ] && grep -qE "(openai|anthropic|langchain|llama.index)" pyproject.toml 2>/dev/null) && _add llm.md
|
|
317
|
-
[ -f "pubspec.yaml" ] && _add flutter.md
|
|
318
|
-
[ -f "Dockerfile" ] && _add docker.md
|
|
319
|
-
[ -d ".github/workflows" ] && _add github-actions.md
|
|
320
|
-
([ -f "playwright.config.ts" ] || [ -f "playwright.config.js" ]) && _add playwright.md
|
|
321
|
-
[ -f "go.mod" ] && _add go.md
|
|
322
|
-
[ -f "Cargo.toml" ] && _add rust.md
|
|
323
|
-
# Design-to-code detection (design contract, design tokens, Figma config, or Figma MCP configured)
|
|
324
|
-
([ -f ".gsd-t/contracts/design-contract.md" ] || [ -f "design-tokens.json" ] || [ -d "design-tokens" ] || [ -f ".figmarc" ] || [ -f "figma.config.json" ] || grep -q '"figma"' ~/.claude/settings.json 2>/dev/null) && _add design-to-code.md
|
|
325
|
-
fi
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
If STACK_RULES is non-empty, append to the subagent prompt:
|
|
23
|
+
```js
|
|
24
|
+
{
|
|
25
|
+
scriptPath: "templates/workflows/gsd-t-execute.workflow.js",
|
|
26
|
+
args: {
|
|
27
|
+
milestone: "M{NN}",
|
|
28
|
+
domains: ["m{NN}-d1-...", "m{NN}-d2-...", ...],
|
|
29
|
+
projectDir: "."
|
|
30
|
+
}
|
|
31
|
+
}
|
|
329
32
|
```
|
|
330
|
-
## Stack Rules (MANDATORY — violations fail this task)
|
|
331
|
-
|
|
332
|
-
{STACK_RULES}
|
|
333
|
-
|
|
334
|
-
These standards have the same enforcement weight as contract compliance.
|
|
335
|
-
Violations are task failures, not warnings.
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
If STACK_RULES is empty (no templates/stacks/ dir or no matches), skip silently.
|
|
339
33
|
|
|
340
|
-
|
|
34
|
+
The Workflow handles preflight, brief generation, file-disjointness validation, parallel domain workers, integrate barrier, and verify-gate. Each stage emits a progress line visible via `/workflows`. The runtime persists the script path on every invocation; iterate by editing the persisted file and re-invoking with the same `scriptPath`.
|
|
341
35
|
|
|
342
|
-
|
|
36
|
+
## Step 3: Interpret the result
|
|
343
37
|
|
|
344
|
-
|
|
345
|
-
2. Load graph context (if `.gsd-t/graph/meta.json` exists): query task's files for relevant graph context
|
|
346
|
-
3. Display: `⚙ [sonnet] gsd-t-execute → domain: {domain-name}, task-{task-id}`
|
|
347
|
-
4. Run observability Bash (T_START / DT_START)
|
|
348
|
-
5. Spawn task subagent — `spawnType: 'primary'` (always headless per headless-default-contract v2.0.0):
|
|
38
|
+
The Workflow returns:
|
|
349
39
|
|
|
40
|
+
```js
|
|
41
|
+
{
|
|
42
|
+
status: "complete" | "verify-failed" | "failed",
|
|
43
|
+
milestone: "M{NN}",
|
|
44
|
+
domainResults: [{ domain, status, filesTouched, tasksDone, tasksBlocked, notes }, ...],
|
|
45
|
+
integrate: { status, crossDomainEdits, notes },
|
|
46
|
+
verifyGate: { ok, track1, track2, ... }
|
|
47
|
+
}
|
|
350
48
|
```
|
|
351
|
-
Task subagent (spawnType: primary, general-purpose, model: sonnet, mode: bypassPermissions):
|
|
352
|
-
"You are executing a single task for the {domain-name} domain.
|
|
353
|
-
|
|
354
|
-
{PAST_FAILURES block if any — ## ⚠️ Past Failures (read before acting)\n{lines}}
|
|
355
|
-
|
|
356
|
-
## Your Task
|
|
357
|
-
{full task block from tasks.md — id, description, files, contract refs, dependencies, acceptance criteria}
|
|
358
|
-
|
|
359
|
-
## Domain Scope
|
|
360
|
-
{contents of .gsd-t/domains/{domain-name}/scope.md}
|
|
361
|
-
|
|
362
|
-
## Relevant Contracts
|
|
363
|
-
{contents of each contract file referenced by this task}
|
|
364
|
-
|
|
365
|
-
## Graph Context (if available)
|
|
366
|
-
{graph query results for this task's files — omit section if unavailable}
|
|
367
|
-
|
|
368
|
-
## Prior Task Summaries (most recent first, max 5)
|
|
369
|
-
{contents of task-{N}-summary.md files — 10-20 lines each}
|
|
370
|
-
|
|
371
|
-
## Stack Rules
|
|
372
|
-
{STACK_RULES if non-empty — omit entire section if empty}
|
|
373
|
-
|
|
374
|
-
## Instructions
|
|
375
|
-
|
|
376
|
-
Execute the task above:
|
|
377
|
-
1. Read the task description, files list, and contract refs carefully
|
|
378
|
-
2. Read relevant contracts — implement EXACTLY what they specify
|
|
379
|
-
3. Destructive Action Guard: if the task involves DROP TABLE, schema changes that lose
|
|
380
|
-
data, removing working modules, or replacing architecture patterns → write a
|
|
381
|
-
NEEDS-APPROVAL entry to .gsd-t/deferred-items.md, skip the task, stop here
|
|
382
|
-
4. **Design Hierarchy Build Rule** (if this task references a design contract):
|
|
383
|
-
- If building an ELEMENT: implement ONLY this element's contract. Use exact values —
|
|
384
|
-
every dimension, color, font size, spacing must trace to the contract or design tokens.
|
|
385
|
-
No guessed values. Render in isolation to confirm before finishing.
|
|
386
|
-
- If building a WIDGET: check src/components/elements/ for already-built element
|
|
387
|
-
components. IMPORT them — do NOT rebuild element functionality inline. If the widget
|
|
388
|
-
contract says 'uses chart-donut', import the chart-donut element. Building a second
|
|
389
|
-
donut implementation inline is a TASK FAILURE.
|
|
390
|
-
- If building a PAGE: check src/components/widgets/ for already-built widget components.
|
|
391
|
-
IMPORT them — do NOT rebuild widget functionality inline. The page's job is composition
|
|
392
|
-
and data wiring, not reimplementing widgets.
|
|
393
|
-
- **Contract is authoritative**: If the element contract says 'bar-vertical-grouped'
|
|
394
|
-
(vertical bars), build vertical bars — even if the Figma screenshot looks like it
|
|
395
|
-
could be horizontal. The contract was written from careful design analysis; the
|
|
396
|
-
screenshot is ambiguous at small sizes. When in doubt, follow the contract.
|
|
397
|
-
5. Implement the task
|
|
398
|
-
6. Verify acceptance criteria are met
|
|
399
|
-
7. Write comprehensive tests (MANDATORY — no feature code without test code):
|
|
400
|
-
- Unit/integration: happy path + edge cases + error cases for every new/changed function
|
|
401
|
-
- Playwright E2E (if UI/routes/flows changed): new specs for new features, cover
|
|
402
|
-
all modes, form validation, empty/loading/error states, common edge cases
|
|
403
|
-
- If no test framework exists: set one up as part of this task
|
|
404
|
-
- If the project has a UI but no Playwright E2E specs exist for the features being
|
|
405
|
-
touched: WRITE THEM. A placeholder spec is not sufficient — write real E2E tests
|
|
406
|
-
that exercise the actual UI functionality being built or changed.
|
|
407
|
-
- **FUNCTIONAL E2E TESTS — NOT LAYOUT TESTS (MANDATORY)**:
|
|
408
|
-
E2E tests that only check element existence (isVisible, isEnabled, toBeAttached)
|
|
409
|
-
are LAYOUT tests, not functional tests. Layout tests pass even when every feature
|
|
410
|
-
is broken. Every Playwright spec MUST verify functional behavior:
|
|
411
|
-
a. **State changes**: After an action (click, type, submit), assert the app STATE
|
|
412
|
-
changed — not just that the button was clickable. Example: clicking a tab must
|
|
413
|
-
load different content; verify the content changed, not just that the tab exists.
|
|
414
|
-
b. **Data flow**: Form submissions must verify data arrived (API call made, response
|
|
415
|
-
rendered, list updated). Don't just assert the form rendered.
|
|
416
|
-
c. **Navigation/routing**: Tab/page switches must verify the NEW content loaded.
|
|
417
|
-
Assert on content unique to the destination, not the navigation element itself.
|
|
418
|
-
d. **Interactive widgets**: Terminals must accept input and produce output. Editors
|
|
419
|
-
must save changes. Panels must load their functional content after opening.
|
|
420
|
-
e. **Network integration**: If a feature requires WebSocket/API connection, verify
|
|
421
|
-
the connection status changes (e.g., "Disconnected" → "Connected") and that
|
|
422
|
-
messages flow through the connection.
|
|
423
|
-
f. **Error recovery**: Don't just check error messages render — verify the app
|
|
424
|
-
recovers (retry button works, form can be resubmitted, etc.).
|
|
425
|
-
A test that would pass on an empty HTML page with the right element IDs is useless.
|
|
426
|
-
Every assertion must prove the FEATURE WORKS, not that the ELEMENT EXISTS.
|
|
427
|
-
8. **Render-Measure-Compare Loop** (when design-to-code stack rule is active — MANDATORY):
|
|
428
|
-
After implementing the component, you MUST verify it renders correctly by measuring
|
|
429
|
-
the actual DOM output against the contract's layout spec. This is not optional.
|
|
430
|
-
Do NOT rely on visual inspection or screenshots — measure mechanically.
|
|
431
|
-
|
|
432
|
-
a. **Render**: Start the dev server if not running. Navigate to a route where the
|
|
433
|
-
component is visible (or create a temporary test route that renders it in isolation).
|
|
434
|
-
|
|
435
|
-
b. **Measure via Playwright** — run `page.evaluate()` to extract DOM properties:
|
|
436
|
-
```javascript
|
|
437
|
-
// For a widget: measure its internal layout
|
|
438
|
-
const el = document.querySelector('.widget-selector');
|
|
439
|
-
const style = getComputedStyle(el);
|
|
440
|
-
return {
|
|
441
|
-
display: style.display, // 'flex' or 'grid'
|
|
442
|
-
flexDirection: style.flexDirection, // 'row' or 'column'
|
|
443
|
-
gap: style.gap,
|
|
444
|
-
gridTemplateColumns: style.gridTemplateColumns,
|
|
445
|
-
width: el.offsetWidth,
|
|
446
|
-
height: el.offsetHeight,
|
|
447
|
-
childCount: el.children.length,
|
|
448
|
-
children: Array.from(el.children).map(c => ({
|
|
449
|
-
tag: c.tagName,
|
|
450
|
-
width: c.offsetWidth,
|
|
451
|
-
height: c.offsetHeight,
|
|
452
|
-
display: getComputedStyle(c).display,
|
|
453
|
-
flexDirection: getComputedStyle(c).flexDirection,
|
|
454
|
-
}))
|
|
455
|
-
};
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
c. **Compare to contract** — check each measured value against the contract spec:
|
|
459
|
-
- `body_layout: flex-row` → verify `flexDirection === 'row'`
|
|
460
|
-
- `container_height: 334px` → verify `height === 334` (±2px tolerance)
|
|
461
|
-
- Grid `2×2` → verify parent has 2 row children, each with 2 card children
|
|
462
|
-
- Legend position: if contract says `body_sidebar` (beside chart) →
|
|
463
|
-
verify legend and chart share a `flex-row` parent.
|
|
464
|
-
If contract says `footer_legend` (below chart) →
|
|
465
|
-
verify legend is in a `flex-column` parent below the chart.
|
|
466
|
-
|
|
467
|
-
d. **Fix mismatches** — if ANY measurement doesn't match the contract:
|
|
468
|
-
- Log: "LAYOUT MISMATCH: {property} expected {contract value}, got {measured value}"
|
|
469
|
-
- Fix the code to match the contract spec
|
|
470
|
-
- Re-render and re-measure (max 2 fix cycles)
|
|
471
|
-
- If still mismatched after 2 cycles → log to `.gsd-t/deferred-items.md`
|
|
472
|
-
|
|
473
|
-
e. **All pass** → log "RENDER-MEASURE PASS: {N} layout properties verified" and proceed.
|
|
474
|
-
|
|
475
|
-
This loop catches the exact class of errors that visual inspection misses:
|
|
476
|
-
grid-cols-4 instead of 2×2, legend below instead of beside, wrong flex-direction.
|
|
477
|
-
These are data comparisons, not visual judgments — the same kind of check as a unit test.
|
|
478
|
-
9. Run ALL test suites — this is NOT optional, not conditional, not "if applicable":
|
|
479
|
-
a. Detect configured test runners: check for vitest/jest config, playwright.config.*, cypress.config.*
|
|
480
|
-
b. Run EVERY detected suite. Unit tests alone are NEVER sufficient when E2E exists.
|
|
481
|
-
c. If `playwright.config.*` exists → run `npx playwright test` (full suite, not just affected specs)
|
|
482
|
-
d. If E2E tests fail → fix (up to 2 attempts) before proceeding
|
|
483
|
-
e. Report ALL suite results: "Unit: X/Y pass | E2E: X/Y pass" — never report just one
|
|
484
|
-
10. Run Pre-Commit Gate checklist from CLAUDE.md — update all affected docs BEFORE committing
|
|
485
|
-
11. Commit immediately: feat({domain-name}/task-{task-id}): {description}
|
|
486
|
-
12. Update .gsd-t/progress.md — mark this task complete; prefix the Decision Log entry:
|
|
487
|
-
- Completed successfully on first attempt → prefix `[success]`
|
|
488
|
-
- Completed after a fix → prefix `[learning]`
|
|
489
|
-
- Deferred to .gsd-t/deferred-items.md → prefix `[deferred]`
|
|
490
|
-
- Failed after 3 attempts → prefix `[failure]`
|
|
491
|
-
13. Spawn QA subagent (model: sonnet) after completing the task. Resolve the templated prompt path first so the orchestrator never holds the full prompt body in its own context:
|
|
492
|
-
Run via Bash: `QA_PROMPT="$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t/templates/prompts/qa-subagent.md"; [ -f "$QA_PROMPT" ] || QA_PROMPT="templates/prompts/qa-subagent.md"`
|
|
493
|
-
Then spawn the subagent with this short prompt:
|
|
494
|
-
'You are the QA agent. Read `'"$QA_PROMPT"'` and follow it exactly. Do not deviate from the protocol in that file. Context for this run: domain={domain-name}, task=task-{task-id}, files-modified={list-from-task-summary}.'
|
|
495
|
-
If QA fails OR shallow tests are found, fix before proceeding. Append issues to .gsd-t/qa-issues.md.
|
|
496
|
-
14. Write task summary to .gsd-t/domains/{domain-name}/task-{task-id}-summary.md:
|
|
497
|
-
## Task {task-id} Summary — {domain-name}
|
|
498
|
-
- **Status**: PASS | FAIL
|
|
499
|
-
- **Files modified**: {list}
|
|
500
|
-
- **Constraints discovered**: {any new constraints or surprises}
|
|
501
|
-
- **Tests**: {pass/fail count}
|
|
502
|
-
- **Notes**: {10-20 lines max — key decisions, patterns, warnings}
|
|
503
|
-
|
|
504
|
-
Deviation rules:
|
|
505
|
-
- Bug blocking progress → fix, max 3 attempts; after fix attempt 2 fails:
|
|
506
|
-
1. Write current failure context to .gsd-t/debug-state.jsonl via appendEntry
|
|
507
|
-
2. Log: "Delegating to headless debug-loop (2 in-context attempts exhausted)"
|
|
508
|
-
3. Run: `gsd-t headless --debug-loop --max-iterations 15`
|
|
509
|
-
4. Check exit code:
|
|
510
|
-
- 0: Tests pass, continue with task
|
|
511
|
-
- 1/4: Log to .gsd-t/deferred-items.md and stop (report FAIL in summary)
|
|
512
|
-
- 3: Report error, stop
|
|
513
|
-
If still blocked after debug-loop, log to .gsd-t/deferred-items.md and stop (report FAIL in summary)
|
|
514
|
-
- Missing dependency → add minimum needed, document in commit message
|
|
515
|
-
- Non-trivial blocker → log to .gsd-t/deferred-items.md
|
|
516
|
-
- Architectural change required → write NEEDS-APPROVAL to .gsd-t/deferred-items.md,
|
|
517
|
-
skip the task, stop here — never self-approve structural changes
|
|
518
|
-
|
|
519
|
-
Report back:
|
|
520
|
-
- Task: {task-id}
|
|
521
|
-
- Status: PASS | FAIL
|
|
522
|
-
- Files modified: {list}
|
|
523
|
-
- Tests: {pass/fail count}
|
|
524
|
-
- Commit: {hash}
|
|
525
|
-
- Deferred items (if any)"
|
|
526
|
-
```
|
|
527
|
-
|
|
528
|
-
6. After task subagent returns:
|
|
529
|
-
- Run observability Bash (T_END / DURATION / CTX_PCT)
|
|
530
|
-
- Append to token-log.md (per-task row)
|
|
531
|
-
- Alert on CTX_PCT thresholds (display to user inline)
|
|
532
|
-
- **Emit task-metrics record** — run via Bash:
|
|
533
|
-
`node bin/metrics-collector.js --milestone {milestone} --domain {domain-name} --task task-{task-id} --command execute --duration_s $DURATION --tokens_used 0 --context_pct ${CTX_PCT:-0} --pass {true|false} --fix_cycles {0|N} --signal_type {pass-through|fix-cycle} --notes "{brief outcome}" 2>/dev/null || true`
|
|
534
|
-
Signal type: `pass-through` if task passed on first attempt; `fix-cycle` if rework was needed.
|
|
535
|
-
- **Emit task_complete event** — run via Bash:
|
|
536
|
-
`node ~/.claude/scripts/gsd-t-event-writer.js --type task_complete --command gsd-t-execute --reasoning "signal_type={signal_type}, domain={domain-name}" --outcome {success|failure} || true`
|
|
537
|
-
- Check `.gsd-t/deferred-items.md` for `NEEDS-APPROVAL` — if found, STOP and present to user before proceeding to the next task
|
|
538
|
-
- Read the task summary from `.gsd-t/domains/{domain-name}/task-{task-id}-summary.md` to use as prior summary for the next task
|
|
539
|
-
|
|
540
|
-
**After all tasks in a domain complete (orchestrator responsibilities):**
|
|
541
|
-
1. Check `.gsd-t/deferred-items.md` for any `NEEDS-APPROVAL` entries — if found, STOP and present to user before spawning the next domain
|
|
542
|
-
2. If a CHECKPOINT is reached per `integration-points.md`, verify contract compliance (see Step 4) before proceeding to the next wave/domain
|
|
543
|
-
3. Update `.gsd-t/progress.md` with domain completion status
|
|
544
|
-
4. **Adaptive Replan Check** (per `adaptive-replan-contract.md`) — run after EVERY domain completes, before dispatching the next domain:
|
|
545
|
-
|
|
546
|
-
a. **Read domain summaries**: Read all `.gsd-t/domains/{completed-domain}/task-*-summary.md` files. Extract every `**Constraints discovered**:` field. If ALL are empty or "none", skip to the next domain (fast path — no replan needed).
|
|
547
|
-
|
|
548
|
-
b. **Assess affected domains** — two modes:
|
|
549
|
-
- **Graph available** (`.gsd-t/graph/meta.json` exists): For each changed module mentioned in the constraints, run `query('getImporters', { file })` to find which remaining domains import it. Also run `query('getDomainBoundaryViolations', {})` to check if constraint changes affect domain boundaries. Scope replan to ONLY those domains.
|
|
550
|
-
- **Graph unavailable** (fallback): Check ALL remaining unexecuted domains' `tasks.md` files — less precise but functional.
|
|
551
|
-
|
|
552
|
-
c. **Check for invalidated assumptions**: Read each affected remaining domain's `.gsd-t/domains/{domain}/tasks.md`. For each task, check whether any assumption is invalidated by the discovered constraints (e.g., wrong column name, deprecated API, wrong library, missing prerequisite, throughput limits).
|
|
553
|
-
|
|
554
|
-
d. **If invalidated assumptions found**: Revise the affected domain's `tasks.md` on disk. Append a Revision block at the end of the file (do NOT overwrite existing tasks — append only):
|
|
555
|
-
```markdown
|
|
556
|
-
## Revision (Replan Cycle {N})
|
|
557
|
-
- **Trigger**: {completed-domain} — constraint discovered during execution
|
|
558
|
-
- **Constraint**: {exact constraint text from summary}
|
|
559
|
-
- **Changes**: {what was revised in this domain's tasks — list specific task IDs and what changed}
|
|
560
|
-
- **Rationale**: {why this revision is needed — what would break without it}
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
e. **Increment replan cycle counter** (track as `REPLAN_CYCLES` in orchestrator state, starting at 0).
|
|
564
|
-
|
|
565
|
-
f. **Cycle guard**: If `REPLAN_CYCLES > 2`, STOP and pause for user input:
|
|
566
|
-
"Replan cycle limit (2) exceeded. {N} constraints are still propagating. Please review `.gsd-t/domains/*/tasks.md` and resolve manually, then re-run execute."
|
|
567
|
-
|
|
568
|
-
g. **Log to Decision Log** in `.gsd-t/progress.md`: `- {date}: [replan] Cycle {N} — {completed-domain} constraint propagated to {list of affected domains}: {brief constraint summary}`
|
|
569
49
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
6. **Per-domain Red Team** — invoke Step 5.5 (Red Team) NOW for this domain. This is the first place Red Team runs in v2.74.12 — there is no global post-execute Red Team anymore. If Red Team returns FAIL, fix bugs and re-run before proceeding to the next domain (max 2 fix-and-verify cycles); if bugs persist, log to `.gsd-t/deferred-items.md` and present to user.
|
|
575
|
-
|
|
576
|
-
7. **Context observation** — run `node -e "const tb=require('./bin/token-budget.cjs'); const s=tb.getSessionStatus('.'); process.stdout.write(JSON.stringify(s));"` and capture `pct` for the NEXT spawn's token-log row. No gating: the next domain dispatcher runs through `autoSpawnHeadless()` either way under headless-default-contract v2.0.0.
|
|
577
|
-
|
|
578
|
-
### Team Mode (when agent teams are enabled)
|
|
579
|
-
Spawn teammates for domains within the same wave. Only domains in the same wave can run in parallel — do not spawn teammates for domains in different waves simultaneously. Each teammate uses the **domain task-dispatcher pattern** — one subagent per task within their domain (same as solo mode).
|
|
580
|
-
|
|
581
|
-
```
|
|
582
|
-
Create an agent team for execution:
|
|
583
|
-
|
|
584
|
-
ALL TEAMMATES must read before starting:
|
|
585
|
-
1. CLAUDE.md — project conventions (CRITICAL)
|
|
586
|
-
2. Your domain's scope.md — what you own
|
|
587
|
-
3. Your domain's constraints.md — what you must/must not do
|
|
588
|
-
4. ALL files in .gsd-t/contracts/ — your interfaces
|
|
589
|
-
5. Your domain's tasks.md — your work
|
|
590
|
-
|
|
591
|
-
RULES FOR ALL TEAMMATES:
|
|
592
|
-
- **Destructive Action Guard**: NEVER drop tables, remove columns, delete data, replace architecture patterns, or remove working modules without messaging the lead first. The lead must get user approval before any destructive action proceeds.
|
|
593
|
-
- Only modify files listed in your domain's scope.md
|
|
594
|
-
- Implement interfaces EXACTLY as specified in contracts
|
|
595
|
-
- **Write comprehensive FUNCTIONAL tests with every task** — no feature code without test code:
|
|
596
|
-
- Unit/integration tests: happy path + edge cases + error cases for every new/changed function
|
|
597
|
-
- Playwright E2E specs (if UI/routes/flows/modes changed): new specs for new features, cover all modes/flags, form validation, empty/loading/error states, common edge cases
|
|
598
|
-
- Tests are part of the deliverable, not a follow-up
|
|
599
|
-
- **E2E tests MUST be functional, not layout tests**: Every assertion must verify an action produced the correct outcome (state changed, data loaded, content updated) — NOT just that an element is visible/clickable. A test that passes on an empty HTML shell with correct IDs is worthless. See the Functional E2E Test Requirements in the solo mode instructions above.
|
|
600
|
-
- If a task is marked BLOCKED, message the lead and wait
|
|
601
|
-
- Run the Pre-Commit Gate checklist from CLAUDE.md BEFORE every commit — update all affected docs
|
|
602
|
-
- **Commit immediately after each task**: `feat({domain}/task-{N}): {description}` — do NOT batch commits
|
|
603
|
-
- **Deviation Rules**: (1) Bug blocking progress → fix, 3 attempts max; (2) Missing dependency → add minimum needed; (3) Blocker → fix and log to deferred-items.md; (4) Architectural change → STOP, message lead, never self-approve
|
|
604
|
-
|
|
605
|
-
**Task-dispatcher pattern per teammate:**
|
|
606
|
-
For each task in your domain's tasks.md (in order, skip completed):
|
|
607
|
-
1. Load prior summaries: read up to 5 most recent `.gsd-t/domains/{your-domain}/task-*-summary.md` files
|
|
608
|
-
2. Load graph context for task's files (if .gsd-t/graph/meta.json exists)
|
|
609
|
-
3. Spawn one Task subagent (model: sonnet) with ONLY:
|
|
610
|
-
- scope.md, relevant contracts, the single task, graph context, prior summaries
|
|
611
|
-
- Instruction to write task summary to `.gsd-t/domains/{domain}/task-{id}-summary.md`
|
|
612
|
-
(format per fresh-dispatch-contract.md Task Summary Format)
|
|
613
|
-
4. After task subagent returns, read the summary and pass it as prior context to the next task
|
|
614
|
-
5. After completing each task, message the lead with:
|
|
615
|
-
"DONE: {domain} Task {N} - {summary of what was created/modified}"
|
|
616
|
-
6. If you need to deviate from a contract, STOP and message the lead
|
|
617
|
-
|
|
618
|
-
Teammate assignments:
|
|
619
|
-
- Teammate "{domain-1}": Execute .gsd-t/domains/{domain-1}/tasks.md (task-dispatcher pattern, isolated worktree)
|
|
620
|
-
- Teammate "{domain-2}": Execute .gsd-t/domains/{domain-2}/tasks.md (task-dispatcher pattern, isolated worktree)
|
|
621
|
-
- Teammate "{domain-3}": Execute .gsd-t/domains/{domain-3}/tasks.md (task-dispatcher pattern, isolated worktree)
|
|
622
|
-
|
|
623
|
-
**Worktree isolation (per domain teammate):**
|
|
624
|
-
Each domain teammate MUST be spawned with `isolation: "worktree"` on the Agent tool:
|
|
625
|
-
```
|
|
626
|
-
Agent({
|
|
627
|
-
prompt: "{domain execution prompt — include: 'You are working in an isolated git worktree. All your changes are isolated to this worktree branch. Do not push; the lead will merge your branch after all domains complete.'}",
|
|
628
|
-
isolation: "worktree"
|
|
629
|
-
})
|
|
630
|
-
```
|
|
631
|
-
Each teammate works in its own isolated copy of the repository. Changes from one domain do not affect another domain's working tree. This is required for parallel safety — see `.gsd-t/contracts/worktree-isolation-contract.md`.
|
|
632
|
-
|
|
633
|
-
Lead responsibilities (QA is handled via Task subagent — spawn one after each domain checkpoint):
|
|
634
|
-
- Use delegate mode (Shift+Tab)
|
|
635
|
-
- Track completions from teammate messages
|
|
636
|
-
- When a CHECKPOINT is reached:
|
|
637
|
-
1. Pause blocked teammates
|
|
638
|
-
2. Verify the gate condition (check contract compliance)
|
|
639
|
-
3. Unblock waiting teammates
|
|
640
|
-
- Update .gsd-t/progress.md after each completion
|
|
641
|
-
- Resolve any contract conflicts immediately
|
|
642
|
-
|
|
643
|
-
**Sequential Merge Protocol (lead runs after ALL domain agents complete):**
|
|
644
|
-
|
|
645
|
-
Once all domain teammates report completion, the lead performs sequential atomic merges. This is the critical integration step — see `.gsd-t/contracts/worktree-isolation-contract.md` for the full merge protocol.
|
|
646
|
-
|
|
647
|
-
1. **Determine merge order**: Read `.gsd-t/contracts/integration-points.md` — use the dependency graph to sort domains. Domains with no upstream dependencies merge first. Example: if domain-A has no deps and domain-B depends on domain-A's output, merge order is [domain-A, domain-B].
|
|
648
|
-
|
|
649
|
-
2. **For each domain (in dependency order)**:
|
|
650
|
-
|
|
651
|
-
a. **File ownership validation (pre-merge)**: Check files the domain agent modified against the domain's `.gsd-t/domains/{domain}/scope.md`:
|
|
652
|
-
- If `.gsd-t/graph/meta.json` exists: run `query('getDomainBoundaryViolations', { domain })` — flag any files modified outside the domain's declared ownership
|
|
653
|
-
- If graph unavailable: list files changed in the worktree branch via `git diff --name-only` and compare against scope.md manually
|
|
654
|
-
- If violations found: log them in `.gsd-t/progress.md` as `[violation] {domain}: modified {file} outside scope`, but do NOT block merge — flag for immediate review after merge
|
|
655
|
-
|
|
656
|
-
b. **Merge the domain's worktree branch**:
|
|
657
|
-
```bash
|
|
658
|
-
# The worktree branch name is returned by the Agent tool when isolation: "worktree" is used
|
|
659
|
-
git merge --no-ff {domain-worktree-branch} -m "integrate({domain}): merge worktree branch"
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
c. **Contract validation (post-merge)**: Read each contract in `.gsd-t/contracts/` — verify the merged code still satisfies all contract shapes (API shapes, schemas, interfaces). If a contract is violated, log it immediately.
|
|
663
|
-
|
|
664
|
-
d. **Run integration tests**:
|
|
665
|
-
```bash
|
|
666
|
-
node --test test/
|
|
667
|
-
# or project's test command from package.json
|
|
668
|
-
```
|
|
669
|
-
|
|
670
|
-
e. **If tests PASS**: Continue to the next domain in merge order.
|
|
671
|
-
|
|
672
|
-
f. **If tests FAIL**: Roll back this domain's merge:
|
|
673
|
-
```bash
|
|
674
|
-
git reset --hard HEAD~1
|
|
675
|
-
# or: git revert HEAD --no-edit
|
|
676
|
-
```
|
|
677
|
-
Log failure: `[rollback] {domain}: merge rolled back — integration tests failed after merge`
|
|
678
|
-
Record in `.gsd-t/progress.md` Decision Log.
|
|
679
|
-
Continue with remaining domains (other domains' merges are not affected).
|
|
680
|
-
|
|
681
|
-
3. **Post-merge ownership report**: After all merges complete (successful or rolled back), log a summary in `.gsd-t/progress.md`:
|
|
682
|
-
```
|
|
683
|
-
## Worktree Merge Summary — {date}
|
|
684
|
-
- {domain-1}: MERGED | tests: PASS | violations: {N}
|
|
685
|
-
- {domain-2}: ROLLED BACK | reason: integration tests failed
|
|
686
|
-
- {domain-3}: MERGED | tests: PASS | violations: 0
|
|
687
|
-
```
|
|
688
|
-
|
|
689
|
-
**Worktree Cleanup (MANDATORY — run after merge protocol, success or failure):**
|
|
690
|
-
|
|
691
|
-
After all merges complete (whether all passed, some rolled back, or errors occurred):
|
|
692
|
-
|
|
693
|
-
1. List all worktree branches created during this execution run:
|
|
694
|
-
```bash
|
|
695
|
-
git worktree list
|
|
696
|
-
git branch --list "gsd-t-worktree-*"
|
|
697
|
-
```
|
|
698
|
-
|
|
699
|
-
2. Remove each domain worktree:
|
|
700
|
-
```bash
|
|
701
|
-
git worktree remove --force {worktree-path}
|
|
702
|
-
git branch -D {worktree-branch}
|
|
703
|
-
```
|
|
704
|
-
|
|
705
|
-
3. **Orphaned worktree detection**: If any worktrees remain after cleanup (can happen if an agent crashed):
|
|
706
|
-
```bash
|
|
707
|
-
git worktree prune
|
|
708
|
-
```
|
|
709
|
-
Log: `[cleanup] Pruned {N} orphaned worktrees via git worktree prune`
|
|
710
|
-
|
|
711
|
-
4. Verify no worktrees remain except the main working tree:
|
|
712
|
-
```bash
|
|
713
|
-
git worktree list
|
|
714
|
-
# should show only: {main-path} {commit} [branch]
|
|
715
|
-
```
|
|
716
|
-
|
|
717
|
-
Cleanup is not optional — orphaned worktrees waste disk space and can confuse subsequent executions. Always run cleanup, even if earlier steps failed.
|
|
718
|
-
```
|
|
719
|
-
|
|
720
|
-
## Step 3.5: Orchestrator Context Gate (MANDATORY)
|
|
721
|
-
|
|
722
|
-
```bash
|
|
723
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 3 --step-label ".5: Orchestrator Context Gate (MANDATORY)" 2>/dev/null || true
|
|
724
|
-
```
|
|
725
|
-
|
|
726
|
-
Context observation — the orchestrator captures `getSessionStatus()` BEFORE every spawn for the Ctx% column only. Under headless-default-contract v2.0.0 the band does NOT gate the spawn decision; every task-dispatcher spawn goes through `autoSpawnHeadless()`.
|
|
727
|
-
|
|
728
|
-
**Before each task spawn — capture ctx reading:**
|
|
729
|
-
|
|
730
|
-
```bash
|
|
731
|
-
node -e "const tb=require('./bin/token-budget.cjs'); const s=tb.getSessionStatus('.'); process.stdout.write(JSON.stringify(s));"
|
|
732
|
-
```
|
|
733
|
-
|
|
734
|
-
The JSON on stdout contains `{pct, threshold}`. Capture `pct` as `{CTX_PCT}` for the token-log `Ctx%` column on the NEXT spawn. The `threshold` field is observational — no longer used for branching.
|
|
735
|
-
|
|
736
|
-
**Configuring the threshold:**
|
|
737
|
-
|
|
738
|
-
The threshold percentage (default `75`) lives in `.gsd-t/context-meter-config.json`. The `modelWindowSize` used for the denominator is in the same file (default `200000`). Override either by editing that file.
|
|
739
|
-
|
|
740
|
-
## Step 4: Checkpoint Handling
|
|
741
|
-
|
|
742
|
-
```bash
|
|
743
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 4 --step-label "Checkpoint Handling" 2>/dev/null || true
|
|
744
|
-
```
|
|
745
|
-
|
|
746
|
-
When a checkpoint is reached (solo or team):
|
|
747
|
-
|
|
748
|
-
1. **Stop** execution of blocked tasks
|
|
749
|
-
2. **Read** the relevant contract
|
|
750
|
-
3. **Verify** the implemented code matches the contract:
|
|
751
|
-
- API response shapes match?
|
|
752
|
-
- Schema matches?
|
|
753
|
-
- Component interfaces match?
|
|
754
|
-
- Error handling matches?
|
|
755
|
-
4. **If mismatch**: Fix the implementation to match the contract, OR update the contract and notify affected domains
|
|
756
|
-
5. **Log** in progress.md: `CHECKPOINT {name}: PASSED/FAILED — {details}`
|
|
757
|
-
6. **Unblock** downstream tasks
|
|
758
|
-
|
|
759
|
-
## Step 5: Error Handling
|
|
760
|
-
|
|
761
|
-
```bash
|
|
762
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 5 --step-label "Error Handling" 2>/dev/null || true
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
### Contract Violation
|
|
766
|
-
A teammate implements something that doesn't match a contract:
|
|
767
|
-
1. Stop the teammate
|
|
768
|
-
2. Identify the deviation
|
|
769
|
-
3. Decide: fix implementation or update contract?
|
|
770
|
-
4. If updating contract, message ALL affected teammates with the change
|
|
771
|
-
5. Log the decision
|
|
772
|
-
|
|
773
|
-
### Merge Conflict / File Conflict
|
|
774
|
-
Two teammates modified the same file (shouldn't happen with good partitioning):
|
|
775
|
-
1. Stop both teammates
|
|
776
|
-
2. Identify which domain owns the file (check scope.md)
|
|
777
|
-
3. Non-owner reverts their changes
|
|
778
|
-
4. Determine if the contract needs updating to prevent recurrence
|
|
779
|
-
5. Log the incident
|
|
780
|
-
|
|
781
|
-
### Blocked Teammate Idle
|
|
782
|
-
A teammate finishes independent tasks and is waiting on a checkpoint:
|
|
783
|
-
1. Check if checkpoint can be expedited
|
|
784
|
-
2. If not, have the teammate work on documentation, tests, or code cleanup within their domain
|
|
785
|
-
3. Or shut down the teammate and respawn when unblocked
|
|
786
|
-
|
|
787
|
-
## Step 5.25: Design Verification Agent (per-domain, MANDATORY when design contract exists)
|
|
788
|
-
|
|
789
|
-
```bash
|
|
790
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 5 --step-label ".25: Design Verification Agent (per-domain, MANDATORY when design contract exists)" 2>/dev/null || true
|
|
791
|
-
```
|
|
792
|
-
|
|
793
|
-
**IMPORTANT — frequency change in v2.74.12**: Design Verification was previously run once at the end of every execute run, regardless of how many domains existed. It is now run ONCE PER COMPLETED DOMAIN — call this step from the "After all tasks in a domain complete" block (Step 3.5 area), not from a global post-execute hook. This keeps verification co-located with the changes that introduced visual deviation, but stops the agent from re-materializing on every task spawn (which is what commit `b68353e` accidentally caused).
|
|
794
|
-
|
|
795
|
-
After all tasks in the CURRENT DOMAIN complete and per-task QA has passed, check if `.gsd-t/contracts/design-contract.md` exists. If it does NOT exist, skip this step entirely.
|
|
796
|
-
|
|
797
|
-
If it DOES exist AND this domain touched UI files — spawn the **Design Verification Agent**. This agent's ONLY job is to open a browser, compare the built frontend against the original design, and produce a structured comparison table. It writes NO feature code.
|
|
798
|
-
|
|
799
|
-
⚙ [opus] Design Verification → visual comparison for domain {domain-name}
|
|
800
|
-
|
|
801
|
-
**OBSERVABILITY LOGGING (MANDATORY) — wrap the Design Verification spawn with `captureSpawn`:**
|
|
802
|
-
|
|
803
|
-
Resolve the templated prompt path first so the orchestrator never holds the full ~3500-token verification protocol in its own context:
|
|
804
|
-
|
|
805
|
-
```bash
|
|
806
|
-
DV_PROMPT="$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t/templates/prompts/design-verify-subagent.md"
|
|
807
|
-
[ -f "$DV_PROMPT" ] || DV_PROMPT="templates/prompts/design-verify-subagent.md"
|
|
808
|
-
```
|
|
809
|
-
|
|
810
|
-
Then spawn through `captureSpawn` — `spawnType: 'validation'` (always headless per headless-default-contract v2.0.0):
|
|
811
|
-
|
|
812
|
-
```
|
|
813
|
-
node -e "
|
|
814
|
-
const { captureSpawn } = require('./bin/gsd-t-token-capture.cjs');
|
|
815
|
-
(async () => {
|
|
816
|
-
await captureSpawn({
|
|
817
|
-
command: 'gsd-t-execute',
|
|
818
|
-
step: 'Design Verify',
|
|
819
|
-
model: 'opus',
|
|
820
|
-
description: 'visual comparison for domain {domain-name}',
|
|
821
|
-
projectDir: '.',
|
|
822
|
-
domain: '{domain-name}',
|
|
823
|
-
task: '-',
|
|
824
|
-
notes: '{VERDICT} — {MATCH}/{TOTAL} elements',
|
|
825
|
-
spawnFn: async () => { /* Task subagent (spawnType: validation, general-purpose, model: opus):
|
|
826
|
-
'You are the Design Verification Agent. Read $DV_PROMPT and follow it exactly.
|
|
827
|
-
Do not deviate from that protocol. Context for this run:
|
|
828
|
-
- domain: {domain-name}
|
|
829
|
-
- design contract: .gsd-t/contracts/design-contract.md
|
|
830
|
-
- files modified by this domain: {list}
|
|
831
|
-
Report back the verdict, match count, breakpoints verified, deviation count
|
|
832
|
-
and summary, and the full comparison table per the protocol's Step 7.' */ },
|
|
833
|
-
});
|
|
834
|
-
})();
|
|
835
|
-
"
|
|
836
|
-
```
|
|
837
|
-
|
|
838
|
-
`captureSpawn` parses `result.usage` and appends a row to `.gsd-t/token-log.md` under the canonical header. Tokens column renders as `in=N out=N cr=N cc=N $X.XX` or `—`, never `N/A`.
|
|
839
|
-
|
|
840
|
-
**Artifact Gate (MANDATORY):**
|
|
841
|
-
After the Design Verification Agent returns, check `.gsd-t/contracts/design-contract.md`:
|
|
842
|
-
1. Read the file — does it contain a `## Verification Status` section?
|
|
843
|
-
2. Does that section contain a comparison table with rows?
|
|
844
|
-
3. If EITHER is missing → the verification agent failed its job. Log:
|
|
845
|
-
`[failure] Design Verification Agent did not produce comparison table — re-spawning`
|
|
846
|
-
Re-spawn the agent (1 retry). If it fails again, log to `.gsd-t/deferred-items.md`.
|
|
847
|
-
|
|
848
|
-
**If VERDICT is DESIGN DEVIATIONS FOUND:**
|
|
849
|
-
1. Fix all deviations (spawn a fix subagent, model: sonnet, with the deviation list)
|
|
850
|
-
2. Re-spawn the Design Verification Agent to re-verify (max 2 fix-and-verify cycles)
|
|
851
|
-
3. If deviations persist after 2 cycles, log to `.gsd-t/deferred-items.md` and present to user
|
|
852
|
-
|
|
853
|
-
**If VERDICT is DESIGN VERIFIED:** Proceed to Red Team.
|
|
854
|
-
|
|
855
|
-
## Step 5.5: Red Team — Adversarial QA (per-domain, MANDATORY)
|
|
856
|
-
|
|
857
|
-
```bash
|
|
858
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 5 --step-label ".5: Red Team — Adversarial QA (per-domain, MANDATORY)" 2>/dev/null || true
|
|
859
|
-
```
|
|
860
|
-
|
|
861
|
-
**IMPORTANT — frequency change in v2.74.12**: Red Team was promoted to per-task by commit `da6d3ae` on the assumption that the orchestrator would catch context drain via an environment-variable-based self-check. That env-var path was never populated by Claude Code, so the check was inert and the per-task spawning of ~10k-token Red Team subagents was the largest single contributor to the v2.74.x context-burn regression. Red Team is now run ONCE PER COMPLETED DOMAIN — call this step from the "After all tasks in a domain complete" block, not from a per-task hook.
|
|
862
|
-
|
|
863
|
-
After all tasks in the CURRENT DOMAIN pass their tests, spawn an adversarial Red Team agent. Its sole purpose is to BREAK the domain that was just built.
|
|
864
|
-
|
|
865
|
-
⚙ [opus] Red Team → adversarial validation for domain {domain-name}
|
|
866
|
-
|
|
867
|
-
**OBSERVABILITY LOGGING (MANDATORY) — wrap the Red Team spawn with `captureSpawn`:**
|
|
868
|
-
|
|
869
|
-
Resolve the templated prompt path so the orchestrator never holds the full ~3500-token Red Team protocol in its own context:
|
|
870
|
-
|
|
871
|
-
```bash
|
|
872
|
-
RT_PROMPT="$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t/templates/prompts/red-team-subagent.md"
|
|
873
|
-
[ -f "$RT_PROMPT" ] || RT_PROMPT="templates/prompts/red-team-subagent.md"
|
|
874
|
-
```
|
|
875
|
-
|
|
876
|
-
Then spawn through `captureSpawn` — `spawnType: 'validation'` (always headless per headless-default-contract v2.0.0):
|
|
877
|
-
|
|
878
|
-
```
|
|
879
|
-
node -e "
|
|
880
|
-
const { captureSpawn } = require('./bin/gsd-t-token-capture.cjs');
|
|
881
|
-
(async () => {
|
|
882
|
-
await captureSpawn({
|
|
883
|
-
command: 'gsd-t-execute',
|
|
884
|
-
step: 'Red Team',
|
|
885
|
-
model: 'opus',
|
|
886
|
-
description: 'adversarial validation for domain {domain-name}',
|
|
887
|
-
projectDir: '.',
|
|
888
|
-
domain: '{domain-name}',
|
|
889
|
-
task: '-',
|
|
890
|
-
notes: '{VERDICT} — {N} bugs found',
|
|
891
|
-
spawnFn: async () => { /* Task subagent (spawnType: validation, general-purpose, model: opus):
|
|
892
|
-
'You are a Red Team QA adversary. Read $RT_PROMPT and follow it exactly.
|
|
893
|
-
Do not deviate from that protocol. Context for this run:
|
|
894
|
-
- domain: {domain-name}
|
|
895
|
-
- files modified by this domain: {list}
|
|
896
|
-
- tasks just completed: {task-id list}
|
|
897
|
-
Report back the verdict (FAIL or GRUDGING PASS), bugs found by severity,
|
|
898
|
-
attack categories exhausted, and the path to the written
|
|
899
|
-
.gsd-t/red-team-report.md.' */ },
|
|
900
|
-
});
|
|
901
|
-
})();
|
|
902
|
-
"
|
|
903
|
-
```
|
|
904
|
-
|
|
905
|
-
`captureSpawn` parses `result.usage` and appends a row to `.gsd-t/token-log.md`. Tokens column renders as `in=N out=N cr=N cc=N $X.XX` or `—`, never `N/A`.
|
|
906
|
-
|
|
907
|
-
**If Red Team VERDICT is FAIL:**
|
|
908
|
-
1. Fix all CRITICAL and HIGH bugs immediately (up to 2 fix attempts per bug)
|
|
909
|
-
2. Re-run Red Team after fixes
|
|
910
|
-
3. If bugs persist after 2 fix cycles, log to `.gsd-t/deferred-items.md` and present to user
|
|
911
|
-
|
|
912
|
-
**If Red Team VERDICT is GRUDGING PASS:** Proceed to completion.
|
|
913
|
-
|
|
914
|
-
## Step 6: Completion
|
|
915
|
-
|
|
916
|
-
```bash
|
|
917
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 6 --step-label "Completion" 2>/dev/null || true
|
|
918
|
-
```
|
|
919
|
-
|
|
920
|
-
When all tasks in all domains are complete:
|
|
921
|
-
1. Update `.gsd-t/progress.md` — all tasks marked complete
|
|
922
|
-
2. Set status to `EXECUTED`
|
|
923
|
-
3. List any contract deviations or decisions made during execution
|
|
924
|
-
|
|
925
|
-
### Autonomy Behavior
|
|
926
|
-
|
|
927
|
-
**Level 3 (Full Auto)**: Log a brief status line (e.g., "✅ Execute complete — {N}/{N} tasks done") and auto-advance to the next phase. Do NOT wait for user input.
|
|
928
|
-
|
|
929
|
-
**Level 1–2**: Report completion summary and recommend proceeding to integrate phase. Wait for confirmation.
|
|
930
|
-
|
|
931
|
-
## Step 7: Doc-Ripple (Automated)
|
|
932
|
-
|
|
933
|
-
```bash
|
|
934
|
-
node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-execute --step 7 --step-label "Doc-Ripple (Automated)" 2>/dev/null || true
|
|
935
|
-
```
|
|
936
|
-
|
|
937
|
-
After all work is committed but before reporting completion:
|
|
938
|
-
|
|
939
|
-
1. Run threshold check — read `git diff --name-only HEAD~1` and evaluate against doc-ripple-contract.md trigger conditions
|
|
940
|
-
2. If SKIP: log "Doc-ripple: SKIP — {reason}" and proceed to completion
|
|
941
|
-
3. If FIRE: spawn doc-ripple agent — `spawnType: 'validation'` (always headless per headless-default-contract v2.0.0):
|
|
942
|
-
|
|
943
|
-
⚙ [{model}] gsd-t-doc-ripple → blast radius analysis + parallel updates
|
|
944
|
-
|
|
945
|
-
Task subagent (spawnType: validation, general-purpose, model: sonnet):
|
|
946
|
-
"Execute the doc-ripple workflow per commands/gsd-t-doc-ripple.md.
|
|
947
|
-
Git diff context: {files changed list}
|
|
948
|
-
Command that triggered: execute
|
|
949
|
-
Produce manifest at .gsd-t/doc-ripple-manifest.md.
|
|
950
|
-
Update all affected documents.
|
|
951
|
-
Report: 'Doc-ripple: {N} checked, {N} updated, {N} skipped'"
|
|
952
|
-
|
|
953
|
-
4. After doc-ripple returns, verify manifest exists and report summary inline
|
|
50
|
+
- `status === "complete"`: every domain reported `complete`, integrate landed clean, verify-gate green. Auto-advance to the next phase.
|
|
51
|
+
- `status === "verify-failed"`: domains completed but verify-gate found regressions. Invoke `gsd-t-debug` (or its Workflow) before retry.
|
|
52
|
+
- `status === "failed"`: a domain reported `failed`, integrate failed, or preflight blocked. Read `domainResults` for the blocking entry.
|
|
954
53
|
|
|
955
54
|
## Document Ripple
|
|
956
55
|
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
### Always update:
|
|
960
|
-
1. **`.gsd-t/progress.md`** — Mark tasks complete, update domain status, log execution summary
|
|
961
|
-
|
|
962
|
-
### Check if affected (per task):
|
|
963
|
-
2. **`.gsd-t/contracts/`** — Did a task change an API endpoint, schema, or component interface? Update the contract
|
|
964
|
-
3. **`docs/requirements.md`** — Did a task implement or change a requirement? Mark it complete or revise
|
|
965
|
-
4. **`docs/architecture.md`** — Did a task add/change a component or data flow? Update it
|
|
966
|
-
5. **`.gsd-t/techdebt.md`** — Did a task resolve a debt item? Mark it done. Did it reveal new debt? Add it
|
|
967
|
-
|
|
968
|
-
### Scan Doc Micro-Update (if `.gsd-t/scan/` exists):
|
|
969
|
-
After all tasks complete, patch structural metadata in scan docs so they stay fresh between full scans. This is near-zero cost — no LLM re-analysis, just updating counts and lists from code.
|
|
970
|
-
|
|
971
|
-
For each scan doc that exists, apply only the relevant patches:
|
|
972
|
-
- **`.gsd-t/scan/architecture.md`** — Update file/directory counts, add new files/modules created during execution
|
|
973
|
-
- **`.gsd-t/scan/quality.md`** — Mark resolved TODOs/FIXMEs, update test counts (run `grep -rc "test\|it\|describe" tests/` or equivalent), append new files to Consumer Surfaces table if applicable
|
|
974
|
-
- **`.gsd-t/scan/security.md`** — If a security finding was fixed during execution, mark it `[RESOLVED]`
|
|
975
|
-
- **`.gsd-t/scan/business-rules.md`** — Append any new validation/auth/workflow rules added during execution
|
|
976
|
-
- **`.gsd-t/scan/contract-drift.md`** — If contracts were updated, mark resolved drift items
|
|
56
|
+
After execute completes, ensure these are updated in the same commit chain:
|
|
977
57
|
|
|
978
|
-
|
|
58
|
+
- `.gsd-t/progress.md` — Decision Log entry per executed task or domain
|
|
59
|
+
- `docs/architecture.md` — if new components or data-flow changes
|
|
60
|
+
- `.gsd-t/contracts/` — if interfaces changed
|
|
61
|
+
- `docs/requirements.md` — mark requirements complete or revised
|
|
979
62
|
|
|
980
|
-
|
|
63
|
+
These are normally handled inside each domain worker's commits. The integrate stage verifies they landed.
|
|
981
64
|
|
|
982
|
-
##
|
|
65
|
+
## Next Up (auto-advance)
|
|
983
66
|
|
|
984
|
-
|
|
67
|
+
`/gsd-t-verify` (or the verify Workflow directly). The execute Workflow's verify-gate step is a fast deterministic check; `/gsd-t-verify` runs the full orthogonal triad (`/code-review ultra` ∥ Red Team ∥ QA) per `.gsd-t/contracts/orthogonal-validation-contract.md`.
|