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

Method indirectTestNote

src/mcp/tools.ts:4336–4371  ·  view source on GitHub ↗

* Test-coverage note for a blast-radius entry whose DIRECT callers include no * test file. A helper called only by production code can still be exercised * by tests further up the caller chain (#1475: 40% of directly-unflagged * symbols had a test within 2-3 hops), so walk up to 2 more hops

(cg: CodeGraph, directCallers: Node[], rel: (p: string) => string, isTest: (n: Node) => boolean)

Source from the content-addressed store, hash-verified

4334 * claiming anything — and even then claim only what was measured.
4335 */
4336 private indirectTestNote(cg: CodeGraph, directCallers: Node[], rel: (p: string) => string, isTest: (n: Node) => boolean): string {
4337 const MAX_HOPS = 3; // direct callers are hop 1
4338 const BUDGET = 64; // getCallers lookups per entry — bounds god-fan-in symbols
4339 const FILE_CAP = 2;
4340 let budget = BUDGET;
4341 const visited = new Set(directCallers.map((n) => n.id));
4342 let frontier = directCallers;
4343 for (let hop = 2; hop <= MAX_HOPS && frontier.length > 0 && budget > 0; hop++) {
4344 const next: Node[] = [];
4345 const found = new Set<string>();
4346 for (const node of frontier) {
4347 if (budget-- <= 0) break;
4348 let callers: Array<{ node: Node }> = [];
4349 try { callers = cg.getCallers(node.id) as Array<{ node: Node }>; } catch { continue; }
4350 for (const c of callers) {
4351 const n = c?.node;
4352 if (!n || visited.has(n.id)) continue;
4353 visited.add(n.id);
4354 if (isTest(n)) found.add(rel(n.filePath));
4355 else next.push(n);
4356 }
4357 }
4358 if (found.size > 0) {
4359 const files = [...found];
4360 const shown = files.slice(0, FILE_CAP).map((f) => `\`${f}\``).join(', ');
4361 const more = files.length > FILE_CAP ? ` +${files.length - FILE_CAP}` : '';
4362 return `; tested via callers: ${shown}${more}`;
4363 }
4364 frontier = next;
4365 }
4366 // Budget exhaustion means hops 2-3 weren't fully searched — fall back to
4367 // the weaker claim that IS established by the direct-caller check.
4368 return budget > 0
4369 ? `; no tests found within ${MAX_HOPS} caller hops`
4370 : '; no test calls this directly';
4371 }
4372
4373 /**
4374 * Graph-connectivity relevance via Random-Walk-with-Restart (personalized

Callers 2

exploreOneSymbolMethod · 0.95

Calls 7

relFunction · 0.85
mapMethod · 0.80
hasMethod · 0.80
pushMethod · 0.80
getCallersMethod · 0.45
addMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected