Skip to content

fix(agent): read jest, vitest, mocha, go and cargo test summaries as checks - #4387

Merged
kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:fix/verification-js-test-summaries
Sep 26, 2026
Merged

kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:fix/verification-js-test-summaries

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

A JavaScript, Go or Rust project's test run was invisible to the agent's verification record: npm test, go test ./... and cargo test were recognised as checks, but their output was only ever read for a pytest or unittest summary. A failing run behind a pipe (npm test | tail) passed on exit code alone, a passing run still drew the "verify your change" reminder, and the flagship eval's judge could not count it as a verified test run. One runner table now knows each runner's own summary line, and the verification footer, the answer seam, and the eval consumer all read through it; pytest and unittest behave exactly as before.

Test plan

  • python -m pytest tests/unit/agents/test_unsupported_test_claim.py tests/unit/agents/test_answer_quality_checks.py tests/unit/agents/test_verification_scope.py tests/unit/eval/test_flagship_tasks.py -q — per-runner pass/fail cases for pytest, unittest, jest, vitest, mocha, go test, cargo test; a piped failure fails; a coloured vitest summary reads; [no tests to run] and --collect-only do not count
  • python -m pytest tests/unit/agents tests/unit/eval -q (2346 passed locally)
  • python util/lint.py --black --isort --pylint
🔍 Technical details
  • checks.py: _RUNNERS table (label, summary regex, ran regex, per_target); runner_summary picks the summary printed last across runners, ANSI-stripped; for go test / cargo test any failing package or target line decides the run. _REPORTED_FAILURE_RE gains N failing, ^FAIL, test result: FAILED.
  • verification.py: summary_reports_failure and has_test_run_summary now go through runner_summary instead of a duplicated pytest/unittest pair of regexes (removed).
  • flagship_tasks.py: _test_run_passed uses the shared table; tests_verified accepts any test-kind check label instead of only "pytest".
  • docs/sdk/core/agent-system.mdx: the fallback-classification sentence names the runners.

…checks

A JavaScript, Go or Rust project's test run was invisible to the verification
record: the command was recognised as a check, but its output was only ever
read for a pytest or unittest summary, so a failing `npm test | tail` or
`go test ./...` behind a pipe passed on exit code alone, and a passing one
still drew the "verify your change" reminder and left the eval judge unable
to count it.

One runner table in checks.py now knows each runner's own summary line, and
verification.py and the flagship eval's tests_verified read through it instead
of keeping their own pytest-only copies. go test and cargo test report per
package or target, so any failing line there decides the run.
@github-actions github-actions Bot added documentation Documentation changes eval Evaluation framework changes tests Test changes performance Performance-critical changes agents labels Sep 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Request changes

This PR lets the agent read the test summaries that JavaScript, Go and Rust test runners print, so failing runs behind a pipe now count as failures. The design is good: one shared table replaces three copies of the pytest/unittest logic. One pattern is too loose, though. The new go test rule counts any printed line that starts with ok or FAIL and has one more word after it as a test result.

  • Ordinary script output can pass as a verified test run. A Python snippet that prints ok done, ok 200 or ok /tmp/out.txt is now recorded as a passing go test run. That clears the "verify your change" reminder and backs a claim like "all tests pass". It also makes the flagship eval's tests_verified return true, even though no tests ran. The same loose match on FAIL <word> can turn a run that isn't a test into a failure. Fix: a real go test package line always has a duration, (cached), or a [...] status after the package name, so require one of those.

Real-world evidence

N/A: no evidence bundle was produced for this run, and the change is internal verification/eval logic with no CLI, API, MCP or UI surface of its own. The verdict rests on static review, plus the false-positive cases I ran directly against the patched checks.py (shown below).

🔍 Technical details

🟡 go test summary regex matches arbitrary ok <word> lines (src/gaia/agents/base/checks.py, _GO_SUMMARY_RE)

The duration / (cached) group is optional, so ^(?:ok|FAIL)[ \t]+\S+[ \t]*$ is enough to match. _GO_RAN_RE only checks the leading ok|FAIL, so it doesn't filter anything out. I loaded the patched module and ran:

'ok done\n'          -> ('go test', 'ok done')          passed=True
'ok 200\n'           -> ('go test', 'ok 200')           passed=True
'Status: ok\nok saved\n' -> ('go test', 'ok saved')     passed=True
'FAIL   something\n' -> ('go test', 'FAIL something')   passed=False

These results feed check_from_python_run (footer / answer seam), has_test_run_summary (which cancels the unverified-change reminder) and flagship_tasks._test_run_passed / tests_verified (the eval judge). So a print("ok done") snippet after an edit scores as "tests verified". Go always writes a package line as ok \t<pkg>\t<dur> / (cached), or FAIL\t<pkg> [build failed], so making that trailer mandatory closes the gap:

_GO_SUMMARY_RE = re.compile(
    r"(?m)^(?:ok|FAIL)[ \t]+\S+"
    r"(?:[ \t]+(?:\(cached\)|\d+(?:\.\d+)?s)(?:[ \t]+\[[^\]\n]*\])?|[ \t]+\[[^\]\n]*\])"
    r"(?:[ \t]+coverage:[^\n]*)?[ \t]*$"
)

Please add "ok done\n", "ok 200\n" and "FAIL something\n" to test_a_runner_that_ran_nothing_is_not_a_check so this stays covered.

🟢 Aliased import (src/gaia/agents/base/verification.py): summary_reports_failure as summary_counts_failure is needed because the local function has the same name. That works, but a reader can easily mix up the two same-named helpers. Importing the module (from gaia.agents.base import checks) and calling checks.summary_reports_failure would be clearer. Optional.

Strengths

  • The _RUNNERS table removes three drifting copies of the pytest/unittest regexes across checks.py, verification.py and flagship_tasks.py. The eval judge and the runtime footer now make the same decision.
  • The per_target handling is correct for Go and Cargo: an earlier failing package isn't hidden by a later ok line. The test covers it, as it does the ANSI-coloured vitest summary.
  • The tests are shaped like real runner output, for both the pass and fail cases, including failures behind a pipe.

A snippet that printed `ok done` or `ok 200` was recorded as a passing
`go test` run: it cleared the "verify your change" reminder and made the
flagship eval's `tests_verified` true with no tests run. The duration,
`(cached)` or `[...]` trailer go always writes after the package name is
now required, so only a real package line matches.

Also drops a walrus name that shadowed the summary variable in
check_from_command, which mypy read as a type conflict.
@kovtcharov-amd

kovtcharov-amd commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Closed the loose go test pattern the review flagged: a snippet that just prints ok done or ok 200 no longer counts as a passing test run. Go always writes a duration, (cached) or a [...] status after the package name, so that trailer is now required, and the three false-positive strings are in the "ran nothing" test case. Also merged current main, which clears the unrelated pylint failure the quality gate was red on.

🔍 Technical details
  • _GO_SUMMARY_RE makes the trailer group mandatory: a duration or (cached) with an optional [...] status, or a bare [...]. Verified ok <tab> pkg <tab> 0.123s, (cached), [build failed] and the coverage: suffix still read, while ok done / ok 200 / FAIL something now return None.
  • Added those three to test_a_runner_that_ran_nothing_is_not_a_check.
  • Renamed the walrus in check_from_command that shadowed found; mypy was reading it as str | None vs tuple[str, str] | None. checks.py is now mypy-clean.
  • Spot-checked the other runner patterns for the same class of false positive (Tests: 3 total, Downloaded 4 passed, 0 failed, 0 passed, 0 total) — all correctly return None.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 26, 2026
Merged via the queue into amd:main with commit 82bd56c Sep 26, 2026
48 of 52 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/verification-js-test-summaries branch September 26, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation Documentation changes eval Evaluation framework changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants