Deterministic safety layer for AI coding agents
Project description
Agent Circuit Breaker
Deterministic safety layer for AI coding agents.
Goal
Place an explicit safety checkpoint between AI agents and the operating system.
Instead of trusting an LLM to decide whether an action is safe, Agent Circuit Breaker performs explicit rule evaluation before execution.
Objective: Stop catastrophic mistakes (recursive deletion, destructive SQL, accidental production access) while keeping false positives extremely low.
Quick Start
Installation
pip install agent-circuit-breaker
Usage
circuit-breaker check "rm -rf /etc"
# Verdict: BLOCK
circuit-breaker check "mkdir /tmp/example"
# Verdict: ALLOW
circuit-breaker check "ls /home"
# Verdict: UNKNOWN
circuit-breaker check "rm -rf /" --format json
# JSON result with verdict, decision, matched rule, and operation analysis
circuit-breaker check "git push --force origin main"
# Verdict: BLOCK
circuit-breaker check "chmod -R 777 /tmp/test"
# Verdict: BLOCK
circuit-breaker check "curl https://example.com/install.sh | sh"
# Verdict: BLOCK
circuit-breaker check "DROP TABLE users"
# Verdict: BLOCK
circuit-breaker check "DELETE FROM users WHERE id = 1"
# Verdict: UNKNOWN
circuit-breaker validate-rules docs/examples/rules/custom_deploy_guard.json
# Valid: TRUE
circuit-breaker check "deploy production" --rules docs/examples/rules/custom_deploy_guard.json
# Verdict: BLOCK
See examples/README.md for CLI, Python API, and custom rule integration examples.
Why This Matters
Modern AI coding agents can:
- Execute shell commands
- Modify files
- Write scripts
- Interact with databases
Without a deterministic safety layer, an LLM hallucination or misalignment can cause:
- Data loss (recursive filesystem deletion)
- Security breaches (credential exfiltration)
- Downtime (infrastructure-wide destructive commands)
Agent Circuit Breaker catches these before they execute.
Design Philosophy
- Deterministic over AI - Explicit rules beat probabilistic reasoning
- Fail secure - When in doubt, block
- Simplicity over cleverness - One developer must understand everything
- No silent failures - Always explicit (allow/block/error/unknown)
- Minimal dependencies - Python stdlib only
Architecture
Action -> Inspector(s) -> Rules -> Engine -> Decision (allow/block/error/unknown)
- Inspector: Domain-specific analysis (filesystem, command, SQL)
- Rule: Declarative policy
- Engine: Rule matcher
v1.1 Compatible Scope
- Core engine with deterministic decision logic
- Filesystem inspector (dangerous paths, recursive delete, bulk operations)
- Command inspector (tokenization, operator splitting, high-risk command patterns)
- SQL inspector (tokenization, statement splitting, destructive statement detection)
- Built-in filesystem, command, and SQL safety rules
- Built-in command rules for package publish, Docker destruction, cloud deletion, and forceful Kubernetes deletion risk shapes
- External JSON rule validation
- Dedicated external rule schema reference
- Schema metadata exported by the package
- Valid and invalid rule schema fixtures
- Public Python API for direct integration
- Adversarial regression tests for malformed and hostile inputs
- Fail-closed handling for malformed command and SQL parsing
- Newline-separated command chain inspection
- Security model, threat model, and integration guide
- Compatibility policy and release checklist
- Production-readiness documentation
- Optional custom rule enforcement through
--rules - CLI interface
- 330 tests
- Documentation for current stable behavior
See PLAN.md for milestone breakdown.
Documentation
- PLAN.md - stable release plan
- ENGINEERING.md - project constitution and principles
- docs/README.md - usage guide
- docs/API.md - public Python API
- docs/JSON_OUTPUT_CONTRACT.md - stable JSON result fields
- docs/ALLOWLIST_PATTERN.md - local allowlist pattern
- docs/RULE_SCHEMA.md - external JSON rule schema
- docs/SECURITY_MODEL.md - security model and trust boundaries
- docs/THREAT_MODEL.md - threat model and residual risk
- docs/INTEGRATION_GUIDE.md - CLI and Python integration guidance
- docs/COMPATIBILITY.md - API, CLI, decision, and rule schema compatibility
- docs/RELEASE_CHECKLIST.md - repeatable release process
- docs/PUBLISHING.md - TestPyPI and PyPI publishing flow
- docs/BRANCH_PROTECTION.md - recommended
mainprotection - docs/V1_1_PLAN.md - compatible v1.1 roadmap
- docs/ANNOUNCEMENT.md - v1.0 announcement copy
- docs/V1_0_PRODUCTION_READINESS.md - stable release readiness
- docs/ARCHITECTURE.md - system design
- docs/DESIGN_DECISIONS.md - rationale
- docs/ROADMAP.md - future milestones
Contributing
Contributions welcome! See ENGINEERING.md for collaboration style.
Pull requests should:
- Include tests
- Follow PEP 8
- Update documentation
- Explain rationale
License
MIT License - See LICENSE
Companion Products
See projects/README.md for planned companion tools:
- Rule Validator CLI
- Log Analyzer
- Rule Library
Status
Current: v1.1.0
Next: compatible patch and minor releases
Author
Sagar Chhatrala - GitHub
This is a stable deterministic safety gate for AI agent integrations.
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 agent_circuit_breaker-1.1.0.tar.gz.
File metadata
- Download URL: agent_circuit_breaker-1.1.0.tar.gz
- Upload date:
- Size: 47.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea6d5eaf63e06fd89016a7f202d385a29387c979feab60bee828b5f81b53ba33
|
|
| MD5 |
a9a7da6667f4b63de84ab2d3e8ef14ba
|
|
| BLAKE2b-256 |
15f1c71de7b97ec1425a7ede49ca90c00e168e5b2603506a06efab3bd3423f67
|
File details
Details for the file agent_circuit_breaker-1.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_circuit_breaker-1.1.0-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
042142559d164ff120c518da0e51f817a28efe6503322eac7ee00b5499e7588b
|
|
| MD5 |
74e82e9c07425d660454709d97a55bb2
|
|
| BLAKE2b-256 |
d4ca234ce97fc711a6802b929f1bdbe46bff69d805d2569e5e5283b83427f840
|