Skip to content

feat(31): shared invariants module in quickwit-dst#6246

Open
g-talbot wants to merge 3 commits intogtt/phase-31-pg-metastorefrom
gtt/phase-31-execute
Open

feat(31): shared invariants module in quickwit-dst#6246
g-talbot wants to merge 3 commits intogtt/phase-31-pg-metastorefrom
gtt/phase-31-execute

Conversation

@g-talbot
Copy link
Copy Markdown

Summary

  • Adds invariants/ module to quickwit-dst — the single source of truth for invariant definitions shared across the verification pyramid (TLA+ specs, stateright models, production code)
  • InvariantId enum catalogs all 20 invariants (SS-1..5, TW-1..3, CS-1..3, MC-1..4, DM-1..5) with Display and descriptions
  • Shared pure functions: window_start_secs(), is_valid_window_duration(), compare_with_null_ordering()
  • check_invariant! macro always evaluates the condition (debug and release), implementing both Layer 3 (Prevention — debug_assert! panic in debug) and Layer 4 (Production — pluggable InvariantRecorder for Datadog metrics)
  • set_invariant_recorder(fn) wires up statsd at process startup; no recorder = no-op (single OnceLock load)
  • stateright is now an optional dependency behind model-checking feature — production crates pull only the invariant definitions, not the model checker
  • quickwit-parquet-engine uses shared functions and check_invariant! macro instead of inline debug_assert!

Stacks on gtt/phase-31-pg-metastore (PR #6245).

Test plan

  • cargo test -p quickwit-dst — 11 invariant unit tests + 2 doctests pass
  • cargo test -p quickwit-dst --features model-checking — all 24 tests pass (stateright models use shared functions)
  • cargo test -p quickwit-parquet-engine — all 153 tests pass
  • cargo test -p quickwit-metastore --all-features — all 187 tests pass (including postgres)
  • cargo test -p quickwit-indexing --all-features — 234 pass (8 pre-existing Pulsar/GCP PubSub flakes skipped)
  • cargo test -p quickwit-integration-tests --all-features — all 46 pass
  • cargo clippy -p quickwit-dst --all-features --tests — clean
  • cargo clippy -p quickwit-parquet-engine --all-features --tests — clean

🤖 Generated with Claude Code

quickwit_cli::logger::setup_dogstatsd_exporter(build_info)?;

#[cfg(not(any(test, feature = "testsuite")))]
quickwit_cli::logger::setup_invariant_recorder();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we group those two into one thing?

Maybe call it:

quickwit_cli_logger::setup_metrics();

}

#[cfg(not(any(test, feature = "testsuite")))]
fn invariant_recorder(id: quickwit_dst::invariants::InvariantId, passed: bool) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id -> invariant_id

@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from c8836d6 to eccf657 Compare March 31, 2026 20:41
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch 2 times, most recently from 3eb3316 to c4418dd Compare March 31, 2026 20:55
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch 2 times, most recently from 6eeaecd to f2113e5 Compare March 31, 2026 21:03
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch 2 times, most recently from aa5ff45 to 142ddd6 Compare March 31, 2026 21:08
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from f2113e5 to 0d561b4 Compare March 31, 2026 21:08
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch from 142ddd6 to 972bd20 Compare March 31, 2026 21:26
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from 0d561b4 to 8ba9201 Compare March 31, 2026 21:26
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch from 972bd20 to 73c90c4 Compare March 31, 2026 21:29
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from 8ba9201 to 0761d11 Compare March 31, 2026 21:30
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch from 73c90c4 to 44bd6bb Compare March 31, 2026 21:31
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from 0761d11 to b551b13 Compare March 31, 2026 21:31
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch from 44bd6bb to add1902 Compare March 31, 2026 21:33
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from b551b13 to 398cdf2 Compare March 31, 2026 21:33
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch from add1902 to d88f67f Compare March 31, 2026 21:40
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch 2 times, most recently from 3289f58 to dbbbd8b Compare March 31, 2026 21:50
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch from d88f67f to b5b840e Compare March 31, 2026 21:50
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from dbbbd8b to 54a1f95 Compare April 1, 2026 10:48
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch 2 times, most recently from c8e6070 to cc704b5 Compare April 1, 2026 11:02
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from 54a1f95 to 9696d99 Compare April 1, 2026 11:02
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from 9696d99 to bf23ab3 Compare April 1, 2026 11:10
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch from cc704b5 to bf93060 Compare April 1, 2026 11:10
g-talbot and others added 3 commits April 1, 2026 07:30
Extract duplicated invariant logic into a shared `invariants/` module
within `quickwit-dst`. This is the "single source of truth" layer in
the verification pyramid — used by stateright models, production
debug_assert checks, and (future) Datadog metrics emission.

Key changes:
- `invariants/registry.rs`: InvariantId enum (20 variants) with Display
- `invariants/window.rs`: shared window_start_secs(), is_valid_window_duration()
- `invariants/sort.rs`: generic compare_with_null_ordering() for SS-2
- `invariants/check.rs`: check_invariant! macro wrapping debug_assert
- stateright gated behind `model-checking` feature (optional dep)
- quickwit-parquet-engine uses shared functions and check_invariant!

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The check_invariant! macro now always evaluates the condition — not just
in debug builds. This implements Layer 4 (Production) of the verification
stack: invariant checks run in release, with results forwarded to a
pluggable InvariantRecorder for Datadog metrics emission.

- Debug builds: panic on violation (debug_assert, Layer 3)
- All builds: evaluate condition, call recorder (Layer 4)
- set_invariant_recorder() wires up statsd at process startup
- No recorder registered = no-op (single OnceLock load)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Emit cloudprem.pomsky.invariant.checked and .violated counters with
invariant label via the metrics crate / DogStatsD exporter at process
startup, completing Layer 4 of the verification stack.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@g-talbot g-talbot force-pushed the gtt/phase-31-execute branch from bf93060 to cedd6ca Compare April 1, 2026 11:30
@g-talbot g-talbot force-pushed the gtt/phase-31-pg-metastore branch from bf23ab3 to a60b361 Compare April 1, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants