Skip to content

fix(engine): warn and fall back for out-of-range similarityThreshold (#8862) - #8994

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-self-plagiarism-threshold-8862
Jul 26, 2026
Merged

fix(engine): warn and fall back for out-of-range similarityThreshold (#8862)#8994
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-self-plagiarism-threshold-8862

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Problem

Closes #8862.

normalizeSelfPlagiarismPolicy in packages/loopover-engine/src/miner-goal-spec.ts only warned when similarityThreshold was not a number. A finite numeric value outside [0, 1] (e.g. 5 or -1) passed the type check, fell through to resolveSelfPlagiarismConfig, and was then silently clamped by self-plagiarism.ts's Math.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: normalizePositiveInteger warns 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 similarityThreshold that 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.ts asserts that 5, -1, Infinity, and NaN each produce a similarityThreshold ... must be a number in [0, 1] warning and fall back to the default 0.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.

@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 26, 2026 15:30
@superagent-security

Copy link
Copy Markdown
Contributor

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

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.87%. Comparing base (f32e140) to head (e193b5c).
⚠️ Report is 8 commits behind head on main.

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     
Flag Coverage Δ
backend 95.16% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/loopover-engine/src/miner-goal-spec.ts 100.00% <ø> (ø)

... and 710 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 26, 2026
@loopover-orb

loopover-orb Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-26 15:55:01 UTC

2 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a small, correctly-targeted fix: it extends the guard in normalizeSelfPlagiarismPolicy (miner-goal-spec.ts:261-266) to also catch non-finite and out-of-range numeric similarityThreshold values, matching the warn-and-fallback convention used by normalizePositiveInteger and other sibling normalizers in this file. The fix is at the right layer (the normalizer itself, not a downstream clamp), the resolveSelfPlagiarismConfig call above it is now effectively unreachable for out-of-range numbers since the guard returns fallback first, and the added test exercises the real parseMinerGoalSpec path with 5, -1, Infinity, and NaN plus a valid in-range control case with no warning.

Nits — 3 non-blocking
  • miner-goal-spec.ts:265 still calls resolveSelfPlagiarismConfig(value) before the guard runs, so for the fixed cases that work is now wasted (harmless since the guard discards the result, but worth reordering or noting it's now dead work for the out-of-range path).
  • Consider moving the similarityThreshold validation before calling resolveSelfPlagiarismConfig so the wasted call is avoided for invalid values (miner-goal-spec.ts:264-266).
  • The new test's loop in miner-goal-spec-parser.test.ts could also assert on `parsed.present` to confirm the spec is still marked present after fallback, consistent with other sibling-field tests in this file.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8862
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 305 registered-repo PR(s), 121 merged, 37 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 305 PR(s), 37 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff extends the guard to catch non-finite or out-of-range similarityThreshold values, warns with a message matching the sibling normalizer style, and falls back to the default, exactly as requested; a new test verifies out-of-range values (5, -1, Infinity, NaN) trigger the warning and fallback while in-range values remain unaffected.

Review context
  • Author: RealDiligent
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 305 PR(s), 37 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask 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.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

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.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(engine): normalizeSelfPlagiarismPolicy silently clamps an out-of-range similarityThreshold with no warning

1 participant