Runtime oversight for autonomous agents — YAML identity manifests with trust levels 1-5, 3-tier tool classification, append-only audit logging, constitutional contracts with monotonically decreasing privileges, memory governance, and trust-mediated delegation with 6 sequential gates.
Installs as a Claude Code plugin. The repositories are currently private, so the plugin fetch cannot resolve until they are published:
git clone https://github.com/bulletproofsoftware-ai/bulletproof-governance-plugin.git cd bulletproof-governance-plugin # point your Claude Code plugin config at this directory, or clone it into # your plugins directory. Hooks self-register via hooks/hooks.json: # SessionStart, PreToolUse, PostToolUse export GOVERNANCE_PLUGIN_ROOT=$PWD # if not at the default plugin path export BPM_ENV_FILE=/path/to/env # must hold QDRANT_API_KEY

bulletproof-governance-plugin/docs/media/
Autonomous AI agents can read files, write code, execute commands, access external services, and delegate to other agents. Without runtime governance, there's no enforcement boundary between what an agent can do and what it should do. "Trust but verify" doesn't work when agents operate faster than humans can review.
The governance framework provides enforcement at the speed of execution — policy evaluated in milliseconds, not minutes. It's implemented in two layers: the governance plugin (Python, SQLite audit bus, policy engine, trust broker) and 7 governance MCP tools in the memory system (constitutional contracts, compliance dashboards, guardrail proofs, data sovereignty).
Who is this agent? Trust 1-5, data classification, permitted tools/delegations
3-tier tool classification × conductor tier matrix
SQLite WAL, 28 event types, sync/async emission
Content classification, ceiling enforcement, provenance
6-gate delegation mediation, delegation tokens
7 MCP tools for contracts, monitoring, proofs, sovereignty
SessionStart → Load manifests, init audit session, register agents
PreToolUse → Policy engine evaluates tool call against manifest + constitutional observer checks drift
PostToolUse → Audit bus logs outcome, memory governor checks content classification
Stop → Deregister agents, flush constitutional assessments, archive session
agent_id: code-reviewer
trust_level: 3 # 1 (minimal) to 5 (full)
data_classification: internal # public | internal | confidential | restricted
permitted_tools: [Read, Glob, Grep, Bash]
permitted_delegations: ["qa-*", "builder"] # fnmatch patterns
max_autonomy_depth: 2
max_delegation_count: 5
human_required: false
4-tier resolution: Static YAML + parent → ceiling enforcement (intersection); static only → authoritative; parent only → derived restrictive (trust-1); neither → default restrictive (trust=1, no tools, human_required=true). SHA-256 hashed for tamper evidence.
Most daily work: zero approval prompts, <200ms total overhead. Human approval only when elevated tool + MAJOR tier.
| Tier | Tools | Overhead |
|---|---|---|
| Exempt | Read, Glob, Grep, TaskList, TaskGet, AskUserQuestion | Zero (async log only) |
| Standard | Edit, Write, Task, Bash, WebFetch, WebSearch | ~50ms auto-allow + audit |
| Elevated | memory_store, memory_forget, NotebookEdit, all MCP tools | ~100ms or human gate at MAJOR |
| Conductor Tier | Exempt | Standard | Elevated |
|---|---|---|---|
| TRIVIAL | Allow | Allow | Allow |
| MINOR | Allow | Allow | Allow |
| STANDARD | Allow | Allow (audited) | Allow (audited) |
| MAJOR | Allow | Allow (audited) | Human Gate |
Beyond the governance plugin's policy engine, 7 MCP tools in the memory system add runtime constitutional governance:
The constitutional observer hook (PreToolUse, <2s, no LLM) checks every tool call for drift and feeds assessments to the compliance layer.
SQLite WAL, 28 event types, hybrid sync/async emission. Sync for denials/threats (with alerting), async for allows (bounded queue, 256 max, daemon worker). JSON-lines buffer fallback. 90-day retention with JSONL archival.
| # | Gate | Check |
|---|---|---|
| 1 | Breadth | max_delegation_count not exceeded? |
| 2 | Depth | max_autonomy_depth > 0? |
| 3 | Classification | Target classification ≤ source? |
| 4 | Trust | Target trust ≤ source? (no escalation) |
| 5 | Targets | fnmatch pattern match on permitted_delegations? |
| 6 | Registration | Manifest registered in TTL-3600s session registry |
Query events, export JSONL
Health dashboard + metrics
Approve/deny confidential writes
Build an agent governance framework for Claude Code:
1. IDENTITY MANIFESTS (YAML): agent_id, trust_level 1-5,
data_classification, permitted_tools/delegations, autonomy depth/count,
SHA-256 hashing, 4-tier resolution with parent ceiling
2. POLICY ENGINE: 3-tier tool classification (exempt/standard/elevated)
× conductor tier matrix. Human gate only at MAJOR+elevated.
Unknown tools → elevated. Typical overhead: <200ms, zero prompts.
3. AUDIT BUS: SQLite WAL, 28 event types, sync for denials,
async for allows (bounded queue 256), JSON-lines buffer fallback,
90-day retention + JSONL archival
4. CONSTITUTIONAL LAYER (7 MCP tools):
- constitutional_contract: monotonically decreasing delegation privileges
- constitutional_monitor: real-time drift detection
- guardrail_proof: Ed25519 + Merkle attestation
- data_sovereignty: jurisdiction tagging, GDPR cascading delete
- governance_report/gap_analysis: ISO 42001 evidence
- compliance_dashboard: ISO 42001 + EU AI Act + OWASP scoring
Plus constitutional_observer hook (<2s PreToolUse, no LLM)
5. MEMORY GOVERNOR: regex content classification
(restricted=block, confidential=queue), ceiling enforcement,
provenance tagging (agent_id + manifest_hash)
6. TRUST BROKER: 6 sequential gates (breadth, depth, classification,
trust, targets, registration), 24-char hex delegation tokens,
ManifestRegistry with file locking + TTL purge
7. COMMANDS: /governance-audit, /governance-status, /governance-review
Build as Claude Code plugin (Python) + 7 MCP tools in memory server.The governance plugin (Python, SQLite) handles runtime policy enforcement. The memory system's 7 MCP tools handle constitutional contracts, compliance, and cryptographic proofs. Neither alone is sufficient — together they cover both enforcement and evidence.
Exempt tools add zero overhead. Standard tools add imperceptible ~50ms. Only elevated tools trigger full evaluation. This keeps governance invisible for routine work while maintaining scrutiny where it matters.
Real-time drift detection on every tool call (<2s, no LLM) catches problems as they happen. Buffered flags flush to vector storage at session end for trend analysis. The compliance dashboard reads these for scoring.
Child agents inherit the intersection of their permissions and parent permissions. A trust-3 parent cannot create a trust-5 child. This is mathematically guaranteed to prevent privilege escalation through delegation chains.
Governance ships 7 hooks in ~/.claude/plugins/local/governance/hooks/hooks.json. Claude Code auto-discovers them when the plugin is installed. All scripts run under ~/.claude/scripts/memory/venv/bin/python3 with the Qdrant API key exported from ~/docker/local/.env.
Security hooks (pre_tool_security, memory_integrity) fail closed — on exception they return {"decision": "block"}. Policy / trust hooks (pre_tool_check) and observation hooks (post_tool_metrics) fail open to avoid blocking sessions on a non-security bug. This split is deliberate.
| Event | Matcher | Script | Fails | Purpose |
|---|---|---|---|---|
| SessionStart | * | session_start.py | open | Bootstrap governance for the session — initialize audit bus, register conductor manifest, validate all static manifests, write session state. Never blocks session start. |
| PreToolUse | * | pre_tool_security.py | closed | Threat detection + scope enforcement. Counterpart to pre_tool_check. Any exception returns {"decision": "block"}. |
| PreToolUse | memory_store | memory_integrity_hook.py | closed | 4-stage memory-write pipeline. Runs BEFORE pre_tool_check when storing to the memory system. |
| PreToolUse | * | pre_tool_check.py | open | Policy + trust evaluation. Runs the trust broker for Task tools (delegation mediation), then the policy engine for all tools. |
| PostToolUse | * | post_tool_metrics.py | open | Behavioral metrics collection. Records tool usage, updates baselines, checks for anomalies. Non-blocking, never returns a decision. |
| PostToolUse | * | post_tool_security.py | scans output | Outbound runtime guardrail — scans tool responses for poisoning and leakage. Complement to pre_tool_security (which scans inputs). |
| PostToolUse | Task | post_task_cleanup.py | open | Cleanup after delegation — deregister the completed agent from the manifest registry. Minimal, non-blocking. |
Governance operates as a plugin using SessionStart (manifest loading), PreToolUse (policy enforcement), PostToolUse (audit logging). The two-layer hook system ensures reliable execution.
Conductor's tier classification feeds the policy engine's tier matrix. NHI lifecycle events emit to the audit bus. The state schema's governance block links manifests to workflows.
7 governance MCP tools operate within the memory server. Memory governor controls what enters vector storage. Constitutional assessments stored in dedicated Qdrant collection.
Context pressure events become CONTEXT_PRESSURE audit entries. Constitutional observer flags decisions made under context pressure for governance review.