@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,491 +1,45 @@
1
1
  # GSD-T: Plan — Create Domain Task Lists with Dependencies
2
2
 
3
- You are the lead agent creating atomic execution plans for each domain. This phase is ALWAYS single-session — one agent with full context across all domains to ensure consistency.
3
+ You are the lead agent. Run the plan phase by invoking the generic upper-stage Workflow at `templates/workflows/gsd-t-phase.workflow.js` with `phase: "plan"`. Planning is ALWAYS single-session — one agent with full context across all domains to ensure consistency. The phase Workflow runs exactly one planning agent, preserving that property.
4
4
 
5
- ## Model Assignment
5
+ ## What this command does
6
6
 
7
- Per `.gsd-t/contracts/model-selection-contract.md` v1.0.0.
8
-
9
- - **Default**: `sonnet` (`selectModel({phase: "plan"})`) — task decomposition is structured work.
10
- - **Escalation**: `/advisor` convention-based fallback from `bin/advisor-integration.js` when a task touches a contract boundary or requires a decision about task granularity (too coarse → brittle execution; too fine → coordination overhead). Never silently downgrade the model under context pressure — M35 removed that behavior.
11
-
12
- ## Step 1: Load Full Context
13
-
14
- ```bash
15
- 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-plan --step 1 --step-label "Load Full Context" 2>/dev/null || true
16
- ```
17
-
18
- Read ALL of these:
19
- 1. `CLAUDE.md`
20
- 2. `.gsd-t/progress.md`
21
- 3. `.gsd-t/contracts/` — every contract file
22
- 4. `.gsd-t/domains/*/scope.md` — every domain scope
23
- 5. `.gsd-t/domains/*/constraints.md` — every domain constraint
24
- 6. `docs/` — requirements, architecture, schema, design
25
- 7. Existing source code (if any) — understand current state
26
- 8. `.gsd-t/CONTEXT.md` (if exists — from discuss phase) — **MANDATORY READ if present**
27
-
28
- **If CONTEXT.md exists:** Every Locked Decision listed in it MUST be mapped to at least one task in Step 2. Do NOT proceed to execute if any Locked Decision is unmapped.
29
-
30
- <!-- M56-D3: brief wire-in -->
31
- **M56 Context-Brief (replaces 30–60k context re-read with ≤2,500-token JSON snapshot):**
32
-
33
- ```bash
34
- SPAWN_ID="plan-${MILESTONE:-default}-$(date -u +%Y%m%dT%H%M%SZ)"
35
- gsd-t brief --kind plan --spawn-id "${SPAWN_ID}" --out ".gsd-t/briefs/${SPAWN_ID}.json" || true
36
- export BRIEF_PATH=".gsd-t/briefs/${SPAWN_ID}.json"
37
- ```
38
-
39
- Pass `$BRIEF_PATH` into any worker prompts spawned downstream (validation subagents read it via `templates/prompts/{qa,red-team,design-verify}-subagent.md`).
40
- <!-- /M56-D3: brief wire-in -->
41
-
42
- ## Step 1.5: Graph-Enhanced Dependency Detection
43
-
44
- ```bash
45
- 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-plan --step 1 --step-label ".5: Graph-Enhanced Dependency Detection" 2>/dev/null || true
46
- ```
47
-
48
- If `.gsd-t/graph/meta.json` exists (graph index is available):
49
- 1. Query `findDuplicates` to detect when planned tasks would create duplicate functions across domains — flag for SharedCore extraction or deduplication
50
- 2. Query `getImporters` for key modules to identify implicit task dependencies that might not be obvious from contracts alone
51
- 3. Feed these findings into the Cross-Domain Duplicate Operation Scan and dependency mapping in Steps 2–3
52
-
53
- If graph is not available, skip this step.
54
-
55
- ## Step 1.7: Pre-Mortem — Historical Failure Analysis
56
-
57
- ```bash
58
- 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-plan --step 1 --step-label ".7: Pre-Mortem — Historical Failure Analysis" 2>/dev/null || true
59
- ```
60
-
61
- Before creating task lists, check historical task-metrics for domain-level failure patterns from previous milestones:
62
-
63
- 1. Run via Bash:
64
- `node -e "const c = require('./bin/metrics-collector.js'); const domains = [/* list domain names from scope files */]; domains.forEach(d => { const w = c.getPreFlightWarnings(d); if(w.length) w.forEach(x => console.log('⚠️ ' + x)); });" 2>/dev/null || true`
65
-
66
- 2. If any domain has `first_pass_rate < 0.6` historically:
67
- - Display warning inline: `⚠️ Domain {name} has historically low first-pass rate ({rate}%). Consider: smaller tasks, more explicit acceptance criteria, or additional contract detail.`
68
- - This is **non-blocking** — it informs task design, does not prevent planning.
69
-
70
- 3. If `.gsd-t/metrics/task-metrics.jsonl` does not exist: skip this step silently (first milestone, no historical data).
71
-
72
- 4. **Rule-based pre-mortem**: Run via Bash:
73
- `node -e "const re = require('./bin/rule-engine.js'); const domains = [/* list domain names */]; domains.forEach(d => { const rules = re.getPreMortemRules(d); if(rules.length) rules.forEach(r => console.log('RULE ' + r.id + ': ' + r.name + ' — historically triggered for domains like ' + d)); });" 2>/dev/null || true`
74
-
75
- If matching rules found: display warnings inline (non-blocking — informs task design). Falls back gracefully if rules.jsonl does not exist or is empty.
76
-
77
- ## Step 2: Create Task Lists Per Domain
78
-
79
- ```bash
80
- 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-plan --step 2 --step-label "Create Task Lists Per Domain" 2>/dev/null || true
81
- ```
82
-
83
- ### SharedCore-First Pre-Check
84
-
85
- Before writing any domain task lists:
86
- 1. Does `.gsd-t/contracts/shared-services-contract.md` exist?
87
- - **YES**: A `shared-core` domain has been identified. Plan its tasks first. All client-surface domains that consume SharedCore operations are BLOCKED BY shared-core until its tasks complete. Use `BLOCKED BY shared-core Task {N}` in the relevant client domain task lists.
88
- - **NO**: Proceed. The Cross-Domain Duplicate Operation Scan (below) will catch any shared operations missed during partition.
89
-
90
- For each domain, write `.gsd-t/domains/{domain-name}/tasks.md`:
91
-
92
- ```markdown
93
- # Tasks: {domain-name}
94
-
95
- ## Summary
96
- {1-2 sentence description of what this domain delivers when all tasks complete}
97
-
98
- ## Tasks
99
-
100
- ### Task 1: {descriptive name}
101
- - **Files**: {files to create or modify}
102
- - **Contract refs**: {which contracts this implements}
103
- - **Dependencies**: NONE | BLOCKED by {domain} Task {N}
104
- - **Acceptance criteria**:
105
- - {specific testable outcome}
106
- - {specific testable outcome}
107
-
108
- ### Task 2: {descriptive name}
109
- - **Files**: {files to create or modify}
110
- - **Contract refs**: {which contracts this implements}
111
- - **Dependencies**: Requires Task 1 (within domain)
112
- - **Acceptance criteria**:
113
- - {specific testable outcome}
114
7
  ```
115
-
116
- ### Design Hierarchy Task Generation (when hierarchical design contracts exist)
117
-
118
- If `.gsd-t/contracts/design/INDEX.md` exists, the design was decomposed into a hierarchy: **elements → widgets → pages**. This hierarchy IS the execution plan. Each level must be built and verified before the next level composes it.
119
-
120
- **Detection**: Check for `.gsd-t/contracts/design/INDEX.md`. If it does NOT exist, skip this section entirely — use standard task generation above.
121
-
122
- **If it EXISTS**: Read INDEX.md to extract the element, widget, and page contract lists. Then generate tasks in strict build order:
123
-
124
- **Wave 1 — Elements (one task per element contract, all parallel-safe):**
125
-
126
- Read each contract file in `.gsd-t/contracts/design/elements/`. For each element:
127
-
128
- ```markdown
129
- ### Task {N}: Build {element-name} element
130
- - **Files**: src/components/elements/{element-name}.{ext}
131
- - **Contract refs**: design/elements/{element-name}.contract.md
132
- - **Dependencies**: NONE
133
- - **Acceptance criteria**:
134
- - Component renders matching ALL visual specs in the element contract (sizes, colors, spacing, typography)
135
- - Props/API matches the contract's interface section exactly
136
- - Every CSS value traces to a design token or explicit contract value — no guessed/approximated values
137
- - Component is importable and reusable (no page-specific logic baked in)
138
- - Render the component in isolation (Storybook, test page, or dev route) and visually confirm it matches the contract spec
139
- ```
140
-
141
- Elements have no inter-dependencies — all can run in parallel within Wave 1.
142
-
143
- **CHECKPOINT after Wave 1**: Verify each built element renders correctly against its contract. Spot-check a sample (or all, if <15 elements) in a browser. Any element that doesn't match its contract gets fixed before Wave 2 starts.
144
-
145
- **Wave 2 — Widgets (one task per widget contract):**
146
-
147
- Read each contract file in `.gsd-t/contracts/design/widgets/`. For each widget:
148
-
149
- ```markdown
150
- ### Task {N}: Assemble {widget-name} widget
151
- - **Files**: src/components/widgets/{widget-name}.{ext}
152
- - **Contract refs**: design/widgets/{widget-name}.contract.md
153
- - **Dependencies**: BLOCKED by Wave 1 (all element tasks)
154
- - **Acceptance criteria**:
155
- - Widget IMPORTS already-built element components from Wave 1 — do NOT rebuild element functionality inline. If element X exists in src/components/elements/, you MUST import it.
156
- - Layout, spacing, and responsive behavior match the widget contract exactly
157
- - Internal element composition matches the contract's element list (correct elements, correct arrangement)
158
- - All element props are wired correctly per the widget contract
159
- - Render the widget in isolation and visually confirm the assembly matches the contract
8
+ preflight → brief (kind=plan) → plan agent (opus, with phase protocol)
160
9
  ```
