Skip to main content
Version: Next

Lifecycle

Entity types can be assigned a lifecycle map via has_lc_map, governing the valid states and transitions of their instances. The lifecycle system controls which entities are considered released, which are read-only, and which state changes are permitted.

Lifecycle Map (lc_map)​

A lifecycle map groups a set of lc_status entries and defines the allowed transitions between them.

FieldDescription
nameSystem identifier (key)
labelLocalized display name
has_lc_statusThe statuses belonging to this lifecycle

Assigning a Lifecycle to an Entity Type​

Use has_lc_map on the entity type definition:

"has_lc_map": [
{ "target": "lc_map/EP_Default" }
]

The entity types of the shipped meta model carry lc_map/EP_Default by default.

Types Without a Lifecycle​

A type does not need a lifecycle map. This suits configuration-like types, where the default statuses have no meaning and a released status would only make the entity permanently uneditable. Instances of a type without a lifecycle map:

  • have no @status field,
  • are never blocked by a read-only or released status -- they are always writable,
  • reject a status change (PUT /@status) with "Entity has no lifecycle map".

Lifecycle Status (lc_status)​

A lifecycle status defines a state an entity can be in.

FieldTypeDescription
namestringSystem identifier (key)
labellocalized mapDisplay name
numberintOrdering number (also accepted for status transitions via the API)
is_releasedboolWhether entities in this status are considered "released"
is_read_onlyboolIf true, content edits (properties, relationships, traits, lists, components) on this branch are blocked
colorstringHex color for UI display
has_lc_transitionrelationshipsValid transitions to other statuses

Transitions (has_lc_transition)​

A transition is a relationship instance between two lc_status entities. Only transitions explicitly defined via has_lc_transition are permitted -- the engine rejects any status change that does not follow a declared transition. Its edge properties:

PropertyMeaning
labelDisplay name for the transition
issues_revisionWhen set, taking this transition also issues the aggregate's next version number. The current version is frozen with the status just reached, and the next version opens with the map's initial status.
revision_levelWhich level of the versioning scheme issues_revision advances (major, minor, …). Empty means the least significant level. Only meaningful with issues_revision.

issues_revision is set per transition, not derived from a status flagged as released: a map may have several released statuses, none at all, or a released status that can be entered more than once.

note

Because an issuing transition reopens the aggregate at the initial status, a transition to a released status with issues_revision does not leave the entity released. It leaves it at the initial status; the released status is recorded on the version that was frozen.

The Default Lifecycle: EP_Default​

The system provides one built-in lifecycle: lc_map/EP_Default.

Statuses​

StatusNumberReleasedRead-OnlyColor
lc_status/new0nono#FF0000
lc_status/review100noyes#FFBB00
lc_status/released200yesyes#00FF00
lc_status/obsolete300noyes#DDDDDD

State Machine​

Valid transitions: new -> review -> released -> obsolete, and review -> new.

warning

Once an entity reaches the review, released, or obsolete status, it becomes read-only (is_read_only: true). The only status that allows saving new commits is new. To make changes to an entity in review, transition it back to new first.

Lifecycle Status Is Per Branch​

The lifecycle status is not stored in a commit. It belongs to the branch of the aggregate. This means:

  • A status transition does not create a commit -- the History shows only content changes.
  • Each branch of an aggregate has its own, independent status.
  • Only the target branch's read-only or released status can block a merge; the source branch's status never does. Status transitions are not merged.
  • An as-of read (?as_of=) reports the status the branch had at that instant.

Every Entity Has an Explicit Status​

An entity of a type with a lifecycle map always has a stored status: on creation it receives the map's initial status, a new branch takes over the status of its source branch, and the system entities shipped with EP are released. A branch created at a frozen version starts at the initial status instead, because that is done to work on it.

The stored status points at one specific commit of the lc_status entity, so editing a status (for example its label) does not change the status of existing entities. If a stored status cannot be resolved, the entity is treated as read-only rather than becoming editable.

API Interaction​

Reading the Current Status​

GET /api/v1/by-key/<type>/<key>/@status

Returns the full entity object for the current lc_status.

Response 200: Status entity object.

Response 404: No lifecycle available for this entity.

Transitioning to a New Status​

PUT /api/v1/by-key/<type>/<key>/@status

or POST on the same path. The request body is either the status name as a string or the status number:

"review"

or

100

The target status can also be given on the address, without a body: PUT /api/v1/by-key/<type>/<key>/@status/review or …/@status/100.

A transition changes the status of the addressed branch atomically; it does not create a new commit. on_status_change hooks run before (and can veto) and after the transition.

Response 200: Updated entity object.

Response 400: Invalid status, illegal transition, or a veto by a pre-hook.

Response 500: A hook could not be evaluated.

Status in Entity Responses​

When an entity has a lifecycle map assigned, its response includes the @status field:

{
"@status": { "name": "new", "number": 0 }
}

If no lifecycle map is assigned, the @status field is absent.

Custom Lifecycle Maps​

You can define custom lifecycle maps by creating lc_map and lc_status entities with your own statuses and transitions. The process is:

  1. Create lc_status entities for each state.
  2. Define has_lc_transition relationships between the statuses (optionally with issues_revision).
  3. Create a lc_map entity with has_lc_status relationships pointing to the statuses.
  4. Assign the lifecycle map to entity types via has_lc_map.