unrig 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
unrig-0.1.0/LICENSE ADDED
@@ -0,0 +1,194 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the Work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the Work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor, but excluding communication that is conspicuously marked or
59
+ otherwise designated in writing by the copyright owner as "Not a
60
+ Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated into the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, and trademark
102
+ notices from the Source form of the Work, excluding those
103
+ notices that do not pertain to any part of the Work; and
104
+
105
+ (d) If the Work includes a "NOTICE" text file as part of its
106
+ distribution, then any Derivative Works that You distribute must
107
+ include a copy of the Notice file in at least one of the
108
+ following places: within a NOTICE text file distributed as part
109
+ of the Derivative Works; within the Source form or
110
+ documentation, if provided along with the Derivative Works; or,
111
+ within a display generated by the Derivative Works, if and
112
+ wherever such third-party notices normally appear. The contents
113
+ of the NOTICE file are for informational purposes only and
114
+ do not modify the License. You may add Your own copyright
115
+ notice to Your own modifications and may provide additional
116
+ or different license terms and conditions for use, reproduction,
117
+ or distribution of Your own modifications, or for any such
118
+ Derivative Works as a whole, provided Your use, reproduction,
119
+ and distribution of the Work otherwise complies with the
120
+ conditions stated in this License.
121
+
122
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
123
+ any Contribution intentionally submitted for inclusion in the Work
124
+ by You to the Licensor shall be under the terms and conditions of
125
+ this License, without any additional terms or conditions.
126
+ Notwithstanding the above, nothing herein shall supersede or modify
127
+ the terms of any separate license agreement you may have executed
128
+ with Licensor regarding such Contributions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade
131
+ names, trademarks, service marks, or product names of the Licensor,
132
+ except as required for reasonable and customary use in describing the
133
+ origin of the Work and reproducing the notice file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or
136
+ agreed to in writing, Licensor provides the Work (and each
137
+ Contributor provides its Contributions) on an "AS IS" BASIS,
138
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
139
+ implied, including, but not limited to, any warranties or
140
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS
141
+ FOR A PARTICULAR PURPOSE. You are solely responsible for determining
142
+ the appropriateness of using or redistributing the Work and assume
143
+ any risks associated with Your exercise of permissions under this
144
+ License.
145
+
146
+ 8. Limitation of Liability. In no event and under no legal theory,
147
+ whether in tort (including negligence), contract, or otherwise,
148
+ unless required by applicable law (such as deliberate intent or
149
+ grossly negligent acts) or agreed to in writing, shall any
150
+ Contributor be liable to You for damages, including any direct,
151
+ indirect, special, incidental, or consequential damages of any
152
+ character arising as a result of this License or out of the use or
153
+ inability to use the Work (including but not limited to damages for
154
+ loss of goodwill, work stoppage, computer failure or malfunction, or
155
+ any and all other commercial damages or losses), even if such
156
+ Contributor has been advised of the possibility of such damages.
157
+
158
+ 9. Accepting Warranty or Additional Liability. While redistributing
159
+ the Work or Derivative Works thereof, You may choose to offer,
160
+ and charge a fee for, acceptance of support, warranty, indemnity,
161
+ or other liability obligations and/or rights consistent with this
162
+ License. However, in accepting such obligations, You may act only
163
+ on Your own behalf and on Your sole responsibility, not on behalf
164
+ of any other Contributor, and only if You agree to indemnify,
165
+ defend, and hold each Contributor harmless for any liability
166
+ incurred by, or claims asserted against, such Contributor by reason
167
+ of your accepting any such warranty or additional liability.
168
+
169
+ END OF TERMS AND CONDITIONS
170
+
171
+ APPENDIX: How to apply the Apache License to your work.
172
+
173
+ To apply the Apache License to your work, attach the following
174
+ boilerplate notice, with the fields enclosed by brackets "[]"
175
+ replaced with your own identifying information. (Don't include
176
+ the brackets!) The text should be enclosed in the appropriate
177
+ comment syntax for the file format. We also recommend that a
178
+ file or class name and description of purpose be included on the
179
+ same "printed page" as the copyright notice for easier
180
+ identification within third-party files.
181
+
182
+ Copyright 2026 Unrig Contributors
183
+
184
+ Licensed under the Apache License, Version 2.0 (the "License");
185
+ you may not use this file except in compliance with the License.
186
+ You may obtain a copy of the License at
187
+
188
+ http://www.apache.org/licenses/LICENSE-2.0
189
+
190
+ Unless required by applicable law or agreed to in writing, software
191
+ distributed under the License is distributed on an "AS IS" BASIS,
192
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
193
+ See the License for the specific language governing permissions and
194
+ limitations under the License.
unrig-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.4
2
+ Name: unrig
3
+ Version: 0.1.0
4
+ Summary: Anti-tamper gates, JUnit/diff verification, and isolated blind review templates for coding agents.
5
+ Author: Chen Jiang
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Janson79jc/unrig
8
+ Project-URL: Repository, https://github.com/Janson79jc/unrig
9
+ Project-URL: Issues, https://github.com/Janson79jc/unrig/issues
10
+ Project-URL: Changelog, https://github.com/Janson79jc/unrig/blob/main/CHANGELOG.md
11
+ Keywords: coding-agents,guardrails,anti-tamper,testing,verification,cli
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.0; extra == "dev"
28
+ Requires-Dist: setuptools>=68.0; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # Unrig
32
+
33
+ [![Unrig CI](https://github.com/Janson79jc/unrig/actions/workflows/ci.yml/badge.svg)](https://github.com/Janson79jc/unrig/actions/workflows/ci.yml)
34
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
35
+
36
+ **English** | [简体中文](README_zh.md)
37
+
38
+ **Anti-Tamper Gates, Freshness Verification, and Isolated Blind Review for Coding Agents.**
39
+
40
+ > Software engineering governance CLI (not affiliated with 3D rigging / `UniRig`).
41
+
42
+ 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.
43
+
44
+ **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).
45
+
46
+ ---
47
+
48
+ ## Architecture at a Glance
49
+
50
+ ```text
51
+ Agent Tool Call (Write / Edit / Bash)
52
+ │
53
+ ▼
54
+ ┌─────────────────────────────┐ exit 2 / JSON deny (L0 writes, traversal, `> file`, `--no-verify`)
55
+ │ 1. `unrig hook` (L0 Guard)│────────────────────────────────────────────────► BLOCKED
56
+ └──────────────┬──────────────┘
57
+ │ exit 0 / allow
58
+ ▼
59
+ ┌─────────────────────────────┐
60
+ │ 2. `unrig verify` Referee │
61
+ │ • L0 Integrity │── git `-uall -z` + `HEAD:.unrig.yaml` union + CRLF-normalized SHA-256
62
+ │ • Format Comment Blanker │── 1:1 newline preservation (Py, JS/TS `/regex/`+`${}`, Vue, Java, Go, XML, SQL, SH, YAML)
63
+ │ • `CounterMultiset` Diff │── `(after - before)` stubs, `DUMMY-CONSTANT-RETURN`, `CLONE-SPAM`, `TYPE-ESCAPE`, suppressions, `.unrig/ratchet.json`
64
+ │ • JUnit & Coverage Proof │── `<testsuite>`/`<testsuites>`, freshness, `skipped == 0`, `skipped_ignored`/`syntax_fallback`/`SHALLOW_HISTORY`
65
+ └──────────────┬──────────────┘
66
+ │ [PASS]
67
+ ▼
68
+ ┌─────────────────────────────┐
69
+ │ 3. Blind Auditor `[🛑]` │ clean context, read-only diff review (no writer excuses leaked)
70
+ └─────────────────────────────┘
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Why Unrig vs. Ordinary Linters / `pre-commit`?
76
+
77
+ | Failure Mode | Standard Linter / `pre-commit` | Unrig |
78
+ |---|---|---|
79
+ | Agent edits `.unrig.yaml` or `--no-verify` | Bypassed cleanly | Blocked pre-write (`unrig hook` exit `2`) + detected unstaged via `-uall -z` + `HEAD` union lock |
80
+ | 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 |
81
+ | 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 |
82
+ | Agent submits old green `junit.xml` after editing code | Passes file existence check | Blocked as `[REPORT_STALE]` (`xml_mtime < max_source_mtime - 1s`) |
83
+ | 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) |
84
+ | External runtime dependencies / cloud sync | Heavy install / cloud accounts | Zero third-party deps (Python stdlib only), 100% air-gapped, zero telemetry |
85
+
86
+ ---
87
+
88
+ ## Quickstart
89
+
90
+ ```bash
91
+ git clone https://github.com/Janson79jc/unrig.git
92
+ cd unrig
93
+ pip install -e .
94
+ # Or install directly without cloning:
95
+ # pip install git+https://github.com/Janson79jc/unrig.git
96
+
97
+ # 1. Initialize `.unrig.yaml` and `.unrig/` protocol/auditor templates
98
+ # (add `--client claude|antigravity|gemini|all` to generate client hook configs automatically)
99
+ unrig init
100
+ git add .unrig.yaml .unrig/ && git commit -m "chore: initialize unrig Level 0 gates"
101
+
102
+ # 2. Run verification referee
103
+ unrig verify
104
+
105
+ # 3. Check or tighten stale `.unrig/ratchet.json` caps as debt is paid down
106
+ unrig ratchet --check
107
+ unrig ratchet --prune
108
+
109
+ # 4. Inspect local interception ledger (recorded silently on blocks in `.unrig/.cache/events.jsonl`)
110
+ unrig stats --days 7
111
+
112
+ # 5. Verify Unrig's own referee against built-in escape mutations
113
+ unrig replay
114
+
115
+ # Optional: run the standalone escape-replay showcase
116
+ python examples/escape-replay/run_demo.py
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Wiring `unrig hook` (`PreToolUse` / `BeforeTool` / `Stop`)
122
+
123
+ `unrig hook` auto-detects the caller protocol from `stdin` JSON (or via `--client claude|antigravity|gemini`):
124
+
125
+ - **Claude Code** (`.claude/settings.json` via `unrig init --client claude`): blocks with exit code **`2`** and prints the reason to `stderr`.
126
+ - **Google Antigravity** (`.agents/hooks.json` via `unrig init --client antigravity`): responds on `stdout` with `{"decision": "allow"}` / `{"decision": "deny", "reason": "..."}` for `PreToolUse` (while allowing read-only tools), and gates `Stop` by running `unrig verify` (`{"decision": "continue", "reason": "..."}` up to 2 consecutive identical bounces, then releases cleanly for human escalation).
127
+ - **Google Gemini CLI** (`.gemini/settings.json` via `unrig init --client gemini`): responds on `stdout` with `{"decision": "allow"}` / `{"decision": "deny", "reason": "..."}` for `BeforeTool`.
128
+
129
+ Example (`.claude/settings.json`):
130
+
131
+ ```json
132
+ {
133
+ "hooks": {
134
+ "PreToolUse": [
135
+ {
136
+ "matcher": "Write|Edit|MultiEdit|Bash",
137
+ "hooks": [
138
+ {
139
+ "type": "command",
140
+ "command": "unrig hook --client claude"
141
+ }
142
+ ]
143
+ }
144
+ ]
145
+ }
146
+ }
147
+ ```
148
+
149
+ 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.
150
+
151
+ > **Defense-in-Depth Boundary**: `unrig hook` is 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.yaml` union locks, and CRLF-normalized hashes) is the deterministic backstop before acceptance or CI merge.
152
+
153
+ ---
154
+
155
+ ## `.unrig.yaml` Reference
156
+
157
+ | Key | Default | Purpose |
158
+ |---|---|---|
159
+ | `version` | `1` | Schema version |
160
+ | `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` |
161
+ | `reports.require_reports` | `false` | Fail with `[REPORT_MISSING]` if no JUnit XML matches `junit_globs` |
162
+ | `reports.forbid_skipped` | `true` | Fail if `skipped > 0` in any JUnit XML |
163
+ | `reports.junit_globs` | Surefire / `junit*.xml` / `test-results/*.xml` | Glob patterns for JUnit XML discovery |
164
+ | `reports.required_tests` | `{}` | Map of `suite_name: [method_a, ...]` that must execute non-skipped |
165
+ | `reports.require_fresh_against` | `[]` | Custom source globs for staleness timestamp check (defaults to all non-ignored source files) |
166
+ | `reports.privilege_log_tokens` | `["--no-verify", "gate.mode=maintenance"]` | Tokens forbidden inside test XML logs / `.txt` outputs |
167
+ | `runtime_proof_artifacts` | `[]` | List of `{path, max_age_seconds}` runtime artifacts verified fresh & non-empty |
168
+ | `diff_checks.enabled` | `true` | Toggle `CounterMultiset(after - before)` incremental scan |
169
+ | `diff_checks.baseline` | `"HEAD~1"` | Git revision baseline (`HEAD` fallback on single-commit repos; emits `[WARN] [SHALLOW_HISTORY]` on shallow clones) |
170
+ | `diff_checks.forbidden_patterns` | `[]` | Team-specific `{id, pattern, message, paths}` rules matched against comment-blanked code |
171
+ | `diff_checks.clone_warn_threshold` | `2` | Net-new cross-file `Alpha-Normalized` isomorphic blocks before emitting `[WARN] [CLONE-SPAM]` |
172
+ | `diff_checks.clone_block_threshold` | `3` | Net-new cross-file `Alpha-Normalized` isomorphic blocks before blocking with `[FAIL] [CLONE-SPAM]` |
173
+ | `diff_checks.clone_min_tokens` | `15` | Minimum normalized token count for a block to participate in incremental clone detection |
174
+ | `ratchet_file` | `".unrig/ratchet.json"` | JSON ledger requiring non-empty `reason` (>= 3 chars) per grandfathered cap |
175
+ | `shell_write_redirect_guards` | `true` | Inspect shell tool commands in `unrig hook` for L0 redirects / `--no-verify` |
176
+
177
+ ---
178
+
179
+ ## Air-Gapped & Privacy Guarantee
180
+
181
+ `unrig` makes **zero network calls** and contains **zero telemetry**. All configuration, ratchet ledgers, and verification runs stay strictly local on your machine.
182
+
183
+ ---
184
+
185
+ ## Contributing, Agents & Security
186
+
187
+ - **Contributors & AI Policy**: Read [CONTRIBUTING.md](CONTRIBUTING.md) (human accountability + required PR AI disclosure aligned with modern open-source standards).
188
+ - **Testing Guide & Rigor Standards**: Read [TESTING.md](TESTING.md).
189
+ - **Coding Agents Working on This Repo**: Read [AGENTS.md](AGENTS.md).
190
+ - **Security & Escape Bypass Reports**: Read [SECURITY.md](SECURITY.md).
191
+ - **Community Standards**: Read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
192
+ - **License**: [Apache-2.0](LICENSE) — see [CHANGELOG.md](CHANGELOG.md) for release notes.
unrig-0.1.0/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # Unrig
2
+
3
+ [![Unrig CI](https://github.com/Janson79jc/unrig/actions/workflows/ci.yml/badge.svg)](https://github.com/Janson79jc/unrig/actions/workflows/ci.yml)
4
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
5
+
6
+ **English** | [简体中文](README_zh.md)
7
+
8
+ **Anti-Tamper Gates, Freshness Verification, and Isolated Blind Review for Coding Agents.**
9
+
10
+ > Software engineering governance CLI (not affiliated with 3D rigging / `UniRig`).
11
+
12
+ 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.
13
+
14
+ **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).
15
+
16
+ ---
17
+
18
+ ## Architecture at a Glance
19
+
20
+ ```text
21
+ Agent Tool Call (Write / Edit / Bash)
22
+ │
23
+ ▼
24
+ ┌─────────────────────────────┐ exit 2 / JSON deny (L0 writes, traversal, `> file`, `--no-verify`)
25
+ │ 1. `unrig hook` (L0 Guard)│────────────────────────────────────────────────► BLOCKED
26
+ └──────────────┬──────────────┘
27
+ │ exit 0 / allow
28
+ ▼
29
+ ┌─────────────────────────────┐
30
+ │ 2. `unrig verify` Referee │
31
+ │ • L0 Integrity │── git `-uall -z` + `HEAD:.unrig.yaml` union + CRLF-normalized SHA-256
32
+ │ • Format Comment Blanker │── 1:1 newline preservation (Py, JS/TS `/regex/`+`${}`, Vue, Java, Go, XML, SQL, SH, YAML)
33
+ │ • `CounterMultiset` Diff │── `(after - before)` stubs, `DUMMY-CONSTANT-RETURN`, `CLONE-SPAM`, `TYPE-ESCAPE`, suppressions, `.unrig/ratchet.json`
34
+ │ • JUnit & Coverage Proof │── `<testsuite>`/`<testsuites>`, freshness, `skipped == 0`, `skipped_ignored`/`syntax_fallback`/`SHALLOW_HISTORY`
35
+ └──────────────┬──────────────┘
36
+ │ [PASS]
37
+ ▼
38
+ ┌─────────────────────────────┐
39
+ │ 3. Blind Auditor `[🛑]` │ clean context, read-only diff review (no writer excuses leaked)
40
+ └─────────────────────────────┘
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Why Unrig vs. Ordinary Linters / `pre-commit`?
46
+
47
+ | Failure Mode | Standard Linter / `pre-commit` | Unrig |
48
+ |---|---|---|
49
+ | Agent edits `.unrig.yaml` or `--no-verify` | Bypassed cleanly | Blocked pre-write (`unrig hook` exit `2`) + detected unstaged via `-uall -z` + `HEAD` union lock |
50
+ | 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 |
51
+ | 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 |
52
+ | Agent submits old green `junit.xml` after editing code | Passes file existence check | Blocked as `[REPORT_STALE]` (`xml_mtime < max_source_mtime - 1s`) |
53
+ | 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) |
54
+ | External runtime dependencies / cloud sync | Heavy install / cloud accounts | Zero third-party deps (Python stdlib only), 100% air-gapped, zero telemetry |
55
+
56
+ ---
57
+
58
+ ## Quickstart
59
+
60
+ ```bash
61
+ git clone https://github.com/Janson79jc/unrig.git
62
+ cd unrig
63
+ pip install -e .
64
+ # Or install directly without cloning:
65
+ # pip install git+https://github.com/Janson79jc/unrig.git
66
+
67
+ # 1. Initialize `.unrig.yaml` and `.unrig/` protocol/auditor templates
68
+ # (add `--client claude|antigravity|gemini|all` to generate client hook configs automatically)
69
+ unrig init
70
+ git add .unrig.yaml .unrig/ && git commit -m "chore: initialize unrig Level 0 gates"
71
+
72
+ # 2. Run verification referee
73
+ unrig verify
74
+
75
+ # 3. Check or tighten stale `.unrig/ratchet.json` caps as debt is paid down
76
+ unrig ratchet --check
77
+ unrig ratchet --prune
78
+
79
+ # 4. Inspect local interception ledger (recorded silently on blocks in `.unrig/.cache/events.jsonl`)
80
+ unrig stats --days 7
81
+
82
+ # 5. Verify Unrig's own referee against built-in escape mutations
83
+ unrig replay
84
+
85
+ # Optional: run the standalone escape-replay showcase
86
+ python examples/escape-replay/run_demo.py
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Wiring `unrig hook` (`PreToolUse` / `BeforeTool` / `Stop`)
92
+
93
+ `unrig hook` auto-detects the caller protocol from `stdin` JSON (or via `--client claude|antigravity|gemini`):
94
+
95
+ - **Claude Code** (`.claude/settings.json` via `unrig init --client claude`): blocks with exit code **`2`** and prints the reason to `stderr`.
96
+ - **Google Antigravity** (`.agents/hooks.json` via `unrig init --client antigravity`): responds on `stdout` with `{"decision": "allow"}` / `{"decision": "deny", "reason": "..."}` for `PreToolUse` (while allowing read-only tools), and gates `Stop` by running `unrig verify` (`{"decision": "continue", "reason": "..."}` up to 2 consecutive identical bounces, then releases cleanly for human escalation).
97
+ - **Google Gemini CLI** (`.gemini/settings.json` via `unrig init --client gemini`): responds on `stdout` with `{"decision": "allow"}` / `{"decision": "deny", "reason": "..."}` for `BeforeTool`.
98
+
99
+ Example (`.claude/settings.json`):
100
+
101
+ ```json
102
+ {
103
+ "hooks": {
104
+ "PreToolUse": [
105
+ {
106
+ "matcher": "Write|Edit|MultiEdit|Bash",
107
+ "hooks": [
108
+ {
109
+ "type": "command",
110
+ "command": "unrig hook --client claude"
111
+ }
112
+ ]
113
+ }
114
+ ]
115
+ }
116
+ }
117
+ ```
118
+
119
+ 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.
120
+
121
+ > **Defense-in-Depth Boundary**: `unrig hook` is 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.yaml` union locks, and CRLF-normalized hashes) is the deterministic backstop before acceptance or CI merge.
122
+
123
+ ---
124
+
125
+ ## `.unrig.yaml` Reference
126
+
127
+ | Key | Default | Purpose |
128
+ |---|---|---|
129
+ | `version` | `1` | Schema version |
130
+ | `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` |
131
+ | `reports.require_reports` | `false` | Fail with `[REPORT_MISSING]` if no JUnit XML matches `junit_globs` |
132
+ | `reports.forbid_skipped` | `true` | Fail if `skipped > 0` in any JUnit XML |
133
+ | `reports.junit_globs` | Surefire / `junit*.xml` / `test-results/*.xml` | Glob patterns for JUnit XML discovery |
134
+ | `reports.required_tests` | `{}` | Map of `suite_name: [method_a, ...]` that must execute non-skipped |
135
+ | `reports.require_fresh_against` | `[]` | Custom source globs for staleness timestamp check (defaults to all non-ignored source files) |
136
+ | `reports.privilege_log_tokens` | `["--no-verify", "gate.mode=maintenance"]` | Tokens forbidden inside test XML logs / `.txt` outputs |
137
+ | `runtime_proof_artifacts` | `[]` | List of `{path, max_age_seconds}` runtime artifacts verified fresh & non-empty |
138
+ | `diff_checks.enabled` | `true` | Toggle `CounterMultiset(after - before)` incremental scan |
139
+ | `diff_checks.baseline` | `"HEAD~1"` | Git revision baseline (`HEAD` fallback on single-commit repos; emits `[WARN] [SHALLOW_HISTORY]` on shallow clones) |
140
+ | `diff_checks.forbidden_patterns` | `[]` | Team-specific `{id, pattern, message, paths}` rules matched against comment-blanked code |
141
+ | `diff_checks.clone_warn_threshold` | `2` | Net-new cross-file `Alpha-Normalized` isomorphic blocks before emitting `[WARN] [CLONE-SPAM]` |
142
+ | `diff_checks.clone_block_threshold` | `3` | Net-new cross-file `Alpha-Normalized` isomorphic blocks before blocking with `[FAIL] [CLONE-SPAM]` |
143
+ | `diff_checks.clone_min_tokens` | `15` | Minimum normalized token count for a block to participate in incremental clone detection |
144
+ | `ratchet_file` | `".unrig/ratchet.json"` | JSON ledger requiring non-empty `reason` (>= 3 chars) per grandfathered cap |
145
+ | `shell_write_redirect_guards` | `true` | Inspect shell tool commands in `unrig hook` for L0 redirects / `--no-verify` |
146
+
147
+ ---
148
+
149
+ ## Air-Gapped & Privacy Guarantee
150
+
151
+ `unrig` makes **zero network calls** and contains **zero telemetry**. All configuration, ratchet ledgers, and verification runs stay strictly local on your machine.
152
+
153
+ ---
154
+
155
+ ## Contributing, Agents & Security
156
+
157
+ - **Contributors & AI Policy**: Read [CONTRIBUTING.md](CONTRIBUTING.md) (human accountability + required PR AI disclosure aligned with modern open-source standards).
158
+ - **Testing Guide & Rigor Standards**: Read [TESTING.md](TESTING.md).
159
+ - **Coding Agents Working on This Repo**: Read [AGENTS.md](AGENTS.md).
160
+ - **Security & Escape Bypass Reports**: Read [SECURITY.md](SECURITY.md).
161
+ - **Community Standards**: Read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
162
+ - **License**: [Apache-2.0](LICENSE) — see [CHANGELOG.md](CHANGELOG.md) for release notes.
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "unrig"
7
+ version = "0.1.0"
8
+ description = "Anti-tamper gates, JUnit/diff verification, and isolated blind review templates for coding agents."
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ authors = [{ name = "Chen Jiang" }]
12
+ keywords = ["coding-agents", "guardrails", "anti-tamper", "testing", "verification", "cli"]
13
+ requires-python = ">=3.10"
14
+ dependencies = []
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Environment :: Console",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: Apache Software License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Topic :: Software Development :: Quality Assurance",
26
+ "Topic :: Software Development :: Testing",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/Janson79jc/unrig"
31
+ Repository = "https://github.com/Janson79jc/unrig"
32
+ Issues = "https://github.com/Janson79jc/unrig/issues"
33
+ Changelog = "https://github.com/Janson79jc/unrig/blob/main/CHANGELOG.md"
34
+
35
+ [project.scripts]
36
+ unrig = "unrig.cli:main"
37
+
38
+ [project.optional-dependencies]
39
+ dev = ["pytest>=8.0", "setuptools>=68.0"]
40
+
41
+ [tool.setuptools]
42
+ package-dir = { "" = "src" }
43
+
44
+ [tool.setuptools.packages.find]
45
+ where = ["src"]
46
+
47
+ [tool.setuptools.package-data]
48
+ unrig = ["templates/*"]
49
+
50
+ [tool.pytest.ini_options]
51
+ pythonpath = ["src"]
52
+ testpaths = ["tests"]
unrig-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ """Unrig — Anti-tamper gates and isolated review for coding agents."""
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["__version__"]