MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / runtimeCitationsFor

Function runtimeCitationsFor

graph-ui/src/core/trace-protocol.ts:39–65  ·  view source on GitHub ↗
(ir: SemanticIR, factPath: string)

Source from the content-addressed store, hash-verified

37 * `createUserGroup` is a different function.
38 */
39export function runtimeCitationsFor(ir: SemanticIR, factPath: string): Evidence[] {
40 const match = /^(steps|calls)\[(\d+)\]$/.exec(factPath);
41 const runtime = ir.runtime;
42 if (!match || runtime === undefined) {
43 return [];
44 }
45 const calls = match[1] === 'steps' ? ir.steps.value : ir.calls.value;
46 const call = calls[Number(match[2])];
47 if (call === undefined) {
48 return [];
49 }
50 // Only trust the row index when the two arrays line up, exactly as the
51 // evidence lookups do: a mislabelled citation is worse than no citation.
52 if (runtime.value.length !== runtime.evidence.length) {
53 return [];
54 }
55 const out: Evidence[] = [];
56 runtime.value.forEach((observed, index) => {
57 if (sameSymbol(observed.targetName, call.targetName)
58 || sameSymbol(observed.targetQualifiedName, call.targetQualifiedName)
59 || sameSymbol(observed.targetQualifiedName, call.targetName)
60 || sameSymbol(observed.targetName, call.targetQualifiedName)) {
61 out.push(runtime.evidence[index]);
62 }
63 });
64 return out;
65}
66
67/**
68 * Whether two written names denote the same symbol.

Callers 1

evidenceForFunction · 0.90

Calls 2

sameSymbolFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected