Skip to content

Add --runs repetition and pass^k reporting to the eval runner - #2247

Merged
malibio merged 2 commits into
mainfrom
issue-2241-eval-runs
Aug 22, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-2241-eval-runs

Conversation

@malibio

@malibio malibio commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Closes #2241.

The problem

Every score this project has quoted from the agent matrix was a single draw from a distribution the repo itself documents as wide — 6/12, 9/12, 8/12 across three consecutive runs with identical guidance and no code changes.

Two consequences, and the second is worse:

  • It cannot detect the improvements we ship. A change worth +1 or +2 scenarios sits entirely inside the noise band, so a long run of "prompt tuning measured null" is confounded with a measurement floor we never established.
  • It produces confident wrong conclusions. A structural claim about one model's failures being a strict subset of another's survived exactly one rep.

What this adds

  1. --runs N — repeats the whole fixture, recording every rep in one results file.
  2. pass^k as the headline, pass^1 alongside. A scenario counts only if it passed in every rep. Reliability, not best-case capability, is the property that matters for a model that writes to a user's graph — two models with the same pass^1 and different flip rates are not equally good. The exit code follows pass^k.
  3. Per-scenario flip rate. fails 3/3 and fails 1/3 are different findings that a single run renders identically, and only the second is debuggable.
  4. Per-rep provenance. Model, context window, commit, and guidance versions are recorded per rep, so a rep that hit a degraded environment is identifiable after the fact rather than attributed to rep 1's conditions. Trace lines carry their rep for the same reason.
   pass^3:   6/12  (passed in every rep)
   pass^1:   7.67/12  (mean of per-rep scores)
   Flipped:  3/12  (passed in some reps, failed in others)
   Per rep:  8/12  7/12  8/12
────────────────────────────────────────────────────────
  ✓ 1  3/3 reps
  ✗ 2  0/3 reps
  ~ 4  2/3 reps  ← FLIPPED

Design note: the runner asserts, it does not own the daemon

The issue proposed that --runs own the purge + daemon restart between reps. It does not, deliberately — the caller owns the daemon, socket, and database everywhere else in this harness, and a runner that started killing processes it did not start would own a lifecycle it cannot see (a daemon under a launch agent, a remote socket, a model that takes a minute to load).

Instead --between-runs <cmd> takes the operator's purge/restart command, and the runner asserts what it was supposed to achieve:

  • Preflight re-runs before every rep — a hook that brought the daemon back on a different model or a smaller context window fails before that rep is scored.
  • Guidance is read back and compared against rep 1. Any drift in a seeded node's content hash aborts — reps that measured different guidance cannot be pooled into one pass^k number without describing a system that never existed.
  • A non-zero exit from the hook aborts rather than scoring a rep against an environment the hook failed to reset.
  • The uniformity guard runs per rep, not pooled. A single impossible rep is as much a harness signature as a single impossible run, and averaging it in is how it would stop being visible.

Each of these writes no results file, consistent with the rest of the gate. Without a hook, the runner says explicitly that reps share one daemon and database.

Other behavior

  • Baseline diffing is on pass^k and names the rate on both sides (passed all 3 baseline rep(s), now 2/3). Pre---runs baselines still join, read as a single rep; two single-draw sides are called out as within the known spread.
  • Results files are rep-shaped even at --runs 1, so readers need one code path — the single-rep shape being the one that produced the wrong conclusions.
  • Empty-generation exclusions leave a scenario's denominator rather than counting as failures, so a stray inference bug cannot make a reliable scenario read as flipping. A scenario excluded in every rep drops out of the scored count instead of being invented as a result.

Testing

25 new unit tests covering aggregation (pass^k, pass^1, flip detection, exclusion handling, fixture ordering), guidance-drift detection (including reorder-insensitivity), the reliability table's rendering, and baseline reading in both formats.

Verified end to end against stub binaries (no model required): a 3-rep run producing pass^3: 1/3 · pass^1: 1.67/3 · Flipped: 1/3 with a scenario passing all reps, one failing all, one flipping, and one excluded throughout; the guidance-drift abort; the uniformity guard firing on rep 1 and skipping the remaining reps; legacy-format baseline joining; and the single-rep path.

bun run test:all passes: frontend 4794/4794, scripts 153/153, browser 24/24, Rust green.

Docs updated in nodespace-docs (ea3487f): new "Repetition and pass^k" section, plus the rep-shaped results file, the trace's rep field, pass^k baseline comparison, and the exit-code description.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QZaSrSHQHAaaCcRvXtknGH

…2241)

Every score this project has quoted from the agent matrix was a single draw
from a distribution the repo documents as wide — 6/12, 9/12, 8/12 across three
consecutive runs with identical guidance and no code changes. That has two
consequences: a change worth +1 or +2 scenarios sits entirely inside the noise
band, so the instrument cannot see the improvements we ship; and single runs
produce confidently wrong structural claims that survive exactly one rep.

- `--runs N` repeats the whole fixture, recording every rep in one results file.
- pass^k is the headline (a scenario counts only if it passed in EVERY rep),
  with pass^1 alongside it, since reliability rather than best-case capability
  is what matters for a model that writes to a user's graph.
- Per-scenario flip rate in the summary: "fails 3/3" and "fails 1/3" are
  different findings that a single run renders identically, and only the second
  is debuggable.
- Provenance is recorded per rep, so a rep that hit a degraded environment is
  identifiable after the fact rather than attributed to rep 1's conditions.
  Trace lines carry their rep for the same reason.

The runner asserts reps are comparable rather than owning the daemon: the
caller owns the lifecycle everywhere else in this harness, so `--between-runs`
takes the operator's purge/restart command, and the runner then re-runs
preflight before each rep, aborts on any seeded-guidance drift, aborts if the
hook exits non-zero, and keeps the uniformity guard per-rep rather than pooled.
Each of these writes no results file, as the rest of the gate does.

Baseline diffing now compares pass^k and names the rate on both sides;
pre-`--runs` baselines still join, read as a single rep. Results files are
rep-shaped even at `--runs 1` so readers need one code path — the single-rep
shape being the one that produced the wrong conclusions.

Empty-generation exclusions leave a scenario's denominator rather than counting
as failures, so a stray inference bug cannot make a reliable scenario read as a
flipping one; a scenario excluded in every rep drops out of the scored count
instead of being invented as a result.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QZaSrSHQHAaaCcRvXtknGH
@malibio

malibio commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #2247

Review Type: Initial Review

Summary

This is a well-executed change to measurement code, and it is a clear net improvement. The core insight — that every number this project has quoted is a single draw from a distribution documented as 6/12–9/12 — is correct, and the fix addresses it at the right layer. The restructure that extracts the scenario loop into runRep is the right seam: it makes a rep a callable unit rather than duplicating the loop, so --runs repeats the identical code path.

I verified the aggregation math empirically rather than by reading it, exercising the edge cases the unit tests do not cover (fully-excluded scenarios, uneven reps, passAt1 vs scoredScenarios denominators, malformed baselines). I could not find a correctness bug in the aggregation. For measurement code whose entire purpose is to not produce wrong numbers, that is the finding that matters most.

I also diffed the restructure against git show origin/main:scripts/eval/runner.ts guard by guard. Every safety property survives, and three are strictly stronger.


Requirements Check

# Requirement Status
1 --runs N, same environment, every rep in one results file ✅
2 pass^k headline, pass^1 alongside ✅
3 Per-scenario flip rate in the summary ✅
4 Provenance per rep, not just per file ✅
5 Purge + daemon restart between reps ✅ (deviation — analysis below)
6 Composes with exclusion accounting ✅

📝 On (2): passAt1 is the mean of per-rep scored pass counts, not a per-scenario rate. This is the right choice and is the one that stays directly comparable to the historical single-run numbers — but note it is measured against a scenario-count denominator (scoredScenarios). Those denominators can legitimately differ when a scenario is excluded in some reps but not others: I confirmed a case rendering as pass^1: 2.50/3. That is arithmetically defensible (mean of 3 and 2) and the label "mean of per-rep scores" is honest, but it is the one number in the output a reader could misread as a rate. Not a defect — see 🟢 below.

