Skip to content

Make the agent scenario matrix (aichat-matrix.ts) an assertable CI eval, not just an observation harness - #1627

Merged
malibio merged 1 commit into
mainfrom
worktree-issue-1364-agent-eval
Jul 11, 2026
Merged

malibio merged 1 commit into
mainfrom
worktree-issue-1364-agent-eval

Conversation

@malibio

@malibio malibio commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Closes #1364

…ness (closes #1364)

Replaces the prose expect strings with a structured Expectation model
(noTools, toolOnce, toolSequence, noRetry, noExtraTypes) and a runner that
exits non-zero on any scenario failure, mirroring routing-eval.ts's
assertion/baseline/exit-code pattern. Assertions strip search_skills (the
ADR-038 routing call) before checking the target tool, so routing calls
never cause a false failure. Adds AICHAT_MATRIX_BASELINE regression
comparison and exposes the runner as `bun run eval:agent`.

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #1627

Review Type: Initial Review

Requirements Check (issue #1364)

  • ✅ Each scenario has a structured, machine-checkable Expectation (not prose) — scripts/aichat-matrix.ts:74-85.
  • ✅ Runner asserts per-scenario pass/fail and exits non-zero on failure — assertExpectation (154-222), exit codes at 355 (baseline regression) and 367 (any scenario failure).
  • ✅ Assertions check for the target tool, tolerating search_skills, not raw tool count — actionTools() filters ROUTING_TOOLS before every check (150-152, 158).
  • ✅ Empty-result (noRetry, scenario 7) and no-extra-types (noExtraTypes, scenario 3) are explicitly asserted — 251-258 (scenario 7), 233-238 (scenario 3).
  • ✅ Exposed as a bun script: "eval:agent": "bun run scripts/aichat-matrix.ts" — package.json:35.
  • ✅ Baseline-comparison mode mirroring routing-eval.ts's ROUTING_BASELINE — AICHAT_MATRIX_BASELINE (59, 335-361), same regression/exit-code shape.
  • ✅ Documented in nodespace-docs/development/agent-eval.md — accurate, describes the three-layer eval model, usage, and all 8 scenarios; committed separately to nodespace-docs per project convention.
  • ✅ bun run quality:fix — ran it; only touches packages/desktop-app and Rust, doesn't cover top-level scripts/*.ts at all (confirmed against package.json's quality:fix definition), so there's nothing for that gate to flag here. See note below on bunx prettier noise.

All 8 acceptance criteria are met.

Code Review Findings

🟢 Suggestions

scripts/aichat-matrix.ts formatting vs. raw prettier
Running bunx prettier --check directly (not through the project's quality:fix, which doesn't touch top-level scripts/*.ts) flags long lines in this file. I checked the sibling file this PR mirrors — scripts/routing-eval.ts — and it has the identical characteristic, along with scripts/aichat.ts and scripts/prompt-dump.ts. This is a pre-existing repo convention (top-level scripts aren't Prettier-gated), not a regression from this change, and consistent with the pattern being mirrored. No action needed.

toolSequence matching is a greedy subsequence check, not "consecutive order"
scripts/aichat-matrix.ts:182-195 — the loop advances idx on any match and never resets, so e.g. ["search_nodes", "update_node"] would also pass against actions like ["update_node", "search_nodes", "update_node"] (an earlier stray update_node doesn't invalidate the match). For scenario 6 this is very unlikely to produce a false pass in practice (the agent has no reason to call update_node before searching), but worth knowing this asserts "these appear in this order somewhere," not "these are the first two action calls." The doc comment (aichat-matrix.ts:79-80) already discloses this accurately ("other tools may appear between/around them"), so this is working as designed and documented — flagging only as a note in case a future scenario needs stricter adjacency.

No unit test for assertExpectation
The assertion logic (scripts/aichat-matrix.ts:154-222) is pure and the entire point of this issue — a bug in the toolSequence subsequence walk or the noRetry run-length counter would silently make the eval useless while still "passing" review by inspection. That said, routing-eval.ts (the explicit pattern this issue asks to mirror) also has zero unit tests for its own assertion logic, and this repo's scripts/ directory has no test files at all today. Given the project's stated pattern-mirroring intent and that this is a dev-tool harness (not shipped product code), I'm not blocking on this — but a follow-up issue adding a lightweight assertExpectation-only unit test (no daemon required, pure function, cheap to test) would meaningfully de-risk this eval layer without violating YAGNI, since the fixture data (arrays of tool-call strings) needs no infrastructure at all. Recommend filing this as a small follow-up rather than blocking this PR on it.

MUTATING_TOOLS — not present, no issue
I checked for a leftover MUTATING_TOOLS list possibly copied from routing-eval.ts and left unused. It does not exist anywhere in this diff or in aichat-matrix.ts — only ROUTING_TOOLS (search_skills) is defined, and it's used consistently everywhere assertions run (actionTools()). No dead code here.

Header comment / docs redundancy
scripts/aichat-matrix.ts:1-39 header and nodespace-docs/development/agent-eval.md cover similar ground (scenario list, ADR-038 routing-tolerance rule, baseline flag) but at different altitudes — the header is a quick in-file usage reference for someone reading the script, the doc page is the discoverable reference for someone browsing nodespace-docs/development/. Redundant in content but each serves a different reader; not worth trimming.

Recommendation: APPROVE

All 8 acceptance criteria are satisfied, the implementation correctly mirrors routing-eval.ts's conventions (baseline env var, exit codes, per-case assertion shape), the subsequence/run-length assertion logic is correct for the scenarios it's asserting today, and the one deferred item (unit-testing assertExpectation) is consistent with the existing precedent in this codebase and reasonable to defer to a follow-up rather than block on.

@malibio

malibio commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

Review Feedback Addressed

The initial review came back with zero blocking findings (🔴/🟡) — all 8 acceptance criteria for #1364 were confirmed met, and the recommendation was APPROVE.

One 🟢 non-blocking suggestion was raised: unit-test assertExpectation directly, since it's the core logic this issue is about. Filed as a standalone follow-up rather than an in-PR change, since:

Follow-up: #1630

No code changes were needed to address this review. PR is unchanged since the review and ready for merge at the user's discretion.

@malibio
malibio merged commit d47c620 into main Jul 11, 2026
@malibio
malibio deleted the worktree-issue-1364-agent-eval branch July 11, 2026 11:57
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.

Make the agent scenario matrix (aichat-matrix.ts) an assertable CI eval, not just an observation harness

1 participant