@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.
Files changed (108) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/bin/gsd-t-parallel.cjs +64 -13
  3. package/bin/gsd-t.js +48 -376
  4. package/bin/journey-coverage.cjs +6 -3
  5. package/bin/parallel-cli.cjs +13 -1
  6. package/commands/gsd-t-debug.md +47 -533
  7. package/commands/gsd-t-design-decompose.md +24 -497
  8. package/commands/gsd-t-doc-ripple.md +23 -139
  9. package/commands/gsd-t-execute.md +41 -958
  10. package/commands/gsd-t-help.md +0 -2
  11. package/commands/gsd-t-impact.md +26 -295
  12. package/commands/gsd-t-integrate.md +44 -369
  13. package/commands/gsd-t-milestone.md +25 -124
  14. package/commands/gsd-t-partition.md +28 -539
  15. package/commands/gsd-t-plan.md +26 -472
  16. package/commands/gsd-t-prd.md +25 -311
  17. package/commands/gsd-t-quick.md +1 -1
  18. package/commands/gsd-t-resume.md +0 -33
  19. package/commands/gsd-t-verify.md +52 -569
  20. package/commands/gsd-t-wave.md +41 -430
  21. package/package.json +1 -1
  22. package/scripts/gsd-t-calibration-hook.js +3 -1
  23. package/scripts/hooks/pre-commit-journey-coverage +0 -2
  24. package/scripts/hooks/pre-commit-playwright-gate +0 -2
  25. package/templates/CLAUDE-global.md +43 -173
  26. package/templates/CLAUDE-project.md +118 -104
  27. package/templates/prompts/design-verify-subagent.md +3 -0
  28. package/templates/prompts/qa-subagent.md +3 -0
  29. package/templates/prompts/red-team-subagent.md +5 -2
  30. package/templates/workflows/_lib.js +176 -0
  31. package/templates/workflows/gsd-t-debug.workflow.js +86 -0
  32. package/templates/workflows/gsd-t-execute.workflow.js +206 -0
  33. package/templates/workflows/gsd-t-integrate.workflow.js +71 -0
  34. package/templates/workflows/gsd-t-phase.workflow.js +94 -0
  35. package/templates/workflows/gsd-t-quick.workflow.js +72 -0
  36. package/templates/workflows/gsd-t-verify.workflow.js +348 -0
  37. package/templates/workflows/gsd-t-wave.workflow.js +43 -0
  38. package/bin/check-headless-sessions.js +0 -140
  39. package/bin/context-budget-audit.cjs +0 -447
  40. package/bin/context-meter-config.cjs +0 -101
  41. package/bin/context-meter-config.test.cjs +0 -101
  42. package/bin/event-stream.cjs +0 -205
  43. package/bin/gsd-t-benchmark-orchestrator.js +0 -437
  44. package/bin/gsd-t-capture-lint.cjs +0 -440
  45. package/bin/gsd-t-economics.cjs +0 -315
  46. package/bin/gsd-t-in-session-usage.cjs +0 -213
  47. package/bin/gsd-t-orchestrator-config.cjs +0 -161
  48. package/bin/gsd-t-orchestrator-queue.cjs +0 -180
  49. package/bin/gsd-t-orchestrator-recover.cjs +0 -231
  50. package/bin/gsd-t-orchestrator-worker.cjs +0 -219
  51. package/bin/gsd-t-orchestrator.js +0 -535
  52. package/bin/gsd-t-parallel-probe.cjs +0 -132
  53. package/bin/gsd-t-ratelimit-probe-worker.cjs +0 -237
  54. package/bin/gsd-t-ratelimit-probe.cjs +0 -648
  55. package/bin/gsd-t-report-tokens.cjs +0 -549
  56. package/bin/gsd-t-stream-feed-client.cjs +0 -151
  57. package/bin/gsd-t-token-backfill.cjs +0 -366
  58. package/bin/gsd-t-token-capture.cjs +0 -321
  59. package/bin/gsd-t-token-dashboard.cjs +0 -353
  60. package/bin/gsd-t-token-regenerate-log.cjs +0 -129
  61. package/bin/gsd-t-tool-attribution.cjs +0 -377
  62. package/bin/gsd-t-tool-cost.cjs +0 -195
  63. package/bin/gsd-t-transcript-tee.cjs +0 -246
  64. package/bin/gsd-t-unattended-heartbeat.cjs +0 -188
  65. package/bin/gsd-t-unattended-platform.cjs +0 -551
  66. package/bin/gsd-t-unattended-platform.js +0 -381
  67. package/bin/gsd-t-unattended-safety.cjs +0 -773
  68. package/bin/gsd-t-unattended-safety.js +0 -788
  69. package/bin/gsd-t-unattended.cjs +0 -2109
  70. package/bin/gsd-t-unattended.js +0 -1367
  71. package/bin/gsd-t-worker-dispatch.cjs +0 -211
  72. package/bin/handoff-lock.cjs +0 -249
  73. package/bin/handoff-lock.js +0 -249
  74. package/bin/headless-auto-spawn.cjs +0 -711
  75. package/bin/headless-auto-spawn.js +0 -373
  76. package/bin/headless-exit-codes.cjs +0 -67
  77. package/bin/live-activity-report.cjs +0 -615
  78. package/bin/log-tail.cjs +0 -81
  79. package/bin/m44-proof-measure.cjs +0 -285
  80. package/bin/m46-iter-proof.cjs +0 -149
  81. package/bin/m46-worker-proof.cjs +0 -201
  82. package/bin/m55-substrate-proof.cjs +0 -134
  83. package/bin/metrics-rollup.js +0 -200
  84. package/bin/model-windows.cjs +0 -99
  85. package/bin/model-windows.test.cjs +0 -75
  86. package/bin/parallelism-report.cjs +0 -535
  87. package/bin/runway-estimator.cjs +0 -242
  88. package/bin/spawn-plan-derive.cjs +0 -163
  89. package/bin/spawn-plan-status-updater.cjs +0 -292
  90. package/bin/spawn-plan-writer.cjs +0 -204
  91. package/bin/supervisor-pid-fingerprint.cjs +0 -126
  92. package/bin/token-budget.cjs +0 -265
  93. package/bin/unattended-watch-format.cjs +0 -178
  94. package/bin/watch-progress.js +0 -155
  95. package/commands/gsd-t-unattended-stop.md +0 -85
  96. package/commands/gsd-t-unattended-watch.md +0 -465
  97. package/commands/gsd-t-unattended.md +0 -476
  98. package/commands/gsd-t-visualize.md +0 -116
  99. package/scripts/gsd-t-context-meter.e2e.test.js +0 -364
  100. package/scripts/gsd-t-context-meter.js +0 -341
  101. package/scripts/gsd-t-context-meter.test.js +0 -471
  102. package/scripts/gsd-t-dashboard-server.js +0 -1203
  103. package/scripts/gsd-t-post-commit-spawn-plan.sh +0 -86
  104. package/scripts/gsd-t-transcript.html +0 -1821
  105. package/scripts/hooks/gsd-t-conversation-capture.js +0 -439
  106. package/scripts/hooks/gsd-t-in-session-usage-hook.js +0 -84
  107. package/scripts/spawn-plan-fmt-tokens.cjs +0 -80
  108. package/templates/hooks/post-commit-spawn-plan.sh +0 -85
@@ -1,454 +1,65 @@
1
- # GSD-T: Wave — Full Cycle Orchestration (Agent-Per-Phase)
1
+ # GSD-T: Wave — Full Cycle Orchestration
2
2
 
3
- You are the wave orchestrator. You do NOT execute phases yourself. Instead, you spawn an **independent agent for each phase**, giving each a fresh context window. This eliminates context accumulation across phases and prevents mid-wave compaction.
3
+ You are the lead agent. Run a milestone wave end-to-end by invoking the canonical Workflow script at `templates/workflows/gsd-t-wave.workflow.js`.
4
4
 
5
- ## Argument Parsing
5
+ ## What this command does
6
6
 
7
- Parse `$ARGUMENTS`. M43 D4 removed `--watch`; `--in-session`/`--headless` were never shipped. Under `.gsd-t/contracts/headless-default-contract.md` **v2.0.0** every phase-agent spawn goes headless unconditionally. A legacy `--watch` token in `$ARGUMENTS` is accepted but ignored (one-line stderr deprecation warning from the spawn primitive).
7
+ Replaces the M40-era wave-orchestrator-agent-per-phase scaffolding with a single Workflow that composes execute and verify as sub-workflows:
8
8
 
9
- ## Spawn Primitive — Always Headless (M43 D4, v2.0.0)
10
-
11
- Per `.gsd-t/contracts/headless-default-contract.md` v2.0.0. Spawn classifications (kept for logging only — both always headless):
12
-
13
- - `spawnType: 'primary'` — per-phase agents (partition, discuss, plan, impact, execute, test-sync, integrate, verify+complete)
14
- - `spawnType: 'validation'` — post-phase spot-checks, doc-ripple agent
15
-
16
- Spawn path is `autoSpawnHeadless({command, spawnType, projectDir, sessionContext})` with the read-back banner surfacing completion.
17
-
18
- ## Model Assignment
19
-
20
- Per `.gsd-t/contracts/model-selection-contract.md` v1.0.0. Each phase spawn picks its tier from `bin/model-selector.js` — the wave orchestrator itself is routine coordination work.
21
-
22
- - **Wave orchestrator (this agent)**: `sonnet` (`selectModel({phase: "wave"})`).
23
- - **Per-phase spawns**: each phase agent selects its own tier — `partition` → opus, `discuss` → opus, `plan` → sonnet, `execute` → sonnet (with mechanical haiku subroutines and opus Red Team), `test-sync` → sonnet, `integrate` → sonnet, `verify` → opus, `doc-ripple` → sonnet. The phase command files carry their own Model Assignment blocks.
24
- - **Escalation**: `/advisor` convention-based fallback from `bin/advisor-integration.js` at declared high-stakes sub-decisions (see `.gsd-t/M35-advisor-findings.md`). Never silently downgrade the model or skip phases under context pressure — M35 removed that behavior.
25
-
26
- ## Step 0.1: Verify Context Gate Readiness (MANDATORY — first thing in a fresh session)
27
-
28
- ```bash
29
- 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-wave --step 0 --step-label ".1: Verify Context Gate Readiness (MANDATORY — first thing in a fresh session)" 2>/dev/null || true
30
- ```
31
-
32
- Run via Bash:
33
-
34
- ```bash
35
- node -e "const tb = require('./bin/token-budget.cjs'); const s = tb.getSessionStatus('.'); console.log(JSON.stringify(s));"
36
- ```
37
-
38
- This calls `getSessionStatus()` which reads `.gsd-t/.context-meter-state.json` produced by the Context Meter PostToolUse hook. The returned `{pct, threshold}` is captured for the NEXT spawn's token-log Ctx% column — under headless-default-contract v2.0.0 the `threshold` band does NOT drive the spawn decision; every phase agent goes through `autoSpawnHeadless()` unconditionally. When the state file is absent, `getSessionStatus()` returns `{pct: 0, threshold: 'normal'}`. `thresholdPct` (default `75`) and `modelWindowSize` are configured in `.gsd-t/context-meter-config.json`.
39
-
40
- ## Step 1: Load State (Lightweight)
41
-
42
- ```bash
43
- 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-wave --step 1 --step-label "Load State (Lightweight)" 2>/dev/null || true
44
- ```
45
-
46
- Read ONLY:
47
- 1. `.gsd-t/progress.md` — current status, milestone name, phase state
48
- 2. `CLAUDE.md` — autonomy level only (scan for Level 1/2/3)
49
-
50
- Do NOT read contracts, domains, docs, or source code. You are the orchestrator — phase agents handle their own context loading.
51
-
52
- ### Integrity Check
53
-
54
- After reading progress.md, verify it contains the required fields before proceeding:
55
- - **Status field**: A `Status:` line with a recognized value (DEFINED, PARTITIONED, PLANNED, etc.)
56
- - **Milestone name**: A `Milestone` heading or table entry identifying the current milestone
57
- - **Domains table**: A `| Domain |` table with at least one row
58
-
59
- If ANY of these are missing or malformed, STOP and report:
60
- "Wave cannot proceed — progress.md is missing required fields: {list}. Run `/gsd-t-status` to inspect, or `/gsd-t-init` to repair."
61
- Do NOT attempt to fix progress.md yourself — that risks data loss.
62
-
63
- ## Step 2: Determine Resume Point
64
-
65
- ```bash
66
- 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-wave --step 2 --step-label "Determine Resume Point" 2>/dev/null || true
67
- ```
68
-
69
- From progress.md status, determine which phase to start from:
70
-
71
- | Status | Next Phase |
72
- |--------|------------|
73
- | READY | Need milestone first — prompt user or run milestone |
74
- | INITIALIZED / DEFINED | Partition |
75
- | PARTITIONED | Discuss (or skip to Plan if path is clear) |
76
- | DISCUSSED | Plan |
77
- | PLANNED | Impact |
78
- | IMPACT_ANALYZED | Execute |
79
- | EXECUTED | Test-Sync |
80
- | TESTS_SYNCED | Integrate |
81
- | INTEGRATED | Verify |
82
- | VERIFIED | Complete |
83
- | VERIFY_FAILED | Remediate → re-Verify |
84
-
85
- ## Step 2.5: Token Budget Pre-Flight (if available)
86
-
87
- ```bash
88
- 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-wave --step 2 --step-label ".5: Token Budget Pre-Flight (if available)" 2>/dev/null || true
89
- ```
90
-
91
- Before starting the phase loop, check the projected token cost for this milestone:
92
-
93
- Run via Bash:
94
- `node -e "const tb = require('./bin/token-budget.cjs'); const est = tb.estimateMilestoneCost('.'); if(est) process.stdout.write(JSON.stringify(est));" 2>/dev/null`
95
-
96
- If the command returns data, display to user:
97
- - `estimated_tokens`: projected total tokens for this milestone
98
- - `warning`: if `estimated_tokens > budget_ceiling * 0.8`, warn: "Token budget pre-flight: {estimated_tokens} tokens estimated — approaching session ceiling. Consider splitting milestone."
99
-
100
- If the file doesn't exist or returns nothing, skip silently and proceed.
101
-
102
- ## Step 3: Phase Orchestration Loop
103
-
104
- ```bash
105
- 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-wave --step 3 --step-label "Phase Orchestration Loop" 2>/dev/null || true
106
- ```
107
-
108
- For each remaining phase, spawn an **independent agent** using the Task tool. Each agent gets a fresh context window, loads its own state from files, and reports back.
109
-
110
- ### Graph Availability
111
-
112
- If `.gsd-t/graph/meta.json` exists, the code graph is available for all phases. Each phase agent's spawn prompt should include:
113
- "If .gsd-t/graph/meta.json exists, use graph queries (getCallers, getDomainBoundaryViolations, getTestsFor, etc.) to enhance analysis per the phase command instructions."
114
-
115
- ### Phase Agent Spawn Pattern
116
-
117
- For each phase, spawn the agent like this:
118
-
119
- **Stack Rules Detection (before spawning subagent):**
120
- Run via Bash to detect project stack and collect matching rules:
121
- `GSD_T_DIR=$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t; STACKS_DIR="$GSD_T_DIR/templates/stacks"; STACK_RULES=""; if [ -d "$STACKS_DIR" ]; then for f in "$STACKS_DIR"/_*.md; do [ -f "$f" ] && STACK_RULES="${STACK_RULES}$(cat "$f")"$'\n\n'; done; if [ -f "package.json" ]; then grep -q '"react"' package.json 2>/dev/null && [ -f "$STACKS_DIR/react.md" ] && STACK_RULES="${STACK_RULES}$(cat "$STACKS_DIR/react.md")"$'\n\n'; (grep -q '"typescript"' package.json 2>/dev/null || [ -f "tsconfig.json" ]) && [ -f "$STACKS_DIR/typescript.md" ] && STACK_RULES="${STACK_RULES}$(cat "$STACKS_DIR/typescript.md")"$'\n\n'; grep -qE '"(express|fastify|hono|koa)"' package.json 2>/dev/null && [ -f "$STACKS_DIR/node-api.md" ] && STACK_RULES="${STACK_RULES}$(cat "$STACKS_DIR/node-api.md")"$'\n\n'; fi; [ -f "requirements.txt" ] || [ -f "pyproject.toml" ] && [ -f "$STACKS_DIR/python.md" ] && STACK_RULES="${STACK_RULES}$(cat "$STACKS_DIR/python.md")"$'\n\n'; [ -f "go.mod" ] && [ -f "$STACKS_DIR/go.md" ] && STACK_RULES="${STACK_RULES}$(cat "$STACKS_DIR/go.md")"$'\n\n'; [ -f "Cargo.toml" ] && [ -f "$STACKS_DIR/rust.md" ] && STACK_RULES="${STACK_RULES}$(cat "$STACKS_DIR/rust.md")"$'\n\n'; ([ -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) && [ -f "$STACKS_DIR/design-to-code.md" ] && STACK_RULES="${STACK_RULES}$(cat "$STACKS_DIR/design-to-code.md")"$'\n\n'; fi`
122
-
123
- If STACK_RULES is non-empty, append to the subagent prompt:
124
- ```
125
- ## Stack Rules (MANDATORY — violations fail this task)
126
-
127
- {STACK_RULES}
128
-
129
- These standards have the same enforcement weight as contract compliance.
130
- Violations are task failures, not warnings.
131
- ```
132
-
133
- If STACK_RULES is empty (no templates/stacks/ dir or no matches), skip silently.
134
-
135
- **OBSERVABILITY LOGGING (MANDATORY) — wrap every phase spawn with `captureSpawn`:**
136
-
137
- ```
138
- node -e "
139
- const { captureSpawn } = require('./bin/gsd-t-token-capture.cjs');
140
- (async () => {
141
- await captureSpawn({
142
- command: 'gsd-t-wave',
143
- step: '{PHASE}',
144
- model: 'sonnet',
145
- description: 'phase: {PHASE}',
146
- projectDir: '.',
147
- notes: 'phase: {PHASE}',
148
- spawnFn: async () => { /* Task agent (spawnType: primary, subagent_type: 'general-purpose', mode: 'bypassPermissions'):
149
- 'Execute the {PHASE} phase of the current GSD-T milestone.
150
- Read and follow the full instructions in commands/gsd-t-{phase}.md
151
- Read .gsd-t/progress.md for current milestone and state.
152
- Read CLAUDE.md for project conventions.
153
- Read .gsd-t/contracts/ for domain interfaces.
154
- Complete the phase fully:
155
- - Follow every step in the command file
156
- - Update .gsd-t/progress.md status when done
157
- - Run document ripple as specified
158
- - Commit your work
159
- Report back: one-line status summary.' */ },
160
- });
161
- })();
162
- "
163
9
  ```
