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

Method owedPayableBelow

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

Source from the content-addressed store, hash-verified

5868 return owed;
5869 };
5870 const owedPayableBelow = (fileIndex: number, budgetLeft: number): number => {
5871 let held = 0;
5872 for (let j = fileIndex + 1; j < sortedFiles.length; j++) {
5873 const path = sortedFiles[j]![0];
5874 const reservedBelow = allocation.allowances.get(path);
5875 if (reservedBelow === undefined) continue;
5876 // Only what that file is guaranteed is owed to it (see `guaranteedOf`).
5877 const r = guaranteedOf(path, reservedBelow);
5878 const overhead = sectionOverhead(path, sortedFiles[j]![1].nodes);
5879 const need = r + overhead;
5880 if (held + need > budgetLeft) {
5881 // PART of a reservation is still a delivered file (CG-26). Holding
5882 // all-or-nothing zeroed the last admitted file whenever its full
5883 // reservation no longer fit: on the precise-query fixture the rank-5
5884 // file took 4,134 chars against a 2,948 reservation while rank 6 —
5885 // admitted, reserved 2,539 — was left 4 chars and skipped. Hold the
5886 // remainder instead, but only while it is still worth a section:
5887 // under MIN_CHARS a slice cannot hold one complete method, and a
5888 // fragment forces the Read this tool exists to prevent.
5889 const partial = budgetLeft - held;
5890 if (partial >= EXPLORE_ALLOCATION.MIN_CHARS + overhead) held += partial;
5891 break;
5892 }
5893 held += need;
5894 }
5895 return held;
5896 };
5897
5898 for (let fileIndex = 0; fileIndex < sortedFiles.length; fileIndex++) {
5899 // 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