Summary
A rule expresses logic that accumulates into an output: totals, scores, and conditional adds. The same pattern models cart totals, fraud risk, SLA points, or eligibility — not only marketing checklists.
Syntax
record Cart Item
unit price: Int
quantity: Int
rule cart total
input items: List<Cart Item>
output total: Int
total starts at 0
for each item in items
add item.unit price * item.quantity to total
return totalSemantics
output name starts at exprinitializes mutable stateadd N when conditionadds to the output when the condition is truefor each item in listiterates;add X to Ymutates accumulatorsreturnfinishes the rule
Compiler note
Rules use mutable accumulators (starts at, add when, loops). The checker validates input types and field access on each condition.
Example
From examples/cart-total.point:
module Checkout
record Cart Item
name: Text
unit price: Int
quantity: Int
calculation line total
input item: Cart Item
output total: Int
total is item.unit price * item.quantity
rule cart total
input items: List<Cart Item>
output total: Int
total starts at 0
for each item in items
add item.unit price * item.quantity to total
return totalFor conditional scoring without loops, see examples/adopters/starter-labs/subscription-tier.point.
Common mistakes
- Using
add N whenon a calculation (rules only) - Iterating a non-list (
iteration-type-mismatch)
Agent diagnostic notes
- Output names in rules avoid duplicate suffixes on the lowered symbol (
cart total+ outputtotalstays readable, notcartTotalTotal) - Ref:
point://semantic/<Module>/rule.<name>
