astrid-runtime/astrid · critical
encoded evidence delta did not reconstruct its target
Error message
encoded evidence delta did not reconstruct its target
What it means
After encoding a delta (Copy/Add operations) between two versions, `delta_size` self-verifies by applying the encoded delta to the base materialization. If the reconstructed bytes differ from the target's materialization, the delta evidence is wrong (bad chunk map, offset corruption, or encoder bug) and the measurement aborts rather than reporting an incorrect delta size.
Source
Thrown at crates/astrid-storage-chunker-evidence/src/sketch.rs:606
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<()> {
if let Some(DeltaOperation::Copy {
offset: previous_offset,
length: previous_length,
}) = operations.last_mut()
&& previous_offset.checked_add(*previous_length) == Some(offset)
{
*previous_length = checked_add(*previous_length, length, "copy extent length")?;
return Ok(());
}
operations.push(DeltaOperation::Copy { offset, length });
Ok(())
}
View on GitHub (pinned to affd8760f4)
Solutions
- Re-chunk/rebuild both versions' descriptors so chunk offsets and lengths match their actual byte layout, then re-measure.
- Check for concurrent access: ensure records are not mutated while delta_size runs (snapshot or lock the store).
- Validate each chunk's offset+length fits within logical_bytes before encoding.
- If a custom operation producer was added to delta_size, test its operations against apply_delta in isolation.
Defensive patterns
Strategy: try-catch
Validate before calling
fn descriptors_consistent(version: &Version) -> bool {
version.chunks.iter().all(|c| {
c.offset.saturating_add(c.length) <= version.logical_bytes
})
} Try / catch
let size = match delta_size(&base, &target) {
Ok(size) => size,
Err(e) if e.to_string().contains("did not reconstruct its target") => {
log::warn!("delta round-trip failed; falling back to full add-size estimate");
target.materialize()?.len() as u64
},
Err(e) => return Err(e),
}; Prevention
- Snapshot records (no concurrent mutation) for the duration of delta measurement.
- Validate chunk offset+length against logical_bytes before measuring.
- Rebuild descriptors after any store rewrite instead of reusing cached chunk lists.
When it happens
Trigger: Calling `measure_target` where the delta produced by `delta_size` fails its round-trip check: `apply_delta(base.materialize(), encode_delta(...))` yields bytes != target.materialize(). Happens when chunk offsets/lengths in either version's chunk list are wrong, or records were mutated between encode and apply.
Common situations: Corrupted chunk descriptors with stale offsets after a store was rewritten; concurrent mutation of records during measurement; a bug in custom delta operation generation.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- unexpected {kind:?} in a canonical File owning closure
- equal chunk identities named different bytes in delta eviden
- unknown delta operation
- delta output length differs from its header
- delta magic mismatch
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/87c6b1c87f7efb80.
Report an issue: GitHub.