* test(#3233): zero plans (0/0) is a no-op; plans-but-none-done still writes 0% cmdStateUpdateProgress mapped 0/0 through clampPercent to 0% and rewrote the shipped Progress record after milestone close. Replace the stale 'handles zero plans gracefully' test (which asserted the buggy percent:0) with a #3233 no-op regression (100% record preserved, updated:false), and add a negative-space guard: plans exist but none done must still write a legitimate 0%. RED — fails on next; fix follows. * fix(#3233): no-op state update-progress when the milestone scan finds zero plans cmdStateUpdateProgress mapped 0/0 through clampPercent to 0% and unconditionally rewrote the body Progress line, so after /gsd-complete-milestone archived the phases (.planning/phases/ empty, scope COMPLETE) a routine update-progress run destroyed the shipped record ([██████████] 100% → [░░░░░░░░░░] 0%). Add an early-return no-op when totalPlans === 0 — mirroring the established scope-withholding no-op (stderr WARNING + {updated:false, reason}) and computeProgressPercent's null-for-empty contract ('nothing to measure' ≠ '0% done'). The legitimate 0% case (plans exist, none summarized) is unaffected: totalPlans > 0 reaches clampPercent(0, N>0) = 0 and writes 0% as before. * test(#3233): unshadow 'Progress field missing' — clear the zero-plans guard The new totalPlans===0 no-op guard fires before the 'Progress field not found' branch, so the existing 'returns error when Progress field missing' test (no phase dirs → 0 plans) was passing for the wrong reason and that branch lost coverage. Give that test a phase dir + PLAN so totalPlans > 0 clears the guard and it reaches the branch it is named for. (Isolated review finding.) * chore(#3233): add changeset fragment * chore(#3233): backfill changeset PR number (#3375) --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -804,6 +804,27 @@ function cmdStateUpdateProgress(cwd: string, raw: boolean): void {
|
||||
return;
|
||||
}
|
||||
|
||||
// #3233: zero plans in the current-milestone phases means there is nothing to
|
||||
// measure — most often the milestone was just closed and its phases archived
|
||||
// (.planning/phases/ empty, but scope COMPLETE — "a real empty"). clampPercent
|
||||
// maps 0/0 to 0%, which would clobber the shipped Progress record (e.g.
|
||||
// [██████████] 100% → [░░░░░░░░░░] 0%). No-op instead, mirroring the
|
||||
// scope-withhold above and computeProgressPercent's null-for-empty contract
|
||||
// ("nothing to measure" ≠ "0% done"). The legitimate 0% case (plans exist,
|
||||
// none summarized → clampPercent(0, N>0) = 0) is unaffected: totalPlans > 0.
|
||||
if (totalPlans === 0) {
|
||||
process.stderr.write(
|
||||
`[gsd-tools] WARNING: state update-progress skipped — no plans found in current-milestone phases (0 plans). ` +
|
||||
`STATE.md's Progress field was left unchanged (milestone archived?).\n`
|
||||
);
|
||||
output(
|
||||
{ updated: false, reason: 'no plans found in current-milestone phases — STATE.md left unchanged (milestone archived?)' },
|
||||
raw,
|
||||
'false',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const percent = clampPercent(totalSummaries, totalPlans);
|
||||
const barWidth = 10;
|
||||
const filled = Math.round(percent / 100 * barWidth);
|
||||
|
||||
Reference in New Issue
Block a user