Repository navigation
Suggest the calls that make a failing state transition verify - #411
Open
CatarinaGamboa wants to merge 1 commit into
Open
CatarinaGamboa wants to merge 1 commit into
CatarinaGamboa wants to merge 1 commit into
Conversation
When a call is made in a state that does not allow it, the verifier builds the class's state machine from its state sets and state refinements, proving each transition with the SMT solver, and searches it for the shortest sequences of calls that lead to a state allowing the call. The error then suggests those calls and lists the calls allowed in the current state. Only transitions that depend on nothing but the state of the object are modeled, and a call is suggested only when a single state refinement allows it in every state the object can be in, as in the verifier, so every suggestion makes the failing call verify. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks done
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.
Stacked on #410.
Description
When a typestate call fails, the State Refinement Error now says which calls to add before it, and which calls are allowed in the object's current state.
processor/state_machine/:StateMachineBuilderbuilds a class's state machine. Its states are the combinations of its@StateSetstates, and each transition is proven with the SMT solver on two fresh objects in a separate scope.StateMachineholds the graph and searches it: a breadth-first search over sets of states, so it also works when the object can be in several states.StateSolverwraps the SMT questions.diagnostics/hints/StateHintsturns the machine into hints: it reads the machine and never calls SMT.AuxStateHandlercomputes the hints right before throwing the error. If computing them fails, the error is reported without hints.To make sure a hint is never wrong:
thisare modeled. A method whose refinement mentions parameters, return values or other ghosts is left out, and the machine is marked incomplete.@StateRefinementallows all of them, aschangeStaterequires.this. Formake().read()an added call could act on a different object.The next PRs add hints for dead ends (unreachable or final state, state depending on the path taken) and for an unknown state, and then cache the machine once per run.
Example
Type of change
Checklist
ErrorStateHint{CallSequence,TwoCalls,MultipleSets,SeveralRefinements,MethodCallReceiver}andTestStateHints, which checks the exact hints (including that the last two get none)mvn testpasses locally🤖 Generated with Claude Code