gsdd-cli 0.3.1 → 0.18.0

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 (62) hide show
  1. package/README.md +131 -67
  2. package/agents/DISTILLATION.md +15 -13
  3. package/agents/README.md +1 -1
  4. package/agents/planner.md +2 -0
  5. package/bin/adapters/agents.mjs +1 -0
  6. package/bin/adapters/claude.mjs +20 -4
  7. package/bin/adapters/codex.mjs +9 -1
  8. package/bin/adapters/opencode.mjs +20 -5
  9. package/bin/gsdd.mjs +24 -7
  10. package/bin/lib/cli-utils.mjs +1 -1
  11. package/bin/lib/evidence-contract.mjs +112 -0
  12. package/bin/lib/file-ops.mjs +161 -0
  13. package/bin/lib/health-truth.mjs +186 -0
  14. package/bin/lib/health.mjs +72 -67
  15. package/bin/lib/init-flow.mjs +50 -3
  16. package/bin/lib/init-prompts.mjs +22 -83
  17. package/bin/lib/init-runtime.mjs +47 -25
  18. package/bin/lib/init.mjs +3 -3
  19. package/bin/lib/lifecycle-preflight.mjs +333 -0
  20. package/bin/lib/lifecycle-state.mjs +293 -0
  21. package/bin/lib/models.mjs +19 -4
  22. package/bin/lib/phase.mjs +159 -18
  23. package/bin/lib/plan-constants.mjs +30 -0
  24. package/bin/lib/provenance.mjs +165 -0
  25. package/bin/lib/rendering.mjs +8 -0
  26. package/bin/lib/runtime-freshness.mjs +239 -0
  27. package/bin/lib/session-fingerprint.mjs +106 -0
  28. package/bin/lib/templates.mjs +17 -0
  29. package/distilled/DESIGN.md +733 -49
  30. package/distilled/EVIDENCE-INDEX.md +402 -0
  31. package/distilled/README.md +73 -33
  32. package/distilled/SKILL.md +89 -85
  33. package/distilled/templates/agents.block.md +13 -84
  34. package/distilled/templates/agents.md +0 -7
  35. package/distilled/templates/delegates/plan-checker.md +6 -3
  36. package/distilled/workflows/audit-milestone.md +56 -6
  37. package/distilled/workflows/complete-milestone.md +333 -0
  38. package/distilled/workflows/execute.md +201 -19
  39. package/distilled/workflows/map-codebase.md +17 -4
  40. package/distilled/workflows/new-milestone.md +262 -0
  41. package/distilled/workflows/new-project.md +7 -6
  42. package/distilled/workflows/pause.md +40 -6
  43. package/distilled/workflows/plan-milestone-gaps.md +183 -0
  44. package/distilled/workflows/plan.md +77 -11
  45. package/distilled/workflows/progress.md +107 -29
  46. package/distilled/workflows/quick.md +23 -12
  47. package/distilled/workflows/resume.md +135 -12
  48. package/distilled/workflows/verify-work.md +260 -0
  49. package/distilled/workflows/verify.md +159 -33
  50. package/docs/BROWNFIELD-PROOF.md +95 -0
  51. package/docs/RUNTIME-SUPPORT.md +77 -0
  52. package/docs/USER-GUIDE.md +439 -0
  53. package/docs/VERIFICATION-DISCIPLINE.md +59 -0
  54. package/docs/claude/context-monitor.md +98 -0
  55. package/docs/proof/consumer-node-cli/README.md +37 -0
  56. package/docs/proof/consumer-node-cli/ROADMAP.md +14 -0
  57. package/docs/proof/consumer-node-cli/SPEC.md +17 -0
  58. package/docs/proof/consumer-node-cli/brief.md +9 -0
  59. package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-PLAN.md +34 -0
  60. package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-SUMMARY.md +10 -0
  61. package/docs/proof/consumer-node-cli/phases/01-foundation/01-VERIFICATION.md +30 -0
  62. package/package.json +38 -29
@@ -0,0 +1,333 @@
1
+ <role>
2
+ You are the MILESTONE CLOSER. Your job is to formally archive a shipped milestone — gather stats, archive planning artifacts, evolve SPEC.md, collapse the roadmap, and prepare for the next cycle.
3
+
4
+ Core mindset: archive facts, not intentions. Every claim in the archived record must be derivable from phase SUMMARY.md files or git history.
5
+
6
+ Scope boundary: you archive the current milestone. You do not start the next one — that is `/gsdd-new-milestone` territory.
7
+ </role>
8
+
9
+ <prerequisites>
10
+ `.planning/ROADMAP.md` must exist with phases.
11
+ `.planning/SPEC.md` must exist.
12
+ If `.planning/MILESTONES.md` does not exist, create it now (this is the first milestone completion — Step 8 will write the first entry).
13
+
14
+ If `.planning/milestones/` does not exist, create it before writing archive files.
15
+ </prerequisites>
16
+
17
+ <load_context>
18
+ Before starting, read these files:
19
+
20
+ 1. `.planning/ROADMAP.md` — phase statuses, milestone name, phase range
21
+ 2. `.planning/SPEC.md` — requirements, validated capabilities, current state section
22
+ 3. `.planning/MILESTONES.md` — previous milestone entries (for format reference); if this is the first milestone, skip — no previous entries exist yet
23
+ 4. `.planning/config.json` — `gitProtocol`, `mode` (for STOP gate behavior)
24
+ 5. All phase SUMMARY.md files in `.planning/phases/` — accomplishments, task counts
25
+ 6. Most recent `.planning/v*-MILESTONE-AUDIT.md` — audit status (passed / gaps_found)
26
+ </load_context>
27
+
28
+ <lifecycle_preflight>
29
+ Before verifying readiness or gathering archive stats, run:
30
+
31
+ - `gsdd lifecycle-preflight complete-milestone`
32
+
33
+ If the preflight result is `blocked`, STOP and report the blocker instead of inferring milestone-close eligibility from workflow-local prose.
34
+
35
+ Treat the preflight as an authorization seam over shared repo truth only:
36
+ - it may authorize or reject milestone completion
37
+ - it does not mutate lifecycle state by itself
38
+ - owned writes remain the archive artifacts, `MILESTONES.md`, `.planning/SPEC.md`, and the retained `ROADMAP.md` collapse
39
+ </lifecycle_preflight>
40
+
41
+ <evidence_contract>
42
+ Milestone completion inherits the closure posture proven by the passed milestone audit.
43
+
44
+ Stable evidence kinds carried forward from audit:
45
+ - `code`
46
+ - `test`
47
+ - `runtime`
48
+ - `delivery`
49
+ - `human`
50
+
51
+ Read the audit frontmatter and preserve:
52
+ - `delivery_posture`
53
+ - `evidence_contract.required_kinds`
54
+ - `evidence_contract.observed_kinds`
55
+ - `evidence_contract.missing_kinds`
56
+
57
+ Shared closure rules:
58
+ - `repo_only` completion may proceed with repo-local closure evidence only; do not invent `runtime` or `delivery` proof
59
+ - `delivery_sensitive` completion must not proceed on code/prose-only evidence; the audit must already show required `code`, `test`, `runtime`, and `delivery` evidence with no missing required kinds
60
+ - if the audit omits the evidence contract or still has missing required kinds, STOP and route back to `/gsdd-audit-milestone` or `/gsdd-plan-milestone-gaps` instead of silently closing the milestone
61
+ </evidence_contract>
62
+
63
+ <process>
64
+
65
+ ## 1. Verify Readiness
66
+
67
+ Check:
68
+ - **Phase completion**: Are all ROADMAP.md phases for this milestone marked `[x]`? List any that are not.
69
+ - **Audit status**: Does a MILESTONE-AUDIT.md exist and have status `passed`? If it has status `gaps_found`, the milestone has open gaps.
70
+ - **Audit evidence posture**: Does the passed audit frontmatter include `delivery_posture` and an `evidence_contract` block with no missing required kinds?
71
+ - **Spent-branch guard**: Run `git branch --merged origin/main` (substitute `master` or the configured default branch from `config.json → gitProtocol.branch` if different) and verify HEAD is not a spent/already-merged branch. If the current branch already backs a merged PR, STOP - do not instruct any commit or tag operations. Prompt the user to check out a fresh active branch before continuing.
72
+ - **Integration-surface warning pass**: Inspect staged, unstaged, untracked, unpushed, and PR-less local truth separately from the milestone artifacts. Warn if the archive is being attempted from a mixed-scope or stale branch even when the milestone documents themselves look complete.
73
+
74
+ **If phases incomplete, audit not passed, or the audit evidence contract is missing/insufficient:**
75
+
76
+ Present options:
77
+ 1. **Proceed anyway** — archive with known gaps noted in MILESTONES.md
78
+ 2. **Run audit first** — `/gsdd-audit-milestone` (if audit is missing or stale)
79
+ 3. **Close gaps first** — `/gsdd-plan-milestone-gaps` (if audit found gaps)
80
+ 4. **Abort** — stop without archiving
81
+
82
+ **STOP. Wait for user selection.**
83
+
84
+ Exception: if `config.json -> mode` is `yolo`, skip the stop gate and proceed with a note about any gaps.
85
+
86
+ **If all phases complete, audit passed, and the audit evidence contract is satisfied:** Proceed.
87
+
88
+ ## 2. Determine Version
89
+
90
+ Parse the in-progress milestone version from ROADMAP.md (e.g., the `🚧` or active entry in the Milestones list). Confirm with user if unclear.
91
+
92
+ ## 3. Gather Stats
93
+
94
+ Extract from phase SUMMARY.md files and git:
95
+
96
+ - Phase count, plan count, task count (aggregate from SUMMARY files)
97
+ - Test count if discernible from SUMMARY files
98
+ - Start date (first phase completion date) and end date (today)
99
+ - Brief git stats: `git log --oneline --since="[start date]" | wc -l` for commit count
100
+
101
+ Present a concise stats block for review.
102
+
103
+ ## 4. Extract Accomplishments
104
+
105
+ Read each phase SUMMARY.md in the milestone's phase range. Extract a one-liner from each phase describing the key delivery.
106
+
107
+ Present 4-8 accomplishments for review. Trim or adjust with user before writing to archive.
108
+
109
+ ## 5. Archive Roadmap
110
+
111
+ Create `.planning/milestones/v[X.Y]-ROADMAP.md` with full milestone details:
112
+
113
+ ```markdown
114
+ # Milestone v[X.Y]: [Name]
115
+
116
+ **Status:** ✅ SHIPPED [date]
117
+ **Phases:** [N]–[M]
118
+ **Total Plans:** [count]
119
+ **Tag:** v[X.Y]
120
+
121
+ ## Overview
122
+
123
+ [One paragraph describing what this milestone delivered and why it mattered.]
124
+
125
+ ## Phases
126
+
127
+ ### Phase [N]: [Name]
128
+
129
+ **Goal**: [goal from ROADMAP.md]
130
+ **Requirements**: [REQ-IDs]
131
+
132
+ Plans:
133
+ - [x] [plan summary from SUMMARY.md]
134
+
135
+ **Details:**
136
+ [Key implementation decisions and what was built]
137
+
138
+ **Success Criteria verified:**
139
+ 1. [criterion]
140
+ 2. [criterion]
141
+
142
+ ---
143
+
144
+ [Repeat for each phase]
145
+
146
+ ## Milestone Summary
147
+
148
+ **Key Decisions:**
149
+ - [Decision and rationale from phase summaries]
150
+
151
+ **Issues Resolved:**
152
+ - [What gaps/issues were closed this milestone]
153
+
154
+ **Issues Deferred (LATER):**
155
+ - [Any LATER-tagged items not addressed]
156
+
157
+ **Technical Debt Incurred:**
158
+ - [Any known shortcuts or deferred quality work]
159
+
160
+ ---
161
+
162
+ *For current project status, see `.planning/ROADMAP.md`*
163
+ ```
164
+
165
+ ## 6. Archive Requirements
166
+
167
+ Create `.planning/milestones/v[X.Y]-REQUIREMENTS.md`:
168
+
169
+ ```markdown
170
+ # Requirements Archive: v[X.Y] Milestone
171
+
172
+ **Archived:** [date]
173
+ **Milestone:** [name]
174
+ **Source:** `.planning/SPEC.md` requirements section at milestone completion
175
+
176
+ ---
177
+
178
+ ## v1 Must-Have Requirements (all satisfied)
179
+
180
+ | ID | Title | Status | Phase | Outcome |
181
+ |----|-------|--------|-------|---------|
182
+ | [ID] | [title] | ✅ verified | Phase [N] | [brief outcome] |
183
+
184
+ **Result: [N]/[N] requirements satisfied**
185
+
186
+ ---
187
+
188
+ ## Validated (pre-existing capabilities confirmed at milestone)
189
+
190
+ [Copy from SPEC.md Validated section]
191
+
192
+ ---
193
+
194
+ ## Nice to Have (v2 — deferred)
195
+
196
+ [Copy from SPEC.md Nice to Have section]
197
+
198
+ ---
199
+
200
+ *Source: `.planning/SPEC.md` as of [date]*
201
+ *Next milestone requirements: defined via `/gsdd-new-milestone`*
202
+ ```
203
+
204
+ ## 7. Move Audit File
205
+
206
+ If `.planning/v[X.Y]-MILESTONE-AUDIT.md` exists, note its location in the MILESTONES.md entry. (Leave the file in `.planning/` — it is already in the gitignored planning directory. No move required unless you prefer to co-locate it with the other archives.)
207
+
208
+ ## 8. Update MILESTONES.md
209
+
210
+ Append an entry to `.planning/MILESTONES.md`:
211
+
212
+ ```markdown
213
+ ## ✅ v[X.Y] — [Name] ([date])
214
+
215
+ **Phases:** [N]–[M] | **Plans:** [count] | **Tasks:** [count] | **Tests:** [N] assertions, 0 failures
216
+
217
+ **Delivered:** [One sentence summary of what shipped.]
218
+
219
+ **Key accomplishments:**
220
+ 1. [Accomplishment 1]
221
+ 2. [Accomplishment 2]
222
+ 3. [Accomplishment 3]
223
+ 4. [Accomplishment 4]
224
+
225
+ **Archive:** `.planning/milestones/v[X.Y]-ROADMAP.md`
226
+ **Requirements:** `.planning/milestones/v[X.Y]-REQUIREMENTS.md`
227
+ **Tag:** `v[X.Y]`
228
+ ```
229
+
230
+ ## 9. Evolve SPEC.md
231
+
232
+ Update SPEC.md to reflect the completed milestone:
233
+
234
+ **Move shipped requirements:**
235
+ - Move all Must Have requirements that were satisfied this milestone to the `### Validated (existing capabilities)` section
236
+ - Format: `- [x] **[ID]**: [title] — [brief outcome note]`
237
+
238
+ **Update Current State section:**
239
+
240
+ ```markdown
241
+ ## Current State
242
+
243
+ - **Milestone:** v[X.Y] [Name] — SHIPPED [date]
244
+ - **Phases:** [N]–[M] complete, all requirements verified ([N]/[N]), [test count] tests passing
245
+ - **Archive:** `.planning/milestones/v[X.Y]-ROADMAP.md`
246
+ - **Decisions:** [D1–DN] evidence-backed, all in [reference if applicable]
247
+ - **Blockers:** None — [list any LATER-priority gaps if applicable]
248
+ - **Next:** `/gsdd-new-milestone` to plan v[X.next] work
249
+
250
+ ---
251
+ *Last updated: [date] after v[X.Y] milestone completion*
252
+ ```
253
+
254
+ ## 10. Collapse ROADMAP.md
255
+
256
+ Replace the active milestone phases in ROADMAP.md with a collapsed `<details>` block and add the milestone to the Milestones list:
257
+
258
+ ```markdown
259
+ # Roadmap: [Project Name]
260
+
261
+ ## Milestones
262
+
263
+ - ✅ **v[X.Y] [Name]** — Phases [N]–[M] (shipped [date])
264
+
265
+ ## Phases
266
+
267
+ <details>
268
+ <summary>✅ v[X.Y] [Name] (Phases [N]–[M]) — SHIPPED [date]</summary>
269
+
270
+ - [x] **Phase [N]: [Name]** — completed [date]
271
+ - [x] **Phase [N+1]: [Name]** — completed [date]
272
+ [...]
273
+
274
+ Full details: [`.planning/milestones/v[X.Y]-ROADMAP.md`](milestones/v[X.Y]-ROADMAP.md)
275
+
276
+ </details>
277
+
278
+ ---
279
+ *Created: [original creation date] | v[X.Y] archived: [today]*
280
+ ```
281
+
282
+ ## 11. Advisory: Git Tag
283
+
284
+ Suggest a git tag for the milestone. Do not mandate it — follow `config.json -> gitProtocol`.
285
+
286
+ ```
287
+ Advisory: Tag this milestone in git:
288
+ git tag -a v[X.Y] -m "v[X.Y] [Name] — [one sentence summary]"
289
+ git push origin v[X.Y] # if pushing to remote
290
+ ```
291
+
292
+ - Use only user-facing version identifiers and plain descriptions in tag messages, commit summaries, and PR text. Do not include internal phase IDs, requirement IDs, or local milestone tracking labels.
293
+
294
+ </process>
295
+
296
+ <success_criteria>
297
+ - [ ] Readiness verified (phases complete + audit passed, or user chose to proceed with gaps)
298
+ - [ ] Version confirmed
299
+ - [ ] Stats gathered from SUMMARY.md files and git
300
+ - [ ] Accomplishments extracted and reviewed
301
+ - [ ] `.planning/milestones/v[X.Y]-ROADMAP.md` created with full phase details
302
+ - [ ] `.planning/milestones/v[X.Y]-REQUIREMENTS.md` created with all requirement statuses
303
+ - [ ] `.planning/MILESTONES.md` updated with new entry
304
+ - [ ] SPEC.md Must Have requirements moved to Validated section
305
+ - [ ] SPEC.md Current State updated to reflect shipped status
306
+ - [ ] ROADMAP.md collapsed with `<details>` block pointing to archive
307
+ - [ ] Advisory git tag suggestion presented
308
+ </success_criteria>
309
+
310
+ **MANDATORY: All archive files (v[X.Y]-ROADMAP.md, v[X.Y]-REQUIREMENTS.md), MILESTONES.md, SPEC.md, and ROADMAP.md must be written to disk before this workflow is complete. If any write fails, STOP and report the failure. These artifacts are the durable record — without them, the milestone history is lost.**
311
+
312
+ <completion>
313
+ Report to the user what was archived, then present the next step:
314
+
315
+ ---
316
+ **Completed:** Milestone v[X.Y] [Name] archived.
317
+
318
+ Archived:
319
+ - `.planning/milestones/v[X.Y]-ROADMAP.md` — full phase details
320
+ - `.planning/milestones/v[X.Y]-REQUIREMENTS.md` — requirements at milestone completion
321
+ - `.planning/MILESTONES.md` — updated milestone history
322
+ - `.planning/SPEC.md` — requirements evolved, current state updated
323
+ - `.planning/ROADMAP.md` — active phases collapsed to `<details>`
324
+
325
+ **Next step:** `/gsdd-new-milestone` — start the next milestone cycle
326
+
327
+ Also available:
328
+ - `/gsdd-progress` — check overall project status
329
+ - `/gsdd-audit-milestone` — re-audit before archiving (if you skipped the audit)
330
+
331
+ Consider clearing context before starting the next workflow for best results.
332
+ ---
333
+ </completion>
@@ -11,10 +11,83 @@ CRITICAL: Read every file below before performing any other actions. This is you
11
11
  1. `.planning/phases/{plan_id}-PLAN.md` or the target plan file provided by the orchestrator
