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   # 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 .venv and 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


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.1.0.tar.gz (153.9 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.1.0-py3-none-any.whl (112.6 kB view details)

Uploaded Python 3

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

Hashes for granary_harness-1.1.0.tar.gz
Algorithm Hash digest
SHA256 404a3c19e43aef7c863d3a2918c84fbb9e8f95a2233fcf1f9e1d8d8542a75a09
MD5 17ca83a8f935947fcfbb8597a08dd5ee
BLAKE2b-256 3293f55db4f33c0eda81d1f338814b43d212c34d11ca25de278d972ef749fbe6

See more details on using hashes here.

Provenance

The following attestation bundles were made for granary_harness-1.1.0.tar.gz:

Publisher: publish.yml on Tunatroll/granary-harness

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for granary_harness-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 08422a674a85493f25e2e991b3c5e10d4f789000f2e8579ed9879cf20b98bc9f
MD5 c8ae00a04d49156a93a56f8de62d16c9
BLAKE2b-256 c37977e6433a4ecfaae9bb809ea61c217dafa19ff10e6365632343b4b4e465ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for granary_harness-1.1.0-py3-none-any.whl:

Publisher: publish.yml on Tunatroll/granary-harness

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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