Granary agent-security, governance, and privilege containment harness.
Project description
Granary Harness โ Secure GitOps Orchestration & Containment
A secure, GitOps-native multi-agent orchestration loop and zero-trust containment framework. Grounded in the academic CAID (Centralized Asynchronous Isolated Delegation) paradigm, Granary coordinates multi-agent fleets asynchronously using private GitHub PRs as an immutable blackboard communications busโfully isolated by local sandboxing boundaries, credential filters, and an MCP gateway.
๐ Day-0 Quickstart (Run the MVP Demo)
Granary is packaged to be extremely lightweight (<5MB) and runs in any terminal in under 30 seconds.
1. Installation & Environment Setup
Clone the repository and install dependencies in editable development mode:
make setup
2. View Security & Governance Status Dashboard
Run bare granary (or granary status) to view a beautifully formatted terminal dashboard showing active directory sandboxes, registered agent capabilities, loaded self-healing hooks, and MCP gateway policies:
.venv/bin/granary
3. Run the Secure Blackboard Loop Demo (CAID)
Execute our E2E GitOps loop simulation to see how agents coordinate asynchronously, how file containment jails block unauthorized traversal attempts, how Helix-style self-healing auto-hooks are dynamically compiled on exceptions, and how SEDM/TierMem memory evolution consolidates records on success:
.venv/bin/python bin/granary-loop-demo.py
Key Features
- Asynchronous GitOps Coordination (CAID): Standardizes multi-agent software engineering workflows over Git branches and PRs (as in arXiv:2603.21489), sequentially merging worker commits and resolving workspace conflicts natively.
- Helix-style "Gene Map" Auto-Hooks: Intercepts, trace-fingerprints, and registers dynamic recovery hooks on sandbox failures, shielding future loops in under 1ms without LLM overhead.
- SEDM/TierMem Memory Evolution: Promotes probation records to active memory via "Verified Write-Back" upon successful PR merges, or quarantines them on task exceptions.
- Operating Constitution: Enforces a strict, declarative, five-tier (T0-T4) blast-radius boundary limit for filesystem, LOC edits, token budgets, and path overrides via
agent-constitution.yaml. - Dynamic JIT Privilege Elevation: Implements
AgentAssertionToken(AAT) withagent_ownerandagent_trust_scoreclaims, alongside RFC 8693 token exchange payloads and RFC 9449 DPoP sender-constraining validation. - Egress & Tunneling Control (ShieldNet): Shannon entropy monitoring and rate limiting over DNS queries to identify exfiltration channels and active tunneling attempts.
- MCP Trust Gateway: High-fidelity Model Context Protocol tool interceptors, risk-based gating, and human-in-the-loop approvals.
Project Structure
granary-harness/
โโโ granary/ # Core security modules
โ โโโ __init__.py # Public API (39 fully exported modules)
โ โโโ identity.py # AAT Claims, signatures, and DPoP validation
โ โโโ constitution.py # Operating Constitution and YAML parser
โ โโโ readiness.py # Pre-launch checklists & cold rollbacks
โ โโโ adversa.py # Adversa offline red-teaming
โ โโโ mcp_security.py # MCP tool risk gateways
โ โโโ shieldnet.py # DNS entropy network egress
โ โโโ attestation.py # Nitro enclave attestation
โ โโโ ... # Sandboxing, rollups, self-healing, otel
โโโ tests/ # Standalone unittest suites
โ โโโ test_granary_*.py # 192 Granary unit tests
โโโ docs/ # Governance & policy contracts
โ โโโ gtm/ # Competitive positioning & matrices
โ โโโ agent-constitution.yaml
โ โโโ governance-cadence.md
โ โโโ planning_merge_verification.md
โโโ pyproject.toml # Package configuration
โโโ CLAUDE.md # Code standards & run commands
โโโ AGENTS.md # Autonomous onboarding reference
Setup & Task Automation
Granary includes a standardized local task runner using the project Makefile:
- Set up standalone environment: Create
.venvand install the package in editable development mode:make setup - Run the unit test suite: Run all 192 Granary tests with verbose reporting:
make test
- Package compiling: Compile the project into distributable wheel (
.whl) and sdist (.tar.gz) archives:make build - Pristine cleaning: Recursively clean caches, bytecode, and packaging/environment folders:
make clean
Command-Line Interface (CLI)
The administrative utility is registered natively upon installation as the executable granary.
1. Constitution Validation
Validate the syntax and autonomy tiers of a declarative agent constitution YAML file:
granary validate-constitution --path docs/agent-constitution.yaml
2. Merkle Audit Ledger Management
- Export Chain: Export a mock, cryptographically chained, and redacted compliance ledger:
granary admin ledger export --work-unit-id "wu_92e8a10f-3a21" --output "./forensics_export.json"
- Verify Chain Integrity: Scan, recalculate Merkle roots, and verify HSM-signatures over an exported ledger file:
granary admin ledger verify-chain --input "./forensics_export.json"
Running Unit Tests
Unit tests are written using Python's built-in, zero-dependency unittest module.
To run the Granary test suite (192 tests) with no regressions:
Legacy Living-NN trees (core/, gfo-server-v3/, etc.) are documented in legacy/README.md and are not part of the PyPI package.
python -m unittest discover -s tests -p "test_granary_*.py" -v
MCP Gateway (Cursor / Claude)
Granary exposes a stdio MCP server that wraps McpTrustGateway for live agent sessions.
Setup
make setup # installs granary-harness[mcp]
Cursor configuration
This repo ships .cursor/mcp.json. After setup, restart Cursor or reload MCP servers. You should see granary-gateway with four tools:
| Tool | Purpose |
|---|---|
granary_authorize_tool |
Risk-tier + scope + JTI replay check before tool execution |
granary_approve_pending |
Human approval for T2/T3 actions |
granary_validate_redirect |
OAuth redirect URI allowlist check |
granary_list_pending |
List queued approval requests |
Run manually:
granary-mcp
Optional custom policy JSON via GRANARY_MCP_POLICY=/path/to/policy.json.
Publishing to PyPI
See docs/PYPI_RELEASE.md for build, twine check, TestPyPI, and production upload steps.
make build
make publish-check
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file granary_harness-1.1.0.tar.gz.
File metadata
- Download URL: granary_harness-1.1.0.tar.gz
- Upload date:
- Size: 153.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
404a3c19e43aef7c863d3a2918c84fbb9e8f95a2233fcf1f9e1d8d8542a75a09
|
|
| MD5 |
17ca83a8f935947fcfbb8597a08dd5ee
|
|
| BLAKE2b-256 |
3293f55db4f33c0eda81d1f338814b43d212c34d11ca25de278d972ef749fbe6
|
Provenance
The following attestation bundles were made for granary_harness-1.1.0.tar.gz:
Publisher:
publish.yml on Tunatroll/granary-harness
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
granary_harness-1.1.0.tar.gz -
Subject digest:
404a3c19e43aef7c863d3a2918c84fbb9e8f95a2233fcf1f9e1d8d8542a75a09 - Sigstore transparency entry: 1615894754
- Sigstore integration time:
-
Permalink:
Tunatroll/granary-harness@22c4da766cfc75136cd13612040555699d4971ab -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Tunatroll
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@22c4da766cfc75136cd13612040555699d4971ab -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file granary_harness-1.1.0-py3-none-any.whl.
File metadata
- Download URL: granary_harness-1.1.0-py3-none-any.whl
- Upload date:
- Size: 112.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08422a674a85493f25e2e991b3c5e10d4f789000f2e8579ed9879cf20b98bc9f
|
|
| MD5 |
c8ae00a04d49156a93a56f8de62d16c9
|
|
| BLAKE2b-256 |
c37977e6433a4ecfaae9bb809ea61c217dafa19ff10e6365632343b4b4e465ae
|
Provenance
The following attestation bundles were made for granary_harness-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on Tunatroll/granary-harness
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
granary_harness-1.1.0-py3-none-any.whl -
Subject digest:
08422a674a85493f25e2e991b3c5e10d4f789000f2e8579ed9879cf20b98bc9f - Sigstore transparency entry: 1615894760
- Sigstore integration time:
-
Permalink:
Tunatroll/granary-harness@22c4da766cfc75136cd13612040555699d4971ab -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Tunatroll
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@22c4da766cfc75136cd13612040555699d4971ab -
Trigger Event:
workflow_dispatch
-
Statement type: