Context
packages/loopover-engine/src/loop-progress.ts:33-34 documents percentComplete as "0-100, or null when the budget is unknown," but the implementation at lines 43-44 clamps only the upper bound (Math.min(100, ...)) with no Math.max(0, ...). LoopProgressState.iteration is a plain number with no runtime validation before this computation, so a negative iteration (from an upstream bookkeeping bug) produces a negative percentComplete. No test file exists for this module; the mirror host test only covers the upper-bound clamp.
Requirements
- Clamp with
Math.max(0, Math.min(100, ...)) so percentComplete can never leave [0, 100] regardless of the caller-supplied iteration value.
Deliverables
Test Coverage Requirements
99%+ Codecov patch coverage on every changed line and branch, plus a regression test that reproduces the exact failure mode described above and asserts it's fixed.
Expected Outcome
percentComplete always stays within its documented [0, 100] range.
Links & Resources
packages/loopover-engine/src/loop-progress.ts:33-34,43-44.
Context
packages/loopover-engine/src/loop-progress.ts:33-34documentspercentCompleteas "0-100, or null when the budget is unknown," but the implementation at lines 43-44 clamps only the upper bound (Math.min(100, ...)) with noMath.max(0, ...).LoopProgressState.iterationis a plainnumberwith no runtime validation before this computation, so a negativeiteration(from an upstream bookkeeping bug) produces a negativepercentComplete. No test file exists for this module; the mirror host test only covers the upper-bound clamp.Requirements
Math.max(0, Math.min(100, ...))sopercentCompletecan never leave[0, 100]regardless of the caller-suppliediterationvalue.Deliverables
iterationassertingpercentCompleteclamps to 0Test Coverage Requirements
99%+ Codecov patch coverage on every changed line and branch, plus a regression test that reproduces the exact failure mode described above and asserts it's fixed.
Expected Outcome
percentCompletealways stays within its documented[0, 100]range.Links & Resources
packages/loopover-engine/src/loop-progress.ts:33-34,43-44.