feat(slop): BYOK frontier model for the AI slop advisory - #728
Conversation
Extends the AI slop advisory (#724) to optionally use the maintainer's own frontier model (Anthropic/OpenAI) instead of free Workers AI, reusing the existing per-repo encrypted key + aiReviewByok flag — one BYOK key serves both AI features. Advisory-only either way; BYOK never changes whether the slop pass can block (it can't). - ai-review.ts: extract callAiProvider (shared BYOK HTTP/timeout/error handling) — runProviderReview now wraps it; export ProviderFailure + DEFAULT_BYOK_DAILY_REPO_LIMIT. - repositories.ts: generalize countByokAiReviewEventsForRepoSince -> countByokAiEventsForRepoSince — one shared per-repo/day BYOK cap across ALL AI features (review + slop), so enabling more capabilities cannot multiply frontier spend. - ai-slop.ts: providerKey path skips the free neuron budget, checks the shared BYOK cap, calls callAiProvider + parseSlopOpinion, records byok:<provider> usage. Workers-AI fallback unchanged. Fail-safe. - processors runAiSlopForAdvisory: decrypt the repo key (a declared provider override must match) and pass it through. Tests: BYOK provider path (provider used, Workers AI not) + shared BYOK cap quota; existing Workers-AI gating/fail-safe still green. 97% coverage held.
|
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 5 changed file(s) — two independent AI reviewers. Suggested action: 🛠️ Request changes. (reviewers split: request changes / merge) Address the suggestions below before merging. Reviewer A · Suggestions
Worth double-checking
Reviewer B · Suggestions
Worth double-checking
|
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.
…free + BYOK) (#737) * fix: gate BYOK slop advisory by contributor * fix(slop): fully gate the AI slop advisory on confirmed contributor 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
Extends the AI slop advisory (#724) to optionally use the maintainer's own frontier model (Anthropic/OpenAI) instead of free Workers AI — reusing the existing per-repo encrypted key +
aiReviewByokflag (no new key or setting). One BYOK key serves both AI features. Advisory-only either way; BYOK never changes whether the slop pass can block (it can't).How
ai-review.ts: extractcallAiProvider(shared BYOK HTTP/timeout/error handling) —runProviderReviewnow wraps it. ExportProviderFailure+DEFAULT_BYOK_DAILY_REPO_LIMIT.repositories.ts: generalizecountByokAiReviewEventsForRepoSince→countByokAiEventsForRepoSince— one shared per-repo/day BYOK cap across all AI features (review + slop), so enabling more capabilities can't multiply frontier spend.ai-slop.ts: theproviderKeypath skips the free neuron budget, checks the shared BYOK cap, callscallAiProvider+parseSlopOpinion, and recordsbyok:<provider>usage. Workers-AI fallback unchanged. Fail-safe on every path.processorsrunAiSlopForAdvisory: decrypt the repo key (a declared provider override must match the stored key) and pass it through.Tests
BYOK provider path (provider used, Workers AI not) + the shared BYOK cap quota; existing Workers-AI gating/fail-safe still green. Typecheck + UI lint + OpenAPI clean; 97% coverage held.