Anchor
Deterministic governance infrastructure for autonomous AI systems.
Anchor is an open-source governance engine that performs static analysis, runtime policy enforcement, deterministic decision auditing, and constitutional enforcement for AI systems. Published as anchor-audit on PyPI.
Overview
Anchor exists because policy expressed only in prose cannot govern autonomous systems reliably. The system turns governance into executable infrastructure so runtime behavior can be inspected, replayed, and reviewed.
By checking codebases against formal compliance parameters using AST matching rather than probabilistic reviews, Anchor guarantees absolute determinism in policy outcomes.
Problem
- AI systems make opaque, probabilistic decisions that are difficult to audit or enforce.
- Standard regex-based scanning creates high volumes of false positives in dependency code.
- Post-hoc logging fails to provide cryptographically checkable evidence of compliance.
Motivation
I built Anchor after noticing that teams deploying LLMs were repeatedly solving compliance in an ad hoc, probabilistic way.
The core motivation was to bring the rigor of compiler design and formal static analysis to the runtime behavior of AI agents.
Solution
Anchor parses codebases into abstract syntax trees (ASTs) using Tree-sitter, evaluating declarative rules defined in .anchor files.
Decisions are logged to a tamper-evident audit file with Ed25519 signatures, enabling cryptographic validation of decision history.
Implementation
The core scan loop is written in Python, operating in two modes: AST node query matching (Mode A) and regex fallback (Mode B).
It compiles and runs as a CLI command line utility (anchor check) and packages policy intents separately from detection matches.
Engineering Decisions
We decoupled rule definitions (policy intent) from detection scripts to allow policy authors and parser developers to work independently.
We selected AST parsing over standard regex matching for the primary check to eliminate false positives in downstream code.
Challenges & Lessons
Handling syntax variations across multiple host languages (Python, Go, JS/TS, Rust) within a single unified AST query model.
Keeping execution latency down to microsecond scales during runtime policy interception.
Anchor Pipeline
Flagship system
Application Source Code ↓ (Tree-sitter Parser) Abstract Syntax Tree (AST) ↓ (Rule Matcher / AST Queries) Enforcement Rules (.anchor) ↓ (Runtime Interceptor) Ed25519 Signed Log File ↓ (Replay & Verification) Verifiable Decision Proof
Every step is linear and deterministic.
The audit logs act as verifiable receipts.
Components
Functional building blocks
The flagship documentation uses the same component taxonomy across every system.
AST Parser
Builds structured trees of source files using Tree-sitter.
Rule Matcher
Checks code patterns against declarative policy domains.
Runtime Interceptor
Applies policy rules inline during live API execution.
Signer
Signs every decision with Ed25519 keys for audit durability.
Features
Core capabilities
These are product features in the engineering sense, not marketing copy.
Multi-language AST scanning
✓Deterministic rule execution
✓Ed25519 cryptographic signatures
✓Separation of rule from detection
✓CLI tool & PyPI package
✓Integration example
Scan codebases and run enforcement checks.
pip install anchor-audit anchor init --all anchor check .
Example output
A governed action should return enough evidence to review without reconstructing the entire runtime path.
Scanned: 742 files Violations: 2 Blocker, 1 Error Log signed: .anchor/reports/latest.json
Documentation
- anchor check
- anchor init
- anchor sync
- anchor verify
Papers & Consultation Briefs
Benchmarks
- Repository scan: <3 seconds
- Runtime interception: <2.1ms
- AST node parsing: ~40ms
Roadmap
The roadmap separates what is already shipped from the next layer of work so the public record stays explicit.
Shipped
AST scanning · Ed25519 log signing · PyPI release v5
Next
Dataflow variable tracking · Multi-agent authorization chains · VS Code extension
Related Systems
Connected systems
Systems in the ecosystem that depend on or complement this flagship project.