MCPcopy Index your code
hub / github.com/PatrickSys/codebase-context / formatEvalReport

Function formatEvalReport

src/eval/harness.ts:166–226  ·  view source on GitHub ↗
({
  codebaseLabel,
  fixturePath,
  summary,
  redactPaths = true
}: FormatEvalReportParams)

Source from the content-addressed store, hash-verified

164}
165
166export function formatEvalReport({
167 codebaseLabel,
168 fixturePath,
169 summary,
170 redactPaths = true
171}: FormatEvalReportParams): string {
172 const lines: string[] = [];
173 const wins = summary.results.filter((result) => result.top1Correct);
174 const failures = summary.results.filter((result) => !result.top1Correct);
175
176 lines.push(`\n=== Eval Report: ${codebaseLabel} ===`);
177 lines.push(`Fixture: ${fixturePath}`);
178 lines.push(
179 `Top-1 Accuracy: ${summary.top1Correct}/${summary.total} (${(summary.top1Accuracy * 100).toFixed(0)}%)`
180 );
181 lines.push(
182 `Top-3 Recall: ${summary.top3RecallCount}/${summary.total} (${(summary.top3Recall * 100).toFixed(0)}%)`
183 );
184 lines.push(
185 `Spec Contamination: ${summary.specContaminatedCount}/${summary.total} (${(summary.specContaminationRate * 100).toFixed(0)}%)`
186 );
187 lines.push(
188 `Gate (${summary.gateThreshold}/${summary.total}): ${summary.passesGate ? 'PASS' : 'FAIL'}`
189 );
190 lines.push(`Wins: ${wins.length} | Failures: ${failures.length}`);
191
192 lines.push('\nWins:');
193 if (wins.length === 0) {
194 lines.push(' (none)');
195 } else {
196 for (const result of wins) {
197 lines.push(
198 ` PASS #${result.queryId} [${result.category}] "${result.query}" -> ${formatPath(result.topFile, redactPaths)} (${result.score.toFixed(3)})`
199 );
200 }
201 }
202
203 lines.push('\nFailures:');
204 if (failures.length === 0) {
205 lines.push(' (none)');
206 } else {
207 for (const result of failures) {
208 lines.push(
209 ` FAIL #${result.queryId} [${result.category}] "${result.query}" -> ${formatPath(result.topFile, redactPaths)} (${result.score.toFixed(3)})`
210 );
211 lines.push(` expected: ${result.expectedPatterns.join(' | ') || '(none)'}`);
212 lines.push(` expected-not: ${result.expectedNotPatterns.join(' | ') || '(none)'}`);
213 lines.push(' top-3 actual:');
214 if (result.top3Files.length === 0) {
215 lines.push(' 1. none');
216 } else {
217 for (let index = 0; index < result.top3Files.length; index++) {
218 lines.push(` ${index + 1}. ${formatPath(result.top3Files[index], redactPaths)}`);
219 }
220 }
221 }
222 }
223

Callers 2

runSingleEvaluationFunction · 0.85

Calls 1

formatPathFunction · 0.85

Tested by

no test coverage detected