governed-agent 0.1.3__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.
Files changed (26) hide show
  1. governed_agent-0.1.3/LICENSE +21 -0
  2. governed_agent-0.1.3/PKG-INFO +242 -0
  3. governed_agent-0.1.3/README.md +221 -0
  4. governed_agent-0.1.3/pyproject.toml +38 -0
  5. governed_agent-0.1.3/setup.cfg +4 -0
  6. governed_agent-0.1.3/src/governed_agent/__init__.py +72 -0
  7. governed_agent-0.1.3/src/governed_agent/audit/__init__.py +5 -0
  8. governed_agent-0.1.3/src/governed_agent/audit/watchtower.py +361 -0
  9. governed_agent-0.1.3/src/governed_agent/capability/__init__.py +57 -0
  10. governed_agent-0.1.3/src/governed_agent/capability/antirollback.py +390 -0
  11. governed_agent-0.1.3/src/governed_agent/capability/crypto.py +443 -0
  12. governed_agent-0.1.3/src/governed_agent/hermes/__init__.py +5 -0
  13. governed_agent-0.1.3/src/governed_agent/hermes/boundary.py +93 -0
  14. governed_agent-0.1.3/src/governed_agent/planning/__init__.py +21 -0
  15. governed_agent-0.1.3/src/governed_agent/planning/blink.py +273 -0
  16. governed_agent-0.1.3/src/governed_agent.egg-info/PKG-INFO +242 -0
  17. governed_agent-0.1.3/src/governed_agent.egg-info/SOURCES.txt +24 -0
  18. governed_agent-0.1.3/src/governed_agent.egg-info/dependency_links.txt +1 -0
  19. governed_agent-0.1.3/src/governed_agent.egg-info/requires.txt +6 -0
  20. governed_agent-0.1.3/src/governed_agent.egg-info/top_level.txt +1 -0
  21. governed_agent-0.1.3/tests/test_audit.py +222 -0
  22. governed_agent-0.1.3/tests/test_capability.py +141 -0
  23. governed_agent-0.1.3/tests/test_coverage_expansion.py +313 -0
  24. governed_agent-0.1.3/tests/test_hermes.py +112 -0
  25. governed_agent-0.1.3/tests/test_planning.py +74 -0
  26. governed_agent-0.1.3/tests/test_security_regressions.py +288 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jtevesnz-sys
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: governed-agent
3
+ Version: 0.1.3
4
+ Summary: Cryptographic capability sealing, scope-bounded planning, and independent audit for LLM agents
5
+ Author-email: jtevesnz-sys <jtevesnz-sys@users.noreply.github.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/jtevesnz-sys/governed-agent
8
+ Project-URL: Documentation, https://github.com/jtevesnz-sys/governed-agent/blob/main/WHITE_PAPER.md
9
+ Project-URL: Repository, https://github.com/jtevesnz-sys/governed-agent.git
10
+ Project-URL: Issues, https://github.com/jtevesnz-sys/governed-agent/issues
11
+ Project-URL: Discussions, https://github.com/jtevesnz-sys/governed-agent/discussions
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: cryptography>=42.0.0
16
+ Requires-Dist: pydantic>=2.0.0
17
+ Provides-Extra: test
18
+ Requires-Dist: pytest>=7.0.0; extra == "test"
19
+ Requires-Dist: pytest-cov>=4.0.0; extra == "test"
20
+ Dynamic: license-file
21
+
22
+ # Governed Agent
23
+
24
+ > **Reference implementation (v0.1.3), not a production security gate.** The file-backed anti-rollback authority detects partial state corruption but cannot detect replay of a complete older snapshot. Its default key is stored beside the state; anyone able to read that key and write the state can forge pins. Use separately protected key custody and an independent monotonic anchor before relying on durable rollback resistance. See the Sequence-Checked Pins section below.
25
+
26
+ > **Deterministic capability-based security, scope-bounded planning, and out-of-band audit for autonomous AI agents.**
27
+
28
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
29
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
30
+ [![Tests: 63 passed](https://img.shields.io/badge/tests-63%20passed-brightgreen.svg)]()
31
+ [![Coverage: 90%](https://img.shields.io/badge/coverage-90%25-brightgreen.svg)]()
32
+ [![Whitepaper](https://img.shields.io/badge/paper-WHITE__PAPER.md-orange.svg)](WHITE_PAPER.md)
33
+ [![arXiv LaTeX](https://img.shields.io/badge/arXiv-paper%2Fgoverned__agent__paper.tex-purple.svg)](paper/governed_agent_paper.tex)
34
+ [![Blog Post](https://img.shields.io/badge/blog-BLOG__POST.md-blue.svg)](BLOG_POST.md)
35
+
36
+ ---
37
+
38
+ ## A focused public release, backed by a larger body of work
39
+
40
+ `governed-agent` is designed as a focused Tier 1 release: roughly 1,200 lines of code covering cryptographic capability sealing, scope-bound planning validation, and independent audit primitives. Its purpose is to give developers a clear, usable foundation for governed agents.
41
+
42
+ It comes from a broader private engineering effort of roughly 20,000 lines. That work spans the systems and workflows behind our research and agent operations. We are keeping it private while making the core governance ideas available for others to inspect and build on.
43
+
44
+ The distinction is deliberate: **a focused release that shows the engineering clearly, with the broader operating system protected for continued development.**
45
+
46
+ ---
47
+
48
+ ## Technical Whitepaper
49
+
50
+ For the formal mathematical specification, threat model, cryptographic formulation, and benchmark evaluation, read the **[Technical Whitepaper (WHITE_PAPER.md)](WHITE_PAPER.md)**.
51
+
52
+ ---
53
+
54
+ ## The Problem: Ambient Authority & Self-Certification
55
+
56
+ Production LLM agent frameworks (LangChain, CrewAI, AutoGen, and tool-calling models) operate under **ambient authority**:
57
+ 1. **Unbounded execution:** If an agent is given tool access (database writes, terminal execution, file mutations), it can execute those tools whenever the model decides to emit a tool call.
58
+ 2. **Probabilistic guardrails:** Traditional safety relies on prompt instructions ("*do not delete files*") or secondary LLM filters. These are easily evaded via prompt injection or context drift.
59
+ 3. **Self-certification:** The same model executing actions is asked to verify whether its execution succeeded.
60
+
61
+ **Governed Agent** replaces some prompt-only checks with deterministic checks under explicit key-custody, dispatcher, and storage assumptions:
62
+ * **Capabilities are cryptographically signed** with RSA-SHA256 tokens; the supplied file-backed pin store checks sequence consistency but is not an independent monotonic anchor.
63
+ * **Planning does not grant execution authority** (`execution_authority: False`).
64
+ * **An out-of-band auditor** checks listed artifacts against their declared hashes when given a real artifact root; the caller must establish trust in the manifest and isolation of the auditor.
65
+
66
+ ---
67
+
68
+ ## Architecture: The 5-Layer Governance Model
69
+
70
+ ```
71
+ ┌─────────────────────────────────────────────────────────────┐
72
+ │ 1. CAPABILITY LAYER │
73
+ │ RSA-SHA256 Capability Sealing & Monotonic Anti-Rollback │
74
+ │ (Tokens bound to scope, expiry, and non-decreasing pins) │
75
+ └──────────────────────────────┬──────────────────────────────┘
76
+ │
77
+ ▼
78
+ ┌─────────────────────────────────────────────────────────────┐
79
+ │ 2. PLANNING LAYER │
80
+ │ Scope-Bounded Task Packets (Plan != Authority) │
81
+ │ (Allowed actions, strict prohibitions, SHA-256 handoffs) │
82
+ └──────────────────────────────┬──────────────────────────────┘
83
+ │
84
+ ▼
85
+ ┌─────────────────────────────────────────────────────────────┐
86
+ │ 3. GOVERNANCE LAYER │
87
+ │ Domain Boundaries & Case Envelope Verification │
88
+ └──────────────────────────────┬──────────────────────────────┘
89
+ │
90
+ ▼
91
+ ┌─────────────────────────────────────────────────────────────┐
92
+ │ 4. INTAKE LAYER │
93
+ │ Credential Sanitization, Secret Defense & Receipt Store │
94
+ └──────────────────────────────┬──────────────────────────────┘
95
+ │
96
+ ▼
97
+ ┌─────────────────────────────────────────────────────────────┐
98
+ │ 5. AUDIT LAYER │
99
+ │ Out-of-Band Independent Verifier (Watchtower) │
100
+ │ (6-point audit: manifest, hashes, residue, PASS/HOLD) │
101
+ └─────────────────────────────────────────────────────────────┘
102
+ ```
103
+
104
+ > **Tier 1 (Core)** provides reference implementations for **Layer 1 (Capability)**, **Layer 2 (Planning)**, and **Layer 5 (Audit)**.
105
+
106
+ ---
107
+
108
+ ## Core Primitives
109
+
110
+ ### 1. Capability Sealing (`governed_agent.capability`)
111
+ Before an agent can invoke a privileged tool, it must hold an unforgeable capability token generated by an authoritative custodian.
112
+
113
+ ```python
114
+ from governed_agent.capability import generate_keypair, seal, verify
115
+
116
+ # Custodian generates keypair
117
+ custodian_key = generate_keypair(key_size=2048, key_id="custodian-primary")
118
+
119
+ # Seal a capability receipt for a specific agent action and context
120
+ receipt = seal(
121
+ request={"action": "mutate_table", "table": "orders"},
122
+ trusted_context={"task_id": "JOB-9102", "role": "database-migration"},
123
+ keypair=custodian_key,
124
+ )
125
+
126
+ # Tool execution boundary verifies the capability token before execution
127
+ verdict = verify(
128
+ receipt_bytes=receipt.receipt_bytes,
129
+ signature=receipt.signature,
130
+ trusted_expected_context={"task_id": "JOB-9102", "role": "database-migration"},
131
+ key=custodian_key.public_key_pem,
132
+ )
133
+
134
+ assert verdict.status == "ACCEPT"
135
+ ```
136
+
137
+ `GovernedToolBoundary.invoke_tool` requires the signed request to contain exactly `{"action": tool_name, **args}`; a signature over the action alone cannot authorize different paths, payloads, or extra arguments.
138
+
139
+ ### 2. Sequence-Checked Pins (`governed_agent.capability.antirollback`)
140
+ Rejects a repeated or lower sequence relative to the authority's *currently loaded* state; durable rollback resistance requires an external anchor:
141
+
142
+ ```python
143
+ from governed_agent.capability import InMemoryAuthority
144
+
145
+ authority = InMemoryAuthority()
146
+ pin1 = authority.create_pin(chain_id="deploy_session", checkpoint_hash="hash_v1", sequence=1)
147
+ pin2 = authority.create_pin(chain_id="deploy_session", checkpoint_hash="hash_v2", sequence=2)
148
+
149
+ # Attempting to replay sequence 1 raises an immediate anti-rollback violation:
150
+ # ValueError: Rollback detected: sequence 1 <= latest sequence 2
151
+ ```
152
+
153
+ `FileBackedAuthority` now accepts only pins authenticated with its configured private key. Legacy pins signed with the public fallback secret are rejected on load; do not automatically re-sign or trust them. Re-establish a trusted state under separately reviewed authority before migration. An unreadable or empty key fails closed; if a key is lost, existing pins cannot be authenticated by a replacement key.
154
+
155
+ **Limits:** The file-backed counter detects partial truncation or inconsistency, but a party able to restore both `pins.json` and `counter.txt` to an older valid snapshot can still roll back the state. It is not a standalone external monotonic anchor. The default `authority.key` lives beside those files: if an attacker can read that key and write the pins, they can forge authenticated state. Keep the authority key in a separately protected trust domain and use an independent monotonic store before treating this as a rollback-resistant security gate.
156
+
157
+ ### 3. Scope-Bounded Planning (`governed_agent.planning`)
158
+ Ensures planning agents cannot execute actions or grant themselves authority:
159
+
160
+ ```python
161
+ from governed_agent.planning import validate, create_handoff
162
+
163
+ task_packet = {
164
+ "task_id": "TASK-501",
165
+ "objective": "Analyze migration logs and propose indexing changes",
166
+ "allowed_actions": ["read", "propose"],
167
+ "prohibited_actions": ["activate", "deploy", "publish", "send", "overwrite"],
168
+ "acceptance_criteria": ["Return index recommendations backed by query cost estimates"],
169
+ "executor": "database_engineer",
170
+ }
171
+
172
+ validation = validate(task_packet)
173
+ assert validation["blink_result"] == "PASS"
174
+ assert validation["execution_authority"] is False # Never grants execution authority!
175
+
176
+ # Generates deterministic, hash-bound handoff packet
177
+ handoff = create_handoff(task_packet, validation)
178
+ print(f"Handoff ID: {handoff['handoff_id']}")
179
+ print(f"Packet SHA256: {handoff['packet_sha256']}")
180
+ ```
181
+
182
+ Handoff creation and reasoning-brief rendering revalidate the supplied packet; caller-provided validation results are ignored. When `GOVERNED_AGENT_BLINK_ENABLED=false`, validation returns `FAIL` and handoffs are denied rather than issuing an unchecked `PASS`.
183
+
184
+ ### 4. Independent Audit (`governed_agent.audit`)
185
+ Enforces separation of duties by auditing build outputs against manifests without model involvement:
186
+
187
+ ```python
188
+ from governed_agent.audit import WatchTower, WatchTowerVerdict
189
+
190
+ auditor = WatchTower(root_dir="artifacts")
191
+ audit_result = auditor.verify("manifest.json")
192
+
193
+ # Returns strict, non-negotiable verdicts: PASS, HOLD, or REVISE
194
+ if audit_result["verdict"] != WatchTowerVerdict.PASS.value:
195
+ raise RuntimeError(f"Audit failed with status: {audit_result['verdict']}")
196
+ ```
197
+
198
+ A full audit requires an existing artifact directory and at least one listed file. Without either, Watchtower returns a non-PASS verdict instead of treating metadata-only checks as filesystem verification. If a manifest declares `size_bytes`, the value must be a nonnegative integer matching the bytes actually read during hashing; a digest over a false size declaration cannot earn PASS.
199
+
200
+ ---
201
+
202
+ ## Comparison Matrix
203
+
204
+ | Property | LangChain / CrewAI | Anthropic MCP | NeMo Guardrails | Governed Agent |
205
+ | :--- | :--- | :--- | :--- | :--- |
206
+ | **Tool Execution Authority** | Ambient | Ambient per server | Prompt/Text filter | **Cryptographic token (RSA-SHA256)** |
207
+ | **Anti-Replay / Monotonicity** | ❌ None | ❌ None | ❌ None | **Sequence checks; durable rollback resistance requires external anchor** |
208
+ | **Tamper-Evident Handoffs** | ❌ Plain text/dict | ❌ JSON-RPC | ❌ None | **✅ SHA-256 bound task packets** |
209
+ | **Planning vs Execution Separation** | ❌ Blended | ❌ Blended | ❌ Blended | **✅ Strict (`execution_authority: False`)** |
210
+ | **Self-Certification Prevention** | ❌ Model self-eval | ❌ None | ❌ None | **✅ Out-of-band 6-point verifier** |
211
+ | **Failure Mode** | Silent fault | Silent fault | Evasion | **Fail-closed (`HOLD`)** |
212
+
213
+ ---
214
+
215
+ ## Installation
216
+
217
+ ```bash
218
+ pip install governed-agent
219
+ ```
220
+
221
+ For development and running tests:
222
+
223
+ ```bash
224
+ git clone https://github.com/jtevesnz-sys/governed-agent.git
225
+ cd governed-agent
226
+ pip install -e .[test]
227
+ pytest
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Community & Contact
233
+
234
+ * **GitHub Discussions:** Ask questions, share architectures, or propose integrations in [Discussions](https://github.com/jtevesnz-sys/governed-agent/discussions).
235
+ * **Security Advisories:** Report potential vulnerabilities privately via [Security Advisories](https://github.com/jtevesnz-sys/governed-agent/security).
236
+ * **Inquiries & Pilots:** Open a discussion thread or reach out via project GitHub handles.
237
+
238
+ ---
239
+
240
+ ## License
241
+
242
+ MIT License. Copyright (c) 2026 jtevesnz-sys.
@@ -0,0 +1,221 @@
1
+ # Governed Agent
2
+
3
+ > **Reference implementation (v0.1.3), not a production security gate.** The file-backed anti-rollback authority detects partial state corruption but cannot detect replay of a complete older snapshot. Its default key is stored beside the state; anyone able to read that key and write the state can forge pins. Use separately protected key custody and an independent monotonic anchor before relying on durable rollback resistance. See the Sequence-Checked Pins section below.
4
+
5
+ > **Deterministic capability-based security, scope-bounded planning, and out-of-band audit for autonomous AI agents.**
6
+
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
9
+ [![Tests: 63 passed](https://img.shields.io/badge/tests-63%20passed-brightgreen.svg)]()
10
+ [![Coverage: 90%](https://img.shields.io/badge/coverage-90%25-brightgreen.svg)]()
11
+ [![Whitepaper](https://img.shields.io/badge/paper-WHITE__PAPER.md-orange.svg)](WHITE_PAPER.md)
12
+ [![arXiv LaTeX](https://img.shields.io/badge/arXiv-paper%2Fgoverned__agent__paper.tex-purple.svg)](paper/governed_agent_paper.tex)
13
+ [![Blog Post](https://img.shields.io/badge/blog-BLOG__POST.md-blue.svg)](BLOG_POST.md)
14
+
15
+ ---
16
+
17
+ ## A focused public release, backed by a larger body of work
18
+
19
+ `governed-agent` is designed as a focused Tier 1 release: roughly 1,200 lines of code covering cryptographic capability sealing, scope-bound planning validation, and independent audit primitives. Its purpose is to give developers a clear, usable foundation for governed agents.
20
+
21
+ It comes from a broader private engineering effort of roughly 20,000 lines. That work spans the systems and workflows behind our research and agent operations. We are keeping it private while making the core governance ideas available for others to inspect and build on.
22
+
23
+ The distinction is deliberate: **a focused release that shows the engineering clearly, with the broader operating system protected for continued development.**
24
+
25
+ ---
26
+
27
+ ## Technical Whitepaper
28
+
29
+ For the formal mathematical specification, threat model, cryptographic formulation, and benchmark evaluation, read the **[Technical Whitepaper (WHITE_PAPER.md)](WHITE_PAPER.md)**.
30
+
31
+ ---
32
+
33
+ ## The Problem: Ambient Authority & Self-Certification
34
+
35
+ Production LLM agent frameworks (LangChain, CrewAI, AutoGen, and tool-calling models) operate under **ambient authority**:
36
+ 1. **Unbounded execution:** If an agent is given tool access (database writes, terminal execution, file mutations), it can execute those tools whenever the model decides to emit a tool call.
37
+ 2. **Probabilistic guardrails:** Traditional safety relies on prompt instructions ("*do not delete files*") or secondary LLM filters. These are easily evaded via prompt injection or context drift.
38
+ 3. **Self-certification:** The same model executing actions is asked to verify whether its execution succeeded.
39
+
40
+ **Governed Agent** replaces some prompt-only checks with deterministic checks under explicit key-custody, dispatcher, and storage assumptions:
41
+ * **Capabilities are cryptographically signed** with RSA-SHA256 tokens; the supplied file-backed pin store checks sequence consistency but is not an independent monotonic anchor.
42
+ * **Planning does not grant execution authority** (`execution_authority: False`).
43
+ * **An out-of-band auditor** checks listed artifacts against their declared hashes when given a real artifact root; the caller must establish trust in the manifest and isolation of the auditor.
44
+
45
+ ---
46
+
47
+ ## Architecture: The 5-Layer Governance Model
48
+
49
+ ```
50
+ ┌─────────────────────────────────────────────────────────────┐
51
+ │ 1. CAPABILITY LAYER │
52
+ │ RSA-SHA256 Capability Sealing & Monotonic Anti-Rollback │
53
+ │ (Tokens bound to scope, expiry, and non-decreasing pins) │
54
+ └──────────────────────────────┬──────────────────────────────┘
55
+ │
56
+ ▼
57
+ ┌─────────────────────────────────────────────────────────────┐
58
+ │ 2. PLANNING LAYER │
59
+ │ Scope-Bounded Task Packets (Plan != Authority) │
60
+ │ (Allowed actions, strict prohibitions, SHA-256 handoffs) │
61
+ └──────────────────────────────┬──────────────────────────────┘
62
+ │
63
+ ▼
64
+ ┌─────────────────────────────────────────────────────────────┐
65
+ │ 3. GOVERNANCE LAYER │
66
+ │ Domain Boundaries & Case Envelope Verification │
67
+ └──────────────────────────────┬──────────────────────────────┘
68
+ │
69
+ ▼
70
+ ┌─────────────────────────────────────────────────────────────┐
71
+ │ 4. INTAKE LAYER │
72
+ │ Credential Sanitization, Secret Defense & Receipt Store │
73
+ └──────────────────────────────┬──────────────────────────────┘
74
+ │
75
+ ▼
76
+ ┌─────────────────────────────────────────────────────────────┐
77
+ │ 5. AUDIT LAYER │
78
+ │ Out-of-Band Independent Verifier (Watchtower) │
79
+ │ (6-point audit: manifest, hashes, residue, PASS/HOLD) │
80
+ └─────────────────────────────────────────────────────────────┘
81
+ ```
82
+
83
+ > **Tier 1 (Core)** provides reference implementations for **Layer 1 (Capability)**, **Layer 2 (Planning)**, and **Layer 5 (Audit)**.
84
+
85
+ ---
86
+
87
+ ## Core Primitives
88
+
89
+ ### 1. Capability Sealing (`governed_agent.capability`)
90
+ Before an agent can invoke a privileged tool, it must hold an unforgeable capability token generated by an authoritative custodian.
91
+
92
+ ```python
93
+ from governed_agent.capability import generate_keypair, seal, verify
94
+
95
+ # Custodian generates keypair
96
+ custodian_key = generate_keypair(key_size=2048, key_id="custodian-primary")
97
+
98
+ # Seal a capability receipt for a specific agent action and context
99
+ receipt = seal(
100
+ request={"action": "mutate_table", "table": "orders"},
101
+ trusted_context={"task_id": "JOB-9102", "role": "database-migration"},
102
+ keypair=custodian_key,
103
+ )
104
+
105
+ # Tool execution boundary verifies the capability token before execution
106
+ verdict = verify(
107
+ receipt_bytes=receipt.receipt_bytes,
108
+ signature=receipt.signature,
109
+ trusted_expected_context={"task_id": "JOB-9102", "role": "database-migration"},
110
+ key=custodian_key.public_key_pem,
111
+ )
112
+
113
+ assert verdict.status == "ACCEPT"
114
+ ```
115
+
116
+ `GovernedToolBoundary.invoke_tool` requires the signed request to contain exactly `{"action": tool_name, **args}`; a signature over the action alone cannot authorize different paths, payloads, or extra arguments.
117
+
118
+ ### 2. Sequence-Checked Pins (`governed_agent.capability.antirollback`)
119
+ Rejects a repeated or lower sequence relative to the authority's *currently loaded* state; durable rollback resistance requires an external anchor:
120
+
121
+ ```python
122
+ from governed_agent.capability import InMemoryAuthority
123
+
124
+ authority = InMemoryAuthority()
125
+ pin1 = authority.create_pin(chain_id="deploy_session", checkpoint_hash="hash_v1", sequence=1)
126
+ pin2 = authority.create_pin(chain_id="deploy_session", checkpoint_hash="hash_v2", sequence=2)
127
+
128
+ # Attempting to replay sequence 1 raises an immediate anti-rollback violation:
129
+ # ValueError: Rollback detected: sequence 1 <= latest sequence 2
130
+ ```
131
+
132
+ `FileBackedAuthority` now accepts only pins authenticated with its configured private key. Legacy pins signed with the public fallback secret are rejected on load; do not automatically re-sign or trust them. Re-establish a trusted state under separately reviewed authority before migration. An unreadable or empty key fails closed; if a key is lost, existing pins cannot be authenticated by a replacement key.
133
+
134
+ **Limits:** The file-backed counter detects partial truncation or inconsistency, but a party able to restore both `pins.json` and `counter.txt` to an older valid snapshot can still roll back the state. It is not a standalone external monotonic anchor. The default `authority.key` lives beside those files: if an attacker can read that key and write the pins, they can forge authenticated state. Keep the authority key in a separately protected trust domain and use an independent monotonic store before treating this as a rollback-resistant security gate.
135
+
136
+ ### 3. Scope-Bounded Planning (`governed_agent.planning`)
137
+ Ensures planning agents cannot execute actions or grant themselves authority:
138
+
139
+ ```python
140
+ from governed_agent.planning import validate, create_handoff
141
+
142
+ task_packet = {
143
+ "task_id": "TASK-501",
144
+ "objective": "Analyze migration logs and propose indexing changes",
145
+ "allowed_actions": ["read", "propose"],
146
+ "prohibited_actions": ["activate", "deploy", "publish", "send", "overwrite"],
147
+ "acceptance_criteria": ["Return index recommendations backed by query cost estimates"],
148
+ "executor": "database_engineer",
149
+ }
150
+
151
+ validation = validate(task_packet)
152
+ assert validation["blink_result"] == "PASS"
153
+ assert validation["execution_authority"] is False # Never grants execution authority!
154
+
155
+ # Generates deterministic, hash-bound handoff packet
156
+ handoff = create_handoff(task_packet, validation)
157
+ print(f"Handoff ID: {handoff['handoff_id']}")
158
+ print(f"Packet SHA256: {handoff['packet_sha256']}")
159
+ ```
160
+
161
+ Handoff creation and reasoning-brief rendering revalidate the supplied packet; caller-provided validation results are ignored. When `GOVERNED_AGENT_BLINK_ENABLED=false`, validation returns `FAIL` and handoffs are denied rather than issuing an unchecked `PASS`.
162
+
163
+ ### 4. Independent Audit (`governed_agent.audit`)
164
+ Enforces separation of duties by auditing build outputs against manifests without model involvement:
165
+
166
+ ```python
167
+ from governed_agent.audit import WatchTower, WatchTowerVerdict
168
+
169
+ auditor = WatchTower(root_dir="artifacts")
170
+ audit_result = auditor.verify("manifest.json")
171
+
172
+ # Returns strict, non-negotiable verdicts: PASS, HOLD, or REVISE
173
+ if audit_result["verdict"] != WatchTowerVerdict.PASS.value:
174
+ raise RuntimeError(f"Audit failed with status: {audit_result['verdict']}")
175
+ ```
176
+
177
+ A full audit requires an existing artifact directory and at least one listed file. Without either, Watchtower returns a non-PASS verdict instead of treating metadata-only checks as filesystem verification. If a manifest declares `size_bytes`, the value must be a nonnegative integer matching the bytes actually read during hashing; a digest over a false size declaration cannot earn PASS.
178
+
179
+ ---
180
+
181
+ ## Comparison Matrix
182
+
183
+ | Property | LangChain / CrewAI | Anthropic MCP | NeMo Guardrails | Governed Agent |
184
+ | :--- | :--- | :--- | :--- | :--- |
185
+ | **Tool Execution Authority** | Ambient | Ambient per server | Prompt/Text filter | **Cryptographic token (RSA-SHA256)** |
186
+ | **Anti-Replay / Monotonicity** | ❌ None | ❌ None | ❌ None | **Sequence checks; durable rollback resistance requires external anchor** |
187
+ | **Tamper-Evident Handoffs** | ❌ Plain text/dict | ❌ JSON-RPC | ❌ None | **✅ SHA-256 bound task packets** |
188
+ | **Planning vs Execution Separation** | ❌ Blended | ❌ Blended | ❌ Blended | **✅ Strict (`execution_authority: False`)** |
189
+ | **Self-Certification Prevention** | ❌ Model self-eval | ❌ None | ❌ None | **✅ Out-of-band 6-point verifier** |
190
+ | **Failure Mode** | Silent fault | Silent fault | Evasion | **Fail-closed (`HOLD`)** |
191
+
192
+ ---
193
+
194
+ ## Installation
195
+
196
+ ```bash
197
+ pip install governed-agent
198
+ ```
199
+
200
+ For development and running tests:
201
+
202
+ ```bash
203
+ git clone https://github.com/jtevesnz-sys/governed-agent.git
204
+ cd governed-agent
205
+ pip install -e .[test]
206
+ pytest
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Community & Contact
212
+
213
+ * **GitHub Discussions:** Ask questions, share architectures, or propose integrations in [Discussions](https://github.com/jtevesnz-sys/governed-agent/discussions).
214
+ * **Security Advisories:** Report potential vulnerabilities privately via [Security Advisories](https://github.com/jtevesnz-sys/governed-agent/security).
215
+ * **Inquiries & Pilots:** Open a discussion thread or reach out via project GitHub handles.
216
+
217
+ ---
218
+
219
+ ## License
220
+
221
+ MIT License. Copyright (c) 2026 jtevesnz-sys.
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "governed-agent"
7
+ version = "0.1.3"
8
+ description = "Cryptographic capability sealing, scope-bounded planning, and independent audit for LLM agents"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [
12
+ {name = "jtevesnz-sys", email = "jtevesnz-sys@users.noreply.github.com"}
13
+ ]
14
+ requires-python = ">=3.10"
15
+ dependencies = [
16
+ "cryptography>=42.0.0",
17
+ "pydantic>=2.0.0",
18
+ ]
19
+
20
+ [project.optional-dependencies]
21
+ test = [
22
+ "pytest>=7.0.0",
23
+ "pytest-cov>=4.0.0",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/jtevesnz-sys/governed-agent"
28
+ Documentation = "https://github.com/jtevesnz-sys/governed-agent/blob/main/WHITE_PAPER.md"
29
+ Repository = "https://github.com/jtevesnz-sys/governed-agent.git"
30
+ Issues = "https://github.com/jtevesnz-sys/governed-agent/issues"
31
+ Discussions = "https://github.com/jtevesnz-sys/governed-agent/discussions"
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
35
+
36
+ [tool.pytest.ini_options]
37
+ testpaths = ["tests"]
38
+ python_files = ["test_*.py"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,72 @@
1
+ """Governed Agent — capability sealing, scope-bounded planning, independent audit, and runtime tool boundaries."""
2
+
3
+ from .capability import (
4
+ KeyPair,
5
+ SealResult,
6
+ VerifyResult,
7
+ generate_keypair,
8
+ seal,
9
+ verify,
10
+ quick_seal,
11
+ quick_verify,
12
+ FileKeyStore,
13
+ create_keystore,
14
+ Pin,
15
+ Checkpoint,
16
+ FileBackedAuthority,
17
+ InMemoryAuthority,
18
+ create_antirollback_authority,
19
+ create_checkpoint,
20
+ )
21
+ from .planning import (
22
+ validate,
23
+ render_brief,
24
+ create_handoff,
25
+ ALLOWED_ACTIONS,
26
+ HIGH_RISK_ACTIONS,
27
+ REQUIRED_PROHIBITIONS,
28
+ enabled,
29
+ )
30
+ from .audit import (
31
+ WatchTower,
32
+ WatchTowerVerdict,
33
+ )
34
+ from .hermes import GovernedToolBoundary, ExecutionDeniedError
35
+
36
+ __version__ = "0.1.2"
37
+ __author__ = "jtevesnz-sys"
38
+ __license__ = "MIT"
39
+
40
+ __all__ = [
41
+ # Capability Layer
42
+ "KeyPair",
43
+ "SealResult",
44
+ "VerifyResult",
45
+ "generate_keypair",
46
+ "seal",
47
+ "verify",
48
+ "quick_seal",
49
+ "quick_verify",
50
+ "FileKeyStore",
51
+ "create_keystore",
52
+ "Pin",
53
+ "Checkpoint",
54
+ "FileBackedAuthority",
55
+ "InMemoryAuthority",
56
+ "create_antirollback_authority",
57
+ "create_checkpoint",
58
+ # Planning Layer
59
+ "validate",
60
+ "render_brief",
61
+ "create_handoff",
62
+ "ALLOWED_ACTIONS",
63
+ "HIGH_RISK_ACTIONS",
64
+ "REQUIRED_PROHIBITIONS",
65
+ "enabled",
66
+ # Audit Layer
67
+ "WatchTower",
68
+ "WatchTowerVerdict",
69
+ # Hermes Tool Boundary
70
+ "GovernedToolBoundary",
71
+ "ExecutionDeniedError",
72
+ ]
@@ -0,0 +1,5 @@
1
+ """Audit layer: independent 6-point verification and verdict engine."""
2
+
3
+ from .watchtower import WatchTower, WatchTowerVerdict
4
+
5
+ __all__ = ["WatchTower", "WatchTowerVerdict"]