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.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 withclear_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>:
gate_state (a map of gate name to its
starting value):
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 complete flow: declare, set, guard, clear a gate
A complete flow: declare, set, guard, clear a gate
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 What happens: a submitted doc waits in
swarm verify.schema.yaml
entities.yaml
nodes.yaml
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.)
