.aegis AST Policy DSL with Deny-Overrides SemanticsAutonomous agents invoking enterprise ERP and financial tools require deterministic, sub-millisecond authorization before executing side effects. Relying on “LLM-as-a-Judge” guardrails for SOX Segregation of Duties or spend caps is non-deterministic, vulnerable to prompt injection, and adds 300–1,000ms of tail latency per step. Conversely, using Python eval() on dynamic rule expressions introduces arbitrary code execution risks (__subclasses__ sandbox escapes).
eval(): Trivial to implement, catastrophic blast radius if policy authors or dynamic expressions access Python object internals. Rejected..aegis Lexer + Recursive-Descent AST Compiler (src/aegis/policy/): Inspired by AWS Cedar (permit/forbid blocks, explicit namespace whitelisting, Deny-Overrides conflict resolution).We implemented a dedicated lexer (lexer.py), recursive-descent compiler (parser.py), and side-effect-free evaluator (evaluator.py) for .aegis policies:
principal, action, context) are grammar-valid; any __ dunder token is rejected at lex time.forbid rule matches, the verdict is DENY regardless of matching permit rules; if zero permit rules match, the verdict is DENY.RuleEvaluationTrace tuple and completes in 29 µs median (p99 < 90 µs).vendor_country) must be hydrated into context before evaluation.