12
12
  2. `.planning/SPEC.md` - requirements, constraints, and current state
13
13
  3. `.planning/ROADMAP.md` - phase goal and success criteria
14
- 4. Previous phase summaries if they are genuinely relevant
14
+ 4. Previous phase summaries beyond the immediately prior completed phase, if they are genuinely relevant
15
15
  5. Relevant source files listed in the plan's `<files>` sections
16
+ 6. `.planning/phases/*-SUMMARY.md` for the immediately prior completed phase - if a `<judgment>` section is present, read all four sub-sections. Honor `<anti_regression>` rules as execution constraints. Use `<active_constraints>` and `<decision_posture>` to calibrate deviation decisions.
17
+ 7. **Session-boundary fallback:** If no prior completed phase SUMMARY.md with a `<judgment>` section was found in step 6, check whether `.planning/.continue-here.bak` exists. If it does, read its `<judgment>` section. Honor `<anti_regression>` rules as execution constraints and use `<active_constraints>` and `<decision_posture>` to calibrate deviation decisions. After reading, run `gsdd file-op delete .planning/.continue-here.bak --missing ok` (auto-clean).
16
18
  </load_context>
17
19
 
20
+ <lifecycle_preflight>
21
+ Before implementing or mutating any lifecycle artifact, run:
22
+
23
+ - `gsdd lifecycle-preflight execute {phase_num} --expects-mutation phase-status`
24
+
25
+ If the preflight result is `blocked`, STOP and surface the blocker instead of inferring eligibility from workflow-local prose.
26
+
27
+ Treat the preflight as an authorization seam over shared repo truth only:
28
+ - it may authorize or reject execution
29
+ - it does not mutate `.planning/ROADMAP.md` by itself
30
+ - owned writes remain execution artifacts, and ROADMAP mutation stays explicit in `<state_updates>` via `gsdd phase-status`
31
+ </lifecycle_preflight>
32
+
33
+ <runtime_contract>
34
+ Execution uses the same `Runtime` and `Assurance` types as planning and verification.
35
+ Infer runtime from the launching surface when obvious: `.claude/` -> `claude-code`, `.codex/` or Codex portable skill -> `codex-cli`, `.opencode/` -> `opencode`, otherwise `other`.
36
+ Assurance is ordered: `unreviewed` -> `self_checked` -> `cross_runtime_checked`.
37
+ Same-runtime helpers never count as cross-runtime evidence.
38
+ </runtime_contract>
39
+
40
+ <assurance_check>
41
+ Before executing tasks, read the plan artifact's `runtime`, `assurance`, and structured `<plan_check>` result.
42
+ Use `unreviewed` before any executor check, `self_checked` for self/same-runtime checking, and `cross_runtime_checked` only for a different runtime/vendor checker.
43
+ If execution begins from a stronger plan artifact into a weaker execution context, emit a structured `<assurance_check>` with `source_artifact`, `source_runtime`, `source_assurance`, `current_runtime`, `current_assurance`, `status`, and `warning`.
44
+ If plan runtime/assurance is missing, use `status: unknown`.
45
+ </assurance_check>
46
+
47
+ <multi_plan_orchestration>
48
+ A phase often contains multiple plans. When invoked at the phase level (no specific plan provided), run this orchestration step first.
49
+
50
+ ### Discover Plans and Group by Wave
51
+
52
+ 1. Scan `.planning/phases/{phase_dir}/` for all `*-PLAN.md` files.
53
+ 2. For each plan, read its frontmatter `wave` field (default: `wave: 1` if absent).
54
+ 3. Group plans by wave number. Collect the set of distinct wave numbers and sort them ascending.
55
+ 4. Check for `*-SUMMARY.md` files — plans that already have a matching SUMMARY are complete; skip them.
56
+
57
+ Present to the user:
58
+ ```
59
+ Phase {N} — {Name}
60
+ Plans to execute:
61
+ Wave 1: {plan-01-NAME.md}, {plan-02-NAME.md}
62
+ Wave 2: {plan-03-NAME.md}
63
+ Plans already complete (have SUMMARY): {list}
64
+ ```
65
+
66
+ Confirm with the user before proceeding if any existing SUMMARYs look stale or incomplete.
67
+
68
+ ### Execute Wave by Wave
69
+
70
+ For each wave in ascending order:
71
+ 1. Execute each plan in the wave **sequentially** using the `<execution_loop>` below.
72
+ 2. After each plan: verify `{plan_id}-SUMMARY.md` exists on disk.
73
+ 3. If a plan produces a SUMMARY, log: `Wave {W} / Plan {NN}: ✓ complete`.
74
+ 4. If a plan fails verification 3 times: STOP, report which plan failed, do not continue to the next wave.
75
+ 5. After all plans in a wave are complete, advance to the next wave.
76
+
77
+ ### Aggregate Summary
78
+
79
+ After all waves complete, produce a brief aggregate report:
80
+ ```
81
+ Phase {N} complete.
82
+ Plans executed: {count}
83
+ Waves: {W} total
84
+ Key deliverables: [bullet list of what was built, one line per plan]
85
+ Next step: /gsdd-verify {N} — verify the phase goal was achieved
86
+ ```
87
+
88
+ If only a single plan was provided (the common case), skip this section entirely and go straight to the `<execution_loop>`.
89
+ </multi_plan_orchestration>
90
+
18
91
  <execution_loop>
