Skip to content

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 at temperature: 0.
  • A judge that throws (budget, outage) does not sink the whole judgment: take the median of whoever actually answered; panelScored records the effective count.
  • median rounds to an integer score; spread = max − min exposes judge disagreement for the UI and review.
  • Rubric version pinned to backend-p6 v1.4, prompt version judge.v1, written into every score's meta.

Score output structure ​

FieldMeaning
scoreinteger 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
codeReviewcoding questions: testsPassed / testsTotal / hintsUsed / durationSec, from real sandbox runs
metajudgeEngine / 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:

  1. Fatal defects → one repair rerun carrying previousOutput (≤1500 chars) and the problem list; success emits a judge.repaired event.
  2. Cosmetic defects only in dimensions → clear dimensions, keep the rest of the judgment.
  3. Repair still fails → all points treated as partial, evidence stating "scoring output incomplete, treated as partial hits".
  4. The run itself fails → unavailable: { reason } (≤160 chars), all points miss with evidence "scoring not executed", judgeEngine: 'none', plus a judge_unavailable event (retryable: false).
  5. 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 by markIncomplete when a run ends early).
  • typeScores: three type buckets (theory / project / coding) derived from the detail rows.
  • citationCoverage and citationCounts (verified / partial / unsupported / claims) plus per-question citation detail.
  • Degradation marker: count provider.fallback events; >0 adds degraded: { 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 / citationCounts until 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 as randomBytes(32) with mode 0600.
  • Verification compares expected vs submitted signature with timingSafeEqual, guarding against timing side channels.
  • Each version writes a report_versions row (id rv_<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.

Local-first · inference egresses on demand · fully traceable