Repository navigation
test(tla): implementation-trace validation — the dual refinement direction - #1691
Merged
Merged
Conversation
…ction The behavior-replay suite checks model -> implementation (every model behavior implemented correctly, exhaustively). This adds the DUAL, implementation -> model: seeded-random op sequences drive the REAL Inventory, the abstract state is recorded after every operation, and TLC verifies each recorded transition satisfies Conservation.tla's Next relation via the ConformsToConservation action property ([][C!Next]_specVars over a trace-following spec). An implementation transition the model forbids fails the property. Together the two directions give two-sided refinement checking — exhaustive model-side, continuously sampled implementation-side. - examples/conservation_trace_gen.rs: deterministic generator (seeded LCG, no clocks/deps); failed reduces are treated as disabled actions (stutters) and not recorded; --corrupt breaks the final state for the negative self-check. - scripts/tla-trace-validate.py: builds a trace-following TLA module + cfg per trace, INSTANCE Conservation, runs TLC; --self-test proves the harness both ACCEPTS a hand-checked legal trace and REJECTS an illegal one (a vacuously green harness is the failure mode to fear). - tla.yml: new step runs the self-test then validates 24 fresh traces per run (seed = github.run_id, printed for exact reproduction); Rust toolchain added to the workflow for the generator. Verified locally end-to-end with real TLC: self-test OK (illegal trace rejected with 'Action property ConformsToConservation is violated'), 8/8 implementation traces conform, corrupted traces fail the run. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the missing “implementation → model” refinement check to the MBT layer by generating real Inventory traces and validating each recorded transition against the TLA+ Conservation model in CI, complementing the existing exhaustive “model → implementation” behavior replay.
Changes:
- Added a Rust trace generator example (
conservation_trace_gen) that drives realInventoryAdd/Reduce sequences and emits abstract state traces. - Added a Python trace validator that wraps traces into a trace-following TLA+ module and has TLC check the
Nextaction property. - Extended the
tla.ymlworkflow and mapping docs to run and document the dual-direction trace validation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| spec/tla/RUST_MAPPING.md | Documents the new dual-direction trace-validation approach and how it complements behavior replay. |
| scripts/tla-trace-validate.py | New validator script that generates per-trace TLA+ modules/config and runs TLC action-property checking. |
| crates/rustledger-core/examples/conservation_trace_gen.rs | New deterministic trace generator example for producing implementation traces from real Inventory. |
| .github/workflows/tla.yml | Adds CI step to self-test the validator and validate fresh traces each run using a varying seed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
📊 Benchmark Results
vs main branch (2026-07-02)
What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FV follow-up #2 (of the improvement menu), companion to #1690. Closes the remaining conceptual gap in the MBT layer.
The gap
The behavior-replay suite (#1685/#1688) checks model → implementation: every model behavior is implemented correctly, exhaustively up to the bound. The dual — implementation → model, i.e. the implementation never takes a transition the model forbids — was unchecked.
The mechanism (MongoDB/etcd-style trace validation)
examples/conservation_trace_gen.rsdrives the realInventorythrough seeded-random Add/Reduce sequences (deterministic LCG — no clocks, no deps; failed reduces = disabled actions = stutters, not recorded) and emits the abstract state after every operation.scripts/tla-trace-validate.pywraps each trace in a trace-following TLA+ spec (C == INSTANCE Conservation) and has TLC verify the[][C!Next]_specVarsaction property — every recorded transition must be a legal model step.tla.ymlruns the validator's self-test, then validates 24 fresh traces per run (seed =github.run_id, printed for exact reproduction — continuous sampling of the dual direction).Trustworthiness of the harness itself
The self-test proves both directions: a hand-checked legal trace is accepted and an illegal one is rejected (
Action property ConformsToConservation is violated) — plus the generator's--corruptmode is verified to fail the pipeline. A vacuously-green harness is the failure mode to fear; this one demonstrably detects violations.Together with #1685/#1688: two-sided refinement checking — exhaustive on the model side, continuously sampled on the implementation side. Extension to other specs follows the same template (documented in
RUST_MAPPING.md).Verified locally with real TLC
Self-test OK · 8/8 real implementation traces conform · corrupted traces fail · clippy
-D warnings+ fmt clean. This PR triggers the TLA workflow itself, so the new step runs on this very PR.🤖 Generated with Claude Code