Skip to content

adapter: Add TLA+ formal verification of timestamp selection#35803

Draft
antiguru wants to merge 1 commit intoMaterializeInc:mainfrom
antiguru:formal_timestamp_selection
Draft

adapter: Add TLA+ formal verification of timestamp selection#35803
antiguru wants to merge 1 commit intoMaterializeInc:mainfrom
antiguru:formal_timestamp_selection

Conversation

@antiguru
Copy link
Copy Markdown
Member

Summary

  • Adds a TLA+ specification modeling the constraint solver in determine_timestamp_via_constraints over a bounded timestamp domain (0..4)
  • Covers all three isolation levels (Serializable, StrictSerializable, StrongSessionSerializable) and all QueryWhen variants
  • TLC exhaustively verifies 750k input combinations checking: lower/upper bound respect, real-time ordering, completeness, soundness, and preference correctness
  • Packaged as an mzcompose test with a Docker container running the TLC model checker

Test plan

  • bin/mzcompose --find tla run timestamp-selection passes locally (750k states, 6s, all 7 properties verified)
  • Integrate in CI pipeline

TODO: Integrate the check in ci/test/pipeline.template.yml

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

Thanks for opening this PR! Here are a few tips to help make the review process smooth for everyone.

PR title guidelines

  • Use imperative mood: "Fix X" not "Fixed X" or "Fixes X"
  • Be specific: "Fix panic in catalog sync when controller restarts" not "Fix bug" or "Update catalog code"
  • Prefix with area if helpful: compute: , storage: , adapter: , sql:

Pre-merge checklist

  • The PR title is descriptive and will make sense in the git log.
  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).

@antiguru antiguru force-pushed the formal_timestamp_selection branch from 573caf3 to 193849c Compare March 31, 2026 12:42
Add a TLA+ specification that models the constraint solver in
`determine_timestamp_via_constraints` as a pure function over a bounded
timestamp domain. The spec covers constraint generation for all three
isolation levels (Serializable, StrictSerializable,
StrongSessionSerializable) and all QueryWhen variants.

TLC exhaustively verifies 750,000 input combinations checking:
- Result respects all lower/upper bounds
- Real-time ordering (result >= oracle_read_ts when oracle is a constraint)
- Completeness (non-empty interval => success)
- Soundness (success => non-empty interval)
- FreshestAvailable picks the largest valid timestamp
- StalestValid picks the smallest valid timestamp

Packaged as an mzcompose test: `bin/mzcompose --find tla run timestamp-selection`

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@antiguru antiguru force-pushed the formal_timestamp_selection branch from 193849c to e0d74f6 Compare March 31, 2026 14:10
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.

1 participant