Skip to content

Commit 6b8151c

Browse files
Merge branch 'feature/technique_intent' into feature/unified-run-spec
2 parents 6130826 + d656d62 commit 6b8151c

85 files changed

Lines changed: 3283 additions & 659 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,71 @@
1-
# garak - generative AI red-teaming and assessment toolkit
1+
# Agent instructions for garak - generative AI red-teaming and assessment toolkit
2+
3+
> These instructions apply to **all** AI-assisted contributions to `nvidia/garak`.
4+
> Breaching these guidelines can result in automatic banning.
25
36
This is tooling for adversarial assessment of LLMs and LLM-powered tools.
47
It's open source software, used in production environments, with an active and skilled community
58
As such, the code needs to be robust, precise, and responsible.
69
Due to the nature of the project, there is a lot of potentially harmful or dangerous data associated with the repository.
710

8-
## Coding guide
9-
- Read the documentation in `docs/`, especially the content on extending garak.
10-
- Avoid adding new dependencies.
11+
## Contribution policy
12+
13+
### Duplicate-work checks
14+
15+
Before proposing a PR, run these checks:
16+
17+
```bash
18+
gh issue view <issue_number> --repo nvidia/garak --comments
19+
gh pr list --repo nvidia/garak --state open --search "<issue_number> in:body"
20+
gh pr list --repo nvidia/garak --state open --search "<short area keywords>"
21+
```
22+
23+
- If an open PR already addresses the same fix, do not open another.
24+
- If your approach is materially different, explain the difference in the issue.
25+
26+
### No low-value busywork PRs
27+
28+
Do not open one-off PRs for tiny edits (single typo, isolated style change, one mutable default, etc.). Mechanical cleanups are acceptable only when bundled with substantive work.
29+
30+
### Cohesive PRs
31+
32+
Each PR should have a clear focus. Only update files related to the topic of that PR.
33+
34+
### Accountability
35+
36+
- Pure code-agent PRs are **not allowed**. A human submitter must understand and defend the change end-to-end.
37+
- The submitting human must review every changed line and run relevant tests.
38+
- PR descriptions for AI-assisted work **must** include:
39+
- Why this is not duplicating an existing PR.
40+
- Test commands run and results.
41+
- Clear statement that AI assistance was used.
42+
43+
### Fail-closed behavior
44+
45+
If work is duplicate/trivial busywork, **do not proceed**. Return a short explanation of what is missing.
46+
47+
### Project Guides
48+
49+
Check the docs on "Contributing" and "Extending", in `docs/source`, and follow these.
50+
51+
### Commit messages
52+
53+
Add attribution using commit trailers such as `Co-authored-by:` (other projects use `Assisted-by:` or `Generated-by:`). For example:
54+
55+
```text
56+
Your commit message here
57+
58+
Co-authored-by: GitHub Copilot
59+
Co-authored-by: Claude
60+
Co-authored-by: gemini-code-assist
61+
Signed-off-by: Your Name <your.email@example.com>
62+
```
63+
64+
65+
## Development requirements
66+
67+
### Coding guide
68+
- Always avoid adding new dependencies. Use the `extra_dependency_names` functionality if essential.
1169
- Keep documentation of garak architecture in the docs/ dir up to date - though use docstrings in the first instance if possible.
1270
- When working on probes, detectors, or buffs, be sure to check the content of the relevant `doc_uri` to understand the code's intent and the underlying technique.
1371
- Use the payloads, data, and services mechanisms when suitable.
@@ -17,21 +75,25 @@ Due to the nature of the project, there is a lot of potentially harmful or dange
1775
- Comply with docstring requirements - see the docs and also `tests/test_docs.py`.
1876
- Catch specific exception types; avoid `except Exception` and bare `except:`.
1977

20-
## Dev environment tips
78+
### Dev environment tips
2179
- Use (and expect) only Python versions specified in `pyproject.toml`.
2280
- Be sure you're using the right environment, with the right dependencies. Virtual environment management is preferred.
2381

24-
## Testing instructions
82+
### Testing instructions
2583
- Don't break existing tests.
2684
- Add tests as you go.
2785
- Tests for specific modules should go in a new file. For example, tests for `garak.probes.xyz` should go in `tests/probes/test_probe_xyz.py`.
2886
- ARM, x86, and Windows all need to be supported - check the list of supported architectures in `pyproject.toml`.
87+
- Don't add tests for default values given in configurable plugins.
88+
- Don't add tests for functionality already covered by tests of parent classes.
89+
- Add descriptive strings to asserts, explaining the expect underlying behaviour; be terse.
90+
- Check that tests work. If `pytest` or other project dependencies are not available, the environment has not been set up correctly; give the user this problem.
2991