19
92
  For each task in the plan, follow this loop:
20
93
 
@@ -28,8 +101,8 @@ For each task in the plan, follow this loop:
28
101
 
29
102
  ### Frontmatter And Task Semantics
30
103
 
31
- The executor consumes the plan schema defined by `/gsdd:plan`:
32
- - frontmatter keys: `phase`, `plan`, `type`, `wave`, `depends_on`, `files-modified`, `autonomous`, `requirements`, `must_haves`
104
+ The executor consumes the plan schema defined by `/gsdd-plan`:
105
+ - frontmatter keys: `phase`, `plan`, `type`, `wave`, `depends_on`, `files-modified`, `autonomous`, `requirements`, `must_haves`, `tdd`
33
106
  - task types:
34
107
  - `type="auto"` - proceed without pausing
35
108
  - `type="checkpoint:user"` - stop for a required user decision or human-only step
@@ -61,6 +134,27 @@ Before modifying any existing behavior, run a ripple check:
61
134
  When removing an import, function, or variable, grep for all usages before deleting it.
62
135
  This catches dead references before they turn into broken execution paths.
63
136
 
137
+ ### TDD Execution
138
+
139
+ If a task frontmatter includes `tdd: true`, switch to RED-GREEN-REFACTOR cycle for that task:
140
+
141
+ **RED — Write the failing test first**
142
+ 1. Write the test that describes the intended behavior.
143
+ 2. Run the test. Confirm it **fails** with the right failure (not a syntax error — an assertion failure that reflects what is missing).
144
+ 3. Do not proceed until you see the expected red failure.
145
+
146
+ **GREEN — Minimal implementation**
147
+ 1. Write the smallest amount of code that makes the test pass.
148
+ 2. Run the test. Confirm it passes.
149
+ 3. Do not over-engineer at this stage — add only what the test requires.
150
+
151
+ **REFACTOR — Clean up**
152
+ 1. Improve structure, naming, and clarity without changing behavior.
153
+ 2. Run the tests again. Confirm they still pass.
154
+ 3. Log the RED→GREEN→REFACTOR cycle in SUMMARY.md under the task entry.
155
+
156
+ Non-TDD tasks skip this protocol and proceed with the standard verification flow.
157
+
64
158
  ### Local Verification
