fix(engine): don't charge per-file-skipped files against repo-map's aggregate budget - #7270
Conversation
…ggregate budget Closes JSONbored#7247 buildRepoMap added each file's byte count to totalSourceBytes before the check that skips a file for exceeding the per-file maxSourceBytes cap. A single oversized file (a vendored/minified asset or generated bundle) that was itself skipped without being parsed still consumed its full byte count against maxTotalSourceBytes, exhausting the aggregate budget so every subsequent small, legitimate file was also marked skipped: resource_limit — a silent, order-dependent near-empty repo map. Move the aggregate accrual to after the per-file cap check so only files that actually pass the per-file cap (and are parsed) count against the aggregate. In-cap files accrue exactly as before.
|
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 #7270 +/- ##
=======================================
Coverage 93.81% 93.81%
=======================================
Files 704 704
Lines 69457 69459 +2
Branches 18899 18899
=======================================
+ Hits 65161 65163 +2
Misses 3302 3302
Partials 994 994
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-19 11:46:38 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.
|
Closes #7247.
Problem
buildRepoMapenforces two byte budgets: a per-file cap (maxSourceBytes) and an aggregate cap across all parsed files (maxTotalSourceBytes). It added each file's byte count tototalSourceBytesbefore the check that skips a file for exceeding the per-file cap:So a single oversized file (a vendored/minified asset or generated bundle that slips into the input list) that is itself skipped for exceeding
maxSourceBytesstill burned its full byte count againstmaxTotalSourceBytes— the aggregate budget meant to bound total parsed work. Every subsequent small, legitimate file then also trippedtotalSourceBytes > maxTotalSourceBytesand was markedskipped: "resource_limit", producing a near-empty, order-dependent repo map with no error surfaced to the driver that consumes it.Fix
Accrue to the aggregate after the per-file cap check, so only files that pass the per-file cap (and are actually parsed) count against the aggregate. Files under the per-file cap accrue and gate against the aggregate exactly as before — the only behavior change is that a per-file-oversized, unparsed file no longer poisons the aggregate for the files after it.
Tests
Added a regression test in
repo-map.test.ts(imports the engine via its source barrel, so the changed lines are instrumented): an oversized first file (28 bytes, over amaxSourceBytes: 20/maxTotalSourceBytes: 20config) is skipped, and the small legitimate file after it is still parsed (symbols extracted) rather than starved of aggregate budget. The existing per-file-cap and aggregate-cap tests continue to cover both skip branches.Verification
tsc --noEmit(root typecheck) — clean.npm run build --workspace @loopover/engine— clean.repo-map.test.ts— 35 tests green.repo-map.ts: 113/113 lines, 12/12 functions, 84/84 branches covered (v8/lcov).