Prepare resolution entry provenance view

This commit is contained in:
2026-09-12 13:10:48 +00:00
parent 818d36f836
commit 88f21d09c7
4 changed files with 142 additions and 3 deletions

View File

@@ -113,9 +113,8 @@ func (m Metadata) hasHistoricalPath(path Path) bool {
}
func finalizeMetadataPaths(m *Metadata, final *document.Node, applications []historyApplication, earlier ...*document.Node) {
m.effectivePaths = make(map[string]Path)
m.effectivePaths = effectivePathIndex(final)
m.historicalPaths = make(map[string][]Path)
walkDocument(final, Path{}, func(path Path, _ *document.Node) { m.effectivePaths[path.String()] = path.clone() })
add := func(path Path, _ *document.Node) {
pointer := path.String()
for _, prior := range m.historicalPaths[pointer] {
@@ -138,3 +137,13 @@ func finalizeMetadataPaths(m *Metadata, final *document.Node, applications []his
walkDocument(application.value, prefix, add)
}
}
// effectivePathIndex records document-derived paths with their contextual segment
// kinds. Callers retain no aliases to the walked tree or its paths.
func effectivePathIndex(final *document.Node) map[string]Path {
paths := make(map[string]Path)
walkDocument(final, Path{}, func(path Path, _ *document.Node) {
paths[path.String()] = path.clone()
})
return paths
}