feat(verifier): retry NextAction up to 16x so gated generators eventually fire

This commit is contained in:
pj committed 2026-04-18 06:39:00 +07:00
1 parent 6c7ea35a7d
commit cefb398437
1 file changed
+15 -2
+15 -2
View File
@@ -113,12 +113,25 @@ func (v *Verifier) EvaluateProperties() map[string]ltl.Verdict {
} }
// NextAction resolves the root action generator into a single Action. // NextAction resolves the root action generator into a single Action.
// Returns ErrNoAction when the generator yields nothing actionable. // Returns ErrNoAction when no branch of the generator produces one after a
// small number of retries. Retrying avoids wedging when most branches of a
// weighted generator produce no action on the current screen (e.g. a gated
// login-phone generator when the app is already past login).
func (v *Verifier) NextAction() (Action, error) { func (v *Verifier) NextAction() (Action, error) {
if v.actionGenerator == nil { if v.actionGenerator == nil {
return Action{}, ErrNoAction return Action{}, ErrNoAction
} }
return v.resolveGenerator(v.actionGenerator) const maxRetries = 16
for range maxRetries {
action, err := v.resolveGenerator(v.actionGenerator)
if err == nil {
return action, nil
}
if !errors.Is(err, ErrNoAction) {
return Action{}, err
}
}
return Action{}, ErrNoAction
} }
var ErrNoAction = errors.New("verifier: no action available") var ErrNoAction = errors.New("verifier: no action available")