MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / owedPayableBelow

Method owedPayableBelow

src/mcp/tools.ts:5926–5952  ·  view source on GitHub ↗
(fileIndex: number, budgetLeft: number)

Source from the content-addressed store, hash-verified

5924 return owed;
5925 };
5926 const owedPayableBelow = (fileIndex: number, budgetLeft: number): number => {
5927 let held = 0;
5928 for (let j = fileIndex + 1; j < sortedFiles.length; j++) {
5929 const path = sortedFiles[j]![0];
5930 const reservedBelow = allocation.allowances.get(path);
5931 if (reservedBelow === undefined) continue;
5932 // Only what that file is guaranteed is owed to it (see `guaranteedOf`).
5933 const r = guaranteedOf(path, reservedBelow);
5934 const overhead = sectionOverhead(path, sortedFiles[j]![1].nodes);
5935 const need = r + overhead;
5936 if (held + need > budgetLeft) {
5937 // PART of a reservation is still a delivered file (CG-26). Holding
5938 // all-or-nothing zeroed the last admitted file whenever its full
5939 // reservation no longer fit: on the precise-query fixture the rank-5
5940 // file took 4,134 chars against a 2,948 reservation while rank 6 —
5941 // admitted, reserved 2,539 — was left 4 chars and skipped. Hold the
5942 // remainder instead, but only while it is still worth a section:
5943 // under MIN_CHARS a slice cannot hold one complete method, and a
5944 // fragment forces the Read this tool exists to prevent.
5945 const partial = budgetLeft - held;
5946 if (partial >= EXPLORE_ALLOCATION.MIN_CHARS + overhead) held += partial;
5947 break;
5948 }
5949 held += need;
5950 }
5951 return held;
5952 };
5953
5954 for (let fileIndex = 0; fileIndex < sortedFiles.length; fileIndex++) {
5955 // Settle the soft share of the file the loop just left: what it spent past

Callers

nothing calls this directly

Calls 1

getMethod · 0.65

Tested by

no test coverage detected