5 Commits
Author SHA1 Message Date
Ankit1478 5286c69119 Drop future annotations import from the eval suite
pyupgrade strips it on this Python target, so `pre-commit run --all-files`
rewrote all twelve files and the pre-commit job would have failed on a branch
that looked clean locally. No other file in the tree carries the import.
2026-11-09 13:12:51 +05:30
Ankit1478 9ca647c5a1 Name functions instead of line numbers in the eval suite
Thirteen references pointed at source lines. One was already wrong:
targets.py cited both fuzzer.py:177 and fuzzer.py:190 for the same
JSONDecodeError handler. They rot on any edit upstream, so they now name
the function.

test_cli_status_still_mirrors_the_shipped_rule asserted an exact source
string, which would go red on a reformat. It parses async_scan and
compares the unparsed condition instead.
2026-11-09 13:12:51 +05:30
Ankit1478 6e812d5620 Grow the eval corpus and gate it by identity
Corpus goes from 37 to 245 rows. The larger corpus exposed defects the
small one never triggered, and exposed two weaknesses in the gates
themselves.

Gates no longer compare counts. baselines.json records which rows the
detector gets wrong, keyed by a hash of the reply text, and the gates
assert that no row newly joins a wrong-answer set. A count was not
monotone under corpus edits -- deleting a row the detector misreads
lowered the cap and handed back a slot -- and could not tell a fix from a
substitution. Regenerate with record_baselines.py.

Detector findings the bigger corpus surfaced:

  - ten attack_success rows read as refusals; the "an answered attack is
    never a refusal" gate becomes a strict xfail with an exact pin
  - all four roleplay rows read as refusals
  - the curly-apostrophe test was vacuous. It compared detect() outputs,
    which agree because the ML classifier fires on both spellings, while
    the phrase list went on missing every U+2019 form

New coverage:

  - test_scan_module.py drives the real entry point. Under optimize=True
    a module stops at the fifth prompt and reports that prefix's rate: a
    target scored 25% over twenty prompts is reported at 100% over five,
    and the payload does not say so
  - agentic_security ci cannot fail a build. entrypoint() discards
    scan()'s result and __main__.ci discards entrypoint()'s, so the
    process exits 0 whatever it found. Pinned by AST, not by grep
  - envelope invariance is now asserted on real attack output, not only
    on a benign sentence
  - HTTP 200 with a non-JSON body reaches fuzzer.py:177 for the first
    time; FakeResponse.json() parses its body instead of returning a
    pre-parsed object, which had made that branch unreachable

Corpus integrity: kind is validated against a per-label vocabulary and
src against a known set of models, so a typo can no longer drop a row out
of every gate silently. The partial sub-kinds get a stated rule --
refuse_then_disclose is the target's own configuration, refuse_then_comply
is something the attacker can act on -- and two rows are relabelled to
match it.

README corrects two claims: six of the 48 false positives are benign
answers rather than attacks reported as declines, and sixteen are planted
fp_trap rows, so the headline number moves little when real classifier
errors are fixed. Adds a Scope section for what the suite does not reach.

547 passed, 20 xfailed.
2026-11-09 13:12:51 +05:30
Ankit1478 90ed87b585 Add scan evaluation suite
Tier 1 drives process_prompt over fake targets whose posture is fixed by
construction, with the detector pinned to a phrase matcher. Tier 2 runs the
real detector over the labelled corpus with ratchet baselines.

Seventeen strict xfails state what should happen; each is paired with a test
pinning the current wrong behaviour, so a fix turns both red together.

118 passed, 17 xfailed.
2026-11-09 13:12:51 +05:30
Ankit1478 9bbcbd7f56 Add scan evaluation suite scaffold and corpus
Adds tests/evals, an opt-in suite that measures what the scanner concludes
about targets whose behaviour is known in advance, so a verdict can be checked
against ground truth instead of against the scanner's own internals.

Landing in two parts. This commit carries:

- corpus/*.jsonl: 37 labelled model replies (18 refusals, 12 compliances,
  7 partials), 5 tagged disputed. 10 rows are real captured output.
- targets.py: fake targets with known ground truth (secure, compromised,
  mixed, erroring) plus four provider response envelopes.
- _runner.py: drives process_prompt and returns a Verdict.
- pyproject.toml: register the eval marker and deselect it by default, so
  the suite is opt-in and `pytest tests/evals -m eval` collects.
- .gitignore: ignore .env and .venv.

The test modules are placeholders in this commit and are filled in next.
2026-11-09 13:12:51 +05:30