Metadata-Version: 2.5
Name: gfg-adr-detection
Version: 0.7.0
Summary: GFG packaging of ADR Detection (uber/ADR) for agentic security detection
Project-URL: Homepage, https://github.com/uber/ADR
Project-URL: Documentation, https://github.com/uber/ADR/tree/master/Detection
Project-URL: Repository, https://github.com/uber/ADR
Project-URL: Issues, https://github.com/uber/ADR/issues
Author: ADR Project Contributors, Global Fashion Group
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ai-agents,benchmark,mcp,security,threat-detection
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Requires-Python: <3.13,>=3.10
Requires-Dist: mcp<2,>=1.28.1
Requires-Dist: numpy>=1.26.2
Requires-Dist: openai<2,>=1.76.0
Requires-Dist: pyyaml>=6.0.2
Provides-Extra: baseline
Requires-Dist: llamafirewall>=1.0.3; extra == 'baseline'
Requires-Dist: torch>=2.13.0; extra == 'baseline'
Requires-Dist: transformers>=4.57.6; extra == 'baseline'
Provides-Extra: benchmark
Requires-Dist: anthropic>=0.25.0; extra == 'benchmark'
Requires-Dist: deepdiff<9,>=8.6.2; extra == 'benchmark'
Requires-Dist: docstring-parser==0.16; extra == 'benchmark'
Requires-Dist: google-cloud-aiplatform==1.71.1; extra == 'benchmark'
Requires-Dist: google-generativeai>=0.3.0; extra == 'benchmark'
Requires-Dist: ipython==8.12.3; extra == 'benchmark'
Requires-Dist: jsonref==1.1.0; extra == 'benchmark'
Requires-Dist: langchain-anthropic==0.3.1; extra == 'benchmark'
Requires-Dist: langchain-core<1.0,>=0.3.85; extra == 'benchmark'
Requires-Dist: langchain-google-genai==2.0.8; extra == 'benchmark'
Requires-Dist: langchain-openai==0.2.14; extra == 'benchmark'
Requires-Dist: langchain<0.4,>=0.3.30; extra == 'benchmark'
Requires-Dist: langgraph==0.2.60; extra == 'benchmark'
Requires-Dist: matplotlib>=3.7.0; extra == 'benchmark'
Requires-Dist: nemoguardrails==0.14.0; extra == 'benchmark'
Requires-Dist: openapi-pydantic==0.3.0; extra == 'benchmark'
Requires-Dist: proto-plus==1.28.2; extra == 'benchmark'
Requires-Dist: pydantic[email]>=2.11.3; extra == 'benchmark'
Requires-Dist: rich==13.9.4; extra == 'benchmark'
Requires-Dist: tenacity==9.0.0; extra == 'benchmark'
Requires-Dist: typing-extensions==4.12.2; extra == 'benchmark'
Provides-Extra: corpus
Requires-Dist: arxiv>=2.2.0; extra == 'corpus'
Requires-Dist: fastmcp>=0.1.0; extra == 'corpus'
Requires-Dist: markitdown[all]>=0.1.2; extra == 'corpus'
Requires-Dist: openpyxl>=3.1.5; extra == 'corpus'
Requires-Dist: psutil>=5.9.0; extra == 'corpus'
Requires-Dist: python-docx>=1.1.2; extra == 'corpus'
Requires-Dist: python-pptx>=1.0.2; extra == 'corpus'
Requires-Dist: requests>=2.33.0; extra == 'corpus'
Provides-Extra: dev
Requires-Dist: black>=26.5.1; extra == 'dev'
Requires-Dist: flake8>=6.0.0; extra == 'dev'
Requires-Dist: isort>=5.12.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Provides-Extra: notebook
Requires-Dist: jupyter>=1.0.0; extra == 'notebook'
Description-Content-Type: text/markdown

# gfg-adr-detection

A packaged, importable build of **ADR Detection** from
[uber/ADR](https://github.com/uber/ADR), maintained by Global Fashion Group for
internal use and published so it can be installed with `pip` rather than cloned.

**Not affiliated with or endorsed by Uber.** This is a modified redistribution
under the Apache License 2.0; the original copyright and `LICENSE` are retained.
For the upstream project, its paper and its benchmark, go to
[github.com/uber/ADR](https://github.com/uber/ADR).

## ⚠️ Not a general-purpose library

ADR Detection is a **research artifact** that parses hostile input and, in its
high-precision tier, spawns a nested agent with permission checks off. Run it in
a container, VM or dedicated host — not alongside your application.

Since 0.5.0 the *default* install is just the detector: four direct
dependencies (`mcp`, `openai`, `PyYAML`, `numpy`) and a closure of roughly 38
packages. The research stack is opt-in, and the CVE-bearing pins upstream
documents and accepts under an isolated threat model now live only in those
extras:

| Extra | What it adds | Why it is not default |
|-------|--------------|-----------------------|
| `baseline` | Meta's LlamaFirewall comparison: `llamafirewall`, `torch`, `transformers` and the NVIDIA CUDA wheels | Several GB. `guardrail` imports `llamafirewall` under `try/except`, so the detector runs without it. |
| `benchmark` | The frozen AgentDojo harness and the paper figures: the LangChain stack, `nemoguardrails`, `matplotlib` | Holds the exact `==` pins retained for reproducibility. These carry the known CVEs. |
| `corpus` | Dependencies of the ~200 deliberately vulnerable benchmark MCP servers | Fixtures only; the corpus is not shipped in the wheel. |

If you install `[benchmark]` or `[baseline]`, the old advice applies in full:
the `==` pins will conflict with most other packages, so give it a dedicated
virtualenv.

## 0.7.0

Security bumps inside the research extras: `langchain-core` 0.3.28 -> 0.3.86
clears a critical serialization-injection advisory, plus aiohttp, tornado,
langsmith, langchain, langchain-community, deepdiff and others. The default
install is unchanged -- same four runtime dependencies, same closure.

## Breaking in 0.6.0

The import package is `guardrail` again, not `adr_guardrail`. 0.4.0 and 0.5.0
shipped `adr_guardrail`; update imports:

```python
from guardrail.adr_agent.adr_baseline import ADRBaseline   # 0.6.0+
```

Note that PyPI's unrelated `guardrail` distribution also ships a top-level
`guardrail` package. Install this alongside it and one will shadow the other
with no error, so give this package a dedicated virtualenv.

## Breaking in 0.5.0

`pip install gfg-adr-detection` no longer installs `torch`, `transformers`, the
LangChain stack, `flask`, `spacy`, `nltk`, `opencv-python` or ~90 other packages
that nothing in the detector imports. Specifically:

- `LlamaFirewallBaseline` now needs `gfg-adr-detection[baseline]`. Without it,
  `is_available()` returns `False` and `main_detector.py --detector
  llamafirewall` exits with a message. Note that constructing the class directly
  only logs a warning, so check `is_available()`.
- Reproducing the benchmark from a checkout needs `uv sync --extra benchmark`.
- Running the corpus MCP servers needs `--extra corpus`.

## What this package changes

Upstream resolves its runtime data relative to `__file__`, three directories up —
which is the source tree in a checkout, and `site-packages` once installed. The
practical effect was that an installed copy discovered **zero** MCP context
providers and silently degraded from two detection tiers to one, with no error.
This build fixes that and the related path assumptions:

- context providers resolve from inside the package (`ADR_CONTEXT_PROVIDERS_DIR`
  overrides; the original layout is still honoured for source checkouts)
- the reasoning workspace is relocatable via `ADR_WORKSPACE_ROOT`, instead of
  being created inside `site-packages`
- MCP servers launch with `sys.executable` rather than `uv run`, which resolved
  an unrelated environment when installed as a wheel
- the dependency `axios` is dropped — it is a JavaScript library, and the PyPI
  project of that name is unrelated to it and to ADR
- the 16 MB benchmark corpus is not shipped, so the source-code context provider
  is disabled by default (`enable_source_code: false`)
- the dependency set is split: the detector's own runtime closure is the default
  install, and the benchmark harness, the LlamaFirewall baseline and the corpus
  fixtures are extras. Upstream declared all three as hard requirements, so
  installing the detector pulled ~199 packages to run code that imports four.
  About 35 of those declarations are imported nowhere in the tree at all.

## Install

```sh
python -m venv .venv && .venv/bin/pip install gfg-adr-detection
```

Requires Python 3.10–3.12. For the research extras:

```sh
pip install "gfg-adr-detection[benchmark]"   # AgentDojo harness + paper figures
pip install "gfg-adr-detection[baseline]"    # LlamaFirewall comparison (torch)
```

## Use

```python
from guardrail.adr_agent.adr_baseline import ADRBaseline

detector = ADRBaseline(config_data=config, benchmark_type="adr_bench")
verdict = detector.analyze_conversation(messages).to_dict()
```

`config` is the parsed `config_detector.yaml` structure documented upstream. The
high-precision tier shells out to the Claude CLI, which refuses to run as root —
so give the container an unprivileged user.

## Licence

Apache-2.0, as the original. See `LICENSE`.
