Skip to content

Add parseOk status to contribution evaluation parsing (#22)#31

Open
arkh-node wants to merge 1 commit into
cimcai:mainfrom
arkh-node:evaluation-parse-status-issue-22
Open

Add parseOk status to contribution evaluation parsing (#22)#31
arkh-node wants to merge 1 commit into
cimcai:mainfrom
arkh-node:evaluation-parse-status-issue-22

Conversation

@arkh-node

@arkh-node arkh-node commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Addresses the #22 question — "have we tested the text insertion of benchmarks / related parsing?"

Fetch side is solid (no change): fetchAndExtractText already guards well — SSRF check (assertPublicUrl), 10s timeout, redirect cap, content-type allowlist, 40k size cap.

The gap (evaluateContribution): the evaluator model's JSON was parsed in a try/catch, and on any parse failure the score silently defaulted to 1 and the summary became the raw model output — so a format failure was indistinguishable from a genuine score of 1. A string-typed score (e.g. "8") also silently fell to 1.

This PR:

  • Extracts the parsing into server/evaluationParse.ts (parseEvaluation + stripJsonFence) with a parseOk flag.
  • evaluateContribution now console.warns when the output isn't valid JSON with a numeric score — visible/retriable instead of buried as a 1.
  • Adds server/evaluationParse.test.ts (vitest, 10 cases): valid/fenced JSON, prose, string score, missing score, clamping, float rounding, empty, oversized, fence stripping.
  • Score/summary behaviour is unchanged; this only surfaces failures.

Possible follow-ups (separate): a retry / provider JSON-mode to enforce format, and persisting the parse status alongside the score.

Tested locally: vitest run → 44 passed | 11 skipped | 0 failed (the new suite is green).


Minor, flagging while here: npm test (vitest) picks up 8 test files, but a couple of node:test-style suites (metrics.test.ts, modelTier.test.ts) appear to fall outside vitest's include glob — so they may not run under npm test. Might be worth consolidating on one framework so a single command covers everything; happy to do that in a follow-up.

Addresses #22.

Extract the evaluator-output parsing from routes.ts into a testable module
(server/evaluationParse.ts) and add a parseOk flag, so a parse *failure* is
visible instead of being silently scored as 1.

- evaluateContribution now warns when the model output isn't valid JSON with a
  numeric score. Previously that case was indistinguishable from a genuine
  score of 1; a string-typed score (e.g. "8") also silently fell to 1.
- Adds server/evaluationParse.test.ts (vitest, 10 cases): valid/fenced JSON,
  prose, string score, missing score, clamping, float rounding, empty,
  oversized, fence stripping.

Score/summary behaviour is unchanged; this only surfaces parse failures.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants