Stateful / model-based testing (Wave 4, 2.2.0)#8
Merged
Conversation
New Rasuvaeff\PropertyTesting\StateMachine namespace: the Command interface (preCondition/nextState/run/postCondition + Stringable label), the CommandSequence value, StateMachine::check() runner, and PostconditionViolation. Gen::commands() returns CommandSequenceArbitrary, which generates valid-by- construction command sequences and shrinks them by dropping command blocks (down to a single step, isolating a failing middle command) and simplifying each command's parameters; the runner skips any command whose precondition a dropped step invalidated. Also: counterexamples and verbose logs render Stringable arguments via __toString(), and a shrunk property reports the minimised run's failure rather than the original draw's. Docs: README/llms.txt sections, CHANGELOG 2.2.0, examples/state_machine.php, package AGENTS invariants, and ROADMAP updated to the 2-release plan (2.2.0 = Wave 4; 2.3.0 = Waves 5+6 merged).
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.
Wave 4 — stateful / model-based testing (
2.2.0)Tests sequences of operations against a simplified model and shrinks the
failing sequence to the shortest one that still breaks — the single biggest gap
vs. non-PHP property-testing libraries.
Public API (new
Rasuvaeff\PropertyTesting\StateMachinenamespace)Command extends \Stringable—preCondition($model),nextState($model),run($model, $system),postCondition($model, $result),__toString().Gen::commands($initialModel, $commandGenerators, $minLength = 0, $maxLength = 100)→
CommandSequenceArbitrary, generating valid-by-construction sequences.StateMachine::check(CommandSequence $sequence, Closure $systemFactory)— callfrom the property body; drives the sequence against a fresh system per run.
CommandSequence(\Stringablevalue) andPostconditionViolation.Design
Reuses the existing
#[Property]machinery: the command sequence is a normalarbitrary passed as one argument, so seed reproducibility,
maxShrinks,PROPERTY_RUNS/SEED/VERBOSEand reporting all come for free. Validity isenforced at run time, not shrink time — the runner skips any command whose
precondition a dropped/simplified step invalidated (fast-check model), so
shrinking stays a cheap pure list operation. Shrinking removes command blocks
(down to a single command, isolating a failing middle step) then simplifies each
command's parameters through its own tree.
Cross-cutting changes
\Stringablearguments via__toString()instead of the class name.Failure:line matches the
Shrunk:arguments.Verification
composer buildgreen — 394 tests.bc-checkvsv2.1.0: no backwards-incompatible changes (additive only).bound;
CommandSequence::__toStringempty-return / array_map unwrap).bin/package-audit: 0 errors, 0 warnings; all 4 examples run.Roadmap
Post-
2.1.0waves now ship as two minors instead of three:2.2.0= Wave 4(this PR);
2.3.0= Waves 5 + 6 merged. SeeROADMAP.md.