Documentation
¶
Overview ¶
Package expr evaluates JS boolean/value expressions (n8n's "{{ $json.x }}" convention, already used by seshat-backend's inbox event filter) for dataflow nodes that need per-item logic (filter/if/set/switch) — unlike event_filter.go's one-VM-per-call approach (fine for a single check per inbound message), a dataflow node may evaluate the same expression against many items in one run, so this pool reuses goja runtimes and caches compiled bytecode across evaluations.
Index ¶
Constants ¶
const DefaultTimeout = 2 * time.Second
DefaultTimeout bounds a single evaluation — an expression authored by an LLM (the Inbox Agent) is untrusted input in the same sense event_filter.go already treats it: it must fail loudly rather than hang the graph.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool evaluates expressions against a bounded set of reused goja runtimes, caching compiled bytecode by source string. A goja.Runtime cannot run two scripts concurrently, so runtimes are checked out/in like a connection pool; Compile is the expensive, reusable part (bytecode has no per-run state), so it's cached independently of runtime checkout.
func NewPool ¶
NewPool creates a pool that keeps up to maxRuntimes JavaScript runtimes ready to evaluate expressions (8 when it is 0 or less) and caches the compiled programs.