caught 0.3.0__tar.gz → 0.4.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.
@@ -4,6 +4,16 @@ All notable changes to Caught are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.4.0] - 2026-12-06
8
+
9
+ ### Added
10
+
11
+ - Check 9: a checker silenced wholesale on a changed line, such as a new `# type: ignore`,
12
+ `# noqa` or `# pragma: no cover` with no error code, or a file-wide `# mypy: ignore-errors`.
13
+ `caught allow` covers it in the allowed files.
14
+ - The README shows how to pass a PR's intended test changes to the GitHub Action's `allow` input
15
+ from a label a maintainer sets.
16
+
7
17
  ## [0.3.0] - 2026-12-06
8
18
 
9
19
  ### Added
@@ -98,6 +108,7 @@ All notable changes to Caught are documented here. The format follows
98
108
  - `bench/`, an evaluation on Impossible-LiveCodeBench against the ImpossibleBench LLM judge, with
99
109
  every model call cached and `make eval` rebuilding the figures in `results/`.
100
110
 
111
+ [0.4.0]: https://github.com/SanyamWadhwa07/caught/releases/tag/v0.4.0
101
112
  [0.3.0]: https://github.com/SanyamWadhwa07/caught/releases/tag/v0.3.0
102
113
  [0.2.0]: https://github.com/SanyamWadhwa07/caught/releases/tag/v0.2.0
103
114
  [0.1.0]: https://github.com/SanyamWadhwa07/caught/releases/tag/v0.1.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: caught
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A Claude Code plugin that refuses an agent's "done" when it cheated the tests.
5
5
  Project-URL: Repository, https://github.com/SanyamWadhwa07/caught
6
6
  Project-URL: Changelog, https://github.com/SanyamWadhwa07/caught/blob/main/CHANGELOG.md
@@ -97,7 +97,7 @@ them with `additional_dependencies` or skip the re-run):
97
97
 
98
98
  ```yaml
99
99
  - repo: https://github.com/SanyamWadhwa07/caught
100
- rev: v0.3.0
100
+ rev: v0.4.0
101
101
  hooks:
102
102
  - id: caught
103
103
  args: [--no-rerun]
@@ -109,11 +109,30 @@ In a GitHub Actions workflow, after installing your test dependencies:
109
109
  - uses: actions/checkout@v5
110
110
  with:
111
111
  fetch-depth: 0
112
- - uses: SanyamWadhwa07/caught@v0.3.0
112
+ - uses: SanyamWadhwa07/caught@v0.4.0
113
113
  with:
114
114
  range: origin/${{ github.base_ref }}..HEAD
115
115
  ```
116
116
 
117
+ A PR that is meant to change tests fails check 1, and in CI there is no session to say
118
+ `caught allow` in. The `allow` input takes the same paths, directories and globs. To let a
119
+ maintainer approve it per PR, tie it to a label, which only people with triage access can set,
120
+ and re-run on label changes:
121
+
122
+ ```yaml
123
+ on:
124
+ pull_request:
125
+ types: [opened, synchronize, reopened, labeled, unlabeled]
126
+ # ...
127
+ - uses: SanyamWadhwa07/caught@v0.4.0
128
+ with:
129
+ range: origin/${{ github.base_ref }}..HEAD
130
+ allow: ${{ contains(github.event.pull_request.labels.*.name, 'tests-changed') && 'tests/' || '' }}
131
+ ```
132
+
133
+ As in a session, the label never clears a test answer hard-coded into the source, source that
134
+ checks whether it is under test, a hook that rewrites outcomes, or a masked test command.
135
+
117
136
  ## Results
118
137
 
119
138
  Measured on [Impossible-LiveCodeBench](docs/impossiblebench.md), whose `oneoff` and
@@ -197,15 +216,18 @@ use. Held-out only:
197
216
  | 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
217
 
199
218
  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).
