Add failing_scanner for deterministic scan-error testing - #1
Merged
Merged
Conversation
A scanner that always raises, so downstream error handling (e.g. a scan runner recording a per-sample scan_error) can be exercised deterministically. The existing random_failure scanner (on the add-random-failure-scanner branch) is probabilistic, so it can't back an exact "one scan_error" assertion; failing_scanner always fails. Registered in _registry.py alongside the existing word_counter, so both are resolvable via the inspect_test_utils package. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
failing_scanner— a scanner whoseexecutealways raises — and registers it in_registry.pyalongside the existingword_counter. Both scanners are now resolvable from theinspect_test_utilspackage.Why
Hawk's online-scanning smoke test drives a scan whose model-full fixture references
word_counter(succeeds) andfailing_scanner(fails), asserting exactly one non-fatalscanner_resultwithscan_error.word_counteralready exists onmain, butfailing_scannerdid not exist in any branch/tag/commit.The nearest existing scanner,
random_failure(on the unmergedadd-random-failure-scannerbranch), is probabilistic (random.random() < failure_rate), so it can't back a deterministic "exactly one scan_error" assertion.failing_scanneralways fails, which is what a smoke/error-path test needs.Notes
test_online_scan) rather than a unit test here (the repo has notest_scanners.pyyet). Happy to add a direct unit test if preferred.online_scan.yamlfixture can pin the scanner package to a recentmaincommit that carries bothword_counterandfailing_scanner(it currently pins an older off-maincommit that has neither the failing scanner nor the latestmainstate).ruff check/ruff format --checkclean.🤖 Generated with Claude Code