Branching & Version Numbers
EP keeps every saved change as an immutable commit. On top of that, two optional mechanisms organise the history of an entity:
- Branches -- Git-like parallel lines of work on one aggregate, which can be merged again.
- Version numbers -- business numbers such as
v1.0.3orRev C, issued deliberately from a versioning scheme.
Branches
Aggregates
Branching works on an aggregate: a top-level entity plus everything it owns through its manifest -- relationships, traits, list items and components, recursively (see Ownership and Manifests). A branch always covers the whole aggregate and is addressed through its top-level entity.
What a Branch Is
A branch is a named pointer (a head) on an aggregate. Every aggregate starts on the main branch. Creating a branch only adds a new name pointing at the current head of the source branch -- no data is copied. That shared head is both the starting state of the branch and the later merge base.
main ──● c1
╲ (create branch "dev" -- both names point at c1, nothing is copied)
dev ────● c1
Addressing a Branch
A branch is selected with a trailing :branch on the key or root_id (see Addressing an Entity): vegetable/potato:dev or <root_id>:dev. Without a suffix, main is used. A pinned commit id takes no branch. Each entity view carries an @branch field naming the branch it was resolved on.
Writes Are Isolated
A write to key:branch creates a new commit on that branch only -- it advances that branch's head and leaves every other branch untouched. Reading key:branch resolves the head on that branch and then its whole owned subtree. If an entity has no head on the requested branch, the read falls back to main.
main ──● c1 ───────────────● c2 (weight=10)
╲
dev ────●─────● c3 (color=green) # main and dev diverge independently
Each branch also has its own lifecycle status.
Merging
Merging reconciles two branches of one aggregate. Given a source and a target branch, the engine finds the merge base (the most recent common ancestor) and decides:
| Outcome | Meaning |
|---|---|
up_to_date | The target already contains the source -- nothing to do. |
fast_forward | The target never diverged -- its head simply moves to the source head. No commit is created. |
three_way | Both diverged -- the changes are merged (below). |
unrelated | No common ancestor (does not occur for branches of the same aggregate). |
In a three-way merge, the engine compares the base with both sides:
- A property, relationship or trait changed on only one side is applied automatically.
- Changed on both sides to the same value -- taken, no conflict.
- Changed on both sides differently -- a conflict.
Without conflicts, a merge commit is written on the target branch. Its metadata.previous is the target's prior head, and metadata.merge_parents names the source head. With conflicts, nothing is written; the engine returns a conflict report with the base, ours and theirs value of each conflict, and the merge is repeated with a resolution per conflict -- either a chosen value or a choice of ours / theirs.
Further rules:
- A merge into a target branch whose status is read-only or released is rejected -- transition the target first. The status of the source branch never blocks a merge.
- Status transitions are not merged; each branch keeps its own status.
- Deletes are merged too: one- or both-sided deletes result in a tombstone, a delete against an edit is a conflict.
- A three-way merge commit fires
on_updatehooks; aprehook can veto the merge. A fast-forward fires nothing.
Limitations (v1)
- Aggregate-scoped: branches exist on the top-level entity; sub-entities follow through the manifest.
- Creation is
main-only: new aggregates are always created onmain. Create the entity first, then branch it. - Keys are global: keys are unique across all branches. The key of an aggregate cannot be renamed on a branch other than
main, and a key cannot be reused for a different entity on another branch. - Lists are not merged item by item: list changes on both sides are reported as a conflict; resolve by choosing a whole side. Three-way merges cover the top-level entity and its direct sub-entities.
- Collection reads are
main-only: listing all instances of a type or trait always readsmain.
Version Numbers
A version number is the business number a person writes on a drawing or a specification (v1.0.3, Rev C). It is independent of commits: a commit is created with every save, a version number only when someone deliberately issues one -- with Increase Version in the user interface, the POST …/@bump route, or a lifecycle transition configured to issue one.
Nothing about semantic versioning is hardcoded. A versioning scheme is ordinary data, built from four entity types:
versioning_scheme --levels (list)--> versioning_level --has_sequence--> sequence
|
elements (list) <---+
|
v
sequence_element
versioning_scheme
| Field | Type | Description |
|---|---|---|
name | system_name | System identifier, required, unique; the key derives from it |
label | localized map | Display name |
description | localized map | Description |
levels | list of versioning_level | Ordered, most significant first |
versioning_level
One digit group of a number (major, minor, …).
| Field | Type | Description |
|---|---|---|
name | system_name | Required. The key derives from it; revision_level on a lifecycle transition names it |
prefix / postfix | string | Written around the level's value when rendering (v, .) |
level_label | string | Human-readable level name |
min_places | int | Required. Minimum rendered width |
max_places | int | Required. Maximum width the level may grow to (at most 64) |
auto_bump | bool | Required. When the level runs out of digits: carry into the next-higher level (true) or fail (false) |
pad_char | string | Optional, display only. Pads the rendered value to min_places |
has_sequence | relationship | The sequence supplying this level's digits |
sequence and sequence_element
A sequence is a reusable ordered alphabet; a sequence_element is one digit.
| Type | Field | Description |
|---|---|---|
sequence | name | Required, unique; the key derives from it |
label | Display name | |
elements | Ordered list of sequence_element. Element 0 is the zero / padding digit | |
sequence_element | name | Required, unique within the sequence. A system_name ([A-Za-z0-9_]), because it forms the address of a version number |
label | Optional display form of the digit -- any characters, e.g. α. Empty means the name is displayed |
A digit has two forms. The name is used in addresses and must be address-safe; the label is what users see. A scheme of Greek letters uses name: alpha, label: α: the number is addressed as widget/acme:alpha and displayed as vα.
A digit may have several characters (alpha, rc), but within one sequence no digit may be a prefix of another (checked separately for names and labels), and no name may contain -. These rules are checked when the scheme is used, so a malformed scheme makes the operation that uses it fail.
Assigning a Scheme: has_versioning_scheme
| Relationship | Source | Description |
|---|---|---|
has_versioning_scheme | an entity type, or a single instance | Binds the scheme that governs the aggregate's numbers. A binding on the instance wins over the type's. A binding added to the type later also applies to instances created before. |
For an instance to carry its own binding, its type must declare has_rel → relationship_type/has_versioning_scheme.
A governed aggregate starts with the scheme's first number (every level at its zero digit). Version numbers are not stored in commits -- issuing one writes no entity and creates no commit. They are read in metadata.version_numbers:
"metadata": {
"version_numbers": [
{
"scheme": "versioning_scheme/semver",
"segments": { "major": "1", "minor": "0", "patch": "3" },
"label": "v1.0.3",
"name": "1-0-3"
}
]
}
| Field | Description |
|---|---|
scheme | The governing scheme as type_name/key |
segments | The value per level, in the digits' name form |
label | The number as people read it, rendered from the scheme's prefixes, postfixes and padding |
name | The address form: GET /api/v1/by-key/widget/acme:1-0-3 reads the aggregate at that version |
The list's first element is the number in force for the address that was read. One commit can carry several numbers (for example after issuing a number without saving anything in between). The field is omitted for entities without a scheme.
When a number is issued, the current version is frozen at the head it ended on, and the next one opens at the same head. A frozen version is read-only. Issuing with @bump keeps the lifecycle status; a lifecycle transition that issues a number reopens the aggregate at the map's initial status (see has_lc_transition).
Parallel Numbered Lines
An aggregate can carry more than one numbering line at a time -- for example a v1.0.x maintenance line beside a v2.x main line, each with its own current number. A line is started either by a branch created at a version or by issuing a number addressed at a frozen version. The new line continues that version's number instead of restarting at the scheme's first number. Only the branch (or version) that started a line may issue numbers on it.