Lexecon is execution control for AI agents.
It intercepts agent tool calls before execution, enforces deterministic policy, and writes a cryptographically verifiable decision trail.
This repository proves one narrow workflow end to end:
- An agent attempts a tool call (
shell.run). - Lexecon intercepts it before execution.
- Policy returns
ALLOW,BLOCK, orESCALATE. - Lexecon writes a signed, hash-chained audit record.
- Blocked calls do not execute.
- An offline verifier can detect audit tampering.
- Sandboxed operating-system isolation.
- Enterprise key management (HSM/KMS).
- Distributed transparency logs or remote attestation.
- Complete command parsing resistant to advanced obfuscation.
pip install -e ".[dev]"
lexecon init-keys
lexecon demo
lexecon verify .audit/ledger.jsonlThe demo command attempts:
rm -rf ./important_dataExpected result: Decision: BLOCK, Executed: false, and Ledger verification: valid.
Creates local Ed25519 keys in .lexecon/:
private_key.pempublic_key.pem
Runs the narrow destructive-command demo through the full interceptor path.
Verifies the ledger by checking:
- Record hash recomputation.
previous_hashchain continuity.- Ed25519 signatures.
Outputs Status: VALID or Status: INVALID with per-record errors.
pip install -e ".[dev]"
pytestCurrent suite: 44 tests.
lexecon/
cli.py # CLI entrypoints: init-keys, demo, verify
enforcement/
policy_engine.py # Deterministic YAML policy evaluation
interceptor.py # Enforcement boundary: decision -> audit -> optional execution
decision.py # Decision model (ALLOW/BLOCK/ESCALATE)
tools/
shell.py # shell.run wrapper used only after ALLOW
audit/
record.py # Canonical record schema + hashing helpers
ledger.py # Append-only JSONL writing + hash chain linkage
signer.py # Ed25519 key generation/sign/verify
verifier.py # Offline ledger integrity verification
policies/
default_policy.yaml # Dangerous command blocking patterns
examples/
block_destructive_shell.py # Scripted demo path
tests/ # Unit and end-to-end coverage
- Protected asset: real-world tool execution.
- Trust boundary: agent output crossing into tool execution.
- Control point:
Interceptor.intercept(). - Audit goal: prove what was decided and whether the record was modified later.
- Fail-closed behavior: interceptor errors return
BLOCKand prevent execution.
See SECURITY_REVIEW_REPORT.md for detailed findings and limitations.
lexecon/enforcement/interceptor.pylexecon/enforcement/policy_engine.pylexecon/audit/ledger.pylexecon/audit/verifier.pytests/test_demo_flow.pytests/test_verifier.py
MIT