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

Function formatAllocation

scripts/agent-eval/parse-run.mjs:692–716  ·  view source on GitHub ↗
(s, indent = '  ')

Source from the content-addressed store, hash-verified

690
691/** The allocation block, as printed under a run and reused by aggregators. */
692export function formatAllocation(s, indent = ' ') {
693 const a = s.allocation;
694 if (!a || !a.calls.length) return `${indent}Explore allocation: no codegraph_explore responses with source sections`;
695 const pct = (f) => `${(f * 100).toFixed(1)}%`;
696 const n = (x) => x.toLocaleString('en-US');
697 const out = [
698 `${indent}Explore allocation — share of returned bytes the answer used ` +
699 `(${a.calls.length} call${a.calls.length === 1 ? '' : 's'}, ${a.filesReturned} file${a.filesReturned === 1 ? '' : 's'}):`,
700 `${indent} efficiency ${pct(a.efficiency).padStart(6)} ${n(a.used)} of ${n(a.envelope)} chars` +
701 ` (${a.filesUsed}/${a.filesReturned} files cited; path-cited alone ${pct(a.efficiencyPath)})`,
702 ];
703 if (!a.hasAnswer) out.push(`${indent} !! no final answer text found — efficiency is not meaningful for this run`);
704 for (const c of a.calls) {
705 out.push(`${indent} call ${c.call}: ${pct(c.efficiency).padStart(6)} ${n(c.used)}/${n(c.envelope)} chars` +
706 ` ${c.files.filter((f) => f.via).length}/${c.files.length} files`);
707 }
708 for (const f of a.files.slice(0, 12)) {
709 const share = a.envelope ? f.chars / a.envelope : 0;
710 const why = f.via === 'symbol' ? `symbol \`${f.symbol}\`` : f.via === 'path' ? 'path' : '—';
711 out.push(`${indent} ${f.via ? '*' : ' '} ${pct(share).padStart(6)} ${String(f.chars).padStart(6)} ${f.path} ${why}`);
712 }
713 if (a.files.length > 12) out.push(`${indent} … ${a.files.length - 12} more files`);
714 out.push(`${indent} note: relative metric — attribution is by citation, so compare builds on the same question, not absolutes.`);
715 return out.join('\n');
716}
717
718// ---------------------------------------------------------------------------
719// Explore sufficiency (CG-8)

Callers 3

parse-session.mjsFile · 0.90
selftestFunction · 0.85
parse-run.mjsFile · 0.85

Calls 3

nFunction · 0.85
pctFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected