Skip to content

Guard machine edges, count faults across starts, and tighten counter-example checks - #105

Merged
Mpdreamz merged 3 commits into
mainfrom
feature/text-inside-external-tags
Nov 19, 2026
Merged

Mpdreamz merged 3 commits into
mainfrom
feature/text-inside-external-tags

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

ConformTo can now check an edge that is only taken while a condition holds, Faults() copes with several starts, and AutoTest says 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. 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 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, as Exhaustive() does, an Allow edge, When guard or action is no longer exercised.

Counter-example and exercise checks (#37 to #40)

CounterExampleReport reads not applicable for Idempotent and 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 new

I 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.Tests passes on net11.0.

Out of scope: #36 asks for either coverage inside Faults() or a NoOps() terminal. CsCheck's SpecFaultsReport has an internal constructor, so Faults() cannot report coverage; NoOps() is the second option. The report Faults() returns with several starts is the best single start's, so a row that says NOTHING may have been caught from another start; the writeLine output has one merged line per fault. ConformToExhaustive reaches each entity by a shortest path, so it seldom exhausts a bound like "3 attempts": use ConformTo for that.

Note for consumers: AxisRun gains two optional parameters (SingleCause, MinimumExercise), and CounterExampleKind gains NotApplicable. Both are source-compatible; code that constructs AxisRun positionally 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

Mpdreamz and others added 3 commits November 19, 2026 19:07
`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>
@Mpdreamz Mpdreamz added the enhancement An existing capability improved (minor bump) label Nov 19, 2026
@Mpdreamz
Mpdreamz enabled auto-merge (squash) November 19, 2026 18:07
@Mpdreamz
Mpdreamz merged commit 4df58da into main Nov 19, 2026
10 checks passed
@Mpdreamz
Mpdreamz deleted the feature/text-inside-external-tags branch November 19, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment