Index inheritance history lookups

This commit is contained in:
2026-10-09 03:52:07 +00:00
parent 5fedc11c8f
commit 344f4f73d7
5 changed files with 115 additions and 11 deletions

View File

@@ -9,11 +9,12 @@ import (
// Metadata provides detached effective presence/origin and chronological history
// queries for a load. Its zero value contains no paths.
type Metadata struct {
effectivePaths map[string]Path
historicalPaths map[string][]Path
fields map[string]FieldInfo
history map[string][]Change
inheritance []inheritanceOperation
effectivePaths map[string]Path
historicalPaths map[string][]Path
fields map[string]FieldInfo
history map[string][]Change
inheritance []inheritanceOperation
inheritanceIndex *inheritanceHistoryIndex
}
// Lookup returns information for an effective path. Unknown and invalid paths
@@ -57,7 +58,11 @@ func (m Metadata) History(path Path) []Change {
return nil
}
history := m.history[path.String()]
return historyWithInheritance(path, history, m.inheritance)
operations := m.inheritance
if m.inheritanceIndex != nil {
operations = m.inheritanceIndex.matchingOperations(path, m.inheritance)
}
return historyWithInheritance(path, history, operations)
}
// HistoricalPaths returns the paths observed during loading, including effective
@@ -161,6 +166,7 @@ func finalizeMetadataPaths(m *Metadata, final *document.Node, applications []his
walkDocument(operation.effective, operation.transfer.to, add)
}
}
m.inheritanceIndex = newInheritanceHistoryIndex(m.inheritance)
}
// effectivePathIndex records document-derived paths with their contextual segment