Commit EnvelopesParticipants

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
FieldRequiredDescription
nameyesIdentifier used to reference this participant in logs and abort ops
stateyesEntity type (state key) this participant targets
entity_expryesExpression 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 = credit

visibility_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_account

Advanced: 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.amount

Phase rules reference

BlockWhen it runsAllowed ops
stagingWhen prepare_event is received by this participantMutation ops on own-stream fields
applyWhen commit_event is receivedMutation ops on own-stream fields
abort_cleanupWhen abort_event is receivedMutation 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.