Circuit breaker protocol for autonomous AI economies. Prevents goal drift, velocity attacks, and agent conflicts in real-time.
This is the reference implementation. Not production ready.
cargo run -p haltchain-apiRun unit tests for the workspace (policy, validator, API stubs):
cargo test --workspaceYou can also build all crates:
cargo build --workspaceStart the HTTP server (listens on port 3000):
cargo run -p haltchain-apiHealth probe:
curl http://localhost:3000/healthValidate an action (allowed example):
curl -s -X POST http://localhost:3000/validate \
-H 'Content-Type: application/json' \
-d '{"agent_id":"trader_bot_01","api_key":"dev-key","action":{"type":"transfer","amount":500,"currency":"USD","recipient":"acct_abc"}}'Validate an action that violates the hard-coded policy (denied):
curl -s -X POST http://localhost:3000/validate \
-H 'Content-Type: application/json' \
-d '{"agent_id":"trader_bot_01","api_key":"dev-key","action":{"type":"transfer","amount":1500,"currency":"USD","recipient":"acct_abc"}}'Rate-limit / circuit-breaker behavior (10 actions per minute): send 11 rapid requests to trip the breaker:
for i in $(seq 1 11); do
curl -s -X POST http://localhost:3000/validate \
-H 'Content-Type: application/json' \
-d '{"agent_id":"rater","api_key":"dev","action":{"type":"generic"}}'
echo
doneCheck agent status (circuit-breaker + rate usage):
curl http://localhost:3000/status/raterInstall the SDK (dev path):
pip install ./sdk/pythonExample usage:
import haltchain
agent = haltchain.Client(agent_id="trader_bot_01", api_key="dev-key")
@agent.validate
def execute_trade(order):
# This function runs only if HaltChain returns ALLOW
print("executing", order)
execute_trade({"type": "transfer", "amount": 100, "currency": "USD", "recipient": "acct_x"})