@tekyzinc/gsd-t 2.50.12 → 2.53.10

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 (99) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +379 -372
  3. package/bin/component-registry.js +250 -0
  4. package/bin/graph-cgc.js +510 -510
  5. package/bin/graph-indexer.js +147 -147
  6. package/bin/graph-overlay.js +195 -195
  7. package/bin/graph-parsers.js +327 -327
  8. package/bin/graph-query.js +453 -452
  9. package/bin/graph-store.js +154 -154
  10. package/bin/qa-calibrator.js +194 -0
  11. package/bin/scan-data-collector.js +153 -153
  12. package/bin/scan-diagrams-generators.js +187 -187
  13. package/bin/scan-diagrams.js +79 -79
  14. package/bin/scan-renderer.js +92 -92
  15. package/bin/scan-report-sections.js +121 -121
  16. package/bin/scan-report.js +184 -184
  17. package/bin/scan-schema-parsers.js +199 -199
  18. package/bin/scan-schema.js +103 -103
  19. package/bin/token-budget.js +246 -0
  20. package/commands/Claude-md.md +10 -10
  21. package/commands/branch.md +15 -15
  22. package/commands/checkin.md +45 -45
  23. package/commands/global-change.md +209 -209
  24. package/commands/gsd-t-audit.md +199 -0
  25. package/commands/gsd-t-backlog-add.md +94 -94
  26. package/commands/gsd-t-backlog-edit.md +111 -111
  27. package/commands/gsd-t-backlog-list.md +63 -63
  28. package/commands/gsd-t-backlog-move.md +94 -94
  29. package/commands/gsd-t-backlog-promote.md +123 -123
  30. package/commands/gsd-t-backlog-remove.md +86 -86
  31. package/commands/gsd-t-backlog-settings.md +158 -158
  32. package/commands/gsd-t-complete-milestone.md +528 -515
  33. package/commands/gsd-t-debug.md +506 -399
  34. package/commands/gsd-t-discuss.md +174 -174
  35. package/commands/gsd-t-execute.md +758 -634
  36. package/commands/gsd-t-feature.md +276 -276
  37. package/commands/gsd-t-health.md +142 -142
  38. package/commands/gsd-t-help.md +465 -457
  39. package/commands/gsd-t-impact.md +302 -302
  40. package/commands/gsd-t-init.md +320 -280
  41. package/commands/gsd-t-integrate.md +365 -249
  42. package/commands/gsd-t-milestone.md +87 -87
  43. package/commands/gsd-t-partition.md +442 -361
  44. package/commands/gsd-t-pause.md +82 -82
  45. package/commands/gsd-t-plan.md +345 -344
  46. package/commands/gsd-t-populate.md +111 -111
  47. package/commands/gsd-t-prd.md +326 -326
  48. package/commands/gsd-t-project.md +211 -211
  49. package/commands/gsd-t-promote-debt.md +123 -123
  50. package/commands/gsd-t-prompt.md +137 -137
  51. package/commands/gsd-t-qa.md +266 -266
  52. package/commands/gsd-t-quick.md +357 -234
  53. package/commands/gsd-t-reflect.md +134 -134
  54. package/commands/gsd-t-resume.md +72 -72
  55. package/commands/gsd-t-scan.md +615 -615
  56. package/commands/gsd-t-setup.md +76 -0
  57. package/commands/gsd-t-status.md +192 -166
  58. package/commands/gsd-t-test-sync.md +381 -381
  59. package/commands/gsd-t-triage-and-merge.md +171 -171
  60. package/commands/gsd-t-verify.md +382 -382
  61. package/commands/gsd-t-visualize.md +118 -118
  62. package/commands/gsd-t-wave.md +401 -378
  63. package/docs/GSD-T-README.md +425 -422
  64. package/docs/architecture.md +385 -369
  65. package/docs/harness-design-analysis.md +371 -0
  66. package/docs/infrastructure.md +205 -205
  67. package/docs/prd-graph-engine.md +398 -398
  68. package/docs/prd-gsd2-hybrid.md +559 -559
  69. package/docs/prd-harness-evolution.md +583 -0
  70. package/docs/requirements.md +14 -0
  71. package/docs/workflows.md +226 -226
  72. package/examples/.gsd-t/domains/example-domain/scope.md +13 -13
  73. package/package.json +40 -40
  74. package/scripts/gsd-t-auto-route.js +39 -39
  75. package/scripts/gsd-t-dashboard-mockup.html +1143 -1143
  76. package/scripts/gsd-t-dashboard-server.js +171 -171
  77. package/scripts/gsd-t-dashboard.html +262 -262
  78. package/scripts/gsd-t-event-writer.js +128 -128
  79. package/scripts/gsd-t-statusline.js +94 -94
  80. package/scripts/gsd-t-tools.js +175 -175
  81. package/templates/CLAUDE-global.md +639 -614
  82. package/templates/CLAUDE-project.md +24 -0
  83. package/templates/backlog-settings.md +18 -18
  84. package/templates/backlog.md +1 -1
  85. package/templates/progress.md +40 -40
  86. package/templates/shared-services-contract.md +60 -60
  87. package/templates/stacks/desktop.ini +2 -2
  88. package/bin/desktop.ini +0 -2
  89. package/commands/desktop.ini +0 -2
  90. package/docs/ci-examples/desktop.ini +0 -2
  91. package/docs/desktop.ini +0 -2
  92. package/examples/.gsd-t/contracts/desktop.ini +0 -2
  93. package/examples/.gsd-t/desktop.ini +0 -2
  94. package/examples/.gsd-t/domains/desktop.ini +0 -2
  95. package/examples/.gsd-t/domains/example-domain/desktop.ini +0 -2
  96. package/examples/desktop.ini +0 -2
  97. package/examples/rules/desktop.ini +0 -2
  98. package/scripts/desktop.ini +0 -2
  99. package/templates/desktop.ini +0 -2
@@ -1,249 +1,365 @@
1
- # GSD-T: Integrate — Wire Domains Together
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.
4
-
5
- ## Step 1: Load Full State
6
-
7
- Read everything:
8
- 1. `CLAUDE.md`
9
- 2. `.gsd-t/progress.md`
10
- 3. `.gsd-t/contracts/` — all contracts (this is your source of truth)
11
- 4. `.gsd-t/contracts/integration-points.md` — all connection points
12
- 5. `.gsd-t/domains/*/scope.md` — understand boundaries
13
- 6. All source code produced during execution
14
-
15
- ## Step 1.5: Graph-Enhanced Integration Validation
16
-
17
- If `.gsd-t/graph/meta.json` exists (graph index is available):
18
- 1. Query `getDomainBoundaryViolations` to validate that cross-domain wiring matches contracts — flag any code that crosses boundaries without a contract
19
- 2. Query `getCallers` and `getCallees` across domain boundaries to verify all integration points are accounted for in `integration-points.md`
20
- 3. Add any unregistered cross-domain calls to the audit findings in Step 2
21
-
22
- If graph is not available, skip this step.
23
-
24
- ## Step 2: Contract Compliance Audit
25
-
26
- Before wiring anything together, verify each domain honored its contracts:
27
-
28
- For each contract file:
29
- 1. Read the contract specification
30
- 2. Find the implementing code
31
- 3. Verify exact compliance:
32
- - Types/shapes match?
33
- - Endpoint signatures match?
34
- - Error responses match?
35
- - Schema matches?
36
- 4. Log findings:
37
-
38
- ```markdown
39
- ## Contract Audit — {date}
40
-
41
- ### api-contract.md
42
- - POST /api/auth/login: ✅ matches
43
- - GET /api/users/:id: ⚠️ response missing `role` field
44
- - Fix: Update auth/userController.js to include role
45
-
46
- ### schema-contract.md
47
- - Users table: ✅ matches
48
- - Sessions table: ✅ matches
49
- ```
50
-
51
- Fix any mismatches BEFORE proceeding to integration.
52
-
53
- ## Step 2.5: Worktree Merge Status Check
54
-
55
- Before wiring integration points, check whether team mode execution left any domains with rolled-back worktree merges:
56
-
57
- 1. Read `.gsd-t/progress.md` — look for `[rollback]` entries in the Decision Log from the execute phase
58
- 2. If any domains were rolled back: list them and their failure reasons before proceeding
59
- 3. Integration point wiring should only proceed for domains whose worktree merges PASSED — rolled-back domains are not yet in the main working tree
60
-
61
- 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.
62
-
63
- ## Step 3: Wire Integration Points
64
-
65
- **Stack Rules Detection (before spawning subagent):**
66
- Run via Bash to detect project stack and collect matching rules:
67
- `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'; fi`
68
-
69
- If STACK_RULES is non-empty, append to the subagent prompt:
70
- ```
71
- ## Stack Rules (MANDATORY — violations fail this task)
72
-
73
- {STACK_RULES}
74
-
75
- These standards have the same enforcement weight as contract compliance.
76
- Violations are task failures, not warnings.
77
- ```
78
-
79
- If STACK_RULES is empty (no templates/stacks/ dir or no matches), skip silently.
80
-
81
- 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.
82
-
83
- **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`:
84
- 1. Sort domains by dependency order (from integration-points.md)
85
- 2. Merge domain A's branch → run tests → merge domain B's branch → run tests
86
- 3. If tests fail after a merge, roll back that domain's merge and log the failure
87
- 4. Contract validation runs between merges
88
- 5. All temporary branches cleaned up after integration completes
89
-
90
- For each connection:
91
- 1. Identify the producing domain (provides the interface)
92
- 2. Identify the consuming domain (calls the interface)
93
- 3. Write or verify the glue code:
94
- - Import statements
95
- - Configuration (env vars, connection strings)
96
- - Middleware chains
97
- - Route registration
98
- - Dependency injection
99
- 4. Ensure error handling flows across the boundary correctly
100
-
101
- ### Common integration tasks:
102
- - **API → UI**: Verify fetch calls match endpoint signatures
103
- - **Auth → Routes**: Wire middleware into route definitions
104
- - **Data layer → Services**: Connect repositories/models to service layer
105
- - **Config**: Ensure shared config (env vars, constants) is consistent
106
-
107
- ## Step 4: End-to-End Smoke Test
108
-
109
- Run through the primary user flows:
110
- 1. Identify the 3-5 most critical paths from requirements
111
- 2. Trace each path through all domain boundaries
112
- 3. Run or manually verify each path works
113
- 4. Document results:
114
-
115
- ```markdown
116
- ## Smoke Test Results
117
-
118
- ### Flow: User Login
119
- 1. UI → POST /api/auth/login ✅
120
- 2. Auth → Users table lookup ✅
121
- 3. Auth → JWT generation ✅
122
- 4. Auth → Response to UI ✅
123
- 5. UI → Store token, redirect ✅
124
- Result: PASS
125
-
126
- ### Flow: Protected Resource Access
127
- 1. UI → GET /api/data with token ✅
128
- 2. Auth middleware → verify token ✅
129
- 3. Data layer → query ⚠️ — missing pagination
130
- Result: PARTIAL — needs pagination contract addition
131
- ```
132
-
133
- ## Step 5: Contract Compliance Testing
134
-
135
- Spawn a QA subagent via the Task tool to verify contract compliance at all domain boundaries:
136
-
137
- ```
138
- Task subagent (general-purpose, model: haiku):
139
- "Run contract compliance tests for this integration. Read .gsd-t/contracts/ for all contract definitions.
140
- Test every domain boundary: verify that producers and consumers match their contract shapes.
141
- Run ALL configured test suites — detect and run every one:
142
- a. Unit tests (vitest/jest/mocha): run the full suite
143
- b. E2E tests: check for playwright.config.* or cypress.config.* — if found, run the FULL E2E suite
144
- c. NEVER skip E2E when a config file exists. Running only unit tests is a QA FAILURE.
145
- d. AUDIT E2E test quality: Review each Playwright spec — if any test only checks element existence
146
- (isVisible, toBeAttached, toBeEnabled) without verifying functional behavior (state changes,
147
- data loaded, content updated after actions), flag it as 'SHALLOW TEST needs functional assertions'.
148
- Report: 'Unit: X/Y pass | E2E: X/Y pass (or N/A if no config) | Boundary: pass/fail by contract | Shallow tests: N'"
149
- ```
150
-
151
- **OBSERVABILITY LOGGING (MANDATORY):**
152
- Before spawning run via Bash:
153
- `T_START=$(date +%s) && DT_START=$(date +"%Y-%m-%d %H:%M") && TOK_START=${CLAUDE_CONTEXT_TOKENS_USED:-0} && TOK_MAX=${CLAUDE_CONTEXT_TOKENS_MAX:-200000}`
154
- After subagent returns run via Bash:
155
- `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
156
- Compute tokens and compaction:
157
- - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
158
- - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
159
- Compute context utilization — run via Bash:
160
- `if [ "${CLAUDE_CONTEXT_TOKENS_MAX:-0}" -gt 0 ]; then CTX_PCT=$(echo "scale=1; ${CLAUDE_CONTEXT_TOKENS_USED:-0} * 100 / ${CLAUDE_CONTEXT_TOKENS_MAX}" | bc); else CTX_PCT="N/A"; fi`
161
- Alert on context thresholds (display to user inline):
162
- - If CTX_PCT >= 85: `echo "🔴 CRITICAL: Context at ${CTX_PCT}% compaction likely. Task MUST be split."`
163
- - If CTX_PCT >= 70: `echo "⚠️ WARNING: Context at ${CTX_PCT}% — approaching compaction threshold. Consider splitting in plan."`
164
- Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted | Domain | Task | Ctx% |` if missing):
165
- `| {DT_START} | {DT_END} | gsd-t-integrate | Step 5 | haiku | {DURATION}s | {pass/fail}, {N} boundaries tested | {TOKENS} | {COMPACTED} | | | {CTX_PCT} |`
166
- 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):
167
- `| {DT_START} | gsd-t-integrate | Step 5 | haiku | {DURATION}s | {severity} | {finding} |`
168
-
169
- QA failure blocks integration completion.
170
-
171
- ## Step 6: Document Ripple
172
-
173
- Integration is where the real system takes shape. Verify documentation matches reality:
174
-
175
- ### Always update:
176
- 1. **`.gsd-t/progress.md`** Log integration results, contract audit findings, smoke test outcomes
177
-
178
- ### Check if affected:
179
- 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
180
- 3. **`docs/requirements.md`** Did integration reveal missing requirements or invalidate existing ones? Update it
181
- 4. **`docs/schema.md`** Does the documented schema match the actual database state? Update it
182
- 5. **`CLAUDE.md`** Did integration establish new conventions (error handling patterns, middleware chains, configuration approaches) that future work should follow? Add them
183
- 6. **`.gsd-t/techdebt.md`** Did integration reveal new debt (workarounds, temporary glue code, known shortcuts)? Add TD items
184
-
185
- ### Skip what's not affected.
186
-
187
- ## Step 7: Test Verification
188
-
189
- After integration and doc ripple, verify everything works together:
190
-
191
- 1. **Update tests**: Add or update integration tests for newly wired domain boundaries
192
- 2. **Run ALL configured test suites** — detect and run every one:
193
- a. Unit/integration tests (vitest/jest/mocha)
194
- b. If `playwright.config.*` exists → run `npx playwright test` (full suite, not just affected specs)
195
- c. Unit tests alone are NEVER sufficient when E2E exists
196
- d. Report: "Unit: X/Y pass | E2E: X/Y pass"
197
- 3. **Verify passing**: All tests must pass. If any fail, fix before proceeding (up to 2 attempts)
198
- 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.
199
- 5. **Smoke test results**: Ensure the Step 4 smoke test results are still valid after any fixes
200
-
201
- ## Step 7.5: Doc-Ripple (Automated)
202
-
203
- After all integration work is committed but before reporting completion:
204
-
205
- 1. Run threshold check — read `git diff --name-only HEAD~1` and evaluate against doc-ripple-contract.md trigger conditions
206
- 2. If SKIP: log "Doc-ripple: SKIP — {reason}" and proceed to completion
207
- 3. If FIRE: spawn doc-ripple agent:
208
-
209
- [{model}] gsd-t-doc-ripple blast radius analysis + parallel updates
210
-
211
- Task subagent (general-purpose, model: sonnet):
212
- "Execute the doc-ripple workflow per commands/gsd-t-doc-ripple.md.
213
- Git diff context: {files changed list}
214
- Command that triggered: integrate
215
- Produce manifest at .gsd-t/doc-ripple-manifest.md.
216
- Update all affected documents.
217
- Report: 'Doc-ripple: {N} checked, {N} updated, {N} skipped'"
218
-
219
- 4. After doc-ripple returns, verify manifest exists and report summary inline
220
-
221
- ## Step 8: Handle Integration Issues
222
-
223
- For each issue found:
224
- 1. Determine if it's a contract gap (missing specification) or implementation bug
225
- 2. **Contract gap**: Update the contract, create a follow-up task
226
- 3. **Implementation bug**: Fix it directly, document the fix
227
- 4. Log everything in progress.md
228
-
229
- ## Step 9: Update State
230
-
231
- Update `.gsd-t/progress.md`:
232
- - Set status to `INTEGRATED`
233
- - Add contract audit results
234
- - Add smoke test results
235
- - List any new tasks created for gaps
236
-
237
- Commit: `[integration] Wire domains together all contracts verified`
238
-
239
- ### Autonomy Behavior
240
-
241
- **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.
242
-
243
- **Level 1–2**: Report integration results and recommend proceeding to verify phase. Wait for confirmation.
244
-
245
- $ARGUMENTS
246
-
247
- ## Auto-Clear
248
-
249
- All work is committed to project files. Execute `/clear` to free the context window for the next command.
1
+ # GSD-T: Integrate — Wire Domains Together
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.
4
+
5
+ ## Step 1: Load Full State
6
+
7
+ Read everything:
8
+ 1. `CLAUDE.md`
9
+ 2. `.gsd-t/progress.md`
10
+ 3. `.gsd-t/contracts/` — all contracts (this is your source of truth)
11
+ 4. `.gsd-t/contracts/integration-points.md` — all connection points
12
+ 5. `.gsd-t/domains/*/scope.md` — understand boundaries
13
+ 6. All source code produced during execution
14
+
15
+ ## Step 1.5: Graph-Enhanced Integration Validation
16
+
17
+ If `.gsd-t/graph/meta.json` exists (graph index is available):
18
+ 1. Query `getDomainBoundaryViolations` to validate that cross-domain wiring matches contracts — flag any code that crosses boundaries without a contract
19
+ 2. Query `getCallers` and `getCallees` across domain boundaries to verify all integration points are accounted for in `integration-points.md`
20
+ 3. Add any unregistered cross-domain calls to the audit findings in Step 2
21
+
22
+ If graph is not available, skip this step.
23
+
24
+ ## Step 2: Contract Compliance Audit
25
+
26
+ Before wiring anything together, verify each domain honored its contracts:
27
+
28
+ For each contract file:
29
+ 1. Read the contract specification
30
+ 2. Find the implementing code
31
+ 3. Verify exact compliance:
32
+ - Types/shapes match?
33
+ - Endpoint signatures match?
34
+ - Error responses match?
35
+ - Schema matches?
36
+ 4. Log findings:
37
+
38
+ ```markdown
39
+ ## Contract Audit — {date}
40
+
41
+ ### api-contract.md
42
+ - POST /api/auth/login: ✅ matches
43
+ - GET /api/users/:id: ⚠️ response missing `role` field
44
+ - Fix: Update auth/userController.js to include role
45
+
46
+ ### schema-contract.md
47
+ - Users table: ✅ matches
48
+ - Sessions table: ✅ matches
49
+ ```
50
+
51
+ Fix any mismatches BEFORE proceeding to integration.
52
+
53
+ ## Step 2.5: Worktree Merge Status Check
54
+
55
+ Before wiring integration points, check whether team mode execution left any domains with rolled-back worktree merges:
56
+
57
+ 1. Read `.gsd-t/progress.md` — look for `[rollback]` entries in the Decision Log from the execute phase
58
+ 2. If any domains were rolled back: list them and their failure reasons before proceeding
59
+ 3. Integration point wiring should only proceed for domains whose worktree merges PASSED — rolled-back domains are not yet in the main working tree
60
+
61
+ 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.
62
+
63
+ ## Step 3: Wire Integration Points
64
+
65
+ **Stack Rules Detection (before spawning subagent):**
66
+ Run via Bash to detect project stack and collect matching rules:
67
+ `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'; fi`
68
+
69
+ If STACK_RULES is non-empty, append to the subagent prompt:
70
+ ```
71
+ ## Stack Rules (MANDATORY — violations fail this task)
72
+
73
+ {STACK_RULES}
74
+
75
+ These standards have the same enforcement weight as contract compliance.
76
+ Violations are task failures, not warnings.
77
+ ```
78
+
79
+ If STACK_RULES is empty (no templates/stacks/ dir or no matches), skip silently.
80
+
81
+ 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.
82
+
83
+ **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`:
84
+ 1. Sort domains by dependency order (from integration-points.md)
85
+ 2. Merge domain A's branch → run tests → merge domain B's branch → run tests
86
+ 3. If tests fail after a merge, roll back that domain's merge and log the failure
87
+ 4. Contract validation runs between merges
88
+ 5. All temporary branches cleaned up after integration completes
89
+
90
+ For each connection:
91
+ 1. Identify the producing domain (provides the interface)
92
+ 2. Identify the consuming domain (calls the interface)
93
+ 3. Write or verify the glue code:
94
+ - Import statements
95
+ - Configuration (env vars, connection strings)
96
+ - Middleware chains
97
+ - Route registration
98
+ - Dependency injection
99
+ 4. Ensure error handling flows across the boundary correctly
100
+
101
+ ### Common integration tasks:
102
+ - **API → UI**: Verify fetch calls match endpoint signatures
103
+ - **Auth → Routes**: Wire middleware into route definitions
104
+ - **Data layer → Services**: Connect repositories/models to service layer
105
+ - **Config**: Ensure shared config (env vars, constants) is consistent
106
+
107
+ ## Step 4: End-to-End Smoke Test
108
+
109
+ Run through the primary user flows:
110
+ 1. Identify the 3-5 most critical paths from requirements
111
+ 2. Trace each path through all domain boundaries
112
+ 3. Run or manually verify each path works
113
+ 4. Document results:
114
+
115
+ ```markdown
116
+ ## Smoke Test Results
117
+
118
+ ### Flow: User Login
119
+ 1. UI → POST /api/auth/login ✅
120
+ 2. Auth → Users table lookup ✅
121
+ 3. Auth → JWT generation ✅
122
+ 4. Auth → Response to UI ✅
123
+ 5. UI → Store token, redirect ✅
124
+ Result: PASS
125
+
126
+ ### Flow: Protected Resource Access
127
+ 1. UI → GET /api/data with token ✅
128
+ 2. Auth middleware → verify token ✅
129
+ 3. Data layer → query ⚠️ — missing pagination
130
+ Result: PARTIAL — needs pagination contract addition
131
+ ```
132
+
133
+ ## Step 5: Contract Compliance Testing
134
+
135
+ **QA Calibration Injection** Before spawning QA, check for known weak spots:
136
+
137
+ Run via Bash:
138
+ `node -e "const qc = require('./bin/qa-calibrator.js'); const inj = qc.generateQAInjection('.'); if(inj) process.stdout.write(inj);" 2>/dev/null`
139
+
140
+ If the command produces output (non-empty), store it as `QA_INJECTION` and prepend it to the QA subagent prompt below. If the file doesn't exist or produces no output, skip silently.
141
+
142
+ Spawn a QA subagent via the Task tool to verify contract compliance at all domain boundaries:
143
+
144
+ ```
145
+ Task subagent (general-purpose, model: sonnet):
146
+ "{QA_INJECTION — if non-empty, insert here as a preamble section before the instructions below}
147
+ Run contract compliance tests for this integration. Read .gsd-t/contracts/ for all contract definitions.
148
+ Test every domain boundary: verify that producers and consumers match their contract shapes.
149
+ Run ALL configured test suites — detect and run every one:
150
+ a. Unit tests (vitest/jest/mocha): run the full suite
151
+ b. E2E tests: check for playwright.config.* or cypress.config.* — if found, run the FULL E2E suite
152
+ c. NEVER skip E2E when a config file exists. Running only unit tests is a QA FAILURE.
153
+ d. AUDIT E2E test quality: Review each Playwright spec — if any test only checks element existence
154
+ (isVisible, toBeAttached, toBeEnabled) without verifying functional behavior (state changes,
155
+ data loaded, content updated after actions), flag it as 'SHALLOW TEST — needs functional assertions'.
156
+ Report: 'Unit: X/Y pass | E2E: X/Y pass (or N/A if no config) | Boundary: pass/fail by contract | Shallow tests: N'
157
+
158
+ ## Exploratory Testing (if Playwright MCP available)
159
+
160
+ After all scripted tests pass:
161
+ 1. Check if Playwright MCP is registered in Claude Code settings (look for "playwright" in mcpServers)
162
+ 2. If available: spend 3 minutes on interactive exploration using Playwright MCP
163
+ - Try variations of happy paths with unexpected inputs
164
+ - Probe for race conditions, double-submits, empty states
165
+ - Test accessibility (keyboard navigation, screen reader flow)
166
+ 3. Tag all findings [EXPLORATORY] in your report and append to .gsd-t/qa-issues.md with [EXPLORATORY] prefix
167
+ 4. If Playwright MCP is not available: skip this section silently
168
+ Note: Exploratory findings do NOT count against the scripted test pass/fail ratio."
169
+ ```
170
+
171
+ **OBSERVABILITY LOGGING (MANDATORY):**
172
+ Before spawning — run via Bash:
173
+ `T_START=$(date +%s) && DT_START=$(date +"%Y-%m-%d %H:%M") && TOK_START=${CLAUDE_CONTEXT_TOKENS_USED:-0} && TOK_MAX=${CLAUDE_CONTEXT_TOKENS_MAX:-200000}`
174
+ After subagent returns — run via Bash:
175
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
176
+ Compute tokens and compaction:
177
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
178
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
179
+ Compute context utilization run via Bash:
180
+ `if [ "${CLAUDE_CONTEXT_TOKENS_MAX:-0}" -gt 0 ]; then CTX_PCT=$(echo "scale=1; ${CLAUDE_CONTEXT_TOKENS_USED:-0} * 100 / ${CLAUDE_CONTEXT_TOKENS_MAX}" | bc); else CTX_PCT="N/A"; fi`
181
+ Alert on context thresholds (display to user inline):
182
+ - If CTX_PCT >= 85: `echo "🔴 CRITICAL: Context at ${CTX_PCT}% compaction likely. Task MUST be split."`
183
+ - If CTX_PCT >= 70: `echo "⚠️ WARNING: Context at ${CTX_PCT}% approaching compaction threshold. Consider splitting in plan."`
184
+ Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted | Domain | Task | Ctx% |` if missing):
185
+ `| {DT_START} | {DT_END} | gsd-t-integrate | Step 5 | haiku | {DURATION}s | {pass/fail}, {N} boundaries tested | {TOKENS} | {COMPACTED} | | | {CTX_PCT} |`
186
+ 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):
187
+ `| {DT_START} | gsd-t-integrate | Step 5 | haiku | {DURATION}s | {severity} | {finding} |`
188
+
189
+ QA failure blocks integration completion.
190
+
191
+ ## Step 6: Document Ripple
192
+
193
+ Integration is where the real system takes shape. Verify documentation matches reality:
194
+
195
+ ### Always update:
196
+ 1. **`.gsd-t/progress.md`** Log integration results, contract audit findings, smoke test outcomes
197
+
198
+ ### Check if affected:
199
+ 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
200
+ 3. **`docs/requirements.md`** — Did integration reveal missing requirements or invalidate existing ones? Update it
201
+ 4. **`docs/schema.md`** Does the documented schema match the actual database state? Update it
202
+ 5. **`CLAUDE.md`** — Did integration establish new conventions (error handling patterns, middleware chains, configuration approaches) that future work should follow? Add them
203
+ 6. **`.gsd-t/techdebt.md`** — Did integration reveal new debt (workarounds, temporary glue code, known shortcuts)? Add TD items
204
+
205
+ ### Skip what's not affected.
206
+
207
+ ## Step 7: Test Verification
208
+
209
+ After integration and doc ripple, verify everything works together:
210
+
211
+ 1. **Update tests**: Add or update integration tests for newly wired domain boundaries
212
+ 2. **Run ALL configured test suites** — detect and run every one:
213
+ a. Unit/integration tests (vitest/jest/mocha)
214
+ b. If `playwright.config.*` exists → run `npx playwright test` (full suite, not just affected specs)
215
+ c. Unit tests alone are NEVER sufficient when E2E exists
216
+ d. Report: "Unit: X/Y pass | E2E: X/Y pass"
217
+ 3. **Verify passing**: All tests must pass. If any fail, fix before proceeding (up to 2 attempts)
218
+ 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.
219
+ 5. **Smoke test results**: Ensure the Step 4 smoke test results are still valid after any fixes
220
+
221
+ ## Step 7.5: Red Team — Adversarial QA (MANDATORY)
222
+
223
+ After integration tests pass, spawn an adversarial Red Team agent. This agent's sole purpose is to BREAK the integrated system. Its success is measured by bugs found, not tests passed.
224
+
225
+ [{model}] Red Team adversarial validation of integrated system
226
+
227
+ **OBSERVABILITY LOGGING (MANDATORY):**
228
+ Before spawning — run via Bash:
229
+ `T_START=$(date +%s) && DT_START=$(date +"%Y-%m-%d %H:%M") && TOK_START=${CLAUDE_CONTEXT_TOKENS_USED:-0} && TOK_MAX=${CLAUDE_CONTEXT_TOKENS_MAX:-200000}`
230
+
231
+ ```
232
+ Task subagent (general-purpose, model: opus):
233
+ "You are a Red Team QA adversary. Your job is to BREAK the integrated system.
234
+
235
+ Your value is measured by REAL bugs found. More bugs = more value.
236
+ If you find zero bugs, you must prove you were thorough — list every
237
+ attack vector you tried and why it didn't break. A short list means
238
+ you didn't try hard enough.
239
+
240
+ Rules:
241
+ - False positives DESTROY your credibility. If you report something
242
+ as a bug and it's actually correct behavior, that's worse than
243
+ missing a real bug. Never report something you haven't reproduced.
244
+ - Style opinions are not bugs. Theoretical concerns are not bugs.
245
+ A bug is: 'I did X, expected Y, got Z.' With proof.
246
+ - You are done ONLY when you have exhausted every category below
247
+ and either found a bug or documented exactly what you tried.
248
+
249
+ ## Attack Categories (exhaust ALL of these)
250
+
251
+ 1. **Contract Violations**: Read .gsd-t/contracts/. Does the code EXACTLY
252
+ match every contract? Test each endpoint/interface/schema shape.
253
+ 2. **Boundary Inputs**: Empty strings, null, undefined, huge payloads,
254
+ special characters, SQL injection attempts, XSS payloads, path traversal.
255
+ 3. **State Transitions**: What happens when actions are performed out of
256
+ order? Double-submit? Concurrent access? Refresh mid-flow?
257
+ 4. **Error Paths**: Remove env vars. Kill the database. Send malformed
258
+ requests. Does the code handle failures gracefully or crash?
259
+ 5. **Missing Flows**: Read docs/requirements.md. Are there user flows that
260
+ exist in requirements but have NO test coverage? Write tests for them.
261
+ 6. **Regression**: Run the FULL test suite. Did any existing tests break?
262
+ 7. **E2E Functional Gaps**: Review ALL Playwright specs. Do they test actual
263
+ behavior (state changes, data loaded, navigation works) or just check
264
+ that elements exist? Flag and rewrite any shallow/layout tests.
265
+ 8. **Cross-Domain Boundaries**: Test data flow across EVERY domain boundary.
266
+ Does data arriving from domain A get validated by domain B? What happens
267
+ when domain A sends malformed data that passed A's own validation?
268
+
269
+ ## Exploratory Testing (if Playwright MCP available)
270
+
271
+ After all scripted tests pass:
272
+ 1. Check if Playwright MCP is registered in Claude Code settings (look for "playwright" in mcpServers)
273
+ 2. If available: spend 5 minutes on adversarial interactive exploration using Playwright MCP
274
+ - Attempt race conditions, double-submits, concurrent access patterns
275
+ - Try unexpected input sequences, boundary values, rapid state transitions
276
+ - Probe error recovery: does the app recover after failures or get stuck?
277
+ 3. Tag all findings [EXPLORATORY] in your report
278
+ 4. If Playwright MCP is not available: skip this section silently
279
+ Note: Exploratory findings are additive — they do not replace scripted test results.
280
+
281
+ ## Report Format
282
+
283
+ For each bug found:
284
+ - **BUG-{N}**: {severity: CRITICAL/HIGH/MEDIUM/LOW}
285
+ - **Reproduction**: {exact steps to reproduce}
286
+ - **Expected**: {what should happen}
287
+ - **Actual**: {what actually happens}
288
+ - **Proof**: {test file or command that demonstrates the bug}
289
+
290
+ Summary:
291
+ - BUGS FOUND: {count} (with severity breakdown)
292
+ - COVERAGE GAPS: {untested flows from requirements}
293
+ - SHALLOW TESTS REWRITTEN: {count}
294
+ - CONTRACTS VERIFIED: {N}/{total}
295
+ - ATTACK VECTORS TRIED: {list every category attempted and results}
296
+ - VERDICT: FAIL ({N} bugs found) | GRUDGING PASS (exhaustive search, nothing found)
297
+
298
+ Write all findings to .gsd-t/red-team-report.md.
299
+ If bugs found, also append to .gsd-t/qa-issues.md."
300
+ ```
301
+
302
+ After subagent returns — run via Bash:
303
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
304
+ Compute tokens and compaction:
305
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
306
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
307
+ Append to `.gsd-t/token-log.md`:
308
+ `| {DT_START} | {DT_END} | gsd-t-integrate | Red Team | sonnet | {DURATION}s | {VERDICT} — {N} bugs found | {TOKENS} | {COMPACTED} | | | {CTX_PCT} |`
309
+
310
+ **If Red Team VERDICT is FAIL:**
311
+ 1. Fix all CRITICAL and HIGH bugs immediately (up to 2 fix attempts per bug)
312
+ 2. Re-run Red Team after fixes
313
+ 3. If bugs persist after 2 fix cycles, log to `.gsd-t/deferred-items.md` and present to user
314
+
315
+ **If Red Team VERDICT is GRUDGING PASS:** Proceed to doc-ripple.
316
+
317
+ ## Step 8: Doc-Ripple (Automated)
318
+
319
+ After all integration work is committed but before reporting completion:
320
+
321
+ 1. Run threshold check — read `git diff --name-only HEAD~1` and evaluate against doc-ripple-contract.md trigger conditions
322
+ 2. If SKIP: log "Doc-ripple: SKIP — {reason}" and proceed to completion
323
+ 3. If FIRE: spawn doc-ripple agent:
324
+
325
+ ⚙ [{model}] gsd-t-doc-ripple → blast radius analysis + parallel updates
326
+
327
+ Task subagent (general-purpose, model: sonnet):
328
+ "Execute the doc-ripple workflow per commands/gsd-t-doc-ripple.md.
329
+ Git diff context: {files changed list}
330
+ Command that triggered: integrate
331
+ Produce manifest at .gsd-t/doc-ripple-manifest.md.
332
+ Update all affected documents.
333
+ Report: 'Doc-ripple: {N} checked, {N} updated, {N} skipped'"
334
+
335
+ 4. After doc-ripple returns, verify manifest exists and report summary inline
336
+
337
+ ## Step 9: Handle Integration Issues
338
+
339
+ For each issue found:
340
+ 1. Determine if it's a contract gap (missing specification) or implementation bug
341
+ 2. **Contract gap**: Update the contract, create a follow-up task
342
+ 3. **Implementation bug**: Fix it directly, document the fix
343
+ 4. Log everything in progress.md
344
+
345
+ ## Step 10: Update State
346
+
347
+ Update `.gsd-t/progress.md`:
348
+ - Set status to `INTEGRATED`
349
+ - Add contract audit results
350
+ - Add smoke test results
351
+ - List any new tasks created for gaps
352
+
353
+ Commit: `[integration] Wire domains together — all contracts verified`
354
+
355
+ ### Autonomy Behavior
356
+
357
+ **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.
358
+
359
+ **Level 1–2**: Report integration results and recommend proceeding to verify phase. Wait for confirmation.
360
+
361
+ $ARGUMENTS
362
+
363
+ ## Auto-Clear
364
+
365
+ All work is committed to project files. Execute `/clear` to free the context window for the next command.