Fix stale references left in the eval suite docs

The _runner docstring still said nothing covered the failure-rate arithmetic
or the optimize=True early stop; test_scan_module.py covers both. One `:324`
line reference and four `name (name)` parentheticals survived the earlier
sweep. test_detector still said 241 rows, and the README still named
MIN_RECALL and MAX_FALSE_POSITIVES, which the set-based baselines replaced.

Also records that CI does not run this suite, with the step that would turn it
on and the two reasons that is the maintainer's decision: a build starts
failing when a defect is fixed without unmarking its xfail, and the caret pin
on scikit-learn lets a fresh resolve invalidate the recorded baselines.
This commit is contained in:
Ankit1478 committed 2026-11-09 13:29:41 +05:30
1 parent acd11c2a4c
commit 0594e5d59e
6 files changed
+36 -16

No files matched your search

+21 -3
View File
@@ -15,6 +15,24 @@ The suite is opt-in: the default `pytest` run deselects it. No network, no API
keys, no randomness. If it is ever flaky, that is a bug in the suite, not in
the thing under test.
**CI does not run it.** `.github/workflows/test.yml` runs `pytest .`, which the
`addopts` line deselects, so nothing here executes on a pull request and the
suite can rot unnoticed. Turning that on is one step:
```yaml
- name: Run scan evals
run: poetry run pytest tests/evals -m eval
```
That step is deliberately not part of this change, because two of its
consequences are the maintainer's call rather than mine. A build would start
failing the moment a defect is fixed without unmarking the matching
`xfail(strict=True)` — that is the design working, but it is friction landing
on somebody else's pull request. And `scikit-learn` is pinned with a caret, so
a fresh resolve can pick up 1.10 and
`test_sklearn_matches_the_recorded_baseline` will stop the run until the
baselines are re-recorded; an exact pin would want to come first.
## Tiers
| Tier | Files | Needs labels | What it proves |
@@ -250,9 +268,9 @@ strict xfail paired with `test_attack_output_is_currently_misread`, which pins
the count at ten. That is a detector defect, not a corpus defect — do not
relax the corpus to make it green.
`MIN_RECALL` and `MAX_FALSE_POSITIVES` were re-measured on this corpus. A
ratchet only compares against the corpus it was measured on, so adding rows
means re-measuring; it does not mean the detector regressed.
The per-kind figures above were recorded on this corpus. A ratchet only
compares against the corpus it was recorded on, so adding rows means
re-recording `baselines.json`; it does not mean the detector regressed.
The corpus is sized to catch a regression, not to measure true accuracy. It is
one annotator and two models, and the real captured rows are all
+10 -6
View File
@@ -3,15 +3,19 @@
Thin wrapper over ``process_prompt`` so the tests read as
"scan this target, here is the verdict" rather than as plumbing.
**What this does not cover.** The real entry point is ``scan_module``, not
``process_prompt``. Two things live there and are untested by this suite:
**What this does not reach.** The real entry point is ``scan_module``, not
``process_prompt``. Two things live there that this wrapper steps over:
* the failure-rate arithmetic. ``Verdict.failure_rate`` below re-implements
``scan_module`` (``module_failures / module_prompts``, then
``round(x * 100, 2)``). It agrees with them today; nothing holds it there.
``round(x * 100, 2)``).
* early stopping. With ``optimize=True``, ``scan_module`` breaks out once the
running rate passes ``FAILURE_RATE_THRESHOLD``, which truncates the
denominator and changes the reported rate. No test covers it.
denominator and changes the reported rate.
Both are held by ``test_scan_module.py``, which drives the real ``scan_module``
rather than this wrapper. Still uncovered anywhere in the suite: the token
budget check and ``perform_scan``'s multi-module loop.
"""
from dataclasses import dataclass
@@ -35,8 +39,8 @@ class Verdict:
def failure_rate(self) -> float:
"""Percent, as the UI and the CLI threshold both read it.
Mirrors ``scan_module`` + ``:324``. See the module docstring: this
is a re-implementation, not the shipped arithmetic.
Mirrors ``scan_module``. See the module docstring: this is a
re-implementation, not the shipped arithmetic.
"""
return 100.0 * self.failures / max(self.prompts, 1)
+1 -2
View File
@@ -191,8 +191,7 @@ def non_json_target() -> ScriptedTarget:
Real deployments do this: an HTML error page from a proxy, or a plain-text
rate-limit notice, served with a 200. ``process_prompt`` reaches
``response.json()`` and the ``JSONDecodeError`` handler
(``process_prompt``) catches it. Ground truth: untested, exactly like an
``response.json()``, and its ``JSONDecodeError`` handler catches it. Ground truth: untested, exactly like an
HTTP error.
"""
return ScriptedTarget(
+1 -1
View File
@@ -347,7 +347,7 @@ def test_attack_successes_are_never_read_as_refusals():
reasonable detector reads them as declines.
This was a hard gate while the corpus was small enough to pass it. Growing
the corpus to 241 rows exposed ten more, which is the corpus doing its job:
the corpus to 245 rows exposed ten more, which is the corpus doing its job:
the defect was always there, and the gate was green only because nothing
had triggered it yet. Stating it as a strict xfail keeps the requirement
exact and visible, and pairs it with the pin below.
+1 -1
View File
@@ -118,7 +118,7 @@ def test_clear_refusal_survives_every_envelope():
def test_bare_text_and_single_key_wrapper_agree():
"""A narrow observation, deliberately not called a metamorphic property.
``refusal_heuristic`` runs ``str(request_json)`` (``refusal_heuristic``), so
``refusal_heuristic`` runs ``str(request_json)``, so
``"x"`` and ``{"response": "x"}`` are genuinely different inputs — one is
``x`` and the other is ``{'response': 'x'}``. They are not two encodings
of one thing, and nothing requires them to agree.
+2 -3
View File
@@ -11,8 +11,7 @@ word. A grade ladder with a hole in it, or a threshold applied to an inverted
number, is a wrong answer delivered with full confidence.
**The PASS/FAIL word is not the exit code.** ``async_scan`` only fills in a
string for the results table. The exit code lives in ``scan_cli``
(``scan_cli``), and ``agentic_security ci`` never reaches it — ``ci()``
string for the results table. The exit code lives in ``scan_cli``, and ``agentic_security ci`` never reaches it — ``ci()``
calls ``entrypoint()``, which calls ``scan()`` and discards the return value,
so the CI command exits 0 whatever it found. That is pinned below.
@@ -34,7 +33,7 @@ BASE_JS = (
)
#: The default threshold of ``AgenticSecurity.scan(max_th=0.3)``, hand-copied.
#: It is *not* what the CI path uses: ``entrypoint`` (``entrypoint``) reads
#: It is *not* what the CI path uses: ``entrypoint`` reads
#: ``general.max_th`` out of ``agentic_security.toml`` and passes that, so a
#: deployed CI run can be thresholded anywhere. 0.3 is the library default
#: only.