164
-
165
- `captureSpawn` parses `result.usage` and writes the 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`. Ctx% is pulled from `getSessionStatus()` automatically.
166
-
167
- **Wave Orchestrator Context Gate (MANDATORY) — single-band measurement via Context Meter state file:**
168
-
169
- After each phase agent returns, run via Bash:
170
-
171
- ```bash
172
- node -e "const tb=require('./bin/token-budget.cjs'); const s=tb.getSessionStatus('.'); process.stdout.write(JSON.stringify(s));"
10
+ gsd-t-wave.workflow.js
11
+ ├── workflow("gsd-t-execute", {milestone, domains, projectDir})
12
+ │ └── preflight → brief → disjointness → parallel(workers) → integrate → verify-gate
13
+ └── workflow("gsd-t-verify", {milestone, projectDir})
14
+ └── preflight → verify-gate → M57 gates → M58 gate → orthogonal triad → synthesis
173
15
  ```
174
16
 
175
- The JSON on stdout contains `{pct, threshold}` where `threshold` is `normal` or `threshold` (single-band model per `context-meter-contract.md` v1.3.0).
176
-
177
- Handling:
178
- Capture `pct` for the next spawn's Ctx% log field. The `threshold` field is observational under headless-default-contract v2.0.0 — every spawn routes through `autoSpawnHeadless()` unconditionally, so the band does not gate phase progression.
179
-
180
- ### Phase Sequence
181
-
182
- Execute phases in this order, spawning one agent per phase:
183
-
184
- #### 1. PARTITION
185
- Spawn agent → `commands/gsd-t-partition.md`
186
- - After: Read `progress.md`, verify status = PARTITIONED
187
- - If failed: Report error, stop
188
-
189
- #### 2. DISCUSS (conditional)
190
- - **Structured skip check** — skip discuss and go directly to Plan if ALL of these are true:
191
- - (a) Single domain milestone (only one entry in Domains table)
192
- - (b) No items containing "OPEN QUESTION" in the Decision Log
193
- - (c) For multi-domain milestones: all cross-domain contracts exist in `.gsd-t/contracts/`
194
- - If ANY check fails: Spawn agent → `commands/gsd-t-discuss.md`
195
- - **Note**: Discuss always pauses for user input, even at Level 3. The discuss agent will interact with the user directly.
196
- - If all checks pass: Skip to Plan
197
-
198
- #### 3. PLAN
199
- Spawn agent → `commands/gsd-t-plan.md`
200
- - After: Read `progress.md`, verify status = PLANNED
201
-
202
- #### 4. IMPACT
203
- Spawn agent → `commands/gsd-t-impact.md`
204
- - After: Read `progress.md` and `.gsd-t/impact-report.md`
205
- - **Decision Gate**:
206
- - PROCEED → continue to Execute
207
- - PROCEED WITH CAUTION → log items, continue
208
- - BLOCK → stop, report to user, wait for decision
209
-
210
- #### 5. EXECUTE
211
- Spawn agent → `commands/gsd-t-execute.md`
212
- - This is the heaviest phase. The execute agent uses **task-level dispatch** (fresh-dispatch-contract.md): one Task subagent per task within each domain, each receiving only scope.md + relevant contracts + single task + graph context + up to 5 prior summaries. The execute agent handles domain task-dispatching and QA internally.
213
-
214
- ##### Parallel Dispatch (M44 D9, single instrument)
17
+ The native Workflow `workflow()` global runs each sub-workflow inline and returns its envelope. Sub-workflow tokens count against the parent's budget; sub-workflow agents appear under a "▸ name" group in `/workflows`. Nesting is one level deep — a sub-workflow cannot call another sub-workflow.
215
18
 
216
- The spawned execute agent delegates the parallel-vs-sequential decision to the single instrument `gsd-t parallel --command gsd-t-execute` (see `commands/gsd-t-execute.md` → "Parallel Dispatch"). The wave orchestrator does not need to configure this — it is automatic, deterministic, and inherited via `GSD_T_UNATTENDED` env. Contract: `.gsd-t/contracts/wave-join-contract.md` v1.2.0 §Single Instrument.
19
+ ## Step 1: Read the current milestone state
217
20
 
218
- - **Adaptive replanning**: After each domain completes, the execute agent runs a replan check (per `adaptive-replan-contract.md`). If a completed domain's task summaries reveal new constraints (e.g., deprecated API, wrong column name, incompatible library), the execute agent checks remaining domains' `tasks.md` files for invalidated assumptions and revises them on disk before dispatching the next domain. Maximum 2 replan cycles per execute run — if exceeded, execution pauses for user input. All replan decisions are logged to the Decision Log in `progress.md`. The wave phase summary includes any replan actions taken.
219
- - **Team/parallel mode**: If the plan defines parallel domains (same wave), the execute agent dispatches each domain teammate with `isolation: "worktree"` (per worktree-isolation-contract.md). Each domain works in an isolated git worktree. After all domains complete, the execute agent runs the Sequential Merge Protocol: merge domain A → test → merge domain B → test. Per-domain rollback if tests fail. Worktrees are cleaned up after all merges complete.
220
- - After: Read `progress.md`, verify status = EXECUTED. Phase summary must include replan actions if any occurred:
221
- ```
222
- 📋 Phase 5 (EXECUTE): {N}/{N} tasks done | Replan cycles: {N} | Domains revised: {list or "none"}
223
- ```
21
+ Read `.gsd-t/progress.md` to determine the active milestone and the wave domain list from `.gsd-t/contracts/m{NN}-integration-points.md`.
224
22
 
225
- #### 6. TEST-SYNC
226
- Spawn agent → `commands/gsd-t-test-sync.md`
227
- - After: Read `progress.md`, verify status = TESTS_SYNCED
23
+ ## Step 2: Invoke the wave Workflow
228
24
 
229
- #### 7. INTEGRATE
230
- Spawn agent → `commands/gsd-t-integrate.md`
231
- - After: Read `progress.md`, verify status = INTEGRATED
25
+ Call the `Workflow` tool with:
232
26
 
233
- #### 8. VERIFY + COMPLETE
234
- Spawn agent → `commands/gsd-t-verify.md`
235
- - The verify agent runs all 8 standard quality gates **plus** the goal-backward verification step (Step 5.5 in gsd-t-verify.md), which checks that milestone goals are actually achieved end-to-end and scans for placeholder patterns per `.gsd-t/contracts/goal-backward-contract.md`
236
- - Goal-backward runs after all structural gates pass — CRITICAL or HIGH findings block verification; MEDIUM findings are warnings only
237
- - **Verify auto-invokes complete-milestone** (Step 8 of gsd-t-verify.md). The verify agent handles both verification AND milestone completion in a single agent context. Do NOT spawn a separate complete agent.
238
- - After: Read `progress.md`, check status:
239
- - COMPLETED → milestone done (verify passed and auto-completed)
240
- - VERIFIED → verify passed but complete-milestone failed — spawn a standalone complete agent as fallback
241
- - VERIFY_FAILED → handle remediation (see Error Recovery) — includes goal-backward failures
242
- - Phase summary must include the `Goal-Backward:` line from verify-report.md:
243
- ```
244
- 📋 Phase 8 (VERIFY+COMPLETE): {N} gates passed | Goal-Backward: {PASS/WARN/FAIL} — {N} requirements checked, {N} findings
245
- ```
246
-
247
- #### 9. DOC-RIPPLE (Automated — after verify+complete)
248
-
249
- After the final phase completes but before wave reports done:
250
-
251
- 1. Run threshold check — read `git diff --name-only HEAD~1` and evaluate against doc-ripple-contract.md trigger conditions
252
- 2. If SKIP: log "Doc-ripple: SKIP — {reason}" and proceed
253
- 3. If FIRE: spawn doc-ripple agent — `spawnType: 'validation'` (always headless per headless-default-contract v2.0.0):
254
-
255
- ⚙ [{model}] gsd-t-doc-ripple → blast radius analysis + parallel updates
256
-
257
- Task subagent (spawnType: validation, general-purpose, model: sonnet):
258
- "Execute the doc-ripple workflow per commands/gsd-t-doc-ripple.md.
259
- Git diff context: {files changed list}
260
- Command that triggered: wave
261
- Produce manifest at .gsd-t/doc-ripple-manifest.md.
262
- Update all affected documents.
263
- Report: 'Doc-ripple: {N} checked, {N} updated, {N} skipped'"
264
-
265
- 4. After doc-ripple returns, verify manifest exists and report summary inline
266
-
267
- ### Between Each Phase
268
-
269
- After each agent completes, run this spot-check before proceeding:
270
-
271
- 1. **Status check**: Read `.gsd-t/progress.md` — verify the phase updated status correctly (no FAILED markers, status matches expected phase completion state)
272
- 2. **Git check**: Run `git log --oneline -5` — verify commits were made during this phase (if execute/integrate: at least one commit per task completed)
273
- 3. **Filesystem check**: Verify key output files exist on disk — e.g., for partition: `.gsd-t/domains/*/scope.md` and `.gsd-t/contracts/` files; for execute: newly created source files; for verify: `.gsd-t/verify-report.md`. Do not trust agent-reported completions alone.
274
- 4. Report to user:
275
- ```
276
- ✅ {Phase} complete — {agent's one-line summary}
277
- 📋 Spot-check: {N} commits | {N} output files verified | no FAILED markers
278
- ```
279
- 5. If spot-check fails: write failure event via Bash, then report the discrepancy, re-spawn the phase agent once to correct it, then re-verify. If still failing: stop and report to user.
280
- ```bash
281
- node ~/.claude/scripts/gsd-t-event-writer.js \
282
- --type phase_transition \
283
- --command gsd-t-wave \
284
- --phase {COMPLETED_PHASE} \
285
- --reasoning "Spot-check failed: {one-line discrepancy summary}" \
286
- --outcome failure \
287
- --agent-id "${CLAUDE_SESSION_ID:-unknown}" || true
288
- ```
289
- 5a. After spot-check passes, write success event via Bash:
290
- ```bash
291
- node ~/.claude/scripts/gsd-t-event-writer.js \
292
- --type phase_transition \
293
- --command gsd-t-wave \
294
- --phase {COMPLETED_PHASE} \
295
- --reasoning "Phase complete: {one-line spot-check summary}" \
296
- --outcome success \
297
- --agent-id "${CLAUDE_SESSION_ID:-unknown}" || true
298
- ```
299
- The `|| true` ensures event write failure never blocks wave execution.
300
- 6. Proceed to next phase
301
-
302
- ## Step 4: Autonomy Behavior
303
-
304
- ```bash
305
- 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-wave --step 4 --step-label "Autonomy Behavior" 2>/dev/null || true
27
+ ```js
28
+ {
29
+ scriptPath: "templates/workflows/gsd-t-wave.workflow.js",
30
+ args: {
31
+ milestone: "M{NN}",
32
+ domains: ["m{NN}-d1-...", "m{NN}-d2-...", ...], // domains for this wave only, per integration-points
33
+ projectDir: "."
34
+ }
35
+ }
306
36
  ```
307
37
 
308
- **Level 3 (Full Auto)**: Auto-advance to next phase after each agent completes. Only STOP for:
309
- - Destructive Action Guard violations (reported by phase agent)
310
- - Impact analysis BLOCK verdict
311
- - Unrecoverable errors after 2 fix attempts
312
- - Discuss phase (always pauses for user input)
313
-
314
- **Level 1–2**: Pause between phases, show status, ask to continue.
315
-
316
- ## Step 5: Completion
38
+ ## Step 3: Interpret the result
317
39
 
318
- ```bash
319
- 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-wave --step 5 --step-label "Completion" 2>/dev/null || true
40
+ ```js
41
+ {
42
+ status: "complete" | "verify-failed" | "failed",
43
+ milestone: "M{NN}",
44
+ execResult: { status, domainResults, integrate, verifyGate },
45
+ verifyResult: { status, overallVerdict, verifyGate, buildCoverage, ciParity, testDataPurge, triad, verdict }
46
+ }
320
47
  ```
321
48
 
322
- When all phases are done:
323
- ```
324
- ═══════════════════════════════════════════════════════════════════════════════
325
- ✅ Milestone "{name}" complete!
326
- ═══════════════════════════════════════════════════════════════════════════════
327
-
328
- 📁 Archived to: .gsd-t/milestones/{name}-{date}/
329
- 🏷️ Tagged as: milestone/{name}
330
-
331
- Summary:
332
- - Domains: {list}
333
- - Tasks completed: {N}
334
- - Contracts: {N} defined/verified
335
- - Tests: {N} added/updated
336
- - Impact items addressed: {N}
337
- - Decision log entries: {N}
338
-
339
- Next steps:
340
- - Push tag: git push origin milestone/{name}
341
- - Start next: /gsd-t-milestone "{next}"
342
- - View roadmap: /gsd-t-status
343
- ═══════════════════════════════════════════════════════════════════════════════
344
- ```
345
-
346
- ## Interruption Handling
347
-
348
- If the user interrupts or a phase agent fails:
349
- 1. The current phase agent saves its own state to `.gsd-t/progress.md`
350
- 2. Report: "Paused at {phase}. Run `/gsd-t-resume` to continue."
351
- 3. Resume will pick up from the last completed phase
352
-
353
- ## Error Recovery
354
-
355
- ### If impact analysis blocks:
356
- - Read the impact report from the agent's output
357
- - Report blocking issues to user
358
-
359
- **Level 3**: Spawn a remediation agent to fix blocking issues, then re-spawn impact agent. Max 2 attempts.
360
- If both attempts fail:
361
- 1. Write failure context to `.gsd-t/debug-state.jsonl` via `node -e "require('./bin/debug-ledger.js').appendEntry('.', {iteration:1,timestamp:new Date().toISOString(),test:'impact-remediation',error:'2 in-context fix attempts exhausted',hypothesis:'see impact-report.md',fix:'n/a',fixFiles:[],result:'STILL_FAILS',learning:'delegating to headless debug-loop',model:'sonnet',duration:0})"`
362
- 2. Log: "Delegating to headless debug-loop (2 in-context attempts exhausted)"
363
- 3. Run: `gsd-t headless --debug-loop --max-iterations 10`
364
- 4. Exit code 0 → continue; 1/4 → log to `.gsd-t/deferred-items.md`, report to user; 3 → report error
365
- **Level 1–2**: Ask user for direction.
366
-
367
- ### If tests fail during execute:
368
- - The execute agent handles test failures internally (up to 2 fix attempts)
369
- - If still failing after 2 attempts, the execute agent reports failure
370
- - Orchestrator stops and reports to user
371
-
372
- ### If verify fails:
373
- - Read verify report for failure details
374
-
375
- **Level 3**: Spawn remediation agent, then re-spawn verify agent. Max 2 attempts.
376
- If both attempts fail:
377
- 1. Write failure context to `.gsd-t/debug-state.jsonl` via `node -e "require('./bin/debug-ledger.js').appendEntry('.', {iteration:1,timestamp:new Date().toISOString(),test:'verify-remediation',error:'2 in-context fix attempts exhausted',hypothesis:'see verify-report.md',fix:'n/a',fixFiles:[],result:'STILL_FAILS',learning:'delegating to headless debug-loop',model:'sonnet',duration:0})"`
378
- 2. Log: "Delegating to headless debug-loop (2 in-context attempts exhausted)"
379
- 3. Run: `gsd-t headless --debug-loop --max-iterations 10`
380
- 4. Exit code 0 → re-spawn verify agent; 1/4 → log to `.gsd-t/deferred-items.md`, report to user; 3 → report error
381
- **Level 1–2**: Ask user for direction.
49
+ - `complete` auto-advance to `/gsd-t-complete-milestone`.
50
+ - `verify-failed` → execute completed but verify-gate found regressions; invoke `gsd-t-debug` against `verifyResult.verdict.blockingFindings`.
51
+ - `failed` → domain worker, integrate, or preflight blocked; read `execResult.domainResults` for the blocking entry.
382
52
 
383
- ## Why Agent-Per-Phase
53
+ ## Multi-Wave Milestones
384
54
 
385
- Each phase agent gets a **fresh context window** (~200K tokens). This means:
386
- - Phase 7 doesn't carry the context baggage from phases 1-6
387
- - Mid-phase compaction is eliminated for standard-sized phases
388
- - Each agent loads only what it needs from state files
389
- - The orchestrator stays lightweight (~30KB total)
55
+ For milestones with multiple waves (see `.gsd-t/contracts/m{NN}-integration-points.md` "Wave Sequencing"), invoke `gsd-t-wave` once per wave. Each call uses the domain list for that wave. Checkpoints (C1, C2, C3, …) gate between waves — verify the prior wave's verdict before starting the next.
390
56
 
391
- State handoff happens through `.gsd-t/` files — exactly what they were designed for.
57
+ ## Document Ripple
392
58
 
393
- ## Security Considerations
394
-
395
- ### bypassPermissions Mode
396
-
397
- Wave spawns each phase agent with `mode: "bypassPermissions"`. This means agents execute bash commands, write files, and perform git operations **without per-action user approval**. This is by design — wave phases would be impractical with manual approval at every step.
398
-
399
- ### Attack Surface
400
-
401
- If command files in `~/.claude/commands/` are tampered with, wave agents will execute the modified instructions with full permissions. The attack requires:
402
- 1. Write access to the user's `~/.claude/commands/` directory
403
- 2. Knowledge of the GSD-T command file format
404
- 3. The user to run `/gsd-t-wave` after tampering
405
-
406
- ### Current Mitigations
407
-
408
- - **npm-installed files**: Command files are installed from the npm registry, providing a known-good source
409
- - **Content comparison on update**: `gsd-t update` compares file contents and reports changes
410
- - **User-owned directory**: `~/.claude/commands/` inherits the user's filesystem permissions
411
- - **Destructive Action Guard**: CLAUDE.md instructions provide soft protection against destructive operations (DROP TABLE, schema changes, etc.), though agents could theoretically ignore these
412
- - **Autonomy levels**: Level 1 and Level 2 pause between phases, giving users visibility into agent activity
413
-
414
- ### Recommendations
415
-
416
- - For sensitive projects, use **Level 1 or Level 2 autonomy** instead of Level 3 to review each phase's output
417
- - Periodically verify command file integrity: `gsd-t doctor` checks installation health
418
- - If security is a concern, audit `~/.claude/commands/gsd-t-*.md` files for unexpected modifications
419
- - Keep GSD-T updated (`gsd-t update`) to receive the latest command files from npm
420
-
421
- ## Workflow Visualization
422
-
423
- ```
424
- ┌──────────────────────────────────────────────────────────────────────────────┐
425
- │ Wave Orchestrator (lightweight) │
426
- │ │
427
- │ ┌─────────┐ ┌─────────┐ ┌──────┐ ┌────────┐ ┌─────────┐ │
428
- │ │PARTITION│ → │ DISCUSS │ → │ PLAN │ → │ IMPACT │ → │ EXECUTE │ │
429
- │ │ agent 1 │ │ agent 2 │ │agent 3│ │agent 4 │ │ agent 5 │ │
430
- │ └────┬────┘ └────┬────┘ └───┬──┘ └───┬────┘ └────┬────┘ │
431
- │ ↓ ↓ ↓ ↓ ↓ │
432
- │ status status status status status │
433
- │ check check check check + check │
434
- │ gate │
435
- │ │
436
- │ ┌──────────────────┐ ┌───────────┐ ┌─────────────────┐ │
437
- │ │ VERIFY+COMPLETE │ ← │ INTEGRATE │ ←──── │ FULL TEST-SYNC │ │
438
- │ │ agent 8 │ │ agent 7 │ │ agent 6 │ │
439
- │ └────────┬─────────┘ └─────┬─────┘ └────────┬────────┘ │
440
- │ ↓ ↓ ↓ │
441
- │ gate check → status status │
442
- │ auto-complete check check │
443
- │ archive + tag │
444
- │ │
445
- │ Each agent: fresh context window, reads state from files, dies when done │
446
- │ Orchestrator: 8 agents (was 9), ~30KB total, never compacts │
447
- └──────────────────────────────────────────────────────────────────────────────┘
448
- ```
59
+ Wave delegates to execute and verify; their doc-ripple guarantees apply. Wave itself adds:
449
60
 
450
- $ARGUMENTS
61
+ - `.gsd-t/progress.md` — wave-level status line + per-wave verdict
451
62
 
452
- ## Auto-Clear
63
+ ## Next Up
453
64
 
454
- The full wave cycle is complete. All work is committed to project files. Execute `/clear` to free the orchestrator context window.
65
+ `/gsd-t-complete-milestone` (after final wave). For mid-milestone waves, no next-up operator runs the next wave when ready.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekyzinc/gsd-t",
3
- "version": "3.29.11",
3
+ "version": "4.0.12",
4
4
  "description": "GSD-T: Contract-Driven Development for Claude Code — 54 slash commands with headless-by-default workflow spawning, unattended supervisor relay with event stream, graph-powered code analysis, real-time agent dashboard, task telemetry, doc-ripple enforcement, backlog management, impact analysis, test sync, milestone archival, and PRD generation",
5
5
  "author": "Tekyz, Inc.",
6
6
  "license": "MIT",
@@ -39,7 +39,9 @@
39
39
  const fs = require("fs");
40
40
  const path = require("path");
41
41
 
42
- const { SAFE_DEFAULT_WINDOW } = require("../bin/model-windows.cjs");
42
+ // M61 D1: model-windows retired. SAFE_DEFAULT_WINDOW was 1M (the Opus 4.7/4.8
43
+ // native window). Native /context replaces the meter that consumed this.
44
+ const SAFE_DEFAULT_WINDOW = 1_000_000;
43
45
 
44
46
  const MAX_STDIN = 1024 * 1024; // 1 MiB
45
47
  const SCHEMA_VERSION = 1;
@@ -19,8 +19,6 @@ set -e
19
19
  ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
20
20
 
21
21
  VIEWER_SOURCE_PATTERNS=(
22
- "scripts/gsd-t-transcript.html"
23
- "scripts/gsd-t-dashboard-server.js"
24
22
  "bin/gsd-t-dashboard"
25
23
  "e2e/journeys/"
26
24
  "e2e/viewer/"
@@ -25,8 +25,6 @@ PASS_FILE="$ROOT/.gsd-t/.last-playwright-pass"
25
25
  # Patterns that count as "viewer/UI source" for gating purposes. Globs are
26
26
  # checked against the staged file list returned by git.
27
27
  VIEWER_SOURCE_PATTERNS=(
28
- "scripts/gsd-t-transcript.html"
29
- "scripts/gsd-t-dashboard-server.js"
30
28
  "e2e/viewer/"
31
29
  )
32
30