feat(evaluation-system): add claude -p eval engine and response cache - #35
Merged
Merged
Conversation
…ponse cache Foundational layer of the prompt-eval suite (D1). Adds src/eval/ with a single-shot Claude Code CLI (`claude -p`) substrate — never the Anthropic SDK: - types.ts: EvalRequest/EvalResult/Envelope + injectable Spawn and Cache seams. - engine.ts: buildArgs (pure print-mode argv: --print --output-format json --json-schema --model --strict-mcp-config --settings + conditional system-prompt/tool-policy flags; prompt on stdin), parseEnvelope (graded, never throws — prefers structured_output, falls back to result, shallow schema check), runClaude (cache-first, spawn, cache-on-success), isAvailable and a skip signal distinct from graded failure for an absent CLI. - cache.ts: content-addressed ResponseCache keyed on a canonical SHA-256 over every output-affecting field. - tests/helpers/fake-claude.ts + tests/eval/*: hermetic engine/cache coverage via the injected Spawn stub, no real claude. Not a plugin deployable — no build.ts entry, no version bump.
This was referenced Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce the foundational eval-engine layer that runs a single-shot model
invocation through the Claude Code CLI in print mode (
claude -p) rather thanthe Anthropic SDK, so the harness's real output schemas are exercised end to
end. The engine forces schemas with
--json-schema, reads cost/latency/usagefrom the
--output-format jsonenvelope, content-addresses responses in afile-backed cache, and stays fully hermetic under
bun testby faking thesubprocess boundary. This is the substrate every later deliverable builds on.
Summary
New
src/eval/module:engine.ts(buildArgs/parseEnvelope/runClaude/isAvailable),types.ts(EvalRequest/EvalResult/Envelope/Spawn), andcache.ts(sha256 content-addressed response cache). Envelope parsing prefersstructured_output, falls back toJSON.parse(result), grades error/mismatch/unparseable cases as
ok:falsewithout throwing, and surfaces an absent CLI asa distinct skip signal. All tests inject a fake
Spawn— no realclaude, nonew runtime dependency.
Acceptance criteria
runClaudeinvokes onlyclaude; argv includes--print --output-format json --json-schema … --model … --strict-mcp-config --settings …plus system-prompt flags when provided.structured_outputyieldsEvalResult{ok:true,…}; missingstructured_outputfalls back toJSON.parse(result).is_error, non-successsubtype, unparseable stdout, and schema-nonconforming output each yieldok:falsewith a descriptive error and no throw.claudeCLI →isAvailable()false andrunClaudereturns askippedresult; nothing throws.bun run typecheck && bun run lint && bun testgreen; no new runtime dependency.Stack
All deliverables target the
strappedrepo (linear stack, each PR based on its parent's branch).strapped/evaluation-system/D1-eval-enginestrapped/evaluation-system/D2-eval-frameworkstrapped/evaluation-system/D3-harness-eval-suitestrapped/evaluation-system/D4-verified-optimizations