📝 On (5) — the deliberate deviation, and I think it is correct. The issue asked --runs to own purge + restart. This PR instead takes --between-runs <cmd> and asserts the reps stayed comparable. I pushed on this because "we chose not to do the requirement" deserves scrutiny, and the justification holds on the evidence:

  • The architectural claim is verifiable: scripts/eval/env.ts states the contract in its header — "The daemon, socket, and database are managed by the CALLER — this harness never starts or seeds anything." Having --runs alone start killing processes would make the runner the single component in the harness that owns a lifecycle it cannot see (launch-agent daemon, remote socket, a model with a long load time).
  • More importantly, the assertions cover what the purge was for. The purge exists so a rep does not silently measure stale guidance. The runner now (a) re-runs the full preflight gate per rep — catching a daemon that came back on a different model or a smaller granted n_ctx, (b) fingerprints seeded-guidance content hashes and aborts on any drift, (c) aborts on a non-zero hook exit, (d) keeps the uniformity guard per-rep rather than pooled. That is a stronger guarantee than owning the restart: owning it would prove the command ran, whereas this proves the outcome the command was supposed to produce. Assert-don't-own is the better engineering choice, and it detects an operator's broken purge script, which automation would not.
  • The residual gap is honestly disclosed rather than hidden: without --between-runs, reps share a database, and the runner prints an explicit note saying so (runner.ts:872-876). Guidance drift is caught; accumulated node/schema state from rep 1 leaking into rep 2 is not. That is a real limitation, correctly documented in both the runner output and agent-eval.md.

I would accept this deviation and consider the issue's item 5 satisfied in intent.


Verification Performed

Aggregation math — probed beyond the committed tests:

  • Scenario excluded in all reps → correctly leaves scoredScenarios entirely (1, not 2); counted as neither pass nor fail. ✅
  • Excluded in some reps → leaves that rep's denominator only; a scenario passing 2/2 scored reps with 1 excluded stays passedAll: true and does not read as flipped. This is the subtle one and it is right. ✅
  • flipped requires passedReps > 0 && passedReps < scoredReps — so 0/3 is a hard fail, not a flip. Correctly distinguishes the two findings the issue is about. ✅
  • Uneven reps (scenario present in only one rep) → per-scenario denominators track independently; no cross-contamination. ✅
  • aggregateReps([]) → zeroes rather than NaN. The passAt1 guard on perRepPassed.length > 0 is load-bearing and tested. ✅
  • readBaselineReliability on null, arrays, bare numbers, and {reps:[{rep:1}]} with missing results → returns null or degrades safely via r.results ?? []; never throws. This matters because a bad --baseline path must not discard an hour of inference. ✅

Safety-property preservation (diffed against origin/main):

Guard Status
Uniformity guard ✅ Preserved, strengthened — now per-rep, so one impossible rep cannot be averaged into invisibility
Empty-generation exclusion ✅ Preserved verbatim, extended coherently across reps
Consecutive-send-failure abort ✅ Preserved; counter correctly scoped inside runRep, so it resets per rep (right call — a fresh daemon is a fresh budget)
Preflight gate before any scenario ✅ Preserved, strengthened — re-runs per rep
"No results file on environment failure" ✅ Preserved — the try wraps the whole rep loop; all four abort paths write nothing
Prior-context turns counted against the budget ✅ Preserved
Baseline join on id, not prompt text ✅ Preserved

Tests: bun run test:scripts → 153 pass / 0 fail. The 25 new tests are well-targeted; formatReliabilityTable asserting exact strings (" ~ flaky 2/3 reps ← FLIPPED") is the right call, since the rendering is the deliverable for requirement 3.


Findings

🟢 Suggestions

📁 scripts/eval/runner.ts:404-414 — passAt1 and passAtK are printed over the same scoredScenarios denominator, but they are computed over different populations: passAtK counts scenarios measured at least once, while passAt1 averages per-rep counts that can each have a different scored population. In a run with partial exclusions this renders as e.g. pass^1: 2.50/3 alongside pass^3: 3/3 — arithmetically correct and honestly labelled, but a reader could take the fraction as a rate. Since the whole point of this PR is that people cite these numbers, consider suffixing the pass^1 line with the per-rep denominators when they are not uniform (the Per rep: line already carries them, so the information is present — just not adjacent). Principle: least-astonishment in a reporting surface; a metric whose denominator shifts silently is the class of thing this PR exists to eliminate.

📁 scripts/eval/runner.ts:180-200 (aggregateReps) — the pure aggregation functions are unit-tested well, but no test covers uneven reps (a scenario appearing in rep 1 and absent from rep 2). I verified the behavior is correct, and the docstring explicitly anticipates the case ("a rep that aborted early simply contributes fewer scenarios"). Since the code claims that property, a test would pin it. Low priority — an early-aborted rep currently voids the run anyway, so the path is defensive rather than reachable. Principle: test the invariants the code documents, so a future refactor cannot silently break a claimed guarantee.

📁 scripts/eval/runner.ts:612-627 (takeFlag) — a missing flag value silently consumes the next flag as its argument (--runs --baseline b.json yields runs="--baseline", which then fails the integer check with a clear message, so the outcome is safe). The order of extraction is also load-bearing in a non-obvious way: --between-runs is taken before --runs, which is what makes a hook command containing the literal token --runs parse correctly. I confirmed both behaviors. Worth a one-line comment noting the extraction order is deliberate, since a future reader reordering those three lines for tidiness would introduce a real bug. Principle: make load-bearing ordering explicit; implicit coupling that looks like arbitrary line order invites breakage.

Non-findings (checked and cleared)

  • No any, no lint suppressions, no @ts-ignore in the diff. The one unavoidable unsafe boundary — parsing an untrusted baseline JSON — is handled with unknown plus explicit narrowing, which is exactly right.
  • console.log usage is correct here. The project's createLogger rule targets production app code; this is CLI tooling whose stdout is the product. Consistent with the pre-existing file.
  • No backward-compatibility code. I checked this specifically given the repo's greenfield rule. readBaselineReliability's pre---runs branch reads an old-format results file from disk — that is data compatibility with artifacts already written to /tmp and committed as baselines, not maintaining two code paths of a live API. Legitimate, and correctly scoped to a single narrowing branch.
  • No stale results-shape consumers. I grepped scripts/ for readers of the old summary/results top-level shape; the only report.summary hit is review-manager.ts, an unrelated structure.
  • Formatting/lint: scripts/ is outside the quality:fix scope (which targets packages/), so there is no gate to violate. An ad-hoc Prettier run flags the file, but it flags the origin/main version identically — pre-existing, not introduced.

Documentation

📁 ../nodespace-docs/development/agent-eval.md (commit ea3487f) — verified against the implementation. The documented results-file shape, the rep field on trace lines, the pass^k exit-code semantics, the four assertions, and the baseline-comparison behavior all match the code. The worked example output block matches formatReliabilityTable's real rendering. No GitHub issue-number references — the doc describes the 6/12, 9/12, 8/12 spread and the "strict subset" false conclusion directly rather than citing issue numbers, which is exactly the project standard. ✅


Recommendation

APPROVE

This is a net improvement by a wide margin, and it is the rare case where the measurement code got the same rigor usually reserved for production code. The aggregation math is correct under adversarial probing, every pre-existing safety guard survived a substantial restructure with three of them strengthened, and the one deliberate deviation from the issue is better-reasoned than the requirement it replaces. The three suggestions above are polish and none should block merge.

One thing worth calling out as genuinely good practice: making the results file rep-shaped even at --runs 1. Special-casing the single-rep shape would have left every downstream reader with two code paths, and the single-rep shape is precisely the one that produced the wrong conclusions. Paying that cost up front in a greenfield repo is the right trade.

🤖 Automated pragmatic-code-review

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

Two of the three review suggestions; the third is skipped with reasoning below.

pass^1 and pass^k are computed over different populations — pass^k counts
scenarios scored in at least one rep, pass^1 averages what each rep actually
scored. Printing both over pass^k's denominator rendered e.g. "2.33/4" beside
"pass^3: 2/4" whenever exclusions were uneven across reps: both correct, but
inviting the pair to be read as one rate over one population. pass^1 now states
its own denominator (2.33/3.67), staying an integer when exclusions are even.

Adds a test for scenarios present in only some reps — a rep that aborts partway
contributes fewer scenarios, and each scenario must be judged against the reps
that actually reached it rather than the run's rep count, or everything after
the abort point reads as unreliable because of where the run stopped.

Skipped: adding a comment marking takeFlag's extraction order as load-bearing.
The stated rationale does not hold — indexOf finds the first occurrence, which
is the real flag, so a hook command *containing* "--runs" parses correctly in
either order (verified). Order only matters when a hook's value is the bare
string "--runs", which is contrived; a comment asserting a hazard that is not
the one described would mislead a future reader more than silence does.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QZaSrSHQHAaaCcRvXtknGH
@malibio

malibio commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed — 2 of 3 suggestions implemented, 1 skipped

All three findings were 🟢 suggestions with no blockers. Commit e63d9722.

✅ Addressed

1. pass^1 / pass^k denominators (runner.ts:1002-1013)

The two numbers are computed over different populations — pass^k counts scenarios scored in at least one rep; pass^1 averages what each rep actually scored. Printing both over pass^k's denominator rendered 2.33/4 beside pass^3: 2/4 whenever exclusions were uneven across reps: both correct, but inviting the pair to be read as one rate over one population.

pass^1 now carries its own denominator, and stays an integer when exclusions are even:

   pass^3:   2/4  (passed in every rep)
   pass^1:   2.33/3.67  (mean of per-rep scores)     ← uneven exclusions
   pass^1:   3.00/4  (mean of per-rep scores)        ← even exclusions

Verified live against stub binaries in both cases.

2. Uneven-rep behavior untested (runner.test.ts:316-334)

Added a test for scenarios present in only some reps. A rep that aborts partway contributes fewer scenarios, and each scenario must be judged against the reps that actually reached it rather than against the run's rep count — otherwise every scenario after the abort point reads as unreliable because of where the run stopped rather than how the model behaved.

⏭️ Skipped

3. Comment marking takeFlag's extraction order as load-bearing

The stated rationale does not hold, so I verified it before writing anything. indexOf finds the first occurrence, which is the real flag — so a hook command containing --runs (the case the finding describes) parses correctly in either order:

current order  → runs: "2"  hook: "--runs 9"
reversed order → runs: "2"  hook: "--runs 9"

Order only diverges when a hook's value is the bare string --runs — contrived, and not the hazard described. A comment asserting a hazard that isn't the real one would mislead a future reader more than silence does. Worth revisiting if the flag surface ever grows a genuinely ambiguous pair.

Verification

  • bun run test:scripts → 154 pass / 0 fail
  • bun run quality:fix → clean, no stray reformats
  • Docs updated in nodespace-docs (f9b3a4c) to state that the two headline numbers carry separate denominators

@malibio
malibio merged commit 00b6f17 into main Aug 22, 2026
@malibio
malibio deleted the issue-2241-eval-runs branch August 22, 2026 21:20
malibio added a commit that referenced this pull request Aug 22, 2026
Three sibling PRs landed on main touching the same files. They compose
rather than conflict, but the seams needed real resolution:

#2247 (--runs / pass^k) restructured the runner around reps: the flat
`summary`/`results` on EvalResults became `aggregate`/`reps`, and the
scenario loop moved into a per-rep function. My per-run counts moved to
RepSummary, and the report sums them across reps rather than quoting the
first.

The seam that actually mattered: `aggregateReps` filtered only
`excludedAsEmptyGeneration`, so setup scenarios would have counted toward
pass^k — putting the cascade back one level up, where a flaky setup turn
reads as an unreliable SCENARIO rather than as its successors' reps not
being comparable. ScenarioReliability now carries `setup`, the aggregate
excludes it, and the reliability table renders it as ⊙ setup rather than
as a degenerate empty generation (both have scoredReps === 0). Four tests
pin it; verified they fail if the filter is reverted.

#2246 (scenario audit) added scenario 11c2, which had no `end` clause —
caught by my own fixture invariant rather than by the merge. It asserts
both halves (the note exists AND the edge reaches it), because it is the
create-and-link-in-one-turn shape: asserting only the edge would pass on
a turn that linked the wrong node, and only the node would pass on the
prose-instead-of-an-edge failure 11c exists to catch. It is also the
shape the asymmetric `after` walk was built to see.

Notably #2246 reached the same conclusion for scenario 6 independently —
assert the outcome, not the route — and relaxed its trajectory
expectation for the reason this PR exists.

test:all green: 227 frontend files / 4794 tests, 214 scripts, 24 skill,
53 Rust binaries including #2246's new winnability suite.

Co-Authored-By: Claude <[email protected]>
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.

Agent eval runner has no repetition support — every quoted score is a single draw from a wide distribution

1 participant