func (col *CollectAggregator) Aggregate(prg cel.Program, vars interpreter.Activation,
	prev model.DecisionValue, rule model.Rule) (model.DecisionValue, error) {
	val, det, err := prg.Eval(vars)
	if err != nil {
		return nil, err
	}
	var prevList *model.ListDecisionValue
	if prev != col.defDec {
		prevList = prev.(*model.ListDecisionValue)
	} else {
		prevList = model.NewListDecisionValue(col.name)
	}
	prevList.Append(val, det, rule)
	return prevList, nil
}
Aggregate appends the value produced by evaluating the CEL program (if not error) with the
previous values observed for the decision.

Note: the collect aggregator does not quite follow CEL semantics with respect to list
construction as the output decision value may include CEL types.Unknown values within it.
It is up to the application to decide whether to error or resolve the unknowns.
package runtime
import (
	"github.com/google/cel-policy-templates-go/policy/model"
	"github.com/google/cel-go/cel"
	"github.com/google/cel-go/common/types"
	"github.com/google/cel-go/interpreter"
)
type Aggregator interface {
	DefaultDecision() model.DecisionValue
	Aggregate(cel.Program,
		interpreter.Activation,
		model.DecisionValue,
		model.Rule) (model.DecisionValue, error)
}
func NewAndAggregator(name string) TemplateOption {
	return DecisionAggregator(
		name,
		&AndAggregator{
			name:   name,
			defDec: model.NewBoolDecisionValue(name, types.True),
		},
	)
}
type AndAggregator struct {
	name   string
	defDec *model.BoolDecisionValue
}
func (and *AndAggregator) DefaultDecision() model.DecisionValue {
	return model.NewBoolDecisionValue(and.name, types.True)
}
func (and *AndAggregator) Aggregate(prg cel.Program, vars interpreter.Activation,
	prev model.DecisionValue, rule model.Rule) (model.DecisionValue, error) {
	val, det, _ := prg.Eval(vars)
	prevBool := prev.(*model.BoolDecisionValue)
	decVal := prevBool.And(val)
	if decVal.Value() == types.False {
		decVal.Finalize(det, rule)
	}
	return decVal, nil
}
func NewCollectAggregator(name string) TemplateOption {
	return DecisionAggregator(
		name,
		&CollectAggregator{
			name:   name,
			defDec: model.NewListDecisionValue(name),
		},
	)
}
type CollectAggregator struct {
	name   string
	defDec *model.ListDecisionValue
}
func (col *CollectAggregator) DefaultDecision() model.DecisionValue {
	return col.defDec
}