Replay explanations through shared history selections

This commit is contained in:
2026-10-26 17:01:32 +00:00
parent 4b4e15fc58
commit 738c8a9cc7
12 changed files with 386 additions and 135 deletions

View File

@@ -40,6 +40,8 @@ func TestHistorySourceObservationsPreserveRawAndCompositeDefinitions(t *testing.
builder := newHistoryBuilder()
builder.observeBaseline(baseline)
builder.observeSourceEvidence(assembly.current.root, assembly.current.origins, assembly.current.applications, assembly.current.overlays)
builder.model.final = assembly.current.root
builder.registerDocumentRoot(assembly.current.root)
model := builder.freeze()
defaultPath := Keys("defaults", "nullable")
@@ -87,6 +89,30 @@ func TestHistorySourceObservationsPreserveRawAndCompositeDefinitions(t *testing.
if emptySummary == nil || len(emptySummary.contributions) != 2 || emptySummary.contributions[0].id != 0 || emptySummary.contributions[1].id != 1 {
t.Fatalf("empty mapping summary contribution references = %#v", emptySummary)
}
metadata := Metadata{historyModel: model}
metadataHistory := metadata.History(Keys("section", "empty"))
var compositeSources []string
for _, change := range metadataHistory {
if len(change.Origin.Locations) > 1 {
compositeSources = locationSourceIDs(change.Origin.Locations)
}
}
inspection := &Inspection{
metadata: metadata, baseline: baseline, final: assembly.current.root,
immutableLookup: buildDocumentLookup(assembly.current.root),
}
explanation, explained := inspection.Explain(Keys("section", "empty"))
var contributionSources []string
for _, change := range explanation.History {
if change.Origin.Layer == LayerBase || change.Origin.Layer == LayerOverlay {
contributionSources = append(contributionSources, locationSourceIDs(change.Origin.Locations)...)
}
}
if !explained || !reflect.DeepEqual(compositeSources, []string{"base", "overlay"}) ||
!reflect.DeepEqual(contributionSources, []string{"base", "overlay"}) {
t.Fatalf("metadata composite attribution and explanation contributions differ: metadata %#v, explanation %#v", metadataHistory, explanation.History)
}
}
func TestHistorySourceReplacementTracksConcreteBeforeAndAfterShapes(t *testing.T) {