Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sudont.xyz/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Sudont Constitution is an AOT-compiled policy object. Operators author their rules in JSON or YAML; the compiler lowers every allowlist, denylist, and mathematical bound into memory-aligned Rust HashSet and BTreeMap structures. At evaluation time, the Judge dereferences pre-hashed keys against pre-aligned buckets so policy evaluation stays line-rate with the RPC — indistinguishable from zero alongside the Cage’s bare-metal simulation run.
The Constitution is compiled once at policy load, not interpreted per-transaction. Hot-path decisions never parse strings, walk trees, or allocate. This is how Sudont meets sub-millisecond latency targets while enforcing thousands of rules.

Why AOT Compilation

A policy-as-code system that evaluates JSON at runtime loses to garbage collection, cache misses, and branch mispredictions. Sudont’s compiler flattens the entire ruleset into a single contiguous memory layout:

Memory-Aligned HashSets

Every allowlist entry is pre-hashed into a fixed-capacity Rust HashSet with a cache-line aligned backing allocation. Lookups hit L1 on the first probe.

Zero Allocation

Evaluation never calls malloc. The compiler reserves every buffer during policy load; the hot path is pure arithmetic and pointer comparison.

Deterministic Dispatch

Rule lookup is O(1) by construction. No tree walks, no regex, no string comparison in the Judge.

Line-Rate Evaluation

Hash-set membership and integer comparison against pre-aligned buckets. A full Constitution evaluation fits well inside the RPC path alongside the Cage’s bare-metal simulation run.

Policy Fields

Every Constitution exposes the same compiled schema. The PolicySnapshot struct in sudont-types captures the compiled form used by the Judge.
FieldType (compiled)Purpose
chain_allowlistHashSet<ChainId>Permitted chain IDs
protocol_allowlistHashSet<ProtocolId>Permitted protocol identifiers
target_allowlistHashSet<Address>Permitted router / contract addresses
token_allowlistHashSet<Address>Permitted tokens
token_denylistHashSet<Address>Blocked tokens
max_trade_sizeU256Absolute size cap in base units
max_slippage_bpsu32Slippage tolerance in basis points
max_price_impact_bpsu32Price impact cap
min_liquidityU256Minimum pool liquidity threshold
private_route_requiredboolForce private mempool egress
fail_closedboolReject any transaction with uncertain state

Compilation Pipeline

Author Policy

Operators write JSON or YAML against the Constitution schema. Source-of-truth is versioned in source control, not stored in a database.

Validate and Canonicalise

The compiler validates every field, resolves aliases, and canonicalises addresses to their checksummed form.

Lower to HashSets

Allowlists and denylists are lowered into fixed-capacity, memory-aligned HashSet structures. Numerical bounds are unpacked into native U256 / u32 fields.

Freeze Snapshot

The compiled PolicySnapshot is made immutable. A content hash is computed and embedded in every ExecutionAttestation so downstream systems can verify which policy approved a trade.

Hot-Path Evaluation

At evaluation time the Judge holds a shared reference to the compiled PolicySnapshot and performs only the following operations per transaction:
  • Hash-set membership checks against allowlists and denylists — pre-hashed keys landing in cache-line-aligned buckets that hit L1 on the first probe.
  • Integer comparisons of simulated State-Diff against max_slippage_bps, max_price_impact_bps, and max_trade_size — single-cycle each.
  • Boolean gates for private_route_required and fail_closed.
No string parsing, no allocation, no I/O. A full Constitution evaluation fits comfortably alongside the Cage’s bare-metal simulation run — both stay line-rate with the RPC.
Because the compiled snapshot is content-hashed, the Constitution version that approved any given trade is cryptographically anchored in the ExecutionAttestation. Auditors can reconstruct the exact rule set active at any point in time.

ReAct Error Payload

See how Constitution violations are serialised into deterministic JSON errors consumed by agentic ReAct loops.