# Cellular habitat snapshot v1 This bounded snapshot is implemented by `biology::CellularHabitat` under ADR-0101. It describes a region-local finite food opening and its current stock; it is not yet an admitted PostgreSQL checkpoint profile. A containing cellular checkpoint must bind its exact world, region and frame identity. All integers are unsigned little-endian unless stated. Records are packed by the codec, not by native C++ layout. ## Envelope | Offset | Width | Field | Contract | |---:|---:|---|---| | 0 | 8 | magic | ASCII `EVOPATK1` | | 8 | 4 | format | 1 | | 12 | 4 | habitat rules | 1 | | 16 | 8 | world | Nonzero identity | | 24 | 8 | region | Nonzero identity | | 32 | 8 | frame | Nonzero identity | | 40 | 4 | width_um | Positive, <=1,000,000, multiple of 1,000 | | 44 | 4 | height_um | Positive, <=1,000,000, multiple of 1,000 | | 48 | 4 | patch_pitch_um | 1,000 | | 52 | 4 | patch_count | 0..4,096 | | 56 | 8 | reserved | Zero | | 64 | 8 | reserved | Zero | | 72 | 56*n | patch records | Ordered by ascending (x_um,y_um) | | 72+56*n | 8 | checksum | FNV-1a64 over all preceding bytes | Exact length is `80 + 56 * patch_count`. The checksum detects accidental corruption; it is not an authentication mechanism. ## Patch record (56 bytes) | Offset | Width | Field | Contract | |---:|---:|---|---| | 0 | 4 | x_um | Patch lower-left coordinate; 1,000 μm aligned and in bounds | | 4 | 4 | y_um | Patch lower-left coordinate; 1,000 μm aligned and in bounds | | 8 | 8 | source | Nonzero opening-provenance identity | | 16 | 8 | energy_pj | Finite usable chemical energy | | 24 | 8 | carbon_fg | Finite organic carbon | | 32 | 8 | nitrogen_fg | Finite organic nitrogen | | 40 | 8 | phosphorus_fg | Finite organic phosphorus | | 48 | 8 | other_fg | Finite organic other matter | Unlisted patches contain no stock. Each conserved channel's sum across the opening must fit `u64`; overflow rejects creation. Records must be strictly ordered and unique. There is no automatic refill or default opening. ## Restore validation Before allocating patch storage, the decoder checks the minimum/maximum byte length, checksum, magic, versions, count cap and exact length. It then validates identity, dimensions, patch pitch, zero reserved fields, patch alignment, source ids, strict ordering and per-channel totals. Restore rebuilds through the same creation validator and accepts only bytes identical to a canonical re-encoding.