Journalled Entities Specification
Concept¶
Entities have a fixed identity, but their information can change over time. The system must record these changes to enable audits, meet compliance needs, and support forensic analysis. Tracking changes also allows business logic to reference the state of the system at any specific moment.
Journalled Entities are designed to support these requirements.
Business Value and Needs¶
Keeping complete history of changes to entities and providing access to immutable, previous versions of an entity is valuable for:
- Audits: Reviewing the history of changes to ensure compliance with regulations and internal policies.
- Forensic Analysis: Investigating issues or incidents by examining the state of entities at specific points in time and determine how the change happened.
- Immutable Values: Once certain business transactions are committed or agreed, the information relating to that transaction must be immutable. This requirement extends not only to the records directly involved in the transaction but also to any reference data or other information that the system used to process the transaction. Although this could be achieved in an ad-hoc manner by copying information to separate storage, it is more desirable to have a general mechanism that allows the business logic to freeze the version of an entity at a particular point.
- Latest Values: Business logic may need to access the latest version of an entity to refresh its state or to ensure that it is presenting the most up-to-date information to users or other systems.
- Analytics: External analytics engines, timeseries reporting and similar use cases require access to the complete history of versions of an entity to compute trends, predictive models etc.
User Stories/Requirements¶
-
Journalled Entities, upon creation, deletion or update operations, must keep record of:
- The values of the properties of the entity before the change
- The values of the properties of the entity after the change
- The identity of the user that made the change.
- An optional note (String) note about the change that the business logic can provide.
- The effective time of the change, that is the time when the change becomes effective for business logic and workflows.
- The recorded time of the change, that is, the time when the change is actually performed to the entity.
-
An Entity or other business logic referring to a Journalled Entity must be able to access the Entity by using:
- A reference to a specific version
- A reference to the entity with the interpretation that the system will return the latest version as of the time of the request.
- A reference to the entity and values for the effective and recorded times. The system will return the latest version of the entity with effective and recorded times earlier than the specified values.
-
The interpretation of
latestfor retrieving an entity version is the record with the highest effective time, selected from the set of records with lower effective time and lower recorded time than the specified values.
Design¶
Concepts¶
-
TimeCoordinates: The pair of effective and recorded times that define when a change happens in the system.- Effective Time: The time when the change becomes effective for business logic and workflows.
- Recorded Time: The time when the change is takes place and is recorded by the system.
Implementation wise, these two values are represented as
Timestampsin the system. -
Entity: Represents a part of the system’s state with a fixed identity and mutable contents. It can be considered as aDictionaryvalue with an additional identity property that is immutable and unique within the system. See Entities Description.- An Entity can be a
Journalled Entityif it supports the requirements described in this document. - An Entity can be accessed by its identity, or by its identity and
TimeCoordinatesto retrieve a specific version of the Entity. - An Entity can be updated, deleted or created, and these operations will result in the creation of a new Record.
- An Entity can be a
Record: An immutable snapshot of an entity’s state at a specific value ofTimeCoordinates. A Record contains:- A unique identity of the Record itself that is unique in the system.
- The
TimeCoordinatesfor when the change was made. - The identity of the user that made the change.
- An optional note about the change.
- The value of the Entity (including its identity) after the change.
- The identity of the Record upon which the change was made (the previous version of the Entity) except for the first record created for an entity.
- A boolean market indicating whether the Entity was deleted in this change or not.
Universe: An access point to a collection of Entities that supports CRUD operations. See Universe Description.Journalled Entity: An Entity that supports the Journalled Entity requirements, together with at least one Universe that gives access to a set of instances of theJournalled Entityand supports the operations describe below.RIO: ARIO, standing for Result IO is an abstraction for a computation that produces a result of an error. It is similar to the concept of anEffectin functional programming languages. It is introduced here to make the signatures more representative of the actual implementation. The need for having operations return aRIOrather than a simple value of aResult<T>value is to allow operations to be composed together in a given context like a service request or a transaction.EntityId: A primitive data type for the identity of an Entity.
Implementation¶
To support the implementation of Journalled Entities the system provides generic implementations of Journalled Entities and Universes as well as Bitemporal persistence and querying capabilities documented in the Common Module Documentation