Skip to main content

compose_with_provenance

Function compose_with_provenance 

Source
pub fn compose_with_provenance(
    base: &[EntryOptions],
    base_label: &str,
    layers: &[DumpLayer<'_>],
    warn: impl FnMut(&str),
) -> (Vec<EntryOptions>, Vec<Provenance>)
Expand description

Compose layers exactly as compose_layers does (single flatten over base) while tracking, per row, which layer contributed it and which layers changed it.

Provenance uses upstream’s prefix-snapshot diff: snapshot k applies layers 1..k over the same base, and a row is compared positionally against the previous snapshot — the patch algorithm only rewrites rows in place or appends, so a top-level index identifies one row across snapshots, and a layer whose addition changed the row (config replacement, disable, group insert) is listed as having patched it. Appended rows carry the appending layer as their origin.

Skipped-patch warnings are attributed to layers the same way: earlier layers’ patches see an identical preceding state in every snapshot that includes them, so each snapshot’s warning list extends the previous one and the new tail belongs to the added layer. warn receives each tail line prefixed with [label].

Patches are never mutated (application clones into the result), so the same layer slices are safely reused across snapshots.