[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-106519":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":15,"stars7d":16,"stars30d":16,"stars90d":14,"forks30d":14,"starsTrendScore":17,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":20,"topics":22,"createdAt":9,"pushedAt":23,"updatedAt":24,"readmeContent":25,"aiSummary":9,"trendingCount":14,"starSnapshotCount":14,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},106519,"project-quarry","cisco-ai-defense\u002Fproject-quarry","cisco-ai-defense","Detection DSL and engine for AI agents",null,"Python",76,5,59,0,7,14,28,64.5,"Apache License 2.0",false,"main",[],"2026-10-29 19:11:05","2026-11-02 18:01:05","# Project Quarry\n\nProject 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.\n\nQuarry 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.\n\nQuarry is in alpha, and its DSL syntax may change before v1.0.0 in ways that require updates to existing rules.\n\n## Features\n\n- Text, regular expressions (RE2), structured-field, and tool use checks\n- Multi-turn flow rules, captures, counts, and typed policy parameters\n- Optional configured model scoring, classification, completion, token counting, and spans\n- Witness evidence, explain output, and typed collections for supported rules\n- Sync and async Python APIs, plus human, JSON, and CSV CLI output\n- Explicit input, compile, time, and model-call limits\n\n## Install\n\nQuarry supports Python 3.11 through 3.13.\n\n**Setup:**\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fcisco-ai-defense\u002Fproject-quarry.git\ncd project-quarry\nuv sync --frozen\n```\n\nRun `uv sync --frozen --extra inference` if your application uses a built-in model provider.\n\n## Quick start\n\nScan an example conversation from the repository root:\n\n```bash\nuv run --frozen quarry scan --config examples\u002Fconfig.yaml --target examples\u002Fdata\u002Fbenign.json\n```\n\n`examples\u002Fconfig.yaml` selects fourteen local rules that run without model credentials.\nFour semantic rules use deterministic keyword stubs via an explicit config opt-in; these stubs are for examples and tests, not production decisions.\n\nTo see a match, scan `examples\u002Fdata\u002Ftool_calls.json` with the same config. You can also target `examples\u002Fdata\u002F` to scan every conversation file; a successful scan with matches exits `1`.\n\nThe full example rule collection is exercised by `uv run --frozen python scripts\u002Fe2e_signature_test.py`, which supplies deterministic model and prober implementations in process.\n\nA YAML configuration file loads your own rules:\n\n```yaml\nconfig_version: 2\nrules:\n  - rules\u002F\n```\n\nFor example, save this rule as `rules\u002Fcredential-request.rule`:\n\n```text\nrule \"Credential request\"\nstrings:\n    $terms = [\"api key\", \"access token\"] nocase\ncondition:\n    any msg in user_messages where msg.content contains_any $terms\n```\n\nPass 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.\n\n## Rule Structure\n\nA `.rule` file contains one named rule. Quarry parses, validates, links, and compiles it when the scanner loads. The [generated language reference](quarry\u002Flanguage\u002Freference.md) lists current functions, fields, operators, and runnable examples.\n\n```text\nrule \"Suspicious request\"\nmetadata:\n    severity = \"medium\"\nstrings:\n    $blocked = [\"reveal a secret\", \"ignore the policy\"] nocase\nvariables:\n    has_blocked_text = any msg in user_messages where msg.content contains_any $blocked\ncondition:\n    has_blocked_text\n```\n\nOptional blocks appear in this order: `metadata`, `strings`, `variables`, `parameters`. Every rule needs `condition:`. A model span rule can also have a `collect:` block after `condition:`. Use `\u002F\u002F` for line comments; `#name` is the occurrence-count operator.\n\nUse `=` to define values in `metadata:`, `strings:`, and `variables:`. Use `==` to compare values in `condition:` expressions, including predicates inside `matches { ... }`. Other comparisons remain `!=`, `\u003C`, `\u003C=`, `>`, and `>=`.\n\n```text\nrule \"Shell call\"\nstrings:\n    $needle = \"sudo\"\ncondition:\n    any call in tool_calls where call.name == \"Bash\"\n       and $needle in call.arguments.*\n```\n\n## Python API\n\n```python\nfrom quarry import QuarryGuard\n\nguard = QuarryGuard(\"config.yaml\")\nmatches = guard.scan({\"messages\": [{\"role\": \"user\", \"content\": \"Plan a picnic.\"}]})\nfor match in matches:\n    print(match[\"rule\"], match[\"metadata\"])\n```\n\n`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.\n\n## Documentation\n\n- [Getting started](docs\u002Fgetting-started.md)\n- [How Quarry works](docs\u002Fhow-quarry-works.md)\n- [DSL guide](docs\u002Fdsl.md) and [generated language reference](quarry\u002Flanguage\u002Freference.md)\n- [Rule writing](docs\u002Frule-writing.md) and [string matching](docs\u002Fstring-matching.md)\n- [Configuration](docs\u002Fconfiguration.md) and [message input](docs\u002Fmessages.md)\n- [Python API](docs\u002Fpython-api.md) and [parameters](docs\u002Fparameters.md)\n- [Model inference](docs\u002Fmodel-inference.md) and [application integration](docs\u002Fintegration.md)\n- [Agent plugin](docs\u002FPLUGIN.md) for Codex, Claude Code, and MCP hosts\n- [Architecture](docs\u002Farchitecture.md) and [testing](docs\u002Ftesting.md)\n- [Synthetic examples](examples\u002FREADME.md)\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) to work on Quarry. Report security issues through [SECURITY.md](SECURITY.md). Keep conversation data and credentials out of public issues.\n\n## License\n\nDistributed under the `Apache 2.0` License. See [LICENSE](LICENSE) for more\ninformation.\n",2,"2026-11-03 04:32:10","CREATED_QUERY"]