Concepts

Explain parent activity from child evidence.

Hierarchy comparison shows which child windows explain a parent roll-up, where parent duration is unexplained, and where child activity is orphaned.

Problem

A parent window says what happened, not why.

A roll-up can correctly say that a region was impacted, but an operator still needs to know which child windows explain that parent range. Without hierarchy explanation, the audit trail often becomes a manual search through device, zone, and region histories.

The hard cases are the ones that look valid at a glance: parent duration that has no child contributor, child activity that did not roll up, or parent and child windows that overlap only partly.

Solution

Compare parent windows against child contribution windows.

Hierarchy comparison matches parent and child windows by source and partition, then emits explanation rows. The parent and child keys may differ because a roll-up usually aggregates several child keys into one parent key.

var hierarchy = pipeline.History.CompareHierarchy(
    "Region explanation",
    parentWindowName: "RegionImpacted",
    childWindowName: "DeviceOffline");

var unexplained = hierarchy.Rows
    .Where(row => row.Kind == HierarchyComparisonRowKind.UnexplainedParent)
    .ToArray();

var orphanedChildren = hierarchy.Rows
    .Where(row => row.Kind == HierarchyComparisonRowKind.OrphanChild)
    .ToArray();

Row meaning

Every row answers one explanation question.

Read hierarchy output as an evidence ledger. Explained rows connect the parent range to child contribution. Unexplained rows are parent duration without child evidence. Orphaned rows are child duration that did not produce the expected parent state.

Explained parent

The parent was active and at least one child contribution overlaps the same source and partition scope.

Unexplained parent

The parent was active, but Spanfold could not find matching child contribution for that range. Treat this as a roll-up integrity question.

Orphaned child

A child was active where no matching parent window exists. This can reveal missing roll-up input, wrong parent keys, or segment projection mistakes.

Partial explanation

Only part of the parent range is explained by children. Drill into the row ranges to find the exact start and stop boundaries.

How to use it

Run it after roll-up changes and before trusting parent metrics.

Hierarchy explanation is most valuable during model design, migration, and incident review. It tells you whether the parent view is a faithful summary of the child evidence or a separate story that only looks similar.

A clean hierarchy result does not mean the business rule is correct. It means the recorded parent windows are explainable from the child windows that Spanfold observed. That makes rule mistakes easier to inspect because the temporal evidence is already connected.