Carry sensitivity across matched records

This commit is contained in:
2026-11-02 14:56:38 +00:00
parent c296eba6c1
commit 3b10f97424
4 changed files with 113 additions and 1 deletions

View File

@@ -124,3 +124,34 @@ func (c resolutionCorrespondence) entryPath(path Path) (Path, bool) {
}
return path.clone(), true
}
// finalPath translates historical record descendants without matching removals.
func (c resolutionCorrespondence) finalPath(path Path) (Path, bool) {
if !path.valid() {
return Path{}, false
}
for depth := 0; depth < len(path.segments); depth++ {
prefix := Path{segments: path.segments[:depth]}
collection, found := c.collections[prefix.String()]
if !found || !collection.eligible {
continue
}
for i, segment := range collection.path.segments {
if segment.kind == pathSegmentKey && path.segments[i].kind == pathSegmentIndex {
return path.clone(), true
}
}
index, ok := schemaIndex(path.segments[depth])
if !ok || index >= len(collection.entryToFinal) {
continue
}
current := collection.entryToFinal[index]
if current < 0 {
return Path{}, false
}
translated := path.clone()
translated.segments[depth] = pathSegment{kind: pathSegmentIndex, index: current}
return translated, true
}
return path.clone(), true
}