Files
msd-core/get-shit-done/references/planner-gap-closure.md
Tom Boucher 46d9c26158 fix(agents): modular decomposition of gsd-planner.md to solve 50K char limit (#1612)
* test: add failing tests for planner modular decomposition

- Assert gsd-planner.md is under 45K after extraction (currently ~50K)
- Assert three reference files exist (gap-closure, revision, reviews)
- Assert planner contains reference pointers to each extracted file
- Assert each reference file contains key content from the original mode

* feat(agents): modular decomposition of gsd-planner.md to fix 50K char limit

Extracts three non-standard mode sections from gsd-planner.md into dedicated
reference files loaded on-demand, and calibrates the security scanner to use
a per-file-type threshold (100K for agent source files vs 50K for user input).

Structural changes:
- Extract <gap_closure_mode> → get-shit-done/references/planner-gap-closure.md
- Extract <revision_mode> → get-shit-done/references/planner-revision.md
- Extract <reviews_mode> → get-shit-done/references/planner-reviews.md
- Add <load_mode_context> step in execution_flow (conditional lazy loading)
- gsd-planner.md: 50,112 → 45,352 chars (well under new 45K target)

Security scanner fix:
- Split agent file check: injection patterns (unchanged) + separate 100K size limit
- The 50K strict-mode limit was designed for user-supplied input, not trusted source files
- Agent files still have a size guard to catch accidental bloat

Partially addresses #1495

* fix(tests): normalize CRLF before measuring planner file size

Windows git checkouts add \r per line, inflating String.length by ~1150 chars
for a 1,400-line file. The 45K threshold test failed on windows-latest because
45,352 chars (Linux) became 46,507 chars (Windows). Apply the same CRLF
normalization pattern used in tests/reachability-check.test.cjs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:32:05 -04:00

61 lines
1.8 KiB
Markdown

# Gap Closure Mode — Planner Reference
Triggered by `--gaps` flag. Creates plans to address verification or UAT failures.
**1. Find gap sources:**
Use init context (from load_project_state) which provides `phase_dir`:
```bash
# Check for VERIFICATION.md (code verification gaps)
ls "$phase_dir"/*-VERIFICATION.md 2>/dev/null
# Check for UAT.md with diagnosed status (user testing gaps)
grep -l "status: diagnosed" "$phase_dir"/*-UAT.md 2>/dev/null
```
**2. Parse gaps:** Each gap has: truth (failed behavior), reason, artifacts (files with issues), missing (things to add/fix).
**3. Load existing SUMMARYs** to understand what's already built.
**4. Find next plan number:** If plans 01-03 exist, next is 04.
**5. Group gaps into plans** by: same artifact, same concern, dependency order (can't wire if artifact is stub → fix stub first).
**6. Create gap closure tasks:**
```xml
<task name="{fix_description}" type="auto">
<files>{artifact.path}</files>
<action>
{For each item in gap.missing:}
- {missing item}
Reference existing code: {from SUMMARYs}
Gap reason: {gap.reason}
</action>
<verify>{How to confirm gap is closed}</verify>
<done>{Observable truth now achievable}</done>
</task>
```
**7. Assign waves using standard dependency analysis** (same as `assign_waves` step):
- Plans with no dependencies → wave 1
- Plans that depend on other gap closure plans → max(dependency waves) + 1
- Also consider dependencies on existing (non-gap) plans in the phase
**8. Write PLAN.md files:**
```yaml
---
phase: XX-name
plan: NN # Sequential after existing
type: execute
wave: N # Computed from depends_on (see assign_waves)
depends_on: [...] # Other plans this depends on (gap or existing)
files_modified: [...]
autonomous: true
gap_closure: true # Flag for tracking
---
```