mandrel 1.87.0 → 1.89.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 (140) hide show
  1. package/.agents/README.md +18 -13
  2. package/.agents/audit-checklists/architecture.md +24 -0
  3. package/.agents/audit-checklists/clean-code.md +24 -0
  4. package/.agents/audit-checklists/dependencies.md +14 -0
  5. package/.agents/audit-checklists/devops.md +17 -0
  6. package/.agents/audit-checklists/documentation.md +22 -0
  7. package/.agents/audit-checklists/lighthouse.md +15 -0
  8. package/.agents/audit-checklists/navigability.md +14 -0
  9. package/.agents/audit-checklists/performance.md +22 -0
  10. package/.agents/audit-checklists/privacy.md +21 -0
  11. package/.agents/audit-checklists/quality.md +18 -0
  12. package/.agents/audit-checklists/security.md +22 -0
  13. package/.agents/audit-checklists/seo.md +16 -0
  14. package/.agents/audit-checklists/sre.md +24 -0
  15. package/.agents/audit-checklists/ux-ui.md +21 -0
  16. package/.agents/docs/SDLC.md +63 -16
  17. package/.agents/docs/configuration.md +5 -3
  18. package/.agents/instructions.md +51 -21
  19. package/.agents/personas/architect.md +10 -7
  20. package/.agents/personas/engineer.md +4 -3
  21. package/.agents/personas/project-manager.md +5 -2
  22. package/.agents/personas/refactorer.md +5 -3
  23. package/.agents/rules/git-conventions.md +77 -0
  24. package/.agents/schemas/agentrc.schema.json +16 -4
  25. package/.agents/schemas/audit-rules.json +16 -2
  26. package/.agents/schemas/audit-rules.schema.json +7 -6
  27. package/.agents/schemas/lifecycle/merge.unlanded.schema.json +38 -0
  28. package/.agents/schemas/signal-event.schema.json +28 -13
  29. package/.agents/scripts/acceptance-spec-reconciler.js +6 -4
  30. package/.agents/scripts/check-context-budget.js +320 -0
  31. package/.agents/scripts/diagnose-friction.js +4 -4
  32. package/.agents/scripts/epic-audit-prepare.js +30 -2
  33. package/.agents/scripts/epic-audit-recheck.js +46 -13
  34. package/.agents/scripts/epic-deliver-prepare.js +80 -8
  35. package/.agents/scripts/epic-plan-spec.js +4 -8
  36. package/.agents/scripts/generate-lens-checklists.js +180 -0
  37. package/.agents/scripts/lib/audit-suite/checklist-threading.js +300 -0
  38. package/.agents/scripts/lib/audit-suite/findings.js +27 -0
  39. package/.agents/scripts/lib/audit-suite/index.js +9 -0
  40. package/.agents/scripts/lib/audit-suite/lens-checklist.js +212 -0
  41. package/.agents/scripts/lib/audit-suite/selector.js +136 -5
  42. package/.agents/scripts/lib/checks/loop-health.js +340 -0
  43. package/.agents/scripts/lib/cli-args.js +8 -0
  44. package/.agents/scripts/lib/config/explain.js +4 -0
  45. package/.agents/scripts/lib/config/runners.js +21 -2
  46. package/.agents/scripts/lib/config/temp-paths.js +24 -0
  47. package/.agents/scripts/lib/config-settings-schema-delivery.js +23 -3
  48. package/.agents/scripts/lib/config-settings-schema-quality.js +7 -0
  49. package/.agents/scripts/lib/doc-tiers.js +291 -0
  50. package/.agents/scripts/lib/epic-body-sections.js +5 -2
  51. package/.agents/scripts/lib/epic-merge-lock.js +83 -0
  52. package/.agents/scripts/lib/epic-plan-clarity.js +3 -1
  53. package/.agents/scripts/lib/feedback-loop/audit-results-graduator.js +66 -20
  54. package/.agents/scripts/lib/feedback-loop/graduator-core.js +395 -86
  55. package/.agents/scripts/lib/feedback-loop/memory-freshness.js +299 -72
  56. package/.agents/scripts/lib/feedback-loop/retro-proposals-graduator.js +438 -0
  57. package/.agents/scripts/lib/gates/friction.js +15 -5
  58. package/.agents/scripts/lib/observability/perf-aggregator.js +30 -104
  59. package/.agents/scripts/lib/observability/perf-report-readers.js +1 -1
  60. package/.agents/scripts/lib/observability/signal-validator.js +204 -0
  61. package/.agents/scripts/lib/observability/signals-writer.js +157 -54
  62. package/.agents/scripts/lib/observability/tool-trace-hook.js +42 -4
  63. package/.agents/scripts/lib/orchestration/acceptance-eval-decision.js +1 -1
  64. package/.agents/scripts/lib/orchestration/code-review.js +74 -4
  65. package/.agents/scripts/lib/orchestration/consolidation-precondition.js +213 -0
  66. package/.agents/scripts/lib/orchestration/doc-reader.js +4 -96
  67. package/.agents/scripts/lib/orchestration/docs-digest.js +34 -0
  68. package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/authoring-context.js +56 -19
  69. package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/run-spec-phase.js +22 -0
  70. package/.agents/scripts/lib/orchestration/lifecycle/emit-merge-unlanded.js +188 -0
  71. package/.agents/scripts/lib/orchestration/lifecycle/listeners/README.md +6 -0
  72. package/.agents/scripts/lib/orchestration/lifecycle/listeners/automerge-armer.js +69 -8
  73. package/.agents/scripts/lib/orchestration/lifecycle/listeners/automerge-predicate.js +11 -2
  74. package/.agents/scripts/lib/orchestration/lifecycle/listeners/finalizer.js +47 -61
  75. package/.agents/scripts/lib/orchestration/lifecycle/listeners/index.js +39 -3
  76. package/.agents/scripts/lib/orchestration/lifecycle/listeners/label-transitioner.js +144 -0
  77. package/.agents/scripts/lib/orchestration/lifecycle/listeners/merge-watcher.js +258 -14
  78. package/.agents/scripts/lib/orchestration/lifecycle/listeners/notify-dispatcher.js +6 -0
  79. package/.agents/scripts/lib/orchestration/merge-block-class.js +218 -0
  80. package/.agents/scripts/lib/orchestration/plan-review-routing.js +1 -1
  81. package/.agents/scripts/lib/orchestration/post-merge/phases/worktree-reap.js +3 -3
  82. package/.agents/scripts/lib/orchestration/retro/phases/compose-body.js +63 -34
  83. package/.agents/scripts/lib/orchestration/retro/phases/gather-signals.js +167 -52
  84. package/.agents/scripts/lib/orchestration/retro/phases/post-and-mirror.js +49 -2
  85. package/.agents/scripts/lib/orchestration/retro-proposals.js +12 -55
  86. package/.agents/scripts/lib/orchestration/retro-runner.js +9 -0
  87. package/.agents/scripts/lib/orchestration/single-story-close/phases/code-review.js +8 -0
  88. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +419 -0
  89. package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +35 -2
  90. package/.agents/scripts/lib/orchestration/single-story-close/phases/wrong-tree-guard.js +353 -69
  91. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +66 -4
  92. package/.agents/scripts/lib/orchestration/spec-section-validator.js +60 -9
  93. package/.agents/scripts/lib/orchestration/story-close/auto-refresh-runner.js +7 -5
  94. package/.agents/scripts/lib/orchestration/story-close/merge-runner.js +24 -2
  95. package/.agents/scripts/lib/orchestration/story-close/phases/code-review.js +167 -8
  96. package/.agents/scripts/lib/orchestration/story-close/shared-checkout-guard.js +163 -0
  97. package/.agents/scripts/lib/orchestration/ticketing/reads.js +20 -9
  98. package/.agents/scripts/lib/planning-corpus.js +306 -0
  99. package/.agents/scripts/lib/signals/detectors/common.js +10 -10
  100. package/.agents/scripts/lib/signals/detectors/index.js +4 -4
  101. package/.agents/scripts/lib/signals/detectors/retry.js +19 -18
  102. package/.agents/scripts/lib/signals/detectors/rework.js +1 -1
  103. package/.agents/scripts/lib/signals/schema.js +56 -81
  104. package/.agents/scripts/lib/signals/span-tree.js +6 -5
  105. package/.agents/scripts/lib/story-plan.js +3 -0
  106. package/.agents/scripts/lib/wave-runner/tick.js +10 -2
  107. package/.agents/scripts/lifecycle-emit.js +39 -8
  108. package/.agents/scripts/providers/github/issues.js +12 -1
  109. package/.agents/scripts/resolve-doc-tiers.js +83 -0
  110. package/.agents/scripts/retro-run.js +51 -0
  111. package/.agents/scripts/signals-view.js +1 -1
  112. package/.agents/scripts/single-story-close.js +20 -1
  113. package/.agents/scripts/standalone-feedback-rollup.js +188 -0
  114. package/.agents/scripts/story-close.js +48 -0
  115. package/.agents/scripts/story-plan.js +51 -12
  116. package/.agents/scripts/validate-docs-freshness.js +69 -15
  117. package/.agents/skills/core/documentation-and-adrs/SKILL.md +58 -0
  118. package/.agents/skills/core/epic-plan-decompose-author/SKILL.md +5 -3
  119. package/.agents/skills/core/epic-plan-spec-author/SKILL.md +20 -7
  120. package/.agents/skills/core/scope-triage/SKILL.md +61 -0
  121. package/.agents/skills/skills.index.json +3 -3
  122. package/.agents/workflows/audit-documentation.md +82 -2
  123. package/.agents/workflows/helpers/code-review.md +193 -44
  124. package/.agents/workflows/helpers/deliver-epic.md +128 -39
  125. package/.agents/workflows/helpers/deliver-stories.md +26 -0
  126. package/.agents/workflows/helpers/epic-audit.md +116 -283
  127. package/.agents/workflows/helpers/epic-deliver-story.md +14 -0
  128. package/.agents/workflows/helpers/epic-plan-decompose.md +18 -200
  129. package/.agents/workflows/helpers/epic-plan-spec.md +18 -180
  130. package/.agents/workflows/helpers/plan-epic.md +141 -105
  131. package/.agents/workflows/helpers/plan-story.md +32 -0
  132. package/.agents/workflows/helpers/single-story-deliver.md +43 -0
  133. package/.agents/workflows/loops/nightly-audit.md +9 -7
  134. package/docs/CHANGELOG.md +29 -0
  135. package/lib/cli/doctor.js +44 -0
  136. package/package.json +4 -3
  137. package/.agents/scripts/epic-plan-spec-validate.js +0 -111
  138. package/.agents/scripts/lib/feedback-loop/code-review-graduator.js +0 -207
  139. package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/prompts.js +0 -58
  140. package/.agents/scripts/lib/signals/detectors/hotspot.js +0 -292
