refs

package
v0.3.0-beta.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package refs validates loop template and CEL references against one namespace.

Index

Constants

View Source
const (
	// CodeUnknownReference identifies an unknown namespace root or symbol.
	CodeUnknownReference = "unknown_reference"
	// CodeUnresolvablePath identifies a known symbol with a missing child path.
	CodeUnresolvablePath = "unresolvable_path"
	// CodeItemOutsideFanout identifies item/index usage outside fan-out scope.
	CodeItemOutsideFanout = "item_outside_fanout"
	// CodeConditionNotBool identifies a CEL expression that does not return bool.
	CodeConditionNotBool = "condition_not_bool"
	// CodeUnsafeCommandInterpolation identifies command output outside the safe shell quoting contract.
	CodeUnsafeCommandInterpolation = "unsafe_command_interpolation"
)

Variables

This section is empty.

Functions

func CostWarningThresholdReached

func CostWarningThresholdReached(cost, limit uint64) bool

CostWarningThresholdReached reports the inclusive 80-percent warning boundary.

func RenderCommandTemplateString

func RenderCommandTemplateString(name string, raw string, data any) (string, error)

RenderCommandTemplateString materializes one validated shell command template.

func RenderTemplateString

func RenderTemplateString(name string, raw string, data any) (string, error)

RenderTemplateString parses and executes one runtime interpolation template with the same curated functions and missing-key behavior used by CompileTemplate.

Types

type Condition

type Condition struct {
	Raw        string
	Program    cel.Program
	References []Reference
	CostLimit  uint64
}

Condition is a compiled CEL bool expression plus validated references.

func (*Condition) Evaluate

func (c *Condition) Evaluate(variables map[string]any) (ConditionEvaluation, error)

Evaluate executes the compiled condition and reports its measured cost.

type ConditionCompiler

type ConditionCompiler struct {
	// contains filtered or unexported fields
}

ConditionCompiler compiles CEL expressions over the shared namespace.

func NewConditionCompiler

func NewConditionCompiler(
	namespace Namespace,
	opts ...ConditionCompilerOption,
) (*ConditionCompiler, error)

NewConditionCompiler builds a CEL environment for the shared namespace.

func (*ConditionCompiler) Compile

func (c *ConditionCompiler) Compile(raw string) (*Condition, error)

Compile parses, validates, checks, and caches a CEL bool expression.

type ConditionCompilerOption

type ConditionCompilerOption func(*ConditionCompiler)

ConditionCompilerOption configures a condition compiler.

func WithCostLimit

func WithCostLimit(limit uint64) ConditionCompilerOption

WithCostLimit overrides the CEL runtime cost limit.

type ConditionEvaluation

type ConditionEvaluation struct {
	Value       bool
	Cost        uint64
	CostWarning bool
}

ConditionEvaluation is one pure CEL result with its measured runtime cost.

type Error

type Error struct {
	Code             string
	Path             []string
	DeepestValidPath []string
	AvailableFields  []string
	AvailableNodes   []string
	Message          string
}

Error reports a namespace validation failure.

func (*Error) Error

func (e *Error) Error() string

type Namespace

type Namespace struct {
	Inputs       map[string]Schema
	Nodes        map[string]NodeSchema
	AllowFanout  bool
	AllowTrigger bool
	AllowEvent   bool
}

Namespace is the single reference namespace consumed by templates and CEL.

func (Namespace) ValidatePath

func (n Namespace) ValidatePath(path []string) *Error

ValidatePath checks a dotted path against the namespace.

type NodeSchema

type NodeSchema struct {
	Output    Schema
	HasOutput bool
}

NodeSchema exposes the referenceable output/status shape for one node.

type Reference

type Reference struct {
	Raw  string
	Path []string
}

Reference records one resolved template or CEL path.

type Schema

type Schema map[string]any

Schema is a permissive JSON-schema-compatible shape used for path validation.

type Template

type Template struct {
	Raw        string
	Parsed     *template.Template
	References []Reference
}

Template is a parsed value interpolation template plus validated references.

func CompileCommandTemplate

func CompileCommandTemplate(name string, raw string, namespace Namespace) (*Template, error)

CompileCommandTemplate validates a shell command template before runtime materialization. Every action that emits runtime data must end in shellQuote so data cannot become shell syntax.

func CompileTemplate

func CompileTemplate(name string, raw string, namespace Namespace) (*Template, error)

CompileTemplate parses and validates one Go text/template string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL