fix(outreach): do not rest a campaign for a quota failure - #195
Merged
Merged
Conversation
The back-off asks whether a discovery pass produced anything, but an empty ValueSERP plan answers HTTP 402 without running the queries at all — which looks identical to a query list with nothing left to give. Left as it was, the month-end 402 that prompted this work would have rested every campaign for up to a day, and since the plan is one shared monthly bucket they would all have been resting by the time it refilled, pushing recovery well past the reset it was supposed to ride out. serpCreditsExhausted() exposes the cooldown the previous commit already tracked, so a pass with no credits behind it declines to vote and leaves the streak alone. The first pass that actually reaches Google is the one that decides whether the queries still work. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ThreatCrush Security Scan35 finding(s) HIGH/CRITICAL: 5 | MEDIUM: 27 | LOW: 3
Snippets are redacted; ThreatCrush never prints matched credential material. |
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.
Why this exists separately
This commit was pushed to #194 before it merged, but GitHub's PR index was lagging and the squash only picked up the first commit.
serpCreditsExhaustedis not on master. Re-opening it on its own so it actually lands.Verified against master:
What it fixes
#194 shipped a back-off that rests a campaign whose discovery pass produced nothing. But an empty ValueSERP plan answers HTTP 402 without running the queries at all, which is indistinguishable from a query list with nothing left to give.
So as master stands right now, switching the paused campaigns back on before the 16:40 UTC quota reset would:
discovery_dry_streak,Because the plan is one shared monthly bucket, this hits every campaign at once, every month. It converts a self-healing 12-hour outage into a ~36-hour one.
serpCreditsExhausted()exposes the cooldown #194 already tracks, so a pass with no credits behind it declines to vote and leaves the streak alone. The first pass that actually reaches Google is the one that decides whether the queries still work.Tests
Two directions, because the distinction is the whole point:
resetSerpCreditCooldown()clears itnpx tsc --noEmitclean,npx vitest run1436 passed / 0 failed.Note
The three campaigns are still paused pending this. Re-enabling them is safe once this deploys, or after 16:40 UTC either way.
🤖 Generated with Claude Code