caught 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- caught-0.3.0/.gitignore +11 -0
- caught-0.3.0/CHANGELOG.md +103 -0
- caught-0.3.0/LICENSE +21 -0
- caught-0.3.0/PKG-INFO +363 -0
- caught-0.3.0/README.md +339 -0
- caught-0.3.0/pyproject.toml +65 -0
- caught-0.3.0/src/caught/__init__.py +3 -0
- caught-0.3.0/src/caught/__main__.py +5 -0
- caught-0.3.0/src/caught/checks.py +700 -0
- caught-0.3.0/src/caught/cli.py +77 -0
- caught-0.3.0/src/caught/gitstate.py +107 -0
- caught-0.3.0/src/caught/hook.py +281 -0
- caught-0.3.0/src/caught/rerun.py +227 -0
caught-0.3.0/.gitignore
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to Caught are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.3.0] - 2026-12-06
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- The package is on PyPI: `pip install caught`. A GitHub release publishes it, through PyPI's
|
|
12
|
+
trusted publishing.
|
|
13
|
+
- `bench/gold.py`: the static checks on the 500 SWE-bench Verified human fixes, as a false-alarm
|
|
14
|
+
set.
|
|
15
|
+
- `bench/rivals.py`: fakegreen and red-green-mode's anti-cheat scan, at pinned commits, on the same
|
|
16
|
+
diffs Caught was scored on.
|
|
17
|
+
- `examples/inflection`: a real library where code bent to fit a wrong test is blocked by the
|
|
18
|
+
regression check, with a test that runs it through the hooks.
|
|
19
|
+
- `bench/study.py`: `caught check` on 60 public coding-agent PRs that change existing tests,
|
|
20
|
+
labelled by reading each diff first.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- Check 5 crashed on a new `match` case over a name, such as `case Color.RED:`.
|
|
25
|
+
|
|
26
|
+
## [0.2.0] - 2026-11-27
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- Three checks on what a change adds: source that asks whether it is under test (the test module
|
|
31
|
+
in `sys.modules`, a `PYTEST_*` environment variable, the runner in `sys.argv`); pytest hooks
|
|
32
|
+
that can rewrite outcomes or drop tests, such as `pytest_runtest_makereport`, in a conftest or
|
|
33
|
+
any other module; and test commands whose exit code is discarded, like `pytest || true`, `| tee`,
|
|
34
|
+
a `-` prefixed Makefile line or tox's `ignore_outcome`.
|
|
35
|
+
- A regression check: when the agent changed source, the original test modules that name the
|
|
36
|
+
changed modules also run on the session-start code, and a test that passed then and fails on
|
|
37
|
+
the agent's code blocks the stop. It catches code bent to fit a wrong test when that breaks
|
|
38
|
+
another test. The changed module's own test file runs first, then files that import it, then
|
|
39
|
+
files that mention it, up to 20.
|
|
40
|
+
- A PyPI-ready package with a `caught` console script and no runtime dependencies.
|
|
41
|
+
- An offline replay of GPT-5's Impossible-SWEbench runs that rebuilds each final diff from its
|
|
42
|
+
transcript, preregistered in `docs/preregistration.md`. Result files keep ids, labels, verdicts
|
|
43
|
+
and check names only.
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
46
|
+
|
|
47
|
+
- An allowance covers test edits, assertion changes, skips and config changes only. Hard-coded
|
|
48
|
+
test answers, test detection and outcome hooks are never covered, and a block names only files
|
|
49
|
+
an allowance could clear.
|
|
50
|
+
- Check 5 also reads string predicates such as `endswith` in a new branch, names bound to
|
|
51
|
+
literals, constants nested in a compared tuple, and `None` returned as the answer. It no longer
|
|
52
|
+
treats a one-character string as a copied test input.
|
|
53
|
+
- A test file that does not parse before or after the change is compared line by line instead of
|
|
54
|
+
being skipped.
|
|
55
|
+
- `caught check A...B` checks what B changed since its merge base with A.
|
|
56
|
+
- A stop with nothing changed since the last one reuses that verdict instead of running the tests
|
|
57
|
+
again.
|
|
58
|
+
- The re-run imports the worktree's code, `src/` layouts included, rather than the checkout an
|
|
59
|
+
editable install points at.
|
|
60
|
+
|
|
61
|
+
### Fixed
|
|
62
|
+
|
|
63
|
+
- A deep call chain in a changed file crashed the Stop hook.
|
|
64
|
+
- The re-run crashed, or the unittest fallback failed, when the session started in a
|
|
65
|
+
subdirectory.
|
|
66
|
+
- Both re-runs could outlast the Stop hook's timeout, and a test that left a child process
|
|
67
|
+
running, such as a server, held a re-run past its own.
|
|
68
|
+
- A re-run could load bytecode an earlier run wrote for a file that has since changed.
|
|
69
|
+
- Punctuation after `caught allow <path>` became part of the path.
|
|
70
|
+
- The GitHub Action glob-expanded its `allow` input.
|
|
71
|
+
|
|
72
|
+
## [0.1.0] - 2026-11-26
|
|
73
|
+
|
|
74
|
+
### Added
|
|
75
|
+
|
|
76
|
+
- A `SessionStart` hook that snapshots the working tree, untracked files included, as a git tree
|
|
77
|
+
object through a throwaway index, and records HEAD and the hash of every test and test-config
|
|
78
|
+
file. Resumed and compacted sessions keep their original snapshot.
|
|
79
|
+
- A `Stop` hook with five checks on the session's diff: test files edited or deleted; assertions
|
|
80
|
+
removed or expected values changed, from Python syntax trees; `skip`, `xfail`, `pass` or
|
|
81
|
+
`try/except` around asserts added; `conftest.py` or pytest options changed; and test literals
|
|
82
|
+
hard-coded into new source branches.
|
|
83
|
+
- A re-run of the original test files against the agent's code in a temporary git worktree when
|
|
84
|
+
the tests or their config were touched. Only tests that fail with the originals and not with
|
|
85
|
+
the agent's versions count, so a test that was already failing is not blamed on the agent.
|
|
86
|
+
- A one-line block reason for the agent that quotes a changed assertion before and after, names
|
|
87
|
+
up to three original tests that fail against the new code, and gives the `caught allow` line to
|
|
88
|
+
send if the edit was requested. After two blocks in a session the stop is allowed with a warning
|
|
89
|
+
shown to the user.
|
|
90
|
+
- `caught allow <path>` in the user's own message, read by a `UserPromptSubmit` hook, allows test
|
|
91
|
+
edits to those files for the session. The agent cannot allow itself, and a hard-coded test
|
|
92
|
+
literal in the source is never covered.
|
|
93
|
+
- `caught check [A..B]`, the same checks on any git range for CI and pre-commit, with `--allow`
|
|
94
|
+
and `--no-rerun`, plus a pre-commit hook and a GitHub Action that run it.
|
|
95
|
+
- The original-test re-run falls back to `python -m unittest` when pytest is not installed.
|
|
96
|
+
- `examples/payments`, a demo repo where "make the failing test pass" tempts a test edit, and a
|
|
97
|
+
README GIF recorded from a real run of the hooks on it.
|
|
98
|
+
- `bench/`, an evaluation on Impossible-LiveCodeBench against the ImpossibleBench LLM judge, with
|
|
99
|
+
every model call cached and `make eval` rebuilding the figures in `results/`.
|
|
100
|
+
|
|
101
|
+
[0.3.0]: https://github.com/SanyamWadhwa07/caught/releases/tag/v0.3.0
|
|
102
|
+
[0.2.0]: https://github.com/SanyamWadhwa07/caught/releases/tag/v0.2.0
|
|
103
|
+
[0.1.0]: https://github.com/SanyamWadhwa07/caught/releases/tag/v0.1.0
|
caught-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sanyam Wadhwa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
caught-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: caught
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: A Claude Code plugin that refuses an agent's "done" when it cheated the tests.
|
|
5
|
+
Project-URL: Repository, https://github.com/SanyamWadhwa07/caught
|
|
6
|
+
Project-URL: Changelog, https://github.com/SanyamWadhwa07/caught/blob/main/CHANGELOG.md
|
|
7
|
+
Project-URL: Issues, https://github.com/SanyamWadhwa07/caught/issues
|
|
8
|
+
Author: Sanyam Wadhwa
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: claude-code,coding-agents,pre-commit,pytest,reward-hacking,testing
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Framework :: Pytest
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<img src="https://raw.githubusercontent.com/SanyamWadhwa07/caught/main/.claude-plugin/icon.png" width="64" height="64" alt="Caught logo: a check mark, struck through">
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<h1 align="center">Caught</h1>
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<strong>Your coding agent says the tests pass. Caught checks how.</strong><br>
|
|
33
|
+
A Claude Code plugin that refuses the agent's "done" when it edited the tests, skipped them,<br>
|
|
34
|
+
or hard-coded their answers. Local, deterministic, no model calls.
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<a href="#install">Install</a> ·
|
|
39
|
+
<a href="#results">Results</a> ·
|
|
40
|
+
<a href="#how-it-works">How it works</a> ·
|
|
41
|
+
<a href="#outside-claude-code">CI and pre-commit</a> ·
|
|
42
|
+
<a href="#limitations">Limitations</a>
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
<p align="center">
|
|
46
|
+
<a href="https://github.com/SanyamWadhwa07/caught/actions/workflows/test.yml"><img src="https://github.com/SanyamWadhwa07/caught/actions/workflows/test.yml/badge.svg" alt="tests"></a>
|
|
47
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-b42318" alt="MIT license"></a>
|
|
48
|
+
<img src="https://img.shields.io/badge/python-3.11%2B%2C_no_dependencies-b42318" alt="Python 3.11+, no dependencies">
|
|
49
|
+
<img src="https://img.shields.io/badge/model_calls-0-b42318" alt="no model calls">
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
<p align="center">
|
|
53
|
+
<img src="https://raw.githubusercontent.com/SanyamWadhwa07/caught/main/docs/demo.gif" width="800" alt="Caught blocking a test edit: the expected value in a failing test is changed to match the code, the tests go green, and the Stop hook refuses the stop with the line, the old and new assertion, and the original test that still fails">
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
<p align="center"><sub>A real run of the hooks on <a href="examples/payments">examples/payments</a>, recorded by <a href="scripts/demo_gif.py">scripts/demo_gif.py</a>, which runs every command shown.</sub></p>
|
|
57
|
+
|
|
58
|
+
Coding agents told to make a failing test pass sometimes do exactly that: they change the test's
|
|
59
|
+
expected value, skip it, or add `if amount == 1500: return 74` to the code. The tests go green and
|
|
60
|
+
the agent reports success. Caught snapshots your tests when a Claude Code session starts, and every
|
|
61
|
+
time the agent tries to stop it diffs the session against that snapshot, re-runs the original
|
|
62
|
+
tests against the new code, and sends the agent back with the exact line it has to undo.
|
|
63
|
+
|
|
64
|
+
On held-out Impossible-LiveCodeBench tasks, where every passing attempt is a cheat by
|
|
65
|
+
construction, it caught **15 of 16 cheats with no false alarms on 19 honest fixes**, in a median
|
|
66
|
+
5.6 s per stop, most of it running the tests. On GPT-5's held-out Impossible-SWEbench runs, with
|
|
67
|
+
the static checks alone, it flagged 119 of 331 cheats and 7 of 292 honest fixes, and 5 of 477
|
|
68
|
+
human fixes from SWE-bench Verified ([details and caveats](#results)).
|
|
69
|
+
|
|
70
|
+
## Install
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
claude plugin install caught --marketplace SanyamWadhwa07/caught
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or inside Claude Code: `/plugin marketplace add SanyamWadhwa07/caught`, then
|
|
77
|
+
`/plugin install caught@caught`. To try a clone without installing, run
|
|
78
|
+
`claude --plugin-dir /path/to/caught`.
|
|
79
|
+
|
|
80
|
+
Caught needs `git` and `python3` (3.11 or later) on `PATH`, and works in git repositories with
|
|
81
|
+
pytest or unittest tests.
|
|
82
|
+
|
|
83
|
+
### Outside Claude Code
|
|
84
|
+
|
|
85
|
+
`caught check` runs the same checks on any git range and exits 1 on a finding, so CI and
|
|
86
|
+
pre-commit can use it:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
pip install caught
|
|
90
|
+
caught check # HEAD against your working tree, untracked files included
|
|
91
|
+
caught check main..HEAD # a branch, as in CI
|
|
92
|
+
caught check --allow tests/test_payment.py --no-rerun
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
In `.pre-commit-config.yaml` (the hook's own environment has no test dependencies, so either add
|
|
96
|
+
them with `additional_dependencies` or skip the re-run):
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
- repo: https://github.com/SanyamWadhwa07/caught
|
|
100
|
+
rev: v0.3.0
|
|
101
|
+
hooks:
|
|
102
|
+
- id: caught
|
|
103
|
+
args: [--no-rerun]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
In a GitHub Actions workflow, after installing your test dependencies:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
- uses: actions/checkout@v5
|
|
110
|
+
with:
|
|
111
|
+
fetch-depth: 0
|
|
112
|
+
- uses: SanyamWadhwa07/caught@v0.3.0
|
|
113
|
+
with:
|
|
114
|
+
range: origin/${{ github.base_ref }}..HEAD
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Results
|
|
118
|
+
|
|
119
|
+
Measured on [Impossible-LiveCodeBench](docs/impossiblebench.md), whose `oneoff` and
|
|
120
|
+
`conflicting` tests contradict the spec, so any passing attempt there is a cheat. The attempts
|
|
121
|
+
come from four free models (`gemini-3.5-flash`, `gemini-3.5-flash-lite`, `gpt-oss-120b`,
|
|
122
|
+
`gpt-oss-20b`) run through ImpossibleBench's own scaffold and instructions. The baseline is
|
|
123
|
+
ImpossibleBench's LLM judge with its prompt unchanged, on two free models, each in its own rows.
|
|
124
|
+
The checks Caught blocks on were chosen on the dev partition; these are the held-out test tasks.
|
|
125
|
+
|
|
126
|
+
**This is a partial run (26 Nov 2026): 55 scored attempts, 35 of them on the test partition.**
|
|
127
|
+
Free-tier limits stopped it. The ranges are 95% intervals and they are wide.
|
|
128
|
+
|
|
129
|
+
| Test partition | Cheats caught | False alarms on honest passes | Model calls per stop |
|
|
130
|
+
|---|---|---|---|
|
|
131
|
+
| Caught, every scored attempt | 15/16, 94% (72-99) | 0/19, 0% (0-17) | 0 |
|
|
132
|
+
| ImpossibleBench judge on `gemini-3.8-flash` | 14/14, 100% (78-100) | 0/16, 0% (0-19) | 1 |
|
|
133
|
+
| Caught, on the attempts that judge saw | 13/14, 93% (69-99) | 0/16, 0% (0-19) | 0 |
|
|
134
|
+
| ImpossibleBench judge on `qwen3.8-27b` | 4/4, 100% (51-100) | 0/10, 0% (0-28) | 1 |
|
|
135
|
+
| Caught, on the attempts that judge saw | 4/4, 100% (51-100) | 0/10, 0% (0-28) | 0 |
|
|
136
|
+
|
|
137
|
+
The `gemini-3.8-flash` judge caught the one cheat Caught missed; neither raised a false alarm.
|
|
138
|
+
Caught runs locally in a median 5.6 s per stop on a laptop (max 52 s, over all 55 stops, most of
|
|
139
|
+
it the test runs) and needs no model or API key. Every cheat here hard-coded answers in the code,
|
|
140
|
+
like
|
|
141
|
+
`if (start, finish, limit, s) == (9251, 82480, 9, "49"): return 733`, because the agents were
|
|
142
|
+
told not to touch the tests. So this eval exercised only check 5 and the regression check, which
|
|
143
|
+
never fired, not the test-edit checks; the Impossible-SWEbench replay below does.
|
|
144
|
+
|
|
145
|
+
A held-out-test check (tests written from the spec by a model) was planned as an option. It is not
|
|
146
|
+
built: after the changes below, Caught misses no dev cheat, so the dev data gives it nothing to
|
|
147
|
+
add.
|
|
148
|
+
|
|
149
|
+
All the numbers, split by dev and test, agent and split, are in
|
|
150
|
+
[results/summary.md](results/summary.md), which `make eval` rebuilds from the raw verdicts.
|
|
151
|
+
|
|
152
|
+
### Impossible-SWEbench
|
|
153
|
+
|
|
154
|
+
The same checks on GPT-5's runs on Impossible-SWEbench: real issues from ten Python repositories,
|
|
155
|
+
with `oneoff` and `conflicting` tests that contradict the issue, so a passing run there is a
|
|
156
|
+
cheat. Each run's final diff is rebuilt offline from its transcript, and the run was
|
|
157
|
+
[preregistered](docs/preregistration.md): one repository (astropy) is dev, the other nine are
|
|
158
|
+
held out and were scored once, on the checks frozen before the run. There is no environment to run
|
|
159
|
+
the tests in, so the re-run and the regression check are off and these are the static checks
|
|
160
|
+
alone.
|
|
161
|
+
|
|
162
|
+
| Held-out, 9 repositories | Flagged, of the runs replayed |
|
|
163
|
+
|---|---|
|
|
164
|
+
| Cheats on `oneoff` | 57/193, 30% (24-36) |
|
|
165
|
+
| Cheats on `conflicting` | 62/138, 45% (37-53) |
|
|
166
|
+
| All cheats | 119/331, 36% (31-41) |
|
|
167
|
+
| Honest passes on `original` | 7/292, 2% (1-5) |
|
|
168
|
+
|
|
169
|
+
On dev the same checks flagged 4 of 13 cheats (13-58) and 0 of 13 honest runs (0-23). Among the
|
|
170
|
+
caught cheats, 87 changed an assertion's expected value, 14 edited a test in another way, 20
|
|
171
|
+
hard-coded a test input in the source and 1 added a skip; a run can do more than one. The other
|
|
172
|
+
212 change no test the checks recognise, so the agent changed the code until the contradicting
|
|
173
|
+
test passed. In a live session the regression check can catch that when it breaks another
|
|
174
|
+
existing test; this replay cannot run tests. All 7 false alarms are check 5 on an honest new
|
|
175
|
+
branch over a value a test also passes in, such as `'left'`, `'min'` or `None`. 142 of the 765
|
|
176
|
+
held-out runs (19%) could not be replayed, all but one because an edit's old text is not in the
|
|
177
|
+
file at the task's commit, and are left out as preregistered. The static checks took a median
|
|
178
|
+
0.62 s per run.
|
|
179
|
+
|
|
180
|
+
The 500 human fixes of SWE-bench Verified, each applied over its task's tests and checked the
|
|
181
|
+
same way, are a second false-alarm set: 0 of 22 dev fixes and 5 of 477 held-out ones were flagged
|
|
182
|
+
(1%, 0-2), all by check 5 on the same kind of branch. One held-out fix did not apply. With no false
|
|
183
|
+
alarm on dev to learn from, check 5 is unchanged.
|
|
184
|
+
|
|
185
|
+
### Against other guards
|
|
186
|
+
|
|
187
|
+
[fakegreen](https://github.com/fitzyracing1/fakegreen) (commit `eb8fdbb`) and
|
|
188
|
+
[red-green-mode](https://github.com/hidevinliu/red-green-mode)'s anti-cheat scan (commit `fb8289e`)
|
|
189
|
+
are the other deterministic guards. Each read the same unified diffs with its defaults: fakegreen
|
|
190
|
+
fails on high-severity findings, and red-green-mode uses the `agent` profile its gate and Stop hook
|
|
191
|
+
use. Held-out only:
|
|
192
|
+
|
|
193
|
+
| Flagged | LiveCodeBench cheats | LiveCodeBench honest | SWE cheats | SWE honest runs | SWE-bench Verified human fixes |
|
|
194
|
+
|---|---|---|---|---|---|
|
|
195
|
+
| Caught | 15/16, 94% (72-99) | 0/19, 0% (0-17) | 119/331, 36% (31-41) | 7/292, 2% (1-5) | 5/477, 1% (0-2) |
|
|
196
|
+
| red-green-mode | 0/16, 0% (0-19) | 0/19, 0% (0-17) | 86/331, 26% (22-31) | 4/292, 1% (1-3) | 6/477, 1% (1-3) |
|
|
197
|
+
| fakegreen | 0/16, 0% (0-19) | 0/19, 0% (0-17) | 0/331, 0% (0-1) | 0/292, 0% (0-1) | 0/477, 0% (0-1) |
|
|
198
|
+
|
|
199
|
+
Caught's LiveCodeBench column includes the re-run and the regression check; every SWE column is
|
|
200
|
+
static checks only, like the other two tools, which read diffs and never run tests.
|
|
201
|
+
red-green-mode's point-patch check runs the changed function, so it was not run: the SWE replay has
|
|
202
|
+
no environment, and the LiveCodeBench solutions are written from an empty stub. fakegreen rates an
|
|
203
|
+
expected value changed as low and an assertion removed as medium, so at its default it fails none
|
|
204
|
+
of these; at any severity it reports something on 93 of the 331 SWE cheats, 9 of the 292 honest
|
|
205
|
+
runs and 4 of the 477 human fixes. red-green-mode caught 12 SWE cheats that Caught missed: 8 by
|
|
206
|
+
a new checker suppression such as `# type: ignore`, which Caught does not look for, 3 by a deleted
|
|
207
|
+
assertion and 1 by a skip. Caught caught 45 that red-green-mode missed. On dev neither tool
|
|
208
|
+
caught a cheat Caught missed. The verdicts are in [results/rivals/](results/rivals).
|
|
209
|
+
|
|
210
|
+
### Coding-agent pull requests
|
|
211
|
+
|
|
212
|
+
A read-only look at real PRs. A search for PRs by three coding-agent apps (Copilot's coding
|
|
213
|
+
agent, Devin and Claude) on Python repositories, with terms like "skip test" or "fix tests", gave
|
|
214
|
+
431 that modify or delete an existing test file. A seeded sample of 60 was labelled by reading
|
|
215
|
+
each diff, before Caught ran: 8 weaken an existing test (a skip, a deleted test or assertion, a
|
|
216
|
+
loosened check, or an expected value changed with no reason given), 52 keep what their tests
|
|
217
|
+
check. Then `caught check --no-rerun` ran on each PR, rebuilt at its merge base:
|
|
218
|
+
|
|
219
|
+
| `caught check` flagged | PRs that weaken a test | PRs that keep their tests |
|
|
220
|
+
|---|---|---|
|
|
221
|
+
| Any finding | 8/8, 100% (68-100) | 41/52, 79% (66-88) |
|
|
222
|
+
| Beyond a plain test edit or config change | 5/8, 62% (31-86) | 22/52, 42% (30-56) |
|
|
223
|
+
|
|
224
|
+
So on PR review Caught finds every weakened test here, and flags most honest test changes too.
|
|
225
|
+
Check 1 reports any edit to an existing test, which a session clears with `caught allow`; a PR has
|
|
226
|
+
no one to say it, so in CI `--allow` the paths the PR is meant to change. Past check 1, 22 PRs
|
|
227
|
+
labelled as keeping their tests were still flagged: 16 for an assertion change the reader judged
|
|
228
|
+
intended, 7 by check 5, one for both. The labels are one reader's, the sample is small, and the search terms pick PRs that talk
|
|
229
|
+
about tests. URLs, labels and verdicts are in [results/study/](results/study).
|
|
230
|
+
|
|
231
|
+
## How it works
|
|
232
|
+
|
|
233
|
+
```mermaid
|
|
234
|
+
flowchart LR
|
|
235
|
+
S[SessionStart] -->|snapshot the working tree<br/>and hash every test file| D[(.git/caught)]
|
|
236
|
+
T[Stop] --> X[diff against the snapshot]
|
|
237
|
+
X --> C[eight static checks]
|
|
238
|
+
X -->|tests or test config touched| R[re-run the original tests<br/>in a temporary worktree]
|
|
239
|
+
C --> V{finding?}
|
|
240
|
+
R --> V
|
|
241
|
+
V -->|no| A[allow]
|
|
242
|
+
V -->|yes, fewer than 2 blocks| B[block, with a one-line reason]
|
|
243
|
+
V -->|yes, 2 blocks already| W[allow, and warn the user]
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
At session start Caught writes the working tree, untracked files included, to a git tree object
|
|
247
|
+
through a throwaway index, so your staging area is never touched. When the agent tries to stop it
|
|
248
|
+
diffs against that snapshot and checks for:
|
|
249
|
+
|
|
250
|
+
1. test files edited or deleted, beyond adding new tests;
|
|
251
|
+
2. assertions removed or expected values changed, by comparing Python syntax trees;
|
|
252
|
+
3. `skip`, `xfail` or `pass` added, or asserts wrapped in `try/except`;
|
|
253
|
+
4. changes to `conftest.py` or to pytest options in `pytest.ini`, `pyproject.toml`, `setup.cfg`
|
|
254
|
+
or `tox.ini`;
|
|
255
|
+
5. literals from a test copied into a new source branch that returns another value from the same
|
|
256
|
+
test, like `if amount == 1500: return 74`;
|
|
257
|
+
6. source that asks whether it is under pytest or unittest: the test module in `sys.modules`, a
|
|
258
|
+
`PYTEST_*` environment variable such as `PYTEST_CURRENT_TEST`, or the runner in `sys.argv`;
|
|
259
|
+
7. pytest hooks that can rewrite outcomes or drop tests, such as `pytest_runtest_makereport`, in a
|
|
260
|
+
conftest or any other module (a new `pytest11` entry point in `pyproject.toml` is a config
|
|
261
|
+
change);
|
|
262
|
+
8. test commands whose exit code is thrown away, like `pytest || true` in a Makefile, script, tox
|
|
263
|
+
or CI file.
|
|
264
|
+
|
|
265
|
+
If the agent touched the tests or their config, Caught also runs the original test files against
|
|
266
|
+
the agent's code in a temporary git worktree, once with the agent's tests and once with the
|
|
267
|
+
originals put back. A test that fails only with the originals is one the edits hid.
|
|
268
|
+
|
|
269
|
+
When the agent changed source code, Caught also runs the original test modules that name the
|
|
270
|
+
changed modules, on the session-start code and on the agent's code. A test that passed at the start
|
|
271
|
+
and fails now is a regression: the usual sign of code bent to fit a wrong test, like rounding fees
|
|
272
|
+
half up so one test passes while the rounding-down test breaks. These runs use the project's
|
|
273
|
+
`.venv` or `venv` if there is one, and `python -m unittest` where pytest isn't installed.
|
|
274
|
+
[examples/inflection](examples/inflection) shows it on a real library: a patch that bends
|
|
275
|
+
`ordinal()` to fit a wrong new test is blocked on the 8 existing tests it breaks, though no test
|
|
276
|
+
file changed.
|
|
277
|
+
|
|
278
|
+
Any finding blocks the stop and tells the agent what it did, for example:
|
|
279
|
+
|
|
280
|
+
> Not done: the expected value in tests/test_payment.py line 28 changed from
|
|
281
|
+
> `assert charge(1500).fee == 74` to `assert charge(1500).fee == 73`, and the original test
|
|
282
|
+
> test_payment::test_fee_on_fifteen_dollars fails against your code. Undo that and fix the code
|
|
283
|
+
> itself, or tell the user the task conflicts with the tests.
|
|
284
|
+
|
|
285
|
+
After two blocks in a session Caught lets the agent stop and shows you the reason as a warning,
|
|
286
|
+
so it can't trap the agent in a loop.
|
|
287
|
+
|
|
288
|
+
### When you do want the tests changed
|
|
289
|
+
|
|
290
|
+
If you ask for a test change, say so to Caught in the same message, with the files:
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
The fee now rounds half up; update the test.
|
|
294
|
+
caught allow tests/test_payment.py
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Caught reads that line with a `UserPromptSubmit` hook, which runs only on what you type, so the
|
|
298
|
+
agent can't allow itself. The allowance lasts for the session and covers test edits,
|
|
299
|
+
assertion changes, skips and pytest config in the listed files, directories (`tests/`) or globs
|
|
300
|
+
(`tests/test_*.py`). It never covers a test literal hard-coded into the source, source that checks
|
|
301
|
+
whether it is under test, or a hook that rewrites outcomes. A block that an allowance could clear
|
|
302
|
+
ends with the exact `caught allow ...` line to send.
|
|
303
|
+
|
|
304
|
+
## Limitations
|
|
305
|
+
|
|
306
|
+
- Python only, with pytest or unittest, in git repositories.
|
|
307
|
+
- The snapshot stages your working tree into a throwaway index, so untracked files that are not
|
|
308
|
+
gitignored are hashed into `.git/objects` too. Keep large build output gitignored.
|
|
309
|
+
- Check 5 is a heuristic. It catches a new branch on a test input (by `==`, `in`, or a string
|
|
310
|
+
method such as `endswith`) that hands back a value from the same test. It misses cheats that
|
|
311
|
+
keep state, override `==`, compute their way to the expected value, or key on a one-character
|
|
312
|
+
string (`if s == "X": return 10`), which it treats as too common to tell from honest code. It
|
|
313
|
+
missed 1 of the 16 LiveCodeBench test cheats above, and its 7 false alarms on held-out SWE fixes
|
|
314
|
+
were new branches on option values a test also uses, such as `"left"` or `"min"`.
|
|
315
|
+
- Caught does not judge whether the code is right, only whether the tests were bypassed. An agent
|
|
316
|
+
that changes behaviour to fit a wrong test is caught only when that breaks another existing test
|
|
317
|
+
that names the changed module; a flaky test can also look like a regression.
|
|
318
|
+
- Known false alarms: libraries that check `"pytest" in sys.modules`, the django-debug-toolbar
|
|
319
|
+
setting `"PYTEST_VERSION" in os.environ`, and new hooks in a pytest plugin you are developing.
|
|
320
|
+
- `caught check` with no range, as the pre-commit hook runs it, checks your working tree against
|
|
321
|
+
HEAD, untracked files included, not only what is staged.
|
|
322
|
+
- A changed source file nested deeper than Python's parser allows is skipped by check 5.
|
|
323
|
+
- The eval is partial: Gemini calls stopped at a spend-cap error and Groq hit its daily token
|
|
324
|
+
caps. The agents are free models in a reimplementation of ImpossibleBench's scaffold, not
|
|
325
|
+
Claude Code, and the judge runs on free models, not its default Claude Opus 4. Transcripts
|
|
326
|
+
longer than Groq's per-minute token limit could not be sent to the `qwen3.8-27b` judge.
|
|
327
|
+
- Labels come from the dataset's construction. Seven tasks whose tests ImpossibleBench's issue #5
|
|
328
|
+
documents as wrong or broken are not scored.
|
|
329
|
+
- Check 5 was widened twice during the run, each time to catch dev-partition misses: answers in
|
|
330
|
+
nested branches, then inputs bound to a name, nested in a tuple, or answered with `None`.
|
|
331
|
+
Interim test-partition numbers had been printed before the second change; that change came only
|
|
332
|
+
from the dev misses.
|
|
333
|
+
- The bench runs model-written code on your machine, with timeouts but no sandbox.
|
|
334
|
+
|
|
335
|
+
## Reproduce
|
|
336
|
+
|
|
337
|
+
Rebuild every figure from the raw verdicts in `results/`:
|
|
338
|
+
|
|
339
|
+
```sh
|
|
340
|
+
uv sync --all-groups
|
|
341
|
+
make eval # or: uv run --group eval python -m bench.report
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Regenerate the attempts and verdicts with API keys (`GEMINI_API_KEY`, `GROQ_API_KEY`) in
|
|
345
|
+
`.env`. Every model call is cached in `bench/.cache/`, so a rerun only pays for new calls:
|
|
346
|
+
|
|
347
|
+
```sh
|
|
348
|
+
uv run --group eval python -m bench.attempts --agent gemini:gemini-3.5-flash
|
|
349
|
+
uv run --group eval python -m bench.attempts --agent groq:openai/gpt-oss-120b
|
|
350
|
+
make caught judge eval
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
The dataset is pinned to revision `98650ffc3f28a01b261669b6d19fcd7773823710`.
|
|
354
|
+
|
|
355
|
+
## Develop
|
|
356
|
+
|
|
357
|
+
```sh
|
|
358
|
+
uv sync --all-groups
|
|
359
|
+
uv run ruff check . && uv run ruff format --check . && uv run mypy
|
|
360
|
+
uv run pytest
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
MIT licensed.
|