Engine

3.7. Appending🔗

How a write is checked and stored: an event is appended when it fits its event type, its expected_revision matches, and no rule rejects it. A client sends a batch of events; the batch is stored whole or not at all. On the shift of the rules page, a batch that creates a shift and assigns Anna is stored, and a batch whose second event is rejected stores nothing:

🔗def
Spec.rulesAccept (rules : List (String × Rule)) (store : List Event) (e : Event) : Bool
Spec.rulesAccept (rules : List (String × Rule)) (store : List Event) (e : Event) : Bool

The reference check of an event against the active rules: every precondition of its entity accepts it on the key's history before it, and every invariant holds on the store with it.

🔗def
Spec.State.appendBatch (st : State) (es : List Event) : Option State
Spec.State.appendBatch (st : State) (es : List Event) : Option State

The reference meaning of an append.

3.7.1. Batches🔗

Each event of a batch is checked against the store with the events before it in the batch, so a batch can pass through a state that a single event could not. Two users swap emails in one batch, through a temporary address; the unique-email invariant holds after every event:

Two users can swap emails in one batch through a temporary address.

3.7.2. Rejections🔗

A rejected batch names the first rejected event and why: its schema, its expected_revision, or the rule, counted in file order. On the folio:

Event sent

Reason

Claim

a charge without its amount

the event does not fit its type

A charge without its amount is not valid.

a charge expecting revision 1 on a folio at revision 2

expected_revision does not match

A charge expecting an older revision is rejected.

a charge on a closed folio

rule 1

A charge on a closed folio is rejected.

🔗structure

A rejected batch: the first rejected event and why.

Spec.Rejection.mk
index : Nat

the event's index in the batch, from 0

position : Nat

the position it would have had

reason : Reason

the first check it fails

3.7.3. Concurrency🔗

Two batches can run at the same time when they touch different keys and groups; they then give the same result in either order.

🔗structure

What checking a batch touches, on the store it is checked against.

Spec.Footprint.mk
writes : List (String × String)

keys appended to, as (entity, key)

reads : List (String × String)

keys read through in

groups : List (String × Spec.Inv × List Value)

groups the events are in before or after them, as (entity, invariant, group)

🔗def

Neither batch writes what the other reads or writes, and they share no group.