Audit registered collection changes by identity

This commit is contained in:
2026-11-02 14:43:48 +00:00
parent 7f004f67ad
commit d120fe907b
8 changed files with 166 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ import (
)
// compareResolutionValues reports field-level changes at stable list positions.
func compareResolutionValues(before, after *document.Node) []documentDelta {
func compareResolutionValues(before, after *document.Node, correspondence ...resolutionCorrespondence) []documentDelta {
var deltas []documentDelta
var compare func(*document.Node, *document.Node, Path)
compare = func(left, right *document.Node, path Path) {
@@ -30,6 +30,25 @@ func compareResolutionValues(before, after *document.Node) []documentDelta {
compare(value, nil, path.Key(key))
}
case document.Sequence:
if len(correspondence) != 0 {
if collection, registered := correspondence[0].collections[path.String()]; registered {
if !collection.eligible {
if !configurationValuesEqual(left, right) {
deltas = append(deltas, documentDelta{path: path.clone(), kind: documentReplaced})
}
return
}
if collection.structural {
deltas = append(deltas, documentDelta{path: path.clone(), kind: documentReplaced})
}
for finalIndex, entryIndex := range collection.finalToEntry {
if entryIndex >= 0 {
compare(left.Sequence[entryIndex], right.Sequence[finalIndex], path.Index(finalIndex))
}
}
return
}
}
if len(left.Sequence) != len(right.Sequence) {
deltas = append(deltas, documentDelta{path: path.clone(), kind: documentReplaced})
return