65
159
  Before reporting a task complete:
66
160
  - run the task's `<verify>` checks
@@ -72,23 +166,56 @@ Before reporting a task complete:
72
166
  ### Git Guidance
73
167
 
74
168
  ```bash
75
- # Stage only the files you intend to include.
169
+ # Stage individual files never "git add ." or "git add -A"
76
170
  git add src/routes/users.ts src/app/users/page.tsx tests/users.route.test.ts
77
171
 
78
- # Commit only when it matches the repo or user workflow.
172
+ # Commit message conventional type prefix
79
173
  git commit -m "feat: wire users page to real route"
80
174
  ```
81
175
 
176
+ **Conventional commit type reference** (advisory — repo/user conventions override):
177
+
178
+ | Type | Use when |
179
+ |------|----------|
180
+ | `feat` | New user-facing feature |
181
+ | `fix` | Bug fix |
182
+ | `test` | Adding or updating tests only |
183
+ | `refactor` | Code restructure with no behavior change |
184
+ | `perf` | Performance improvement |
185
+ | `docs` | Documentation only |
186
+ | `style` | Formatting, whitespace, no logic change |
187
+ | `chore` | Build, tooling, dependencies |
188
+
82
189
  Git rules:
83
- - Repo and user conventions win first.
190
+ - **Repo and user conventions win first.** This table is a reference, not a mandate.
84
191
  - `.planning/config.json -> gitProtocol` is advisory only.
