Scoring & Reports
Scoring and reporting each have exactly one code entry: per-question scoring goes through scoring.ts, report assembly through report-builder.ts. First score and rescore share the same path, guaranteeing "the same score uses the same algorithm regardless of where it comes from".
Scoring pipeline
Judge panel: median, not mean
- Panel size
clamp(1, 3, config.services.judgePanel), default 1; each judge is an independent run attemperature: 0. - A judge that throws (budget, outage) does not sink the whole judgment: take the median of whoever actually answered;
panelScoredrecords the effective count. medianrounds to an integer score;spread = max − minexposes judge disagreement for the UI and review.- Rubric version pinned to
backend-p6 v1.4, prompt versionjudge.v1, written into every score's meta.
Score output structure
| Field | Meaning |
|---|---|
score | integer total (panel median) |
keyPoints[] | per scoring point: point / verdict (hit / partial / miss) / evidence / basis (point sources) |
dimensions[] | model-provided dimension scores (name + value), kept as-is |
codeReview | coding questions: testsPassed / testsTotal / hintsUsed / durationSec, from real sandbox runs |
meta | judgeEngine / promptVersion / rubricVersion / panel |
Evidence must come from the answer text or code-run results; basis anchors each point back to its KB source for citation verification.
Format repair and degradation: never fabricate a score
Real models occasionally answer in prose or omit fields. The order is repair once, then degrade conservatively — not replace with a neutral 50:
- Fatal defects → one repair rerun carrying
previousOutput(≤1500 chars) and the problem list; success emits ajudge.repairedevent. - Cosmetic defects only in dimensions → clear
dimensions, keep the rest of the judgment. - Repair still fails → all points treated as
partial, evidence stating "scoring output incomplete, treated as partial hits". - The run itself fails →
unavailable: { reason }(≤160 chars), all pointsmisswith evidence "scoring not executed",judgeEngine: 'none', plus ajudge_unavailableevent (retryable: false). - No answer → points
miss, evidence "(no answer)".
Report: a single assembly point
buildReport fills every derived field before persisting:
- Recomputable total:
meanScore = round(mean of per-question card scores)— a report score must be recomputable from its own cards. progress:planned/scored/skipped(filled bymarkIncompletewhen a run ends early).typeScores: three type buckets (theory / project / coding) derived from the detail rows.citationCoverageandcitationCounts(verified/partial/unsupported/claims) plus per-question citation detail.- Degradation marker: count
provider.fallbackevents; >0 addsdegraded: { steps, reason }to the report itself — a score produced by the local mock is not a model score, and the report says so. - A rescore keeps the previous
citationCoverage/citationCountsuntil citations are recomputed.
assembleAndSave assembles first, persists last: the copy that gets hashed and signed must be exactly what the user sees.
Hash and signature
text
hash = sha256(JSON.stringify(report))
signature = HMAC-SHA256(hash, signingKey)- Signing key:
dataDir/keys/report-signing.key, generated on first use asrandomBytes(32)with mode0600. - Verification compares expected vs submitted signature with
timingSafeEqual, guarding against timing side channels. - Each version writes a
report_versionsrow (idrv_<sessionId>_<version>) holding score / verdict / report / hash / signature / model / note. - The verify endpoint recomputes the hash from the stored report text and compares — change one character and verification fails.