161
10
 
162
- Widgets that share no elements can run in parallel. Widgets that compose the same elements should be sequenced to avoid merge conflicts.
163
-
164
- **CHECKPOINT after Wave 2**: Verify each built widget assembles its elements correctly. Open each widget in a browser — the composition should match the widget contract's layout spec. Any widget that doesn't match gets fixed before Wave 3 starts.
165
-
166
- **Wave 3 — Pages (one task per page contract):**
167
-
168
- Read each contract file in `.gsd-t/contracts/design/pages/`. For each page:
169
-
170
- ```markdown
171
- ### Task {N}: Compose {page-name} page
172
- - **Files**: src/pages/{page-name}.{ext}
173
- - **Contract refs**: design/pages/{page-name}.contract.md
174
- - **Dependencies**: BLOCKED by Wave 2 (all widget tasks)
175
- - **Acceptance criteria**:
176
- - Page IMPORTS already-built widget components from Wave 2 — do NOT rebuild widget functionality inline
177
- - Section ordering, page layout, and responsive breakpoints match the page contract exactly
178
- - All widget instances are wired with correct data/props per the page contract
179
- - Full page renders correctly at all breakpoints specified in the design contracts
180
- ```
11
+ For each domain, the agent writes atomic `tasks.md` entries in parallel-execution shape (`### Mxx-Dx-Tx — title`, a `**Touches**:` field per task, `## Files Owned` in scope.md), with contract refs, dependencies, and acceptance criteria. It updates `.gsd-t/contracts/integration-points.md` with wave groupings and validates file-disjointness via `gsd-t parallel --dry-run`.
181
12
 
