astrid-runtime/astrid · critical
equal chunk identities named different bytes in delta eviden
Error message
equal chunk identities named different bytes in delta evidence
What it means
When measuring delta size between a base and target version, `delta_size` assumes chunk identity (ObjectId) implies identical canonical bytes — content addressing should guarantee this. If a target chunk shares its ID with a base chunk but `canonical_bytes()` differ, the content-addressing invariant is broken and emitting a Copy operation would silently produce wrong data, so the function bails.
Source
Thrown at crates/astrid-storage-chunker-evidence/src/sketch.rs:593
(None, None) => break,
}
sampled = sampled.saturating_add(1);
}
(shared, sampled)
}
fn delta_size(base: &Version, target: &Version) -> Result<u64> {
let mut by_id = BTreeMap::new();
for chunk in &base.chunks {
by_id.entry(chunk.id).or_insert(*chunk);
}
let mut operations = Vec::new();
for target_chunk in &target.chunks {
if let Some(base_chunk) = by_id.get(&target_chunk.id) {
if base.record(base_chunk.id)?.canonical_bytes()
!= target.record(target_chunk.id)?.canonical_bytes()
{
bail!("equal chunk identities named different bytes in delta evidence");
}
push_copy(&mut operations, base_chunk.offset, base_chunk.length)?;
} else {
push_add(
&mut operations,
target.record(target_chunk.id)?.canonical_bytes(),
)?;
}
}
let encoded = encode_delta(base.file, target.file, target.logical_bytes, &operations)?;
let reconstructed = apply_delta(&base.materialize()?, &encoded)?;
if reconstructed != target.materialize()? {
bail!("encoded evidence delta did not reconstruct its target");
}
Ok(u64::try_from(encoded.len())?)
}
fn push_copy(operations: &mut Vec<DeltaOperation>, offset: u64, length: u64) -> Result<()> {View on GitHub (pinned to affd8760f4)
Solutions
- Verify object IDs are true content hashes (recompute the hash of canonical_bytes for the mismatched chunk and re-key the record).
- Rebuild the evidence store / re-chunk the affected files so each chunk ID maps to exactly one byte sequence.
- Check that base and target records were loaded from the same store with the same serialization configuration.
- If intentional dedup-by-ID must be relaxed, compare bytes before emitting Copy and emit Add for mismatches instead of bailing.
Defensive patterns
Strategy: validation
Validate before calling
fn verify_chunk_identity(record: &ObjectRecord, id: ObjectId) -> Result<()> {
let bytes = record.canonical_bytes();
let recomputed = hash_content(bytes);
if recomputed != id {
bail!("chunk id {id:?} does not hash its content ({recomputed:?})");
}
Ok(())
} Type guard
fn chunk_ids_match_bytes(base: &ObjectRecord, target: &ObjectRecord) -> bool {
base.canonical_bytes() == target.canonical_bytes()
} Try / catch
match delta_size(&base, &target) {
Err(e) if e.to_string().contains("named different bytes") => {
eprintln!("content-addressing violated: re-hash and re-key the store");
},
r => r?,
} Prevention
- Always derive object IDs from a hash of canonical_bytes; never hand-assign IDs.
- Periodically re-hash stored chunks to detect ID/content divergence.
- Avoid merging evidence stores written with different hashing configurations.
When it happens
Trigger: Calling `measure_target`/`delta_size` where a target file contains a chunk whose ObjectId exists in the base version's chunk map, but the two records' canonical_bytes() differ — caused by hash collisions, mis-keyed records, or a store where object IDs were reused for different content.
Common situations: Corrupted or hand-assembled object stores; hashing configuration changes (same ID scheme, different byte serialization); evidence stores merged from differently-configured writers.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- unexpected {kind:?} in a canonical File owning closure
- durable capsule {id} WASM hash differs between metadata and
- signed Distro.toml does not match Distro.lock manifest_hash;
- encoded evidence delta did not reconstruct its target
- durable capsule {id} disappeared after publish
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/3f98651cd92eba64.
Report an issue: GitHub.