---
title: "How we continuously validate formal specifications in production"
description: "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."
url: "https://swe.quest/articles/how-we-continuously-validate-formal-specifications-in-production-8af79b473bcc3ebf"
canonical: "https://www.datadoghq.com/blog/engineering/continuous-formal-spec-validation/"
source: "Datadog Engineering"
published: "2026-11-05"
difficulty: "hard"
kind: "Case study"
reading_minutes: 16
tags: ["formal-methods","testing","distributed-systems","rust","observability"]
---

# How we continuously validate formal specifications in production

A post on [Datadog Engineering](https://swe.quest/sources/datadog.md), published 2026-11-05, 16 min read, Case study. Original: [https://www.datadoghq.com/blog/engineering/continuous-formal-spec-validation/](https://www.datadoghq.com/blog/engineering/continuous-formal-spec-validation/)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Formal methods](https://swe.quest/tags/formal-methods.md) (Architecture & design)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Distributed systems](https://swe.quest/tags/distributed-systems.md) (Distributed systems)
- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)

## Prerequisites

- TLA+ basics ([easy posts on Formal methods](https://swe.quest/tags/formal-methods.md?difficulty=easy))
- model checking ([easy posts on Formal methods](https://swe.quest/tags/formal-methods.md?difficulty=easy))
- distributed system invariants
- Kafka partitioning ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))

## Keywords

TLA+, FETCh, Husky, Datadog, Rust, PObserve, Kafka

## Related posts

- [How we use formal modeling, lightweight simulations, and chaos testing to design reliable distributed systems](https://swe.quest/articles/how-we-use-formal-modeling-lightweight-simulations-and-chaos-testing-to-design-aca03cf9b6abf48d.md): Datadog Engineering · 2024-11-20 · Hard · 23 min read · Formal methods, Queues & messaging, Distributed systems, Chaos engineering, Multi-tenancy
  Datadog 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.
- [Protocol-Aware Deterministic Simulation Testing](https://swe.quest/articles/protocol-aware-deterministic-simulation-testing-7f3b613be8faf2a6.md): TigerBeetle · 2026-08-20 · Hard · 10 min read · Formal methods, Testing, Consensus, Replication, Storage engines
  TigerBeetle'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.
- [Simulation Testing For Liveness](https://swe.quest/articles/simulation-testing-for-liveness-7a5ba398eed57d56.md): TigerBeetle · 2023-07-06 · Hard · 4 min read · Formal methods, Testing, Consensus, Distributed systems, Resilience
  TigerBeetle'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.
- [Diagnosing instability in production-scale agent reinforcement learning](https://swe.quest/articles/diagnosing-instability-in-production-scale-agent-reinforcement-learning-d64c85292b24dcc4.md): Engineering@Microsoft · 2026-01-28 · Hard · 6 min read · Model training, AI agents, Observability, LLMs
  Late-phase instability in on-policy RL for tool-using agents can come from variance amplification in tool-conditioned contexts.
- [Making Rust observability reliable at scale with OpenTelemetry](https://swe.quest/articles/making-rust-observability-reliable-at-scale-with-opentelemetry-93edfa18e478ae5a.md): Datadog Engineering · 2026-09-01 · Medium · 10 min read · Observability, Rust, Open source
  Datadog 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
