Unified run.spec selection grammar#1831
Open
patriciapampanelli wants to merge 7 commits into
Open
Conversation
…bes/--probe_tags/--buffs Signed-off-by: Patricia Pampanelli <ppampanelli@nvidia.com>
…ection) Signed-off-by: Patricia Pampanelli <ppampanelli@nvidia.com>
…fig) Signed-off-by: Patricia Pampanelli <ppampanelli@nvidia.com>
Signed-off-by: Patricia Pampanelli <ppampanelli@nvidia.com>
…ncludes Signed-off-by: Patricia Pampanelli <ppampanelli@nvidia.com>
…pec alias Signed-off-by: Patricia Pampanelli <ppampanelli@nvidia.com>
Signed-off-by: Patricia Pampanelli <ppampanelli@nvidia.com>
6b8151c to
b3a43fe
Compare
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.
Summary
Introduces a single selection grammar —
run.spec— for choosing probes and buffs, replacing the fragmented--probes/--probe_tags/--buffsflags and their config keys. One transport-agnostic engine parses both the CLI string (--run_spec) and the config form (run: { spec: { include: [...], exclude: [...] } }) into the same internalSpec, then resolves it to canonical plugin paths.Resolves #1744
Grammar
probes.<module>[.<Class>],buffs.<module>[.<Class>],probes.*none(orprobes.none) selects no probes — an explicit empty selection, distinct from an unspecified spec (which defaults toprobes.*)tier:<N>(inclusive threshold — tiers1..N),tag:<prefix>(membership)-(e.g.-probes.dan.DanInTheWild,-tier:3)probes.*), injected only at resolve time.What changed
New module
garak/_spec.py—Selector/Spec/Resolution+ parsing and resolution._resolve_plugin_pathsis the single shared resolution core. Anoneselector kind represents an explicit empty selection.garak/cli.py— adds--run_spec(underscore, consistent with garak's other flags such as--probe_tags/--list_probes);--probes/--probe_tags/--buffsare deprecated and map ontorun.spec(with--run_specwinning on conflict).garak/command.py—print_buffs()gains an optionalselected_buffsargument so--list_buffsmatching--list_probes/--list_detectors. Previously the buff listing ignored any selection and always listed every buff; called without the argument, behaviour is unchanged (lists all).garak/_config.py—run.specdefault; legacy config keys (plugins.probe_spec,plugins.buff_spec,run.probe_tags) map ontorun.specpost-merge (mirroringmodel_type→target_type).Report snapshot now carries
run.specinstead of the legacy keys.Downstream consumers (
report_digest.py,aggregate_reports.py) readrun.spec, with a fallback for reports predating this change.Bundled configs (
bag.yaml,fast.json) migrated torun.spec.Docs updated (
configurable.rst,usage.rst,faster.rst, new_spec.rst,cliref.rstregenerated from--help).Selection of "none" vs unspecified (standardized)
A single rule governs empty vs default selection, consistently across CLI and config:
none(e.g.--probes noneorprobe_spec: none) → explicit empty selection (probes.none); resolves to no probes. A run with no probes is a deliberate no-op ("No probes, nothing to do").auto) → unspecified; resolves to all active probes (probes.*).This restores the legacy meaning of
none(which selected nothing) while keeping the unified grammar's implicit default. The only behavior change vs the legacy flags is that--probes ""/--probes autonow default to all (they previously selected nothing); these are degenerate inputs and the new behavior is the more intuitive one.Deprecation
--probes/--probe_tags/--buffsandplugins.probe_spec/plugins.buff_spec/run.probe_tagsare deprecated (emit a deprecation notice). Detectors are out of scope here and keep their ownplugins.detector_specsurface, to be migrated at #1789.Examples
CLI
Config (YAML)
Manual — selection resolution
garak --list_probesgarak --list_probes --run_spec "probes.dan"garak --list_probes --run_spec "probes.none"→ 0 probes (default still lists all)garak --list_probes --run_spec "probes.dan.DanInTheWild"garak --list_probes --run_spec "probes.dan, -probes.dan.DanInTheWild"garak --list_probes --run_spec "tier:1"garak --list_probes --run_spec "tier:3, -tier:2"garak --list_probes --run_spec "tag:owasp:llm01"garak --list_buffs --run_spec "buffs.encoding"Manual — deprecation, conflict, errors
--probes noneis a deliberate no-op:garak -t test.Blank --probes none→ "No probes, nothing to do" (does not run all probes)--probesdeprecation maps to run.spec:garak --list_probes -p dan--probe_tagsdeprecation maps totag::garak --list_probes --probe_tags owasp:llm01--buffsdeprecation maps tobuffs.:garak --list_buffs -b encodingprobe_spec: noneselects nothing (parity with CLI);auto/empty default to all--run_specwins over legacy flag:garak --list_probes --run_spec "probes.dan" -p atkgengarak --list_probes --run_spec "detectors.foo"garak --list_probes --run_spec "probes.dan, -probes.dan"