fix(engine): floor percentComplete at 0 so it stays in its documented 0-100 range (#6773)#6799
Conversation
… 0-100 range (JSONbored#6773) buildProgressSnapshot clamped only the upper bound (Math.min(100, ...)). LoopProgressState.iteration is an unvalidated caller-supplied number, so a negative iteration (an upstream bookkeeping bug) produced a negative percentComplete, contradicting the field's documented 0-100 range. Clamp both ends with Math.max(0, Math.min(100, ...)) and add a regression test asserting a negative iteration floors to 0. Closes JSONbored#6773
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6799 +/- ##
=======================================
Coverage 93.63% 93.63%
=======================================
Files 683 683
Lines 68148 68148
Branches 18703 18703
=======================================
Hits 63812 63812
Misses 3350 3350
Partials 986 986
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-17 07:18:44 UTC
Review summary Nits — 2 non-blocking
Flagged checks (non-blocking)
Decision drivers
Context & advisory signals — never blocks the verdict
Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
packages/loopover-engine/src/loop-progress.tsdocumentspercentCompleteas "0-100, or null when the budget is unknown", butbuildProgressSnapshotclamped only the upper bound (Math.min(100, ...)).LoopProgressState.iterationis a plain, unvalidatednumber, so a negativeiteration(from an upstream bookkeeping bug) produced a negativepercentComplete— outside the documented range, on a customer-facing progress surface.Math.max(0, Math.min(100, ...)). No other behavior changes (the null-budget path and the upper clamp are untouched).Closes #6773
Test plan
iteration(-1and-100) floorspercentCompleteto0.100), exact-percent, and null-budget cases still pass unchanged —test/unit/loop-progress.test.tsgreen (13 tests).npm run typecheckclean.