Repository navigation
Guard machine edges, count faults across starts, and tighten counter-example checks - #105
Merged
Merged
Conversation
`EntitySpec.Faults()` with several starts now counts a fault as caught when any start catches it, and fails only for a fault no start catches. Before, it threw on the first start that did not catch every fault, including faults only another start can trigger. A fault that changed no step from any start is reported as never triggered. `EntitySpec.NoOps()` replaces each action with one that returns its input and asks whether a requirement fails or, as `Exhaustive()` does, an `Allow` edge, `When` guard or action is no longer exercised. `Faults()` cannot count coverage, so its automatic "X has no effect" faults were reported but never caught. Part of #35 and #36. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`Permit<TEntity>(trigger, from, to, when: e => ...)` declares an edge that is only taken while a condition holds, so "retry while attempts are left" no longer makes `ConformTo` diverge once the entity refuses the fourth retry. `ConformTo` and `ConformToMutable` evaluate the guard on the entity before each step: true, the entity must take the edge; false, it must stay where it is. The exhaustive variants evaluate it on each entity they reach. The edge stays in the diagram, and without an entity (`Spec()`, `TryFire`, `AsConstraint`, `ToMermaid()`) it is permitted. A guard written for another entity type than the one under test is refused up front. Closes #42. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`CounterExampleReport` reads `not applicable` for an `Idempotent` or order-independence rule instead of "NONE FOUND, write one": no value breaks a rule about an operation, so the advice could not be followed. `CounterExample(rule, breakIt, appliesTo)` names the bases a counter-example applies to, and the docs say a value it leaves unchanged is skipped. `RequireSingleCause()` holds counter-examples the search finds to one cause, as given ones are. `MinimumExercise(share)` fails an axis that exercises a rule in a smaller share of the runs, and a rule under 10% passes with a warning that names it. Closes #37, #38, #39 and #40. 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.
ConformTocan now check an edge that is only taken while a condition holds,Faults()copes with several starts, andAutoTestsays less that is wrong and asks for more when you want it to.Prompt summary: Work on seven related issues from real use of the library (#35 to #40 and #42) in one pull request: guards on declared machine edges, faults across several starts, the "X has no effect" fault, and the counter-example and exercise checks of
AutoTest.Why
Each issue is a place where a correct entity or a correct test failed, or a gap passed in silence. A machine edge that the entity refuses after its budget diverged from the diagram.
Faults()with two starts failed for faults only the other start can trigger. Reports told you to write a counter-example that cannot exist, and an axis that exercised a rule in 4 of 200 runs passed with no warning.What
Guards on machine edges (#42)
Permit<TEntity>(trigger, from, to, when: e => ...)declares a guarded edge.ConformToandConformToMutableevaluate the guard on the entity before each step: true, the entity must take the edge; false, it must stay where it is. The edge stays in the diagram, and without an entity (Spec(),TryFire,ToMermaid()) it is permitted. The entity type is named because the machine does not know it. A guard for another type than the one under test is refused up front.Faults across starts, and
NoOps()(#35, #36)Faults()counts a fault as caught when any start catches it, and fails only for one no start catches. A fault that changed no step from any start is reported as never triggered.NoOps()replaces each action with one that returns its input and asks whether a requirement fails or, asExhaustive()does, anAllowedge,Whenguard or action is no longer exercised.Counter-example and exercise checks (#37 to #40)
CounterExampleReportreadsnot applicableforIdempotentand order-independence rules.CounterExample(rule, breakIt, appliesTo)names the bases it applies to, and the docs say a value left unchanged is skipped.RequireSingleCause()holds found counter-examples to one cause.MinimumExercise(share)fails an axis that exercises a rule in a smaller share of runs, and a rule under 10% passes with a warning that names it.Verify
dotnet run --project tests/Nullean.Entities.CsCheck.Tests -f net11.0 # GuardedMachineTests, FaultsAcrossStartsTests, NoOpsTests, CounterExampleStrictnessTests are newI broke each new behaviour on purpose (guard ignored, single cause ignored, coverage ignored, minimum ignored, and so on) and the matching tests failed. The CsCheck, core, Reactive and examples test projects pass on net10.0 and net11.0;
Apps.Testspasses on net11.0.Out of scope: #36 asks for either coverage inside
Faults()or aNoOps()terminal. CsCheck'sSpecFaultsReporthas an internal constructor, soFaults()cannot report coverage;NoOps()is the second option. The reportFaults()returns with several starts is the best single start's, so a row that says NOTHING may have been caught from another start; thewriteLineoutput has one merged line per fault.ConformToExhaustivereaches each entity by a shortest path, so it seldom exhausts a bound like "3 attempts": useConformTofor that.Note for consumers:
AxisRungains two optional parameters (SingleCause,MinimumExercise), andCounterExampleKindgainsNotApplicable. Both are source-compatible; code that constructsAxisRunpositionally and was compiled earlier needs a rebuild.Closes #42
Closes #40
Closes #39
Closes #38
Closes #37
Closes #36
Closes #35
🤖 Generated with Claude Code