Carry sensitivity across matched records
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user