Index collection policy retirement

This commit is contained in:
2026-10-25 22:49:02 +00:00
parent 549fca239d
commit 68383f34de
5 changed files with 298 additions and 10 deletions

View File

@@ -260,7 +260,7 @@ func (operation *overlayMergeOperation) combined(path Path, incoming *document.N
}
func (operation *overlayMergeOperation) replaced(path Path, existing, incoming *document.Node) {
operation.result.collectionPolicies.retireCollectionPoliciesAtOrBelow(path)
operation.assembly.retireCollectionPoliciesAtOrBelow(path)
recordOverlayReplacement(operation.result, path, existing, incoming, operation.layer, true, operation.incomingOrigins)
}
@@ -275,7 +275,7 @@ func (operation *overlayMergeOperation) merge(path Path, existing, incoming *doc
return existing, false
}
applyOverlaySequenceEvidence(
operation.result, path, existing, incoming, combined, resolution,
operation.assembly, path, existing, incoming, combined, resolution,
operation.incomingOrigins, operation.incomingPolicies, operation.layer,
)
operation.valueDestinations[path.String()] = true
@@ -334,7 +334,7 @@ func finalizeOverlayCollection(
diagnostics = append(diagnostics, issues...)
continue
}
assembly.current.collectionPolicies.set(path, policy)
assembly.setCollectionPolicy(path, policy)
}
if len(diagnostics) != 0 {
return nil, canonicalDiagnostics(diagnostics)
@@ -414,7 +414,7 @@ func recordOverlayReplacement(
}
func applyOverlaySequenceEvidence(
result *composedDocument,
assembly *assemblyAccumulator,
path Path,
lower, higher *document.Node,
combined sequenceCombinationResult,
@@ -423,19 +423,20 @@ func applyOverlaySequenceEvidence(
incomingPolicies collectionPolicyScope,
layer Layer,
) {
result := assembly.current
lowerPolicy, hadLowerPolicy := result.collectionPolicies.at(path)
if resolution.operation == sequenceModeReplace {
var lowerValue *collectionPolicy
if hadLowerPolicy {
lowerValue = &lowerPolicy
}
result.collectionPolicies.retireCollectionPoliciesAtOrBelow(path)
assembly.retireCollectionPoliciesAtOrBelow(path)
resolution.policy = collectionPolicyForReplacement(lowerValue, resolution.policy)
}
if combined.value == nil || combined.value.Kind != document.Sequence {
recordOverlayReplacement(result, path, lower, higher, layer, true, incomingOrigins)
result.collectionPolicies.set(path, resolution.policy)
assembly.setCollectionPolicy(path, resolution.policy)
return
}
@@ -519,7 +520,7 @@ func applyOverlaySequenceEvidence(
policy.setRecordPolicyAt(outputIndex, replacedCollectionRecordPolicy())
}
}
result.collectionPolicies.set(path, policy)
assembly.setCollectionPolicy(path, policy)
}
func collectOverlayOrigins(origins map[string]Origin, node *document.Node, path Path, layer Layer) {