Relation

Relations define adjacencies and rules governing how different kinds of objects interact. They specify which kinds of objects, and how many, can be accepted in a relation, as well as the outcomes when objects are connected (related) or disconnected (unrelated) from one another.

All relations are created from a special set called the Set of Relations, which is governed by the OOPS (Object Operating and Positioning System) contract.

Allrelations adhere to the Kind of Relation, which determines the elements that make up a relation object.

Relations play a crucial role in defining kind objects. By listing relation IDs in their fields, kinds declare support for the adjacencies defined by those relations, enabling objects of that kind to interact with others in a structured and regulated way.

Creation

Relation objects are created unpon registration, they are initialized as follows:

id

Relation IDs are allocated from a specific range:

uint64 constant ID_REL_EMERGENT_MIN = 17;
uint64 constant ID_REL_EMERGENT_MAX = type(uint56).max;

The id is constrained to values no greater than 2^56 - 1 to ensure that the upper 8 bits of the uint64 remain unset.

meta

The meta field is initialized in the following manner.

meta.flags   = 0;
meta.rev     = 1;
meta.kindRev = latestKindOfRelation();  // The latest revision of the Kind of Relation
meta.setRev  = latestSetOfRelation();   // The latest revision of the Set of Relations
meta.kind    = ID_KIND_OF_RELATION;
meta.set     = ID_SET_OF_RELATION;

Since the kind and set objects always point to their latest revisions, relations created later may have higher values in these fields.

elems

According to the Kind of Relation, a relation object is composed of the following elements:

ElementAliasMutableDescription
elems[0]descYMateial hash of the metadata for the relation.
elems[1]ruleNRules for handling departure objects when being related or unrelated .
elems[2]adjs0NSpecifies adjacencies supported by the relation.
elems[3]adjs1NSpecifies adjacencies supported by the relation.
elems[4]adjs2NSpecifies adjacencies supported by the relation.
elems[5]adjs3NSpecifies adjacencies supported by the relation.

All elements should be provided upon registration, the rule and adjsN cannot be changed once set.

desc

The desc element is the material hash of the metadata for this relation. It does not play a role in the interactions defined by the relation on the universe chain.

Instead, it's only utilized by the kind contract on the Previous chain. The material should be a JSON object containing fields such as:

  • name: The name of the relation.
  • description: A detailed explanation of the relation.
  • image (optional): A URL or reference to an image representing the relation.

rule

The rule field encoding rules for handling departure objects when they are being related or unrelated.

(To Be Continued)

adjsN

The adjs[0..3] elements collectively define the adjacencies supported by a relation, often referred to as the relation's adjacency specification.

These 4 elements can hold up to 8 adjacency primitives. To ensure a valid adjacency specification, the following rules apply:

  1. Special Kinds:

    • type(uint64).min (0): Represents any, allowing any kind of object not explicitly listed.
    • type(uint64).max (2^64 - 1): Represents total, specifying the maximum number of objects allowed in the relation.
  2. Ordering: Adjacencies must be listed in ascending order of their kind values. If an adjacency with the any kind is present, it must be listed first, and if total is included, it must be listed last.

These 4 elements are filled according to the adjacency primitives in the following manner:

Assuming all adjsN elements are initially set to zero and ordered from left to right, each adjacency is encoded into a uint128 value and sequentially inserted into the array in big-endian format.

Operations

Interoperations are not applicable to relation objects, all unary operations are supported and listed below:

OperationFields Affected
transferowner
updatemeta.rev, elems.desc
upgrademeta.rev, meta.kindRev, meta.setRev
touchmeta.rev