Project Quarry
Project Quarry is a Python framework for detecting threats and behavior patterns in agent conversations. Write rules over messages, tool calls, tool results, and event order. You can also call a configured model adapter from a rule when local checks are not enough.
Quarry parses and validates rules when you load them, then compiles each rule to a symbolic finite-state automaton. A scan runs that compiled program over the conversation. Rules that cannot compile fail during loading.
Quarry is in alpha, and its DSL syntax may change before v1.0.0 in ways that require updates to existing rules.
Features
- Text, regular expressions (RE2), structured-field, and tool use checks
- Multi-turn flow rules, captures, counts, and typed policy parameters
- Optional configured model scoring, classification, completion, token counting, and spans
- Witness evidence, explain output, and typed collections for supported rules
- Sync and async Python APIs, plus human, JSON, and CSV CLI output
- Explicit input, compile, time, and model-call limits
Install
Quarry supports Python 3.11 through 3.13.
Setup:
git clone https://github.com/cisco-ai-defense/project-quarry.git
cd project-quarry
uv sync --frozen
Run uv sync --frozen --extra inference if your application uses a built-in model provider.
Quick start
Scan an example conversation from the repository root:
uv run --frozen quarry scan --config examples/config.yaml --target examples/data/benign.json
examples/config.yaml selects fourteen local rules that run without model credentials.
Four semantic rules use deterministic keyword stubs via an explicit config opt-in;
these stubs are for examples and tests, not production decisions.
To see a match, scan examples/data/tool_calls.json with the same
config. You can also target examples/data/ to scan every conversation file; a
successful scan with matches exits 1. The full example rule collection is exercised
by uv run --frozen python scripts/e2e_signature_test.py, which supplies deterministic
model and prober implementations in process.
A YAML configuration file loads your own rules:
config_version: 2
rules:
- rules/
For example, save this rule as rules/credential-request.rule:
rule "Credential request"
strings:
$terms = ["api key", "access token"] nocase
condition:
any msg in user_messages where msg.content contains_any $terms
Pass an OpenAI-shaped conversation as JSON with a messages array. The CLI exits 0 for a complete clean scan, 1 for a complete match, and 2 when the scan is invalid or incomplete.
Python API
from quarry import QuarryGuard
guard = QuarryGuard("config.yaml")
matches = guard.scan({"messages": [{"role": "user", "content": "Plan a picnic."}]})
for match in matches:
print(match["rule"], match["metadata"])
QuarryGuard raises on incomplete scans. DSLScanner returns a ScanResult so you can inspect completion status, evidence, and typed outputs. compile_policy prepares one reusable parameterized rule.
Documentation
- Getting started
- How Quarry works
- DSL guide and generated language reference
- Rule writing and string matching
- Configuration and message input
- Python API and parameters
- Model inference and application integration
- Agent plugin for Codex, Claude Code, and MCP hosts
- Architecture and testing
- Synthetic examples
See CONTRIBUTING.md to work on Quarry. Report security issues through SECURITY.md. Keep conversation data and credentials out of public issues.
License
Distributed under the Apache 2.0 License. See LICENSE for more
information.
Metadata
Release files for cisco-project-quarry 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cisco_project_quarry-0.1.0.tar.gz | 533.3 kB | With provenance | Details for cisco_project_quarry-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cisco_project_quarry-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cisco_project_quarry-0.1.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / cisco_project_quarry-0.1.0.tar.gz
| Download URL | cisco_project_quarry-0.1.0.tar.gz |
|---|---|
| Size | 533.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3682a9cbc5aa21edd7030e8af0a0696973a469f1ca84ab190e096f21ba8ec8f5
|
|
BLAKE2b-256 checksum How to use checksums |
6c478dd60b0216c04abc2d08048342bea5d42f9227bfb4f132a80fc84a414453
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / cisco_project_quarry-0.1.0-py3-none-any.whl
| Download URL | cisco_project_quarry-0.1.0-py3-none-any.whl |
|---|---|
| Size | 541.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ebd039e4c810a3a1a1c01f927d1105dcf87065e5ed7d55f341dd5e2eac84706
|
|
BLAKE2b-256 checksum How to use checksums |
4a495be1905b310fd139efab0f7dfce5428ddf6df8bf40c6382e43701c31838b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for cisco-project-quarry 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for cisco_project_quarry-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.