fix(miner): scope recordRateLimit to the core-billed rate-limit resource - #10201
Conversation
GitHub bills the search endpoint and the per-repo contents/list requests against two independent primary rate-limit resources, and reports each response's resource in x-ratelimit-resource. Folding both into a single Math.min'd rateLimitRemaining recorded the search bucket's small per-minute allowance as the run's whole budget, pinning the core-budget-gated policy fan-out to serial concurrency. Skip a response billed against a resource other than core, while still recording one with no resource header at all.
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-31 12:30:51 UTC
Review summary Nits — 3 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10201 +/- ##
===========================================
- Coverage 92.21% 80.53% -11.69%
===========================================
Files 934 283 -651
Lines 114178 59025 -55153
Branches 27593 8767 -18826
===========================================
- Hits 105294 47535 -57759
- Misses 7582 11199 +3617
+ Partials 1302 291 -1011
Flags with carried forward coverage won't be shown. Click here to find out more.
|
What
recordRateLimitinpackages/loopover-miner/lib/opportunity-fanout.tsfolded every response'sx-ratelimit-remaininginto one number withMath.min, regardless of which GitHub rate-limitresource billed the request.
githubGetJsonserves both the search endpoint (billed against thesmall, per-minute
searchbucket) and the per-repo contents/list endpoints (billed against thelarge, per-hour
corebucket). Folding both meant a single/search/issuesresponse pinnedsummary.rateLimitRemainingto the search bucket's tiny remaining count, which sits underdiscovery-throttle.ts's default 50 low-water-mark — soresolveThrottledConcurrencyserializedevery subsequent policy-doc fetch in the run to one in-flight request, even though the core budget
those requests actually spend had thousands left.
Fix
recordRateLimitnow reads the response'sx-ratelimit-resourceheader and returns early (recordingneither
rateLimitRemainingnorrateLimitResetAt) when that header is present and notcore. Aresponse with no
x-ratelimit-resourceheader at all — an older forge/proxy, or any existing testfixture — is recorded exactly as before. The
#9678null/blank/non-numeric guard is preservedverbatim. No public shape changed:
CandidateIssueSummary.rateLimitRemainingnow simply reflects thecore budget.
Tests
Added to
test/unit/miner-opportunity-fanout.test.ts:x-ratelimit-remainingis folded into the summaryrateLimitResetAtis likewise scoped to core-billed responsesx-ratelimit-resourceheader still recordsx-ratelimit-remaining(backward compatible)REGRESSION: the search bucket's remaining budget does not pin the core fan-out to serial concurrency) that fails against the pre-fix code, asserting the observed maxin-flight
/contents/requests exceeds 1 underconcurrency: 5Ran
npx vitest run test/unit/miner-opportunity-fanout.test.ts test/unit/miner-opportunity-fanout-forge.test.ts test/unit/miner-opportunity-fanout-pagination.test.ts— all 56 tests pass, and coverage on the changed lines is 100% (branch-counted).Closes #10005