Commit Graph
781 Commits
Author SHA1 Message Date
Ankit1478 0594e5d59e 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.
2026-11-09 13:29:41 +05:30
Ankit1478 acd11c2a4c Keep local-only ignores out of the eval suite change 2026-11-09 13:12:51 +05:30
Ankit1478 8bb7981225 Fix stale figures in the eval README 2026-11-09 13:12:51 +05:30
Ankit1478 9b03064943 Correct the xfail count in the eval README 2026-11-09 13:12:51 +05:30
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 8f456013b6 Add blind-review tooling for the eval corpus
The labelling rules only mean something if a second person applies them the
same way. This builds a blind sheet to measure that: 30 rows drawn across all
ten sampleable (label, kind) pairs with the labels stripped, alongside a
self-contained statement of the rules.

Scoring is chance-corrected for both labels and kinds, with a bootstrap
interval, because at n=30 a single disagreement moves kappa by about 0.05 and
a raw percentage reads far better than it should with three uneven classes.
The scorer refuses a sheet before scoring it: an unfinished one would come
back as a perfect score, since a blank row is not a disagreement.

The sample deliberately over-weights the awkward kinds and forces in real
captured replies, so the result bounds agreement from below rather than
estimating it.

The answer key and the generated sheet are gitignored. Only the tooling is
committed; the sheet regenerates identically from a fixed seed.
2026-11-09 13:12:51 +05:30
Ankit1478 457bf4cf24 Guard the environment the detector baselines were recorded in
baselines.json records what the bundled OneClassSVM answers. That model
is three .joblib files committed to the repo, pickled with scikit-learn
1.9.1, so the recorded sets only hold under that release. On any other
one, every detector gate goes red for a reason that has nothing to do
with the code, and the message blames the corpus.

Three checks now run before the gates:

  - the three .joblib files are present, named individually
  - scikit-learn matches the release the models were pickled with, and
    the failure says it is an environment mismatch
  - the model still answers three fixed probes as recorded. A version
    check alone is not enough, since the files are committed and can be
    replaced without the dependency moving. One probe answers False, so
    a model degenerated to a constant is caught too

Pins that the ML plugin returns numpy.bool_ while annotated -> bool.
Harmless through the manager's any(), wrong for any caller using
`is True`.
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 c3d0064a15 Empty the eval test modules pending review
targets.py and _runner.py were committed before review. Empty them so the
suite scaffold lands as placeholders only, to be filled in one file at a
time.

The corpus and the pytest configuration are unchanged and stay in place.
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
Alexander Myasoedov c53cf3c02a Merge pull request #362 from nicho810/feat/cheapaimodel-preset
feat: add cheapaimodel preset to LLM specs
2026-11-04 11:49:56 +02:00
Nicho Deng abfe075849 feat: add cheapaimodel preset to LLM specs 2026-11-03 12:21:58 +08:00
Alexander Myasoedov 02f80c94da Merge pull request #361 from heydryft/feat/runcrate-provider
feat: add Runcrate preset to LLM specs
2026-11-01 20:34:03 +02:00
Nirupam Bhowmick 69a75b9329 feat: add Runcrate preset to LLM specs 2026-11-01 10:42:10 +00:00
Alexander Myasoedov 5dd991ed75 Merge branch 'main' of github.com:msoedov/agentic_security 2026-10-19 17:35:23 +03:00
Alexander Myasoedov 69e11e7d6d feat(update docs): 2026-10-19 17:35:15 +03:00
Alexander Myasoedov b6a5669060 Merge pull request #357 from msoedov/perf/harness-lazy-httpx
perf(harness): lazy import httpx
2026-10-18 19:54:23 +03:00
Alexander Myasoedov 6afb6611dc refactor(harness): lazy import fire 2026-10-18 19:51:05 +03:00
Alexander Myasoedov b89cf55645 perf(harness): lazy import httpx, bump black to 26.10.1 for PEP 810 syntax 2026-10-18 19:49:39 +03:00
Alexander Myasoedov fbfce94012 Merge pull request #352 from msoedov/chore/triage-fixes
Triage fixes and switch to Python 3.15
2026-10-18 19:15:06 +03:00
Alexander Myasoedov 32a3d23bf5 chore: drop Docker image and its CI workflow 2026-10-18 19:12:42 +03:00
Alexander Myasoedov d0a78195ba chore: switch to Python 3.15 (#347)
Relock so every dependency installs from wheels on 3.15 (multiprocess and
pyyaml are pure-python sdists), allow pandas 3 and scikit-learn 1.9.
2026-10-18 19:12:42 +03:00
Alexander Myasoedov 726b7ff835 chore(refusal_classifier): re-save bundled models with scikit-learn 1.9.1
Scores are identical to the 1.6.1 pickles (max abs decision diff 0.0 on 474 texts).
2026-10-18 19:08:48 +03:00
Alexander Myasoedov 55c6124b46 test(registry): check HF datasets via metadata, deactivate 3 dead ones (#72) 2026-10-18 19:08:48 +03:00
Alexander Myasoedov 486af8e58e fix(verify): return 400 for bad specs and upstream errors (#149) 2026-10-18 19:08:48 +03:00
Alexander Myasoedov 48a3374e6c fix(refusal_classifier): read judge verdict on word boundaries (#350) 2026-10-18 19:08:48 +03:00
Alexander Myasoedov 0005b251c3 chore(pre-commit): ignore flake8 E731 2026-10-18 19:08:48 +03:00
Alexander Myasoedov eab28edb52 feat(agentic_security_harness): 2026-10-18 18:09:43 +03:00
Alexander Myasoedov b9755a9ead Merge pull request #349 from msoedov/fix/pre-commit-pyupgrade
fix: ci poetry venv and pre-commit pyupgrade
2026-09-22 17:35:39 +03:00
Alexander Myasoedov 71c1f20a51 fix: unquote self-referential annotation for pyupgrade
pyupgrade --py314-plus rewrites the quoted return annotation added in #345,
failing pre-commit. The project requires Python 3.14, where annotations are
evaluated lazily (PEP 649), so the unquoted form imports fine.
2026-09-22 17:26:45 +03:00
Alexander Myasoedov f43472cc9b fix: ci poetry installs into system python
poetry.toml sets virtualenvs.create=false, so pipx poetry installed into
the runner's system Python 3.12 and failed uninstalling Debian packages.
Force venv creation in CI via POETRY_VIRTUALENVS_CREATE. Drop the poetry
cache from release, which never creates a venv.
2026-09-22 16:58:07 +03:00
Alexander Myasoedov bdf2208f6b Merge pull request #346 from jiawenlai1109/fix/audio-temp-leak-on-save-error
fix(audio_generator): clean up temp file when gTTS save() fails
2026-09-22 16:53:32 +03:00
jiawenlai1109 1fd08f50ee fix(audio_generator): clean up temp file when gTTS save() fails
generate_audio_cross_platform() created the temp MP3 via tts.save() one
statement *before* the try/finally that was supposed to remove it, so any
exception raised by the save itself escaped the cleanup and left
temp_audio_<hex>.mp3 in the current working directory.

gTTS.save() performs an outbound HTTP request, which is exactly the path that
fails offline or behind egress restrictions, and .gitignore does not cover the
temp_audio_* pattern - so every such run litters the working tree.

Move the save inside the existing try. Success-path behaviour is unchanged, and
this now matches how generate_audio_mac_wav() in the same file already guards
its two temp paths.

Verified on Ubuntu 22.04 / Python 3.14.7, same offline-failing test before and
after: leaked temp_audio_*.mp3 count went 1 -> 0, test result unchanged
(1 failed, gTTSError: Failed to connect). black --check passes; rest of the
module is 1 passed, 1 skipped, 1 pre-existing offline failure.
2026-09-22 17:55:01 +08:00
Alexander Myasoedov 2340bc2f5a Merge pull request #345 from Anai-Guo/fix/hybrid-classifier-self-annotation
fix(refusal_classifier): quote self-referential annotation to fix import NameError
2026-09-11 10:08:39 +03:00
Tai An 6f221d5c62 fix(refusal_classifier): quote self-referential return annotation to fix import NameError 2026-09-11 00:07:19 -07:00
Alexander MyasoedovandClaude Fable 5.1 1f2413e2b0 fix: ci pre-commit poetry env
Install poetry before setup-python and enable the poetry cache so
setup-python activates the 3.14 interpreter. With virtualenvs.create=false
poetry otherwise installs into the runner's system Python 3.12 and fails
uninstalling Debian dist-packages.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bk6CFfaN3YJFZ6yztQja7D
2026-09-07 14:08:49 +03:00
Alexander Myasoedov a49706457c fix: pc 2026-09-07 14:03:57 +03:00
Alexander Myasoedov 5a9e80b9af fix: cosmetic 2026-09-07 14:03:57 +03:00
Alexander Myasoedov 3e6b184c4f fix: template fix 2026-09-07 14:03:57 +03:00
Alexander Myasoedov f286ebf21a fix: docs 2026-09-07 14:03:57 +03:00
Alexander Myasoedov b5aa075927 Merge pull request #340 from rwinkelman/feat/scan-cli-spec-309
feat(cli): add stateless scan command for agent-invocable runs (#309)
2026-09-07 13:36:03 +03:00
Alexander Myasoedov 35379d1124 fix: build 2026-09-07 13:35:20 +03:00
Alexander Myasoedov fd43b13bb7 fix: syntax error 2026-09-07 13:24:28 +03:00
Alexander Myasoedov c75df250c7 Merge pull request #343 from TianHengZhuang/main
docs: document module interface and add ModuleProtocol
2026-09-07 13:16:03 +03:00
Alexander Myasoedov 80015fd803 Merge pull request #342 from Sabina8205/docs/cli-reference
docs: add CLI reference and correct configuration filename
2026-09-07 13:14:19 +03:00
TianHengZhuang ad41e09a2c docs: add module docstrings 2026-09-07 11:06:45 +08:00
TianHengZhuang 39fa5b34c0 docs: add module docstrings 2026-09-07 11:06:38 +08:00
TianHengZhuang d41039773e docs: add module docstrings 2026-09-07 11:06:32 +08:00