refactor(#1793): ADR-1769 Phase 7 — sync, prune, update migrations (#1760, #1761) (#1794)

Migrate cmdStateSync, cmdStatePrune, cmdStateUpdate (state.cts) onto the
STATE.md Transition Module substrate and close the maintenance bug pair
#1760/#1761 (ADR-1769, epic #1769). Completes the substrate: all 10
lifecycle/maintenance transitions now route through transitionCore.

- Add {kind: 'sync'|'prune'|'update'} to StateTransitionIntent with syncCore,
  pruneCore, updateCore in src/state-transition.cts.
- updateCore: body-only single-field update (strip/reassemble), mirroring the
  pre-migration cmdStateUpdate contract.
- pruneCore: pure content→content section pruning (Decisions / Recently
  Completed / resolved Blockers / Performance Metrics rows at or below cutoff),
  byte-identical tokenizeHeadings splicing. Adapter owns currentPhase, dry-run,
  and STATE-ARCHIVE.md.
- syncCore: body writes (Total Plans in Phase, Progress bar, Last Activity)
  given disk-derived numbers. Adapter owns the disk scan + roadmap scope.
- #1760: cmdStatePrune now derives currentPhase from 'Current Phase' OR 'Phase'
  (the canonical template emits 'Phase: X of Y'), so prune engages on
  template-conformant STATE.md instead of bailing 'Only 0 phases'.
- #1761: cmdStateSync skips the Progress write (percent=null) when a milestone
  version is set in frontmatter but the ROADMAP has no versioned heading for it
  (milestone cannot be bounded). Projects without a milestone version are
  unaffected. Leaves progress untouched rather than silently writing fallback-
  derived wrong values.
- Regression: bug-1760 (prune engages on template field) + bug-1761 (sync
  leaves progress untouched when unbounded). ADR-1769 marked Accepted.

All 82 transition + 515 regression tests pass.

Closes #1793
This commit is contained in:
Tom Boucher
2026-06-27 16:53:44 -04:00
committed by GitHub
parent 064f63b299
commit 79c69d443b
9 changed files with 804 additions and 165 deletions

View File

@@ -10,6 +10,8 @@
"bug-170-workflow-fallback-install-hint.test.cjs",
"bug-1736-local-install-commands.test.cjs",
"bug-1754-js-hook-guard.test.cjs",
"bug-1760-state-prune-noop-template-field.test.cjs",
"bug-1761-state-sync-wrong-progress.test.cjs",
"bug-1817-sh-hook-guard.test.cjs",
"bug-1818-unknown-flags.test.cjs",
"bug-1826-phases-clear-confirm.test.cjs",

View File

@@ -100,6 +100,8 @@
"state": {
"files": [
"bug-1695-state-patch-clobbers-phase-name.test.cjs",
"bug-1760-state-prune-noop-template-field.test.cjs",
"bug-1761-state-sync-wrong-progress.test.cjs",
"bug-21-state-md-template-frontmatter.test.cjs",
"bug-2630-state-frontmatter-milestone-switch.test.cjs",
"bug-3127-state-begin-phase-idempotent.test.cjs",