Files
msd-core/sdk/prompts/workflows/plan-phase.md
Tom Boucher 1a3d953767 feat: add unified post-planning gap checker (closes #2493) (#2610)
* feat: add unified post-planning gap checker (closes #2493)

Adds a unified post-planning gap checker as Step 13e of plan-phase.md.
After all plans are generated and committed, scans REQUIREMENTS.md and
CONTEXT.md <decisions> against every PLAN.md in the phase directory and
emits a single Source | Item | Status table.

Why
- The existing Requirements Coverage Gate (§13) blocks/re-plans on REQ
  gaps but emits two separate per-source signals. Issue #2493 asks for
  one unified report after planning so that requirements AND
  discuss-phase decisions slipping through are surfaced in one place
  before execution starts.

What
- New workflow.post_planning_gaps boolean config key, default true,
  added to VALID_CONFIG_KEYS, CONFIG_DEFAULTS, hardcoded.workflow, and
  cmdConfigSet (boolean validation).
- New get-shit-done/bin/lib/decisions.cjs — shared parser for
  CONTEXT.md <decisions> blocks (D-NN entries). Designed for reuse by
  the related #2492 plan/verify decision gates.
- New get-shit-done/bin/lib/gap-checker.cjs — parses REQUIREMENTS.md
  (checkbox + traceability table forms), reads CONTEXT.md decisions,
  walks PHASE_DIR/*-PLAN.md, runs word-boundary coverage detection
  (REQ-1 must not match REQ-10), formats a sorted report.
- New gsd-tools gap-analysis CLI command wired through gsd-tools.cjs.
- workflows/plan-phase.md gains §13e between §13d (commit plans) and
  §14 (Present Final Status). Existing §13 gate preserved — §13e is
  additive and non-blocking.
- sdk/prompts/workflows/plan-phase.md gets an equivalent
  post_planning_gaps step for headless mode.
- Docs: CONFIGURATION.md, references/planning-config.md, INVENTORY.md,
  INVENTORY-MANIFEST.json all updated.

Tests
- tests/post-planning-gaps-2493.test.cjs: 30 test cases covering step
  insertion position, decisions parser, gap detector behavior
  (covered/not-covered, false-positive guard, missing-file
  resilience, malformed-input resilience, gate on/off, deterministic
  natural sort), and full config integration.
- Full suite: 5234 / 5234 pass.

Design decisions
- Numbered §13e (sub-step), not §14 — §14 already exists (Present
  Final Status); inserting before it preserves downstream auto-advance
  step numbers.
- Existing §13 gate kept, not replaced — §13 blocks/re-plans on
  REQ gaps; §13e is the unified post-hoc report. Per spec: "default
  behavior MUST be backward compatible."
- Word-boundary ID matching avoids REQ-1 matching REQ-10 and avoids
  brittle semantic/substring matching.
- Shared decisions.cjs parser so #2492 can reuse the same regex.
- Natural-sort keys (REQ-02 before REQ-10) for deterministic output.
- Boolean validation in cmdConfigSet rejects non-boolean values
  matches the precedent set by drift_threshold/drift_action.

Closes #2493

* fix(#2493): expose post_planning_gaps in loadConfig() + sync schema example

Address CodeRabbit review on PR #2610:

- core.cjs loadConfig(): return post_planning_gaps from both the
  config.json branch and the global ~/.gsd/defaults.json fallback so
  callers can rely on config.post_planning_gaps regardless of whether
  the key is present (comment 3127977404, Major).
- docs/CONFIGURATION.md: add workflow.post_planning_gaps to the Full
  Schema JSON example so copy/paste users see the new toggle alongside
  security_block_on (comment 3127977392, Minor).
- tests/post-planning-gaps-2493.test.cjs: regression coverage for
  loadConfig() — default true when key absent, honors explicit
  true/false from workflow.post_planning_gaps.
2026-04-22 23:03:59 -04:00

3.5 KiB

Create executable phase plans (PLAN.md files) for a roadmap phase with integrated research and verification. Headless SDK variant — runs autonomously. Research, planning, and plan-checking proceed without user prompts. Default flow: Research (if needed) -> Plan -> Verify -> Done. Load all context from injected context files. Extract: phase directory, phase number, phase name, research status, context status, plan count, requirement IDs.

If planning directory is missing: report error via event stream.

Validate phase exists in roadmap. If not found: report error with available phases. Load CONTEXT.md if it exists. This contains user decisions that constrain planning.

If no CONTEXT.md exists: proceed without — plan using research and requirements only. In headless mode, there is no interactive discuss-phase; context comes from prior artifacts or is skipped.

If RESEARCH.md exists: use existing research.

If RESEARCH.md is missing and research is enabled:

  1. Execute research phase (spawn researcher agent)
  2. Researcher writes RESEARCH.md
  3. Continue to planning

If research is disabled: skip to planning step.

Execute planning with the planner agent definition. Provide: - Phase number, name, and goal - Context files: state, roadmap, requirements, context, research - Phase requirement IDs (every ID must appear in a plan's requirements field)

The planner creates PLAN.md files with task breakdown, dependency analysis, and verification criteria.

- **PLANNING COMPLETE** — Plans created. If plan checker is enabled: proceed to verification. - **PLANNING BLOCKED** — Log blocker, report via event stream. - **PLANNING INCONCLUSIVE** — Report with available context. If plan checker is enabled, execute verification with the plan-checker agent. Provide: - Phase number and goal - Plan files to verify - Roadmap, requirements, context, research files - Phase requirement IDs

The checker verifies plans will achieve the phase goal before execution.

- **VERIFICATION PASSED** — Plans ready for execution. - **ISSUES FOUND** — Enter revision loop (max 3 iterations): 1. Send issues back to planner for targeted revision 2. Re-run plan checker 3. If max iterations reached: proceed with current plans, log remaining issues After plans pass the checker (or checker is skipped), verify all phase requirements are covered: 1. Extract requirement IDs claimed by plans 2. Compare against phase requirements from roadmap 3. If gaps found: log as warning, continue (headless mode does not block for coverage gaps) Unified post-planning gap report (#2493). Gated on `workflow.post_planning_gaps` (default true). When enabled, scan REQUIREMENTS.md and CONTEXT.md `` against all generated PLAN.md files, then emit one `Source | Item | Status` table. Skip-gracefully on missing sources. Non-blocking — headless mode reports gaps via the event stream and continues.

<success_criteria>

  • Phase validated against roadmap
  • Research completed (unless skipped or existing)
  • PLAN.md file(s) created with valid structure
  • Plan checker passed (or issues logged)
  • Requirements coverage verified </success_criteria>