@reinsjs/eval
The eval harness reins uses to decide its own defaults with numbers instead of taste. Real sessions become fixtures; recorded tools replay deterministically so every arm faces the same world; arms (a baseline, a threshold-only fallback, or a full brain configuration) run side by side on real models; metrics come straight from the timelines; a gate says pass or fail.
pnpm add -D @reinsjs/eval
import { compact, perception } from "@reinsjs/brain"
import { checkGate, noneArm, renderReport, runEval, thresholdArm, withContextWindow } from "@reinsjs/eval"
import { anthropic } from "@reinsjs/lowering-pi"
const bound = anthropic("claude-sonnet-5", { apiKey: process.env.ANTHROPIC_API_KEY ?? "" })
const report = await runEval({
fixtures, // EvalFixture[]: seed log + task + graders (+ `maxResumes`, default 0: a budget pause counts as "did not finish"); see `recording.ts` for turning a real JSONL into one
arms: [noneArm(), thresholdArm(), { name: "compact", sockets: [compact(), perception()] }],
lowering: withContextWindow(bound.lowering, 32_000), // shrink what the mechanisms *believe* the window is
model: bound.model,
repeats: 3,
})
console.log(renderReport(report))
const gate = checkGate(report, { candidate: "compact", reference: "threshold" })
The reference CLI is examples/eval/run.ts in the repository; copy from it rather than from memory.
Pieces
| module |
what |
jsonl |
read/write event JSONL; reading goes through the schema registry (unknown or unupgradable events fail loudly) |
recording |
turn a real recording into fixture material: re-attach spilled blobs, redact deterministically |
recorded-tools |
tools that answer from the recording so arms compare like with like |
metrics |
pure functions over a timeline: tokens and cache hits, turns / tool calls / duplicate calls, compaction count and streaks, governance decay windows |
arms |
noneArm, thresholdArm, withCapabilities / withContextWindow lowering wrappers; brain-driven arms are assembled by the caller from @reinsjs/brain |
runner |
fixture × arm × repeat runner with approval auto-answering, budget resumes, handoff following and a forked probe question at the end |
gate |
the four hard rules from the PRD (§7 threshold 2 / P8), candidate against reference: total tokens (≤ reference × ratio), completion (≥), recall (≥), governance (the candidate's own violation rate does not rise after compaction) |
report |
Markdown tables |
Zero node:*: file I/O and the CLI live in the caller (examples/eval in the repository is the reference CLI and holds the fixtures reins itself is measured on).
Read the numbers correctly
withContextWindow changes only what the mechanisms are told; the real window is untouched. It measures how the mechanism behaves in a narrow window, not what overflow does.
- The probe question keeps brain tools (an arm with
compact can recall, one with spill can fetch_blob) and drops host tools — so the recall cell is intentionally not the same exam for a baseline arm.
- The governance rule compares the candidate against itself before and after its first compaction, and only over the runs that still had model actions after it (
ArmSummary.violations.compactedRuns); runs that never compacted would otherwise dilute the after-rate towards zero. Both the per-run mean and the rate pooled over actions (pooledBefore / pooledAfter) must not rise, since either alone can be skewed by how actions are spread over runs. Two of the four gate rules can pass on "no information" — recall without planted facts, governance without such runs — and both say so in a note.
checkGate throws unless the reference and candidate arms cover exactly the same fixture × repeat cells, each once, and each arm's summary.runs matches its cells in outcomes (keep outcomes when you build a report by hand; strip timelines, not cells). Every rule compares per-run means, so a cell missing from one arm (a crashed process when arms run separately) would compare the arms on different exams.
- Behavioural defects only show on real models. Scripted lowerings prove mechanics, not that a model will use them.
Documentation
docs/archive/implementation-plans/2026-09-08-技术方案v1.0.md §13, docs/系统全景图_模块盘点/eval.md, the E1–E4 reports under docs/archive/ — in Chinese.
MIT © 2026 NewRate Limited.