sub2api
sub2api copied to clipboard
fix: preserve Anthropic window cooldowns
Summary
- Detect official Anthropic 5h / 7d window exhaustion before user-configured 429 temporary-unschedulable rules run.
- Persist the official reset time as the account rate-limit cooldown instead of allowing a broad local keyword rule to shorten it to a small temporary pause.
- Add a unit regression test for the precedence behavior.
Why
Anthropic/Claude official 429 responses can include per-window reset headers for the 5h and 7d unified rate-limit windows. Those reset timestamps describe the real account-level cooldown.
If a local temp_unschedulable_rules keyword rule handles the same 429 first, Sub2API can retry the account too early while the official Anthropic window is still exhausted.
Fixes #3249
Validation
go test ./internal/service -run 'Anthropic|429' -count=1
go test -tags unit ./internal/service -run 'Anthropic|429' -count=1
go test ./internal/service -count=1
go test -tags unit ./internal/service -count=1
git diff --check upstream/main...HEAD