Invariant Specification & IDE Integration
Declare mathematical pre-trade risk invariants directly above outbound execution functions using native C++ or Rust attributes. The compiler and IDE Language Server verify constraints at compile time without adding runtime branches.
1. Inline Invariant Declaration (C++ / Rust)
Quantize market telemetry into exact rational fractions (ℚ) to prevent IEEE 754 floating-point drift and guarantee finite SMT proof convergence:
// Hardcode statutory and desk exposure limits directly into C++ AST
[[bath::invariant("notional_limit <= 5000000_Q")]]
[[bath::invariant("price_slippage_floor >= 995_Q / 1000_Q")]]
[[bath::invariant("max_order_delta_ns <= 1200_Q")]]
void execute_order_routing(Rational price, Rational size) {
// Critical execution path — zero runtime branch checks emitted
transmit_outbound_wire(price, size);
}2. Real-Time IDE AST Verification (LSP)
Add the compiler language server to Cursor or Visual Studio Code settings for sub-second AST feedback:
"bath.lsp.path": "~/.bath/bin/bath-compile", "bath.lsp.args": ["--lsp", "--strict-invariants"]