Skip to content

Trim a ConformTo failure to the steps the divergence needs - #34

Merged
Mpdreamz merged 1 commit into
mainfrom
feature/conform-minimal-trace
Oct 20, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
feature/conform-minimal-trace

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

ConformTo and ConformToMutable now 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 ship in Cancelled, the shortest failing walk is place, 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 refused pay in Cancelled kept 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, ConformTo records 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

ConformTo replays on the immutable entity, and ConformToMutable creates a fresh instance for every replay. ConformToServiceAsync is 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 CsCheck test project passes (264 tests on net10.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

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>
@Mpdreamz Mpdreamz added the bug Something isn't working label Oct 20, 2026
@Mpdreamz
Mpdreamz merged commit f12a258 into main Oct 20, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConformTo failure trace keeps steps the failure does not need

1 participant