fix(slop): fully gate the AI slop advisory on confirmed contributor (free + BYOK) - #737
Conversation
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
gittensory · advisory review Reviewed 2 changed file(s) — two independent AI reviewers. Suggested action: ✅ Safe to merge — both reviewers found no blocking issues. Reviewer A · Suggestions
Worth double-checking
Reviewer B · No blocking issues spotted. |
Completes the BYOK-only gating in this PR by closing the remaining cost vector: the AI slop advisory was still invoking FREE Workers AI for any PR author (the shared daily neuron budget), even though the AI review path (runAiReviewForAdvisory) already no-ops for unconfirmed authors. - runAiSlopForAdvisory now returns early when `!confirmedContributor` (matching the AI review path exactly): no AI spend — free OR BYOK — on a PR from an unconfirmed/untrusted author. The deterministic slop core still runs for everyone; only the paid AI layer is gated. Fail-closed: if the contributor can't be confirmed, no AI runs. - The BYOK key lookup no longer needs its own `&& confirmedContributor` guard (the early return already guarantees it). Adopts the full-gate approach from the sibling PR #727 (which also spotted this vector) while preserving this branch's BYOK integration (#728). Deliberately does NOT adopt #727's neuron-budget bump (1 -> 6): the AI review path estimates by LOGICAL free-call count, not worst-case retries, so a 6x reservation would be inconsistent and over-reserve, causing premature quota_exceeded.
What
Closes a cost/abuse vector in the AI-assisted slop advisory (#724/#728): it was being invoked for any PR author when
slopGateMode != offandslopAiAdvisorywas enabled, letting an unconfirmed/untrusted author spend both the shared free Workers AI neuron budget and the maintainer-paid BYOK quota. The AI review path (runAiReviewForAdvisory) already no-ops for unconfirmed authors; this brings the slop path in line.How
runAiSlopForAdvisorynow returns early when!confirmedContributor(matching the AI review path exactly): no AI spend — free OR BYOK — on a PR from an unconfirmed author. The deterministic slop core still runs for everyone; only the paid AI layer is gated. Fail-closed — if the contributor can't be confirmed, no AI runs.confirmedContributoris computed before the slop block (theofficialdetection + confirmation now runs ahead of the AI slop call), so the gate is enforced before any AI invocation.&& confirmedContributorguard — the early return guarantees it.Scope note (supersedes #727 and #739)
1 → 6): the AI review path estimates by logical free-call count, not worst-case retries (runWorkersOpinion/runWorkersSlopOpinionretry internally but count as one logical call). A 6× reservation would be inconsistent with that convention and would over-reserve the daily budget, causing prematurequota_exceeded.Verification
typecheck✅ ·test:coverage✅ (1836 passed; branches 97.02%, all metrics ≥97) ·git diff --check✅ ·test:workers✅test/unit/ai-slop.test.ts: confirmed contributors still get the advisory (free + BYOK paths); an unconfirmed contributor now triggers a complete no-op (neither BYOK fetch nor Workers AI; no finding) — matching the AI review path.