Apply sparse collection policy across overlays

This commit is contained in:
2026-10-25 23:05:23 +00:00
parent 3a1b6ff355
commit d172a5e46a
3 changed files with 122 additions and 12 deletions

View File

@@ -155,26 +155,21 @@ func prepareOverlayCollection(
}
registered := make(map[string]bool)
for _, claim := range claims.ordered {
key := claim.path.String()
if _, hasLowerPolicy := lowerPolicies.collections[key]; hasLowerPolicy {
registered[key] = true
registeredPaths[key] = claim.path.clone()
}
if claim.kind == document.Sequence {
if _, ok := sequencePolicy.identityFieldsAt(claim.path); ok {
registered[claim.path.String()] = true
registeredPaths[claim.path.String()] = claim.path.clone()
registered[key] = true
registeredPaths[key] = claim.path.clone()
}
}
}
for key := range declarationsByPath {
registered[key] = true
}
var overlayLookup *documentLookup
if len(lowerPolicies.collections) != 0 {
overlayLookup = buildDocumentLookup(overlay)
}
for key := range lowerPolicies.collections {
if node, found := documentAtPathWithLookup(overlay, lowerPolicies.collections[key].destination, overlayLookup); found && node != nil {
registered[key] = true
registeredPaths[key] = lowerPolicies.collections[key].destination.clone()
}
}
resolutions := make(map[string]collectionPolicyResolution, len(registered))
for key := range registered {