182
- **CHECKPOINT after Wave 3**: Full Design Verification Agent comparison against Figma (Step 5.25 in execute). This is where the pixel-perfect validation happens — but by this point, each element and widget has already been verified individually, so page-level deviations should be limited to composition/layout issues.
183
-
184
- **Critical rules for design hierarchy tasks:**
185
- - **ONE CONTRACT = ONE TASK**: Never merge multiple element or widget contracts into one task. Each gets its own focused subagent with only its own contract in context.
186
- - **NO INLINE REBUILDS**: This is the single most important rule. A widget task that rebuilds an element's functionality inline (instead of importing the element component) is a **TASK FAILURE** — not a style preference, a failure. Same for page tasks rebuilding widgets inline. The entire hierarchy exists to prevent this.
187
- - **VERIFY BEFORE COMPOSING**: No Wave 2 task starts until Wave 1 is verified. No Wave 3 task starts until Wave 2 is verified. The checkpoint gates are mandatory, not advisory.
188
- - **ELEMENT CONTRACT IS AUTHORITATIVE**: If the element contract says `bar-vertical-grouped` (vertical bars), the widget that composes it gets vertical bars — period. The Figma screenshot is reference material; the contract is the spec. When they disagree, the contract wins (and flag the discrepancy for review).
189
-
190
- **Combining with non-design tasks**: If the milestone has both design tasks and non-design tasks (API, data layer, auth), the non-design tasks can run in parallel with Wave 1 elements. Map dependencies normally — a widget that needs API data is BLOCKED by both its elements AND the API task.
191
-
192
- ---
193
-
194
- ### Task Design Rules:
195
- 0. **UI tasks — reference the design brief**: If `.gsd-t/contracts/design-brief.md` exists, UI task descriptions must reference it. Include a note like: "Follow the color palette, typography, spacing, and component patterns defined in `.gsd-t/contracts/design-brief.md`." This ensures visual consistency without repeating spec details in every task.
196
- 1. **Atomic**: Each task produces a working, testable increment
197
- 2. **Self-contained context**: A fresh agent with only CLAUDE.md, the domain's scope/constraints, the relevant contracts, and the task description should be able to execute it
198
- 3. **File-scoped**: Each task lists exactly which files it touches — no surprises
199
- 4. **Contract-bound**: Every task that crosses a domain boundary must reference the specific contract it implements
200
- 5. **Ordered**: Tasks within a domain are numbered in execution order
201
- 6. **No implicit knowledge**: Don't assume the executing agent remembers previous tasks — reference contracts and files explicitly
202
- 7. **Context-window fit**: Each task MUST be executable within a single context window. Apply the scope validation heuristics below.
203
-
204
- ### Task Scope Validation
205
-
206
- After writing each task, apply this heuristic check before finalizing:
207
-
208
- **Splitting candidates — flag if ANY of these are true:**
209
- - Task lists **more than 5 files** to modify or create
210
- - Task has **more than 3 complex dependencies** (other tasks, contracts, or external systems it must read and understand)
211
- - Task description spans multiple distinct concerns (e.g., "implement X and also refactor Y and update Z docs")
212
-
213
- **Warning threshold:** If a task is flagged, emit:
214
- > ⚠️ **Task scope warning — {domain} Task {N}**: Estimated context load is high ({N} files, {N} dependencies). This task may approach the 70% context window threshold. Consider splitting into:
215
- > - Task {N}a: {first concern}
216
- > - Task {N}b: {second concern}
217
-
218
- **Auto-split rule (Level 3 Full Auto):** If a task has >5 files AND >3 dependencies, split it automatically. Renumber subsequent tasks. Document the split rationale in the task's Dependencies field.
219
-
220
- **Guidance for estimating context size:**
221
- - Each file to read ≈ 1–5% of context window (varies by file size)
222
- - CLAUDE.md + scope.md + constraints.md + contracts ≈ 15–25% baseline overhead
223
- - Tasks with >5 files or >3 cross-domain contracts commonly exceed 70% total context
224
-
225
- This rule implements the "task must fit in one context window" constraint — a task that compacts its subagent is a task that produces incomplete or corrupt output.
226
-
227
- ### Cross-Domain Duplicate Operation Scan
228
-
229
- After creating all domain task lists, scan for operations that appear in more than one domain.
230
-
231
- **Check for duplicate task descriptions, function names, or operation verbs** across all `tasks.md` files:
232
-
233
- ```
234
- For each operation in each domain's task list:
235
- Does this operation appear (by name or clear equivalent) in another domain's task list?
236
- → YES → flag as duplicate candidate
237
- ```
238
-
239
- **If duplicates found:**
240
-
241
- > ⚠️ **Duplicate operations detected** — the following operations appear in multiple domains:
242
- > - `{operation}` — found in: {domain-A} Task {N}, {domain-B} Task {N}
243
- > - `{operation}` — found in: {domain-A} Task {N}, {domain-C} Task {N}
244
- >
245
- > **Options:**
246
- > 1. If a `shared-core` domain exists → reassign these tasks to shared-core
247
- > 2. If no shared-core → extract to a new `shared-core` domain (go back to partition and add it)
248
- > 3. If the operations are truly surface-specific variants → document the distinction explicitly in each domain's constraints.md to prevent future confusion
249
-
250
- **Level 3 (Full Auto)**: If shared-core exists, move the duplicates there automatically. If not, add a task to the first affected domain's list: "Extract `{operation}` to shared-core — coordinate with {domain-B} before implementing".
251
-
252
- **If no duplicates found:**
253
-
254
- > ✅ No duplicate operations detected across domains.
255
-
256
- ### SharedCore Contract Compliance Check
257
-
258
- If `.gsd-t/contracts/shared-services-contract.md` exists, run a second pass:
259
-
260
- For each client-surface domain's task list, compare task operations against the SharedCore contract's "Shared Operations" table. Flag any task that implements an operation already owned by SharedCore:
261
-
262
- > ⚠️ **SharedCore contract violation** — the following tasks reimplement operations owned by SharedCore:
263
- > - {domain} Task {N}: implements `{operation}` — already owned by SharedCore per shared-services-contract.md
264
- >
265
- > Fix: Change these tasks to CALL the SharedCore function rather than implementing it independently.
266
-
267
- If no violations: `✅ All client domains reference SharedCore correctly.`
268
-
269
- ---
270
-
271
- ### REQ Traceability
272
-
273
- After creating task lists, append a traceability table to `docs/requirements.md`:
274
-
275
- ```markdown
276
- ## Requirements Traceability (updated by plan phase)
277
- | REQ-ID | Requirement Summary | Domain | Task(s) | Status |
278
- |--------|---------------------|--------|---------|--------|
279
- | REQ-001 | {summary} | {domain} | Task 1, Task 3 | pending |
280
- | REQ-002 | {summary} | {domain} | Task 2 | pending |
281
- ```
282
-
283
- - Every REQ-ID must map to at least one domain/task — orphaned requirements are a planning gap
284
- - Every task group should trace back to at least one REQ-ID — tasks with no REQ reference may be scope creep
285
- - Report: orphaned requirements (no task) and unanchored tasks (no REQ)
286
-
287
- ## Step 3: Map Cross-Domain Dependencies
288
-
289
- ```bash
290
- 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-plan --step 3 --step-label "Map Cross-Domain Dependencies" 2>/dev/null || true
291
- ```
292
-
293
- Update `.gsd-t/contracts/integration-points.md` with the full dependency graph **and wave groupings**:
294
-
295
- ```markdown
296
- # Integration Points
297
-
298
- ## Dependency Graph
299
-
300
- ### Independent (can start immediately)
301
- - data-layer: Tasks 1-3
302
- - auth: Tasks 1-2
303
- - ui: Tasks 1-2
304
-
305
- ### First Checkpoint
306
- - GATE: data-layer Task 3 (schema migrations) must complete
307
- - UNLOCKS: auth Task 3 (user lookup), ui Task 3 (data fetching)
308
- - VERIFY: Lead confirms schema matches schema-contract.md
309
-
310
- ### Second Checkpoint
311
- - GATE: auth Task 4 (auth middleware) must complete
312
- - UNLOCKS: ui Task 5 (protected routes)
313
- - VERIFY: Lead confirms auth endpoints match api-contract.md
314
-
315
- ## Wave Execution Groups
316
-
317
- Waves allow parallel execution within a wave and sequential execution between waves.
318
- Each wave contains domains/tasks that can safely run in parallel (no shared files, no cross-domain dependencies within the wave).
319
-
320
- ### Wave 1 — Independent (parallel)
321
- - data-layer: Tasks 1-3
322
- - auth: Tasks 1-2
323
- - **Shared files**: NONE — safe to run in parallel
324
- - **Completes when**: All listed tasks done
325
-
326
- ### Wave 2 — After Wave 1 Checkpoint (parallel)
327
- - CHECKPOINT: Lead verifies schema-contract.md before Wave 2 starts
328
- - auth: Tasks 3-4
329
- - ui: Tasks 1-2
330
- - **Shared files**: NONE — safe to run in parallel
331
- - **Completes when**: All listed tasks done
332
-
333
- ### Wave 3 — After Wave 2 Checkpoint (sequential)
334
- - CHECKPOINT: Lead verifies api-contract.md before Wave 3 starts
335
- - ui: Tasks 3-5
336
- - **Note**: Sequential — each task depends on the previous
337
-
338
- ### Integration
339
- - INTEGRATION: Wire all domains together
340
-
341
- ## Execution Order (for solo mode)
342
- 1. data-layer Tasks 1-3
343
- 2. auth Tasks 1-2 (parallel-safe with data-layer)
344
- 3. CHECKPOINT: verify schema contract
345
- 4. auth Tasks 3-4
346
- 5. ui Tasks 1-2 (parallel-safe with auth 3-4)
347
- 6. CHECKPOINT: verify api contract
348
- 7. ui Tasks 3-5
349
- 8. INTEGRATION: wire everything together
350
- ```
351
-
352
- ### Wave Grouping Rules:
353
- 1. **Same wave** = no shared files, no dependency between them
354
- 2. **Different wave** = one depends on the other's output, OR they modify the same file
355
- 3. **CHECKPOINT between waves** = lead verifies contract compliance before unlocking next wave
356
- 4. Always check domain `scope.md` files for file ownership — overlapping files → different waves
357
-
358
- ## Step 4: Estimate Scope
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-plan --step 4 --step-label "Estimate Scope" 2>/dev/null || true
362
- ```
363
-
364
- Add to each domain's `tasks.md`:
365
- ```markdown
366
- ## Execution Estimate
367
- - Total tasks: {N}
368
- - Independent tasks (no blockers): {N}
369
- - Blocked tasks (waiting on other domains): {N}
370
- - Estimated checkpoints: {N}
371
- ```
372
-
373
- ## Step 5: Document Ripple
374
-
375
- ```bash
376
- 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-plan --step 5 --step-label "Document Ripple" 2>/dev/null || true
377
- ```
378
-
379
- After creating task lists and mapping dependencies, update affected documentation:
380
-
381
- ### Always update:
382
- 1. **`.gsd-t/progress.md`** — Updated in Step 5, but verify Decision Log includes planning decisions and rationale
383
-
384
- ### Check if affected:
385
- 2. **`docs/requirements.md`** — If planning revealed missing, ambiguous, or conflicting requirements, update them
386
- 3. **`docs/architecture.md`** — If the task breakdown reveals new components or clarifies data flow, update it
387
- 4. **`.gsd-t/contracts/`** — If planning revealed contract gaps or needed additional detail, update them
388
- 5. **Domain `constraints.md`** — If planning revealed new constraints (task ordering, shared resources), add them
389
-
390
- ### Skip what's not affected.
391
-
392
- ## Step 6: Test Verification
393
-
394
- ```bash
395
- 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-plan --step 6 --step-label "Test Verification" 2>/dev/null || true
396
- ```
397
-
398
- Before finalizing the plan:
399
-
400
- 1. **Run existing tests**: Execute the full test suite to confirm codebase state before execution begins
401
- 2. **Verify passing**: Document any pre-existing failures — assign them to appropriate domain tasks
402
- 3. **Include test tasks**: Ensure each domain's task list includes test creation/update tasks where acceptance criteria require verification
403
-
404
- ## Step 7: Plan Validation
405
-
406
- ```bash
407
- 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-plan --step 7 --step-label "Plan Validation" 2>/dev/null || true
408
- ```
409
-
410
- Spawn a Task subagent to validate the plan before proceeding:
411
-
412
- ```
413
- Task subagent (general-purpose, model: haiku):
414
- "Validate this GSD-T plan. Read:
415
- - .gsd-t/domains/*/tasks.md (all task lists)
416
- - .gsd-t/contracts/ (all contracts)
417
- - docs/requirements.md (including traceability table)
418
- - .gsd-t/CONTEXT.md (if exists)
419
-
420
- Check:
421
- 1. REQ coverage: every REQ-ID in requirements.md maps to at least one task
422
- 2. Locked Decisions (from CONTEXT.md if present): every Locked Decision maps to at least one task
423
- 3. Task completeness: every task has files, contract refs, and acceptance criteria
424
- 4. Cross-domain dependencies: all BLOCKED-BY references point to real tasks
425
- 5. Contract existence: every task referencing a contract has that contract file present
426
-
427
- Report: PASS (all checks pass) or FAIL with specific gaps listed."
428
- ```
429
-
430
- **OBSERVABILITY LOGGING (MANDATORY) — wrap the validation spawn with `captureSpawn`:**
431
-
432
- ```
433
- node -e "
434
- const { captureSpawn } = require('./bin/gsd-t-token-capture.cjs');
435
- (async () => {
436
- await captureSpawn({
437
- command: 'gsd-t-plan',
438
- step: 'Step 7',
439
- model: 'haiku',
440
- description: 'plan validation, iteration {N}',
441
- projectDir: '.',
442
- notes: '{PASS/FAIL}, iteration {N}',
443
- spawnFn: async () => { /* Task validation subagent call */ },
444
- });
445
- })();
446
- "
447
- ```
448
-
449
- `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`).
450
- If validation FAIL, append each gap to `.gsd-t/qa-issues.md` (create with header `| Date | Command | Step | Model | Duration(s) | Severity | Finding |` if missing):
451
- `| {DT_START} | gsd-t-plan | Step 7 | haiku | {DURATION}s | medium | {gap description} |`
452
-
453
- **If FAIL**: Fix the identified gaps (up to 3 iterations). If still failing after 3 iterations, STOP and report to user with the specific gaps. Plan cannot proceed until validation PASSES.
454
-
455
- ## Step 8: Update Progress
456
-
457
- ```bash
458
- 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-plan --step 8 --step-label "Update Progress" 2>/dev/null || true
459
- ```
13
+ ## Step 1: Read the current milestone state
460
14
 
461
- Update `.gsd-t/progress.md`:
462
- - Set status to `PLANNED`
463
- - Update domain table with task counts
464
- - Record any planning decisions in the Decision Log
15
+ Read `.gsd-t/progress.md` and each domain's `scope.md`/`constraints.md`. The partition output is the input to planning.
465
16
 
466
- ## Step 9: Report
17
+ ## Step 2: Invoke the phase Workflow
467
18
 
468
- ```bash
469
- 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-plan --step 9 --step-label "Report" 2>/dev/null || true
19
+ ```js
20
+ {
21
+ scriptPath: "templates/workflows/gsd-t-phase.workflow.js",
22
+ args: {
23
+ phase: "plan",
24
+ milestone: "M{NN}",
25
+ projectDir: ".",
26
+ userInput: "$ARGUMENTS"
27
+ }
28
+ }
470
29
  ```
