feat(contributor-scan): benchmark runs go beside the scan runs (3.1, follow-up)

`ousast benchmark` and its MCP twin wrote a run to
`<target>/.openultrasast/benchmarks/<id>/`, into the scanned tree, and no user
document said so. By the maintainer decision of 2026-11-24 a benchmark run now
goes to `<runs_dir>/<benchmark-run-id>/`, beside the scan runs, where run
retention removes it like a scan run.

`create_benchmark_run` in src/openultrasast/benchmark.py takes the runs
directory instead of the target. The two `_benchmark` functions, in cli.py and
in mcp.py, load the configuration the way `_run_scan` does and pass
`config.runs_dir`, so a benchmark run follows `OPENULTRASAST_RUNS_DIR` like the
scan it runs.

Both create the run once the scan has returned. Created first, as it was, the
run was under the scan's own retention while the scan ran, and a scan that
outlasted the retention window took it for an old one: the scoreboard could not
be written and the scan outcome was never printed. A failed scan now also
leaves no empty run behind.

README.md and docs/examples.md name where a benchmark run goes.

Tests: the three location assertions failed before the change and pass after
it. A new test pins that retention removes a benchmark run like a scan run, and
another that a benchmark keeps its run when its scan outlasts the retention
window. The nine test files around the change pass (120 passed); ruff, mypy,
the three gates and compileall pass. A run of the real CLI printed `run_dir=`
and `benchmark_run_dir=` as siblings under the runs directory and left only the
calibration ledger in the scanned tree. An independent reviewer approved the
change in two rounds; its first round found the retention window, which this
cut closes.
This commit is contained in:
Marius Ciepluch
2026-11-25 10:40:01 +01:00
parent 78434a6e9f
commit 9e4983f465
7 changed files with 83 additions and 13 deletions
+3 -1
View File
@@ -8,7 +8,9 @@ the current working directory, never against the target. Once a scan has written
default location, with no `OPENULTRASAST_RUNS_DIR` set, the runs there that are older than 30 days
are removed, and `ousast` prints one `notice:` line when it removes any;
`OPENULTRASAST_RUNS_RETENTION_DAYS` sets the number of days (`0` keeps every run), and nothing is
ever removed from a location chosen with `OPENULTRASAST_RUNS_DIR`.
ever removed from a location chosen with `OPENULTRASAST_RUNS_DIR`. `ousast benchmark` writes its
run to the same directory, as `<runs_dir>/<benchmark-run-id>/` beside the scan runs, and prints
that path (`benchmark_run_dir=<path>`); run retention removes it like a scan run.
A scan that rejects or holds a finding writes one file into the scanned tree, and only when that
file's content would change: