$index
$index : string
One point in the site's history.
Shaped like a git commit: a parent, a tree, a time, an actor and a message. A restore target is always a commit, and every commit is reachable from a ref by walking parents.
The root commit has no parent and almost every other commit has exactly one, so history is a chain. The single exception is a merge commit, which also names the branch tip it brought in through Commit::$merge, and that is the only way a second line of history becomes reachable from a ref.
merge is serialized only when it is set. A commit is addressed by the bytes of its own JSON,
so writing the key as NULL on every commit would change the address of every commit ever written
and orphan the whole store. A single-parent commit therefore serializes exactly as it did before
merging existed, which CommitTest proves byte for byte.
A commit does not carry an index of the site. It names the anchor its history resolves against, and only the commit that wrote that anchor is marked as one. Writing a per-commit index was measured at 3,989,289 bytes to record a 201-byte change across 50,000 subjects, because the cost scaled with how many subjects the site had rather than with how many changed. So the index belongs to an anchor on its own interval, and the commits between two anchors inherit its address, its chain length and its time - which keeps a flush at four objects whatever the site's size.
__construct(string $index, string|null $parent = null, int $microtime = 0, string $label = '', int|null $actor = null, int $operations = 0, int $rawBytes = 0, int $storedBytes = 0, int $level = 0, bool $base = false, int $chain = 0, int $anchoredAt = 0, array$metadata = [], string|null $merge = null) : mixed
Constructs a commit.
| string | $index | Address of the base anchor this commit's history resolves against. Its own when this commit is an anchor, otherwise the one it inherited from its parent. |
| string|null | $parent | Address of the previous commit, or NULL for the root of history. |
| int | $microtime | Unix microseconds the commit was sealed at. |
| string | $label | Short human summary, such as "42 nodes, 3 config objects". |
| int|null | $actor | Drupal user id responsible, or NULL for cron and other unattended work. |
| int | $operations | Captured operations this commit covers. |
| int | $rawBytes | Decoded bytes the operations described. |
| int | $storedBytes | Bytes actually written, after deduplication, compression and sealing. |
| int | $level | Compaction level; 0 for a freshly flushed commit, higher after a rollup. |
| bool | $base | Whether this commit wrote the anchor it names, so a replay can stop here. |
| int | $chain | How many anchors stand between the one this commit names and the full anchor behind it, counting the full one. Carried on the commit so a flush can apply the full-anchor policy without reading the chain. |
| int | $anchoredAt | Unix microseconds the anchor this commit names was written at, so a flush can tell whether the next anchor is due without reading it. |
| array |
$metadata | Anything a capture wants to carry, such as the segment key it came from. |
| string|null | $merge | Address of the second parent, which is the branch tip a merge brought in, or NULL for every other commit. Declared last so every existing positional caller is untouched. |
When an address is not a valid digest, a count is negative, or a merge parent is named by a commit that has no first parent.
id() : string
This commit's content address.
Derived from the serialized commit, so an identical commit written twice is the same commit.
When the label or the metadata holds a string JSON cannot represent. (string) false would
otherwise address every such commit as Hash::of(''), so two unrelated commits would be one
commit and overwrite each other.
A 64-character lowercase hex digest.
parents() : list<string>
Every commit this one builds on.
A walk that follows only Commit::$parent stays on the line the ref describes, which is what a replay wants; a walk that has to decide whether one commit is an ancestor of another needs both, which is what a merge base wants.
Parent addresses, the first parent first, empty for the root of history.