fix(runner): cap HuggingFace Retry-After backoff at 30s - #50
Conversation
Honor Retry-After integer seconds and HTTP-date values only up to the existing 30s quadratic fallback ceiling. A 429 with Retry-After: 3600 could block clawscan benchmark for an hour per attempt when the client context is Background. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed September 1, 2026, 6:58 AM ET / 10:58 UTC. ClawSweeper reviewWhat this changesThe PR limits numeric and HTTP-date Hugging Face Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 11 items remain Keep this PR open: current main does not already contain the cap, but the patch makes the client retry before a valid server-directed delay expires and still permits numeric-duration overflow. Priority: P1 Review scores
Verification
How this fits togetherClawScan’s benchmark runner fetches Hugging Face dataset rows before running benchmark cases. Transient HTTP responses feed a retry-delay calculation that controls when the next row request is sent. flowchart LR
A[Benchmark command] --> B[Hugging Face row request]
B --> C[Transient HTTP response]
C --> D[Retry delay calculation]
D --> E[Wait before retry]
E --> B
B --> F[Benchmark rows]
Decision needed
Why: The proposed cap changes established rate-limit behavior rather than repairing a purely local calculation, and the source does not establish that retrying early is acceptable to Hugging Face. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Define the benchmark retry policy explicitly, preserve valid server-directed delays unless maintainers intentionally accept a capped policy, and guard numeric conversion before constructing a duration. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: a retriable response flows through the changed helper into Is this the best way to solve the issue? No; the cap changes the server-directed retry contract and does not prevent overflow before duration conversion. A maintainer-approved delay policy is needed before selecting the narrow repair. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6432c40f2340. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (13 earlier review cycles; latest 8 shown)
|
What Problem This Solves
clawscan benchmark clawhub-security-signalsfetches HuggingFace dataset rows and retries on 429/5xx.huggingFaceRowsBackoffhonorsRetry-Afteras integer seconds or an HTTP-date with no ceiling, while the quadratic fallback is already capped at 30s.The public CLI builds
HuggingFaceBenchmarkClientwith a nil Context, sorequestContext()iscontext.Background()and the retryselectnever expires. A 429 withRetry-After: 3600blocks the process for one hour per attempt (up to five waits). This change capsRetry-Afterat the same 30s ceiling. It does not add a process-wide signal context.The uncapped header path was introduced in #3 (2026-06-25). #46 made the wait cancelable when a context is set; it did not cap the delay.
Evidence
Red (unfixed
huggingFaceRowsBackoff):Green (after the 30s cap):
Retry-After: 3600and an HTTP-date two hours ahead both return 30s. The quadratic fallback path is unchanged.Real behavior proof
Behavior or issue addressed: HuggingFace row-fetch
Retry-Afterdelays (integer seconds and HTTP-date) are capped at 30s, matching the existing fallback ceiling, so a 429 cannot stallclawscan benchmarkfor an hour per attempt.Real environment tested: macOS 26.6.2 (Darwin 25.6.0 arm64), go1.27.0 darwin/arm64, checkout
/tmp/oc-pr-clawscan-F003onfix/f003-huggingface-retry-after-cap.Exact steps or command run after this patch:
go test -count=1 -timeout 30s -v -run TestHuggingFaceRowsBackoffCapsRetryAfter ./internal/runner/Evidence after fix: terminal output from the patched tree:
Observed result after fix:
Retry-After: 3600is 30s (was 1h). An HTTP-date two hours ahead is also 30s. The helper no longer returns a multi-hour wait.What was not tested: A live HuggingFace 429 with a long
Retry-Afterheader. Network fetch ofdatasets-server.huggingface.coduring this change.Command:
go test -count=1 -timeout 30s -v -run TestHuggingFaceRowsBackoffCapsRetryAfter ./internal/runner/Observed: unfixed delay was
1h0m0sforRetry-After: 3600; patched delay is30sfor both3600and a future HTTP-date.Expected: both header forms cap at 30s.
Time: 11:07:34 PDT (2026-08-29 18:07:34 UTC)
Date: 2026-08-29
Environment: macOS 26.6.2, Darwin 25.6.0 arm64, go1.27.0 darwin/arm64