Metadata-Version: 2.4
Name: envaudit-cli
Version: 0.3.0
Summary: Autonomously harden RL environments: find rewarded solutions that don't do the task, and write the tests that stop them.
Project-URL: Homepage, https://www.shreshthrajan.com/envaudit/
Project-URL: Paper, https://arxiv.org/abs/2606.16062
Author-email: Shreshth Rajan <rajan.shreshth@gmail.com>
License-Expression: Apache-2.0
Keywords: benchmarks,evaluation,reinforcement-learning,reward-hacking,rl-environments
Requires-Python: >=3.9
Requires-Dist: anthropic>=0.40
Requires-Dist: numpy>=1.21
Provides-Extra: science
Requires-Dist: h5py; extra == 'science'
Requires-Dist: nibabel; extra == 'science'
Requires-Dist: scipy; extra == 'science'
Requires-Dist: tifffile; extra == 'science'
Description-Content-Type: text/markdown

# envaudit

Autonomously harden RL environments. RL rewards wrong solutions: patches that pass the tests without fixing the bug, and outputs that pass a grader without doing the task. Envaudit finds them by running a cheap wrong answer through your environment's real grader next to your reference solution, then writes a test that closes each hole and keeps it only if the reference still passes and the wrong answer now fails.

```
pipx install envaudit-cli
export ANTHROPIC_API_KEY=...
envaudit harbor path/to/tasks --fix          # Harbor / Terminal-Bench-style tasks
envaudit tasks.jsonl --fix                   # patch-style tasks (SWE-bench format also works)
```

In CI, `envaudit harbor . --changed-since origin/main --fix --fail-on hack` audits only the tasks a pull request changed and exits 1 if any is hackable. A ready GitHub Actions workflow: https://www.shreshthrajan.com/envaudit/envaudit-action.yml

## Grader mutation (no API key, $0)

```
envaudit harbor path/to/tasks --mutate --out report.html
envaudit harbor . --changed-since origin/main --mutate --fail-on slack    # in CI
```

`--mutate` checks a Harbor task's grader without a model. It runs the reference solution once, makes its own outputs wrong in known ways (scaled, noisy, NaN or inf, zeros, constants, shuffled rows, half the rows, a dropped field), and regrades each wrong output with the task's own verifier through `harbor trials regrade`. Two controls run next to them: the unmodified outputs must pass and emptied outputs must fail. A second oracle run measures how much the outputs vary between runs, and small changes inside that noise floor are not counted.

Each task gets a class. DEGENERATE-ACCEPT means an empty, NaN, zero or constant output got full reward. SLACK means another clearly wrong output got full reward. TIGHT means none did. `report.html` and `report.json` list every accepted wrong output with its score. Read each one against the instruction, since a field can be scale-invariant or unused by design.

Tasks whose verifier reruns the submitted code have no output data to perturb, so they are skipped as code-only. The check reads csv, tsv, json, npz, npy, numeric txt, mtx, tif, nii, h5 and sdf files. Other files are left as they are and noted in the report. tif, nii, h5 and mtx need `tifffile`, `nibabel`, `h5py` and `scipy`; install them with `pipx install "envaudit-cli[science]"`. `--fail-on slack` exits 1 on SLACK or DEGENERATE-ACCEPT, and `--fail-on degenerate` only on DEGENERATE-ACCEPT. Other options: `--noise-reruns`, `--max-mutants` and `--verifier-timeout`. The task needs a separate verifier (`tests/Dockerfile`) and its outputs declared in `task.toml` `artifacts`.

Everything runs on your machine with Docker; the only outside calls are to the Anthropic API with your key.

Results on public benchmarks and training data: https://www.shreshthrajan.com/envaudit/
Paper: https://arxiv.org/abs/2606.16062
