Hexarch Guardrails
Hexarch Guardrails is a lightweight, policy‑driven Python library for enforcing safety rules before a function runs. It is designed to stop destructive or expensive operations at the function boundary, with decisions recorded to an audit log for later review.
What it is (and what it isn’t)
It is:
- A Python guardrails library that enforces policy at runtime.
- Pre‑execution control for deletes, spend limits, and risky automation.
- Auditable by default (SQLite locally; Postgres for production).
It is not:
- A generic “LLM guardrails” framework.
- A heavy platform or SaaS dependency.
- A post‑hoc logging tool.
Core Capabilities
- Policy‑driven enforcement via
hexarch.yaml - Pre‑execution interception with
@guardian.check("policy_id") - Audit logging of every allow/deny decision
- CLI tooling for reviewing audit history
- SQLite for local development, Postgres for production
Install
pip install hexarch-guardrails==0.4.6b1
# Optional extras
pip install "hexarch-guardrails[cli,postgres]==0.4.6b1"
Minimal Example
from hexarch_guardrails import Guardian
from hexarch_guardrails.exceptions import PolicyViolation
guardian = Guardian() # loads hexarch.yaml
@guardian.check("safe_delete")
def delete_user(user_id):
print(f"Deleted user {user_id}")
try:
delete_user("user_123")
except PolicyViolation as e:
print(f"Blocked: {e}")
Auditing & Proof
Every policy decision is written to a decision ledger (decisions.db for SQLite, or Postgres in production). This record is your evidence trail for:
- Incident reviews
- SOC2 / HIPAA readiness
- Cost‑savings attribution (blocked spend)
- Operational auditability
Official Links
- PyPI: https://pypi.org/project/hexarch-guardrails/
- GitHub: https://github.com/no1rstack/hexarch-guardrails
- Documentation: https://www.hexarch.systems/docs
Note: you may see the package mirrored on other indexes (e.g., piwheels), but PyPI is the canonical source.