relationships — Graph Edges
Defines relationship streams between entity types.
relationships:
artist_followers:
from: user
to: artist
cardinality: many_to_many # or one_to_many
unique: true # reject duplicate (from_id, to_id) edges
emit_events:
created: ARTIST_FOLLOWED # event emitted when relationship_create fires
removed: ARTIST_UNFOLLOWED # event emitted when relationship_remove firesRelationship fields
| Field | Required | Description |
|---|---|---|
from | yes | Source entity type |
to | yes | Target entity type |
cardinality | yes | many_to_many or one_to_many |
unique | no | Deduplicate duplicate edges |
emit_events.created | no | Event fired when edge is created |
emit_events.removed | no | Event fired when edge is removed |
relationship_create and relationship_remove ops are allowed in core rules — they maintain an edge table, not stream state. When emit_events is set, a matching domain event fires through the normal pipeline.
unique: true deduplicates at the engine level, but without a preflight the caller sees a no-op instead of a semantic error. Pair unique: true with an explicit preflight that emits a domain-specific rejection code.