fix(#3581): derive init.progress's next_phase from roadmap order, not artifact presence (#3603)

* test(#3581): pin init.progress's frontier to roadmap order over stray artifacts

Failing-first regression for #3581: a stray out-of-order phase directory
(a phase-9 UAT evidence file while roadmap phase 8 was pending and
unscaffolded) made init.progress report next_phase 09, skipping Phase 8
and disagreeing with roadmap.analyze. Rows pin the issue shape, the
aligned-tree control, and the all-complete boundary.

* fix(#3581): derive init.progress's next_phase from roadmap order, not artifact presence

The frontier is re-derived from the sorted phase union after the disk and
roadmap loops: the first not-yet-begun, not-roadmap-complete phase wins.
Artifacts still feed status and completion per entry, but a stray
out-of-order directory can no longer drag the frontier past a pending
unscaffolded roadmap phase, and init.progress agrees with roadmap.analyze.

* fix(#3581): frontier = first not-complete phase in roadmap order (resume semantics)

Review-of-own-control refinement: a begun-but-unfinished phase (in_progress,
executed, researched) is the frontier — the next thing to execute is to
resume it — so the frontier predicate is simply 'not complete and not
roadmap-complete', first in the sorted union.

* fix(#3581): preserve the pinned pending-only frontier contract; repair the boundary fixture

Review findings: the resume-semantics refinement broke the suite-pinned
contract that an in-progress phase is currentPhase's lane, not nextPhase's
(tests/init.test.cjs 'multiple phases with mixed statuses') — reverted to
first pending-or-not_started; the control row now pins the pure ordering
property (roadmap-only pending beats a later pending directory); the
boundary fixture gains passing verification reports so disk status reaches
complete under the #3168 disk-strict bar.

* chore(#3581): add changeset fragment

* chore(#3581): backfill changeset pr number

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-08-17 18:24:49 -04:00
committed by GitHub
parent 3ab0007164
commit f56ffa86ab
3 changed files with 96 additions and 0 deletions

View File

@@ -3069,6 +3069,25 @@ function cmdInitProgress(cwd: string, raw: boolean, options: Record<string, unkn
(a, b) => parseInt(a['number'] as string, 10) - parseInt(b['number'] as string, 10),
);
// #3581: the frontier is ROADMAP ORDER, not artifact presence. The disk loop
// above could claim nextPhase from a stray out-of-order artifact directory
// (a phase-9 UAT evidence dir while roadmap phase 8 was pending and
// unscaffolded), silently skipping 8 — and init.progress then disagreed with
// roadmap.analyze on the same tree. Re-derive from the sorted union: the
// first phase that has not begun ('pending' | 'not_started') and is not
// roadmap-complete wins; artifacts still feed each entry's status and
// completion (corroborating evidence) but no longer outrank the ordering.
// Aligned trees derive the identical frontier as the loops above; an
// all-complete milestone finds none and keeps nextPhase null for the
// completion flow.
{
const frontier = phases.find((p) => {
const st = p['status'];
return (st === 'pending' || st === 'not_started') && p['roadmap_complete'] !== true;
});
if (frontier) nextPhase = frontier;
}
let pausedAt: string | null = null;
const state = platformReadSync(path.join(planningDir(cwd), 'STATE.md'));
if (state !== null) {