Skip to content

refactor(scripts): extract shared Gemini quota-error predicate (9 sites)#1028

Open
sliamh11 wants to merge 2 commits into
mainfrom
dedup/gemini-quota-predicate
Open

refactor(scripts): extract shared Gemini quota-error predicate (9 sites)#1028
sliamh11 wants to merge 2 commits into
mainfrom
dedup/gemini-quota-predicate

Conversation

@sliamh11

Copy link
Copy Markdown
Owner

Summary

  • Adds scripts/_gemini_quota.py with a single is_quota_error(exc) predicate and re-points 9 duplicated inline "429"/RESOURCE_EXHAUSTED checks across drift_check.py (3), trec_atom_benchmark.py (2), memory_indexer.py (1, plus deleting its own now-redundant local copy), rule_following_judge.py (1), and attention_dilution_probe.py (2) to use it.

Opportunistic dedup cleanup found during the Deus V2 migration — not a Linear-tracked issue. Deliberately narrow scope: an earlier, broader attempt to consolidate the entire "call Gemini with model-fallback" logic across these files was rejected across 3 review rounds because the actual retry/fallback bodies differ meaningfully per file (temperature, token limits, exhaustion-tracking, retry cadence, control-flow shape). Only the one-line predicate — proven byte-for-byte semantically identical after str() normalization across all 9 sites — is extracted. Everything else stays untouched.

Test plan

  • New scripts/tests/test_gemini_quota.py — 6 cases, all passing
  • test_gemini_quota.py + test_drift_check.py — 113 passed
  • test_memory_indexer.py + test_memory_indexer_ner.py + test_rule_following_judge.py + test_attention_dilution_probe.py — 347 passed
  • Smoke-tested all 4 modified scripts import cleanly (rule_following_judge, attention_dilution_probe need scripts/bench/ on sys.path; drift_check, trec_atom_benchmark need scripts/ on sys.path)
  • Grep-confirmed no inline literal quota checks remain at any of the 9 sites
  • Native code-reviewer + GPT + GLM co-gate — all SHIP
  • verification-gate — SHIP

🤖 Generated with Claude Code

sliamh11 and others added 2 commits July 14, 2026 12:26
Adds scripts/_gemini_quota.py with a single is_quota_error(exc) predicate
and re-points the 9 duplicated inline "429"/RESOURCE_EXHAUSTED checks in
drift_check.py, trec_atom_benchmark.py, memory_indexer.py,
rule_following_judge.py, and attention_dilution_probe.py to use it.

Scope is intentionally minimal — this is the one piece of the Gemini
call-with-fallback logic proven safe to consolidate across prior review
rounds. The surrounding retry/fallback bodies (temperatures, token
limits, exhaustion-tracking, retry cadence) differ meaningfully per file
and are left untouched.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant