@tekyzinc/gsd-t 3.29.10 → 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 (112) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/bin/gsd-t-parallel.cjs +64 -13
  3. package/bin/gsd-t-test-data-adapters/file-json-array.cjs +27 -3
  4. package/bin/gsd-t-test-data-adapters/localstorage-key-prefix.cjs +6 -1
  5. package/bin/gsd-t-test-data-adapters/sqlite-table-where.cjs +16 -1
  6. package/bin/gsd-t-test-data-ledger.cjs +1 -0
  7. package/bin/gsd-t.js +48 -376
  8. package/bin/journey-coverage.cjs +6 -3
  9. package/bin/parallel-cli.cjs +13 -1
  10. package/commands/gsd-t-debug.md +47 -533
  11. package/commands/gsd-t-design-decompose.md +24 -497
  12. package/commands/gsd-t-doc-ripple.md +23 -139
  13. package/commands/gsd-t-execute.md +41 -958
  14. package/commands/gsd-t-help.md +0 -2
  15. package/commands/gsd-t-impact.md +26 -295
  16. package/commands/gsd-t-integrate.md +44 -369
  17. package/commands/gsd-t-milestone.md +25 -124
  18. package/commands/gsd-t-partition.md +28 -539
  19. package/commands/gsd-t-plan.md +26 -472
  20. package/commands/gsd-t-prd.md +25 -311
  21. package/commands/gsd-t-quick.md +1 -1
  22. package/commands/gsd-t-resume.md +0 -33
  23. package/commands/gsd-t-verify.md +52 -569
  24. package/commands/gsd-t-wave.md +41 -430
  25. package/package.json +1 -1
  26. package/scripts/gsd-t-calibration-hook.js +3 -1
  27. package/scripts/hooks/pre-commit-journey-coverage +0 -2
  28. package/scripts/hooks/pre-commit-playwright-gate +0 -2
  29. package/templates/CLAUDE-global.md +43 -173
  30. package/templates/CLAUDE-project.md +118 -104
  31. package/templates/prompts/design-verify-subagent.md +3 -0
  32. package/templates/prompts/qa-subagent.md +3 -0
  33. package/templates/prompts/red-team-subagent.md +5 -2
  34. package/templates/workflows/_lib.js +176 -0
  35. package/templates/workflows/gsd-t-debug.workflow.js +86 -0
  36. package/templates/workflows/gsd-t-execute.workflow.js +206 -0
  37. package/templates/workflows/gsd-t-integrate.workflow.js +71 -0
  38. package/templates/workflows/gsd-t-phase.workflow.js +94 -0
  39. package/templates/workflows/gsd-t-quick.workflow.js +72 -0
  40. package/templates/workflows/gsd-t-verify.workflow.js +348 -0
  41. package/templates/workflows/gsd-t-wave.workflow.js +43 -0
  42. package/bin/check-headless-sessions.js +0 -140
  43. package/bin/context-budget-audit.cjs +0 -447
  44. package/bin/context-meter-config.cjs +0 -101
  45. package/bin/context-meter-config.test.cjs +0 -101
  46. package/bin/event-stream.cjs +0 -205
  47. package/bin/gsd-t-benchmark-orchestrator.js +0 -437
  48. package/bin/gsd-t-capture-lint.cjs +0 -440
  49. package/bin/gsd-t-economics.cjs +0 -315
  50. package/bin/gsd-t-in-session-usage.cjs +0 -213
  51. package/bin/gsd-t-orchestrator-config.cjs +0 -161
  52. package/bin/gsd-t-orchestrator-queue.cjs +0 -180
  53. package/bin/gsd-t-orchestrator-recover.cjs +0 -231
  54. package/bin/gsd-t-orchestrator-worker.cjs +0 -219
  55. package/bin/gsd-t-orchestrator.js +0 -535
  56. package/bin/gsd-t-parallel-probe.cjs +0 -132
  57. package/bin/gsd-t-ratelimit-probe-worker.cjs +0 -237
  58. package/bin/gsd-t-ratelimit-probe.cjs +0 -648
  59. package/bin/gsd-t-report-tokens.cjs +0 -549
  60. package/bin/gsd-t-stream-feed-client.cjs +0 -151
  61. package/bin/gsd-t-token-backfill.cjs +0 -366
  62. package/bin/gsd-t-token-capture.cjs +0 -321
  63. package/bin/gsd-t-token-dashboard.cjs +0 -353
  64. package/bin/gsd-t-token-regenerate-log.cjs +0 -129
  65. package/bin/gsd-t-tool-attribution.cjs +0 -377
  66. package/bin/gsd-t-tool-cost.cjs +0 -195
  67. package/bin/gsd-t-transcript-tee.cjs +0 -246
  68. package/bin/gsd-t-unattended-heartbeat.cjs +0 -188
  69. package/bin/gsd-t-unattended-platform.cjs +0 -551
  70. package/bin/gsd-t-unattended-platform.js +0 -381
  71. package/bin/gsd-t-unattended-safety.cjs +0 -773
  72. package/bin/gsd-t-unattended-safety.js +0 -788
  73. package/bin/gsd-t-unattended.cjs +0 -2109
  74. package/bin/gsd-t-unattended.js +0 -1367
  75. package/bin/gsd-t-worker-dispatch.cjs +0 -211
  76. package/bin/handoff-lock.cjs +0 -249
  77. package/bin/handoff-lock.js +0 -249
  78. package/bin/headless-auto-spawn.cjs +0 -711
  79. package/bin/headless-auto-spawn.js +0 -373
  80. package/bin/headless-exit-codes.cjs +0 -67
  81. package/bin/live-activity-report.cjs +0 -615
  82. package/bin/log-tail.cjs +0 -81
  83. package/bin/m44-proof-measure.cjs +0 -285
  84. package/bin/m46-iter-proof.cjs +0 -149
  85. package/bin/m46-worker-proof.cjs +0 -201
  86. package/bin/m55-substrate-proof.cjs +0 -134
  87. package/bin/metrics-rollup.js +0 -200
  88. package/bin/model-windows.cjs +0 -99
  89. package/bin/model-windows.test.cjs +0 -75
  90. package/bin/parallelism-report.cjs +0 -535
  91. package/bin/runway-estimator.cjs +0 -242
  92. package/bin/spawn-plan-derive.cjs +0 -163
  93. package/bin/spawn-plan-status-updater.cjs +0 -292
  94. package/bin/spawn-plan-writer.cjs +0 -204
  95. package/bin/supervisor-pid-fingerprint.cjs +0 -126
  96. package/bin/token-budget.cjs +0 -265
  97. package/bin/unattended-watch-format.cjs +0 -178
  98. package/bin/watch-progress.js +0 -155
  99. package/commands/gsd-t-unattended-stop.md +0 -85
  100. package/commands/gsd-t-unattended-watch.md +0 -465
  101. package/commands/gsd-t-unattended.md +0 -476
  102. package/commands/gsd-t-visualize.md +0 -116
  103. package/scripts/gsd-t-context-meter.e2e.test.js +0 -364
  104. package/scripts/gsd-t-context-meter.js +0 -341
  105. package/scripts/gsd-t-context-meter.test.js +0 -471
  106. package/scripts/gsd-t-dashboard-server.js +0 -1203
  107. package/scripts/gsd-t-post-commit-spawn-plan.sh +0 -86
  108. package/scripts/gsd-t-transcript.html +0 -1821
  109. package/scripts/hooks/gsd-t-conversation-capture.js +0 -439
  110. package/scripts/hooks/gsd-t-in-session-usage-hook.js +0 -84
  111. package/scripts/spawn-plan-fmt-tokens.cjs +0 -80
  112. package/templates/hooks/post-commit-spawn-plan.sh +0 -85
@@ -1,394 +1,69 @@
1
1
  # GSD-T: Integrate — Wire Domains Together
2
2
 
3
- You are the lead agent performing integration work. This phase is ALWAYS single-session one agent with full context across all domains to handle the seams.
3
+ You are the lead agent. Integrate cross-domain work by invoking the canonical Workflow script at `templates/workflows/gsd-t-integrate.workflow.js`.
4
4
 
5
- ## Argument Parsing
5
+ ## What this command does
6
6
 
7
- Parse `$ARGUMENTS`. M43 D4 removed the `--watch` opt-out; `--in-session`/`--headless` were never shipped. Under `.gsd-t/contracts/headless-default-contract.md` **v2.0.0** every spawn below goes headless unconditionally — QA (Step 5), Red Team (Step 7.5), doc-ripple (Step 9). Integrate's own lead-agent body remains the interactive entry point for this command (it is itself the spawn target when invoked from `/gsd` or `gsd-t-wave`). A legacy `--watch` token is accepted but ignored (stderr deprecation line).
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 used below:
12
-
13
- - `spawnType: 'validation'` — QA subagent (Step 5 contract compliance), Red Team (Step 7.5 adversarial), doc-ripple (Step 9)
14
-
15
- Spawn path is `autoSpawnHeadless({command, spawnType: 'validation', projectDir, sessionContext})`. Read-back banner surfaces each completion.
16
-
17
- ## Model Assignment
18
-
19
- Per `.gsd-t/contracts/model-selection-contract.md` v1.0.0.
20
-
21
- - **Default**: `sonnet` (`selectModel({phase: "integrate"})`) — integration wiring is routine coordination.
22
- - **Mechanical subroutines** (demote to `haiku`): integration test runners.
23
- - **Red Team**: `opus` — adversarial QA at integration seams always runs at top tier.
24
- - **Escalation**: `/advisor` convention-based fallback from `bin/advisor-integration.js` when a seam reveals a contract gap or security boundary. Never silently downgrade the model or skip Red Team / doc-ripple under context pressure — M35 removed that behavior.
25
-
26
- ## Step 1: Load Full State
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-integrate --step 1 --step-label "Load Full State" 2>/dev/null || true
30
- ```
31
-
32
- Read everything:
33
- 1. `CLAUDE.md`
34
- 2. `.gsd-t/progress.md`
35
- 3. `.gsd-t/contracts/` — all contracts (this is your source of truth)
36
- 4. `.gsd-t/contracts/integration-points.md` — all connection points
37
- 5. `.gsd-t/domains/*/scope.md` — understand boundaries
38
- 6. All source code produced during execution
39
-
40
- ## Step 1.5: Graph-Enhanced Integration Validation
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-integrate --step 1 --step-label ".5: Graph-Enhanced Integration Validation" 2>/dev/null || true
44
- ```
45
-
46
- If `.gsd-t/graph/meta.json` exists (graph index is available):
47
- 1. Query `getDomainBoundaryViolations` to validate that cross-domain wiring matches contracts — flag any code that crosses boundaries without a contract
48
- 2. Query `getCallers` and `getCallees` across domain boundaries to verify all integration points are accounted for in `integration-points.md`
49
- 3. Add any unregistered cross-domain calls to the audit findings in Step 2
50
-
51
- If graph is not available, skip this step.
52
-
53
- ## Step 2: Contract Compliance Audit
54
-
55
- ```bash
56
- 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-integrate --step 2 --step-label "Contract Compliance Audit" 2>/dev/null || true
57
- ```
58
-
59
- Before wiring anything together, verify each domain honored its contracts:
60
-
61
- For each contract file:
62
- 1. Read the contract specification
63
- 2. Find the implementing code
64
- 3. Verify exact compliance:
65
- - Types/shapes match?
66
- - Endpoint signatures match?
67
- - Error responses match?
68
- - Schema matches?
69
- 4. Log findings:
70
-
71
- ```markdown
72
- ## Contract Audit — {date}
73
-
74
- ### api-contract.md
75
- - POST /api/auth/login: ✅ matches
76
- - GET /api/users/:id: ⚠️ response missing `role` field
77
- - Fix: Update auth/userController.js to include role
78
-
79
- ### schema-contract.md
80
- - Users table: ✅ matches
81
- - Sessions table: ✅ matches
82
- ```
83
-
84
- Fix any mismatches BEFORE proceeding to integration.
85
-
86
- ## Step 2.5: Worktree Merge Status Check
87
-
88
- ```bash
89
- 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-integrate --step 2 --step-label ".5: Worktree Merge Status Check" 2>/dev/null || true
90
- ```
91
-
92
- Before wiring integration points, check whether team mode execution left any domains with rolled-back worktree merges:
93
-
94
- 1. Read `.gsd-t/progress.md` — look for `[rollback]` entries in the Decision Log from the execute phase
95
- 2. If any domains were rolled back: list them and their failure reasons before proceeding
96
- 3. Integration point wiring should only proceed for domains whose worktree merges PASSED — rolled-back domains are not yet in the main working tree
97
-
98
- If rolled-back domains exist, report them to the user (or if Level 3: log to `.gsd-t/deferred-items.md` as `[integration-gap] {domain}: not yet merged — worktree rollback during execute`). Do NOT attempt to re-merge rolled-back domains here; that requires re-running execute for the affected domain.
99
-
100
- ## Step 3: Wire Integration Points
101
-
102
- ```bash
103
- 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-integrate --step 3 --step-label "Wire Integration Points" 2>/dev/null || true
104
- ```
105
-
106
- ### Parallel Dispatch (MANDATORY — single instrument)
107
-
108
- Delegate to `gsd-t parallel --command` — do NOT re-implement probe-and-branch logic here (M44 D9 Step 3: "create 1 instrument that accomplishes this instead of implementing it in all the commands").
109
-
110
- ```bash
111
- node bin/gsd-t.js parallel --milestone {milestone} --command gsd-t-integrate && exit 0 || true
112
- # Exit 0 → multi-domain integration; N detached children handle disjoint subsets.
113
- # Exit 2+ → single-domain wiring. Fall through to sequential dispatch below.
114
- ```
115
-
116
- `runDispatch` owns the D4/D5/D6 gates + disjoint task-id partitioning + `autoSpawnHeadless()` fan-out. Mode auto-detects from `GSD_T_UNATTENDED=1`. No user prompt. Parallel-when-safe + headless-when-possible are both the default.
117
-
118
- Contract: `.gsd-t/contracts/wave-join-contract.md` v1.1.0; `.gsd-t/contracts/headless-default-contract.md` v2.0.0.
119
-
120
- **Stack Rules Detection (before spawning subagent):**
121
- Run via Bash to detect project stack and collect matching rules:
122
- `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`
123
-
124
- If STACK_RULES is non-empty, append to the subagent prompt:
125
- ```
126
- ## Stack Rules (MANDATORY — violations fail this task)
127
-
128
- {STACK_RULES}
129
-
130
- These standards have the same enforcement weight as contract compliance.
131
- Violations are task failures, not warnings.
132
- ```
133
-
134
- If STACK_RULES is empty (no templates/stacks/ dir or no matches), skip silently.
135
-
136
- Work through each integration point in `integration-points.md`. If integration work spans multiple domains with independent tasks, use the **task-level dispatch pattern** (per fresh-dispatch-contract.md): spawn one Task subagent per integration task, passing only the relevant contracts, the specific integration point to wire, and summaries from prior integration tasks (max 5, 10-20 lines each). This prevents context accumulation across integration tasks.
137
-
138
- **Multi-domain integration merging**: If integration work itself requires merging domain outputs that weren't merged during execute (e.g., domains executed in separate waves and integration needs to combine them), use the Sequential Merge Protocol from `.gsd-t/contracts/worktree-isolation-contract.md`:
139
- 1. Sort domains by dependency order (from integration-points.md)
140
- 2. Merge domain A's branch → run tests → merge domain B's branch → run tests
141
- 3. If tests fail after a merge, roll back that domain's merge and log the failure
142
- 4. Contract validation runs between merges
143
- 5. All temporary branches cleaned up after integration completes
144
-
145
- For each connection:
146
- 1. Identify the producing domain (provides the interface)
147
- 2. Identify the consuming domain (calls the interface)
148
- 3. Write or verify the glue code:
149
- - Import statements
150
- - Configuration (env vars, connection strings)
151
- - Middleware chains
152
- - Route registration
153
- - Dependency injection
154
- 4. Ensure error handling flows across the boundary correctly
155
-
156
- ### Common integration tasks:
157
- - **API → UI**: Verify fetch calls match endpoint signatures
158
- - **Auth → Routes**: Wire middleware into route definitions
159
- - **Data layer → Services**: Connect repositories/models to service layer
160
- - **Config**: Ensure shared config (env vars, constants) is consistent
161
-
162
- ## Step 4: End-to-End Smoke Test
163
-
164
- ```bash
165
- 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-integrate --step 4 --step-label "End-to-End Smoke Test" 2>/dev/null || true
166
- ```
167
-
168
- Run through the primary user flows:
169
- 1. Identify the 3-5 most critical paths from requirements
170
- 2. Trace each path through all domain boundaries
171
- 3. Run or manually verify each path works
172
- 4. Document results:
173
-
174
- ```markdown
175
- ## Smoke Test Results
176
-
177
- ### Flow: User Login
178
- 1. UI → POST /api/auth/login ✅
179
- 2. Auth → Users table lookup ✅
180
- 3. Auth → JWT generation ✅
181
- 4. Auth → Response to UI ✅
182
- 5. UI → Store token, redirect ✅
183
- Result: PASS
184
-
185
- ### Flow: Protected Resource Access
186
- 1. UI → GET /api/data with token ✅
187
- 2. Auth middleware → verify token ✅
188
- 3. Data layer → query ⚠️ — missing pagination
189
- Result: PARTIAL — needs pagination contract addition
190
- ```
191
-
192
- ## Step 5: Contract Compliance Testing
193
-
194
- ```bash
195
- 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-integrate --step 5 --step-label "Contract Compliance Testing" 2>/dev/null || true
196
- ```
197
-
198
- Spawn a QA subagent via the Task tool to verify contract compliance at all domain boundaries — `spawnType: 'validation'` (always headless per headless-default-contract v2.0.0):
7
+ Replaces the M40-era single-session integrate scaffolding with a deterministic Workflow that runs cross-domain wire-up between completed parallel domain workers:
199
8
 
200
9
  ```
201
- Task subagent (spawnType: validation, general-purpose, model: sonnet):
202
- "Run contract compliance tests for this integration. Read .gsd-t/contracts/ for all contract definitions.
203
- Test every domain boundary: verify that producers and consumers match their contract shapes.
204
- Run ALL configured test suites — detect and run every one:
205
- a. Unit tests (vitest/jest/mocha): run the full suite
206
- b. E2E tests: check for playwright.config.* or cypress.config.* — if found, run the FULL E2E suite
207
- c. NEVER skip E2E when a config file exists. Running only unit tests is a QA FAILURE.
208
- d. AUDIT E2E test quality: Review each Playwright spec — if any test only checks element existence
209
- (isVisible, toBeAttached, toBeEnabled) without verifying functional behavior (state changes,
210
- data loaded, content updated after actions), flag it as 'SHALLOW TEST — needs functional assertions'.
211
- Report: 'Unit: X/Y pass | E2E: X/Y pass (or N/A if no config) | Boundary: pass/fail by contract | Shallow tests: N'
212
-
213
- ## Exploratory Testing (if Playwright MCP available)
214
-
215
- After all scripted tests pass:
216
- 1. Check if Playwright MCP is registered in Claude Code settings (look for "playwright" in mcpServers)
217
- 2. If available: spend 3 minutes on interactive exploration using Playwright MCP
218
- - Try variations of happy paths with unexpected inputs
219
- - Probe for race conditions, double-submits, empty states
220
- - Test accessibility (keyboard navigation, screen reader flow)
221
- 3. Tag all findings [EXPLORATORY] in your report and append to .gsd-t/qa-issues.md with [EXPLORATORY] prefix
222
- 4. If Playwright MCP is not available: skip this section silently
223
- Note: Exploratory findings do NOT count against the scripted test pass/fail ratio."
10
+ preflight brief → integrate agent (sees all domain results) → light verify-gate
224
11
  ```
225
12
 
226
- **OBSERVABILITY LOGGING (MANDATORY) wrap the Step 5 validation spawn with `captureSpawn`:**
13
+ Integrate runs AFTER parallel domain workers commit their work and BEFORE the full verify Workflow. It handles:
227
14
 
228
- ```
229
- node -e "
230
- const { captureSpawn } = require('./bin/gsd-t-token-capture.cjs');
231
- (async () => {
232
- await captureSpawn({
233
- command: 'gsd-t-integrate',
234
- step: 'Step 5',
235
- model: 'haiku',
236
- description: 'cross-boundary integration QA',
237
- projectDir: '.',
238
- notes: '{pass/fail}, {N} boundaries tested',
239
- spawnFn: async () => { /* Task validation subagent call */ },
240
- });
241
- })();
242
- "
243
- ```
15
+ - Shared-file edits sequenced at integrate (per `.gsd-t/contracts/m{NN}-integration-points.md` "Cross-Domain File Contention Matrix")
16
+ - Cross-domain contract updates (e.g. integration-points.md status flips)
17
+ - Interleaved-touch resolution where two domains both modified the same file's separate regions
244
18
 
245
- `captureSpawn` 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`.
246
- 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):
247
- `| {DT_START} | gsd-t-integrate | Step 5 | haiku | {DURATION}s | {severity} | {finding} |`
19
+ It does NOT re-do work that domain workers already did, and does NOT run the full orthogonal validation triad (that's `/gsd-t-verify`).
248
20
 
249
- QA failure blocks integration completion.
250
-
251
- ## Step 6: Document Ripple
252
-
253
- ```bash
254
- 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-integrate --step 6 --step-label "Document Ripple" 2>/dev/null || true
255
- ```
21
+ ## Step 1: Read the current milestone state
256
22
 
257
- Integration is where the real system takes shape. Verify documentation matches reality:
23
+ Read `.gsd-t/progress.md` and verify all required domain workers have completed (status `complete` in their tasks.md). Read `.gsd-t/contracts/m{NN}-integration-points.md` for the shared-file matrix.
258
24
 
259
- ### Always update:
260
- 1. **`.gsd-t/progress.md`** — Log integration results, contract audit findings, smoke test outcomes
25
+ ## Step 2: Invoke the integrate Workflow
261
26
 
262
- ### Check if affected:
263
- 2. **`docs/architecture.md`** — Now that domains are wired together, does the documented architecture match the actual data flow, component relationships, and integration patterns? Update it
264
- 3. **`docs/requirements.md`** — Did integration reveal missing requirements or invalidate existing ones? Update it
265
- 4. **`docs/schema.md`** — Does the documented schema match the actual database state? Update it
266
- 5. **`CLAUDE.md`** — Did integration establish new conventions (error handling patterns, middleware chains, configuration approaches) that future work should follow? Add them
267
- 6. **`.gsd-t/techdebt.md`** — Did integration reveal new debt (workarounds, temporary glue code, known shortcuts)? Add TD items
27
+ Call the `Workflow` tool with:
268
28
 
269
- ### Skip what's not affected.
270
-
271
- ## Step 7: Test Verification
272
-
273
- ```bash
274
- 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-integrate --step 7 --step-label "Test Verification" 2>/dev/null || true
29
+ ```js
30
+ {
31
+ scriptPath: "templates/workflows/gsd-t-integrate.workflow.js",
32
+ args: {
33
+ milestone: "M{NN}",
34
+ domains: ["m{NN}-d1-...", "m{NN}-d2-..."], // domains that just completed
35
+ projectDir: "."
36
+ }
37
+ }
275
38
  ```
276
39
 
277
- After integration and doc ripple, verify everything works together:
278
-
279
- 1. **Update tests**: Add or update integration tests for newly wired domain boundaries
280
- 2. **Run ALL configured test suites** — detect and run every one:
281
- a. Unit/integration tests (vitest/jest/mocha)
282
- b. If `playwright.config.*` exists → run `npx playwright test` (full suite, not just affected specs)
283
- c. Unit tests alone are NEVER sufficient when E2E exists
284
- d. Report: "Unit: X/Y pass | E2E: X/Y pass"
285
- 3. **Verify passing**: All tests must pass. If any fail, fix before proceeding (up to 2 attempts)
286
- 4. **Functional test quality**: Spot-check E2E specs — every assertion must verify functional behavior (state changed, data loaded, content updated after action), not just element existence. Shallow tests that would pass on an empty HTML page are not acceptable.
287
- 5. **Smoke test results**: Ensure the Step 4 smoke test results are still valid after any fixes
40
+ ## Step 3: Interpret the result
288
41
 
289
- ## Step 7.5: Red Team — Adversarial QA (MANDATORY)
290
-
291
- ```bash
292
- 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-integrate --step 7 --step-label ".5: Red Team — Adversarial QA (MANDATORY)" 2>/dev/null || true
42
+ ```js
43
+ {
44
+ status: "complete" | "verify-failed" | "failed",
45
+ integrate: {
46
+ status: "green" | "warnings" | "failed",
47
+ crossDomainEdits: [...],
48
+ notes: string
49
+ },
50
+ verifyGate: { ... }
51
+ }
293
52
  ```
294
53
 
295
- After integration tests pass, spawn an adversarial Red Team agent on the integrated system. Success is measured by bugs found, not tests passed.
296
-
297
- [opus] Red Teamadversarial validation of integrated system
298
-
299
- Resolve the templated prompt path via Bash:
300
- ```bash
301
- RT_PROMPT="$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t/templates/prompts/red-team-subagent.md"
302
- [ -f "$RT_PROMPT" ] || RT_PROMPT="templates/prompts/red-team-subagent.md"
303
- ```
304
-
305
- Then spawn through `captureSpawn` — `spawnType: 'validation'` (always headless per headless-default-contract v2.0.0):
306
-
307
- ```
308
- node -e "
309
- const { captureSpawn } = require('./bin/gsd-t-token-capture.cjs');
310
- (async () => {
311
- await captureSpawn({
312
- command: 'gsd-t-integrate',
313
- step: 'Red Team',
314
- model: 'opus',
315
- description: 'cross-domain adversarial validation',
316
- projectDir: '.',
317
- notes: '{VERDICT} — {N} bugs found',
318
- spawnFn: async () => { /* Task subagent (spawnType: validation, general-purpose, model: opus):
319
- 'Read \$RT_PROMPT and follow it. Context: cross-domain integration run.
320
- Additional category for this run: Cross-Domain Boundaries — test data flow across every
321
- domain boundary; does data arriving from domain A get validated by domain B; what happens
322
- when A sends malformed data that passed A own validation.
323
- Write findings to .gsd-t/red-team-report.md.' */ },
324
- });
325
- })();
326
- "
327
- ```
328
-
329
- `captureSpawn` 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`.
330
-
331
- **If FAIL:** fix CRITICAL/HIGH bugs (≤2 cycles) → re-run. Persistent bugs → `.gsd-t/deferred-items.md`.
332
- **If GRUDGING PASS:** proceed to doc-ripple.
333
-
334
- ## Step 8: Doc-Ripple (Automated)
335
-
336
- ```bash
337
- 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-integrate --step 8 --step-label "Doc-Ripple (Automated)" 2>/dev/null || true
338
- ```
339
-
340
- After all integration work is committed but before reporting completion:
341
-
342
- 1. Run threshold check — read `git diff --name-only HEAD~1` and evaluate against doc-ripple-contract.md trigger conditions
343
- 2. If SKIP: log "Doc-ripple: SKIP — {reason}" and proceed to completion
344
- 3. If FIRE: spawn doc-ripple agent — `spawnType: 'validation'` (always headless per headless-default-contract v2.0.0):
345
-
346
- ⚙ [{model}] gsd-t-doc-ripple → blast radius analysis + parallel updates
347
-
348
- Task subagent (spawnType: validation, general-purpose, model: sonnet):
349
- "Execute the doc-ripple workflow per commands/gsd-t-doc-ripple.md.
350
- Git diff context: {files changed list}
351
- Command that triggered: integrate
352
- Produce manifest at .gsd-t/doc-ripple-manifest.md.
353
- Update all affected documents.
354
- Report: 'Doc-ripple: {N} checked, {N} updated, {N} skipped'"
355
-
356
- 4. After doc-ripple returns, verify manifest exists and report summary inline
357
-
358
- ## Step 9: Handle Integration Issues
359
-
360
- ```bash
361
- 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-integrate --step 9 --step-label "Handle Integration Issues" 2>/dev/null || true
362
- ```
363
-
364
- For each issue found:
365
- 1. Determine if it's a contract gap (missing specification) or implementation bug
366
- 2. **Contract gap**: Update the contract, create a follow-up task
367
- 3. **Implementation bug**: Fix it directly, document the fix
368
- 4. Log everything in progress.md
369
-
370
- ## Step 10: Update State
371
-
372
- ```bash
373
- 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-integrate --step 10 --step-label "Update State" 2>/dev/null || true
374
- ```
375
-
376
- Update `.gsd-t/progress.md`:
377
- - Set status to `INTEGRATED`
378
- - Add contract audit results
379
- - Add smoke test results
380
- - List any new tasks created for gaps
381
-
382
- Commit: `[integration] Wire domains together — all contracts verified`
383
-
384
- ### Autonomy Behavior
54
+ - `complete` (integrate green + verify-gate green) auto-advance to `/gsd-t-verify` for the full triad.
55
+ - `verify-failed` (integrate green but verify-gate red) → invoke `gsd-t-debug`.
56
+ - `failed` (integrate failed)cross-domain wire-up could not complete; read `integrate.notes` for the blocker.
385
57
 
386
- **Level 3 (Full Auto)**: Log a brief status line (e.g., "✅ Integrate complete — all domain boundaries wired, {N} contracts verified") and auto-advance to the next phase. Do NOT wait for user input.
58
+ ## Document Ripple
387
59
 
388
- **Level 1–2**: Report integration results and recommend proceeding to verify phase. Wait for confirmation.
60
+ The integrate agent updates:
61
+ - Cross-domain contracts in `.gsd-t/contracts/` (status flips, API surface changes)
62
+ - `.gsd-t/contracts/m{NN}-integration-points.md` — checkpoint flag (C1 done → C2 ready)
63
+ - `.gsd-t/progress.md` — integrate verdict + cross-domain edit summary
389
64
 
390
- $ARGUMENTS
65
+ Each domain's own doc-ripple was handled by the domain worker (per execute Workflow's worker prompt).
391
66
 
392
- ## Auto-Clear
67
+ ## Next Up
393
68
 
394
- All work is committed to project files. Execute `/clear` to free the context window for the next command.
69
+ `/gsd-t-verify` (full orthogonal triad on the integrated milestone state).
@@ -1,143 +1,44 @@
1
1
  # GSD-T: New Milestone — Define and Optionally Partition
2
2
 
3
- You are defining a new milestone for the project. A milestone is a significant deliverable (e.g., "User Authentication", "MVP Launch", "Payment Integration").
3
+ You are the lead agent. Define a new milestone by invoking the generic upper-stage Workflow at `templates/workflows/gsd-t-phase.workflow.js` with `phase: "milestone"`. A milestone is a significant deliverable (e.g., "User Authentication", "Payment Integration").
4
4
 
5
- ## Step 1: Load Context
5
+ ## What this command does
6
6
 
7
- ```bash
8
- 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-milestone --step 1 --step-label "Load Context" 2>/dev/null || true
9
7
  ```
10
-
11
- Read:
12
- 1. `CLAUDE.md`
13
- 2. `.gsd-t/progress.md` — check if GSD-T is initialized
14
- 3. `docs/` — existing documentation
15
-
16
- If `.gsd-t/` doesn't exist, run the init workflow first.
17
-
18
- <!-- M56-D3: brief wire-in -->
19
- **M56 Context-Brief (surfaces last completed milestone + version + recent decision log without re-reading progress.md):**
20
-
21
- ```bash
22
- SPAWN_ID="milestone-${ARG_OR_DEFAULT:-define}-$(date -u +%Y%m%dT%H%M%SZ)"
23
- gsd-t brief --kind milestone --spawn-id "${SPAWN_ID}" --out ".gsd-t/briefs/${SPAWN_ID}.json" || true
24
- export BRIEF_PATH=".gsd-t/briefs/${SPAWN_ID}.json"
8
+ preflight → brief (kind=milestone) → milestone agent (opus, with phase protocol)
25
9
  ```
26
10
 
27
- The `milestone` brief includes `lastCompletedMilestoneRow`, `currentVersion`, and the last 3 decision-log entries so the milestone-definition step can derive version-bump rationale + scope baseline without paging in the full progress history.
28
- <!-- /M56-D3: brief wire-in -->
11
+ The agent defines the milestone origin, goal, falsifiable success criteria — and appends it to `.gsd-t/progress.md`. Partition is deferred (the Next Up successor). Effort/scope is expressed in GSD-T-native units (domain count, wave count, spawn count) never developer-hours.
29
12
 
30
- ## Step 2: Define the Milestone
13
+ ## Step 1: Load context
31
14
 
32
- ```bash
33
- 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-milestone --step 2 --step-label "Define the Milestone" 2>/dev/null || true
34
- ```
35
-
36
- Based on $ARGUMENTS and available documentation:
37
-
38
- 1. **Name**: Clear, descriptive milestone name
39
- 2. **Goal**: 1-2 sentence description of what "done" looks like
40
- 3. **Scope**: What's included and what's explicitly NOT included
41
- 4. **Success criteria**: 3-5 measurable outcomes
42
-
43
- Update `.gsd-t/progress.md` milestones table:
44
- ```markdown
45
- | # | Milestone | Status | Domains |
46
- |---|-----------|--------|---------|
47
- | {N} | {name} | DEFINED | TBD |
48
- ```
15
+ Read `.gsd-t/progress.md` (current version + completed milestones), `docs/requirements.md`, and `docs/architecture.md` so the new milestone is framed against existing state.
49
16
 
50
- ## Step 3: Clear Previous Milestone State (if applicable)
17
+ ## Step 2: Invoke the phase Workflow
51
18
 
52
- ```bash
53
- 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-milestone --step 3 --step-label "Clear Previous Milestone State (if applicable)" 2>/dev/null || true
19
+ ```js
20
+ {
21
+ scriptPath: "templates/workflows/gsd-t-phase.workflow.js",
22
+ args: {
23
+ phase: "milestone",
24
+ projectDir: ".",
25
+ userInput: "$ARGUMENTS"
26
+ }
27
+ }
54
28
  ```
55
29
 
56
- If there's a completed previous milestone:
57
- 1. Archive domain task files (they contain valuable context)
58
- 2. Keep contracts that are still valid
59
- 3. Clean domain task lists for new work
60
- 4. Reset integration checkpoints
61
-
62
- If previous milestone is NOT complete:
63
- Ask user: "Milestone {N-1} is still {status}. Archive it and start new? Or complete it first?"
64
-
65
- ## Step 4: Pre-Partition Assessment
66
-
67
- ```bash
68
- 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-milestone --step 4 --step-label "Pre-Partition Assessment" 2>/dev/null || true
69
- ```
70
-
71
- Before formal partitioning, do a quick assessment.
72
-
73
- **Express scope in GSD-T-native units only.** Per `feedback_no_human_hour_estimates.md` (memory): never use developer-hours, dev-days, sprints, story points, or person-weeks. Use these instead:
74
-
75
- | Unit | Use for |
76
- |------|---------|
77
- | **Domain count** | Partition coarseness (1-2 / 3-4 / 5+) |
78
- | **Wave count** | How many serial gates the milestone needs |
79
- | **Spawn count** | Estimated `claude -p` / Task subagent invocations |
80
- | **Token-spend range** | `$X-Y` based on prior comparable milestones |
81
- | **Rate-limit-window count** | If the milestone might span > 1 5h Claude Max window |
82
- | **Parallel-domain count** | How many domains can run concurrently (file-disjoint) |
83
-
84
- Assessment template:
30
+ ## Step 3: Interpret the result
85
31
 
86
- - **Domain count**: Simple (1-2 domains), Medium (3-4), Complex (5+)
87
- - **Wave count**: estimated based on cross-domain dependencies
88
- - **Parallel-domain count**: how many can run in the same wave
89
- - **Token-spend range**: $X-Y based on prior comparable milestones (read `.gsd-t/token-log.md` for trailing-3 comparison)
90
- - **Recommended approach**:
91
- - 1-2 domains: Consider using /gsd-t-quick for each piece
92
- - 3-4 domains: Standard partition → plan → execute flow
93
- - 5+ domains: Partition → discuss → plan → execute → integrate → verify
94
-
95
- Present the assessment and ask: "Ready to partition into domains now, or want to discuss first?"
96
-
97
- ## Step 5: Document Ripple
98
-
99
- ```bash
100
- 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-milestone --step 5 --step-label "Document Ripple" 2>/dev/null || true
101
- ```
102
-
103
- After defining the milestone, update affected documentation:
104
-
105
- ### Always update:
106
- 1. **`.gsd-t/progress.md`** — Already updated in Step 2, but verify the Decision Log includes the milestone definition with rationale
107
-
108
- ### Check if affected:
109
- 2. **`docs/requirements.md`** — If the milestone scope implies new or changed requirements, add or update them
110
- 3. **`docs/architecture.md`** — If the milestone will introduce new components or change system structure, note planned changes
111
- 4. **`.gsd-t/roadmap.md`** — If it exists, add the new milestone in the proper sequence
112
- 5. **`CLAUDE.md`** — If the milestone establishes new scope boundaries or conventions, add them
113
-
114
- ### Skip what's not affected.
115
-
116
- ## Step 6: Test Verification
117
-
118
- ```bash
119
- 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-milestone --step 6 --step-label "Test Verification" 2>/dev/null || true
120
- ```
121
-
122
- Before proceeding to partition:
123
-
124
- 1. **Run existing tests**: Execute the full test suite to confirm the codebase is clean before starting the milestone
125
- 2. **Verify passing**: If any tests fail, flag them as pre-existing — they should be addressed as part of this milestone or logged as tech debt
126
- 3. **Baseline**: Record test state so the milestone has a clear starting point for quality measurement
127
-
128
- ## Step 7: Auto-Partition (if user confirms)
129
-
130
- ```bash
131
- 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-milestone --step 7 --step-label "Auto-Partition (if user confirms)" 2>/dev/null || true
132
- ```
32
+ The Workflow returns `{ status, artifacts, summary, decisions }`.
133
33
 
134
- If the user wants to proceed immediately, execute the partition workflow (same as gsd-t-partition) for this milestone.
34
+ - `status === "complete"`: milestone defined and appended to progress.md with falsifiable SCs. Do NOT auto-partition for large/risky milestones — show the Next Up hint.
35
+ - `status === "blocked"`: the agent needs a scoping decision from the user.
36
+ - `status === "failed"`: read `summary`.
135
37
 
136
- Otherwise, set status to DEFINED and remind them:
137
- "Run /gsd-t-partition to decompose into domains, or /gsd-t-discuss to explore approaches first."
38
+ ## Document Ripple
138
39
 
139
- $ARGUMENTS
40
+ The milestone agent appends the milestone definition + a Decision Log entry to `.gsd-t/progress.md`.
140
41
 
141
- ## Auto-Clear
42
+ ## Next Up
142
43
 
143
- All work is committed to project files. Execute `/clear` to free the context window for the next command.
44
+ `/gsd-t-partition` decompose the milestone into domains.