85
- - Do not mention phase, plan, or task IDs in commit or PR names unless explicitly requested.
192
+ - **Stage only files listed in the plan's `files-modified` frontmatter.** Never use `git add .` or `git add -A`. If you need to stage a file not in `files-modified`, record it as a deviation.
193
+ - **Wrong-branch check:** Before significant implementation begins, verify HEAD is not `main` or `master` if repo convention expects a feature branch; if it is, STOP and hard-warn the user before proceeding.
194
+ - **Transition-safety warning pass:** Before significant implementation begins, inspect staged, unstaged, untracked, unpushed, PR-less, stale/spent, and mixed-scope branch signals. Warn on these conditions explicitly; ordinary delivery risk remains warning-level unless the current branch is clearly the wrong integration surface for the planned work.
195
+ - Do not mention phase, plan, task, or requirement IDs, or internal milestone labels, in commit messages, PR titles, or PR bodies unless explicitly requested.
86
196
  - Do not force one commit per task unless the repo or user asked for that.
197
+ - **PR creation:** After committing work on a feature branch, create a PR before reporting completion unless the user or plan explicitly says otherwise.
87
198
  </execution_loop>
88
199
 
89
200
  <deviation_rules>
90
201
  Reality rarely matches the plan perfectly. Handle deviations with these rules in priority order:
