Skip to content

Relations

A relation is a meta-object that defines how different kinds of objects may interact.

Descriptor

Relations are themselves objects: they have their own kind and are minted from a set. The Kind of Relation and the Set of Relation are genesis objects created during protocol initialization.

A relation’s descriptor is initialized with the following values:

FieldValueDescription
flags0Reserved flags
rev1Initially 1, increments as the relation itself evolves
krevlatestRevision of the Kind of Relation at creation (increments over time)
srevlatestRevision of the Set of Relation at creation (increments over time)
kind3ID of the Kind of Relation
set3ID of the Set of Relation

Elements

Each relation has 7 elements, as specified in the Kind of Relation object's eltys field.

IndexElementMutableDescription
0codeYesAddress of the relation contract (reserved for future use)
1dataYesMatter hash containing relation-specific data
2ruleNoEncoded rule defining how the relation behaves
3adjs[0]YesEncoded adjacencies (part 1)
4adjs[1]YesEncoded adjacencies (part 2)
5adjs[2]YesEncoded adjacencies (part 3)
6adjs[3]YesEncoded adjacencies (part 4)

Adjacency

An adjacency specifies which kinds of objects a relation admits, and how many of each kind may participate.

struct Adjacency {
    uint16 degs;  // number of objects of this kind allowed
    uint48 kind;  // the kind of objects
}

Each adjacency can be compactly encoded as a single uint64:

uint64 adj = (uint64(degs) << 48) | kind;

The kind field has two special meanings; all other values refer to a registered kind ID:

  • 0 — any kind not explicitly listed
  • 0xFFFFFFFFFFFFdegs applies to the total number of objects in the relation

Adjacencies are stored in a relation’s adjs[i] fields, ordered by ascending kind ID.

Relation Data

The data field stores a matter hash referencing a piece of data associated with the relation.

Omni Registry

When a relation is registered in the Omni Registry, it receives a relation ID.
Its ID and revision can be compactly encoded into a single uint64:

uint64 compact = (uint64(rev) << 48) | id;

A relation is admitted by a kind if its compact ID appears in that kind’s rels[i] fields.

©2025 every