Skip to main content
Once a handler has passed its guard, it records data on the entity and moves the entity through its state machine.

Writing data with data_accumulation

data_accumulation writes fields onto the entity. writes is a list, and each item takes one of four forms:
value and expression are mutually exclusive on one item. The direct and mapped forms read from source_event (the triggering event by default), and that event must declare every field they reference.
The key is value. literal: is not accepted here — that key is used inside action blocks instead.
What you write here persists: a value written by one handler is readable as entity.<field> in later handlers, not just this one. See the execution model for the read/write ordering within a handler.

Advancing state

advances_to moves the entity to another state. The target must be one of the flow’s declared states, and advances_to is the only thing that changes an entity’s state:

Gates

A gate is a named boolean checkpoint on the entity. Gates are separate from ordinary boolean fields because the runtime knows about them: they can be cleared as a set with clear_gates, and they must be declared up front so swarm verify can prove every guard reads a gate somebody sets. sets_gate raises one; a later guard reads it as entity.gates.<name>:
Every gate a node sets must be declared in that node’s gate_state (a map of gate name to its starting value):
To reset, clear_gates: true clears every gate on the entity — it is entity-wide, not scoped to this node. There is no way to clear a single gate. This is how you re-enter a cycle:
A doc that must be reviewed before it can publish. The gate is declared once, set on approval, required by the publish guard, and cleared if changes are requested. This passes swarm verify.
schema.yaml
entities.yaml
nodes.yaml
What happens: a submitted doc waits in in_review. publish.requested is rejected until review.approved has set g_reviewed, so a doc cannot skip review. If changes.requested arrives, clear_gates drops the gate and sends the doc back to draft, which means it has to be re-approved before it can publish again. (The events declare a swarm.source: external line, omitted here for brevity.)
See Stages, gates, and timers for the model behind stages and gates.