Bring Your Own Detector.
A development and debugging harness for jailbreak detectors, guards, and model-side safety policies.
Quick Start | Documentation | Notebooks | Examples | Ask DeepWiki | Community
About
Turnkey shortens the path from “I have a detector idea” to “I can run it, inspect what happened, and audit the result.” It gives detector authors one runtime for paired evaluation, typed model signals, inspectable event traces, and reproducible audit artifacts.
The first run is deliberately small: it runs on CPU, downloads no model, and requires no API key. GPU-backed methods and remote judges are optional layers, not prerequisites for understanding the system.
Core Features
- Bring your own detector: scaffold with
turnkey init, then loadpath.py:buildwithout forking Turnkey or editing a central registry. - Compare paired paths: evaluate the reference and intervention paths on the same selected and attacked input.
- Ask for model state: typed providers expose prompt logprobs, hidden states, gradients, and other method-owned signals with cache and lifecycle accounting.
- Debug the failure: connect a case to its policy, target, provider, timing, cache, and measured-forward events in the CLI or a standalone HTML report.
- Audit the claim: recompute metrics and verify redaction, source identity, event relationships, and public artifacts instead of trusting a summary.
- Start without infrastructure: the dummy backend and fixture dataset make the complete loop runnable without GPU access.
dataset -> attack -> target -> judge -> detector policy -> metrics -> audit
Quick Start
Install the packaged release from PyPI
with pip install turnkey, or install from source for development.
git clone https://github.com/lijrjyan/turnkey.git
cd turnkey
uv sync --extra dev
uv run turnkey run --config configs/runs/smoke.yaml
The run prints an output directory containing four public artifacts:
| Artifact | Purpose |
|---|---|
run.json |
Resolved configuration, source identity, and environment |
cases.jsonl |
Redacted paired reference/intervention outcomes |
events.jsonl |
Target, policy, provider, cache, and timing events |
metrics.json |
Safety, utility, and measured runtime cost |
Inspect one failure category and independently audit the bundle:
uv run turnkey inspect outputs/<run-id> --category missed_harm
uv run turnkey audit outputs/<run-id>
uv run turnkey report outputs/<run-id> --html report.html
An empty JSON list from turnkey audit means the bundle passed the current
artifact checks. It is not a claim that a detector is scientifically validated
or production-ready.
Start an external detector without copying boilerplate by hand:
uv run turnkey init my-detector
cd my-detector
uv run turnkey dev ./detector.py:build --max-samples 4
Docker
Run the same CPU smoke with nothing installed but Docker:
docker build -t turnkey https://github.com/lijrjyan/turnkey.git
docker run --rm -v "$PWD/outputs:/app/outputs" turnkey
The default command runs configs/runs/smoke.yaml and writes the four core
artifacts under outputs/. Any CLI invocation works the same way, for example
docker run --rm turnkey detector list. For GPU-backed HF models, build the
large image with --target full and run with --gpus all.
Included Method Examples
Turnkey includes compact integrations that exercise different runtime capabilities:
| Method | Signal or control pattern |
|---|---|
allow_all |
No-op baseline for pipeline and metric sanity |
keyword |
Local prompt rule for the first detector and CI smoke |
smoothllm |
Perturbation and repeated target calls |
jailguard |
Mutation and divergence |
gradsafe |
Gradient provider |
perplexity |
Typed prompt-logprob filter |
self_exam |
Output-side deterministic self-screening |
llamaguard |
Separate Llama Guard input classifier |
rcs_toy |
CPU-safe representation proxy |
rcs |
Hidden-state provider and calibration |
These integrations demonstrate the harness. They are not leaderboard results or claims of strict paper reproduction; original model, dataset, calibration, and license conditions still apply.
Documentation
Choose the shortest path for what you are trying to do:
| Goal | Guide |
|---|---|
| Install and verify the source checkout | Installation |
| Complete the first run-to-audit loop | Ten-minute quickstart |
| Add a detector without changing Turnkey | Build an external detector |
| Trace a missed or overblocked case | Debug a run |
| Understand policies and model signals | Runtime concepts |
| Compare model-based safety filters | Model-based filters |
| Learn the public artifact contract | Artifact concepts |
| Use the command line precisely | CLI reference |
| Learn interactively | Executable notebooks |
Build the complete local documentation site with:
uv sync --extra docs
uv run mkdocs serve
Development
Development happens on dev; main is the stable branch and only receives
reviewed changes.
uv sync --extra dev
uv run ruff check .
uv run pytest -q
uv run make smoke
Optional model and judge dependencies are isolated from the CPU-first path:
uv sync --extra dev --extra hf --extra judges
Community & Support
- Use GitHub Issues for confirmed bugs, documentation gaps, and scoped feature proposals.
- After the public repository has been indexed, use Ask DeepWiki to explore the architecture and ask code-grounded questions.
- Never include credentials, private prompts, unpublished datasets, or personal data in issues, logs, examples, or generated artifacts.
- Do not open a public issue for a vulnerability or suspected data leak. Use GitHub's private vulnerability reporting channel when it is available.
Project Status
Turnkey is an early source preview. Public interfaces, artifact schemas, and
method integrations can change before the first functional PyPI release. Pin a
Git commit for reproducible work and inspect the generated run.json before
comparing runs.
The README badge and .devin/wiki.json prepare DeepWiki integration, but the
free public index cannot read a private GitHub repository. Ask DeepWiki becomes
active after the formal repository is public and indexed; private indexing
requires a connected Devin account.
License
Turnkey is licensed under the Apache License 2.0. Third-party methods and datasets retain their own terms; see third_party/README.md.
Metadata
Release files for turnkey 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 | |
|---|---|---|---|
| turnkey-0.1.0.tar.gz | 291.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| turnkey-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 537.3 kB
Release files / turnkey-0.1.0.tar.gz
| Download URL | turnkey-0.1.0.tar.gz |
|---|---|
| Size | 291.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e10d6522434fc2add6114d6ccf5e4d1952dfbe7992d83ae10142425ffe9c2c75
|
|
BLAKE2b-256 checksum How to use checksums |
2860a54e0c0e0a384c3e4f00f5a183e07c0ffc70783c52c77d0cf9d322c66722
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Release files / turnkey-0.1.0-py3-none-any.whl
| Download URL | turnkey-0.1.0-py3-none-any.whl |
|---|---|
| Size | 246.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
260a519d751dc3b1783cdca5092dea9c3f61004fe673569004ee864c0104174b
|
|
BLAKE2b-256 checksum How to use checksums |
ab48de23f4ed8a260fd404f4082f57657b8bf837b72a5314569b28126d2eaab7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|