Skip to content

Per review quota#156

Open
helq wants to merge 4 commits into
sashiko-dev:mainfrom
helq:feat-per-review-quota
Open

Per review quota#156
helq wants to merge 4 commits into
sashiko-dev:mainfrom
helq:feat-per-review-quota

Conversation

@helq
Copy link
Copy Markdown
Collaborator

@helq helq commented May 7, 2026

The global throttling system might stall reviews after an API outage. These changes make the global quota mechanism configurable and allow to set up more aggressive retries.

Instead of using an exponential backoff mechanism that can stall reviews for hours, we can force a review on a given timeoff.

helq added 3 commits May 7, 2026 23:14
Introduce new configuration parameters under the [ai] section in
Settings.toml to support more flexible backoff strategies:
- global_backoff: toggle between global and per-worker backoff
- quota_backoff_secs: flat delay for Quota Exceeded (429) errors
- transient_backoff_type: exponential or flat transient retry backoff
- transient_flat_backoff_secs: flat delay for transient retries

Also implement corresponding fields and serde-defaults inside the
Rust Settings parsing layer in src/settings.rs.

Signed-off-by: Elkin Cruz <elkin@google.com>
Define a unified, downcastable AiError enum in src/ai/mod.rs to map
provider-specific errors (QuotaExceeded, Transient, Fatal) at the
API boundary.

Implement custom error mappings for GeminiClient, ClaudeClient, and
OpenAiCompatClient so that they return the standardized AiError
wrapped in anyhow::Error. This decouples provider-specific error
formatting from the core orchestration layer.

Signed-off-by: Elkin Cruz <elkin@google.com>
Refactor QuotaManager to support flat backoffs and enforce a minimum
delay cap (1s) to prevent zero-delay CPU exhaustion loops.

Update Reviewer's orchestration in run_review_tool to instantiate a
local QuotaManager if global_backoff is disabled, and update the
retry loop to robustly downcast errors to AiError.

Implement comprehensive unit tests for QuotaManager using Tokio's
virtual clock, and add integration tests in reviewer.rs verifying
worker isolation (local backoff) and dynamic deadline extensions
(timeout exemption).

Also update the design documentation under designs/ to document the
new configurable backoff and AiError architecture.

Signed-off-by: Elkin Cruz <elkin@google.com>
@helq helq force-pushed the feat-per-review-quota branch from 1e32510 to 46df351 Compare May 7, 2026 23:35
This allows faster recovery after LLM API outages. If there is an
outage, the exponential backoff might be overly aggressive, making some
reviews stay stuck for much longer after the outage has happened.

Signed-off-by: Elkin Cruz <elkin@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant