Repository navigation
Trim a ConformTo failure to the steps the divergence needs - #34
Merged
Merged
Conversation
CsCheck shrinks a state-dependent walk by its choices and can keep a refused trigger that changes nothing. ConformTo and ConformToMutable now replay the failing walk, remove each step that is not needed, and report the smaller trace, noting how many steps were trimmed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
ConformToandConformToMutablenow report the shortest trace that shows a divergence, instead of whatever CsCheck's shrinking stopped at.Prompt summary: File the library findings from the landing audit as issues and open a PR for each, smallest fix first. This is the last, and the largest.
Closes #25.
Why
For an implementation that allows
shipinCancelled, the shortest failing walk isplace,cancel,ship. Across 14 runs of that demo, CsCheck's report showed 3 steps in 3 runs and 4, 5 or 7 steps in the rest, with a refusedpayinCancelledkept as step 3. CsCheck picks each step of a walk from the triggers that are possible in the current state, so removing an earlier step changes the later choices and shrinking cannot delete it.What
Replay and trim
While CsCheck runs,
ConformTorecords each walk. When CsCheck reports a failure, the recorded failing walk is replayed against a fresh entity, and each step is removed in turn while the divergence still happens, until no step can go. The report keeps CsCheck's seed line, adds "trimmed from 4 to 3 steps", and prints the smaller trace in the same layout. A failure that is already minimal is rethrown unchanged.Both entry points
ConformToreplays on the immutable entity, andConformToMutablecreates a fresh instance for every replay.ConformToServiceAsyncis untouched: it generates a plain array of triggers, which CsCheck already shrinks well.Tests
Two tests run the failing door 12 times each and require "diverged from the specification at step 2" every time. Without the change they fail (steps 3, 4 and 5 appear). The
CsChecktest project passes (264 tests onnet10.0), and I ran the 14-run demo again: 14 of 14 reports show 3 steps.Out of scope: The seed in the report reproduces CsCheck's original, longer failure, not the trimmed trace. The trace in the report is what to replay.
Verify
dotnet run --project tests/Nullean.Entities.CsCheck.Tests -c Release -f net10.0 # 264 passed