MCPcopy Create free account
hub / github.com/openai/plugins / computeSummary

Function computeSummary

plugins/plugin-eval/src/core/scoring.js:256–309  ·  view source on GitHub ↗
(result)

Source from the content-addressed store, hash-verified

254}
255
256export function computeSummary(result) {
257 const deductions = buildDeductions(result.checks);
258 const penalty = deductions.reduce((total, entry) => total + entry.penalty, 0);
259
260 const score = Math.max(0, Math.round(100 - penalty));
261 const grade =
262 score >= GRADE_THRESHOLDS.A
263 ? "A"
264 : score >= GRADE_THRESHOLDS.B
265 ? "B"
266 : score >= GRADE_THRESHOLDS.C
267 ? "C"
268 : score >= GRADE_THRESHOLDS.D
269 ? "D"
270 : "F";
271
272 const failedErrors = result.checks.filter(
273 (check) => check.status === "fail" && check.severity === "error",
274 ).length;
275 const warningSignals = result.checks.filter((check) => check.status === "warn").length;
276 const riskLevel = failedErrors > 0 || score < 70 ? "high" : warningSignals > 0 || score < 85 ? "medium" : "low";
277 const checkCounts = summarizeChecks(result.checks);
278 const riskReasons = buildRiskReasons({
279 score,
280 failedErrors,
281 warningSignals,
282 deductions,
283 checkSummary: checkCounts,
284 });
285
286 const topRecommendations = unique(
287 result.checks
288 .filter((check) => check.status === "fail" || check.status === "warn")
289 .flatMap((check) => check.remediation)
290 .slice(0, 5),
291 );
292
293 return enrichSummary(result, {
294 score,
295 grade,
296 riskLevel,
297 riskReasons,
298 scoreBreakdown: {
299 startingScore: 100,
300 totalDeductions: penalty,
301 finalScore: score,
302 gradeThresholds: GRADE_THRESHOLDS,
303 },
304 checkCounts,
305 deductions,
306 categoryDeductions: buildCategoryDeductions(deductions),
307 topRecommendations,
308 });
309}
310
311export function enrichSummary(result, summary) {
312 const deductions = Array.isArray(summary?.deductions) ? summary.deductions : buildDeductions(result.checks);

Callers 1

analyzePathFunction · 0.90

Calls 7

buildDeductionsFunction · 0.85
summarizeChecksFunction · 0.85
buildRiskReasonsFunction · 0.85
uniqueFunction · 0.85
enrichSummaryFunction · 0.85
buildCategoryDeductionsFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected