Files
aevolution/schemas/lineage-archive-v2.md
dingo decd4f8043
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m18s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 5m33s
Foundation / checks (postgres) (push) Canceled after 5m29s
Foundation / checks (tsan) (push) Canceled after 5m28s
Foundation / checks (client) (push) Canceled after 5m37s
Foundation / checks (network) (push) Canceled after 5m39s
M12.4: preserve exact biology across ownership candidates
2026-10-17 18:17:59 -04:00

2.5 KiB
Raw Permalink Blame History

Lineage archive v2 (M11.4c)

Authority: ADR-0122. The encoder and decoder are LineageArchive::encode/decode in src/biology/lineage.cpp. All integers are little-endian; no native struct serialization is used. V1 bytes and decoding remain unchanged. V2 is used by cellular-v3 checkpoints.

Offset Size Field
0 8 magic AEVOLAR1
8 4 archive format = 2
12 4 highest genome schema present
16 4 genome count G (≤ 4096)
20 4 birth-record organism count O (≤ 65536)
24 4 genome-revision count R (≤ 4096)
28 4 reserved = 0
32 8 total bytes, including checksum
40 … G × (u16 length 1..256, canonical genome record), ordered by (ancestry depth, genome id)
… 33·O birth records ordered by organism id: organism, birth genome, born tick, died tick, alive flag
… 40·R revisions ordered by (effective tick, organism): organism, previous genome, successor genome, origin event, effective tick (all u64)
end−8 8 FNV-1a64 of all preceding bytes

The maximum size is 3,383,344 bytes. Counts and total size are checked before allocation. A revision's successor is already in the genome table, has exactly the previous genome as its parent, and carries the same nonzero value as its genome ID and origin event. The organism must be alive at that tick, the tick must be after birth and before death, and at most one revision per organism per tick is permitted. Revisions form a continuous chain from the immutable birth genome. OrganismRecord.genome always remains the birth genome; the current genome is resolved by replaying the revisions.

Format 2 is append-only. Decoding admits genomes and birth/death records, then replays revisions against the organism's current genome. The result must re-encode to identical bytes. A format-2 archive with no revisions is used by the explicit cellular-v2-to-v3 migration. Other profiles retain their v1 payload caps and bytes.

ADR-0144 adds a detached merge_living_from operation without changing this encoding. It retains the destination archive, imports selected living organisms' exact birth/revision facts and complete genome-parent closure, and validates a canonical round trip. A dead destination record, conflicting identity/birth or revision rewind refuses the whole candidate. Repeating the same import is exact; source and destination inputs remain unchanged. This operation does not confer residency or copy biological stock; the versioned cellular owner tracks that.