gsdd-cli 0.18.4 → 0.19.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 (100) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +625 -607
  3. package/agents/DISTILLATION.md +421 -421
  4. package/agents/README.md +62 -62
  5. package/agents/approach-explorer.md +361 -361
  6. package/agents/debugger.md +82 -82
  7. package/agents/executor.md +394 -394
  8. package/agents/integration-checker.md +318 -318
  9. package/agents/mapper.md +103 -103
  10. package/agents/planner.md +313 -313
  11. package/agents/researcher.md +84 -84
  12. package/agents/roadmapper.md +296 -296
  13. package/agents/synthesizer.md +236 -236
  14. package/agents/verifier.md +337 -337
  15. package/bin/adapters/agents.mjs +34 -34
  16. package/bin/adapters/claude.mjs +191 -191
  17. package/bin/adapters/codex.mjs +85 -85
  18. package/bin/adapters/index.mjs +20 -20
  19. package/bin/adapters/opencode.mjs +278 -278
  20. package/bin/gsdd.mjs +123 -116
  21. package/bin/lib/cli-utils.mjs +28 -28
  22. package/bin/lib/evidence-contract.mjs +112 -112
  23. package/bin/lib/file-ops.mjs +209 -161
  24. package/bin/lib/health-truth.mjs +181 -178
  25. package/bin/lib/health.mjs +265 -235
  26. package/bin/lib/init-flow.mjs +252 -236
  27. package/bin/lib/init-prompts.mjs +248 -247
  28. package/bin/lib/init-runtime.mjs +225 -212
  29. package/bin/lib/init.mjs +17 -17
  30. package/bin/lib/lifecycle-preflight.mjs +360 -333
  31. package/bin/lib/lifecycle-state.mjs +351 -267
  32. package/bin/lib/manifest.mjs +116 -114
  33. package/bin/lib/models.mjs +411 -411
  34. package/bin/lib/phase.mjs +397 -378
  35. package/bin/lib/plan-constants.mjs +30 -30
  36. package/bin/lib/provenance.mjs +109 -106
  37. package/bin/lib/rendering.mjs +178 -130
  38. package/bin/lib/runtime-freshness.mjs +221 -219
  39. package/bin/lib/templates.mjs +225 -224
  40. package/bin/lib/workspace-root.mjs +132 -0
  41. package/distilled/DESIGN.md +2347 -2327
  42. package/distilled/EVIDENCE-INDEX.md +397 -394
  43. package/distilled/README.md +196 -193
  44. package/distilled/SKILL.md +86 -85
  45. package/distilled/templates/agents.block.md +21 -21
  46. package/distilled/templates/agents.md +6 -6
  47. package/distilled/templates/approach.md +232 -232
  48. package/distilled/templates/auth-matrix.md +78 -78
  49. package/distilled/templates/brownfield-change/CHANGE.md +99 -0
  50. package/distilled/templates/brownfield-change/HANDOFF.md +38 -0
  51. package/distilled/templates/brownfield-change/VERIFICATION.md +56 -0
  52. package/distilled/templates/codebase/architecture.md +110 -110
  53. package/distilled/templates/codebase/concerns.md +95 -95
  54. package/distilled/templates/codebase/conventions.md +193 -193
  55. package/distilled/templates/codebase/stack.md +96 -96
  56. package/distilled/templates/delegates/approach-explorer.md +25 -25
  57. package/distilled/templates/delegates/mapper-arch.md +26 -26
  58. package/distilled/templates/delegates/mapper-concerns.md +27 -27
  59. package/distilled/templates/delegates/mapper-quality.md +28 -28
  60. package/distilled/templates/delegates/mapper-tech.md +25 -25
  61. package/distilled/templates/delegates/plan-checker.md +68 -68
  62. package/distilled/templates/delegates/researcher-architecture.md +30 -30
  63. package/distilled/templates/delegates/researcher-features.md +30 -30
  64. package/distilled/templates/delegates/researcher-pitfalls.md +30 -30
  65. package/distilled/templates/delegates/researcher-stack.md +30 -30
  66. package/distilled/templates/delegates/researcher-synthesizer.md +31 -31
  67. package/distilled/templates/research/architecture.md +57 -57
  68. package/distilled/templates/research/features.md +23 -23
  69. package/distilled/templates/research/pitfalls.md +46 -46
  70. package/distilled/templates/research/stack.md +45 -45
  71. package/distilled/templates/research/summary.md +67 -67
  72. package/distilled/templates/roadmap.md +74 -62
  73. package/distilled/templates/spec.md +110 -110
  74. package/distilled/workflows/audit-milestone.md +275 -271
  75. package/distilled/workflows/complete-milestone.md +336 -332
  76. package/distilled/workflows/execute.md +454 -449
  77. package/distilled/workflows/map-codebase.md +253 -253
  78. package/distilled/workflows/new-milestone.md +242 -238
  79. package/distilled/workflows/new-project.md +398 -398
  80. package/distilled/workflows/pause.md +160 -156
  81. package/distilled/workflows/plan-milestone-gaps.md +183 -183
  82. package/distilled/workflows/plan.md +451 -447
  83. package/distilled/workflows/progress.md +227 -223
  84. package/distilled/workflows/quick.md +351 -347
  85. package/distilled/workflows/resume.md +220 -212
  86. package/distilled/workflows/verify-work.md +260 -260
  87. package/distilled/workflows/verify.md +431 -429
  88. package/docs/BROWNFIELD-PROOF.md +95 -95
  89. package/docs/RUNTIME-SUPPORT.md +93 -75
  90. package/docs/USER-GUIDE.md +440 -399
  91. package/docs/VERIFICATION-DISCIPLINE.md +59 -59
  92. package/docs/claude/context-monitor.md +98 -98
  93. package/docs/proof/consumer-node-cli/README.md +37 -37
  94. package/docs/proof/consumer-node-cli/ROADMAP.md +14 -14
  95. package/docs/proof/consumer-node-cli/SPEC.md +17 -17
  96. package/docs/proof/consumer-node-cli/brief.md +9 -9
  97. package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-PLAN.md +34 -34
  98. package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-SUMMARY.md +10 -10
  99. package/docs/proof/consumer-node-cli/phases/01-foundation/01-VERIFICATION.md +30 -30
  100. package/package.json +62 -61
