fix(engine): warn and fall back for out-of-range similarityThreshold (#8862) - #8994
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
normalizeSelfPlagiarismPolicy only warned when similarityThreshold was not a number. A finite numeric outside [0, 1] (e.g. 5 or -1) fell through to resolveSelfPlagiarismConfig and self-plagiarism.ts's clamp, silently collapsing to the [0, 1] bound with no warning and the field marked present -- unlike every sibling numeric normalizer, which warns and falls back to the documented default. Extend the guard to also reject non-finite and out-of-range numerics, matching normalizePositiveInteger's warn-and-fall-back convention.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8994 +/- ##
==========================================
+ Coverage 90.56% 93.87% +3.31%
==========================================
Files 96 807 +711
Lines 22490 80465 +57975
Branches 3884 24397 +20513
==========================================
+ Hits 20367 75537 +55170
- Misses 1945 3560 +1615
- Partials 178 1368 +1190
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-26 15:55:01 UTC
Review summary Nits — 3 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed 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.
|
Problem
Closes #8862.
normalizeSelfPlagiarismPolicyinpackages/loopover-engine/src/miner-goal-spec.tsonly warned whensimilarityThresholdwas not a number. A finite numeric value outside[0, 1](e.g.5or-1) passed the type check, fell through toresolveSelfPlagiarismConfig, and was then silently clamped byself-plagiarism.ts'sMath.min(1, Math.max(0, value))-- collapsing to a bound with no warning, and the field reported as present/configured.Every sibling numeric normalizer here behaves differently:
normalizePositiveIntegerwarns and falls back to the documented default when a value is non-finite or out of range. This normalizer was the odd one out, so a fat-fingered threshold silently changed miner behavior.Fix
Extend the guard so a
similarityThresholdthat is non-finite or outside[0, 1]also warns and falls back to the default, matching the warn-and-fall-back convention of the sibling normalizers.Test
test/unit/miner-goal-spec-parser.test.tsasserts that5,-1,Infinity, andNaNeach produce asimilarityThreshold ... must be a number in [0, 1]warning and fall back to the default0.85, while an in-range value (0.42) is still accepted verbatim with no warning. The test targets the observable warning + fallback, so it fails if the guard is reverted.