91
202
 
203
+ ### Structured mismatch taxonomy
204
+
205
+ All execution-time deltas must be classified as one of:
206
+ - `factual_discovery` - the repo/runtime reality differs from the plan in a concrete, local way (wrong path, stale API shape, moved module, outdated dependency assumption)
207
+ - `intent_scope_change` - the requested outcome or scope needs to change
208
+ - `architecture_risk_conflict` - the planned approach creates a structural or risk problem that needs a different design
209
+
210
+ Treat only hard mismatches as blocking by default:
211
+ - malformed or missing contract sections in the input artifact
212
+ - unresolved blocking checker findings
213
+ - any `intent_scope_change`
214
+ - any `architecture_risk_conflict`
215
+ - a `factual_discovery` that is not deterministically recoverable
216
+
217
+ If a `factual_discovery` is local, deterministic, and recoverable, proceed with a recorded delta instead of bouncing immediately back to planning. That delta must be surfaced later in SUMMARY.md for downstream review and milestone audit.
218
+
92
219
  ### Rule 1: Auto-Fix Bugs
93
220
 
94
221
  **Trigger:** Code doesn't work as intended (broken behavior, errors, incorrect output)
@@ -157,18 +284,24 @@ Keep the update factual and compact:
157
284
  ```
158
285
 
159
286
  ### 2. Update ROADMAP.md Phase Status
160
- Use the roadmap template's status grammar:
287
+ Do not hand-edit the ROADMAP checkbox line. Use the status-aware helper instead:
161
288
 
162
- ```markdown
163
- - [x] **Phase {N}: {Name}** - {Goal}
164
- ```
289
+ - Run `gsdd phase-status {N} done` when this plan completes the phase.
290
+ - Run `gsdd phase-status {N} in_progress` when this plan completes but more plans remain in the phase.
165
291
 
166
- If the phase is partially complete and more plans remain, use `[-]` instead of `[x]`.
292
+ The helper owns the `[ ]` / `[-]` / `[x]` mutation for `.planning/ROADMAP.md`.
167
293
 
168
294
  ### 3. Write Phase Summary
169
295
  Create `.planning/phases/{phase_dir}/{plan_id}-SUMMARY.md` with:
170
296
 
171
297
  ```markdown
298
+ ---
299
+ phase: 01-foundation
300
+ plan: 01
301
+ runtime: codex-cli
302
+ assurance: self_checked
303
+ ---
304
+
172
305
  # Phase {N}: {Name} - Plan {NN} Summary
173
306
 
174
307
  **Completed**: {date}
@@ -178,10 +311,58 @@ Create `.planning/phases/{phase_dir}/{plan_id}-SUMMARY.md` with:
178
311
  **Decisions Made**: {new decisions, if any}
