Repository navigation
test(core): error-path conformance for TLA+ refinement — Err must be a stutter - #1683
Merged
Merged
Conversation
…a stutter TLA+ actions are atomic: a disabled guard means NO transition, so the models cannot express (and TLC can never catch) partial-mutation-then-error. That obligation lives at the refinement boundary — and it is exactly where #1677 hid: TLC was green while FIFO/LIFO/HIFO oversells drained lots before erroring. The then-current conformance layer could not see it either: prop_conservation_invariant clamped reductions to min(current) and skipped Err with if-let-Ok; prop_non_negative_inventory generated the precise failing input but asserted NOTHING on the Err branch. - prop_conservation_invariant: unclamped reduce amounts (Err now reachable), Err asserts a full inventory snapshot unchanged, conservation checked after every step. - prop_non_negative_inventory: oversell must Err AND leave the inventory untouched. - NEW prop_failed_reduce_is_a_stutter: all 7 booking methods x 4 error classes (oversell / wrong currency / unknown label / unmatched cost, ambiguous under STRICT) — Err implies snapshot-identical state. - RUST_MAPPING.md: new 'Refinement Obligations' section documenting the stutter obligation, where it is checked, and the generator rules for future conformance tests (violate the guards; never if-let-Ok-skip Err). 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 formal-verification conformance checks at the Rust↔TLA+ refinement boundary, ensuring failed Inventory::reduce operations behave like TLA+ stutter steps (no observable state transition) and making error paths reachable in existing invariants.
Changes:
- Updated conservation + non-negative inventory properties to intentionally exercise failing reductions and assert inventory stutter on
Err. - Added
prop_failed_reduce_is_a_stutterto assert failed reductions do not mutate inventory across booking methods and error classes. - Documented the new “Refinement Obligations” (stutter rule) and where it is enforced.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spec/tla/RUST_MAPPING.md | Documents the refinement “Err must be a stutter” obligation and maps each obligation to its Rust test coverage. |
| crates/rustledger-core/tests/tla_proptest.rs | Strengthens existing TLA+ proptests to cover Err paths + adds a new stutter-focused property with an inventory snapshot helper. |
💡 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 was referenced Jul 2, 2026
Merged
robcohen
added a commit
that referenced
this pull request
Jul 2, 2026
Patch release. User-facing fixes since v0.19.0: - NONE booking: over-reduction now shorts past zero from ANY balance (consumes available units, appends the remainder as a negative position), fixing the inconsistency where shorting from a positive balance was rejected while shorting from zero was allowed (#1686, via #1688). - try_reduce: the read-only preview is now reduce-on-a-clone — equivalent to the mutating path by construction. Previously it diverged under STRICT (FIFO fallback instead of AmbiguousMatch), NONE (error instead of short), and {*} merge (wrong dispatch) (#1690). No WIT change (rustledger:ledger stays 3.2.0); embedders are unaffected. Also carries the formal-verification hardening arc (#1683-#1697): behavior replay across 11 corpora, dual-direction trace validation, exact-rational AVERAGE model, coverage lint, weekly escalated replay, pad-directive spec, and Kani proofs for the new NONE semantics. Workspace 0.19.0 -> 0.19.1; packages/mcp-server bumped to match. Co-authored-by: Claude Opus 4.8 <[email protected]>
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.
First of two formal-verification PRs (per the model↔implementation gap analysis after #1677).
The gap this closes
TLA+ actions are atomic — a disabled guard means no transition, so the specs cannot express (and TLC can never catch) "mutate halfway, then fail". That obligation lives at the refinement boundary, and it's exactly where #1677 hid: TLC was green while FIFO/LIFO/HIFO oversells drained lots before erroring.
The conformance layer couldn't see it either — validated line-by-line:
prop_conservation_invariantclamped every reduction tomin(current)and skippedErrwithif let Ok(..)→ the buggy state was unreachable.prop_non_negative_inventorygenerated the precise failing input (current + 1oversell) but asserted nothing on theErrbranch.Changes
prop_conservation_invariant: unclamped amounts (error path reachable),Err⟹ full-snapshot-unchanged, conservation re-checked after every step.prop_non_negative_inventory: oversell mustErrand leave the inventory untouched.prop_failed_reduce_is_a_stutter: all 7 booking methods × 4 error classes (oversell / wrong currency / unknown label / unmatched cost, + STRICT ambiguity) —Err⟹ state bit-identical. 300 cases.RUST_MAPPING.md: new Refinement Obligations section — the stutter rule, where each obligation is checked, and generator rules for future conformance tests (violate the guards; neverif let Ok-skip).Would have caught #1677 outright; with #1677's fix on main, all 20 properties pass. clippy
-D warnings+ fmt clean.Companion PR: the TLC trace→Rust-test converter (roadmap's "Now" item).
🤖 Generated with Claude Code