@@ -1,204 +1,22 @@
1
1
  ---
2
2
  description: >-
3
- Phase 8 of sprint planning decompose an Epic's sectioned body (which
4
- carries the folded Tech Spec) into a
5
- backlog of child Stories, persist the backlog, and flip the Epic to
6
- `agent::ready`. Host-LLM authored; no external API calls.
3
+ Thin pointer — Phase 8 (decompose) of sprint planning now lives entirely in
4
+ `helpers/plan-epic.md`. This file is kept only so pre-existing links to
5
+ `helpers/epic-plan-decompose.md` still resolve.
7
6
  ---
8
7
 
9
- # Sprint Plan — Decompose Phase (helper)
10
-
11
- > **Helper module.** Not a slash command. Invoked by `/plan` (Phase 8).
12
- > To run the decompose phase interactively, use `/plan [Epic_ID]` it
13
- > delegates here after the spec phase.
14
-
15
- ## Role
16
-
17
- Director / Architect
18
-
19
- ## Context
20
-
21
- This helper is the **decompose phase** of the split planning pipeline. It
22
- reads the Epic body whose managed sections carry the Tech Spec previously
23
- produced by the spec phase
24
- helper ([`epic-plan-spec.md`](epic-plan-spec.md)) — generates the Epic's child
25
- Story tickets, persists them to GitHub, and flips the Epic to
26
- `agent::ready` (parking) so a human can run `/deliver` when
27
- execution should begin.
28
-
29
- The ticket array is authored **directly by you, the host LLM**.
30
- `epic-plan-decompose.js` is a deterministic wrapper that (a) emits the
31
- authoring context you need and (b) validates, persists, and transitions the
32
- Epic lifecycle state.
33
-
34
- The ticket array contains `type::story` tickets only — no Feature
35
- containers and no `type::task` children. Acceptance criteria and verification
36
- steps are inlined on each Story body via the `acceptance[]` and
37
- `verify[]` fields. The decomposer system prompt lives in the
38
- [`epic-plan-decompose-author`](../../skills/core/epic-plan-decompose-author/SKILL.md)
39
- skill.
40
-
41
- ## Constraint
42
-
43
- - **Do not** run this skill until the spec phase is complete. The Epic body
44
- must carry Tech Spec content (the managed section or a `## Delivery
45
- Slicing` heading); the script will refuse to proceed otherwise.
46
- - **Do not** restructure the Story set after the decomposition
47
- writes — the `epic-plan-state` checkpoint records the structure as
48
- committed. Use `--force` to rebuild from scratch.
49
- - **Every** temp file must include the Epic ID in its name. Multiple Epics
50
- may be decomposed concurrently; bare names will collide.
51
- - **Do not** flip the Epic past `agent::ready` from this helper. Execution
52
- begins when an operator runs `/deliver [Epic_ID]`.
53
-
54
- ## Prerequisites
55
-
56
- 1. **Epic is on `agent::review-spec`** — i.e. the spec phase has already run
57
- and the Epic body carries the Tech Spec sections.
58
- 2. **API keys** — `GITHUB_TOKEN` set in `.env`.
59
-
60
- ## Step 1 — Gather decomposition context
61
-
62
- ```bash
63
- node .agents/scripts/epic-plan-decompose.js --epic [Epic_ID] --emit-context \
64
- > temp/epic-[Epic_ID]/decomposer-context.json
65
- ```
66
-
67
- The emitted JSON contains the Epic body (`epicBody` — the spec sections and
68
- acceptance table travel inside it), risk heuristics, the
69
- decomposer system prompt, and the `maxTickets` **reviewability budget**
70
- (Story #2798 — not a hard cap; over-budget plans require an explicit
71
- `--allow-over-budget` override at persist time).
72
-
73
- ## Step 2 — Author the ticket array
74
-
75
- Read `temp/epic-[Epic_ID]/decomposer-context.json`. Produce a JSON array of
76
- Story objects that conforms to the schema in the system prompt
77
- and write it to `temp/epic-[Epic_ID]/tickets.json`.
78
-
79
- When the Tech Spec carries a `## Delivery Slicing` section, author toward the
80
- Architect's proposed shippable-Story clusters rather than mapping Epic
81
- capabilities 1:1; degrade gracefully (current behaviour) when it is absent.
82
-
83
- ## Step 2.5 — Phase 8.3: Holistic Consolidation (HITL diff gate)
84
-
85
- The decompose phase runs in the sequence **emit-context → author →
86
- consolidate → validate+persist**. Step 2 is the *author* half; this step is
87
- the *consolidate* half, a separate critic pass run **before** the
88
- deterministic validator and **before** the GitHub write.
89
-
90
- Activate the
91
- [`epic-plan-consolidate`](../../skills/core/epic-plan-consolidate/SKILL.md)
92
- skill with `[Epic_ID]` as input. It reads the draft
93
- `temp/epic-[Epic_ID]/tickets.json` plus the Epic body (with its folded
94
- Tech Spec sections) from
95
- `decomposer-context.json`, reconciles the draft against the Tech Spec
96
- `## Delivery Slicing` target (degrading gracefully when absent), and emits:
97
-
98
- - a **consolidated** `temp/epic-[Epic_ID]/tickets.json` (overwriting the draft),
99
- - a human-readable `temp/epic-[Epic_ID]/consolidation-report.md` (rationale +
100
- before/after diff).
101
-
102
- The pass is constrained to scope-preserving operations only — **merge sibling
103
- Stories and rewire `depends_on`**. It MUST NOT add scope or invent tickets.
104
- It consolidates fragmented slices by merging them into a cohesive Story,
105
- never by splitting one into two; the `assertAllTicketsAreStories` validator
106
- (in `lib/orchestration/ticket-validator.js`) stays as the post-consolidation
107
- backstop that rejects any non-Story ticket the pass might emit.
108
-
109
- > **HITL diff gate.** Show the operator
110
- > `temp/epic-[Epic_ID]/consolidation-report.md` (the before/after diff +
111
- > rationale) **before** running the persist call in Step 3. Consolidation is
112
- > never auto-applied without operator review — the operator approves the
113
- > consolidated plan (or rejects it and the draft is persisted instead). Only
114
- > after approval proceed to Step 3.
115
-
116
- This sub-step does **not** renumber the top-level lifecycle phases (9–12); it
117
- is a sub-step of Phase 8.
118
-
119
- ## Step 3 — Persist and transition
120
-
121
- ```bash
122
- # Normal decomposition
123
- node .agents/scripts/epic-plan-decompose.js --epic [Epic_ID] \
124
- --tickets temp/epic-[Epic_ID]/tickets.json
125
-
126
- # Re-decompose (closes existing child Features/Stories first)
127
- node .agents/scripts/epic-plan-decompose.js --epic [Epic_ID] \
128
- --tickets temp/epic-[Epic_ID]/tickets.json --force
129
-
130
- # Persist an over-budget plan (Story #2798 — only after the operator
131
- # has confirmed the over_budget_rationale on the Epic)
132
- node .agents/scripts/epic-plan-decompose.js --epic [Epic_ID] \
133
- --tickets temp/epic-[Epic_ID]/tickets.json --allow-over-budget
134
- ```
135
-
136
- On success the script:
137
-
138
- - Creates the Feature / Story hierarchy under the Epic.
139
- - Updates the `epic-plan-state` structured comment with the ticket count
140
- and decompose timestamp.
141
- - Flips the Epic to `agent::ready`.
142
-
143
- ## Step 4 — Cross-validation
144
-
145
- Delegate the structural invariants (hierarchy completeness, dependency DAG
146
- acyclicity, missing complexity labels) to `epic-plan-healthcheck.js`. It is
147
- the single source of truth for post-decompose validation — the Phase 10 run
148
- inside `/plan` calls the same script, so local and remote flows agree.
149
-
150
- ```bash
151
- node .agents/scripts/epic-plan-healthcheck.js --epic [Epic_ID] --paranoid
152
- ```
153
-
154
- `--paranoid` is the flag that runs the richer hierarchy and dependency
155
- checks; pair it with `--epic [Epic_ID]` so the script can fetch the
156
- ticket tree. `--dry-run` exists as well but only emits the planned
157
- checks without performing any I/O — it is not a substitute for
158
- `--paranoid` when you need the hierarchy invariants validated.
159
-
160
- The script exits 0 regardless of findings (non-blocking), but lists any
161
- `ERR`-level findings that must be addressed before execution:
162
-
163
- - Missing `type::story` tickets.
164
- - Stories without `complexity::` labels.
165
- - Dependency cycles across Stories.
166
-
167
- For the semantic checks the healthcheck cannot automate, do these by eye:
168
-
169
- - **Scope-overlap check**: Stories whose scope is "docs / runbook / README"
170
- downstream of a "config + runbook" Story in the same Epic should carry a
171
- scope-verification note pointing at
172
- `git diff main -- <path>` against the upstream Story branch.
173
- - **Risk flagging**: Confirm `risk::high` Stories match the heuristics in
174
- the decomposer context.
175
-
176
- Fix any gaps by creating additional issues or updating existing ones.
177
-
178
- ## Step 5 — Cleanup
179
-
180
- The wrapper script deletes the phase-scoped temp files automatically when
181
- Step 3 succeeds — no operator action required. The cleanup contract lives in
182
- [`lib/plan-phase-cleanup.js`](../../scripts/lib/plan-phase-cleanup.js), which
183
- is the single source of truth for which temp paths this phase owns.
184
-
185
- ## Handoff
186
-
187
- - Surface the backlog summary and the Wave 0 candidates to the operator:
188
-
189
- > "Decomposition complete. Epic #[ID] is on `agent::ready` with NN ticket(s)
190
- > across MM Stories. Run `/deliver [Epic_ID]` to begin execution."
191
-
192
- ## Troubleshooting
193
-
194
- - "Epic #N body carries no Tech Spec sections (no ## Delivery Slicing)" —
195
- run `/plan [Epic_ID]`
196
- first (it will run the spec phase if the Tech Spec sections are missing).
197
- - Validator rejects the tickets file — the most common causes are a
198
- Story whose `parent_slug` does not point at a Feature, a missing
199
- `acceptance[]` / `verify[]` array on a Story body, or a Story
200
- `depends_on` slug that does not resolve to another Story in the same
201
- Epic.
202
- - If `--force` is required but the script refuses, confirm the Epic has the
203
- linked artifacts first — `--force` only re-decomposes; it does not bypass
204
- the spec-phase prerequisite.
8
+ # Sprint Plan — Decompose Phase (thin pointer)
9
+
10
+ > **Superseded.** This file used to carry its own Phase 8 step-by-step
11
+ > procedure a drifted duplicate of the authoritative one, and a pre-skill
12
+ > pattern. Story #4403 collapsed it: the full, current Phase 8 procedure
13
+ > (context gathering, the
14
+ > [`epic-plan-decompose-author`](../../skills/core/epic-plan-decompose-author/SKILL.md)
15
+ > skill activation, the Phase 8.3 consolidation / Phase 8.4 reachability /
16
+ > Phase 8.5 pre-mortem critic passes, the persist call, cross-validation, and
17
+ > cleanup) lives in
18
+ > [`helpers/plan-epic.md` § Phase 8](plan-epic.md#phase-8-work-breakdown-decomposition).
19
+ > Read that section — do not resurrect an inline copy here.
20
+
21
+ The complementary Phase 7 pointer is
22
+ [`helpers/epic-plan-spec.md`](epic-plan-spec.md).
@@ -1,184 +1,22 @@
1
1
  ---
2
2
  description: >-
3
- Phase 7 of sprint planning generate the Tech Spec and Acceptance Table for
4
- an Epic, persist them as managed sections of the Epic body, and flip the
5
- Epic to `agent::review-spec`. Host-LLM authored; no external API calls.
3
+ Thin pointer — Phase 7 (spec) of sprint planning now lives entirely in
4
+ `helpers/plan-epic.md`. This file is kept only so pre-existing links to
5
+ `helpers/epic-plan-spec.md` still resolve.
6
6
  ---
7
7
 
8
- # Sprint Plan — Spec Phase (helper)
9
-
10
- > **Helper module.** Not a slash command. Invoked by `/plan` (Phase 7).
11
- > To run the spec phase interactively, use `/plan [Epic_ID]` it
12
- > delegates here.
13
-
14
- ## Role
15
-
16
- Director / Architect
17
-
18
- ## Context
19
-
20
- This helper is the **spec phase** of the split planning pipeline. It produces
21
- two planning artifacts for an Epic — a Technical Specification and an
22
- Acceptance Table — persists them as **marker-delimited managed sections of
23
- the Epic body** (`<!-- mandrel:tech-spec:start/end -->` and
24
- `<!-- mandrel:acceptance-table:start/end -->`), and flips the Epic to
25
- `agent::review-spec` (parking) so a human reviewer can read the updated Epic
26
- body on GitHub before decomposition. A `/plan` Epic run creates exactly
27
- **one** issue — the Epic. The PRD artifact class was retired (Story #4314);
28
- its one novel section, **User Stories**, lives inline in the Epic body.
29
- Story #4324 retired the `context::tech-spec` / `context::acceptance-spec`
30
- ticket classes the same way — the content semantics are unchanged, only
31
- where the output lives moved.
32
-
33
- > **Single prose home.** The canonical, full-detail spec-phase contract
34
- > (idempotent managed sections, the fold rationale, the
35
- > `acceptance::n-a` waiver, the Epic-lease preflight) lives in
36
- > [`epic-plan.md` § Phase 7](plan-epic.md). This helper carries only the
37
- > operational step list; when the two disagree, `epic-plan.md` wins.
38
-
39
- The Tech Spec and Acceptance Table are authored **directly by you, the host
40
- LLM**. `epic-plan-spec.js` is a deterministic wrapper that (a) emits the
41
- authoring context you need and (b) persists the sections and transitions the
42
- Epic lifecycle state.
43
-
44
- The complementary Phase 8 helper is
45
- [`epic-plan-decompose.md`](epic-plan-decompose.md). The `/plan`
46
- wrapper chains both helpers with a confirmation gate in between.
47
-
48
- ## Constraint
49
-
50
- - **Do not** create any tickets from this phase — the only GitHub write is
51
- the section-scoped Epic body update (plus structured comments);
52
- decomposition belongs to
53
- [`epic-plan-decompose.md`](epic-plan-decompose.md).
54
- - **Do not** flip the Epic to `agent::ready` from this skill. The terminal
55
- label for the spec phase is `agent::review-spec`.
56
- - **Every** temp file must include the Epic ID in its name. Multiple Epics may
57
- be planned concurrently; bare names like `temp/techspec.md` will collide.
58
- - **Stop and hand back to the operator** after Step 4 when
59
- `planningRisk.requiresReview` is true or the operator passed
60
- `--force-review` — do not chain into decomposition. Low-risk Epics
61
- auto-proceed to Phase 8 after the persist stdout confirms
62
- `reviewRouting.decision === 'auto-proceed'`.
63
-
64
- ## Prerequisites
65
-
66
- 1. **GitHub Epic** — an open issue with the `type::epic` label. The Epic's
67
- body should contain enough narrative context (including its `## User
68
- Stories` section) to seed the Tech Spec.
69
- 2. **API keys** — `GITHUB_TOKEN` set in `.env`.
70
-
71
- ## Step 1 — Gather authoring context
72
-
73
- Run the spec-phase CLI in context-emission mode to collect the Epic body, the
74
- scraped project docs, and the recommended system prompts.
75
-
76
- ```bash
77
- node .agents/scripts/epic-plan-spec.js --epic [Epic_ID] --emit-context \
78
- > temp/epic-[Epic_ID]/planner-context.json
79
- ```
80
-
81
- ## Step 2 — Author the Tech Spec
82
-
83
- Read `temp/epic-[Epic_ID]/planner-context.json`. Using
84
- `systemPrompts.techSpec`, the Epic body (its Context / Goal / Scope / User
85
- Stories sections), and `docsContext`, write the Tech Spec to
86
- `temp/epic-[Epic_ID]/techspec.md`. Open the document with the
87
- `## Delivery Slicing` section (no `<h1>`); do not restate the Epic's
88
- Context / Goal / Scope — the output lands as sections of the same Epic body.
89
-
90
- ## Step 2.5 — Author the risk verdict
91
-
92
- Judge the change described by the Epic body and Tech Spec you just wrote and
93
- write `temp/epic-[Epic_ID]/risk-verdict.json` conforming to
94
- [`risk-verdict.schema.json`](../../schemas/risk-verdict.schema.json):
95
- `{ axes: [{ axis, level, rationale }], summary }`. The authoritative
96
- authoring rules (axis vocabulary, judgment-not-keywords, derivation
97
- preview) live in the
98
- [`epic-plan-spec-author` Skill, Step 4](../../skills/core/epic-plan-spec-author/SKILL.md).
99
-
100
- ## Step 2.6 — Author the Acceptance Table
101
-
102
- Using `systemPrompts.acceptanceSpec`, the Epic body, and the Tech Spec, write
103
- the Acceptance Spec to `temp/epic-[Epic_ID]/acceptance-spec.md`. It opens
104
- with `## Acceptance Table` and captures the stable-ID acceptance criteria
105
- table (`| AC ID | Outcome | Feature File | Scenario | Disposition |`) that
106
- drives close-time reconciliation in `/deliver` Phase 6.
107
-
108
- **Skip this step only** when the Epic carries the `acceptance::n-a` waiver
109
- label (refactor-only or docs-only Epics); in that case omit
110
- `--acceptance-table` from Step 3.
111
-
112
- ## Step 3 — Persist and transition
113
-
114
- ```bash
115
- # Normal flow (both managed sections)
116
- node .agents/scripts/epic-plan-spec.js --epic [Epic_ID] \
117
- --tech-spec temp/epic-[Epic_ID]/techspec.md \
118
- --risk-verdict temp/epic-[Epic_ID]/risk-verdict.json \
119
- --acceptance-table temp/epic-[Epic_ID]/acceptance-spec.md
120
-
121
- # Re-plan (--force overwrites the managed sections in place)
122
- node .agents/scripts/epic-plan-spec.js --epic [Epic_ID] \
123
- --tech-spec temp/epic-[Epic_ID]/techspec.md \
124
- --risk-verdict temp/epic-[Epic_ID]/risk-verdict.json \
125
- --acceptance-table temp/epic-[Epic_ID]/acceptance-spec.md --force
126
-
127
- # Waived (acceptance::n-a label on Epic — no Acceptance Table authored)
128
- node .agents/scripts/epic-plan-spec.js --epic [Epic_ID] \
129
- --tech-spec temp/epic-[Epic_ID]/techspec.md \
130
- --risk-verdict temp/epic-[Epic_ID]/risk-verdict.json
131
- ```
132
-
133
- On success the script:
134
-
135
- - Validates the risk verdict against `risk-verdict.schema.json` (a
136
- malformed verdict fails closed before any GitHub mutation) and derives
137
- the `planningRisk` envelope from it.
138
- - Upserts the Tech Spec content and (unless waived) the `## Acceptance
139
- Table` as managed sections of the Epic body, stripping any legacy
140
- `## Planning Artifacts` section. The Acceptance Table is skipped when
141
- `--acceptance-table` is omitted under the `acceptance::n-a` waiver.
142
- - Upserts the `risk-verdict` structured comment recording the verdict and
143
- the derived envelope.
144
- - Upserts the `epic-plan-state` structured comment with the current phase,
145
- the persisted-section flags (`techSpecPersisted`, `acceptanceTable`),
146
- the `riskVerdict` field, and timestamps.
147
- - Flips the Epic to `agent::review-spec`.
148
-
149
- ## Step 4 — Cleanup
150
-
151
- The wrapper script deletes the phase-scoped temp files automatically when
152
- Step 3 succeeds — no operator action required. The cleanup contract lives in
153
- [`lib/plan-phase-cleanup.js`](../../scripts/lib/plan-phase-cleanup.js), which
154
- is the single source of truth for which temp paths this phase owns. If you
155
- need to inspect the temp artefacts after the fact, re-run
156
- `epic-plan-spec.js --emit-context` to regenerate the planner context.
157
-
158
- ## Handoff
159
-
160
- Branch on the shared planning risk decision surfaced in the persist stdout
161
- JSON (`planningRisk`, `reviewRouting`):
162
-
163
- - **High risk or `--force-review` — STOP.** Surface the Epic URL to the
164
- operator:
165
-
166
- > "Spec phase complete for Epic #[ID]. Review the updated Epic body
167
- > (Tech Spec sections + `## Acceptance Table`) on GitHub. When you're
168
- > ready, re-run `/plan [Epic_ID]` — the wrapper will pick up where it
169
- > left off and run the decompose phase."
170
-
171
- - **Low risk — auto-proceed.** Relay `reviewRouting.operatorMessage` and
172
- continue directly to Phase 8 decomposition without waiting for verbal
173
- approval in this session.
174
-
175
- ## Troubleshooting
176
-
177
- - If `--emit-context` fails with "Epic not found", confirm the ID matches the
178
- GitHub issue number and the token has `issues:read`.
179
- - If the persist call fails after writing the Tech Spec section but before
180
- the Acceptance Table, re-run with `--force` (the section upsert is
181
- idempotent — it replaces the managed regions in place).
182
- - If the Epic does not flip to `agent::review-spec` after the script claims
183
- success, the label write likely races with a concurrent mutation — re-run the
184
- persist step; it's idempotent against the already-persisted sections.
8
+ # Sprint Plan — Spec Phase (thin pointer)
9
+
10
+ > **Superseded.** This file used to carry its own Phase 7 step-by-step
11
+ > procedure a drifted duplicate of the authoritative one, and a pre-skill
12
+ > pattern that instructed inline authoring from the envelope's
13
+ > (now-retired) `systemPrompts` field. Story #4403 collapsed it: the full,
14
+ > current Phase 7 procedure (context gathering, the
15
+ > [`epic-plan-spec-author`](../../skills/core/epic-plan-spec-author/SKILL.md)
16
+ > skill activation, the persist call and its folded Tech Spec section gate,
17
+ > review routing, freshness/BDD advisories, and cleanup) lives in
18
+ > [`helpers/plan-epic.md` § Phase 7](plan-epic.md#phase-7-epic-planning-tech-spec--acceptance-spec).
19
+ > Read that section — do not resurrect an inline copy here.
20
+
21
+ The complementary Phase 8 pointer is
22
+ [`helpers/epic-plan-decompose.md`](epic-plan-decompose.md).