Participants
Each entry in participants declares one entity stream that must stage and commit (or abort) as part of the envelope.
Basic participant
participants:
- name: sender
state: wallet
entity_expr: event.sender_id| Field | Required | Description |
|---|---|---|
name | yes | Identifier used to reference this participant in logs and abort ops |
state | yes | Entity type (state key) this participant targets |
entity_expr | yes | Expression to extract the entity ID from the prepare_event payload |
delta_expr
An expression describing the value being staged — used for audit trails and abort reconciliation.
participants:
- name: sender
state: wallet
entity_expr: event.sender_id
delta_expr: "-event.amount" # negative = debit
- name: receiver
state: wallet
entity_expr: event.receiver_id
delta_expr: "event.amount" # positive = creditvisibility_gate
An expression that must evaluate to true for this participant to be enrolled in the envelope. If it evaluates to false, the participant is skipped and the envelope can proceed without it.
participants:
- name: loyalty_ledger
state: loyalty
entity_expr: event.user_id
visibility_gate: "event.apply_loyalty == true"This is useful for optional participants (e.g., apply loyalty points only when a flag is set).
participant_type
Optional tag for specialized runtime routing. Values depend on your deployment configuration.
participants:
- name: escrow
state: escrow
entity_expr: event.escrow_id
participant_type: escrow_accountAdvanced: staging, apply, abort_cleanup
For full control over each participant’s phase, declare explicit rule blocks. The compiler merges these with the generated coordination rules.
participants:
- name: sender
state: wallet
entity_expr: event.sender_id
staging:
rules:
- name: hold_funds
when: {}
then:
- op: sub
path: /available_balance
value: event.amount
cap:
min: 0
- op: add
path: /held_balance
value: event.amount
apply:
rules:
- name: confirm_debit
when: {}
then:
- op: sub
path: /held_balance
value: event.amount
- op: sub
path: /total_balance
value: event.amount
abort_cleanup:
rules:
- name: release_hold
when: {}
then:
- op: sub
path: /held_balance
value: event.amount
- op: add
path: /available_balance
value: event.amountPhase rules reference
| Block | When it runs | Allowed ops |
|---|---|---|
staging | When prepare_event is received by this participant | Mutation ops on own-stream fields |
apply | When commit_event is received | Mutation ops on own-stream fields |
abort_cleanup | When abort_event is received | Mutation ops to reverse staging |
If you omit staging, apply, or abort_cleanup, the compiler generates default rules based on delta_expr. For full control over the balance mechanics, declare them explicitly.