Share layered tier application
This commit is contained in:
@@ -113,21 +113,12 @@ func assembleLayeredInput[T any](request loadRequest[T], input assembledInput, p
|
||||
return input, diagnostics
|
||||
}
|
||||
if composition != nil {
|
||||
if assembly == nil {
|
||||
assembly = newAssemblyAccumulator(composition)
|
||||
} else {
|
||||
var declarations []sequenceDeclarationSpec
|
||||
for _, scope := range composition.acquisition {
|
||||
declarations = append(declarations, acquiredSequenceDeclarations(scope)...)
|
||||
}
|
||||
operations, diagnostics := assembly.applyOverlayWithCollectionProjection(
|
||||
composition.root, composition.origins, composition.collectionPolicies, composition.applications, LayerUnderlay,
|
||||
policy.sequencePolicy, declarations,
|
||||
)
|
||||
if len(diagnostics) != 0 {
|
||||
return input, diagnostics
|
||||
}
|
||||
projectTierSourceDestinations(input.sources[sourceStart:], input.versionState.evidenceSince(evidenceStart), operations)
|
||||
_, diagnostics = applyCompletedTier(
|
||||
&assembly, composition, composition.collectionPolicies, LayerUnderlay, policy.sequencePolicy,
|
||||
input.sources[sourceStart:], input.versionState.evidenceSince(evidenceStart),
|
||||
)
|
||||
if len(diagnostics) != 0 {
|
||||
return input, diagnostics
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,23 +151,14 @@ func assembleLayeredInput[T any](request loadRequest[T], input assembledInput, p
|
||||
}
|
||||
if mainComposition != nil {
|
||||
input.versionState.locateMainVersion(mainComposition.root)
|
||||
if assembly == nil {
|
||||
assembly = newAssemblyAccumulator(mainComposition)
|
||||
} else {
|
||||
var declarations []sequenceDeclarationSpec
|
||||
for _, scope := range mainComposition.acquisition {
|
||||
declarations = append(declarations, acquiredSequenceDeclarations(scope)...)
|
||||
}
|
||||
operations, diagnostics := assembly.applyOverlayWithCollectionProjection(
|
||||
mainComposition.root, mainComposition.origins, mainComposition.collectionPolicies, mainComposition.applications, LayerBase,
|
||||
policy.sequencePolicy, declarations,
|
||||
)
|
||||
if len(diagnostics) != 0 {
|
||||
return input, append(versionDiagnostics, diagnostics...)
|
||||
}
|
||||
projectTierSourceDestinations(input.sources[:mainSourceCount], mainEvidence, operations)
|
||||
input.versionState.projectMainVersion(operations)
|
||||
operations, diagnostics := applyCompletedTier(
|
||||
&assembly, mainComposition, mainComposition.collectionPolicies, LayerBase, policy.sequencePolicy,
|
||||
input.sources[:mainSourceCount], mainEvidence,
|
||||
)
|
||||
if len(diagnostics) != 0 {
|
||||
return input, append(versionDiagnostics, diagnostics...)
|
||||
}
|
||||
input.versionState.projectMainVersion(operations)
|
||||
}
|
||||
if input.versionState != nil {
|
||||
request.effectiveVersion = input.versionState.effectiveRule
|
||||
@@ -230,6 +212,42 @@ func assembleLayeredInput[T any](request loadRequest[T], input assembledInput, p
|
||||
return input, versionDiagnostics
|
||||
}
|
||||
|
||||
// applyCompletedTier joins one already-composed precedence tier to the load's
|
||||
// assembly and projects only that tier's source/version evidence through the
|
||||
// resulting sequence operations. Callers select the tier-local evidence ranges
|
||||
// so lower-tier and main-tier coordinates remain distinct.
|
||||
func applyCompletedTier(
|
||||
assembly **assemblyAccumulator,
|
||||
composition *composedDocument,
|
||||
incomingPolicies collectionPolicyScope,
|
||||
layer Layer,
|
||||
sequencePolicy sequencePolicy,
|
||||
incomingSources []SourceInfo,
|
||||
incomingVersions []*sourceVersionEvidence,
|
||||
) ([]sequenceHistoryContribution, []Diagnostic) {
|
||||
if composition == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if *assembly == nil {
|
||||
*assembly = newAssemblyAccumulator(composition)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var declarations []sequenceDeclarationSpec
|
||||
for _, scope := range composition.acquisition {
|
||||
declarations = append(declarations, acquiredSequenceDeclarations(scope)...)
|
||||
}
|
||||
operations, diagnostics := (*assembly).applyOverlayWithCollectionProjection(
|
||||
composition.root, composition.origins, incomingPolicies, composition.applications, layer,
|
||||
sequencePolicy, declarations,
|
||||
)
|
||||
if len(diagnostics) != 0 {
|
||||
return nil, diagnostics
|
||||
}
|
||||
projectTierSourceDestinations(incomingSources, incomingVersions, operations)
|
||||
return operations, nil
|
||||
}
|
||||
|
||||
func acquireUnderlayGroupScopes(group loadGroup, index int, rule *VersionRule, state *acquisitionState, policy acquisitionPolicy) (*acquiredUnderlayGroup, []Diagnostic) {
|
||||
initialBytes, initialNodes := state.accounting.bytes, state.accounting.nodes
|
||||
tier := &tierAcquisitionState{visited: make(map[resourceIdentity]importRoute), hostToken: &namespaceToken{}}
|
||||
|
||||
Reference in New Issue
Block a user