Repository navigation
Fix five matrix-harness defects that corrupt or block scoring - #2282
Conversation
…t gate pass
Four defects in the matrix harness, all of which corrupt or block scoring. No
product code changes; every fix is in scripts/eval/.
## Nested properties were never matched
The daemon serialises typed properties under the node's own type key:
{"task": {"_schema_version": 1, "due_date": "2026-08-06", "status": "open"}}
`toSnapshotNode` passed that wrapper through untouched, and every consumer -
`nodeSatisfies`, `populatedCount`, and both failure renderers - asks about the
INNER keys. So a keyed lookup found nothing and `populatedCount` returned 1
(the wrapper) no matter how many fields were written, making `minProperties: 2`
unsatisfiable by construction.
Measured against DeepSeek V4 Pro on d393ad1, scenarios 9, 10b and 13 each
failed 3/3 reps on writes that persisted exactly what was asked:
x 9. Set property on existing node tools=[update_node]
-> no existing node was updated to match [content~"offline sync",
some property = 8]
- nodes modified: feature_write_up:"Offline sync"
{feature_write_up={"_schema_version":1,"estimated_days":8,...}}
The trajectory verdicts corroborate this independently: across three reps there
are 21 outcome/trajectory disagreements and every one runs the same direction
(trajectory PASS, outcome FAIL). Model error would produce a mix.
`flattenTypeKeyedProperties` lifts the wrapper once, at the snapshot boundary,
so matching, counting and the failure messages cannot drift apart. Only the
node's own type key is lifted, only when it holds an object, and keys sitting
beside the wrapper survive. `_schema_version` is dropped so `minProperties`
counts what the model wrote rather than what persistence added.
The bug was not uniform across models - it only penalises typed nodes with
nested properties - so every score recorded on #2239 is depressed by an unknown,
model-dependent amount and the cross-model ranking there is not decision-grade
until the arms are re-run.
## The preflight skill-index gate could never pass
`awaitSkillIndex` compared a numerator and denominator sitting on opposite sides
of `should_skip_scope_filter` (packages/core/src/ops/search_ops.rs):
search "update an existing node" --type skill -> always 0 (scope-filtered;
`skill` is not in the
Knowledge allowlist)
search "" --type skill -> 8 (enumerate; bypass applies)
so it reported 0/8 against a warm, fully-embedded index, waited its full 120s
timeout and exited 2 before any scenario ran - for every model. preflight.ts
shipped in d393ad1 and has never completed a successful run.
Switching the numerator to an enumerate is not the fix: `enumerate_nodes` queries
rows by type and never consults embeddings, so it returns every skill the instant
the daemon boots and would wave through the cold-index state the gate exists to
catch. The CLI exposes no `--scope` override, so no CLI query can answer the
question. `embeddedSkillCount` reads the embedding table directly, via the
daemon's own reported database path so it cannot drift onto a different database
than the one being scored, and fails closed (0, never a fallback count) when the
query cannot run.
## Scenarios whose setup failed were scored as model failures
Setup turns are graded with the same matcher, so a correct setup was marked
failed - and the harness then ran the dependent scenario anyway after printing
its own warning that the result was meaningless. 12d failed 2/3 reps that way.
Those scenarios are now excluded rather than scored, with a `Blocked:` summary
line so the denominator never shrinks with nothing on screen to explain it.
## Scenario 12a could not establish the state 12d asserts
12a's prompt set up a type tracking only `estimated_days`, and 12d then asked
for the biggest job to be marked signed off - a field the type never declared.
The model reasoned correctly and declined to invent it:
"The biggest job is search indexer at 21 days, but the Build Job type only
tracks estimated_days - it has no 'signed off' field."
That is the behaviour this suite wants, scored red by the fixture. 12a now names
the sign-off field too, the same way scenario 3 names its downstream fields
(#1846). The fixture's own comment predicted this failure mode for this group.
## Verification
`bun run test:scripts`: 245 pass, 0 fail (was 224). The nested-property tests
were confirmed to FAIL (4 of them) against the unfixed flattening before being
checked in against the fix - the assertion is on the scoring outcome for real
daemon-shaped payloads, not on a helper's return value. The preflight tests
cover the cold-index case in both directions, so a probe that always returns the
seed count fails just as a structurally-zero one does.
`rust:lint` fails in this worktree on a missing `resources/skill/**/*` glob. That
is pre-existing - it reproduces in the primary checkout, and this change touches
no .rs files.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01S1ztc8m23p4WHoSToNfm89
The guard aborts a run whose scored scenarios are uniformly 0% or 100%, on the stated premise that "real runs on this suite have never been perfectly uniform". That premise held only while outcome scoring mis-read type-keyed properties and red-lined correct writes. With the preceding commit's fix in place a capable model legitimately passes everything: DeepSeek V4 Pro scored 21/21, the guard called it a harness signature, and no results file was written - the data was simply lost. This is the failure mode of a heuristic calibrated against a broken baseline: it fires exactly when the thing it was measuring starts working. Deleting the guard is the wrong answer - it has caught two real false results (a contaminated 11/12, and negative assertions scoring green while every turn died on context overflow). What separates those from a real full pass is observable without a model in the loop: a degenerate environment produces identical turns that call nothing, while a run that actually exercised the suite calls many different tools. `checkUniformity` now takes the distinct-tool count and exempts a full pass that clears MIN_DISTINCT_TOOLS_FOR_REAL_PASS (3, chosen below the suite's real diversity and above what a stuck run can produce). A uniform ZERO stays suspicious regardless of diversity: both known false results were all-fail, and a model calling varied tools while failing every scenario is precisely the "same unhandled code path" case the guard describes. The parameter defaults to 0, so any caller that does not measure diversity keeps today's strict behaviour rather than silently getting the looser check. Verified: `bun run test:scripts` 250 pass, 0 fail (was 245). The new tests were confirmed to FAIL against the unfixed guard before being checked in - one fails on the exemption path, and the remaining four pin the shapes that must still abort (near-zero diversity, uniform zero, omitted argument). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01S1ztc8m23p4WHoSToNfm89
Pragmatic Code Review — PR #2282Review Type: Initial review (comprehensive) SummaryThis is a genuinely high-quality diagnostic PR. All four defects are real, correctly root-caused, and the fixes address the cause rather than the symptom. The standout is that the author identified and rejected the obvious fix in two places — swapping the preflight numerator to an enumerate (which would make the gate vacuous), and deleting the uniformity guard (which has caught two real false results) — and documented why. That reasoning is preserved in the code comments, not just the commit message, which is where it will actually be read. I independently re-verified the author's central claims rather than taking them on trust:
I found one issue worth fixing before merge, plus several smaller items. Net assessment: this is a clear improvement to code health and the analysis quality is well above the bar. Requirements Check against #2263
Bonus beyond the issue: fixture 12a and the uniformity-guard exemption, both of which were discovered downstream of the primary fix. The 12a change is well-justified — the model's refusal to invent an undeclared field was correct behavior being scored red. Code Review Findings🔴 Critical📁 The docstring states the function "Returns 0 — never a fallback count — when the query cannot be run at all". That contract holds for a failing query but not for a missing binary. I verified the actual behaviour:
} catch (e) {
if (e instanceof EnvironmentError) abortOnEnvironment(fixture.name, e);
throw e;
}A plain This is also a new hard runtime dependency. The docstring justifies it with " Principle — fail-safe defaults / honest contracts: a function documenting "fails closed" must fail closed on every path that can prevent the query running, not just the anticipated one. A guard that covers one of two failure modes is more dangerous than no guard, because it invites reliance on a property that does not hold. Suggested fix — wrap the spawn and make the dependency explicit: export function embeddedSkillCount(
dbPath: string,
run: (db: string) => { exitCode: number | null; stdout: string } = (db) => {
try {
const r = Bun.spawnSync([...], { ... });
return { exitCode: r.exitCode, stdout: r.stdout.toString() };
} catch {
// `sqlite3` absent from PATH: spawnSync THROWS rather than returning a
// non-zero exit. Fail closed like any other unusable probe.
return { exitCode: null, stdout: "" };
}
},
): number {The existing test Separately, consider a preflight check that 🟡 Improvements📁 The comment /** Narrow one CLI node object into a SnapshotNode, tolerating absent fields. */
/**
* Bookkeeping keys the daemon writes itself...
*/
const PERSISTENCE_KEYS = new Set(["_schema_version"]);Two adjacent doc comments describing unrelated things. Move it back down to Principle: a doc comment's position is part of its meaning — a misattached one actively misinforms, unlike a missing one. 📁
I believe this is correct and arguably an improvement —
Given that standing warning, this deserves an explicit note and a test pinning the intent, rather than arriving as an undocumented side effect. If a migration bumps 📁 Verified behaviour: The spread order means the wrapper wins and the sibling is silently dropped. Every other edge case is handled well and I confirmed each:
The collision case is almost certainly unreachable given how the daemon serialises, and the comment explicitly reasons about preserving siblings — so this is not a correctness objection so much as an unstated precedence rule. Worth one line documenting which side wins, since "keys beside the wrapper must survive" is stated as the goal and a colliding sibling is the one case where it does not. 📁 function retrievableSkillCount(env: EvalEnv, _limit: number): number {
return embeddedSkillCount(readServedDatabasePath(env));
}
Also note 📁 The threshold is well-justified in prose (below the suite's real diversity, above what a stuck run produces) and the The tests cover 0, 1, and 6 but not the boundary itself. I verified it directly: Correct, but the constant could be changed to 4 and every existing test would still pass. A test at exactly 3 and exactly 2 would pin the threshold rather than leaving it inferable only from the constant's own value. Principle: a magic threshold's tests should straddle it, or the value is not actually pinned by the suite. 📁
This is the conservative direction (less diversity → more likely to flag), so it does not create a false-pass risk. Worth a sentence acknowledging the interaction, since the two features landed in separate commits and their coupling is not obvious from either one alone. 🟢 Nitpicks
What this PR does wellCalling these out because they are the parts worth repeating:
RecommendationAPPROVE — with the 🔴 finding addressed before merge. The The core work is correct, well-tested, and the regression tests are the real thing — I confirmed they fail against the unfixed code and that they assert scoring outcomes on realistic daemon payloads rather than helper return values. This is a clear net improvement to a harness whose defects were silently corrupting every score recorded on #2239. One follow-up worth tracking separately: the remaining two acceptance criteria on #2263 (re-run the #2239 arms; annotate the pre-fix scores as unreliable) are correctly out of scope here, but the cross-model ranking on #2239 stays non-decision-grade until they are done. |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (with one 🔴 to address before merge — posted as a comment because GitHub blocks self-approval). Full findings in the review comment above.
Headline: embeddedSkillCount does not fail closed when sqlite3 is missing from PATH — Bun.spawnSync throws rather than returning a non-zero exitCode, so the throw escapes gate() as a non-EnvironmentError and surfaces as a raw stack trace. Verified empirically. Small contained fix.
Independently re-verified: 250 pass/0 fail; the 4 nested-property tests confirmed to fail against reverted flattening; regression tests assert scoring outcomes on real daemon payloads, not helper return values.
## Critical: the fail-closed contract did not hold for a missing binary
`embeddedSkillCount`'s docstring promises it returns 0 "when the query cannot be
run at all". That held for a query that FAILS but not for one that cannot start:
`Bun.spawnSync` throws on a missing executable rather than returning a non-zero
`exitCode`, so the `exitCode !== 0` guard was never reached. The throw escaped
through `awaitSkillIndex` into `gate()`, which renders only `EnvironmentError`
actionably and rethrows anything else as a raw stack trace — landing on exactly
the environment-vs-model boundary this gate exists to police.
The whole probe call is now wrapped, not just the default closure, so an
injected probe that throws is covered too. The existing
`exitCode: null` test already pinned the desired outcome but could never reach
this path, because an injected fake cannot throw; the new test injects one that
does, and was confirmed to FAIL against the unwrapped call.
The docstring's claim that "sqlite3 is already required by the harness's own
diagnostics" was also wrong, and is corrected: the other mentions of sqlite3 in
that file are remediation TEXT printed for a human, never executed. This is the
first place the harness runs it, so the dependency is now stated plainly.
## Also addressed
- `changedNodes` behaviour change is documented and pinned. Flattening dropped
`_schema_version` from the comparator behind `expectNoWrites`, so a node whose
only difference is a persistence-bumped schema version no longer counts as
changed. That is the intended direction, but it loosened a false-PASS path as
an undocumented side effect. Three tests now pin both directions — a version-
only bump is not a change, a real field change still is, including alongside a
bump — so the loosening cannot widen unnoticed. Built through `toSnapshotNode`
rather than the `node()` helper, which constructs a SnapshotNode directly and
would not exercise flattening at all.
- Collision precedence stated. On `{task: {status: "inner"}, status: "outer"}`
the wrapper wins. Unreachable given current daemon serialization, so the rule
is stated rather than defended, and pinned by a test.
- Orphaned JSDoc moved back onto `toSnapshotNode`, ~57 lines from where the new
declarations had stranded it above `PERSISTENCE_KEYS`.
- Dead `_limit` parameter dropped from `retrievableSkillCount` and its one call
site.
- Threshold boundary tests added at exactly 3 and 2. The previous cases (0, 1, 6)
left `MIN_DISTINCT_TOOLS_FOR_REAL_PASS` changeable to 4 with every test still
passing, so the constant was not actually pinned by the suite.
## Skipped, with reasons
- `Number.parseInt(...) || 0` (nit): reviewer notes `sqlite3 COUNT()` cannot
produce the inputs that would differ, and 0 is the correct result for every
case it maps. Purely stylistic; changing it adds no behaviour.
- Replacing the local `omit` helper with `delete` after the spread (nit):
reviewer called the current form "arguably clearer about intent". Agreed.
- 12a prompt length (nit): the three-clause form is what makes 12d winnable,
which is the defect it was changed to fix.
- Hoisting `readServedDatabasePath` out of the poll loop: ~40 subprocess spawns
across a wait already dominated by a 30s embedding debounce. Real but
immaterial, and moving it changes the shape of `awaitSkillIndex`'s injectable
probe, which is load-bearing for its tests. Worth revisiting if the gate is
ever refactored.
Verified: `bun run test:scripts` 257 pass, 0 fail (was 250). Both new guards
confirmed to FAIL against the unfixed code before being checked in — the
throwing-probe test against the unwrapped call, and 2 of the changedNodes tests
against a `PERSISTENCE_KEYS` removal that never runs.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01S1ztc8m23p4WHoSToNfm89
Review addressed —
|
Pragmatic Code Review — PR #2282Review Type: Re-Review Previous Review Summary
Every claim in the author's response was re-verified independently rather than taken on trust. All of them hold, including the two the author flagged as traps. Details below. Verification I performedI did not accept the author's test-failure claims; I reproduced each by reverting the fix and re-running, then restored. 1. Suite count — confirmed. 2. The throwing-probe test genuinely fails against the unwrapped call — confirmed. The error surfaces exactly as the prior review predicted — an uncaught 3. The underlying So the original 🔴 was a real hole, not a theoretical one, and it is now closed. 4. The changedNodes tests genuinely exercise flattening — confirmed, and this is the important one. The author flagged the exact trap ("built through
That second run is the decisive one: if the tests were built through the 5. The threshold is now genuinely pinned — confirmed in both directions. The prior review's objection was that the constant could be changed to 4 with every test still passing. It now cannot be changed in either direction without breaking a test. This is a correct fix to a real gap in the suite. 6. One definition, one call site, both updated. No stale argument anywhere. 7. Requirements Check against #2263Unchanged from the prior review;
Findings🔴 CriticalNone. The prior 🔴 is correctly and completely fixed. 🟡 ImprovementsNone new. The five addressed 🟡 items each landed correctly — I checked each rather than assuming:
🟢 NitpicksNit: 📁 I verified this directly: A
Worth at most one clause in the existing comment acknowledging that any probe throw — not only a missing binary — maps to 0. Take or leave. Nit: 📁 The comment explains that Principle — comments must describe the code as it is, not as it was. This is precisely the class of drift the prior review flagged at Assessment of the four skipsAll four justifications are sound, and I want to record why rather than just concurring:
One thing worth calling outThe author's response did something unusual and valuable: it named the trap in its own work before I could check it ("built through Equally, the docstring correction is the right kind of fix. The original comment asserted RecommendationAPPROVE — no blocking findings. Merge when ready. The 🔴 is closed, and closed correctly: the whole probe call is wrapped rather than just the default closure, so an injected throwing probe is covered too, and — importantly — The five 🟡 fixes are all real fixes rather than comment-only gestures, and two of them (the changedNodes pinning and the threshold boundary) close genuine holes in the suite's ability to detect regression — verified by mutation, in both directions. The four skips are each justified on substance. The two remaining items are a stale comment rationale and an over-broad catch that fails in the safe direction. Neither is worth another round. Standing follow-ups, unchanged: re-run the #2239 arms and annotate the pre-fix scores (the remaining #2263 ACs), and file the Verification note: all reverts performed during this review were restored; |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Delta reviewed: fee42ac4 only. The 🔴 is closed correctly — the whole probe call is wrapped, so an injected throwing probe is covered, while readServedDatabasePath's own fail-closed EnvironmentError is evaluated outside the try and still propagates. Verified that scoping specifically.
Independently re-verified rather than trusted: 257 pass/0 fail; throwing-probe test confirmed to FAIL against the unwrapped call; the 3 changedNodes tests confirmed NON-vacuous by disabling flattening alone (2 fail) as well as PERSISTENCE_KEYS alone (2 fail); threshold mutation-tested in BOTH directions (constant→2 and constant→4 each break a test). All 4 skips justified on substance. 2 🟢 nits remain, neither worth another round.
All verification reverts restored; git status clean on scripts/.
Comment-only. No executable line changes (verified: the diff contains zero non-comment +/- lines), so behaviour is unchanged and the 257 tests pass untouched. Both findings were the same class the first review flagged at `graph.ts:124` — a comment that survived the change it described and now misinforms. `awaitSkillIndex`'s `expected` parameter carried a detailed justification for being declared BEFORE `probe`: that `probe`'s default read it, making a later declaration a forward reference. Dropping the dead `_limit` argument in the previous commit removed that dependency — the default is now `(e) => retrievableSkillCount(e)`, which counts embedded rows and needs no expected value. The comment now says why the order is kept (published signature, positional callers) and states plainly that the hazard is gone, rather than describing a coupling that no longer exists. The bare `catch` added in the previous commit had no recorded rationale. The re-review judged it a good trade but that reasoning lived only in the review thread, so the next reader would have had to re-derive it — or "fix" it by narrowing on Bun's error text, which is the thing worth avoiding. Now stated: it deliberately also swallows a programming error in a caller-supplied probe, because the alternative couples this gate to a runtime's error message, and failing closed is safe in either case. Also records that `readServedDatabasePath` is evaluated by the caller OUTSIDE the try, so its own fail-closed EnvironmentError still propagates — the property that keeps the wider catch from defeating the guard. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01S1ztc8m23p4WHoSToNfm89
Re-review addressed —
|
Five defects in the matrix eval harness, found while re-running #2239. No product code changes — every fix is in
scripts/eval/.Closes #2263.
1. Nested properties were never matched
The daemon serialises typed properties under the node's own type key, and
toSnapshotNodepassed that wrapper through untouched. Every consumer asks about the INNER keys, so keyed lookups found nothing andpopulatedCountalways returned 1 (the wrapper) — makingminProperties: 2unsatisfiable by construction.Measured against DeepSeek V4 Pro: scenarios 9, 10b and 13 each failed 3/3 reps on writes that persisted exactly what was asked. The trajectory verdicts corroborate independently — 21 outcome/trajectory disagreements across three reps, every one in the same direction (trajectory PASS, outcome FAIL). Model error would produce a mix.
flattenTypeKeyedPropertieslifts the wrapper once at the snapshot boundary, so matching, counting and the failure messages cannot drift apart.The bug only penalised typed nodes with nested properties, so it was non-uniform across models — every score on #2239 is depressed by an unknown, model-dependent amount.
2. The preflight gate could never pass
Numerator and denominator sat on opposite sides of
should_skip_scope_filter: a real query is scope-filtered (skillisn't in the Knowledge allowlist → always 0) while an enumerate gets the bypass (→ 8). The gate reported 0/8 against a warm, fully-embedded index and exited 2 before any scenario ran, for every model.Switching to an enumerate isn't the fix —
enumerate_nodesnever consults embeddings, so it would wave through the cold-index state the gate exists to catch.embeddedSkillCountreads the embedding table via the daemon's own reported DB path, and fails closed.3. Failed setups cascaded into scored failures
Dependent scenarios now excluded rather than scored, with a
Blocked:summary line so the denominator never shrinks unexplained.4. Scenario 12a could not establish 12d's state
12a set up a type tracking only
estimated_days; 12d then asked for a sign-off field that was never declared. The model reasoned correctly and declined to invent it — scored red by the fixture. 12a now names the field, as scenario 3 does (#1846).5. The uniformity guard discarded a legitimate full pass
Second commit. With (1) fixed, DeepSeek scored 21/21 — and the guard called it a harness signature and wrote no results file. Its premise ("real runs have never been perfectly uniform") held only while the scoring bug suppressed passes.
The guard has caught two real false results, so deleting it is wrong. It now takes a distinct-tool count and exempts a full pass with genuine diversity; a uniform zero stays suspicious regardless, since both known false results were all-fail.
Verification
bun run test:scripts: 250 pass, 0 fail (was 224).Both fixes were confirmed to FAIL before being checked in — 4 tests for the nested-property fix, 1 for the uniformity exemption — asserting scoring outcomes on real daemon-shaped payloads rather than helper return values. Cold-index cases are pinned in both directions, so a probe that always returns the seed count fails just as a structurally-zero one does.
Pre-push gate passed in full.
🤖 Generated with Claude Code
https://claude.ai/code/session_01S1ztc8m23p4WHoSToNfm89