Versions in this module Expand all Collapse all v0 v0.1.0 Apr 13, 2026 Changes in this version + var ErrActionValueType = errors.New("rules: action value type mismatch") + var ErrActionsZero = errors.New("rules: actions registry is nil or not initialized") + var ErrAssert = errors.New("rules: assertion error") + var ErrAssertFailed = errors.New("rules: assertion failed") + var ErrCardinalityViolation = errors.New("rules: single-use action used multiple times") + var ErrCompile = errors.New("rules: compilation failed") + var ErrDefine = errors.New("rules: action definition failed") + var ErrDefinitionDuplicate = errors.New("rules: duplicate definition") + var ErrDuplicateRegistration = errors.New("rules: duplicate registration") + var ErrMultipleTerminals = errors.New("rules: multiple terminal actions in rule") + var ErrNoDefinitions = errors.New("rules: no rule definitions provided") + var ErrProgramZero = errors.New("rules: program is nil or not compiled") + var ErrUnknownAction = errors.New("rules: unknown action") + var ErrUnknownDefinition = errors.New("rules: unknown definition") + func Check[E any](compiler *anyexpr.Compiler[E], when string) error + type Action struct + Triggered bool + Triggers []Trigger[V] + Value V + Values []V + type ActionEntry struct + Name string + Value any + type ActionInfo struct + Cardinality action.Cardinality + Description string + Name string + Terminal bool + ValueType string + type Actions struct + func DefineActions[E any, A any]() (*Actions[E, A], error) + func (ac *Actions[E, A]) Describe() []ActionInfo + func (ac *Actions[E, A]) IsZero() bool + type Assertion struct + func NewAssertion[A any](expr string) (*Assertion[A], error) + func (a *Assertion[A]) Assert(eval *Evaluation[any, A]) error + func (a *Assertion[A]) AssertResult(result A) error + type CompileOpt func(*CompileOpts[E, A]) error + type CompileOpts struct + type Definition struct + Enabled *bool + Mode EvalMode + Name string + Skip string + Stop bool + Tags []string + Then []ActionEntry + When string + func (d Definition) IsEnabled() bool + type EvalMode int + const SkipThenWhen + const WhenThenSkip + func (m EvalMode) String() string + type Evaluation struct + Duration time.Duration + Env E + Matched []string + Result A + StartedAt time.Time + Stopped bool + StoppedBy string + Trace []Step + Traced bool + func TestRule[E any, A any](compiler *anyexpr.Compiler[E], actions *Actions[E, A], def Definition, env E) (*Evaluation[E, A], error) + func (e *Evaluation[E, A]) Debug() string + type EvaluationOpt func(*evaluationConfig) + func ExcludeNames(names ...string) EvaluationOpt + func ExcludeTags(tags ...string) EvaluationOpt + func MustWithSelector(expr string) EvaluationOpt + func WithNames(names ...string) EvaluationOpt + func WithSelector(expr string) (EvaluationOpt, error) + func WithTags(tags ...string) EvaluationOpt + func WithTrace(enabled bool) EvaluationOpt + type Evaluator struct + func NewEvaluator[E any, A any](program *Program[E, A], opts ...EvaluatorOpt) (*Evaluator[E, A], error) + func (ev *Evaluator[E, A]) Run(ctx context.Context, env E, opts ...EvaluationOpt) (*Evaluation[E, A], error) + type EvaluatorOpt func(*evaluatorConfig) + func OnEvaluation(opts ...EvaluationOpt) EvaluatorOpt + type Outcome int + const OutcomeDisabled + const OutcomeExcluded + const OutcomeMatched + const OutcomeSkipExpr + const OutcomeSkipped + func (o Outcome) String() string + type Program struct + func Compile[E any, A any](compiler *anyexpr.Compiler[E], actions *Actions[E, A], defs []Definition, ...) (*Program[E, A], error) + func (p *Program[E, A]) IsZero() bool + type Registry struct + func NewRegistry[E any, A any](compiler *anyexpr.Compiler[E], actions *Actions[E, A]) (*Registry[E, A], error) + func (r *Registry[E, A]) Add(defs ...Definition) error + func (r *Registry[E, A]) Compile(opts ...CompileOpt[E, A]) (*Program[E, A], error) + func (r *Registry[E, A]) Definitions() []Definition + func (r *Registry[E, A]) Len() int + func (r *Registry[E, A]) Remove(names ...string) + func (r *Registry[E, A]) Update(defs ...Definition) error + func (r *Registry[E, A]) Upsert(defs ...Definition) + type RuleMeta struct + Name string + Tags []string + type Step struct + Actions []string + Duration time.Duration + Mode EvalMode + Outcome Outcome + Rule string + Selector string + Skip string + type TestCase struct + Assertions []string + Env E + Name string + Rule Definition + type TestResult struct + Error error + Evaluation *Evaluation[E, A] + Failures []string + Name string + Passed bool + func RunTestCase[E any, A any](compiler *anyexpr.Compiler[E], actions *Actions[E, A], tc TestCase[E, A]) TestResult[E, A] + type Trigger struct + Rule string + Tags []string + Value V