fix(review): apply the prompt-injection reputation override before the minSample guard - #5975
Conversation
…e minSample guard signalFromCounts returned "neutral" for a low-sample account whose only windowed outcome was a single source_prompt_injection close, because the sample < minSample guard ran before the documented unconditional prompt-injection hard override. Move the override above the guard so any prompt-injection returns "low" regardless of sample size, as the comment already describes. Closes JSONbored#5940
|
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 #5975 +/- ##
=======================================
Coverage 95.16% 95.16%
=======================================
Files 589 589
Lines 46790 46790
Branches 14943 14943
=======================================
Hits 44528 44528
Misses 1511 1511
Partials 751 751
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-15 05:27:02 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 2 non-blocking
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://gittensory.aethereal.dev/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
signalFromCounts(src/review/submitter-reputation.ts) derives a submitter's reputation ("low" | "neutral" | "trusted") from recency-windowed outcome counts. Its own comment describes the prompt-injection check as an unconditional hard override — "the single hard-abuse signal", any one occurrence is enough. But thesample < cfg.minSampleguard (defaultminSample: 5) runs first and returns"neutral"before the prompt-injection branch is ever reached:So a first-time / low-history submitter whose only windowed outcome is a single
source_prompt_injectionclose hassample = 1 < 5→"neutral"— the exact opposite of the documented intent, and the worst case for this bug: a brand-new low-sample account attempting prompt injection once is precisely the scenario the hard override exists to catch.Fix
Move the prompt-injection hard override above the
minSampleguard so it fires unconditionally, as documented. Nothing else changes — the weighted-fail / trusted logic still runs only over a sufficient sample.Test
test/unit/submitter-reputation.test.tsadds: a single prompt-injection from a low-sample account (sample = 1) →"low"— which returned"neutral"before the fix. The existing sufficient-sample prompt-injection cases and the minSample/neutralcases are unchanged.Local: the two affected unit suites pass;
tsc --noEmitclean on the changed files.Closes #5940