Engine

3.2. Selectors🔗

A selector picks events from a history. Forms nest: any except ReminderSent within 30 days.

🔗inductive type

A selector: an expression in rule text that evaluates to a list of picked events from a history.

Spec.Selector.type (t : String) : Selector

EventType

Spec.Selector.list (ts : List String) : Selector

[EventType, ...]

Spec.Selector.any : Selector

any: every event of the history

Spec.Selector.except (a b : Selector) : Selector

a except b

Spec.Selector.filter (s : Selector) (c : CondExpr) :
  Selector

s where c; inside c, bare fields are fields of the picked event

Spec.Selector.byField (t : String) (fs : List String) :
  Selector

EventType(f1, ..., fn): events of that type whose fields f1 to fn each equal the same field of the enclosing picked event, or of the incoming event if there is none

Spec.Selector.inEntity (s : Selector) (entity : String)
  (key : ValueExpr) : Selector

s in entity(key)

Spec.Selector.window (s : Selector) (w : Window) : Selector

s within n unit, s today, ... (preconditions only)

3.2.1. What the forms pick🔗

A selector names events by type, or all of them (any), and narrows them with except and where. On the history of a folio, FolioOpened, ChargePosted, ChargeVoided, FolioClosed, FolioReopened:

Selector

Picks

Claim

[ChargePosted, ChargeVoided]

the charge and the void

A list of types picks the charges and the voids.

any except [FolioClosed, FolioReopened]

the opening, the charge and the void

Any except closing and reopening picks the other events.

3.2.2. Windows🔗

A window keeps only recent events: within 1 hour, today, this week, this month, all counted up to the incoming event's time. The account file's never MoneyWithdrawn today is one:

      - on: MoneyWithdrawn
        requires: $amount > 0 and never MoneyWithdrawn today

A second withdrawal on the day is rejected (A second withdrawal on the same day is rejected. ), one on the next day is accepted (A withdrawal on the next day is accepted. ). A login limit shows within: the fourth failed login in an hour is allowed, the fifth rejected.

The fourth failed login in an hour is allowed and the fifth is rejected.

3.2.3. Calendar🔗

today, this week and this month follow the calendar in UTC: days from midnight, weeks from Monday to Sunday, months from the 1st.

Two moments

Same period?

Claim

Sunday 6 and Monday 7 December 2026

different weeks

Sunday and the following monday are in different weeks.

30 November 23:59:59 and 1 December 00:00:00

different months

The last second of november and the first of december are in different months.