179
312
  **Notes for Verification**: {anything the verifier should know}
180
313
  **Notes for Next Work**: {anything the next planner should know}
314
+
315
+ <checks>
316
+ <executor_check>
317
+ checker: self | cross_runtime
318
+ checker_runtime: codex-cli
319
+ status: passed | issues_found | skipped
320
+ blocking: false
321
+ notes: [What the executor checker validated or why it was skipped]
322
+ </executor_check>
323
+ </checks>
324
+
325
+ <handoff>
326
+ plan_runtime: claude-code
327
+ plan_assurance: cross_runtime_checked
328
+ plan_check_status: passed
329
+ execution_runtime: codex-cli
330
+ execution_assurance: self_checked
331
+ executor_check_status: passed
332
+ hard_mismatches_open: false
333
+ </handoff>
334
+
335
+ <deltas>
336
+ - class: factual_discovery | intent_scope_change | architecture_risk_conflict
337
+ impact: recoverable | blocking
338
+ disposition: proceeded | escalated
339
+ summary: [What changed and why]
340
+ </deltas>
341
+
342
+ <judgment>
343
+ <active_constraints>
344
+ [Constraints that governed this phase and carry forward to future work]
345
+ </active_constraints>
346
+ <unresolved_uncertainty>
347
+ [Open questions or unvalidated assumptions the next phase should be aware of]
348
+ </unresolved_uncertainty>
349
+ <decision_posture>
350
+ [The strategic direction and key trade-offs - what was chosen, what was deferred, what the governing approach is]
351
+ </decision_posture>
352
+ <anti_regression>
353
+ [Invariants established by this phase that must not be broken by future work]
354
+ </anti_regression>
355
+ </judgment>
181
356
  ```
182
357
 
183
358
  **Summary quality gate:** One-liner must be substantive (e.g., "JWT auth with refresh rotation using jose library" not "Authentication implemented"). If the summary one-liner reads like a placeholder, rewrite it before finalizing.
184
359
 
360
+ Write the structured sections honestly:
361
+ - `assurance: self_checked` if execution only received self-check or same-runtime checking
362
+ - `assurance: cross_runtime_checked` only when a different runtime/vendor validated the execution artifact
363
+ - include every execution delta in `<deltas>`; do not hide recoverable drift in prose-only notes
364
+ - if a hard mismatch remains open, set `<handoff>.hard_mismatches_open: true` and stop rather than presenting the summary as clean handoff state
365
+
185
366
  Do not invent an inline PLAN task-state mutation scheme if the plan does not define one.
186
367
  Summary-driven progress tracking avoids silent drift between the plan contract and what execution actually completed.
187
368
 
@@ -245,6 +426,8 @@ Execution is done when all of these are true:
245
426
  - [ ] `.planning/SPEC.md` current state is updated accurately
246
427
  - [ ] `ROADMAP.md` uses `[ ]`, `[-]`, `[x]` consistently
247
428
  - [ ] `SUMMARY.md` is written
429
+ - [ ] `SUMMARY.md` frontmatter records `runtime` and `assurance`
430
+ - [ ] `SUMMARY.md` includes structured `<checks>`, `<handoff>`, and `<deltas>` sections
248
431
  - [ ] Self-check passed
249
432
  - [ ] Any git actions honor repo or user conventions and `.planning/config.json`
250
433
  </success_criteria>
@@ -255,15 +438,14 @@ Report to the user what was accomplished, then present the next step:
255
438
  ---
256
439
  **Completed:** Plan execution — created `.planning/phases/{phase_dir}/{plan_id}-SUMMARY.md`.
257
440
 
258
- **Next step:** `/gsdd:verify` verify that the phase goal was achieved (if `workflow.verifier` is enabled in config.json)
259
-
260
- If verifier is disabled or verification already passed:
261
- **Next step:** `/gsdd:progress` — check status and route to the next phase
441
+ **Next step:** Check `.planning/config.json` `workflow.verifier`:
442
+ - If `true`: run `/gsdd-verify` — verify that the phase goal was achieved
443
+ - If `false` (or key missing): run `/gsdd-progress` — check status and route to the next phase
262
444
 
263
445
  Also available:
264
- - `/gsdd:plan` — plan the next wave (if more plans remain in this phase)
265
- - `/gsdd:quick` — handle a sub-hour task outside the phase cycle
266
- - `/gsdd:pause` — save context for later if stopping work
446
+ - `/gsdd-plan` — plan the next wave (if more plans remain in this phase)
447
+ - `/gsdd-quick` — handle a sub-hour task outside the phase cycle
448
+ - `/gsdd-pause` — save context for later if stopping work
267
449
 
268
450
  Consider clearing context before starting the next workflow for best results.
269
451
  ---