Nodora
Language

Basics

Anatomy of a Nodora program

A Nodora source file is a list of signal declarations and rule declarations at the top level. Whitespace is insignificant and line comments start with //.

// declarations live at the top level
signal NotifyUser(user_id, message)

rule RateLimitCheck {
    limit = if input.plan == "free" then 100 else 1000
    exceeded = input.requests_last_hour > limit

    emit NotifyUser(input.user_id, "You exceeded your hourly quota") when exceeded

    out allowed = !exceeded
}

Rules

A rule is a named block of statements. Each rule receives an input object provided at evaluation time and may declare any number of outputs and emissions.

rule Name {
    // statements
}

Statements run top-to-bottom and only support two forms: assignments and emits. There are no loops, no early returns, and no mutation — each local name is bound exactly once.

Assignments

is_adult = input.age >= 18      // local binding
out approved = is_adult         // declared output

Plain assignments introduce a local name visible to subsequent statements. Prefixing with out also exposes the value in the evaluation result under that name. See Variables.

Signals

A signal declares an external event with a fixed parameter list. Signals are not invoked from inside the rule directly — they are emitted by emit statements (see Signals).

signal Name(param1, param2)

Emits

emit BlockAccount(input.user_id) when !eligible
emit Audit(input.user_id)

emit queues a signal during evaluation. The optional when clause gates the emission on a boolean expression. See Signals.

Input

Every rule has an implicit input value of type object provided by the caller. Use dot or bracket access to read fields:

rule Example {
    out a = input.user.name
    out b = input["user"]["name"]
}

Reading a missing field yields the special value undefined (see Types), which propagates through most operations without raising an error.

Reserved keywords

signal, rule, emit, when, out, in, if, then, else, true, false.

A minimal example

rule ExampleRule {
    out is_adult = input.age >= 18
}

Compile and run:

nodora compile -f ExampleRule.ruleset
echo '{"age":21}' | nodora eval -f ExampleRule.json --stdin
{"outputs":{"is_adult":true},"emitted_signals":[]}

On this page