fix(review): gate every AI-spend call site on the repo's paused/frozen state - #4420
Merged
Conversation
…n state resolveRepoActionMode() is already computed once per pass in maybePublishPrPublicSurface and correctly threaded into every GitHub-write call (labels, comments, check-runs) -- but never into the four functions that actually spend real tokens (runAiReviewForAdvisory, runAiSlopForAdvisory, runLinkedIssueSatisfactionForAdvisory, runVisualVisionForAdvisory) or the maintainer-invoked agent-run summary (attachPrivateAiSummary). Each of those was gated only by its own independent feature flag (aiReviewMode, slop.aiAdvisory, linkedIssueSatisfactionGateMode), completely orthogonal to the fleet-wide env brake, the DB freeze, and per-repo pause. This meant reactivating a repo with a large stale PR backlog (or simply forgetting one of several independent settings while trying to pause) let already-queued and newly-triggered review jobs keep spending for as long as the backlog took to drain -- confirmed live: two repos burned through 500 fresh AI-review/slop calls across 98 distinct PRs over several hours before the queue emptied, because re-engaging the freeze override alone did not stop already-dispatched work from reaching the LLM call once dequeued. Threads the mode already resolved by the caller into all five spend paths, with "paused" as the first check in each -- gating at the point of spend rather than only at the point of dispatch, so a freeze that engages between enqueue and execution is still honored. "dry_run" still computes (so a maintainer can validate review decisions locally); only "paused" stops spend outright.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolveRepoActionMode()is already computed once per pass inmaybePublishPrPublicSurfaceand correctly threaded into every GitHub-write call (labels, comments, check-runs) — but was never threaded into the functions that actually spend real tokens:runAiReviewForAdvisory,runAiSlopForAdvisory,runLinkedIssueSatisfactionForAdvisory,runVisualVisionForAdvisory, plus the maintainer-invoked agent-run summary (attachPrivateAiSummary). Each was gated only by its own independent feature flag (aiReviewMode,slop.aiAdvisory,linkedIssueSatisfactionGateMode), completely orthogonal to the fleet-wide env brake, the DB freeze, and per-repo pause.modeinto all five spend paths, withmode === "paused"as the very first check in each — gating at the point of spend, not just the point of dispatch, so a freeze that engages between enqueue and execution is still honored."dry_run"still computes (so a maintainer can validate review decisions locally without publishing); only"paused"stops spend outright.Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
npm run typechecknpx vitest run test/unit/ai-review-advisory.test.ts test/unit/ai-slop.test.ts test/unit/linked-issue-satisfaction-run.test.ts test/unit/visual-vision-wiring.test.ts test/unit/rag-wiring.test.ts test/unit/repo-culture-profile-wiring.test.ts test/unit/reputation-wiring.test.ts test/unit/enrichment-wiring.test.ts test/unit/grounding-wiring.test.ts test/unit/impact-map-processor-wiring.test.ts test/unit/advisory-ai-routing-call-sites.test.ts test/unit/repository-settings-enforcement.test.ts test/unit/agent-orchestrator.test.ts— 279/279 pass, including 5 new dedicated regression tests (one per spend path) proving a"paused"mode never reaches the LLM/vision provider call even when every feature-specific flag would otherwise allow it.npx vitest run test/unit/queue.test.ts— full suite, 754/754 pass (this is the primary integration suite exercising the changedprocessors.tscall sites end-to-end).npm run actionlint/npm run test:workers/npm run build:mcp/npm run test:mcp-pack/npm run ui:openapi:check/npm run ui:lint/npm run ui:typecheck/npm run ui:build/npm audit— not run locally for this focused change; relying on CI (validate) for the full gate.If any required check was skipped, explain why:
npm run test:cigate is left to CI per the repo's own established practice for this size of change.Safety
UI Evidencesection. — N/A, no UI changes.Notes
auto_pause_after_reviewed_commitscost counter from GitHub-publish success (it currently undercounts when a publish step is slow/rate-limited), and a coarser per-(repo, PR) minimum-reinterval throttle spanning all three independent trigger sources (scheduled sweep, CI-completion webhook, live push webhook).