Skip to content

Data and identity

A Template describes a kind of persisted Item. This chapter defines what a Runtime guarantees about Items: identity and scope, Property interpretation, hierarchy and keys, state machines, Relations and archiving.

  • Every Item belongs to exactly one Workspace and has exactly one Template, identified by the Template’s PRN.
  • Every Item has an Identifier that is unique within its Workspace and stable for the Item’s lifetime. A Runtime must never assign an Identifier to a second Item.
  • Every Item has a version. A Runtime must assign a new version on every successful write to the Item, including Property, state, key, parent and archive changes.
  • An execution reads and writes Items in its own Workspace only. A lookup by Identifier from another Workspace returns nothing.
  • Every Workspace has exactly one Workspace Item, an Item of the Workspace Template. It is the root of the Workspace’s hierarchy, and ctx.getWorkspaceItem() returns it.
  • A Property declaration defines how a stored value is interpreted. It is not a guarantee that a value is present.
  • properties exposes each declared Property as its interpreted value, or undefined when the stored value is absent or does not fit the declared type. propertyValues exposes each stored value with its type tag.
  • A Property type change does not rewrite stored values. Existing Items keep what was stored; interpretation applies at read time.
  • Parsing an operation or Event input, interpreting a stored value and checking that an Item is suitable for an operation are three distinct steps. A Runtime performs the first two. Application code performs the third.
  • A Property key is a Definition key and is never id or state.
  • Items of an extensible Template may carry Property extensions declared per parent. Extension Properties are readable by every principal that can see the Item.
  • Every Item except the Workspace Item has a parent. Every parent chain ends at the Workspace Item. A Runtime must reject a parent assignment that would create a cycle.
  • A child may carry a key: a string of at most 256 characters, unique among the children of one parent.
  • Creating a child with a key a sibling already holds moves the key to the new child. The previous holder keeps its Identifier and loses its key. getChildByKey returns the current holder.
  • upsertChildByKey updates the child that holds the key when one exists and creates it otherwise, as one atomic operation.
  • A key path addresses an Item from the Workspace Item down the hierarchy: ctx.getItemByKeyPath('leave', 'policy') resolves each segment against the children of the Item resolved so far.
  • A Template may declare states. Exactly one state is the default; states marked with setInitial are also valid starting states.
  • A new Item starts in the default state unless its creator names an initial state. Naming a state that is not initial is an error. An Item of a Template with no states has no state.
  • A transition names a source state and a target state on the same Template. Executing it is an atomic operation; Unit of Work defines the source-state check and the conflict.
  • An Item exposes its state as item.state?.value.
  • A Relation is declared on a Template or Union with a fixed cardinality and a direction. A Runtime must reject a target whose Template the Relation does not permit.
  • A one-side Relation holds at most one target; set replaces it and clear removes it. A many-side Relation holds a set of targets; add inserts, remove deletes, and adding a target that is already linked changes nothing.
  • setIfNotExists and addIfNotExists return true when they wrote a link and false when a link already existed. Unit of Work defines their atomicity under concurrent writes.
  • Removing a Relation removes the link, not the Items. Archiving an Item does not cascade to related Items; an application declares any propagation it needs.
  • archive marks an Item excluded from default selection and retains it. unarchive reverses the mark.
  • A selector excludes archived Items unless it asks for them.

Item visibility and Property access follow the active auth context and the Template’s Grants. Authorization defines those rules.

The specification uses Template, Item, Property and Relation. A parent-child link in the hierarchy is not a Relation; a Relation links independently managed Items.

  • Data model explains Templates, Items, Properties, the hierarchy and Relations.
  • Define data declares Templates, Properties and keys.
  • Relate items applies Relation cardinalities and conditional writes.
  • Handle incomplete data reads Items whose values are absent.
  • WriteItem exposes the write operations these rules govern.