Share sequence history construction
This commit is contained in:
@@ -978,6 +978,14 @@ record replacement/removal, modes, origin locations, and sensitivity for both
|
|||||||
precedence and inheritance.
|
precedence and inheritance.
|
||||||
Focused check: `go test ./internal/engine -run 'Sequence|Collection|Inheritance|History|Explain|Sensitivity'`.
|
Focused check: `go test ./internal/engine -run 'Sequence|Collection|Inheritance|History|Explain|Sensitivity'`.
|
||||||
|
|
||||||
|
Status: **complete** (E03). Prior completed commits include `8832449`,
|
||||||
|
`549fca2`, `3a1b6ff`, and `d172a5e`. Validation passed:
|
||||||
|
`env GOTOOLCHAIN=local GOPROXY=off GOTELEMETRY=off go test ./internal/engine -run 'Sequence|Collection|Inheritance|History|Explain|Sensitivity' -count=1`,
|
||||||
|
`env GOTOOLCHAIN=local GOPROXY=off GOTELEMETRY=off go test ./internal/engine -count=1`,
|
||||||
|
`env GOTOOLCHAIN=local GOPROXY=off GOTELEMETRY=off go test ./... -count=1`,
|
||||||
|
`env GOTOOLCHAIN=local GOPROXY=off GOTELEMETRY=off go test -race ./...`,
|
||||||
|
and `git diff --check`.
|
||||||
|
|
||||||
## Stage 30 — Index Original Tier-History Values Lazily
|
## Stage 30 — Index Original Tier-History Values Lazily
|
||||||
|
|
||||||
Finding: **E04**.
|
Finding: **E04**.
|
||||||
|
|||||||
@@ -413,6 +413,27 @@ func applySequenceHistory(target **document.Node, incoming *document.Node, contr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sequenceHistoryContributionForCombination(
|
||||||
|
destination Path,
|
||||||
|
operation sequenceMode,
|
||||||
|
incoming *document.Node,
|
||||||
|
combined sequenceCombinationResult,
|
||||||
|
) sequenceHistoryContribution {
|
||||||
|
contribution := sequenceHistoryContribution{
|
||||||
|
path: destination.clone(), mode: sequenceHistoryMapped,
|
||||||
|
}
|
||||||
|
if operation == sequenceModeReplace {
|
||||||
|
contribution.mode = sequenceHistoryReplace
|
||||||
|
if incoming != nil && incoming.Kind == document.Sequence {
|
||||||
|
contribution.length = len(incoming.Sequence)
|
||||||
|
}
|
||||||
|
return contribution
|
||||||
|
}
|
||||||
|
contribution.items = append([]sequenceItemProjection(nil), combined.higherItems...)
|
||||||
|
contribution.replacements = append([]sequenceItemReplacement(nil), combined.replacements...)
|
||||||
|
return contribution
|
||||||
|
}
|
||||||
|
|
||||||
func cloneSequenceHistoryContributions(values []sequenceHistoryContribution) []sequenceHistoryContribution {
|
func cloneSequenceHistoryContributions(values []sequenceHistoryContribution) []sequenceHistoryContribution {
|
||||||
if values == nil {
|
if values == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -469,21 +469,18 @@ func TestSequenceHistoryReplaysCombinationEvidence(t *testing.T) {
|
|||||||
t.Fatalf("combine diagnostics = %#v", diagnostics)
|
t.Fatalf("combine diagnostics = %#v", diagnostics)
|
||||||
}
|
}
|
||||||
|
|
||||||
mode := sequenceHistoryMapped
|
|
||||||
if test.operation == sequenceModeReplace {
|
|
||||||
mode = sequenceHistoryReplace
|
|
||||||
}
|
|
||||||
length := 0
|
|
||||||
if mode == sequenceHistoryReplace {
|
|
||||||
length = len(combined.higherItems)
|
|
||||||
}
|
|
||||||
application := historyApplication{
|
application := historyApplication{
|
||||||
layer: LayerOverlay,
|
layer: LayerOverlay,
|
||||||
value: higherRoot,
|
value: higherRoot,
|
||||||
sequences: []sequenceHistoryContribution{{
|
sequences: []sequenceHistoryContribution{
|
||||||
path: Keys("records"), mode: mode, length: length,
|
sequenceHistoryContributionForCombination(Keys("records"), test.operation, higher, combined),
|
||||||
items: combined.higherItems, replacements: combined.replacements,
|
},
|
||||||
}},
|
}
|
||||||
|
if len(combined.higherItems) != 0 {
|
||||||
|
combined.higherItems[0].outputIndex++
|
||||||
|
}
|
||||||
|
if len(combined.replacements) != 0 {
|
||||||
|
combined.replacements[0].outputIndex++
|
||||||
}
|
}
|
||||||
application.sequencesByPath = indexSequenceHistoryContributions(application.sequences)
|
application.sequencesByPath = indexSequenceHistoryContributions(application.sequences)
|
||||||
replayed := document.Clone(lowerRoot)
|
replayed := document.Clone(lowerRoot)
|
||||||
|
|||||||
@@ -85,17 +85,9 @@ func combineInheritanceTemplate(
|
|||||||
result.replacements = append(result.replacements, applyInheritanceSequenceOrigins(
|
result.replacements = append(result.replacements, applyInheritanceSequenceOrigins(
|
||||||
mergedOrigins, child.origins, childPath, lowerValue, incoming, combined, resolution.operation,
|
mergedOrigins, child.origins, childPath, lowerValue, incoming, combined, resolution.operation,
|
||||||
)...)
|
)...)
|
||||||
history := sequenceHistoryContribution{path: childPath.clone(), mode: sequenceHistoryMapped}
|
sequenceContributions = append(sequenceContributions, sequenceHistoryContributionForCombination(
|
||||||
if resolution.operation == sequenceModeReplace {
|
childPath, resolution.operation, incoming, combined,
|
||||||
history.mode = sequenceHistoryReplace
|
))
|
||||||
if incoming != nil && incoming.Kind == document.Sequence {
|
|
||||||
history.length = len(incoming.Sequence)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
history.items = append([]sequenceItemProjection(nil), combined.higherItems...)
|
|
||||||
history.replacements = append([]sequenceItemReplacement(nil), combined.replacements...)
|
|
||||||
}
|
|
||||||
sequenceContributions = append(sequenceContributions, history)
|
|
||||||
return combined.value, true
|
return combined.value, true
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -274,17 +274,9 @@ func (operation *overlayMergeOperation) merge(path Path, existing, incoming *doc
|
|||||||
operation.incomingOrigins, operation.incomingPolicies, operation.layer,
|
operation.incomingOrigins, operation.incomingPolicies, operation.layer,
|
||||||
)
|
)
|
||||||
operation.valueDestinations[path.String()] = true
|
operation.valueDestinations[path.String()] = true
|
||||||
history := sequenceHistoryContribution{path: path.clone(), mode: sequenceHistoryMapped}
|
operation.sequenceApplications[path.String()] = sequenceHistoryContributionForCombination(
|
||||||
if resolution.operation == sequenceModeReplace {
|
path, resolution.operation, incoming, combined,
|
||||||
history.mode = sequenceHistoryReplace
|
)
|
||||||
if incoming != nil && incoming.Kind == document.Sequence {
|
|
||||||
history.length = len(incoming.Sequence)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
history.items = append([]sequenceItemProjection(nil), combined.higherItems...)
|
|
||||||
history.replacements = append([]sequenceItemReplacement(nil), combined.replacements...)
|
|
||||||
}
|
|
||||||
operation.sequenceApplications[path.String()] = history
|
|
||||||
return combined.value, true
|
return combined.value, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user