@@ -1,421 +1,421 @@
1
- # GSDD Role Distillation Ledger
2
-
3
- Evidence map from each of the 10 canonical GSDD roles to their GSD sources, with keep/strip/why rationale. This ledger documents why each role exists in its current form and what GSD content was distilled or merged.
4
-
5
- ---
6
-
7
- ## 1. Mapper
8
-
9
- **Canonical role:** `agents/mapper.md`
10
-
11
- **GSD source:** `agents/_archive/gsd-codebase-mapper.md`
12
-
13
- **Merger type:** Kept-as-is (function scope preserved, output contract simplified)
14
-
15
- **Kept from GSD:**
16
- - Mandatory initial-read discipline for context files
17
- - 4 focus areas (tech, arch, quality, concerns)
18
- - Output contract with artifact names and downstream consumers
19
- - Core algorithm: parse → explore → fill template → write → confirm
20
-
21
- **Stripped from GSD:**
22
- - Multi-file codebase output reduced to 4-file standard (see D1)
23
- - Validator-pass patterns (GSDD trusts agent reads, not file validation)
24
-
25
- **Gained in GSDD:**
26
- - Explicit "Downstream Consumers" section (shows who uses mapper output)
27
- - Clear guidance on prescriptive vs. descriptive output (helps agents write better code)
28
-
29
- **Rationale:** Mapper is the lowest-level, most stable role. Its core job (explore + document) hasn't changed, but the output set shrank from 7 files to 4 files per D1 (lean context decision). The agent role contract itself needed no substantive changes.
30
-
31
- ---
32
-
33
- ## 2. Researcher
34
-
35
- **Canonical role:** `agents/researcher.md`
36
-
37
- **GSD sources:** `agents/_archive/gsd-project-researcher.md` + `agents/_archive/gsd-phase-researcher.md` (merged)
38
-
39
- **Merger type:** Merged (same algorithm, different scope parameter)
40
-
41
- **Kept from GSD:**
42
- - Mandatory initial-read discipline
43
- - Research scope (project vs. phase)
44
- - Research mode (ecosystem, feasibility, comparison)
45
- - Core algorithm: receive scope → identify domains → execute tool hierarchy → verify → write → return structured result
46
- - Quality guarantees (training data = hypothesis, honest reporting, investigation not confirmation, confidence levels on every finding)
47
- - Research pitfalls and prevention strategies
48
-
49
- **Stripped from GSD:**
50
- - Separate role contracts for project-researcher and phase-researcher (merged into one with scope parameter)
51
- - Tool-specific shell commands (kept portable tool contracts instead)
52
-
53
- **Gained in GSDD:**
54
- - Explicit "Scope" table showing scope × trigger × focus × output location
55
- - Clear statement: "Same algorithm, different scope. The scope is a context input, not a different role."
56
-
57
- **Rationale:** The GSD original had two roles (project and phase researcher) that followed the identical algorithm but with a scope parameter. GSDD merged them into one canonical role taking scope as input, reducing the role count from 11 to 9 (later 10 with approach-explorer in D29) while preserving all leverage. This is the clean merger mentioned in D2.
58
-
59
- ---
60
-
61
- ## 3. Synthesizer
62
-
63
- **Canonical role:** `agents/synthesizer.md`
64
-
65
- **GSD source:** `agents/_archive/gsd-research-synthesizer.md` (with recovery hardening from PR #15)
66
-
67
- **Merger type:** Kept-as-is (hardened in 2026-03-13)
68
-
69
- **Kept from GSD:**
70
- - Mandatory initial-read discipline
71
- - Input contract: all 4 research files (STACK, FEATURES, ARCHITECTURE, PITFALLS)
72
- - Output contract: SUMMARY.md with executive summary, key findings, roadmap implications, confidence/gaps
73
- - Downstream consumer (roadmapper) and what it needs
74
- - 6-step execution flow: read → synthesize → extract → derive → assess → write
75
-
76
- **Stripped from GSD:**
77
- - Conditional skip logic (kept mandatory synthesizer per D5 original decision)
78
- - Vendor-specific output formatting
79
-
80
- **Gained in GSDD (PR #15 hardening):**
81
- - Explicit required files list with blocked-return pattern (do not guess from partial context, return blocked status naming missing file)
82
- - "Be opinionated" guidance to roadmapper
83
- - Stronger structured-return contract
84
-
85
- **Rationale:** Synthesizer is a thin single-step role with no merge or extraction needed. It was hardened in PR #15 to restore explicit structure and completion discipline, but the core function and leverage remained unchanged from GSD.
86
-
87
- ---
88
-
89
- ## 4. Planner
90
-
91
- **Canonical role:** `agents/planner.md`
92
-
93
- **GSD sources:** `agents/_archive/gsd-planner.md` + `agents/_archive/gsd-plan-checker.md` (merged)
94
-
95
- **Merger type:** Merged (orchestration ownership transferred to native adapters)
96
-
97
- **Kept from GSD:**
98
- - Mandatory initial-read discipline
99
- - Phase goal decomposition and dependency graphs
100
- - Goal-backward verification (must-haves, artifacts, key links)
101
- - Planner responsibility and scope
102
- - Input contract (SPEC, ROADMAP, codebase context, prior phase artifacts)
103
- - Output contract (PLAN.md with frontmatter, objective, context references, typed tasks)
104
-
105
- **Stripped from GSD:**
106
- - Separate plan-checker role (now a delegate at `distilled/templates/delegates/plan-checker.md`)
107
- - GSD's native 3-cycle verification loop (embedded in planner) → moved to native adapter surfaces (Claude skill, OpenCode command, Codex agent)
108
- - Vendor-specific fresh-context orchestration logic
109
-
110
- **Gained in GSDD:**
111
- - Explicit scope boundary: "plan-scoped, does not own verification or milestone audit"
112
- - Goal-backward section with 4 clear questions
113
- - Planning process section with concrete steps
114
- - Reference to plan-checker delegate for fresh-context review
115
- - Reduced-assurance fallback mode description (when no independent checker runs)
116
-
117
- **Rationale:** GSD's plan-checker was a separate role running a 3-cycle revision loop. GSDD merged planner and plan-checker into a single portable contract, but preserved the adversarial review concept through native adapter surfaces. The portable workflow describes the reduced-assurance fallback. This is the high-impact merger from D2 with full tradeoff documentation.
118
-
119
- ---
120
-
121
- ## 5. Roadmapper
122
-
123
- **Canonical role:** `agents/roadmapper.md`
124
-
125
- **GSD source:** `agents/_archive/gsd-roadmapper.md` (with recovery hardening from PR #15)
126
-
127
- **Merger type:** Kept-as-is (hardened in 2026-03-13)
128
-
129
- **Kept from GSD:**
130
- - Mandatory initial-read discipline
131
- - Bounded section structure (phases, requirements, success criteria, coverage validation)
132
- - Explicit coverage validation
133
- - Parse-critical artifact contract
134
- - Structured return modes
135
- - Checklist-driven completion
136
-
137
- **Stripped from GSD:**
138
- - Template-path references (output lives in `.planning/ROADMAP.md`)
139
- - Commit steps (GSDD handles git separately)
140
- - Vendor-specific file conventions
141
-
142
- **Gained in GSDD (PR #15 hardening):**
143
- - Explicit `.planning/ROADMAP.md` ownership contract
144
- - Explicit `[ ]` / `[-]` / `[x]` status grammar
145
- - Concrete `ROADMAP CREATED` artifact example
146
- - Hard boundary: "this role does not settle the separate ROADMAP/STATE lifecycle seam"
147
-
148
- **Rationale:** Roadmapper was over-distilled in the initial extraction; PR #15 recovered visible structure and completion discipline. The core role and leverage were intact; hardening just restored the guardrails that improve compliance.
149
-
150
- ---
151
-
152
- ## 6. Executor
153
-
154
- **Canonical role:** `agents/executor.md`
155
-
156
- **GSD source:** `agents/_archive/gsd-executor.md` (with substantial hardening from PR #16)
157
-
158
- **Merger type:** Kept-as-is (hardened significantly in 2026-03-13)
159
-
160
- **Kept from GSD:**
161
- - Plan-scoped execution discipline
162
- - Task implementation and deviation handling
163
- - Git action recording without repo-specific naming assumptions
164
- - Checkpoint protocol
165
- - Completion summary
166
- - State update responsibility
167
-
168
- **Stripped from GSD:**
169
- - Bash recipe patterns and shell-specific guidance
170
- - Tool-specific directory naming conventions
171
-
172
- **Gained in GSDD (PR #16 hardening):**
173
- - Explicit scope boundary with 6 things executor does NOT own
174
- - Clearer deviation rules with priority order (auto-fix bugs first)
175
- - Success criteria confirmation requirement
176
- - Verify quality checks now live inside task_completeness (runnable, fast, ordered)
177
- - Stronger commitment to documented deviations
178
-
179
- **Rationale:** Executor is the most complex role, with the broadest deviation surface. PR #16 audit recovered substantive guardrails: explicit scope boundaries, rule priority, and verification discipline. The ~150-line executor contract expanded to ~400 lines because the detail prevents misalignment, not because the job changed.
180
-
181
- ---
182
-
183
- ## 7. Verifier
184
-
185
- **Canonical role:** `agents/verifier.md`
186
-
187
- **GSD source:** `agents/_archive/gsd-verifier.md` (with selective hardening from D2)
188
-
189
- **Merger type:** Kept-as-is (scope preserved; cross-phase audit extracted separately)
190
-
191
- **Kept from GSD:**
192
- - Phase-level goal-backward verification
193
- - Exists/Substantive/Wired gate
194
- - Anti-pattern scan
195
- - Output contract with compact base fields (phase, verified, status, score)
196
- - Verification-report structure
197
-
198
- **Stripped from GSD:**
199
- - Cross-phase integration audit scope (extracted as separate role + workflow)
200
- - GSD's narrative all-encompassing verification
201
-
202
- **Gained in GSDD:**
203
- - Richer structured verifier findings (re_verification, gaps, human_verification) when material
204
- - Explicit boundaries: "phase-scoped only, cross-phase integration is a separate concern"
205
- - D2 cross-reference: why integration-checker exists as a separate role
206
-
207
- **Rationale:** Verifier's phase-level job is unchanged. The extraction of integration-checker as a separate milestone surface (D2, PR #12) made verifier smaller and clearer. Phase verification and milestone integration audit are now distinct concerns with explicit handoff points.
208
-
209
- ---
210
-
211
- ## 8. Integration-Checker
212
-
213
- **Canonical role:** `agents/integration-checker.md`
214
-
215
- **GSD source:** `agents/_archive/gsd-integration-checker.md` (with structural recovery in PR #12 and systemic hardening in PR #15)
216
-
217
- **Merger type:** Extracted as standalone role (cross-phase scope differs structurally from phase verification)
218
-
219
- **Kept from GSD:**
220
- - Mandatory initial-read discipline
221
- - Cross-phase wiring verification (exports → imports, APIs → consumers, forms → handlers, data → display)
222
- - E2E flow tracing
223
- - Typed structured return
224
- - Checklist-driven completion
225
-
226
- **Stripped from GSD (intentional):**
227
- - Framework-specific Bash recipes
228
- - Hardcoded path assumptions
229
- - File-extension-specific grep flags
230
- - Tool-specific details that don't survive vendor-agnostic distillation
231
-
232
- **Gained in GSDD:**
233
- - PR #12: explicit section boundaries, stronger structured output, cleaner split between role contract and milestone workflow
234
- - PR #15: recovered compliance guardrails, restored mandatory read enforcement, explicit auth-protection verification
235
- - D2 reference: structural difference from phase verifier
236
- - New in D21 (PR #35): Step 4a matrix-driven auth verification (if AUTH_MATRIX.md exists)
237
-
238
- **Rationale:** GSD's integration-checker was a separate surface but lived in the shadows of the main role contracts. PR #12 extracted it fully; PR #15 recovered its substantive guardrails. The role is different from verifier because it owns milestone scope (all-phase wiring) vs. phase scope (phase goal). This is the cleanest separation in D2.
239
-
240
- ---
241
-
242
- ## 9. Debugger
243
-
244
- **Canonical role:** `agents/debugger.md`
245
-
246
- **GSD source:** `agents/_archive/gsd-debugger.md` (no changes)
247
-
248
- **Merger type:** Kept-as-is (unchanged)
249
-
250
- **Kept from GSD:**
251
- - Systematic debugging methodology
252
- - Hypothesis formulation and testing
253
- - State persistence across context resets
254
- - Structured checkpoint protocol
255
- - Deviation handling
256
-
257
- **Stripped from GSD:** (nothing significant)
258
- - Minor tool path references
259
-
260
- **Gained in GSDD:** (nothing)
261
- - The role is kept as-is for compatibility
262
-
263
- **Rationale:** Debugger is a standalone utility role with no dependencies on other roles. It was preserved exactly as-is from GSD because it works and has no vendor lock-in. It's used ad-hoc when agents encounter failures, not as part of the main workflow pipeline.
264
-
265
- ---
266
-
267
- ## 10. Approach-Explorer
268
-
269
- **Canonical role:** `agents/approach-explorer.md`
270
-
271
- **GSD sources:** `workflows/discuss-phase.md` + `workflows/list-phase-assumptions.md` + `workflows/discovery-phase.md` (merged into new role)
272
-
273
- **Merger type:** New role from 2 GSD sources (discuss-phase + list-phase-assumptions) with thematic input from discovery-phase
274
-
275
- **Kept from GSD:**
276
- - Gray area identification with 5 domain types (SEE/CALL/RUN/READ/ORGANIZED) from discuss-phase
277
- - Scope guardrail: phase boundary is fixed, deferred ideas captured not acted on
278
- - 5-dimension assumption surfacing (technical approach, implementation order, scope boundaries, risks, dependencies) with confidence levels from list-phase-assumptions
279
- - Deferred ideas capture from discuss-phase
280
- - Adaptive area-by-area deep questioning from discuss-phase (GSD used 4-question batches; GSDD uses adaptive convergence)
281
-
282
- Note: `discovery-phase.md` contributed the concept of pre-planning research but the mechanism is entirely different — GSD used 3-level depth workflows (Quick/Standard/Deep) as a separate invocation; GSDD uses per-gray-area research subagents embedded in the plan workflow. This is thematic inspiration, not a structural merger.
283
-
284
- **Stripped from GSD:**
285
- - `gsd-tools.cjs` dependencies and STATE.md updates
286
- - Vendor-specific commit steps, path conventions, and "Claude" references
287
- - CONTEXT.md output format (replaced with structured APPROACH.md)
288
- - Separate workflow invocation (absorbed into plan workflow as inline + research subagent hybrid)
289
- - Rigid 4-question batched loop (replaced with adaptive questioning until decision converges)
290
-
291
- **Gained in GSDD:**
292
- - XML semantic structure matching planner pattern (`<role>`, `<algorithm>`, `<examples>`, etc.)
293
- - 3 few-shot conversation examples (taste decision, technical decision, hybrid + delegation)
294
- - Gray area classification: taste (ask directly), technical (research first), hybrid (both)
295
- - Pre-question research per gray area via isolated research subagents returning compressed summaries
296
- - Self-check quality gate before writing APPROACH.md
297
- - Intermediate decision persistence (protect against context limits)
298
- - JIT context loading with extraction guidance (read ONLY locked decisions from SPEC, ONLY phase goal from ROADMAP)
299
- - Structured approach comparison with trade-offs
300
- - File persistence to `{padded_phase}-APPROACH.md` using dedicated template
301
- - Plan-checker integration via new `approach_alignment` verification dimension
302
- - Config toggle (`workflow.discuss: true|false`) for optional skip
303
- - Downstream consumer contract: planner reads locked decisions, plan-checker verifies alignment
304
- - "Agent's Discretion" explicit marking for areas where user delegates choice (vendor-neutral)
305
- - Hybrid architecture: conversation inline (main context) + research in subagents. Native agent kept as optimization.
306
-
307
- **Rationale:** GSDD's initial distillation dropped GSD's discuss-phase and list-phase-assumptions entirely, removing genuine leverage: the planner converges on a single approach without user input, explores no alternatives, and surfaces no assumptions. The approach explorer recovers this phase-level user alignment by combining GSD's discuss-phase interaction pattern with comparative research. Ground-up rewrite (D29) applied 5 external resources on context engineering, meta-prompting, and agent skill design to produce a prompt-engineered role contract with proper XML structure, examples, adaptive conversation, and hybrid research isolation.
308
-
309
- ---
310
-
311
- ## Summary: Merger Table (from D2)
312
-
313
- | Canonical role | Absorbs from GSD | Merger criteria |
314
- |---|---|---|
315
- | `mapper.md` | `gsd-codebase-mapper.md` | Kept-as-is; output set changed per D1 (7 → 4 files) |
316
- | `researcher.md` | `gsd-project-researcher.md` + `gsd-phase-researcher.md` | Scope parameter instead of separate role |
317
- | `synthesizer.md` | `gsd-research-synthesizer.md` | Kept-as-is; hardened in PR #15 |
318
- | `planner.md` | `gsd-planner.md` + `gsd-plan-checker.md` | Orchestration ownership moved to native adapters; portable checker-delegate created |
319
- | `roadmapper.md` | `gsd-roadmapper.md` | Kept-as-is; hardened in PR #15 |
320
- | `executor.md` | `gsd-executor.md` | Kept-as-is; heavily hardened in PR #16 |
321
- | `verifier.md` | `gsd-verifier.md` | Kept-as-is; cross-phase audit extracted to integration-checker |
322
- | `integration-checker.md` | `gsd-integration-checker.md` | Extracted as standalone; recovered in PR #12, hardened in PR #15 |
323
- | `debugger.md` | `gsd-debugger.md` | Kept-as-is; no changes |
324
- | `approach-explorer.md` | `discuss-phase.md` + `list-phase-assumptions.md` + `discovery-phase.md` | New role from 3 GSD workflow sources |
325
-
326
- **Result:** 11 GSD roles → 10 GSDD canonical roles (2 mergers: researcher, planner). 1 extraction: integration-checker moved from embedded to standalone. 1 addition: approach-explorer recovers discuss-phase leverage with research enhancement. Total leverage preserved and extended.
327
-
328
- ---
329
-
330
- ## Evidence and Context
331
-
332
- - GSD sources: `agents/_archive/gsd-*.md`
333
- - GSDD canonical roles: `agents/*.md` (all except `_archive/`)
334
- - Design decisions: `distilled/DESIGN.md` (D1, D2)
335
- - PR history:
336
- - PR #9: Delegate extraction
337
- - PR #12: Integration-checker extraction and lifecycle contract seam
338
- - PR #14-17: Systemic role-contract hardening and leverage recovery
339
- - PR #35: OWASP authorization matrix integration into integration-checker
340
-
341
- ---
342
-
343
- ## Maintenance
344
-
345
- This ledger is updated when:
346
-
347
- 1. A canonical role contract changes significantly (update the "Kept"/"Stripped"/"Gained" sections)
348
- 2. A GSD role is merged into or extracted from a canonical role (update the merger table)
349
- 3. New evidence surfaces that changes the distillation rationale (update with citation)
350
-
351
- Do not add speculative content. Every entry must reference actual source files and PRs that contain evidence.
352
-
353
- ---
354
-
355
- ## Role Contract Design Principles
356
-
357
- Cross-source best practices applied to GSDD role contracts, audited against 6 external resources. These principles govern how role contracts should be written and revised. Ranked by impact.
358
-
359
- > **Source note:** "Anthropic CE" in this section refers to Anthropic's "Building effective agents" (Dec 2024) for orchestration and sub-agent patterns, and LangChain's "Context Engineering for Agents" (2025) for Write/Select/Compress/Isolate context management patterns. They are cited separately where attribution is precise.
360
-
361
- ### Architecture-Level (highest leverage)
362
-
363
- | Principle | What It Means | Source | GSDD Implementation |
364
- |-----------|--------------|--------|---------------------|
365
- | **Context isolation** | Research and heavy reads go in subagents; only compressed summaries enter the main context | Anthropic "Building effective agents" (Dec 2024): orchestrator-worker pattern — sub-agents do deep technical work and return condensed summaries | Approach explorer research subagents return ~1000-token summaries; plan-checker runs in fresh context |
366
- | **JIT context loading** | Never say "read everything." Specify what to extract from each file | LangChain "Context Engineering for Agents" (2025): Select step of Write/Select/Compress/Isolate — load only the specific content needed, not full files | `<input_contract>` with extraction guidance: "From SPEC.md read ONLY locked decisions" |
367
- | **Intermediate persistence** | For long interactions, write confirmed state to disk incrementally | Anthropic BEA: agent memory outside context window. LangChain CE: Write pattern — confirmed state persisted to disk | Approach explorer writes decisions to disk as they're confirmed during conversation |
368
- | **Progressive disclosure** | Don't front-load all context; let agents discover incrementally | LangChain CE: Compress/Isolate patterns — agents assemble understanding incrementally rather than loading everything upfront | Gray areas presented individually; research loaded per area on demand |
369
-
370
- ### Prompt Structure (medium leverage)
371
-
372
- | Principle | What It Means | Source | GSDD Implementation |
373
- |-----------|--------------|--------|---------------------|
374
- | **XML semantic structure** | Use XML tags to separate role, instructions, examples, inputs, outputs, anti-patterns | Anthropic Claude: "XML tags help Claude parse complex prompts unambiguously" | All roles use `<role>`, most use `<quality_guarantees>`, `<anti_patterns>`. Approach-explorer adds `<algorithm>`, `<examples>`, `<scope_guardrail>` |
375
- | **Anti-patterns early** | Place "don't do this" instructions near the top, after role definition | Anthropic Claude prompting docs: critical information at the beginning receives more attention (primacy effect in long-context prompts) | `<anti_patterns>` placed immediately after `<role>` in all roles that have them |
376
- | **Few-shot examples** | Show the pattern of interaction, not just output format | Anthropic Claude: "3-5 examples for best results." Examples in `<example>` tags | Approach-explorer: 3 examples. Other roles use inline format examples within algorithm sections |
377
- | **Self-check before output** | Run an explicit checklist before producing the final artifact | OpenAI: "verification loops." Anthropic Claude: "Ask Claude to self-check" | Approach-explorer step 7; planner `<plan_self_check>`; executor completion verification |
378
- | **Scope boundaries with heuristics** | Don't just list in/out of scope — give the agent a judgment rule | Novel, validated in approach-explorer | "Does this clarify implementation within the phase, or does it add a capability that could be its own phase?" |
379
-
380
- ### Language & Tone (lower leverage, still matters)
381
-
382
- | Principle | What It Means | Source | GSDD Implementation |
383
- |-----------|--------------|--------|---------------------|
384
- | **Authority language: intentional leverage** | Anthropic Claude warns "CRITICAL:" can overtrigger on newer models. GSDD decision: **keep CRITICAL: for mandatory initial-read** — a genuine compliance-critical instruction where skipping causes cascading failures. Emphasis markers work when rare and specific (signal-to-noise principle: one CRITICAL: in a role contract is a load-bearing gate; ten would be noise). Use normal language for algorithm steps, scope guidance, and quality rules. | Anthropic Claude prompting docs (overtriggering caution) + technical writing signal-to-noise principle. GSDD applies the caution selectively: only compliance-critical context gates use CRITICAL: | `CRITICAL: Mandatory initial read` kept in all 7 roles. `NEVER` kept for security (mapper secret protection). Normal language used for algorithm steps, scope guidance, and quality rules |
385
- | **Tell what to do, not just what not to do** | Anti-patterns alone are insufficient; pair with positive instructions | Anthropic Claude: "Tell Claude what to do instead of what not to do" | Every role has both `<anti_patterns>` AND positive algorithm/process sections |
386
- | **Context for instructions** | Explain WHY a rule exists so the agent can generalize | Anthropic Claude: "Providing context or motivation behind your instructions helps Claude better understand your goals" | Research quality rules explain WHY: "Training data is a hypothesis. Verify before asserting." |
387
-
388
- ### Novel Patterns (not from any source)
389
-
390
- These patterns emerged from GSDD's specific needs and were validated through implementation:
391
-
392
- | Pattern | What It Does | Where Used |
393
- |---------|-------------|------------|
394
- | **Taste/Technical/Hybrid classification** | Adapts research depth to decision type; taste needs no research, technical does | Approach-explorer step 2 |
395
- | **Research quality rules** | "One viable option is valid" / "Don't manufacture trade-offs" | Approach-explorer step 3 |
396
- | **5-dimension assumption surfacing** | Forces transparency about inferences vs. confirmed facts, with confidence levels | Approach-explorer step 6 |
397
- | **Agent's Discretion delegation** | User can explicitly say "you decide" — reduces fatigue on low-stakes choices | Approach-explorer step 4, planner `<approach_decisions>` |
398
- | **Domain classification table** | SEE/CALL/RUN/READ/ORGANIZED determines gray area focus per phase type | Approach-explorer step 2 |
399
- | **Degrees of freedom mapping** | Taste=high freedom, technical=low freedom (research-constrained). GSDD-originated: applies statistical degrees-of-freedom concept to prompt design scope | Approach-explorer classification system |
400
-
401
- ### Source Ranking
402
-
403
- Sources are ranked by soundness for agent prompt design. Higher-ranked sources take precedence when sources disagree.
404
-
405
- 1. **Anthropic — "Building effective agents" (Dec 2024)** — Agent architecture patterns with production evidence (Claude Code). Most authoritative for orchestrator-worker design, sub-agent fresh context, and task decomposition.
406
- 2. **LangChain — "Context Engineering for Agents" (2025)** — Write/Select/Compress/Isolate framework. Most authoritative for context window management, JIT loading, and information flow patterns.
407
- 3. **Anthropic — Claude Prompting Best Practices (Claude 4.6)** — Model-specific, up-to-date. Critical for behavioral warnings (overtriggering, subagent overuse). Supersedes general guidance for Claude-targeted agents.
408
- 4. **OpenAI — Prompt Guidance (GPT-5.4)** — Deepest general-purpose reference. Novel concepts: completeness contracts, verification loops, tool persistence rules, empty result recovery. Model-specific but patterns transfer.
409
- 5. **OpenAI Cookbook — Meta-Prompting** — Narrow scope: LLM-as-judge evaluation, iterative prompt refinement. Useful technique, not a framework. See also: Suzgun & Kalai "Meta-Prompting" (2024, arXiv 2401.12954).
410
- 6. **JBurlison/MetaPrompts** — Structural skeleton (agent/skill/prompt/instruction hierarchy). Minimal actual guidance on prompt quality.
411
-
412
- ### Key Discrepancy Resolution
413
-
414
- When sources conflict, these resolutions apply:
415
-
416
- | Conflict | Resolution | Why |
417
- |----------|------------|-----|
418
- | Authority language ("YOU MUST" vs. normal) | Keep CRITICAL: for mandatory initial-read (compliance-critical). Use normal language elsewhere | Emphasis markers work when rare and specific (signal-to-noise). Anthropic's overtriggering concern applies to general guidance; a single CRITICAL: for a mandatory context gate is a load-bearing instruction, not noise |
419
- | Example count (2 vs. 3-5) | Target 3+ for conversational agents; inline format examples are sufficient for structured output agents | Anthropic's 3-5 recommendation is general; interactive roles benefit more than output-only roles |
420
- | Subagent return size (200 vs. 1000-2000 tokens) | Use 300-500 tokens | Anthropic's 1000-2000 is upper bound; 200 was too tight for structured approach summaries with trade-offs |
421
- | "Don't invent alternatives" vs. "try fallback strategies" | Keep "don't invent" for approach research; use fallbacks for information retrieval | These solve different problems: manufacturing fake options is worse than acknowledging one viable path |
1
+ # GSDD Role Distillation Ledger
2
+
3
+ Evidence map from each of the 10 canonical GSDD roles to their GSD sources, with keep/strip/why rationale. This ledger documents why each role exists in its current form and what GSD content was distilled or merged.
4
+
5
+ ---
6
+
7
+ ## 1. Mapper
8
+
9
+ **Canonical role:** `agents/mapper.md`
10
+
11
+ **GSD source:** `agents/_archive/gsd-codebase-mapper.md`
12
+
13
+ **Merger type:** Kept-as-is (function scope preserved, output contract simplified)
14
+
15
+ **Kept from GSD:**
16
+ - Mandatory initial-read discipline for context files
17
+ - 4 focus areas (tech, arch, quality, concerns)
18
+ - Output contract with artifact names and downstream consumers
19
+ - Core algorithm: parse → explore → fill template → write → confirm
20
+
21
+ **Stripped from GSD:**
22
+ - Multi-file codebase output reduced to 4-file standard (see D1)
23
+ - Validator-pass patterns (GSDD trusts agent reads, not file validation)
24
+
25
+ **Gained in GSDD:**
26
+ - Explicit "Downstream Consumers" section (shows who uses mapper output)
27
+ - Clear guidance on prescriptive vs. descriptive output (helps agents write better code)
28
+
29
+ **Rationale:** Mapper is the lowest-level, most stable role. Its core job (explore + document) hasn't changed, but the output set shrank from 7 files to 4 files per D1 (lean context decision). The agent role contract itself needed no substantive changes.
30
+
31
+ ---
32
+
33
+ ## 2. Researcher
34
+
35
+ **Canonical role:** `agents/researcher.md`
36
+
37
+ **GSD sources:** `agents/_archive/gsd-project-researcher.md` + `agents/_archive/gsd-phase-researcher.md` (merged)
38
+
39
+ **Merger type:** Merged (same algorithm, different scope parameter)
40
+
41
+ **Kept from GSD:**
42
+ - Mandatory initial-read discipline
43
+ - Research scope (project vs. phase)
44
+ - Research mode (ecosystem, feasibility, comparison)
45
+ - Core algorithm: receive scope → identify domains → execute tool hierarchy → verify → write → return structured result
46
+ - Quality guarantees (training data = hypothesis, honest reporting, investigation not confirmation, confidence levels on every finding)
47
+ - Research pitfalls and prevention strategies
48
+
49
+ **Stripped from GSD:**
50
+ - Separate role contracts for project-researcher and phase-researcher (merged into one with scope parameter)
51
+ - Tool-specific shell commands (kept portable tool contracts instead)
52
+
53
+ **Gained in GSDD:**
54
+ - Explicit "Scope" table showing scope × trigger × focus × output location
55
+ - Clear statement: "Same algorithm, different scope. The scope is a context input, not a different role."
56
+
57
+ **Rationale:** The GSD original had two roles (project and phase researcher) that followed the identical algorithm but with a scope parameter. GSDD merged them into one canonical role taking scope as input, reducing the role count from 11 to 9 (later 10 with approach-explorer in D29) while preserving all leverage. This is the clean merger mentioned in D2.
58
+
59
+ ---
60
+
61
+ ## 3. Synthesizer
62
+
63
+ **Canonical role:** `agents/synthesizer.md`
64
+
65
+ **GSD source:** `agents/_archive/gsd-research-synthesizer.md` (with recovery hardening from PR #15)
66
+
67
+ **Merger type:** Kept-as-is (hardened in 2026-03-13)
68
+
69
+ **Kept from GSD:**
70
+ - Mandatory initial-read discipline
71
+ - Input contract: all 4 research files (STACK, FEATURES, ARCHITECTURE, PITFALLS)
72
+ - Output contract: SUMMARY.md with executive summary, key findings, roadmap implications, confidence/gaps
73
+ - Downstream consumer (roadmapper) and what it needs
74
+ - 6-step execution flow: read → synthesize → extract → derive → assess → write
75
+
76
+ **Stripped from GSD:**
77
+ - Conditional skip logic (kept mandatory synthesizer per D5 original decision)
78
+ - Vendor-specific output formatting
79
+
80
+ **Gained in GSDD (PR #15 hardening):**
81
+ - Explicit required files list with blocked-return pattern (do not guess from partial context, return blocked status naming missing file)
82
+ - "Be opinionated" guidance to roadmapper
83
+ - Stronger structured-return contract
84
+
85
+ **Rationale:** Synthesizer is a thin single-step role with no merge or extraction needed. It was hardened in PR #15 to restore explicit structure and completion discipline, but the core function and leverage remained unchanged from GSD.
86
+
87
+ ---
88
+
89
+ ## 4. Planner
90
+
91
+ **Canonical role:** `agents/planner.md`
92
+
93
+ **GSD sources:** `agents/_archive/gsd-planner.md` + `agents/_archive/gsd-plan-checker.md` (merged)
94
+
95
+ **Merger type:** Merged (orchestration ownership transferred to native adapters)
96
+
97
+ **Kept from GSD:**
98
+ - Mandatory initial-read discipline
99
+ - Phase goal decomposition and dependency graphs
100
+ - Goal-backward verification (must-haves, artifacts, key links)
101
+ - Planner responsibility and scope
102
+ - Input contract (SPEC, ROADMAP, codebase context, prior phase artifacts)
103
+ - Output contract (PLAN.md with frontmatter, objective, context references, typed tasks)
104
+
105
+ **Stripped from GSD:**
106
+ - Separate plan-checker role (now a delegate at `distilled/templates/delegates/plan-checker.md`)
107
+ - GSD's native 3-cycle verification loop (embedded in planner) → moved to native adapter surfaces (Claude skill, OpenCode command, Codex agent)
108
+ - Vendor-specific fresh-context orchestration logic
109
+
110
+ **Gained in GSDD:**
111
+ - Explicit scope boundary: "plan-scoped, does not own verification or milestone audit"
112
+ - Goal-backward section with 4 clear questions
113
+ - Planning process section with concrete steps
114
+ - Reference to plan-checker delegate for fresh-context review
115
+ - Reduced-assurance fallback mode description (when no independent checker runs)
116
+
117
+ **Rationale:** GSD's plan-checker was a separate role running a 3-cycle revision loop. GSDD merged planner and plan-checker into a single portable contract, but preserved the adversarial review concept through native adapter surfaces. The portable workflow describes the reduced-assurance fallback. This is the high-impact merger from D2 with full tradeoff documentation.
118
+
119
+ ---
120
+
121
+ ## 5. Roadmapper
122
+
123
+ **Canonical role:** `agents/roadmapper.md`
124
+
125
+ **GSD source:** `agents/_archive/gsd-roadmapper.md` (with recovery hardening from PR #15)
126
+
127
+ **Merger type:** Kept-as-is (hardened in 2026-03-13)
128
+
129
+ **Kept from GSD:**
130
+ - Mandatory initial-read discipline
131
+ - Bounded section structure (phases, requirements, success criteria, coverage validation)
132
+ - Explicit coverage validation
133
+ - Parse-critical artifact contract
134
+ - Structured return modes
135
+ - Checklist-driven completion
136
+
137
+ **Stripped from GSD:**
138
+ - Template-path references (output lives in `.planning/ROADMAP.md`)
139
+ - Commit steps (GSDD handles git separately)
140
+ - Vendor-specific file conventions
141
+
142
+ **Gained in GSDD (PR #15 hardening):**
143
+ - Explicit `.planning/ROADMAP.md` ownership contract
144
+ - Explicit `[ ]` / `[-]` / `[x]` status grammar
145
+ - Concrete `ROADMAP CREATED` artifact example
146
+ - Hard boundary: "this role does not settle the separate ROADMAP/STATE lifecycle seam"
147
+
148
+ **Rationale:** Roadmapper was over-distilled in the initial extraction; PR #15 recovered visible structure and completion discipline. The core role and leverage were intact; hardening just restored the guardrails that improve compliance.
149
+
150
+ ---
151
+
152
+ ## 6. Executor
153
+
154
+ **Canonical role:** `agents/executor.md`
155
+
156
+ **GSD source:** `agents/_archive/gsd-executor.md` (with substantial hardening from PR #16)
157
+
158
+ **Merger type:** Kept-as-is (hardened significantly in 2026-03-13)
159
+
160
+ **Kept from GSD:**
161
+ - Plan-scoped execution discipline
162
+ - Task implementation and deviation handling
163
+ - Git action recording without repo-specific naming assumptions
164
+ - Checkpoint protocol
165
+ - Completion summary
166
+ - State update responsibility
167
+
168
+ **Stripped from GSD:**
169
+ - Bash recipe patterns and shell-specific guidance
170
+ - Tool-specific directory naming conventions
171
+
172
+ **Gained in GSDD (PR #16 hardening):**
173
+ - Explicit scope boundary with 6 things executor does NOT own
174
+ - Clearer deviation rules with priority order (auto-fix bugs first)
175
+ - Success criteria confirmation requirement
176
+ - Verify quality checks now live inside task_completeness (runnable, fast, ordered)
177
+ - Stronger commitment to documented deviations
178
+
179
+ **Rationale:** Executor is the most complex role, with the broadest deviation surface. PR #16 audit recovered substantive guardrails: explicit scope boundaries, rule priority, and verification discipline. The ~150-line executor contract expanded to ~400 lines because the detail prevents misalignment, not because the job changed.
180
+
181
+ ---
182
+
183
+ ## 7. Verifier
184
+
185
+ **Canonical role:** `agents/verifier.md`
186
+
187
+ **GSD source:** `agents/_archive/gsd-verifier.md` (with selective hardening from D2)
188
+
189
+ **Merger type:** Kept-as-is (scope preserved; cross-phase audit extracted separately)
190
+
191
+ **Kept from GSD:**
192
+ - Phase-level goal-backward verification
193
+ - Exists/Substantive/Wired gate
194
+ - Anti-pattern scan
195
+ - Output contract with compact base fields (phase, verified, status, score)
196
+ - Verification-report structure
197
+
198
+ **Stripped from GSD:**
199
+ - Cross-phase integration audit scope (extracted as separate role + workflow)
200
+ - GSD's narrative all-encompassing verification
201
+
202
+ **Gained in GSDD:**
203
+ - Richer structured verifier findings (re_verification, gaps, human_verification) when material
204
+ - Explicit boundaries: "phase-scoped only, cross-phase integration is a separate concern"
205
+ - D2 cross-reference: why integration-checker exists as a separate role
206
+
207
+ **Rationale:** Verifier's phase-level job is unchanged. The extraction of integration-checker as a separate milestone surface (D2, PR #12) made verifier smaller and clearer. Phase verification and milestone integration audit are now distinct concerns with explicit handoff points.
208
+
209
+ ---
210
+
211
+ ## 8. Integration-Checker
212
+
213
+ **Canonical role:** `agents/integration-checker.md`
214
+
215
+ **GSD source:** `agents/_archive/gsd-integration-checker.md` (with structural recovery in PR #12 and systemic hardening in PR #15)
216
+
217
+ **Merger type:** Extracted as standalone role (cross-phase scope differs structurally from phase verification)
218
+
219
+ **Kept from GSD:**
220
+ - Mandatory initial-read discipline
221
+ - Cross-phase wiring verification (exports → imports, APIs → consumers, forms → handlers, data → display)
222
+ - E2E flow tracing
223
+ - Typed structured return
224
+ - Checklist-driven completion
225
+
226
+ **Stripped from GSD (intentional):**
227
+ - Framework-specific Bash recipes
228
+ - Hardcoded path assumptions
229
+ - File-extension-specific grep flags
230
+ - Tool-specific details that don't survive vendor-agnostic distillation
231
+
232
+ **Gained in GSDD:**
233
+ - PR #12: explicit section boundaries, stronger structured output, cleaner split between role contract and milestone workflow
234
+ - PR #15: recovered compliance guardrails, restored mandatory read enforcement, explicit auth-protection verification
235
+ - D2 reference: structural difference from phase verifier
236
+ - New in D21 (PR #35): Step 4a matrix-driven auth verification (if AUTH_MATRIX.md exists)
237
+
238
+ **Rationale:** GSD's integration-checker was a separate surface but lived in the shadows of the main role contracts. PR #12 extracted it fully; PR #15 recovered its substantive guardrails. The role is different from verifier because it owns milestone scope (all-phase wiring) vs. phase scope (phase goal). This is the cleanest separation in D2.
239
+
240
+ ---
241
+
242
+ ## 9. Debugger
243
+
244
+ **Canonical role:** `agents/debugger.md`
245
+
246
+ **GSD source:** `agents/_archive/gsd-debugger.md` (no changes)
247
+
248
+ **Merger type:** Kept-as-is (unchanged)
249
+
250
+ **Kept from GSD:**
251
+ - Systematic debugging methodology
252
+ - Hypothesis formulation and testing
253
+ - State persistence across context resets
254
+ - Structured checkpoint protocol
255
+ - Deviation handling
256
+
257
+ **Stripped from GSD:** (nothing significant)
258
+ - Minor tool path references
259
+
260
+ **Gained in GSDD:** (nothing)
261
+ - The role is kept as-is for compatibility
262
+
263
+ **Rationale:** Debugger is a standalone utility role with no dependencies on other roles. It was preserved exactly as-is from GSD because it works and has no vendor lock-in. It's used ad-hoc when agents encounter failures, not as part of the main workflow pipeline.
264
+
265
+ ---
266
+
267
+ ## 10. Approach-Explorer
268
+
269
+ **Canonical role:** `agents/approach-explorer.md`
270
+
271
+ **GSD sources:** `workflows/discuss-phase.md` + `workflows/list-phase-assumptions.md` + `workflows/discovery-phase.md` (merged into new role)
272
+
273
+ **Merger type:** New role from 2 GSD sources (discuss-phase + list-phase-assumptions) with thematic input from discovery-phase
274
+
275
+ **Kept from GSD:**
276
+ - Gray area identification with 5 domain types (SEE/CALL/RUN/READ/ORGANIZED) from discuss-phase
277
+ - Scope guardrail: phase boundary is fixed, deferred ideas captured not acted on
278
+ - 5-dimension assumption surfacing (technical approach, implementation order, scope boundaries, risks, dependencies) with confidence levels from list-phase-assumptions
279
+ - Deferred ideas capture from discuss-phase
280
+ - Adaptive area-by-area deep questioning from discuss-phase (GSD used 4-question batches; GSDD uses adaptive convergence)
281
+
282
+ Note: `discovery-phase.md` contributed the concept of pre-planning research but the mechanism is entirely different — GSD used 3-level depth workflows (Quick/Standard/Deep) as a separate invocation; GSDD uses per-gray-area research subagents embedded in the plan workflow. This is thematic inspiration, not a structural merger.
283
+
284
+ **Stripped from GSD:**
285
+ - `gsd-tools.cjs` dependencies and STATE.md updates
286
+ - Vendor-specific commit steps, path conventions, and "Claude" references
287
+ - CONTEXT.md output format (replaced with structured APPROACH.md)
288
+ - Separate workflow invocation (absorbed into plan workflow as inline + research subagent hybrid)
289
+ - Rigid 4-question batched loop (replaced with adaptive questioning until decision converges)
290
+
291
+ **Gained in GSDD:**
292
+ - XML semantic structure matching planner pattern (`<role>`, `<algorithm>`, `<examples>`, etc.)
293
+ - 3 few-shot conversation examples (taste decision, technical decision, hybrid + delegation)
294
+ - Gray area classification: taste (ask directly), technical (research first), hybrid (both)
295
+ - Pre-question research per gray area via isolated research subagents returning compressed summaries
296
+ - Self-check quality gate before writing APPROACH.md
297
+ - Intermediate decision persistence (protect against context limits)
298
+ - JIT context loading with extraction guidance (read ONLY locked decisions from SPEC, ONLY phase goal from ROADMAP)
299
+ - Structured approach comparison with trade-offs
300
+ - File persistence to `{padded_phase}-APPROACH.md` using dedicated template
301
+ - Plan-checker integration via new `approach_alignment` verification dimension
302
+ - Config toggle (`workflow.discuss: true|false`) for optional skip
303
+ - Downstream consumer contract: planner reads locked decisions, plan-checker verifies alignment
304
+ - "Agent's Discretion" explicit marking for areas where user delegates choice (vendor-neutral)
305
+ - Hybrid architecture: conversation inline (main context) + research in subagents. Native agent kept as optimization.
306
+
307
+ **Rationale:** GSDD's initial distillation dropped GSD's discuss-phase and list-phase-assumptions entirely, removing genuine leverage: the planner converges on a single approach without user input, explores no alternatives, and surfaces no assumptions. The approach explorer recovers this phase-level user alignment by combining GSD's discuss-phase interaction pattern with comparative research. Ground-up rewrite (D29) applied 5 external resources on context engineering, meta-prompting, and agent skill design to produce a prompt-engineered role contract with proper XML structure, examples, adaptive conversation, and hybrid research isolation.
308
+
309
+ ---
310
+
311
+ ## Summary: Merger Table (from D2)
312
+
313
+ | Canonical role | Absorbs from GSD | Merger criteria |
314
+ |---|---|---|
315
+ | `mapper.md` | `gsd-codebase-mapper.md` | Kept-as-is; output set changed per D1 (7 → 4 files) |
316
+ | `researcher.md` | `gsd-project-researcher.md` + `gsd-phase-researcher.md` | Scope parameter instead of separate role |
317
+ | `synthesizer.md` | `gsd-research-synthesizer.md` | Kept-as-is; hardened in PR #15 |
318
+ | `planner.md` | `gsd-planner.md` + `gsd-plan-checker.md` | Orchestration ownership moved to native adapters; portable checker-delegate created |
319
+ | `roadmapper.md` | `gsd-roadmapper.md` | Kept-as-is; hardened in PR #15 |
320
+ | `executor.md` | `gsd-executor.md` | Kept-as-is; heavily hardened in PR #16 |
321
+ | `verifier.md` | `gsd-verifier.md` | Kept-as-is; cross-phase audit extracted to integration-checker |
322
+ | `integration-checker.md` | `gsd-integration-checker.md` | Extracted as standalone; recovered in PR #12, hardened in PR #15 |
323
+ | `debugger.md` | `gsd-debugger.md` | Kept-as-is; no changes |
324
+ | `approach-explorer.md` | `discuss-phase.md` + `list-phase-assumptions.md` + `discovery-phase.md` | New role from 3 GSD workflow sources |
325
+
326
+ **Result:** 11 GSD roles → 10 GSDD canonical roles (2 mergers: researcher, planner). 1 extraction: integration-checker moved from embedded to standalone. 1 addition: approach-explorer recovers discuss-phase leverage with research enhancement. Total leverage preserved and extended.
327
+
328
+ ---
329
+
330
+ ## Evidence and Context
331
+
332
+ - GSD sources: `agents/_archive/gsd-*.md`
333
+ - GSDD canonical roles: `agents/*.md` (all except `_archive/`)
334
+ - Design decisions: `distilled/DESIGN.md` (D1, D2)
335
+ - PR history:
336
+ - PR #9: Delegate extraction
337
+ - PR #12: Integration-checker extraction and lifecycle contract seam
338
+ - PR #14-17: Systemic role-contract hardening and leverage recovery
339
+ - PR #35: OWASP authorization matrix integration into integration-checker
340
+
341
+ ---
342
+
343
+ ## Maintenance
344
+
345
+ This ledger is updated when:
346
+
347
+ 1. A canonical role contract changes significantly (update the "Kept"/"Stripped"/"Gained" sections)
348
+ 2. A GSD role is merged into or extracted from a canonical role (update the merger table)
349
+ 3. New evidence surfaces that changes the distillation rationale (update with citation)
350
+
351
+ Do not add speculative content. Every entry must reference actual source files and PRs that contain evidence.
352
+
353
+ ---
354
+
355
+ ## Role Contract Design Principles
356
+
357
+ Cross-source best practices applied to GSDD role contracts, audited against 6 external resources. These principles govern how role contracts should be written and revised. Ranked by impact.
358
+
359
+ > **Source note:** "Anthropic CE" in this section refers to Anthropic's "Building effective agents" (Dec 2024) for orchestration and sub-agent patterns, and LangChain's "Context Engineering for Agents" (2025) for Write/Select/Compress/Isolate context management patterns. They are cited separately where attribution is precise.
360
+
361
+ ### Architecture-Level (highest leverage)
362
+
363
+ | Principle | What It Means | Source | GSDD Implementation |
364
+ |-----------|--------------|--------|---------------------|
365
+ | **Context isolation** | Research and heavy reads go in subagents; only compressed summaries enter the main context | Anthropic "Building effective agents" (Dec 2024): orchestrator-worker pattern — sub-agents do deep technical work and return condensed summaries | Approach explorer research subagents return ~1000-token summaries; plan-checker runs in fresh context |
366
+ | **JIT context loading** | Never say "read everything." Specify what to extract from each file | LangChain "Context Engineering for Agents" (2025): Select step of Write/Select/Compress/Isolate — load only the specific content needed, not full files | `<input_contract>` with extraction guidance: "From SPEC.md read ONLY locked decisions" |
367
+ | **Intermediate persistence** | For long interactions, write confirmed state to disk incrementally | Anthropic BEA: agent memory outside context window. LangChain CE: Write pattern — confirmed state persisted to disk | Approach explorer writes decisions to disk as they're confirmed during conversation |
368
+ | **Progressive disclosure** | Don't front-load all context; let agents discover incrementally | LangChain CE: Compress/Isolate patterns — agents assemble understanding incrementally rather than loading everything upfront | Gray areas presented individually; research loaded per area on demand |
369
+
370
+ ### Prompt Structure (medium leverage)
371
+
372
+ | Principle | What It Means | Source | GSDD Implementation |
373
+ |-----------|--------------|--------|---------------------|
374
+ | **XML semantic structure** | Use XML tags to separate role, instructions, examples, inputs, outputs, anti-patterns | Anthropic Claude: "XML tags help Claude parse complex prompts unambiguously" | All roles use `<role>`, most use `<quality_guarantees>`, `<anti_patterns>`. Approach-explorer adds `<algorithm>`, `<examples>`, `<scope_guardrail>` |
375
+ | **Anti-patterns early** | Place "don't do this" instructions near the top, after role definition | Anthropic Claude prompting docs: critical information at the beginning receives more attention (primacy effect in long-context prompts) | `<anti_patterns>` placed immediately after `<role>` in all roles that have them |
376
+ | **Few-shot examples** | Show the pattern of interaction, not just output format | Anthropic Claude: "3-5 examples for best results." Examples in `<example>` tags | Approach-explorer: 3 examples. Other roles use inline format examples within algorithm sections |
377
+ | **Self-check before output** | Run an explicit checklist before producing the final artifact | OpenAI: "verification loops." Anthropic Claude: "Ask Claude to self-check" | Approach-explorer step 7; planner `<plan_self_check>`; executor completion verification |
378
+ | **Scope boundaries with heuristics** | Don't just list in/out of scope — give the agent a judgment rule | Novel, validated in approach-explorer | "Does this clarify implementation within the phase, or does it add a capability that could be its own phase?" |
379
+
380
+ ### Language & Tone (lower leverage, still matters)
381
+
382
+ | Principle | What It Means | Source | GSDD Implementation |
383
+ |-----------|--------------|--------|---------------------|
384
+ | **Authority language: intentional leverage** | Anthropic Claude warns "CRITICAL:" can overtrigger on newer models. GSDD decision: **keep CRITICAL: for mandatory initial-read** — a genuine compliance-critical instruction where skipping causes cascading failures. Emphasis markers work when rare and specific (signal-to-noise principle: one CRITICAL: in a role contract is a load-bearing gate; ten would be noise). Use normal language for algorithm steps, scope guidance, and quality rules. | Anthropic Claude prompting docs (overtriggering caution) + technical writing signal-to-noise principle. GSDD applies the caution selectively: only compliance-critical context gates use CRITICAL: | `CRITICAL: Mandatory initial read` kept in all 7 roles. `NEVER` kept for security (mapper secret protection). Normal language used for algorithm steps, scope guidance, and quality rules |
385
+ | **Tell what to do, not just what not to do** | Anti-patterns alone are insufficient; pair with positive instructions | Anthropic Claude: "Tell Claude what to do instead of what not to do" | Every role has both `<anti_patterns>` AND positive algorithm/process sections |
386
+ | **Context for instructions** | Explain WHY a rule exists so the agent can generalize | Anthropic Claude: "Providing context or motivation behind your instructions helps Claude better understand your goals" | Research quality rules explain WHY: "Training data is a hypothesis. Verify before asserting." |
387
+
388
+ ### Novel Patterns (not from any source)
389
+
390
+ These patterns emerged from GSDD's specific needs and were validated through implementation:
391
+
392
+ | Pattern | What It Does | Where Used |
393
+ |---------|-------------|------------|
394
+ | **Taste/Technical/Hybrid classification** | Adapts research depth to decision type; taste needs no research, technical does | Approach-explorer step 2 |
395
+ | **Research quality rules** | "One viable option is valid" / "Don't manufacture trade-offs" | Approach-explorer step 3 |
396
+ | **5-dimension assumption surfacing** | Forces transparency about inferences vs. confirmed facts, with confidence levels | Approach-explorer step 6 |
397
+ | **Agent's Discretion delegation** | User can explicitly say "you decide" — reduces fatigue on low-stakes choices | Approach-explorer step 4, planner `<approach_decisions>` |
398
+ | **Domain classification table** | SEE/CALL/RUN/READ/ORGANIZED determines gray area focus per phase type | Approach-explorer step 2 |
399
+ | **Degrees of freedom mapping** | Taste=high freedom, technical=low freedom (research-constrained). GSDD-originated: applies statistical degrees-of-freedom concept to prompt design scope | Approach-explorer classification system |
400
+
401
+ ### Source Ranking
402
+
403
+ Sources are ranked by soundness for agent prompt design. Higher-ranked sources take precedence when sources disagree.
404
+
405
+ 1. **Anthropic — "Building effective agents" (Dec 2024)** — Agent architecture patterns with production evidence (Claude Code). Most authoritative for orchestrator-worker design, sub-agent fresh context, and task decomposition.
406
+ 2. **LangChain — "Context Engineering for Agents" (2025)** — Write/Select/Compress/Isolate framework. Most authoritative for context window management, JIT loading, and information flow patterns.
407
+ 3. **Anthropic — Claude Prompting Best Practices (Claude 4.6)** — Model-specific, up-to-date. Critical for behavioral warnings (overtriggering, subagent overuse). Supersedes general guidance for Claude-targeted agents.
408
+ 4. **OpenAI — Prompt Guidance (GPT-5.4)** — Deepest general-purpose reference. Novel concepts: completeness contracts, verification loops, tool persistence rules, empty result recovery. Model-specific but patterns transfer.
409
+ 5. **OpenAI Cookbook — Meta-Prompting** — Narrow scope: LLM-as-judge evaluation, iterative prompt refinement. Useful technique, not a framework. See also: Suzgun & Kalai "Meta-Prompting" (2024, arXiv 2401.12954).
410
+ 6. **JBurlison/MetaPrompts** — Structural skeleton (agent/skill/prompt/instruction hierarchy). Minimal actual guidance on prompt quality.
411
+
412
+ ### Key Discrepancy Resolution
413
+
414
+ When sources conflict, these resolutions apply:
415
+
416
+ | Conflict | Resolution | Why |
417
+ |----------|------------|-----|
418
+ | Authority language ("YOU MUST" vs. normal) | Keep CRITICAL: for mandatory initial-read (compliance-critical). Use normal language elsewhere | Emphasis markers work when rare and specific (signal-to-noise). Anthropic's overtriggering concern applies to general guidance; a single CRITICAL: for a mandatory context gate is a load-bearing instruction, not noise |
419
+ | Example count (2 vs. 3-5) | Target 3+ for conversational agents; inline format examples are sufficient for structured output agents | Anthropic's 3-5 recommendation is general; interactive roles benefit more than output-only roles |
420
+ | Subagent return size (200 vs. 1000-2000 tokens) | Use 300-500 tokens | Anthropic's 1000-2000 is upper bound; 200 was too tight for structured approach summaries with trade-offs |
421
+ | "Don't invent alternatives" vs. "try fallback strategies" | Keep "don't invent" for approach research; use fallbacks for information retrieval | These solve different problems: manufacturing fake options is worse than acknowledging one viable path |