Skip to content

Authoring rules

Use these pairs when writing a graph or reading a refusal. The left column is code to diagnose, not a template. A warning still allows the graph to run.

RuleRefused or warnedWrite insteadDiagnostic
Render an integerdata as stringstring(data)E-EXPR
Narrow a uint to intdata as int(data as? int).orValue(0)E-EXPR
Read an arraydata[0]data[?0].orValue("none")E-EXPR
Read a map fielddata.namedata.?name.orValue("none")E-EXPR
Read a schemaless JSON objectout = data is Receiptval receipt = data as? Receipt; out = receipt != nullE-EXPR
Initialize statevar last: stringvar last: string = ""E-EXPR
Test array membershipdata.exists(x, x == "red")"red" in dataE-EXPR
Test a map key1 in data"id" in dataE-EXPR
Build an array["a"] + ["b"]["a", "b"]E-EXPR
Test a stringdata.matches("^a.*b.*c$")data.startsWith("a") && data.contains("b") && data.endsWith("c")E-EXPR
Choose when a key expiresinstance = { key = data }instance = { key = data }; lifetime = { kind = idle; max = duration("5m") }E-LIFETIME-REQUIRED
Close an outbound Calllifetime = { kind = once }lifetime = { kind = once }; closing = { drain_for = duration("1s"); settle_for = duration("1s") }E-INSTANCE
Discard a lost answer_ => out = "failed"_ => nothingW-MATCH-CATCHALL
Mock HTTP 204out = "body"; exit = Completed { status = 204 }exit = Completed { status = 204 }E-CONTRACT-REQUIRED
Mock HTTP 205out = "body"; exit = Completed { status = 205 }exit = Completed { status = 205 }E-CONTRACT-REQUIRED
Describe a codec refusalexit = DecodeFailed {}exit = DecodeFailed { message = "expected a status" }E-PORT-TYPE

int and uint are signed and unsigned 32-bit integers. Either fits a long; a computed long need not fit either narrower type. For an array received at a port, even index zero might be absent. Choose a fallback only if it means something for your application; otherwise handle null separately.

A schemaless JSON codec delivers an object as a map. If it does not fit Receipt, receipt is null. Use is for a typed union or its case. An HTTP timeout does not prove that the operation failed. If you record an outcome instead of dropping it, name each lost-answer case the warning lists before the wildcard, even if several cases go to the same destination.

For example, this handler distinguishes an unknown outcome from a known failure:

on in match data {
Completed => out = "answered"
BodyTooLarge | DecodeFailed | OutcomeUnknown | ProtocolFailed | TimeoutExpired => out = "unconfirmed"
_ => out = "failed"
}

Lifetime choices are persistent, idle, age, slot and once. A finite owner with an outbound Connector also declares its closing budgets. A 204 or 205 has a terminal but no body. A codec refusal carries a message about the expected data, not a copy of the value received.

Not availableAlternative in this release
The iteration macro existsUse membership for an element or key.
Array concatenation with +Construct the known elements explicitly. There is no general concatenation operator.

Diagram