feat: state machine self check - #137
Merged
Merged
Conversation
…onformance helper Two pieces every consumer of a machine-with-a-twin writes for itself, found by auditing the first one (nwyc) that got far enough to need them. StateMachineSelfCheckHealthCheck had zero product content: resolve every registered IMachine, call SnapshotSelfCheck.Run, map an empty result to Healthy. It belongs next to the thing it checks, with AddTraxStateMachineSelfCheck() so a host adds it in one line and a newly-registered machine is picked up with no edit. MachineConformance folds the three drift checks a generated twin needs into one call. Written by hand they come out as three test files with two copies of the same path plumbing and no statement anywhere of why three are needed, so the helper documents that: the IR check catches a machine edit that skipped regeneration, the corpus check catches a build that shipped a stale golden, and the self-check catches an engine that no longer reproduces it. It is framework-agnostic like DifferentialCorpus -- returns problems, asserts nothing -- because consumers are split across NUnit and xUnit. The corpus check is new rather than lifted: consumers compare the committed corpus by replaying it, which cannot tell them their assembly embedded a different one. Comparing the file to the embedded copy closes that, and makes the self-check's result meaningful. Still to move, both blocked on packaging rather than design: a default HttpContext-backed ISnapshotPrincipal, and the Testcontainers + AddStateMachines + AddTraxGraphQL server fixture every e2e rebuilds. Both need ASP.NET Core references that Persistence deliberately does not have, so they want a .AspNetCore package rather than being forced in here.
…nformance The health check is thin but its three claims are not: corpus-less machines are skipped rather than failed, every divergent machine is named (not just the first), and the registration resolves IEnumerable<IMachine> at run time, which is what lets a host add the line once and have a machine discovered later be covered. The last one only shows up through HealthCheckService, so the AddTraxStateMachineSelfCheck tests build a provider and read the report rather than inspecting registrations. MachineConformance gets both verdicts of each leg over real files: a missing artifact, a stale one, a committed corpus that differs from the embedded copy, and a machine whose engine no longer replays what it ships. The trailing-newline tolerance is pinned too, since committed artifacts carry one and the in-memory forms do not. The fakes live in the Persistence test project because MachineConformance is over IMachine, and the declarative Machine<,> turnstile is already there.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
This PR is included in version 1.52.0 |
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.
No description provided.