diff --git a/crates/aienos-kernel/src/store.rs b/crates/aienos-kernel/src/store.rs index e22030e9..f3d5b279 100644 --- a/crates/aienos-kernel/src/store.rs +++ b/crates/aienos-kernel/src/store.rs @@ -6,6 +6,10 @@ //! Content-addressed extents (`model/`, `cortex/wal`, `agent/`) //! rather than a general-purpose POSIX filesystem. +/// Canonical System Store v1 byte format. This module does not provide a +/// persistent transaction or mount implementation. +pub mod v1; + use crate::block::{BlockDevice, BlockError}; use crate::crypto::sha256; diff --git a/crates/aienos-kernel/src/store/v1.rs b/crates/aienos-kernel/src/store/v1.rs new file mode 100644 index 00000000..32c2e21c --- /dev/null +++ b/crates/aienos-kernel/src/store/v1.rs @@ -0,0 +1,1054 @@ +//! Canonical System Store v1 encodings from ADR 0015. +//! +//! This module provides format primitives only. It does not read or write a +//! device, provision a region, mount a store, or implement transactions. + +use alloc::vec; +use alloc::vec::Vec; + +use crate::crypto::sha256::Sha256; + +pub const STORE_UNIT_BYTES: usize = 4096; +pub const MAX_CATALOG_ENTRIES: usize = 4096; +pub const CATALOG_HEADER_BYTES: usize = 16; +pub const CATALOG_ENTRY_BYTES: usize = 64; +pub const MAX_OBJECT_BYTES: u64 = 67_108_864; +pub const MAX_OBJECT_UNITS: u32 = 16_384; +pub const MAX_TRANSACTION_OBJECTS: usize = 256; +pub const MAX_TRANSACTION_UNITS: u64 = 32_768; +pub const MAX_REGION_UNITS: u64 = 4_294_967_296; +pub const OBJECT_KIND_CATALOG: u16 = 1; +pub const OBJECT_KIND_COMMIT_RECORD: u16 = 2; +pub const OBJECT_VERSION_V1: u16 = 1; +pub const COMMIT_RECORD_BYTES: usize = 200; +pub const SUPERBLOCK_CRC_OFFSET: usize = 168; +pub const SUPERBLOCK_RESERVED_OFFSET: usize = 172; + +const OBJECT_DOMAIN: &[u8] = b"AIENOS-STORE-OBJECT-V1\0"; +const CATALOG_MAGIC: &[u8; 8] = b"AIENCAT1"; +const COMMIT_MAGIC: &[u8; 8] = b"AIENCMT1"; +const SUPERBLOCK_MAGIC: &[u8; 8] = b"AIENSTR1"; + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum FormatError { + InvalidLength, + InvalidObject, + ObjectTooLarge, + LengthOverflow, + MalformedDescriptor, + OutOfBounds, + Overlap, + CatalogTooLarge, + CatalogOrder, + DuplicateObject, + BadCatalogMagic, + UnsupportedVersion, + MalformedCommitRecord, + MalformedSuperblock, + BadSuperblockMagic, + BadSuperblockCrc, + NonzeroReserved, + WrongSuperblockSlot, + UnsupportedFeatures, + IntegrityFailure, + InvalidGeneration, + ConflictingRoots, + InconsistentHistory, +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] +pub struct ObjectId(pub [u8; 32]); + +impl ObjectId { + pub fn calculate(kind: u16, version: u16, semantic_bytes: &[u8]) -> Result { + if kind == 0 || version == 0 || semantic_bytes.is_empty() { + return Err(FormatError::InvalidObject); + } + if semantic_bytes.len() as u64 > MAX_OBJECT_BYTES { + return Err(FormatError::ObjectTooLarge); + } + let length = + u64::try_from(semantic_bytes.len()).map_err(|_| FormatError::ObjectTooLarge)?; + let mut hash = Sha256::new(); + hash.update(OBJECT_DOMAIN); + hash.update(&kind.to_le_bytes()); + hash.update(&version.to_le_bytes()); + hash.update(&length.to_le_bytes()); + hash.update(semantic_bytes); + Ok(Self(hash.finalize())) + } + + /// Validate an entire physical object extent, including zero final padding. + pub fn validate_extent( + self, + kind: u16, + version: u16, + byte_length: u64, + extent: &[u8], + ) -> Result<(), FormatError> { + let units = object_unit_count(byte_length)?; + let extent_length = usize::try_from(u64::from(units) * STORE_UNIT_BYTES as u64) + .map_err(|_| FormatError::LengthOverflow)?; + if extent.len() != extent_length { + return Err(FormatError::InvalidLength); + } + let semantic_length = + usize::try_from(byte_length).map_err(|_| FormatError::LengthOverflow)?; + if extent[semantic_length..].iter().any(|byte| *byte != 0) { + return Err(FormatError::NonzeroReserved); + } + if Self::calculate(kind, version, &extent[..semantic_length])? != self { + return Err(FormatError::IntegrityFailure); + } + Ok(()) + } +} + +pub fn object_unit_count(byte_length: u64) -> Result { + if byte_length == 0 { + return Err(FormatError::InvalidObject); + } + if byte_length > MAX_OBJECT_BYTES { + return Err(FormatError::ObjectTooLarge); + } + let units = byte_length + .checked_add(STORE_UNIT_BYTES as u64 - 1) + .ok_or(FormatError::LengthOverflow)? + / STORE_UNIT_BYTES as u64; + let units = u32::try_from(units).map_err(|_| FormatError::LengthOverflow)?; + if units > MAX_OBJECT_UNITS { + return Err(FormatError::ObjectTooLarge); + } + Ok(units) +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct CatalogEntry { + pub object_id: ObjectId, + pub kind: u16, + pub version: u16, + pub first_unit: u64, + pub byte_length: u64, + pub unit_count: u32, + pub flags: u16, +} + +impl CatalogEntry { + pub fn encode(self) -> Result<[u8; CATALOG_ENTRY_BYTES], FormatError> { + self.validate_shape()?; + let mut bytes = [0u8; CATALOG_ENTRY_BYTES]; + bytes[0..32].copy_from_slice(&self.object_id.0); + put_u16(&mut bytes, 32, self.kind); + put_u16(&mut bytes, 34, self.version); + put_u64(&mut bytes, 36, self.first_unit); + put_u64(&mut bytes, 44, self.byte_length); + put_u32(&mut bytes, 52, self.unit_count); + put_u16(&mut bytes, 56, self.flags); + Ok(bytes) + } + + pub fn decode(bytes: &[u8]) -> Result { + if bytes.len() != CATALOG_ENTRY_BYTES { + return Err(FormatError::InvalidLength); + } + if bytes[58..64].iter().any(|byte| *byte != 0) { + return Err(FormatError::NonzeroReserved); + } + let mut id = [0; 32]; + id.copy_from_slice(&bytes[..32]); + let value = Self { + object_id: ObjectId(id), + kind: get_u16(bytes, 32)?, + version: get_u16(bytes, 34)?, + first_unit: get_u64(bytes, 36)?, + byte_length: get_u64(bytes, 44)?, + unit_count: get_u32(bytes, 52)?, + flags: get_u16(bytes, 56)?, + }; + value.validate_shape()?; + Ok(value) + } + + fn validate_shape(self) -> Result<(), FormatError> { + if self.kind < 3 || self.version == 0 || self.flags != 0 { + return Err(FormatError::MalformedDescriptor); + } + if object_unit_count(self.byte_length)? != self.unit_count { + return Err(FormatError::MalformedDescriptor); + } + Ok(()) + } + + pub fn validate_bounds( + self, + region_units: u64, + catalog_first_unit: u64, + committed_high_water: u64, + ) -> Result<(), FormatError> { + self.validate_shape()?; + if !(4..=MAX_REGION_UNITS).contains(®ion_units) + || committed_high_water < 4 + || committed_high_water > region_units + { + return Err(FormatError::OutOfBounds); + } + let end = self + .first_unit + .checked_add(u64::from(self.unit_count)) + .ok_or(FormatError::LengthOverflow)?; + if self.first_unit < 2 + || end > catalog_first_unit + || end > committed_high_water + || end > region_units + { + return Err(FormatError::OutOfBounds); + } + Ok(()) + } +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Catalog { + pub entries: Vec, +} + +impl Catalog { + pub fn encode(&self) -> Result, FormatError> { + if self.entries.len() > MAX_CATALOG_ENTRIES { + return Err(FormatError::CatalogTooLarge); + } + self.check_order()?; + let bytes_length = CATALOG_HEADER_BYTES + .checked_add( + self.entries + .len() + .checked_mul(CATALOG_ENTRY_BYTES) + .ok_or(FormatError::LengthOverflow)?, + ) + .ok_or(FormatError::LengthOverflow)?; + let mut bytes = vec![0u8; bytes_length]; + bytes[..8].copy_from_slice(CATALOG_MAGIC); + put_u16(&mut bytes, 8, 1); + put_u16(&mut bytes, 10, CATALOG_ENTRY_BYTES as u16); + put_u32(&mut bytes, 12, self.entries.len() as u32); + for (index, entry) in self.entries.iter().copied().enumerate() { + let start = CATALOG_HEADER_BYTES + index * CATALOG_ENTRY_BYTES; + bytes[start..start + CATALOG_ENTRY_BYTES].copy_from_slice(&entry.encode()?); + } + Ok(bytes) + } + + pub fn decode(bytes: &[u8]) -> Result { + if bytes.len() < CATALOG_HEADER_BYTES { + return Err(FormatError::InvalidLength); + } + if &bytes[..8] != CATALOG_MAGIC { + return Err(FormatError::BadCatalogMagic); + } + if get_u16(bytes, 8)? != 1 || get_u16(bytes, 10)? != CATALOG_ENTRY_BYTES as u16 { + return Err(FormatError::UnsupportedVersion); + } + let count = + usize::try_from(get_u32(bytes, 12)?).map_err(|_| FormatError::LengthOverflow)?; + if count > MAX_CATALOG_ENTRIES { + return Err(FormatError::CatalogTooLarge); + } + let expected = CATALOG_HEADER_BYTES + .checked_add( + count + .checked_mul(CATALOG_ENTRY_BYTES) + .ok_or(FormatError::LengthOverflow)?, + ) + .ok_or(FormatError::LengthOverflow)?; + if bytes.len() != expected { + return Err(FormatError::InvalidLength); + } + let mut entries = Vec::with_capacity(count); + for index in 0..count { + let start = CATALOG_HEADER_BYTES + index * CATALOG_ENTRY_BYTES; + entries.push(CatalogEntry::decode( + &bytes[start..start + CATALOG_ENTRY_BYTES], + )?); + } + let catalog = Self { entries }; + catalog.check_order()?; + Ok(catalog) + } + + pub fn validate_extents( + &self, + region_units: u64, + catalog_first_unit: u64, + committed_high_water: u64, + ) -> Result<(), FormatError> { + if !(4..=MAX_REGION_UNITS).contains(®ion_units) + || committed_high_water < 4 + || committed_high_water > region_units + || catalog_first_unit < 2 + || catalog_first_unit >= region_units + { + return Err(FormatError::OutOfBounds); + } + let mut extents = Vec::with_capacity(self.entries.len()); + for entry in self.entries.iter().copied() { + entry.validate_bounds(region_units, catalog_first_unit, committed_high_water)?; + let end = entry + .first_unit + .checked_add(u64::from(entry.unit_count)) + .ok_or(FormatError::LengthOverflow)?; + extents.push((entry.first_unit, end)); + } + extents.sort_unstable(); + if extents.windows(2).any(|pair| pair[0].1 > pair[1].0) { + return Err(FormatError::Overlap); + } + Ok(()) + } + + fn check_order(&self) -> Result<(), FormatError> { + for pair in self.entries.windows(2) { + if pair[0].object_id >= pair[1].object_id { + return if pair[0].object_id == pair[1].object_id { + Err(FormatError::DuplicateObject) + } else { + Err(FormatError::CatalogOrder) + }; + } + } + Ok(()) + } +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CommitRecord { + pub store_uuid: [u8; 16], + pub region_units: u64, + pub generation: u64, + pub previous_generation: u64, + pub previous_commit_id: ObjectId, + pub previous_catalog_id: ObjectId, + pub catalog_id: ObjectId, + pub catalog_first_unit: u64, + pub catalog_byte_length: u64, + pub catalog_unit_count: u32, + pub catalog_entry_count: u32, + pub committed_high_water: u64, +} + +impl CommitRecord { + pub fn encode(&self) -> Result<[u8; COMMIT_RECORD_BYTES], FormatError> { + self.validate()?; + let mut bytes = [0u8; COMMIT_RECORD_BYTES]; + bytes[..8].copy_from_slice(COMMIT_MAGIC); + put_u16(&mut bytes, 8, 1); + put_u16(&mut bytes, 10, COMMIT_RECORD_BYTES as u16); + put_u16(&mut bytes, 12, 1); + put_u16(&mut bytes, 14, 0); + put_u64(&mut bytes, 16, 0); + put_u64(&mut bytes, 24, 0); + bytes[32..48].copy_from_slice(&self.store_uuid); + put_u64(&mut bytes, 48, self.region_units); + put_u64(&mut bytes, 56, self.generation); + put_u64(&mut bytes, 64, self.previous_generation); + bytes[72..104].copy_from_slice(&self.previous_commit_id.0); + bytes[104..136].copy_from_slice(&self.previous_catalog_id.0); + bytes[136..168].copy_from_slice(&self.catalog_id.0); + put_u64(&mut bytes, 168, self.catalog_first_unit); + put_u64(&mut bytes, 176, self.catalog_byte_length); + put_u32(&mut bytes, 184, self.catalog_unit_count); + put_u32(&mut bytes, 188, self.catalog_entry_count); + put_u64(&mut bytes, 192, self.committed_high_water); + Ok(bytes) + } + + pub fn decode(bytes: &[u8]) -> Result { + if bytes.len() != COMMIT_RECORD_BYTES || &bytes[..8] != COMMIT_MAGIC { + return Err(FormatError::MalformedCommitRecord); + } + if get_u16(bytes, 8)? != 1 || get_u16(bytes, 10)? as usize != COMMIT_RECORD_BYTES { + return Err(FormatError::UnsupportedVersion); + } + if get_u16(bytes, 12)? != 1 || get_u16(bytes, 14)? != 0 { + return Err(FormatError::UnsupportedVersion); + } + if get_u64(bytes, 16)? != 0 || get_u64(bytes, 24)? != 0 { + return Err(FormatError::UnsupportedFeatures); + } + let mut store_uuid = [0; 16]; + store_uuid.copy_from_slice(&bytes[32..48]); + let mut prev_commit = [0; 32]; + prev_commit.copy_from_slice(&bytes[72..104]); + let mut prev_catalog = [0; 32]; + prev_catalog.copy_from_slice(&bytes[104..136]); + let mut catalog = [0; 32]; + catalog.copy_from_slice(&bytes[136..168]); + let record = Self { + store_uuid, + region_units: get_u64(bytes, 48)?, + generation: get_u64(bytes, 56)?, + previous_generation: get_u64(bytes, 64)?, + previous_commit_id: ObjectId(prev_commit), + previous_catalog_id: ObjectId(prev_catalog), + catalog_id: ObjectId(catalog), + catalog_first_unit: get_u64(bytes, 168)?, + catalog_byte_length: get_u64(bytes, 176)?, + catalog_unit_count: get_u32(bytes, 184)?, + catalog_entry_count: get_u32(bytes, 188)?, + committed_high_water: get_u64(bytes, 192)?, + }; + record.validate()?; + Ok(record) + } + + pub fn object_id(&self) -> Result { + ObjectId::calculate( + OBJECT_KIND_COMMIT_RECORD, + OBJECT_VERSION_V1, + &self.encode()?, + ) + } + + pub fn validate(&self) -> Result<(), FormatError> { + if !(4..=MAX_REGION_UNITS).contains(&self.region_units) || self.generation == 0 { + return Err(FormatError::MalformedCommitRecord); + } + let expected_bytes = CATALOG_HEADER_BYTES + .checked_add( + usize::try_from(self.catalog_entry_count) + .map_err(|_| FormatError::LengthOverflow)? + .checked_mul(CATALOG_ENTRY_BYTES) + .ok_or(FormatError::LengthOverflow)?, + ) + .ok_or(FormatError::LengthOverflow)?; + if self.catalog_entry_count as usize > MAX_CATALOG_ENTRIES + || self.catalog_byte_length != expected_bytes as u64 + || object_unit_count(self.catalog_byte_length)? != self.catalog_unit_count + { + return Err(FormatError::MalformedCommitRecord); + } + let catalog_end = self + .catalog_first_unit + .checked_add(u64::from(self.catalog_unit_count)) + .ok_or(FormatError::LengthOverflow)?; + if self.catalog_first_unit < 2 + || catalog_end >= self.region_units + || self.committed_high_water != catalog_end + 1 + || self.committed_high_water > self.region_units + { + return Err(FormatError::MalformedCommitRecord); + } + if self.generation == 1 { + if self.previous_generation != 0 + || self.previous_commit_id != ObjectId([0; 32]) + || self.previous_catalog_id != ObjectId([0; 32]) + { + return Err(FormatError::InvalidGeneration); + } + } else if self.previous_generation.checked_add(1) != Some(self.generation) + || self.previous_commit_id == ObjectId([0; 32]) + || self.previous_catalog_id == ObjectId([0; 32]) + { + return Err(FormatError::InvalidGeneration); + } + Ok(()) + } + + pub fn validates_catalog( + &self, + catalog_id: ObjectId, + catalog: &Catalog, + ) -> Result<(), FormatError> { + let semantic = catalog.encode()?; + if self.catalog_id != catalog_id + || self.catalog_entry_count as usize != catalog.entries.len() + || self.catalog_byte_length != semantic.len() as u64 + || object_unit_count(semantic.len() as u64)? != self.catalog_unit_count + || ObjectId::calculate(OBJECT_KIND_CATALOG, OBJECT_VERSION_V1, &semantic)? != catalog_id + { + return Err(FormatError::IntegrityFailure); + } + Ok(()) + } + + pub fn identifies_predecessor(&self, previous: &Self, previous_id: ObjectId) -> bool { + self.generation.checked_sub(1) == Some(previous.generation) + && self.previous_generation == previous.generation + && self.previous_commit_id == previous_id + && self.previous_catalog_id == previous.catalog_id + && self.store_uuid == previous.store_uuid + && self.region_units == previous.region_units + && self.catalog_first_unit >= previous.committed_high_water + } +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Superblock { + pub store_uuid: [u8; 16], + pub slot_id: u32, + pub region_units: u64, + pub generation: u64, + pub commit_record_id: ObjectId, + pub commit_record_unit: u64, + pub catalog_id: ObjectId, + pub catalog_first_unit: u64, + pub catalog_byte_length: u64, + pub catalog_unit_count: u32, + pub catalog_entry_count: u32, + pub committed_high_water: u64, +} + +impl Superblock { + pub fn encode(&self) -> Result<[u8; STORE_UNIT_BYTES], FormatError> { + self.validate_shape()?; + let mut bytes = [0u8; STORE_UNIT_BYTES]; + bytes[..8].copy_from_slice(SUPERBLOCK_MAGIC); + put_u16(&mut bytes, 8, 1); + put_u16(&mut bytes, 10, 0); + put_u64(&mut bytes, 12, 0); + put_u64(&mut bytes, 20, 0); + bytes[28..44].copy_from_slice(&self.store_uuid); + put_u32(&mut bytes, 44, self.slot_id); + put_u64(&mut bytes, 48, self.region_units); + put_u64(&mut bytes, 56, self.generation); + bytes[64..96].copy_from_slice(&self.commit_record_id.0); + put_u64(&mut bytes, 96, self.commit_record_unit); + bytes[104..136].copy_from_slice(&self.catalog_id.0); + put_u64(&mut bytes, 136, self.catalog_first_unit); + put_u64(&mut bytes, 144, self.catalog_byte_length); + put_u32(&mut bytes, 152, self.catalog_unit_count); + put_u32(&mut bytes, 156, self.catalog_entry_count); + put_u64(&mut bytes, 160, self.committed_high_water); + let checksum = crc32c(&bytes); + put_u32(&mut bytes, SUPERBLOCK_CRC_OFFSET, checksum); + Ok(bytes) + } + + pub fn decode(bytes: &[u8], expected_slot: u32) -> Result { + if bytes.len() != STORE_UNIT_BYTES || &bytes[..8] != SUPERBLOCK_MAGIC { + return Err(FormatError::BadSuperblockMagic); + } + let stored_crc = get_u32(bytes, SUPERBLOCK_CRC_OFFSET)?; + let mut canonical = [0u8; STORE_UNIT_BYTES]; + canonical.copy_from_slice(bytes); + canonical[SUPERBLOCK_CRC_OFFSET..SUPERBLOCK_CRC_OFFSET + 4].fill(0); + if crc32c(&canonical) != stored_crc { + return Err(FormatError::BadSuperblockCrc); + } + if bytes[SUPERBLOCK_RESERVED_OFFSET..] + .iter() + .any(|byte| *byte != 0) + { + return Err(FormatError::NonzeroReserved); + } + if get_u16(bytes, 8)? != 1 || get_u16(bytes, 10)? != 0 { + return Err(FormatError::UnsupportedVersion); + } + if get_u64(bytes, 12)? != 0 || get_u64(bytes, 20)? != 0 { + return Err(FormatError::UnsupportedFeatures); + } + let slot_id = get_u32(bytes, 44)?; + if slot_id != expected_slot || slot_id > 1 { + return Err(FormatError::WrongSuperblockSlot); + } + let mut uuid = [0; 16]; + uuid.copy_from_slice(&bytes[28..44]); + let mut commit = [0; 32]; + commit.copy_from_slice(&bytes[64..96]); + let mut catalog = [0; 32]; + catalog.copy_from_slice(&bytes[104..136]); + let value = Self { + store_uuid: uuid, + slot_id, + region_units: get_u64(bytes, 48)?, + generation: get_u64(bytes, 56)?, + commit_record_id: ObjectId(commit), + commit_record_unit: get_u64(bytes, 96)?, + catalog_id: ObjectId(catalog), + catalog_first_unit: get_u64(bytes, 136)?, + catalog_byte_length: get_u64(bytes, 144)?, + catalog_unit_count: get_u32(bytes, 152)?, + catalog_entry_count: get_u32(bytes, 156)?, + committed_high_water: get_u64(bytes, 160)?, + }; + value.validate_shape()?; + Ok(value) + } + + pub fn validate_commit( + &self, + commit_id: ObjectId, + commit: &CommitRecord, + ) -> Result<(), FormatError> { + if self.commit_record_id != commit_id + || self.store_uuid != commit.store_uuid + || self.region_units != commit.region_units + || self.generation != commit.generation + || self.catalog_id != commit.catalog_id + || self.catalog_first_unit != commit.catalog_first_unit + || self.catalog_byte_length != commit.catalog_byte_length + || self.catalog_unit_count != commit.catalog_unit_count + || self.catalog_entry_count != commit.catalog_entry_count + || self.committed_high_water != commit.committed_high_water + || self.commit_record_unit.checked_add(1) != Some(commit.committed_high_water) + || self + .catalog_first_unit + .checked_add(u64::from(self.catalog_unit_count)) + != Some(self.commit_record_unit) + { + return Err(FormatError::MalformedSuperblock); + } + Ok(()) + } + + pub fn equivalent_root(&self, other: &Self) -> bool { + self.store_uuid == other.store_uuid + && self.region_units == other.region_units + && self.generation == other.generation + && self.commit_record_id == other.commit_record_id + } + + fn validate_shape(&self) -> Result<(), FormatError> { + if self.slot_id > 1 + || !(4..=MAX_REGION_UNITS).contains(&self.region_units) + || self.generation == 0 + || self.committed_high_water > self.region_units + || self.committed_high_water < 4 + { + return Err(FormatError::MalformedSuperblock); + } + let expected_catalog_length = CATALOG_HEADER_BYTES + .checked_add( + usize::try_from(self.catalog_entry_count) + .map_err(|_| FormatError::LengthOverflow)? + .checked_mul(CATALOG_ENTRY_BYTES) + .ok_or(FormatError::LengthOverflow)?, + ) + .ok_or(FormatError::LengthOverflow)?; + let catalog_end = self + .catalog_first_unit + .checked_add(u64::from(self.catalog_unit_count)) + .ok_or(FormatError::LengthOverflow)?; + if self.catalog_entry_count as usize > MAX_CATALOG_ENTRIES + || self.catalog_byte_length != expected_catalog_length as u64 + || object_unit_count(self.catalog_byte_length)? != self.catalog_unit_count + || self.catalog_first_unit < 2 + || catalog_end != self.commit_record_unit + || self.commit_record_unit.checked_add(1) != Some(self.committed_high_water) + { + return Err(FormatError::MalformedSuperblock); + } + Ok(()) + } +} + +/// CRC-32C/Castagnoli, reflected polynomial 0x82f63b78, init/xorout all ones. +pub fn crc32c(bytes: &[u8]) -> u32 { + let mut crc = 0xffff_ffffu32; + for byte in bytes { + crc ^= u32::from(*byte); + for _ in 0..8 { + let mask = 0u32.wrapping_sub(crc & 1); + crc = (crc >> 1) ^ (0x82f6_3b78 & mask); + } + } + !crc +} + +fn get_u16(bytes: &[u8], offset: usize) -> Result { + let field = bytes + .get(offset..offset.checked_add(2).ok_or(FormatError::LengthOverflow)?) + .ok_or(FormatError::InvalidLength)?; + Ok(u16::from_le_bytes([field[0], field[1]])) +} +fn get_u32(bytes: &[u8], offset: usize) -> Result { + let field = bytes + .get(offset..offset.checked_add(4).ok_or(FormatError::LengthOverflow)?) + .ok_or(FormatError::InvalidLength)?; + Ok(u32::from_le_bytes([field[0], field[1], field[2], field[3]])) +} +fn get_u64(bytes: &[u8], offset: usize) -> Result { + let field = bytes + .get(offset..offset.checked_add(8).ok_or(FormatError::LengthOverflow)?) + .ok_or(FormatError::InvalidLength)?; + Ok(u64::from_le_bytes([ + field[0], field[1], field[2], field[3], field[4], field[5], field[6], field[7], + ])) +} +fn put_u16(bytes: &mut [u8], offset: usize, value: u16) { + bytes[offset..offset + 2].copy_from_slice(&value.to_le_bytes()); +} +fn put_u32(bytes: &mut [u8], offset: usize, value: u32) { + bytes[offset..offset + 4].copy_from_slice(&value.to_le_bytes()); +} +fn put_u64(bytes: &mut [u8], offset: usize, value: u64) { + bytes[offset..offset + 8].copy_from_slice(&value.to_le_bytes()); +} + +#[cfg(test)] +mod tests { + use super::*; + + fn from_hex(value: &str) -> [u8; N] { + assert_eq!(value.len(), N * 2); + let mut out = [0; N]; + for (index, byte) in out.iter_mut().enumerate() { + *byte = u8::from_str_radix(&value[index * 2..index * 2 + 2], 16).unwrap(); + } + out + } + + fn assert_sha256(bytes: &[u8], expected: &str) { + let mut hash = Sha256::new(); + hash.update(bytes); + assert_eq!(hash.finalize(), from_hex::<32>(expected)); + } + + fn sample_genesis() -> (CommitRecord, ObjectId, Superblock) { + let catalog = Catalog { entries: vec![] }; + let catalog_bytes = catalog.encode().unwrap(); + let catalog_id = + ObjectId::calculate(OBJECT_KIND_CATALOG, OBJECT_VERSION_V1, &catalog_bytes).unwrap(); + let record = CommitRecord { + store_uuid: core::array::from_fn(|index| index as u8), + region_units: 16, + generation: 1, + previous_generation: 0, + previous_commit_id: ObjectId([0; 32]), + previous_catalog_id: ObjectId([0; 32]), + catalog_id, + catalog_first_unit: 2, + catalog_byte_length: catalog_bytes.len() as u64, + catalog_unit_count: 1, + catalog_entry_count: 0, + committed_high_water: 4, + }; + let commit_id = record.object_id().unwrap(); + let superblock = Superblock { + store_uuid: record.store_uuid, + slot_id: 0, + region_units: record.region_units, + generation: record.generation, + commit_record_id: commit_id, + commit_record_unit: 3, + catalog_id, + catalog_first_unit: 2, + catalog_byte_length: catalog_bytes.len() as u64, + catalog_unit_count: 1, + catalog_entry_count: 0, + committed_high_water: 4, + }; + (record, catalog_id, superblock) + } + + #[test] + fn object_id_and_catalog_vectors_match_adr_0015() { + let semantic: [u8; 16] = core::array::from_fn(|index| index as u8); + let standalone = ObjectId::calculate(0x1234, 0x5678, &semantic).unwrap(); + assert_eq!( + standalone.0, + from_hex("80b93b4e31915bf7a7fd4607e686e757924425d9a4f9c1e84f51672d1b9b1334") + ); + + let empty = Catalog { entries: vec![] }; + let empty_bytes = empty.encode().unwrap(); + assert_eq!( + empty_bytes, + from_hex::<16>("4149454e434154310100400000000000") + ); + let empty_id = + ObjectId::calculate(OBJECT_KIND_CATALOG, OBJECT_VERSION_V1, &empty_bytes).unwrap(); + assert_eq!( + empty_id.0, + from_hex("44197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a") + ); + + let app_id = ObjectId::calculate(3, 1, &semantic).unwrap(); + assert_eq!( + app_id.0, + from_hex("307663335463d5f838fdd1b60950a02c873a28cd6cea13c2ffbfa5d8e41145a6") + ); + let entry = CatalogEntry { + object_id: app_id, + kind: 3, + version: 1, + first_unit: 4, + byte_length: 16, + unit_count: 1, + flags: 0, + }; + let one = Catalog { + entries: vec![entry], + }; + let one_bytes = one.encode().unwrap(); + assert_eq!(one_bytes.len(), 80); + assert_sha256( + &one_bytes, + "3b8b9ea39606ad6abba5f20db970872b20487663cfff69024a6cc01d7e951645", + ); + let one_id = + ObjectId::calculate(OBJECT_KIND_CATALOG, OBJECT_VERSION_V1, &one_bytes).unwrap(); + assert_eq!( + one_id.0, + from_hex("15d05f57a32d04af08fc9ba5d88c2fd9fdf09ba9858cfa35b25bb6e66c1f7c85") + ); + assert_eq!(Catalog::decode(&one_bytes).unwrap(), one); + } + + #[test] + fn commit_superblock_genesis_and_adjacent_vectors_match_adr_0015() { + let (genesis, empty_catalog_id, mut genesis_sb) = sample_genesis(); + let genesis_bytes = genesis.encode().unwrap(); + assert_sha256( + &genesis_bytes, + "54e2090af026678f548a8096a5781caeef14122f2cc22d65f4afa69e65a198f0", + ); + let genesis_id = genesis.object_id().unwrap(); + assert_eq!( + genesis_id.0, + from_hex("655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d422") + ); + let mut commit_unit = [0; STORE_UNIT_BYTES]; + commit_unit[..COMMIT_RECORD_BYTES].copy_from_slice(&genesis_bytes); + assert_sha256( + &commit_unit, + "d23bfa188198e0b285e12411ab8054183f67b2e67cbe03933a2444297a98dc4d", + ); + assert_eq!(CommitRecord::decode(&genesis_bytes).unwrap(), genesis); + + genesis_sb.validate_commit(genesis_id, &genesis).unwrap(); + let sb_a = genesis_sb.encode().unwrap(); + assert_sha256( + &sb_a, + "fd25f10310b662942275d0b72255a9f3a4e389b6e34d111465884a467e7ebdbc", + ); + let crc_a = get_u32(&sb_a, SUPERBLOCK_CRC_OFFSET).unwrap(); + assert_eq!(crc_a.to_le_bytes(), from_hex("fc775a27")); + assert_eq!(Superblock::decode(&sb_a, 0).unwrap(), genesis_sb); + + genesis_sb.slot_id = 1; + let sb_b = genesis_sb.encode().unwrap(); + assert_sha256( + &sb_b, + "e75a62a7a81ac318487ad1def438933430df9c199a1e5ef8942ef599731018e7", + ); + assert_eq!( + get_u32(&sb_b, SUPERBLOCK_CRC_OFFSET).unwrap().to_le_bytes(), + from_hex("98353ee3") + ); + let decoded_b = Superblock::decode(&sb_b, 1).unwrap(); + assert!(Superblock::decode(&sb_a, 0) + .unwrap() + .equivalent_root(&decoded_b)); + assert_eq!(crc32c(b"123456789"), 0xe306_9283); + + let semantic: [u8; 16] = core::array::from_fn(|index| index as u8); + let app_id = ObjectId::calculate(3, 1, &semantic).unwrap(); + let gen2_catalog = Catalog { + entries: vec![CatalogEntry { + object_id: app_id, + kind: 3, + version: 1, + first_unit: 4, + byte_length: 16, + unit_count: 1, + flags: 0, + }], + }; + let gen2_catalog_bytes = gen2_catalog.encode().unwrap(); + let gen2_catalog_id = + ObjectId::calculate(OBJECT_KIND_CATALOG, OBJECT_VERSION_V1, &gen2_catalog_bytes) + .unwrap(); + let gen2 = CommitRecord { + store_uuid: genesis.store_uuid, + region_units: genesis.region_units, + generation: 2, + previous_generation: 1, + previous_commit_id: genesis_id, + previous_catalog_id: empty_catalog_id, + catalog_id: gen2_catalog_id, + catalog_first_unit: 5, + catalog_byte_length: 80, + catalog_unit_count: 1, + catalog_entry_count: 1, + committed_high_water: 7, + }; + assert!(gen2.identifies_predecessor(&genesis, genesis_id)); + let gen2_bytes = gen2.encode().unwrap(); + assert_sha256( + &gen2_bytes, + "2a1a929eaae3b473531ee70ee8bb945ffe6ca05caf0b5e7a8c69d2179e1e716c", + ); + let gen2_id = gen2.object_id().unwrap(); + assert_eq!( + gen2_id.0, + from_hex("7787f3c9a29560e67987c4c83dd2b49ab402ee27975432a0f43fdf50749d11c1") + ); + let gen2_sb = Superblock { + store_uuid: gen2.store_uuid, + slot_id: 0, + region_units: gen2.region_units, + generation: 2, + commit_record_id: gen2_id, + commit_record_unit: 6, + catalog_id: gen2_catalog_id, + catalog_first_unit: 5, + catalog_byte_length: 80, + catalog_unit_count: 1, + catalog_entry_count: 1, + committed_high_water: 7, + }; + gen2_sb.validate_commit(gen2_id, &gen2).unwrap(); + assert_sha256( + &gen2_sb.encode().unwrap(), + "47c84fb7394d4fb5b52d1b600fe67c4f3f07d41ed98ffadde2afa15b4dc9ddcc", + ); + } + + #[test] + fn malformed_object_catalog_and_extent_vectors_are_rejected() { + let semantic = [0x5au8; 16]; + assert_eq!( + ObjectId::calculate(3, 1, &[]), + Err(FormatError::InvalidObject) + ); + assert_eq!( + ObjectId::calculate(0, 1, &semantic), + Err(FormatError::InvalidObject) + ); + let id = ObjectId::calculate(3, 1, &semantic).unwrap(); + let entry = CatalogEntry { + object_id: id, + kind: 3, + version: 1, + first_unit: 2, + byte_length: 16, + unit_count: 1, + flags: 0, + }; + let mut encoded_entry = entry.encode().unwrap(); + encoded_entry[58] = 1; + assert_eq!( + CatalogEntry::decode(&encoded_entry), + Err(FormatError::NonzeroReserved) + ); + let mut bad_flags = entry; + bad_flags.flags = 1; + assert_eq!(bad_flags.encode(), Err(FormatError::MalformedDescriptor)); + + let ordered = Catalog { + entries: vec![ + entry, + CatalogEntry { + object_id: ObjectId([0xff; 32]), + ..entry + }, + ], + }; + assert!(ordered.encode().is_ok()); + let reversed = Catalog { + entries: vec![ordered.entries[1], ordered.entries[0]], + }; + assert_eq!(reversed.encode(), Err(FormatError::CatalogOrder)); + let duplicate = Catalog { + entries: vec![entry, entry], + }; + assert_eq!(duplicate.encode(), Err(FormatError::DuplicateObject)); + + let mut empty_bytes = Catalog { entries: vec![] }.encode().unwrap(); + empty_bytes[12..16].copy_from_slice(&1u32.to_le_bytes()); + assert_eq!( + Catalog::decode(&empty_bytes), + Err(FormatError::InvalidLength) + ); + let mut bad_magic = Catalog { entries: vec![] }.encode().unwrap(); + bad_magic[0] ^= 1; + assert_eq!( + Catalog::decode(&bad_magic), + Err(FormatError::BadCatalogMagic) + ); + + let mut physical = [0; STORE_UNIT_BYTES]; + physical[..semantic.len()].copy_from_slice(&semantic); + id.validate_extent(3, 1, semantic.len() as u64, &physical) + .unwrap(); + physical[STORE_UNIT_BYTES - 1] = 1; + assert_eq!( + id.validate_extent(3, 1, semantic.len() as u64, &physical), + Err(FormatError::NonzeroReserved) + ); + physical[STORE_UNIT_BYTES - 1] = 0; + physical[0] ^= 1; + assert_eq!( + id.validate_extent(3, 1, semantic.len() as u64, &physical), + Err(FormatError::IntegrityFailure) + ); + + let first = CatalogEntry { + first_unit: 2, + ..entry + }; + let overlap = Catalog { + entries: vec![ + entry, + CatalogEntry { + object_id: ObjectId([0xff; 32]), + ..first + }, + ], + }; + assert_eq!( + overlap.validate_extents(32, 5, 8), + Err(FormatError::Overlap) + ); + assert_eq!( + entry.validate_bounds(8, 2, 8), + Err(FormatError::OutOfBounds) + ); + } + + #[test] + fn malformed_generation_high_water_and_superblock_bytes_are_rejected() { + let (genesis, _, sb) = sample_genesis(); + let mut broken_genesis = genesis.clone(); + broken_genesis.previous_generation = 1; + assert_eq!(broken_genesis.encode(), Err(FormatError::InvalidGeneration)); + let mut broken_high_water = genesis.clone(); + broken_high_water.committed_high_water = 5; + assert_eq!( + broken_high_water.encode(), + Err(FormatError::MalformedCommitRecord) + ); + + let bytes = sb.encode().unwrap(); + let mut bad_crc = bytes; + bad_crc[168] ^= 1; + assert_eq!( + Superblock::decode(&bad_crc, 0), + Err(FormatError::BadSuperblockCrc) + ); + let mut reserved = bytes; + reserved[SUPERBLOCK_RESERVED_OFFSET] = 1; + reserved[SUPERBLOCK_CRC_OFFSET..SUPERBLOCK_CRC_OFFSET + 4].fill(0); + let corrected_crc = crc32c(&reserved); + put_u32(&mut reserved, SUPERBLOCK_CRC_OFFSET, corrected_crc); + assert_eq!( + Superblock::decode(&reserved, 0), + Err(FormatError::NonzeroReserved) + ); + assert_eq!( + Superblock::decode(&bytes, 1), + Err(FormatError::WrongSuperblockSlot) + ); + + let mut changed_unit = sb.clone(); + changed_unit.commit_record_unit = 2; + assert_eq!( + changed_unit.validate_commit(genesis.object_id().unwrap(), &genesis), + Err(FormatError::MalformedSuperblock) + ); + assert_eq!( + genesis.validates_catalog(genesis.catalog_id, &Catalog { entries: vec![] }), + Ok(()) + ); + } +} diff --git a/crates/aienos-kernel/tests/store_v1_negative.rs b/crates/aienos-kernel/tests/store_v1_negative.rs new file mode 100644 index 00000000..5a61deb7 --- /dev/null +++ b/crates/aienos-kernel/tests/store_v1_negative.rs @@ -0,0 +1,458 @@ +use aienos_kernel::store::v1::{ + crc32c, Catalog, CatalogEntry, CommitRecord, FormatError, ObjectId, Superblock, + COMMIT_RECORD_BYTES, MAX_CATALOG_ENTRIES, STORE_UNIT_BYTES, +}; + +fn oid(kind: u16, data: &[u8]) -> ObjectId { + ObjectId::calculate(kind, 1, data).unwrap() +} + +fn entry(first_unit: u64, data: &[u8]) -> CatalogEntry { + CatalogEntry { + object_id: oid(3, data), + kind: 3, + version: 1, + first_unit, + byte_length: data.len() as u64, + unit_count: 1, + flags: 0, + } +} + +fn empty_catalog() -> (Catalog, Vec, ObjectId) { + let catalog = Catalog { entries: vec![] }; + let bytes = catalog.encode().unwrap(); + let id = oid(1, &bytes); + (catalog, bytes, id) +} + +fn genesis() -> CommitRecord { + let (_, _, catalog_id) = empty_catalog(); + CommitRecord { + store_uuid: [0x11; 16], + region_units: 8, + generation: 1, + previous_generation: 0, + previous_commit_id: ObjectId([0; 32]), + previous_catalog_id: ObjectId([0; 32]), + catalog_id, + catalog_first_unit: 2, + catalog_byte_length: 16, + catalog_unit_count: 1, + catalog_entry_count: 0, + committed_high_water: 4, + } +} + +fn superblock(slot_id: u32, commit: &CommitRecord) -> Superblock { + Superblock { + store_uuid: commit.store_uuid, + slot_id, + region_units: commit.region_units, + generation: commit.generation, + commit_record_id: commit.object_id().unwrap(), + commit_record_unit: 3, + catalog_id: commit.catalog_id, + catalog_first_unit: commit.catalog_first_unit, + catalog_byte_length: commit.catalog_byte_length, + catalog_unit_count: commit.catalog_unit_count, + catalog_entry_count: commit.catalog_entry_count, + committed_high_water: commit.committed_high_water, + } +} + +fn rechecksum_superblock(bytes: &mut [u8]) { + bytes[168..172].fill(0); + let crc = crc32c(bytes); + bytes[168..172].copy_from_slice(&crc.to_le_bytes()); +} + +#[test] +fn catalog_rejects_bad_header_counts_and_exact_lengths() { + let (_, valid, _) = empty_catalog(); + + for (offset, replacement) in [(0, b'X'), (8, 2), (10, 63)] { + let mut malformed = valid.clone(); + malformed[offset] = replacement; + assert!(Catalog::decode(&malformed).is_err(), "offset {offset}"); + } + + let mut wrong_count = valid.clone(); + wrong_count[12..16].copy_from_slice(&1u32.to_le_bytes()); + assert_eq!( + Catalog::decode(&wrong_count), + Err(FormatError::InvalidLength) + ); + assert_eq!( + Catalog::decode(&valid[..15]), + Err(FormatError::InvalidLength) + ); + let mut trailing = valid.clone(); + trailing.push(0); + assert_eq!(Catalog::decode(&trailing), Err(FormatError::InvalidLength)); + + let mut over_limit = valid; + over_limit[12..16].copy_from_slice(&((MAX_CATALOG_ENTRIES as u32) + 1).to_le_bytes()); + assert_eq!( + Catalog::decode(&over_limit), + Err(FormatError::CatalogTooLarge) + ); +} + +#[test] +fn catalog_rejects_entry_reserved_flags_and_invalid_lengths() { + let mut encoded = entry(2, b"x").encode().unwrap(); + for offset in 58..64 { + let mut malformed = encoded; + malformed[offset] = 1; + assert_eq!( + CatalogEntry::decode(&malformed), + Err(FormatError::NonzeroReserved) + ); + } + + encoded[56] = 1; + assert_eq!( + CatalogEntry::decode(&encoded), + Err(FormatError::MalformedDescriptor) + ); + + for (offset, value) in [ + (32, 0u64), // kind zero + (34, 0), // version zero + (44, 0), // length zero + (44, 67_108_865), + (52, 0), // unit count zero + (52, 2), // incorrect ceil(length / unit) + ] { + let mut malformed = entry(2, b"x").encode().unwrap(); + let bytes = value.to_le_bytes(); + let width = if offset == 44 { + 8 + } else if offset == 52 { + 4 + } else { + 2 + }; + malformed[offset..offset + width].copy_from_slice(&bytes[..width]); + assert!( + CatalogEntry::decode(&malformed).is_err(), + "offset {offset}, value {value}" + ); + } + assert_eq!( + ObjectId::calculate(3, 1, b""), + Err(FormatError::InvalidObject) + ); +} + +#[test] +fn catalog_rejects_unsorted_and_duplicate_object_ids() { + let a = entry(2, b"a"); + let b = entry(3, b"b"); + let (low, high) = if a.object_id < b.object_id { + (a, b) + } else { + (b, a) + }; + + let sorted = Catalog { + entries: vec![low, high], + } + .encode() + .unwrap(); + assert!(Catalog::decode(&sorted).is_ok()); + + let descending = Catalog { + entries: vec![high, low], + } + .encode(); + assert_eq!(descending, Err(FormatError::CatalogOrder)); + + let duplicate = Catalog { + entries: vec![low, low], + } + .encode(); + assert_eq!(duplicate, Err(FormatError::DuplicateObject)); +} + +#[test] +fn catalog_entry_bounds_reject_metadata_overflow_and_high_water_violations() { + let valid = entry(2, b"x"); + assert!(valid.validate_bounds(8, 4, 5).is_ok()); + assert_eq!( + entry(0, b"x").validate_bounds(8, 4, 5), + Err(FormatError::OutOfBounds) + ); + assert_eq!( + entry(1, b"x").validate_bounds(8, 4, 5), + Err(FormatError::OutOfBounds) + ); + assert_eq!( + entry(4, b"x").validate_bounds(8, 4, 5), + Err(FormatError::OutOfBounds) + ); + assert_eq!( + entry(2, b"x").validate_bounds(8, 4, 2), + Err(FormatError::OutOfBounds) + ); + assert_eq!( + entry(3, b"x").validate_bounds(2, 8, 8), + Err(FormatError::OutOfBounds) + ); + + let mut overflow = valid; + overflow.first_unit = u64::MAX; + assert_eq!( + overflow.validate_bounds(8, 8, 8), + Err(FormatError::LengthOverflow) + ); +} + +#[test] +fn catalog_extents_reject_overlap_and_metadata_overlap() { + let a = entry(2, b"first"); + let b = entry(2, b"second"); + let mut entries = vec![a, b]; + entries.sort_by_key(|item| item.object_id); + let catalog = Catalog { entries }; + assert_eq!( + catalog.validate_extents(16, 4, 8), + Err(FormatError::Overlap) + ); + + let metadata_overlap = Catalog { + entries: vec![entry(3, b"third")], + }; + assert_eq!( + metadata_overlap.validate_extents(16, 3, 8), + Err(FormatError::OutOfBounds) + ); +} + +#[test] +fn object_id_rejects_semantic_mutation_wrong_identity_and_nonzero_padding() { + let semantic = b"payload"; + let id = oid(3, semantic); + let mut extent = vec![0; STORE_UNIT_BYTES]; + extent[..semantic.len()].copy_from_slice(semantic); + assert!(id + .validate_extent(3, 1, semantic.len() as u64, &extent) + .is_ok()); + + let mut changed_semantic = extent.clone(); + changed_semantic[0] ^= 1; + assert_eq!( + id.validate_extent(3, 1, semantic.len() as u64, &changed_semantic), + Err(FormatError::IntegrityFailure) + ); + + let mut changed_padding = extent.clone(); + changed_padding[STORE_UNIT_BYTES - 1] = 1; + assert_eq!( + id.validate_extent(3, 1, semantic.len() as u64, &changed_padding), + Err(FormatError::NonzeroReserved) + ); + + assert_eq!( + id.validate_extent(4, 1, semantic.len() as u64, &extent), + Err(FormatError::IntegrityFailure) + ); + assert_eq!( + id.validate_extent(3, 2, semantic.len() as u64, &extent), + Err(FormatError::IntegrityFailure) + ); + assert_eq!( + id.validate_extent(3, 1, (semantic.len() + 1) as u64, &extent), + Err(FormatError::IntegrityFailure) + ); + assert_eq!( + id.validate_extent(3, 1, semantic.len() as u64, &extent[..STORE_UNIT_BYTES - 1]), + Err(FormatError::InvalidLength) + ); + assert_eq!( + ObjectId::calculate(3, 1, b""), + Err(FormatError::InvalidObject) + ); +} + +#[test] +fn crc32c_known_answer_and_superblock_rejects_corruption_reserved_and_slot() { + assert_eq!(crc32c(b"123456789"), 0xe306_9283); + let commit = genesis(); + let valid = superblock(0, &commit).encode().unwrap(); + assert!(Superblock::decode(&valid, 0).is_ok()); + + let mut field_corrupt = valid; + field_corrupt[56] ^= 1; + assert_eq!( + Superblock::decode(&field_corrupt, 0), + Err(FormatError::BadSuperblockCrc) + ); + + let mut crc_corrupt = valid; + crc_corrupt[168] ^= 1; + assert_eq!( + Superblock::decode(&crc_corrupt, 0), + Err(FormatError::BadSuperblockCrc) + ); + + for offset in 172..STORE_UNIT_BYTES { + let mut reserved = valid; + reserved[offset] = 1; + rechecksum_superblock(&mut reserved); + assert_eq!( + Superblock::decode(&reserved, 0), + Err(FormatError::NonzeroReserved), + "offset {offset}" + ); + } + + assert_eq!( + Superblock::decode(&valid, 1), + Err(FormatError::WrongSuperblockSlot) + ); + + for (offset, value) in [(48, 3u64), (56, 0), (160, 5)] { + let mut malformed = valid; + malformed[offset..offset + 8].copy_from_slice(&value.to_le_bytes()); + rechecksum_superblock(&mut malformed); + assert_eq!( + Superblock::decode(&malformed, 0), + Err(FormatError::MalformedSuperblock), + "offset {offset}" + ); + } + + let mut unsupported_features = valid; + unsupported_features[12] = 1; + rechecksum_superblock(&mut unsupported_features); + assert_eq!( + Superblock::decode(&unsupported_features, 0), + Err(FormatError::UnsupportedFeatures) + ); +} + +#[test] +fn commit_record_rejects_lengths_features_generation_and_high_water() { + let good = genesis(); + let encoded = good.encode().unwrap(); + assert_eq!(encoded.len(), COMMIT_RECORD_BYTES); + assert_eq!(CommitRecord::decode(&encoded).unwrap(), good); + + for bad_length in [COMMIT_RECORD_BYTES - 1, COMMIT_RECORD_BYTES + 1] { + let malformed = vec![0u8; bad_length]; + assert!(CommitRecord::decode(&malformed).is_err()); + } + + for (offset, value) in [ + (56, 0u64), + (64, 1), + (176, 15), + (184, 2), + (188, 1), + (192, 3), + (192, 5), + ] { + let mut malformed = encoded; + malformed[offset..offset + 8].copy_from_slice(&value.to_le_bytes()); + assert!( + CommitRecord::decode(&malformed).is_err(), + "offset {offset}, value {value}" + ); + } + + let mut oversized_region = encoded; + oversized_region[48..56].copy_from_slice(&4_294_967_297u64.to_le_bytes()); + assert!(CommitRecord::decode(&oversized_region).is_err()); + + let mut features = encoded; + features[16] = 1; + assert_eq!( + CommitRecord::decode(&features), + Err(FormatError::UnsupportedFeatures) + ); + + let commit_id = good.object_id().unwrap(); + let mut padded_commit = vec![0u8; STORE_UNIT_BYTES]; + padded_commit[..encoded.len()].copy_from_slice(&encoded); + assert!(commit_id + .validate_extent(2, 1, encoded.len() as u64, &padded_commit) + .is_ok()); + padded_commit[STORE_UNIT_BYTES - 1] = 1; + assert_eq!( + commit_id.validate_extent(2, 1, encoded.len() as u64, &padded_commit), + Err(FormatError::NonzeroReserved) + ); + + let mut malformed_genesis = good.clone(); + malformed_genesis.previous_generation = 1; + assert_eq!( + malformed_genesis.encode(), + Err(FormatError::InvalidGeneration) + ); +} + +#[test] +fn generation_link_requires_adjacent_generation_and_exact_predecessor_ids() { + let previous = genesis(); + let previous_id = previous.object_id().unwrap(); + let mut next = previous.clone(); + next.generation = 2; + next.previous_generation = 1; + next.previous_commit_id = previous_id; + next.previous_catalog_id = previous.catalog_id; + next.catalog_first_unit = 4; + next.committed_high_water = 6; + assert!(next.encode().is_ok()); + assert!(next.identifies_predecessor(&previous, previous_id)); + + next.previous_catalog_id.0[0] ^= 1; + assert!(!next.identifies_predecessor(&previous, previous_id)); + next.previous_catalog_id = previous.catalog_id; + next.previous_commit_id.0[0] ^= 1; + assert!(!next.identifies_predecessor(&previous, previous_id)); + next.previous_commit_id = previous_id; + next.previous_generation = 0; + assert_eq!(next.encode(), Err(FormatError::InvalidGeneration)); + + let mut overflow = next; + overflow.generation = u64::MAX; + overflow.previous_generation = u64::MAX - 1; + overflow.previous_commit_id = ObjectId([1; 32]); + overflow.previous_catalog_id = ObjectId([1; 32]); + assert!(overflow.encode().is_ok()); + overflow.generation = u64::MAX; + overflow.previous_generation = u64::MAX; + assert_eq!(overflow.encode(), Err(FormatError::InvalidGeneration)); +} + +#[test] +fn superblock_commit_validation_binds_commit_unit_catalog_and_high_water() { + let commit = genesis(); + let sb = superblock(0, &commit); + assert!(sb + .validate_commit(commit.object_id().unwrap(), &commit) + .is_ok()); + + let mut wrong_commit_unit = sb.clone(); + wrong_commit_unit.commit_record_unit = 2; + assert_eq!( + wrong_commit_unit.validate_commit(commit.object_id().unwrap(), &commit), + Err(FormatError::MalformedSuperblock) + ); + + let mut wrong_catalog = sb.clone(); + wrong_catalog.catalog_first_unit = 1; + assert_eq!( + wrong_catalog.validate_commit(commit.object_id().unwrap(), &commit), + Err(FormatError::MalformedSuperblock) + ); + + let mut wrong_high_water = sb; + wrong_high_water.committed_high_water = 3; + assert_eq!( + wrong_high_water.validate_commit(commit.object_id().unwrap(), &commit), + Err(FormatError::MalformedSuperblock) + ); +} diff --git a/docs/adr/0015-golden-vectors.json b/docs/adr/0015-golden-vectors.json new file mode 100644 index 00000000..5d941b28 --- /dev/null +++ b/docs/adr/0015-golden-vectors.json @@ -0,0 +1,109 @@ +{ + "schema": "AIENOS-STORE-V1-GOLDEN-VECTORS-1", + "source_contract": "ADR 0015, format layout tables", + "object_id": { + "kind_u16le": "3412", + "version_u16le": "7856", + "semantic_bytes_hex": "000102030405060708090a0b0c0d0e0f", + "preimage_hex": "4149454e4f532d53544f52452d4f424a4543542d563100341278561000000000000000000102030405060708090a0b0c0d0e0f", + "object_id_hex": "80b93b4e31915bf7a7fd4607e686e757924425d9a4f9c1e84f51672d1b9b1334", + "preimage_sha256": "80b93b4e31915bf7a7fd4607e686e757924425d9a4f9c1e84f51672d1b9b1334", + "semantic_sha256": "be45cb2605bf36bebde684841a28f0fd43c69850a3dce5fedba69928ee3a8991" + }, + "empty_catalog": { + "semantic_bytes_hex": "4149454e434154310100400000000000", + "object_id_hex": "44197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a", + "unit_hex": "4149454e434154310100400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "unit_sha256": "bb930f73e55884dc6131df1944c7cdd444bf45fa6df758a2d3773b84b1a57b0a", + "semantic_sha256": "c5c5d1f8ba6303216f491af96ae64f8bc2f75e018980c8a34c5537882a16c432" + }, + "one_entry_catalog": { + "entry_object_id_hex": "307663335463d5f838fdd1b60950a02c873a28cd6cea13c2ffbfa5d8e41145a6", + "entry_kind_u16le": "0300", + "entry_version_u16le": "0100", + "entry_first_unit_u64le": "0400000000000000", + "entry_byte_length_u64le": "1000000000000000", + "entry_unit_count_u32le": "01000000", + "entry_flags_u16le": "0000", + "entry_reserved_hex": "000000000000", + "semantic_bytes_hex": "4149454e434154310100400001000000307663335463d5f838fdd1b60950a02c873a28cd6cea13c2ffbfa5d8e41145a60300010004000000000000001000000000000000010000000000000000000000", + "object_id_hex": "15d05f57a32d04af08fc9ba5d88c2fd9fdf09ba9858cfa35b25bb6e66c1f7c85", + "unit_hex": "4149454e434154310100400001000000307663335463d5f838fdd1b60950a02c873a28cd6cea13c2ffbfa5d8e41145a603000100040000000000000010000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "unit_sha256": "22fd16777373ac734b268f5f9433722a61d6711f7cb52229048225cab0784583", + "semantic_sha256": "3b8b9ea39606ad6abba5f20db970872b20487663cfff69024a6cc01d7e951645" + }, + "crc32c": { + "check_input_ascii": "123456789", + "check_output_numeric": "0xe3069283", + "check_output_u32le": "839206e3", + "algorithm": "reflected Castagnoli polynomial 0x82f63b78, init/xorout 0xffffffff" + }, + "genesis": { + "store_uuid_hex": "000102030405060708090a0b0c0d0e0f", + "region_units_u64le": "1000000000000000", + "catalog_first_unit": 2, + "commit_record_unit_number": 3, + "unit_map": { + "0": "superblock A", + "1": "superblock B", + "2": "genesis catalog", + "3": "genesis CommitRecord" + }, + "catalog_semantic_hex": "4149454e434154310100400000000000", + "catalog_unit_hex": "4149454e434154310100400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "catalog_object_id_hex": "44197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a", + "commit_record_semantic_hex": "4149454e434d54310100c8000100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f1000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a0200000000000000100000000000000001000000000000000400000000000000", + "commit_record_object_id_hex": "655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d422", + "commit_record_unit_hex": "4149454e434d54310100c8000100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f1000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a02000000000000001000000000000000010000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "commit_record_unit_sha256": "d23bfa188198e0b285e12411ab8054183f67b2e67cbe03933a2444297a98dc4d", + "commit_record_crc_domain_preimage_hex": "4149454e4f532d53544f52452d4f424a4543542d56310002000100c8000000000000004149454e434d54310100c8000100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f1000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a0200000000000000100000000000000001000000000000000400000000000000", + "superblock_a_unit_hex": "4149454e535452310100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f0000000010000000000000000100000000000000655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d422030000000000000044197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a0200000000000000100000000000000001000000000000000400000000000000fc775a27000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "superblock_a_unit_sha256": "fd25f10310b662942275d0b72255a9f3a4e389b6e34d111465884a467e7ebdbc", + "superblock_a_crc_u32le": "fc775a27", + "superblock_b_unit_hex": "4149454e535452310100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f0100000010000000000000000100000000000000655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d422030000000000000044197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a020000000000000010000000000000000100000000000000040000000000000098353ee3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "superblock_b_unit_sha256": "e75a62a7a81ac318487ad1def438933430df9c199a1e5ef8942ef599731018e7", + "superblock_b_crc_u32le": "98353ee3", + "expected_root_classification": "redundant valid copies; equivalent logical roots" + }, + "adjacent_generations": { + "generation_1_commit_record_object_id_hex": "655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d422", + "generation_1_catalog_object_id_hex": "44197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a", + "generation_1_committed_high_water": 4, + "unit_map": { + "0": "generation 2 superblock A", + "1": "generation 1 superblock B", + "2": "generation 1 catalog", + "3": "generation 1 CommitRecord", + "4": "generation 2 application object", + "5": "generation 2 catalog", + "6": "generation 2 CommitRecord" + }, + "application_object_semantic_hex": "000102030405060708090a0b0c0d0e0f", + "application_object_id_hex": "307663335463d5f838fdd1b60950a02c873a28cd6cea13c2ffbfa5d8e41145a6", + "application_object_unit_hex": "000102030405060708090a0b0c0d0e0f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "application_object_unit_sha256": "c5a7bf537a1c5d4a65eb9894586cb709563765e1e74fdfa16be912896162d1b3", + "generation_2_catalog_semantic_hex": "4149454e434154310100400001000000307663335463d5f838fdd1b60950a02c873a28cd6cea13c2ffbfa5d8e41145a60300010004000000000000001000000000000000010000000000000000000000", + "generation_2_catalog_object_id_hex": "15d05f57a32d04af08fc9ba5d88c2fd9fdf09ba9858cfa35b25bb6e66c1f7c85", + "generation_2_catalog_unit_hex": "4149454e434154310100400001000000307663335463d5f838fdd1b60950a02c873a28cd6cea13c2ffbfa5d8e41145a603000100040000000000000010000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "generation_2_catalog_unit_sha256": "22fd16777373ac734b268f5f9433722a61d6711f7cb52229048225cab0784583", + "generation_2_commit_record_semantic_hex": "4149454e434d54310100c8000100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f100000000000000002000000000000000100000000000000655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d42244197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a15d05f57a32d04af08fc9ba5d88c2fd9fdf09ba9858cfa35b25bb6e66c1f7c850500000000000000500000000000000001000000010000000700000000000000", + "generation_2_commit_record_object_id_hex": "7787f3c9a29560e67987c4c83dd2b49ab402ee27975432a0f43fdf50749d11c1", + "generation_2_commit_record_unit_hex": "4149454e434d54310100c8000100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f100000000000000002000000000000000100000000000000655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d42244197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a15d05f57a32d04af08fc9ba5d88c2fd9fdf09ba9858cfa35b25bb6e66c1f7c8505000000000000005000000000000000010000000100000007000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "generation_2_commit_record_unit_sha256": "18dd6334b46755605ba8156e10c3f5e9ddf5169c9094afb984fa06f91b512e2c", + "generation_2_commit_record_preimage_hex": "4149454e4f532d53544f52452d4f424a4543542d56310002000100c8000000000000004149454e434d54310100c8000100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f100000000000000002000000000000000100000000000000655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d42244197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a15d05f57a32d04af08fc9ba5d88c2fd9fdf09ba9858cfa35b25bb6e66c1f7c850500000000000000500000000000000001000000010000000700000000000000", + "generation_2_superblock_a_unit_hex": "4149454e535452310100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f00000000100000000000000002000000000000007787f3c9a29560e67987c4c83dd2b49ab402ee27975432a0f43fdf50749d11c1060000000000000015d05f57a32d04af08fc9ba5d88c2fd9fdf09ba9858cfa35b25bb6e66c1f7c8505000000000000005000000000000000010000000100000007000000000000002a9dcb0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "generation_2_superblock_a_unit_sha256": "47c84fb7394d4fb5b52d1b600fe67c4f3f07d41ed98ffadde2afa15b4dc9ddcc", + "generation_2_superblock_a_crc_u32le": "2a9dcb0e", + "generation_2_committed_high_water": 7, + "expected_root_classification": "normal adjacent history; generation 2 follows generation 1 exactly" + }, + "equivalent_roots": { + "superblock_a_unit_hex": "4149454e535452310100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f0000000010000000000000000100000000000000655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d422030000000000000044197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a0200000000000000100000000000000001000000000000000400000000000000fc775a27000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "superblock_a_unit_sha256": "fd25f10310b662942275d0b72255a9f3a4e389b6e34d111465884a467e7ebdbc", + "superblock_b_unit_hex": "4149454e535452310100000000000000000000000000000000000000000102030405060708090a0b0c0d0e0f0100000010000000000000000100000000000000655010d6bc51309dc8f00d44ea167f65e074cb065881d33eec3af6eda4c2d422030000000000000044197839cf88e93c480d77a0c234ce21362a038d33d398ead10e062906d7be6a020000000000000010000000000000000100000000000000040000000000000098353ee3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "superblock_b_unit_sha256": "e75a62a7a81ac318487ad1def438933430df9c199a1e5ef8942ef599731018e7", + "superblock_a_crc_u32le": "fc775a27", + "superblock_b_crc_u32le": "98353ee3", + "expected_root_classification": "same generation and equivalent logical root; redundant valid copies" + } +} diff --git a/docs/adr/0015-golden-vectors.md b/docs/adr/0015-golden-vectors.md new file mode 100644 index 00000000..24c8865f --- /dev/null +++ b/docs/adr/0015-golden-vectors.md @@ -0,0 +1,25 @@ +# ADR 0015 canonical golden vectors + +`0015-golden-vectors.json` contains the byte-exact inputs and outputs for +ObjectId, empty and one-entry catalogs, CommitRecord objects, Superblock A/B, +CRC32C, genesis, adjacent generations, and equivalent roots. Unit fixtures are +full 4096-byte hex strings; each includes a SHA-256 digest. CommitRecord +semantic bytes, ObjectIds, catalog semantic bytes, CRC fields, fixed resource +geometry, and expected root classifications are also recorded. + +The fixtures use a deterministic UUID (`00 01 ... 0f`) so bytes are +reproducible. A real provisioner MUST still create a fresh random 128-bit Store +UUID. + +Run the standard-library-only independent encoder/verifier from the repository +root: + +```sh +python3 scripts/check_store_v1_vectors.py +``` + +The verifier rebuilds each encoding, checks all padded unit bytes and +SHA-256/CRC32C values against the checked-in manifest, and checks the genesis, +adjacent-generation, and equivalent-root relations. The exact fixtures are the +interoperability oracle; the Python code is a second implementation of the +format and is not production Store code. diff --git a/docs/adr/0015-system-store-v1-format.md b/docs/adr/0015-system-store-v1-format.md new file mode 100644 index 00000000..1f3ddd4e --- /dev/null +++ b/docs/adr/0015-system-store-v1-format.md @@ -0,0 +1,162 @@ +# ADR 0015: AIENOS System Store v1 Format + +Status: Accepted for P3-1 format freeze +Date: 2026-09-25 +Scope: Permanent System Store v1 bytes, canonical encodings, and format-level validation. +Out of scope: Native NVMe drivers, QEMU power-cut orchestration, Cortex persistence, Agent State integration, TRUST-1, Machine 1 storage, GB10, general evidence infrastructure, and complete transaction or mount implementation. + +## Decision + +System Store v1 MUST use the byte layouts and rules in this ADR. Implementations MUST NOT serialize native structure layouts, host endianness, implicit padding, or implementation defaults. Every multibyte integer is unsigned little-endian. Every reserved byte is zero when written and MUST be zero when read. + +The permanent Store unit is exactly 4096 bytes. The only supported physical logical-block sizes are 512 and 4096 bytes. Implementations MUST NOT use read-modify-write to emulate a Store unit. The required layering is: + +`BlockDevice → provisioning → BoundedBlockDevice → StoreDevice → Store` + +The bounded region is expressed in 4096-byte Store units, with unit 0 = Superblock A, unit 1 = Superblock B, and units 2 onward = append arena. `open()` MUST NOT write, repair, or autoformat. It MUST distinguish `Unformatted`, `ForeignOrUnknown`, `UnsupportedVersion`, `Corrupt/RecoveryRequired`, and a valid Store. A block-device read error MUST be reported as `MountError::Io`, never as corrupt media. + +## 1. Canonical constants and object identity + +The following v1 limits are mandatory: + +| Name | Value | +|---|---:| +| `STORE_UNIT_BYTES` | 4096 | +| `MAX_CATALOG_ENTRIES` | 4096 | +| `CATALOG_ENTRY_BYTES` | 64 | +| `MAX_OBJECT_BYTES` | 67,108,864 | +| `MAX_OBJECT_UNITS` | 16,384 | +| `MAX_TRANSACTION_OBJECTS` | 256 | +| `MAX_TRANSACTION_UNITS` | 32,768 | +| `MAX_REGION_UNITS` | 4,294,967,296 | + +The catalog limit is an entry count. A full 4096-entry catalog is 262,160 semantic bytes (16 + 4096 × 64), occupying 65 Store units after final-unit padding. The numeric kind reservations, nonzero kind/version rule, format version 1.0, zero feature masks, and magic values below are explicit v1 format-owner decisions. + +An ObjectId is exactly 32 bytes: + +```text +SHA256( + ASCII("AIENOS-STORE-OBJECT-V1\0") + || kind:u16le || version:u16le || byte_length:u64le + || semantic_bytes[byte_length] +) +``` + +The domain contains exactly one terminal NUL. `kind` and `version` MUST be nonzero. Kind 1 is reserved for Catalog, kind 2 for CommitRecord, and kinds 3 through 65535 are application object kinds. Catalog and CommitRecord object version is 1. Zero-length objects are invalid. Physical location, unit count, Store UUID, generation, catalog membership, and final physical padding are excluded from ObjectId. Object bytes occupy one contiguous run of `ceil(byte_length / 4096)` units. Bytes `[byte_length, unit_count × 4096)` MUST be zero and are not semantic bytes. A descriptor MUST report that exact unit count, remain wholly in the append arena and within the bounded region and committed high-water, and not overlap another object extent. Each ObjectId MUST be recalculated as SHA-256 of the domain, descriptor kind/version/byte_length in the specified encodings, and exactly `byte_length` semantic bytes. An existing ObjectId MAY be deduplicated only after independently validating its descriptor, semantic bytes, ObjectId, and final padding. + +## 2. Catalog bytes + +A Catalog is an ordinary kind-1, version-1 object. Its semantic bytes have exactly this header and entry sequence; the catalog object's own final unit padding follows its semantic bytes and is zero. + +### Header (16 bytes) + +| Offset | Size | Field | Required value/encoding | +|---:|---:|---|---| +| 0 | 8 | magic | ASCII `AIENCAT1` | +| 8 | 2 | format_version | u16 LE = 1 | +| 10 | 2 | entry_size | u16 LE = 64 | +| 12 | 4 | entry_count | u32 LE, 0 through 4096 | + +The semantic length MUST equal `16 + entry_count × 64`, with checked arithmetic. There are no trailing bytes. + +### CatalogEntry (64 bytes) + +| Offset | Size | Field | Required value/encoding | +|---:|---:|---|---| +| 0 | 32 | ObjectId | raw digest bytes | +| 32 | 2 | kind | u16 LE; at least 3 | +| 34 | 2 | version | u16 LE; nonzero | +| 36 | 8 | first_unit | u64 LE; region-relative | +| 44 | 8 | byte_length | u64 LE; 1 through `MAX_OBJECT_BYTES` | +| 52 | 4 | unit_count | u32 LE; exactly `ceil(byte_length / 4096)`, at most `MAX_OBJECT_UNITS` | +| 56 | 2 | flags | u16 LE = 0 | +| 58 | 6 | reserved | all zero | + +Entries MUST be in strictly increasing lexicographic order by the 32 ObjectId bytes. Duplicate IDs are invalid. Each application extent MUST start at unit 2 or later, end at or before `catalog_first_unit`, and not overlap any other application extent. The Catalog extent MUST start at or after unit 2, have `ceil((16 + entry_count × 64) / 4096)` units, and end exactly at `commit_record_unit`. The one-unit CommitRecord extent MUST follow the Catalog and end at exclusive committed high-water. These extents MUST lie within `[2, region_units)`, and no object padding extent may overlap another object or metadata extent. The catalog lists application objects only; Catalog and CommitRecord objects are referenced by CommitRecord/Superblock fields and are not catalog entries. A new commit writes a new immutable full catalog. Store v1 MUST NOT delete, replace, relocate, or repair an existing application object or catalog entry. + +## 3. CommitRecord bytes and generations + +A CommitRecord is an ordinary kind-2, version-1 object. Its semantic bytes are exactly 200 bytes, followed by zero padding to the end of its single 4096-byte Store unit. Its complete field layout is: + +| Offset | Size | Field | Required value/encoding | +|---:|---:|---|---| +| 0 | 8 | magic | ASCII `AIENCMT1` | +| 8 | 2 | record_version | u16 LE = 1 | +| 10 | 2 | record_size | u16 LE = 200 | +| 12 | 2 | format_major | u16 LE = 1 | +| 14 | 2 | format_minor | u16 LE = 0 | +| 16 | 8 | required_features | u64 LE = 0 in v1 | +| 24 | 8 | compatible_features | u64 LE = 0 in v1 | +| 32 | 16 | store_uuid | provisioned random 128-bit identity | +| 48 | 8 | region_units | u64 LE, 4 through `MAX_REGION_UNITS` | +| 56 | 8 | generation | u64 LE, nonzero | +| 64 | 8 | previous_generation | u64 LE | +| 72 | 32 | previous_commit_id | ObjectId bytes | +| 104 | 32 | previous_catalog_id | ObjectId bytes | +| 136 | 32 | catalog_id | ObjectId bytes | +| 168 | 8 | catalog_first_unit | u64 LE | +| 176 | 8 | catalog_byte_length | u64 LE | +| 184 | 4 | catalog_unit_count | u32 LE | +| 188 | 4 | catalog_entry_count | u32 LE | +| 192 | 8 | committed_high_water | u64 LE, exclusive | + +The CommitRecord ObjectId is computed with the ObjectId formula over exactly these 200 semantic bytes. No other fields or trailing semantic bytes are permitted. The CommitRecord binds the format and features, Store UUID, region geometry, current generation, predecessor generation/CommitRecord/catalog, current catalog identity and descriptor, and committed high-water. + +Genesis has generation 1, previous_generation 0, all-zero previous CommitRecord and previous catalog IDs, a real empty-or-populated Catalog object, and a real CommitRecord object. A non-genesis generation MUST equal its predecessor generation + 1 using checked arithmetic, and its previous CommitRecord and catalog IDs MUST equal that predecessor's identities. One Store history MUST retain the same Store UUID and region geometry in every generation. A transaction's CommitRecord is at `commit_first_unit`; its committed high-water MUST equal `commit_first_unit + 1`. Region units name `[0, region_units)`; the minimum region is 4 units. + +Transaction append order is new application objects, complete new catalog, then one-unit CommitRecord. For a non-genesis generation, newly appended objects MUST form one contiguous run beginning at the predecessor's committed high-water; the Catalog MUST immediately follow that run (or begin at the predecessor high-water if there are no newly written objects). There MUST be no holes or backfill. Before the first persistent write, all size, count, arithmetic, transaction, and bounded-region capacity limits MUST be checked. A preflight failure MUST produce zero persistent writes. The write sequence is payload objects, catalog, CommitRecord, flush, inactive superblock, flush. The second flush is the commit point. The active superblock MUST NOT be rewritten as part of a transaction. Committed high-water is exclusive; after recovery an uncommitted tail beyond it may be reused, which is not general garbage collection. + +## 4. Superblock bytes and CRC32C + +Each superblock occupies exactly one 4096-byte Store unit. Bytes 172 through 4095 MUST be zero. The fields before the CRC are: + +| Offset | Size | Field | Required value/encoding | +|---:|---:|---|---| +| 0 | 8 | magic | ASCII `AIENSTR1` | +| 8 | 2 | format_major | u16 LE = 1 | +| 10 | 2 | format_minor | u16 LE = 0 | +| 12 | 8 | required_features | u64 LE = 0 | +| 20 | 8 | compatible_features | u64 LE = 0 | +| 28 | 16 | store_uuid | same as CommitRecord | +| 44 | 4 | slot_id | u32 LE: 0 for A, 1 for B | +| 48 | 8 | region_units | u64 LE, 4 through `MAX_REGION_UNITS` | +| 56 | 8 | generation | u64 LE, nonzero | +| 64 | 32 | commit_record_id | ObjectId bytes | +| 96 | 8 | commit_record_unit | u64 LE | +| 104 | 32 | catalog_id | ObjectId bytes | +| 136 | 8 | catalog_first_unit | u64 LE | +| 144 | 8 | catalog_byte_length | u64 LE | +| 152 | 4 | catalog_unit_count | u32 LE | +| 156 | 4 | catalog_entry_count | u32 LE | +| 160 | 8 | committed_high_water | u64 LE, exclusive | +| 168 | 4 | crc32c | CRC-32C/Castagnoli | +| 172 | 3924 | reserved | all zero | + +CRC-32C is the reflected Castagnoli algorithm (reflected polynomial `0x82f63b78`), init `0xffffffff`, xorout `0xffffffff`. To calculate the checksum, process all 4096 bytes with bytes 168 through 171 treated as zero. A reader MUST verify the CRC before trusting other superblock fields. The CRC establishes physical superblock credibility; SHA-256 establishes logical object integrity; the flushed superblock establishes commit authority. + +The CRC-valid superblock's generation, Store UUID, region, CommitRecord ID/unit, catalog ID/descriptor, and high-water MUST exactly agree with its validated CommitRecord. In particular, `committed_high_water == commit_record_unit + 1`. The CommitRecord's catalog descriptor MUST agree with the decoded Catalog's ObjectId, semantic byte length (`16 + entry_count × 64`), unit count, and entry count. Superblock A and B that reference the same logical root differ only in `slot_id` and consequently CRC. A and B represent equivalent logical roots exactly when the Store UUID, format/features, generation, and CommitRecord ObjectId match; slot and physical CommitRecord unit are excluded. All other copies of root fields are checked against the CommitRecord before this equivalence comparison. + +## 5. Format and root validation + +Validation MUST follow this trust chain and MUST validate every referenced object before accepting a root: + +`Bounded Region → Superblock CRC32C → SHA-256 CommitRecord → SHA-256 Catalog → sorted descriptors → SHA-256 Objects → Generation` + +The Superblock's CommitRecord reference MUST identify one full Store unit; the semantic CommitRecord bytes MUST hash to its ObjectId and its remainder MUST be zero. Its catalog reference MUST identify `catalog_unit_count` contiguous units whose semantic length and ObjectId match the CommitRecord; catalog padding MUST be zero. Every catalog descriptor MUST satisfy its exact length/unit formula, bounds, non-overlap, zero-padded physical representation, and ObjectId. Metadata that points to any corrupt object is not a valid root. CRC-valid metadata alone never constitutes a valid root. + +The two superblock units MUST both be read. Any actual read error while reading either root or any referenced object returns `MountError::Io`. Classification is deterministic: + +1. If both superblock units are all zero, classify `Unformatted`. +2. If neither has `AIENSTR1` magic and at least one is nonzero, classify `ForeignOrUnknown`. +3. A CRC-valid `AIENSTR1` superblock whose major/minor or feature values are unsupported classifies `UnsupportedVersion`; do not fall back to another root. +4. Otherwise, invalid CRC, reserved bytes, malformed fields, or a graph-invalid root is `Corrupt/RecoveryRequired`, except for the specific degraded case below. +5. If both roots validate and have the same generation, equivalent roots are redundant valid copies; non-equivalent roots are `ConflictingRoots`. +6. If both roots validate and generations differ by exactly one, they MUST have the same Store UUID and region geometry. The newer root is normal only when its predecessor generation, CommitRecord ID, and catalog ID identify the older root exactly. Otherwise classify `InconsistentHistory`. +7. If both roots validate but are not adjacent, classify `InconsistentHistory`. +8. If one root is completely valid and the other is all zero, the valid root is a valid Store. If both superblocks are CRC-valid and supported, and one is completely valid while the strictly newer root has a graph error, the valid older root MUST be exposed read-only as `DegradedRecovery`. If a newer root is completely valid while the older root has a graph error, select the newer valid root as a valid Store. A graph-invalid root at the same generation as the valid root, an invalid-CRC root whose generation cannot be trusted, a nonzero wrong-magic unit, or a valid Store paired with unsupported-version metadata classifies `Corrupt/RecoveryRequired` or `UnsupportedVersion` as specified above; do not silently fall back based only on readability. + +When both roots validate, the older/newer comparison uses generation without wrapping; overflow is invalid. A valid graph with a generation relationship error is history-inconsistent, not object-corrupt. Store v1 provides crash/corruption recovery and MUST NOT claim malicious full-device anti-rollback protection; trusted anti-rollback belongs to M5. + +## 6. Canonical vectors + +The repository's checked-in canonical vectors MUST include byte-exact ObjectId, empty and one-entry Catalog, CommitRecord, Superblock A/B, CRC32C, genesis, adjacent-generation, and equivalent-root examples. Negative vectors MUST exercise reserved bytes, lengths, counts, ordering, duplicates, bounds, CRC, ObjectIds, generation relationships, and high-water marks. Vectors are normative examples of the encodings above; parsers MUST reject malformed bytes rather than normalizing them. diff --git a/docs/adr/README.md b/docs/adr/README.md index 603fbce7..2be8fb04 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -20,6 +20,7 @@ This directory documents the key architectural decisions and formal technical sp | [ADR 0012](0012-self-construction-capability-growth-and-generations.md) | Self-Construction, Capability Growth, and Reversible System Generations | Accepted | 2026-09-24 | [ADR 0002](0002-incumbent-os-as-migration-environment.md); [ADR 0006](0006-deterministic-recovery-core-and-offline-operator-authority.md); [ADR 0007](0007-continuous-existence-provisioning-once.md); [`ROADMAP.md`](../../ROADMAP.md) (SEED-0A, SEED-0B) | | [ADR 0013](0013-aienos-abi-v1.md) | AIENOS ABI v1 | Proposed | 2026-09-24 | [ADR 0012](0012-self-construction-capability-growth-and-generations.md); [ADR 0004](0004-reversibility-definition-and-network-effect-boundary.md); [issue #30](https://github.com/aien-dev/aienos/issues/30); [PR #106](https://github.com/aien-dev/aienos/pull/106); [`abi.rs`](../../crates/aienos-kernel/src/abi.rs) | | [ADR 0014](0014-binary-artifact-v0-and-native-admission.md) | Binary Artifact v0 and Native Admission | Proposed | 2026-09-25 | [ADR 0012](0012-self-construction-capability-growth-and-generations.md); [ADR 0013](0013-aienos-abi-v1.md); SEED-0B qualification | +| [ADR 0015](0015-system-store-v1-format.md) | AIENOS System Store v1 Format | Accepted for P3-1 format freeze | 2026-09-25 | [ADR 0003](0003-bootstrap-firmware-handoff-and-minimal-object-store.md); P3 Native Persistence & Continuity | --- diff --git a/scripts/check_store_v1_vectors.py b/scripts/check_store_v1_vectors.py new file mode 100644 index 00000000..c4d56b5d --- /dev/null +++ b/scripts/check_store_v1_vectors.py @@ -0,0 +1,252 @@ +import hashlib, json, struct +from pathlib import Path + +UNIT = 4096 +UUID = bytes(range(16)) + + +def oid(kind, version, semantic): + preimage = b"AIENOS-STORE-OBJECT-V1\0" + struct.pack("> 1) ^ (0x82f63b78 if crc & 1 else 0) + return crc ^ 0xffffffff + + +def catalog(entries): + out = bytearray(b"AIENCAT1" + struct.pack("