Unrig
English | 简体中文
Anti-Tamper Gates, Freshness Verification, and Isolated Blind Review for Coding Agents.
Software engineering governance CLI (not affiliated with 3D rigging /
UniRig).
Coding agents rarely fail cleanly. Left unchecked on a failing check, agents frequently weaken assertions, skip skipped-test counters, edit gate configs, duplicate existing brownfield debt, or reuse stale test XML reports instead of fixing the underlying bug.
Unrig locks the verification boundary cleanly — 100% offline / zero telemetry / zero third-party runtime dependencies (Python >= 3.10 stdlib only) and non-invasive on brownfield repos (zero source-code marker annotations required).
Architecture at a Glance
Agent Tool Call (Write / Edit / Bash)
│
▼
┌─────────────────────────────┐ exit 2 / JSON deny (L0 writes, traversal, `> file`, `--no-verify`)
│ 1. `unrig hook` (L0 Guard)│────────────────────────────────────────────────► BLOCKED
└──────────────┬──────────────┘
│ exit 0 / allow
▼
┌─────────────────────────────┐
│ 2. `unrig verify` Referee │
│ • L0 Integrity │── git `-uall -z` + `HEAD:.unrig.yaml` union + CRLF-normalized SHA-256
│ • Format Comment Blanker │── 1:1 newline preservation (Py, JS/TS `/regex/`+`${}`, Vue, Java, Go, XML, SQL, SH, YAML)
│ • `CounterMultiset` Diff │── `(after - before)` stubs, `DUMMY-CONSTANT-RETURN`, `CLONE-SPAM`, `TYPE-ESCAPE`, suppressions, `.unrig/ratchet.json`
│ • JUnit & Coverage Proof │── `<testsuite>`/`<testsuites>`, freshness, `skipped == 0`, `skipped_ignored`/`syntax_fallback`/`SHALLOW_HISTORY`
└──────────────┬──────────────┘
│ [PASS]
▼
┌─────────────────────────────┐
│ 3. Blind Auditor `[🛑]` │ clean context, read-only diff review (no writer excuses leaked)
└─────────────────────────────┘
Why Unrig vs. Ordinary Linters / pre-commit?
| Failure Mode | Standard Linter / pre-commit |
Unrig |
|---|---|---|
Agent edits .unrig.yaml or --no-verify |
Bypassed cleanly | Blocked pre-write (unrig hook exit 2) + detected unstaged via -uall -z + HEAD union lock |
| Agent duplicates existing dirty debt in brownfield file | Ignored by line diffs or fails whole legacy file | Caught by CounterMultiset(after - before) without touching untouched legacy debt |
Agent weakens/skips tests (assert True, .only, skipped=1, @ts-ignore) |
Compiles & passes CI | Blocked by AST/lexical stub, focus, catch & suppression rules + forbid_skipped: true + method floors |
Agent submits old green junit.xml after editing code |
Passes file existence check | Blocked as [REPORT_STALE] (xml_mtime < max_source_mtime - 1s) |
Agent fakes passing stubs (return True, copy-paste test clones) |
Compiles & inflates green test counts | Blocked by DUMMY-CONSTANT-RETURN + incremental CLONE-SPAM (Alpha-Normalized diff clone check) |
| External runtime dependencies / cloud sync | Heavy install / cloud accounts | Zero third-party deps (Python stdlib only), 100% air-gapped, zero telemetry |
Quickstart
git clone https://github.com/Janson79jc/unrig.git
cd unrig
pip install -e .
# Or install directly without cloning:
# pip install git+https://github.com/Janson79jc/unrig.git
# 1. Initialize `.unrig.yaml` and `.unrig/` protocol/auditor templates
# (add `--client claude|antigravity|gemini|all` to generate client hook configs automatically)
unrig init
git add .unrig.yaml .unrig/ && git commit -m "chore: initialize unrig Level 0 gates"
# 2. Run verification referee
unrig verify
# 3. Check or tighten stale `.unrig/ratchet.json` caps as debt is paid down
unrig ratchet --check
unrig ratchet --prune
# 4. Inspect local interception ledger (recorded silently on blocks in `.unrig/.cache/events.jsonl`)
unrig stats --days 7
# 5. Verify Unrig's own referee against built-in escape mutations
unrig replay
# Optional: run the standalone escape-replay showcase
python examples/escape-replay/run_demo.py
Wiring unrig hook (PreToolUse / BeforeTool / Stop)
unrig hook auto-detects the caller protocol from stdin JSON (or via --client claude|antigravity|gemini):
- Claude Code (
.claude/settings.jsonviaunrig init --client claude): blocks with exit code2and prints the reason tostderr. - Google Antigravity (
.agents/hooks.jsonviaunrig init --client antigravity): responds onstdoutwith{"decision": "allow"}/{"decision": "deny", "reason": "..."}forPreToolUse(while allowing read-only tools), and gatesStopby runningunrig verify({"decision": "continue", "reason": "..."}up to 2 consecutive identical bounces, then releases cleanly for human escalation). - Google Gemini CLI (
.gemini/settings.jsonviaunrig init --client gemini): responds onstdoutwith{"decision": "allow"}/{"decision": "deny", "reason": "..."}forBeforeTool.
Example (.claude/settings.json):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit|MultiEdit|Bash",
"hooks": [
{
"type": "command",
"command": "unrig hook --client claude"
}
]
}
]
}
}
When any tool attempts to modify a path in protected_l0_files (including client hook configs .claude/settings.json, .agents/hooks.json, and .gemini/settings.json), even via ../ traversal, Windows backslashes, shell output redirections like > .unrig.yaml, or git ... commit/push --no-verify, unrig hook blocks it deterministically.
Defense-in-Depth Boundary:
unrig hookis the fast pre-execution guardrail against accidental edits and common bypasses at the agent tool layer;unrig verify(backed by git working-tree status,HEAD:.unrig.yamlunion locks, and CRLF-normalized hashes) is the deterministic backstop before acceptance or CI merge.
.unrig.yaml Reference
| Key | Default | Purpose |
|---|---|---|
version |
1 |
Schema version |
protected_l0_files |
[.unrig.yaml, .unrig/ratchet.json, .unrig/PROTOCOL.md, .unrig/blind_auditor_prompt.md, .claude/settings.json, .agents/hooks.json, .gemini/settings.json] |
Extra paths always merged with immutable L0 defaults + HEAD:.unrig.yaml |
reports.require_reports |
false |
Fail with [REPORT_MISSING] if no JUnit XML matches junit_globs |
reports.forbid_skipped |
true |
Fail if skipped > 0 in any JUnit XML |
reports.junit_globs |
Surefire / junit*.xml / test-results/*.xml |
Glob patterns for JUnit XML discovery |
reports.required_tests |
{} |
Map of suite_name: [method_a, ...] that must execute non-skipped |
reports.require_fresh_against |
[] |
Custom source globs for staleness timestamp check (defaults to all non-ignored source files) |
reports.privilege_log_tokens |
["--no-verify", "gate.mode=maintenance"] |
Tokens forbidden inside test XML logs / .txt outputs |
runtime_proof_artifacts |
[] |
List of {path, max_age_seconds} runtime artifacts verified fresh & non-empty |
diff_checks.enabled |
true |
Toggle CounterMultiset(after - before) incremental scan |
diff_checks.baseline |
"HEAD~1" |
Git revision baseline (HEAD fallback on single-commit repos; emits [WARN] [SHALLOW_HISTORY] on shallow clones) |
diff_checks.forbidden_patterns |
[] |
Team-specific {id, pattern, message, paths} rules matched against comment-blanked code |
diff_checks.clone_warn_threshold |
2 |
Net-new cross-file Alpha-Normalized isomorphic blocks before emitting [WARN] [CLONE-SPAM] |
diff_checks.clone_block_threshold |
3 |
Net-new cross-file Alpha-Normalized isomorphic blocks before blocking with [FAIL] [CLONE-SPAM] |
diff_checks.clone_min_tokens |
15 |
Minimum normalized token count for a block to participate in incremental clone detection |
ratchet_file |
".unrig/ratchet.json" |
JSON ledger requiring non-empty reason (>= 3 chars) per grandfathered cap |
shell_write_redirect_guards |
true |
Inspect shell tool commands in unrig hook for L0 redirects / --no-verify |
Air-Gapped & Privacy Guarantee
unrig makes zero network calls and contains zero telemetry. All configuration, ratchet ledgers, and verification runs stay strictly local on your machine.
Contributing, Agents & Security
- Contributors & AI Policy: Read CONTRIBUTING.md (human accountability + required PR AI disclosure aligned with modern open-source standards).
- Testing Guide & Rigor Standards: Read TESTING.md.
- Coding Agents Working on This Repo: Read AGENTS.md.
- Security & Escape Bypass Reports: Read SECURITY.md.
- Community Standards: Read CODE_OF_CONDUCT.md.
- License: Apache-2.0 — see CHANGELOG.md for release notes.
Metadata
Release files for unrig 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 |
|---|---|---|---|---|
| unrig-0.1.0.tar.gz | 72.3 kB | With provenance | Details for unrig-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| unrig-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for unrig-0.1.0-py3-none-any.whl |
Total release size: 128.4 kB
Release files / unrig-0.1.0.tar.gz
| Download URL | unrig-0.1.0.tar.gz |
|---|---|
| Size | 72.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3a469d6a0ff0d6c23527a1fbb039f02a7959b452fb94707e7c7bfe46995667d
|
|
BLAKE2b-256 checksum How to use checksums |
f200ba855c4bb158978c544de7e3d7bdc40db024b6ef2fed300752a9c02f9dab
|
| 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 Nov 23, 2026.
Transparency logRelease files / unrig-0.1.0-py3-none-any.whl
| Download URL | unrig-0.1.0-py3-none-any.whl |
|---|---|
| Size | 56.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b193c9fefffc33ac25a18b148ea669fdb08916cb646fa7e81aadc813dd739b9
|
|
BLAKE2b-256 checksum How to use checksums |
ae8aa6af6c481ff7220c485dec05e6807a03d28c9772f2629f1445c284c39159
|
| 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 Nov 23, 2026.
Transparency logSecurity for unrig 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
Both files in this release have been uploaded with provenance metadata.
Attestation for unrig-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 Nov 23, 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.