Skip to main content

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) with agent_owner and agent_trust_score claims, 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   # 158 verified 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 .venv and install the package in editable development mode:
    make setup
    
  • Run the unit test suite: Run all 158 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 complete test suite (158 tests) with no regressions:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

granary_harness-1.0.1.tar.gz (138.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

granary_harness-1.0.1-py3-none-any.whl (110.0 kB view details)

Uploaded Python 3

File details

Details for the file granary_harness-1.0.1.tar.gz.

File metadata

  • Download URL: granary_harness-1.0.1.tar.gz
  • Upload date:
  • Size: 138.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for granary_harness-1.0.1.tar.gz
Algorithm Hash digest
SHA256 31c9e6347ead85892e8196e89e3227c45ccefa1373925135b999faf5b2068492
MD5 ef915dfd11e0f56a5a26e6b79909d276
BLAKE2b-256 73b64d109a9b6d88ee3c8886abd17fc351e02ae9d8c35c3879bbb791529a1374

See more details on using hashes here.

File details

Details for the file granary_harness-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for granary_harness-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0798bcdd45a586e8d003cc33aa9a4ae85959c2fdea7708af42b5868070698760
MD5 0d39828e1e4b6196380d7c00c78fe24f
BLAKE2b-256 5586f47643741fdb0a21c09f49272eaf097cfe88d60dd183cebdc868b71f2e3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page