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 fires

Relationship fields

FieldRequiredDescription
fromyesSource entity type
toyesTarget entity type
cardinalityyesmany_to_many or one_to_many
uniquenoDeduplicate duplicate edges
emit_events.creatednoEvent fired when edge is created
emit_events.removednoEvent 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.