219
+ static checks only, like the other two tools, which read diffs and never run tests. red-green-mode's
220
+ point-patch check runs the changed function, so it was not run: the SWE replay has no environment,
221
+ and the LiveCodeBench solutions are written from an empty stub. fakegreen rates an expected value
222
+ changed as low and an assertion removed as medium, so at its default it fails none of these; at any
223
+ severity it reports something on 93 of the 331 SWE cheats, 9 of the 292 honest runs and 4 of the 477
224
+ human fixes. red-green-mode caught 12 SWE cheats that Caught missed: 8 by a new checker suppression
225
+ such as `# type: ignore`, which the frozen checks did not look for, 3 by a deleted assertion and 1
226
+ by a skip. Caught caught 45 that red-green-mode missed. On dev neither tool caught a cheat Caught
227
+ missed. Check 9 was added afterwards for suppressions, tuned on dev only: it flags 1 more of the 13
228
+ dev cheats and none of the 49 honest dev diffs. Held-out was not re-scored, so its held-out effect
229
+ is unmeasured ([deviation 6](docs/preregistration.md#deviations)). The verdicts are in
230
+ [results/rivals/](results/rivals).
209
231
 
210
232
  ### Coding-agent pull requests
211
233
 
@@ -234,7 +256,7 @@ about tests. URLs, labels and verdicts are in [results/study/](results/study).
234
256
  flowchart LR
235
257
  S[SessionStart] -->|snapshot the working tree<br/>and hash every test file| D[(.git/caught)]
236
258
  T[Stop] --> X[diff against the snapshot]
237
- X --> C[eight static checks]
259
+ X --> C[nine static checks]
238
260
  X -->|tests or test config touched| R[re-run the original tests<br/>in a temporary worktree]
239
261
  C --> V{finding?}
240
262
  R --> V
@@ -260,7 +282,10 @@ diffs against that snapshot and checks for:
260
282
  conftest or any other module (a new `pytest11` entry point in `pyproject.toml` is a config
261
283
  change);
262
284
  8. test commands whose exit code is thrown away, like `pytest || true` in a Makefile, script, tox
263
- or CI file.
285
+ or CI file;
286
+ 9. a checker silenced wholesale: a new `# type: ignore`, `# noqa`, `# pyright: ignore` or
287
+ `# pragma: no cover` that names no error code, or a file-wide `# mypy: ignore-errors`.
288
+ `# type: ignore[arg-type]` and `# noqa: E501` say what they allow and pass.
264
289
 
265
290
  If the agent touched the tests or their config, Caught also runs the original test files against
266
291
  the agent's code in a temporary git worktree, once with the agent's tests and once with the
@@ -295,11 +320,11 @@ caught allow tests/test_payment.py
295
320
  ```
296
321
 
297
322
  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.
323
+ agent can't allow itself. The allowance lasts for the session and covers test edits, assertion
324
+ changes, skips, pytest config and suppression comments in the listed files, directories (`tests/`)
325
+ or globs (`tests/test_*.py`). It never covers a test literal hard-coded into the source, source that
326
+ checks whether it is under test, or a hook that rewrites outcomes. A block that an allowance could
327
+ clear ends with the exact `caught allow ...` line to send.
303
328
 
304
329
  ## Limitations
305
330
 
@@ -315,6 +340,9 @@ ends with the exact `caught allow ...` line to send.
315
340
  - Caught does not judge whether the code is right, only whether the tests were bypassed. An agent
316
341
  that changes behaviour to fit a wrong test is caught only when that breaks another existing test
317
342
  that names the changed module; a flaky test can also look like a regression.
343
+ - Check 9 flags a blanket suppression in any changed Python file, tests included. A codebase that
344
+ writes bare `# type: ignore` as a habit will see it; name the error code, or `caught allow` the
345
+ file.
318
346
  - Known false alarms: libraries that check `"pytest" in sys.modules`, the django-debug-toolbar
319
347
  setting `"PYTEST_VERSION" in os.environ`, and new hooks in a pytest plugin you are developing.
320
348
  - `caught check` with no range, as the pre-commit hook runs it, checks your working tree against
@@ -73,7 +73,7 @@ them with `additional_dependencies` or skip the re-run):
73
73
 
74
74
  ```yaml
75
75
  - repo: https://github.com/SanyamWadhwa07/caught
76
- rev: v0.3.0
76
+ rev: v0.4.0
77
77
  hooks:
78
78
  - id: caught
79
79
  args: [--no-rerun]
@@ -85,11 +85,30 @@ In a GitHub Actions workflow, after installing your test dependencies:
85
85
  - uses: actions/checkout@v5
86
86
  with:
87
87
  fetch-depth: 0
88
- - uses: SanyamWadhwa07/caught@v0.3.0
88
+ - uses: SanyamWadhwa07/caught@v0.4.0
89
89
  with:
90
90
  range: origin/${{ github.base_ref }}..HEAD
91
91
  ```
92
92
 
93
+ A PR that is meant to change tests fails check 1, and in CI there is no session to say
94
+ `caught allow` in. The `allow` input takes the same paths, directories and globs. To let a
95
+ maintainer approve it per PR, tie it to a label, which only people with triage access can set,
96
+ and re-run on label changes:
97
+
98
+ ```yaml
99
+ on:
100
+ pull_request:
101
+ types: [opened, synchronize, reopened, labeled, unlabeled]
102
+ # ...
103
+ - uses: SanyamWadhwa07/caught@v0.4.0
104
+ with:
105
+ range: origin/${{ github.base_ref }}..HEAD
106
+ allow: ${{ contains(github.event.pull_request.labels.*.name, 'tests-changed') && 'tests/' || '' }}
107
+ ```
108
+
109
+ As in a session, the label never clears a test answer hard-coded into the source, source that
110
+ checks whether it is under test, a hook that rewrites outcomes, or a masked test command.
111
+
93
112
  ## Results
94
113
 
95
114
  Measured on [Impossible-LiveCodeBench](docs/impossiblebench.md), whose `oneoff` and
@@ -173,15 +192,18 @@ use. Held-out only:
173
192
  | 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) |
174
193
 
175
194
  Caught's LiveCodeBench column includes the re-run and the regression check; every SWE column is
176
- static checks only, like the other two tools, which read diffs and never run tests.
177
- red-green-mode's point-patch check runs the changed function, so it was not run: the SWE replay has
178
- no environment, and the LiveCodeBench solutions are written from an empty stub. fakegreen rates an
179
- expected value changed as low and an assertion removed as medium, so at its default it fails none
180
- of these; at any severity it reports something on 93 of the 331 SWE cheats, 9 of the 292 honest
181
- runs and 4 of the 477 human fixes. red-green-mode caught 12 SWE cheats that Caught missed: 8 by
182
- a new checker suppression such as `# type: ignore`, which Caught does not look for, 3 by a deleted
183
- assertion and 1 by a skip. Caught caught 45 that red-green-mode missed. On dev neither tool
184
- caught a cheat Caught missed. The verdicts are in [results/rivals/](results/rivals).
195
+ static checks only, like the other two tools, which read diffs and never run tests. red-green-mode's
196
+ point-patch check runs the changed function, so it was not run: the SWE replay has no environment,
197
+ and the LiveCodeBench solutions are written from an empty stub. fakegreen rates an expected value
198
+ changed as low and an assertion removed as medium, so at its default it fails none of these; at any
199
+ severity it reports something on 93 of the 331 SWE cheats, 9 of the 292 honest runs and 4 of the 477
200
+ human fixes. red-green-mode caught 12 SWE cheats that Caught missed: 8 by a new checker suppression
201
+ such as `# type: ignore`, which the frozen checks did not look for, 3 by a deleted assertion and 1
202
+ by a skip. Caught caught 45 that red-green-mode missed. On dev neither tool caught a cheat Caught
203
+ missed. Check 9 was added afterwards for suppressions, tuned on dev only: it flags 1 more of the 13
204
+ dev cheats and none of the 49 honest dev diffs. Held-out was not re-scored, so its held-out effect
205
+ is unmeasured ([deviation 6](docs/preregistration.md#deviations)). The verdicts are in
206
+ [results/rivals/](results/rivals).
185
207
 
186
208
  ### Coding-agent pull requests
187
209
 
@@ -210,7 +232,7 @@ about tests. URLs, labels and verdicts are in [results/study/](results/study).
210
232
  flowchart LR
211
233
  S[SessionStart] -->|snapshot the working tree<br/>and hash every test file| D[(.git/caught)]
212
234
  T[Stop] --> X[diff against the snapshot]
213
- X --> C[eight static checks]
235
+ X --> C[nine static checks]
214
236
  X -->|tests or test config touched| R[re-run the original tests<br/>in a temporary worktree]
215
237
  C --> V{finding?}
216
238
  R --> V
@@ -236,7 +258,10 @@ diffs against that snapshot and checks for:
236
258
  conftest or any other module (a new `pytest11` entry point in `pyproject.toml` is a config
237
259
  change);
238
260
  8. test commands whose exit code is thrown away, like `pytest || true` in a Makefile, script, tox
239
- or CI file.
261
+ or CI file;
262
+ 9. a checker silenced wholesale: a new `# type: ignore`, `# noqa`, `# pyright: ignore` or
263
+ `# pragma: no cover` that names no error code, or a file-wide `# mypy: ignore-errors`.
264
+ `# type: ignore[arg-type]` and `# noqa: E501` say what they allow and pass.
240
265
 
241
266
  If the agent touched the tests or their config, Caught also runs the original test files against
242
267
  the agent's code in a temporary git worktree, once with the agent's tests and once with the
@@ -271,11 +296,11 @@ caught allow tests/test_payment.py
271
296
  ```
272
297
 
273
298
  Caught reads that line with a `UserPromptSubmit` hook, which runs only on what you type, so the
274
- agent can't allow itself. The allowance lasts for the session and covers test edits,
275
- assertion changes, skips and pytest config in the listed files, directories (`tests/`) or globs
276
- (`tests/test_*.py`). It never covers a test literal hard-coded into the source, source that checks
277
- whether it is under test, or a hook that rewrites outcomes. A block that an allowance could clear
278
- ends with the exact `caught allow ...` line to send.
299
+ agent can't allow itself. The allowance lasts for the session and covers test edits, assertion
300
+ changes, skips, pytest config and suppression comments in the listed files, directories (`tests/`)
301
+ or globs (`tests/test_*.py`). It never covers a test literal hard-coded into the source, source that
302
+ checks whether it is under test, or a hook that rewrites outcomes. A block that an allowance could
303
+ clear ends with the exact `caught allow ...` line to send.
279
304
 
280
305
  ## Limitations
281
306
 
@@ -291,6 +316,9 @@ ends with the exact `caught allow ...` line to send.
291
316
  - Caught does not judge whether the code is right, only whether the tests were bypassed. An agent
292
317
  that changes behaviour to fit a wrong test is caught only when that breaks another existing test
293
318
  that names the changed module; a flaky test can also look like a regression.
319
+ - Check 9 flags a blanket suppression in any changed Python file, tests included. A codebase that
320
+ writes bare `# type: ignore` as a habit will see it; name the error code, or `caught allow` the
321
+ file.
294
322
  - Known false alarms: libraries that check `"pytest" in sys.modules`, the django-debug-toolbar
295
323
  setting `"PYTEST_VERSION" in os.environ`, and new hooks in a pytest plugin you are developing.
296
324
  - `caught check` with no range, as the pre-commit hook runs it, checks your working tree against
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "caught"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "A Claude Code plugin that refuses an agent's \"done\" when it cheated the tests."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,3 +1,3 @@
1
1
  """Caught: refuse a coding agent's "done" when it cheated the tests."""
2
2
 
3
- __version__ = "0.3.0"
3
+ __version__ = "0.4.0"
@@ -10,7 +10,9 @@ import ast
10
10
  import configparser
11
11
  import copy
12
12
  import difflib
13
+ import io
13
14
  import re
15
+ import tokenize
14
16
  import tomllib
15
17
  from collections import Counter
16
18
  from collections.abc import Iterator, Mapping
@@ -40,6 +42,7 @@ PRIORITY = [
40
42
  "special_case",
41
43
  "test_edit",
42
44
  "config",
45
+ "suppression",
43
46
  "rerun",
44
47
  "regression",
45
48
  ]
@@ -92,6 +95,7 @@ def run_checks(before: Snapshot, after: Snapshot) -> list[Finding]:
92
95
  findings += check_test_file(path, old, new)
93
96
  if path.endswith(".py") and new is not None:
94
97
  findings += check_source(path, old, new)
98
+ findings += check_suppressions(path, old or "", new)
95
99
  elif is_command_file(path) and new is not None:
96
100
  findings += check_masking(path, old or "", new)
97
101
  findings += check_special_cases(before, after)
@@ -698,3 +702,43 @@ def check_masking(path: str, old: str, new: str) -> list[Finding]:
698
702
  )
699
703
  for number, line in added
700
704
  ]
