garak icon indicating copy to clipboard operation
garak copied to clipboard

Digest scores a detector with nothing evaluated as a complete failure (0.0 / DEFCON 1)

Open reeve25 opened this issue 2 months ago • 3 comments

Steps to reproduce

When a detector returns None for every output of a probe, the evaluator records total_evaluated: 0 and the console prints SKIP ... 0/0. The digest then scores that pairing as 0, which is the same as "attack succeeded every time", and it gets DEFCON 1 / "immediate risk (complete failure)".

  1. Run against the built-in target that always returns None:
garak --target_type test.Nones -p test.Test -d mitigation.MitigationBypass
  1. The eval entry in report.jsonl:
{"entry_type": "eval", "probe": "test.Test", "detector": "mitigation.MitigationBypass", "passed": 0, "fails": 0, "nones": 40, "total_evaluated": 0, ...}
  1. The digest entry garak writes at the end of the same report.jsonl has:
group _summary: {'score': 0.0, 'group_defcon': 1}
detector: {'absolute_score': 0.0, 'absolute_defcon': 1, 'absolute_comment': 'immediate risk (complete failure)', 'total_evaluated': 0, 'passed': 0}
probe_score: 0.0  probe_severity: 1

It also drags down results that were scored. With one detector passing 20/20 and a second one that scored nothing on the same probe:

import garak._config
garak._config.load_base_config()
import garak.analyze.report_digest as rd

evals = [
    {"probe": "test.Test", "detector": "always.Pass", "passed": 20, "fails": 0, "nones": 0, "total_evaluated": 20},
    {"probe": "test.Test", "detector": "mitigation.MitigationBypass", "passed": 0, "fails": 0, "nones": 20, "total_evaluated": 0},
]
conn, cur = rd._init_populate_result_db(evals)
print(rd._get_probe_group_summaries(cur, "test"))
for fn in ("lower_quartile", "mean", "minimum"):
    print(fn, rd._get_group_aggregate_score(cur, "test", fn)[0])
[('test', 'Test', 0.0)]
lower_quartile 0.25
mean 0.5
minimum 0.0

The probe score is 0.0 because _get_probe_group_summaries takes min(score) across detectors, and every group aggregation counts the unscored row as a 0.

Expected behavior

A pairing with nothing evaluated should be treated as not scored, not as a total failure. In the second example the probe and group should come out at 1.0, from the one detector that did score.

The digest already does this for the technique/intent matrix: technique_intent_matrix sets "score": None when the total is 0. The results table is the part that doesn't.

Current behavior

garak/analyze/report_digest.py, _init_populate_result_db:

instances = eval.get("total_evaluated", eval.get("total", None))
score = passes / instances if instances else 0

instances == 0 falls through to score = 0, and that row feeds the detector entry, the probe score (min), the group score (scoring.aggregate) and TBSA, which reads absolute_score/absolute_defcon from the digest.

Fixing it isn't just a matter of changing the 0 to None: garak.analyze.score_to_defcon(None, ...) raises TypeError, so the group/probe/detector paths would need to skip or handle the unscored rows. Skipping the insert when instances == 0, or storing NULL and filtering it in those queries, both look workable; I'm not sure how you'd want an all-skipped probe shown in the HTML report.

This isn't covered by #2210 / #2209 (those are analyze_log and qual_review) or #1954 (evaluator ASR denominator); neither touches the digest.

garak version

Source checkout at 8d1259ef (0.17.1.pre1)

Additional Information

  1. Windows 11
  2. Python 3.12.10
  3. Editable uv pip install -e ".[tests]" from a git checkout
  4. Eval row from the report is above; happy to attach the full report.jsonl if useful
  5. Command line above, no config file
  6. n/a

I'd like to work on a fix for this if it's wanted.

reeve25 avatar Sep 30 '26 00:09 reeve25

This seems to be a regression or maybe is an edge case that does not conform to other skip patterns. In other scenarios that produce a SKIP message from the detector no eval entry is emitted suppressing the score for that probe detector pair from the digest.

As noted in the report there are multiple items to address here:

  • Should a probe that received None responses for all attempts be considered skipped at the detection phase in the same way as when the detector itself was not available for some reason?
  • Depending on the answer above how should a probe class that has not processable results for any detector be presented in the html report?

A naive short term path may be simply to suppress the eval entry when all attempt results are none instead of reporting a DC-1 score for a probe that had no actionable response.

Any solution mixes with another vector as the currently it is possible that a probe technique simply exhausts all tokens allowed for the request in the reasoning stage as some service stacks will terminate inference with a None result, when this occurs possibly indicating a localized Denial-Of-Service level concern for certain prompts that should be raised as a risk in the report.

Not sure what a good solution to this looks like but open evaluating proposals.

jmartin-tech avatar Sep 30 '26 13:09 jmartin-tech

I’d like to contribute by validating the remaining edge case around previously generated reports.

I noticed the review mentions that the writer-side fix prevents new zero-evaluation entries, but existing report.jsonl files may still be scored incorrectly by the digest reader.

Would a focused follow-up covering legacy report entries with total_evaluated: 0 be useful? I can investigate the reader-side behavior, add regression tests for mixed scored/unscored detector results, and verify that valid detector scores and DEFCON calculations remain unchanged.

I’ll avoid duplicating the existing PR and would appreciate your guidance on whether this follow-up is in scope.

Harshit057 avatar Oct 09 '26 18:10 Harshit057

Hi maintainers,

I reviewed #2251 and the existing fix in #2258.

I noticed the writer-side fix is already covered, and another contributor has expressed interest in handling legacy report entries.

I'd be interested in investigating the remaining HTML reporting behavior for probes where all detector evaluations are skipped.

Before starting, could you confirm whether this is something you'd like to support, and how an all-skipped probe should be represented?

If useful, I can first prepare a minimal reproduction and regression tests without duplicating the existing PR.

Thanks!

abhi06032005 avatar Oct 16 '26 13:10 abhi06032005