Repository navigation
fix(bench): one source/test convention for LOC and the judge (JS/TS, spec/, mjs/cts, skip .git/) - #1126
Open
zak1201 wants to merge 5 commits into
Open
fix(bench): one source/test convention for LOC and the judge (JS/TS, spec/, mjs/cts, skip .git/)#1126zak1201 wants to merge 5 commits into
zak1201 wants to merge 5 commits into
Conversation
_is_test only knew Python conventions (test_*.py, *_test.py, conftest.py, test/ and tests/ dirs), so *.test.js / *.spec.ts / *.test.jsx / *.spec.tsx and files under __tests__/ were counted as source LOC. That inflated src_loc for JS/TS cells and hid them from wrote_tests_rate, contrary to the README's "tests are excluded and tracked separately". Adds the .test/.spec JS/TS filename rule and __tests__ dir to _is_test, and an _is_test case in --selftest that also pins look-alikes (latest.ts, contest.tsx, test-utils.js, spec.js) as source. Result fields unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
judge.py kept its own _is_test(name) that only matched Python filenames (test_*.py, *_test.py, conftest.py), so source_text fed the LLM judge JS/TS test files and anything under tests/, test/ or __tests__/ as if it were source. Import the shared classifier from run.py instead, so LOC metrics and the over-engineering judge see the same source/test split. complete.py picks this up through judge.source_text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jasmine and RSpec put tests under spec/ (e.g. spec/button_spec.js), which _is_test still counted as source. Add "spec" to the test directory names; a file merely named spec.js stays source. The judge follows via the shared _is_test, and the selftest gains a spec/ case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ES-module and CommonJS variants were missing from CODE_EXT, so a cell that delivered server.mjs or config.cts got zero LOC for it. Add them to CODE_EXT and extend the .test/.spec filename rule to the same variants (button.test.mjs, util.spec.cts) so their tests stay out of source LOC. The selftest gains source and test cases for the new extensions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Hi @DietrichGebert, the |
source_text skipped only file names starting with "." or "_", so the .git/ that _git_snapshot creates in diff/fixture workspaces (HEAD, config, index, hook samples, objects) was concatenated into the judge prompt. Skip any path with a dot-prefixed component; run.py --selftest gains an offline check on a snapshotted workspace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
benchmarks/agentic/run.py_is_testnow also treats these as tests:*.test.*/*.spec.*filenames forjs|jsx|ts|tsx|mjs|cjs|mts|cts__tests__/orspec/directory (Jasmine/RSpec layout; a file merely namedspec.jsstays source)--selftestgains anis_testcheck covering the Python and JS/TS conventions, plus look-alikes that must stay source (latest.ts,contest.tsx,test-utils.js,spec.js,button.js,app.py). Cases forspec/button_spec.jsand the.mjs/.ctsvariants were added too. It also asserts the resultingcode_statssplit.CODE_EXTgains.mjs,.cjs,.mtsand.cts. Before this, a cell that deliveredserver.mjsorconfig.ctsgot 0 LOC for that file.benchmarks/agentic/judge.pydrops its own_is_test(name)and imports the one fromrun.py.source_textnow excludes the same files the LOC metrics treat as tests.complete.pypicks this up throughjudge.source_text.judge.source_textalso skips any path with a component starting with.. Workspaces ofdiff: Trueandfixturetasks are git repos (_git_snapshot), and files inside.git/(HEAD, config, index, hook samples, objects) don't start with.. They were being sent to the LLM judge as "source" byjudge.run, and bycomplete.submissionfordiff: Truetasks.--selftestgains ajudge_sourcecheck: it snapshots a workspace and asserts onlysrc/app.jsreaches the judge. (This was fix(bench): keep .git/ out of the over-engineering judge's input #1127, folded in here.)Why
run.pyonly knew Python conventions, so JS/TS test files a cell wrote were counted as source LOC. That inflatedsrc_loc/total_locand kept them out ofwrote_tests_rate, which contradicts the README ("Tests are excluded and tracked separately").judge.pyhad a second, even narrower copy: Python filenames only, notests//test/dirs. So the over-engineering judge was shown JS/TS tests and Python helpers undertests/as source. Two copies of one rule had already drifted.Scope
run.pycallerscode_stats(surgical/open tasks) andgit_diff_stats(fixture/diff tasks) both pick up the fix. Result fields and their names are unchanged. The source/test split moves, and with it the fixture-task correctness gate (see Reviewer notes).fileintasks.pymatches the new rules.CODE_EXTadditions in point 2, fixture exclusion, the self-check split, Git diff counting and the judge rubric/model are untouched.judge.py→run.pyis a new import.run.pyhas no import-time side effects and doesn't importjudge, so there is no cycle.complete.pyandanswer.pyimport cleanly.Reviewer notes
--rescore(or re-judging) an existing run will now give a lowersrc_loc_median, a higherwrote_tests_rate, and possibly different judge scores than the published numbers wherever cells wrote JS/TS tests or atests/dir.--rescoreoverwritesresults.json/summary.jsonin place.score_workspacescores everyfixturetask ascorrect = total_loc > 0fromgit_diff_stats. All fixture tasks are alsoopen, so when no source LOC is left it first falls back to fenced code in the chat answer (chat_code_loc). A cell whose diff adds only JS/TS test files (e.g.src/app.test.ts) wascorrect=1before; now it iscorrect=0unless its chat answer contains a fenced code block, and with no code at all it drops out ofwrote_file_rateand the LOC medians. So--rescorecan lowercorrect_rateand raisecost_per_passfor fixture tasks. This is intended: Python tests already behaved this way.spec/is matched as a directory name anywhere in the path. A source tree that usesspec/for non-test code (e.g. API specs written in TS) would now be counted as test. No task intasks.pyseeds or delivers anything underspec/.score_fixtureintasks.pykeeps its own.tsx/.ts/.jsx/.jslist. I left it alone becausescore_workspacereplaces the score for everyfixturetask with the git-diff result, soscore_fixtureis never reached.Verification (offline, no API calls)
python run.py --selftest→ all instruments valid, including the newis_testandjudge_sourcechecks.spec/rule it fails on exactlyspec/button_spec.js. With the previousCODE_EXTand filename rule it fails on exactlysrc/button.test.mjsandsrc/util.spec.cts.git_diff_statswith.mjs/.ctsfiles:src/server.mjsandsrc/cfg.ctscount as source (2 files / 4 lines),src/server.test.mjscounts as test.git_diff_statsin a throwaway repo:src/app.test.jsandsrc/__tests__/b.tscounted as test,src/new.tscounted as source.score_workspaceontmpl-fe-datepicker(throwaway repo seeded withsrc/app.ts, diff adding onlysrc/app.test.ts): at2961b52total_loc=2, correct=1. At this head: chat answer without code →total_loc=0,test_loc=2, correct=0; chat answer with a fenced code block →total_loc=1(from the chat), correct=1.judge.source_texton a synthetic workspace:src/button.test.js,src/Button.spec.tsx,src/__tests__/b.tsandtests/helper.py.app.py,notes.md,src/button.js,src/latest.ts. Non-code artifacts likenotes.mdare still included, as before.node scripts/check-rule-copies.jsandnode scripts/check-versions.jspass.node --test tests/*.test.js: 141/142. The only failure iscsv: correct pandas one-liner passes, caused by a broken pandas/numpy install on my machine and unrelated to this change. Because of that failure,npm teststops before thepi-extensiontests, so I ran them directly: 30/30 pass.--selftest(needs an API key).🤖 Generated with Claude Code