emit.fields. Nothing is copied automatically from the triggering event, and there are no
defaults. Each entry in fields is a CEL expression, usually reading the entity you just wrote
or the incoming payload:
swarm verify and the runtime actually
see:
emit.from: entity(orpayload— exactly one namespace, no lists) auto-fills every required declared payload field whose name matches a source field. Optional fields are never auto-filled; explicitfields:entries win overfrom:. So ifticket.assigneddeclarescategory(required) andnote(optional),from: entityfillscategoryfromentity.categoryand leavesnoteunset.- Inside
fields:, a bare namespace value means the same-named source field:category: entitylowers tocategory: entity.category. Dotted CEL stays the form for renames and computed values.
emit: ticket.assigned, emits with an empty payload. swarm verify
accepts it, so the empty payload only shows up at runtime when a subscriber receives {}. Use
the bare form only for events that declare no fields; use fields the moment an event carries
data.
Routing is not the producer’s job
An emit does not choose who receives it. The producer says what happened; the receiving side decides who hears it:- Inside a flow — delivery comes from subscriptions (
subscribes_toon nodes,subscriptionson agents). An internal emit needs nothing beyondeventandfields. - Across flows — the event leaves through a declared output pin, and the receiving flow
decides which instance gets it. See Composing flows for pins,
connectedges, andresolution. - Replies — reply correlation is declared on the receiving pin, not chosen per-emit by the producer.
emit is valid only when the handler has a single emit site. If the
handler also branches with rules or on_complete, the emit moves onto the branch; a
handler-level emit alongside rules is a boot error. See Branching.
Migrating from emit.target / emit.broadcast
Migrating from emit.target / emit.broadcast
Older Swarm versions accepted
emit.target and emit.broadcast — producer-side recipient and
cardinality selection. Both are retired and now fail at load with a RETIRED-EMIT-ROUTING
error naming the replacement. If you are migrating: a target: sender reply becomes
receiver-owned reply correlation on the pin; a broadcast: true fan-out becomes either
ordinary subscriptions (every subscriber in the flow already receives an internal event) or
explicit connect edges per receiving flow.
