How we continuously validate formal specifications in production
FETCh (Formal Execution Trace Checker) compiles TLA+ specifications into Rust runtime monitors that consume production telemetry and flag any state transition the spec forbids, catching drift between a formal model and the evolving implementation. Datadog applied it to Husky's event routing system and found that a placement-logic change had let conflicting placements persist for about a year, which would have crashed backfill during placement data-loss recovery. TLA+ refinement lets an unbounded observable spec be monitored in production while a bounded refinement stays model-checkable. Lightweight typing via existential quantifiers and type annotations makes the specs translatable to code. Monitor state stays tractable by checking placements globally and checking per-event routing locally in sidecars.
Related posts
- How we use formal modeling, lightweight simulations, and chaos testing to design reliable distributed systems
Datadog Engineering hardMasterDatadog validated the design of Courier, a multi-tenant message queue built on multiple FoundationDB clusters after its March 2023 outage, by combining TLA+ formal modeling, lightweight simulations and chaos testing. Each tenant is sharded across 4 of 8 FoundationDB clusters so that no two tenants share the same set, and brokers health-check clusters and route around failures. The TLA+ spec models brokers, senders and receivers with weak fairness, and TLC checks properties such as at-least-once delivery across every reachable state. Simulations then cover what model checking cannot, such as latency, cost and scalability. Together these give design-level confidence that unit tests miss, at the cost of keeping models and simulations in sync with the design.
- Protocol-Aware Deterministic Simulation Testing
TigerBeetle hardMasterTigerBeetle's deterministic simulator (the VOPR) has full visibility into each replica's consensus and storage state, so it can check invariants that black-box tools like Jepsen or Antithesis cannot see through user-facing APIs. For safety, it asserts that every committed WAL entry has matching checksums across replicas, that LSM manifest structure is consistent everywhere, and that replicas are byte-for-byte identical, which goes deeper than the cheaper production checks that crash a diverging backup. For liveness, it enforces per-replica invariants: a replica with an uncorrupted WAL must never need cluster coordination to recover, and missing blocks must be repaired from intact copies on other replicas whenever any copy still exists.
- Simulation Testing For Liveness
TigerBeetle hardMasterTigerBeetle's VOPR simulator now has a "liveness" mode alongside its "safety" mode, because uniformly random, eventually-healing faults can never surface livelocks such as a permanently asymmetric partition that triggers endless view changes. After a period of random fault injection, the simulator picks a quorum as the core, restarts and heals everything inside it, makes all failures involving non-core replicas permanent, and then requires the core to process every transaction before a timeout. The new mode found a resonance bug in which parallel log repair combined with round-robin repair targets always sent each missing op to the one replica that also lacked it, a stall that previously cleared only when a restart reset the counter.
- Diagnosing instability in production-scale agent reinforcement learning
Engineering@Microsoft hardMasterLate-phase instability in on-policy RL for tool-using agents can come from variance amplification in tool-conditioned contexts. Post-tool states fall in low-support regions of the reference policy, so importance-ratio tails grow while loss, reward, entropy and global KL stay flat. A small-scale reproduction shows p95 per-token log-ratio growth and right-tail CDF stretching in post-tool slices, with effective sample size used as a supporting signal; constraining tool outputs or drift-aware baselines suppressed the growth. The proposed fix is monitoring rather than a new optimizer: slice diagnostics by pre-tool versus post-tool contexts, track tail percentiles in-stream across workers, and treat KL caps and rollbacks as load-bearing guardrails. These checks ship in Microsoft's open-source Post-Training Toolkit, now integrated into Hugging Face TRL.
- Making Rust observability reliable at scale with OpenTelemetry
Datadog Engineering mediumAdeptDatadog built dd-trace-rs, an opinionated Rust tracer on top of the OpenTelemetry Rust SDK, to fix fragmented traces, inconsistent sampling and context loss across Rust services. Upstream, they rewrote OpenTelemetry's active-context slot as a stack that tolerates out-of-order and overlapping scopes, which made some context operations 2–4x faster. They also fixed the tracing-opentelemetry bridge and a tracing subscriber callback bug so OpenTelemetry spans attach correctly inside tracing spans. On the Datadog side, a custom sampler defers keep/drop decisions and a span processor flushes whole trace chunks, emitting statistics for dropped spans; together these cut ingestion volume 20x while tripling indexed spans per service.