471
30
 
472
- ### Autonomy Behavior
31
+ ## Step 3: Interpret the result
473
32
 
474
- **Level 3 (Full Auto)**: Log a brief status line (e.g., "✅ Plan complete — {N} tasks across {N} domains, {execution mode}") and auto-advance to the next phase. Do NOT wait for user input.
33
+ The Workflow returns `{ status, artifacts, summary, decisions }`.
475
34
 
476
- **Level 1–2**: Present to the user:
477
- 1. Task count per domain
478
- 2. Dependency graph (which domains block which)
479
- 3. Recommended execution mode:
480
- - **Solo sequential**: < 8 total tasks or heavily interdependent
481
- - **Solo interleaved**: 8-15 tasks with some independence
482
- - **Team parallel**: 15+ tasks with 3+ independent starting points
483
- 4. Any ambiguities found during planning that need user input
35
+ - `status === "complete"`: every domain has atomic tasks; `gsd-t parallel --dry-run` validates disjointness. Auto-advance to `/gsd-t-execute`.
36
+ - `status === "partial" | "blocked"`: read `summary` (e.g. file-overlap between domains needing re-scoping).
37
+ - `status === "failed"`: read `summary`.
484
38
 
485
- Wait for confirmation before proceeding.
39
+ ## Document Ripple
486
40
 
487
- $ARGUMENTS
41
+ The plan agent writes per-domain `tasks.md`, updates `integration-points.md`, and adds a Decision Log entry.
488
42
 
489
- ## Auto-Clear
43
+ ## Next Up
490
44
 
491
- All work is committed to project files. Execute `/clear` to free the context window for the next command.
45
+ `/gsd-t-execute` run domain tasks (solo or parallel). (`/gsd-t-impact` first if the change is risky.)