Skip to content

fix(miner): drop discovery-index candidates whose repo bans AI contributions (#9680) - #9908

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
kai392:fix/9680-drop-ai-banned-v2
Jul 29, 2026
Merged

fix(miner): drop discovery-index candidates whose repo bans AI contributions (#9680)#9908
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
kai392:fix/9680-drop-ai-banned-v2

Conversation

@kai392

@kai392 kai392 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What

supplementWithDiscoveryIndex folded hosted discovery-index candidates into the local fan-out with dedupe as the only filter. The index client deliberately preserves a repo's AI-contribution ban (normalizeDiscoveryIndexCandidate writes aiPolicyAllowed !== false), but nothing downstream re-checks it — and the as RawCandidateIssue cast (whose aiPolicyAllowed is declared as the literal true) laundered a false straight through. So an index-served candidate flagged "this repo bans automated contributions" was ranked and enqueued into the miner's own portfolio backlog. The local path enforces the ban hard (fetchTargetIssues: if (!verdict.allowed) return []); the index path did not.

How

  • discover-cli.ts: filter out aiPolicyAllowed === false candidates before the dedupe filter / cast, mirroring fetchTargetIssues's own drop. The predicate is !== false, so a candidate that omits the field entirely is still kept.
  • discovery-index-client.ts: recordDiscoveryTelemetry now accepts an optional droppedAiBanned count, spread conditionally into the log payload so every existing caller keeps its exact { event, outcome } shape; the discover_query call reports the number dropped.

Tests

  • One index candidate aiPolicyAllowed: false + one true → only the allowed one reaches ranked/enqueued output, and droppedAiBanned: 1 is reported (fails against current code).
  • A candidate that omits aiPolicyAllowed is still kept (not a fail-closed drop).
  • A direct recordDiscoveryTelemetry case (both opt-ins enabled, count supplied) asserting the payload carries the count — so both arms of the conditional spread are covered.

The shared-module test that asserts the exact { event, outcome } telemetry payload still passes.

Closes #9680

@kai392
kai392 requested a review from JSONbored as a code owner July 29, 2026 21:41
@loopover-orb

loopover-orb Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-29 21:46:38 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR closes the fix in the right layer: it drops discovery-index candidates with aiPolicyAllowed === false before the dedupe/cast in supplementWithDiscoveryIndex, mirroring fetchTargetIssues' local enforcement, and threads a droppedAiBanned count through recordDiscoveryTelemetry via a conditional spread that preserves the exact prior payload shape for existing callers. The trace holds up: the `as RawCandidateIssue` cast (whose type declares aiPolicyAllowed as literal true) previously laundered a false straight through with no re-check downstream, so this is a real reachable defect, not a can't-occur fix. Tests cover both arms (banned dropped, field-omitted kept) and the telemetry spread's both branches, and the PR closes #9680 as required.

Nits — 4 non-blocking
  • nit: discover-cli.ts's inline comment above the filter is quite long (6+ lines) for a single filter predicate — consider trimming to the core rationale.
  • nit: the filter predicate `candidate.aiPolicyAllowed !== false` is duplicated conceptually from fetchTargetIssues' own ban check; consider extracting a small shared helper if this pattern recurs a third time.
  • Consider adding a one-line JSDoc/type note on DiscoveryIndexCandidate's aiPolicyAllowed field itself (if not already documented) so future readers don't need to trace through discover-cli.ts to learn that omission means allowed.
  • The droppedAiBanned count could also be useful in the non-JSON renderDiscoverSummary output for operator visibility, though this is out of scope for this fix.

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 #9680
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: 95 registered-repo PR(s), 50 merged, 7 issue(s).
Contributor context ✅ Confirmed Gittensor contributor kai392; Gittensor profile; 95 PR(s), 7 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: significant
Linked issue satisfaction

Addressed
The diff filters index candidates with aiPolicyAllowed === false before the dedupe/cast in supplementWithDiscoveryIndex, keeps field-absent candidates via the `!== false` predicate, and surfaces the dropped count via an extended recordDiscoveryTelemetry call, exactly as required; it also adds named regression tests for both the drop/keep cases, the omitted-field case, and the telemetry payload.

Review context
  • Author: kai392
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, Cuda, JavaScript, Kotlin, MDX, Perl, Ruby, TypeScript
  • Official Gittensor activity: 95 PR(s), 7 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 <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> 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

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

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

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.37%. Comparing base (8b44697) to head (619b68c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #9908       +/-   ##
===========================================
- Coverage   91.76%   79.37%   -12.39%     
===========================================
  Files         921      283      -638     
  Lines      113207    58868    -54339     
  Branches    27255     8718    -18537     
===========================================
- Hits       103886    46729    -57157     
- Misses       8034    11844     +3810     
+ Partials     1287      295      -992     
Flag Coverage Δ
backend 95.69% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/loopover-miner/lib/discover-cli.ts 94.86% <100.00%> (-5.14%) ⬇️
...kages/loopover-miner/lib/discovery-index-client.ts 100.00% <100.00%> (ø)

... and 771 files with indirect coverage changes

…butions (JSONbored#9680)

`supplementWithDiscoveryIndex` folded hosted-index candidates into the
local fan-out with dedupe as the only filter. The index client deliberately
preserves a repo's AI-contribution ban (`aiPolicyAllowed !== false`), but
nothing downstream re-checks it -- the `as RawCandidateIssue` cast (the type
declares `aiPolicyAllowed: true`) laundered a `false` straight through, so an
AI-banned repo's issue was ranked and enqueued into the miner's own
portfolio backlog, where the loop would later claim and attempt it. The
local path enforces the ban hard (`fetchTargetIssues`: `if (!verdict.allowed)
return []`); the index path did not.

- discover-cli.ts: filter out `aiPolicyAllowed === false` candidates before
  the dedupe/cast, using `!== false` so a candidate omitting the field is
  still kept (matching normalizeDiscoveryIndexCandidate's own default).
- discovery-index-client.ts: `recordDiscoveryTelemetry` now carries an
  optional `droppedAiBanned` count, spread conditionally so existing callers
  keep their exact `{ event, outcome }` payload; the `discover_query` call
  reports the number dropped.

Tests: an index candidate `aiPolicyAllowed:false` + one `true` -> only the
allowed one is ranked and `droppedAiBanned:1` is reported (fails against
current code); a candidate omitting the field is still kept; and a direct
recordDiscoveryTelemetry case (both opt-ins on) covering the payload with
the count present, so both arms of the conditional spread are covered.

Closes JSONbored#9680

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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

@loopover-orb
loopover-orb Bot merged commit 93e80ac into JSONbored:main Jul 29, 2026
8 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 30, 2026
7 tasks
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.

miner(discover): drop discovery-index candidates whose repo bans AI contributions

2 participants