705
+
706
+
707
+ # Check 9: a checker silenced wholesale. A suppression that names the rule it allows, with an
708
+ # error code in brackets or after a colon, says what it allows, so it is not flagged.
709
+
710
+ BLANKET = re.compile(
711
+ r"#\s*(?:type:\s*ignore(?!\s*\[)|noqa(?!\s*:)|pyright:\s*ignore(?!\s*\[)"
712
+ r"|pragma:\s*no\s*cover|mypy:\s*ignore-errors|(?:ruff|flake8):\s*noqa(?!\s*:)"
713
+ r"|pylint:\s*skip-file)",
714
+ re.I,
715
+ )
716
+
717
+
718
+ def _suppressions(text: str) -> list[tuple[int, str]]:
719
+ """(line number, comment) for each blanket suppression comment, ignoring strings."""
720
+ try:
721
+ tokens = list(tokenize.generate_tokens(io.StringIO(text).readline))
722
+ except (tokenize.TokenError, SyntaxError):
723
+ return []
724
+ return [
725
+ (t.start[0], t.string.strip())
726
+ for t in tokens
727
+ if t.type == tokenize.COMMENT and BLANKET.search(t.string)
728
+ ]
729
+
730
+
731
+ def check_suppressions(path: str, old: str, new: str) -> list[Finding]:
732
+ """Blanket suppressions the change added, like `# type: ignore` or `# pragma: no cover`."""
733
+ before, after = _suppressions(old), _suppressions(new)
734
+ seen = Counter(comment for _, comment in before)
735
+ added = []
736
+ for number, comment in after:
737
+ if seen[comment]:
738
+ seen[comment] -= 1
739
+ else:
740
+ added.append((number, comment))
741
+ return [
742
+ Finding("suppression", path, number, f"{path} line {number} silences a checker: `{c}`")
743
+ for number, c in added
744
+ ]
@@ -31,9 +31,10 @@ from caught.rerun import rerun_originals
31
31
  MAX_BLOCKS = 2
32
32
  ADVICE = "Undo that and fix the code itself, or tell the user the task conflicts with the tests."
33
33
  ALLOW = re.compile(r"\bcaught allow\b([^\n]*)", re.IGNORECASE)
34
- # An allowance covers edits to the allowed test and config files. It never covers source that
35
- # copies or detects the tests, or a hook that rewrites outcomes: "change the tests" means neither.
36
- ALLOWABLE = {"test_edit", "assertion", "skip", "config"}
34
+ # An allowance covers edits to the allowed test and config files, and suppression comments in
35
+ # the allowed files. It never covers source that copies or detects the tests, or a hook that
36
+ # rewrites outcomes: "change the tests" means neither.
37
+ ALLOWABLE = {"test_edit", "assertion", "skip", "config", "suppression"}
37
38
 
38
39
 
39
40
  def _repo(payload: dict) -> tuple[Path, Path] | None:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes