MCPcopy
hub / github.com/colbymchenry/codegraph / scoreSearchNodes

Function scoreSearchNodes

__tests__/evaluation/scoring.ts:5–40  ·  view source on GitHub ↗
(
  caseId: string,
  expectedSymbols: string[],
  results: Array<{ node: { name: string }; score: number }>,
  latencyMs: number
)

Source from the content-addressed store, hash-verified

3export const PASS_THRESHOLD = 0.5;
4
5export function scoreSearchNodes(
6 caseId: string,
7 expectedSymbols: string[],
8 results: Array<{ node: { name: string }; score: number }>,
9 latencyMs: number
10): EvalResult {
11 const expectedLower = expectedSymbols.map((s) => s.toLowerCase());
12 const resultNames = results.map((r) => r.node.name.toLowerCase());
13
14 const found: string[] = [];
15 const missed: string[] = [];
16 let firstRank = 0;
17
18 for (let i = 0; i < expectedLower.length; i++) {
19 const idx = resultNames.indexOf(expectedLower[i]);
20 if (idx !== -1) {
21 found.push(expectedSymbols[i]);
22 if (firstRank === 0) firstRank = idx + 1;
23 } else {
24 missed.push(expectedSymbols[i]);
25 }
26 }
27
28 const recall = expectedSymbols.length > 0 ? found.length / expectedSymbols.length : 0;
29 const mrr = firstRank > 0 ? 1 / firstRank : 0;
30
31 return {
32 caseId,
33 pass: recall >= PASS_THRESHOLD,
34 recall,
35 mrr,
36 foundSymbols: found,
37 missedSymbols: missed,
38 latencyMs,
39 };
40}
41
42export function scoreFindRelevantContext(
43 caseId: string,

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected