fix(engine): keep renderRepoMap's output within maxOutputChars including the marker (#9617) - #9633
Conversation
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-29 02:23:31 UTC
Review summary Nits — 4 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 #9633 +/- ##
==========================================
+ Coverage 90.12% 90.13% +0.01%
==========================================
Files 891 891
Lines 112306 112323 +17
Branches 26629 26639 +10
==========================================
+ Hits 101216 101246 +30
+ Misses 9760 9743 -17
- Partials 1330 1334 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…ing the marker renderRepoMap's pushLine budgets every content line against maxOutputChars, but the truncation marker was appended via lines.push unbudgeted — so a truncated result overshot by up to the marker's length plus a newline, and in the degenerate case returned a marker longer than the budget with no content. maxOutputChars is a token-budget guarantee the prompt builder relies on. Reserve the marker (plus its joining newline) from the budget: on truncation, drop trailing content lines until the marker fits, and when the budget can't hold even the marker alone, return the empty string rather than an over-budget marker. A complete (non-truncated) render is byte-for-byte unchanged.
Problem
Closes #9617.
renderRepoMap(packages/loopover-engine/src/miner/repo-map.ts) budgets content lines viapushLinebut appended the truncation marker unbudgeted (lines.push(...)), so a truncated result overshotmaxOutputCharsby up to the marker's length + a newline, and a first line over budget returned only an over-budget marker.maxOutputCharsis a token-budget guarantee the prompt packet relies on.Fix
Reserve the marker from the budget (extracted to a
TRUNCATION_MARKERconst):result.length <= maxOutputCharsalways.maxOutputChars< the marker length → return the empty string, never an over-budget marker.Tests
test/unit/repo-map.test.ts(root vitest): tightened the truncation test to the strict<= maxOutputCharsbound; added budget-spread + empty-string + marker-only cases; updated the four break-site tests to the new contract.packages/loopover-engine/test/repo-map.test.ts(engine node:test): mirrors the budget contract so theengineCodecov flag credits the changed lines, complete + truncated + empty-string + marker-only + keep-fitting-symbol cases.100% line + branch coverage on the changed source.