30-
## Code primitives
92+
### Code primitives
3193
- Avoid updating `attempt` or any base classes (`probes.base.*`, `generators.base.*`, `detectors.base.*`) frivolously.
3294
- Consider using a service for content to be available across all of garak over a whole run.
3395

34-
## Style
96+
### Style
3597
- Comply with any repository formatting and linting config in `pyproject.toml`.
3698
- Don't include default values in docstrings; the code is the documentation for these.
3799
- Follow the visual design language of CLI output, including emojis and colour changes where in line with existing style.

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,5 @@
179179
import os
180180
import sys
181181

182-
sys.path.insert(0, "../..")
182+
sys.path.insert(0, os.path.abspath("../.."))
183183
sys.path.append(os.path.abspath("./_ext"))

docs/source/extending.probe.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ From the base class:
9595
tags: Iterable[str] = []
9696
# what the probe is trying to do, phrased as an imperative
9797
goal: str = ""
98+
# the target behaviour / failure mode this probe elicits,
99+
# as a code from the trait typology (garak/data/cas/trait_typology.json).
100+
# Propagated to every Attempt minted by the probe.
101+
intent: Union[str, None] = None
98102
# Deprecated -- the detectors that should be run for this probe. always.Fail is chosen as default to send a signal if this isn't overridden.
99103
recommended_detector: Iterable[str] = ["always.Fail"]
100104
# default detector to run, if the primary/extended way of doing it is to be used (should be a string formatted like recommended_detector)
@@ -118,6 +122,7 @@ Many of these are decent defaults, though there are a few that we absolutely wan
118122
* ``active``: Should this probe be part of default scans?
119123
* ``tags``: MISP-formatted taxonomy categories __e.g.__ ``["avid-effect:security:S0403", "owasp:llm01", "quality:Security:PromptStability", "payload:jailbreak"]``
120124
* ``goal``: What is the probe trying to do? __e.g.__ ``"disregard the system prompt"``
125+
* ``intent``: Which target behaviour / failure mode does this probe elicit? Must be a code from ``garak/data/cas/trait_typology.json`` __e.g.__ ``"T009ignore"``. The value is automatically propagated to every ``Attempt`` the probe creates. If the probe loads a payload that also declares an ``intent``, the payload's intent takes priority.
121126
* ``primary_detector``: What ``Detector`` should your probe use?
122127

123128
.. code-block:: python
@@ -133,6 +138,7 @@ Many of these are decent defaults, though there are a few that we absolutely wan
133138
"payload:jailbreak",
134139
]
135140
goal = "disregard the system prompt"
141+
intent = "T009ignore" # the target behaviour elicited, from trait_typology.json
136142
doc_uri = "https://garak.ai"
137143
active = False
138144
...

docs/source/generators/llm.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
garak.generators.llm
2+
====================
3+
4+
Wraps Simon Willison's ``llm`` library, which provides a unified interface
5+
to many LLM providers (OpenAI, Claude, Gemini, Ollama, etc.) via plugins.
6+
7+
API keys and provider setup are managed by ``llm`` directly. Install the
8+
base package and any provider plugins you need:
9+
10+
.. code-block:: bash
11+
12+
pip install llm llm-claude-3
13+
14+
Then invoke garak with the ``llm`` model id:
15+
16+
.. code-block:: bash
17+
18+
garak --model_type llm --model_name gpt-4o-mini
19+
20+
.. automodule:: garak.generators.llm
21+
:members:
22+
:undoc-members:
23+
:show-inheritance:

docs/source/index_generators.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ For a detailed oversight into how a generator operates, see :doc:`generators/bas
2020
generators/langchain
2121
generators/langchain_serve
2222
generators/litellm
23+
generators/llm
2324
generators/mistral
2425
generators/ollama
2526
generators/openai

docs/source/payloads.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The JSON structure of a payload is:
2525
"garak_payload_name": // a mandatory key, used to identify this as a garak payload. holds a description of the payload.
2626
"payload_types": // a list of strings, each identifying an entry in the payload typology (typology_payloads.tsv)
2727
["Security circumvention instructions/Product activation codes"],
28+
"intent": "S003productkeys", // optional; a code from the trait typology (garak/data/cas/trait_typology.json) describing the target behaviour these payloads are designed to elicit. When set, probes using this payload will propagate the intent to each Attempt, overriding the probe's default intent.
2829
"detector_name": "productkey.Win5x5", // a suggested detector
2930
"detector_config": {}, // a config dict of Configurable options for the detector
3031
"payloads": [ // a list of strings: the payloads themselves

0 commit comments

Comments
 (0)