Files
msd-core/tests
Tom Boucher 23e6d49929 fix(#3233): no-op state update-progress when the milestone scan finds zero plans (#3375)
* 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>
2026-08-11 22:59:16 -04:00
..