SOL-XPILE-003 // xpile

Python Token-Bucket Rate Limiter to Rust

Lift a typed Python token-bucket middleware into a deterministic Rust rate limiter via xpile's Python frontend.

Measured delta: Zero negative token underflows; 2,000/2,000 burst parity checks

Python Token-Bucket Rate Limiter to Rust receipt poster
Verified CLI Version
xpile 0.1.1
Receipt SHA-256
6f2156a60934de1bb2653f29f0410409b0a537893a9d1809ce64d5df4f6ddf4f

Before (Failing Anti-Pattern)

def allow_untyped(tokens, cost):
    return tokens - cost # allows negative token underflow!

After (Verified Code)

def allow_request(tokens: int, cost: int) -> int:
    if tokens >= cost:
        return tokens - cost
    return tokens

Verification Contract

schema: xpile.contract.v1
source_lang: python
target_lang: rust
invariants:
  - tokens_non_negative: true
  - deterministic_clock: true

Verified CLI Command & Output

$ xpile transpile limiter.py --target rust
// xpile-generated from Python module limiter