Remove superseded history attribution paths
This commit is contained in:
@@ -2,19 +2,13 @@ package engine
|
||||
|
||||
import "gitea.maximumdirect.net/eric/ConfigKit/internal/document"
|
||||
|
||||
// postDecodeOverrideContext keeps the structural, typed pre-CLI, and effective
|
||||
// post-CLI views distinct while preparing the existing inspection machinery.
|
||||
// postDecodeOverrideContext carries the typed post-CLI state and detached
|
||||
// resolution views after the history builder has taken ownership of evidence.
|
||||
type postDecodeOverrideContext struct {
|
||||
structuralInput *document.Node
|
||||
preCLI *document.Node
|
||||
preCLIOrigins map[string]Origin
|
||||
decoded decodedConfiguration
|
||||
metadata Metadata
|
||||
historyBuilder *historyBuilder
|
||||
resolution resolutionInput
|
||||
applications []historyApplication
|
||||
postDecodeApps []historyApplication
|
||||
referenceInput *document.Node
|
||||
decoded decodedConfiguration
|
||||
metadata Metadata
|
||||
resolution resolutionInput
|
||||
referenceInput *document.Node
|
||||
}
|
||||
|
||||
func preparePostDecodeOverrideContext(input assembledInput, before decodedConfiguration, assigned decodedOverrideResult) postDecodeOverrideContext {
|
||||
@@ -32,14 +26,12 @@ func preparePostDecodeOverrideContext(input assembledInput, before decodedConfig
|
||||
structuralOverlays = input.composition.overlays
|
||||
metadata.historyBuilder.setScratch(input.composition.root)
|
||||
metadata.historyBuilder.observeSourceEvidence(input.composition.root, input.composition.origins, applications, structuralOverlays)
|
||||
applyInheritanceMetadata(&metadata, input.composition.root, input.composition.origins, structuralOverlays, input.inheritance)
|
||||
metadata.historyBuilder.setScratch(input.composition.root)
|
||||
metadata.historyBuilder.observeInheritanceEvidence(input.inheritance.operations)
|
||||
} else if input.composition != nil {
|
||||
structuralOverlays = input.composition.overlays
|
||||
metadata.historyBuilder.setScratch(input.composition.root)
|
||||
metadata.historyBuilder.observeSourceEvidence(input.composition.root, input.composition.origins, applications, structuralOverlays)
|
||||
applyOverlayMetadata(&metadata, structuralOverlays)
|
||||
} else if len(applications) != 0 {
|
||||
metadata.historyBuilder.observeSourceEvidence(input.document, nil, applications, nil)
|
||||
}
|
||||
@@ -58,7 +50,8 @@ func preparePostDecodeOverrideContext(input assembledInput, before decodedConfig
|
||||
collectFieldInfo(after.final, Path{}, after, metadata.fields)
|
||||
}
|
||||
if len(cliRecords) != 0 || len(postDecodeApps) != 0 {
|
||||
appendPostDecodeCLIHistory(&metadata, cliRecords, postDecodeApps, before.final)
|
||||
metadata.historyBuilder.setScratch(before.final)
|
||||
metadata.historyBuilder.observeCLIEvidence(postDecodeApps, cliRecords)
|
||||
}
|
||||
metadata.historyBuilder.observePostCLICheckpoint(after.final, after.origins)
|
||||
metadata.historyBuilder.prefixReady = true
|
||||
@@ -82,33 +75,10 @@ func preparePostDecodeOverrideContext(input assembledInput, before decodedConfig
|
||||
finalizeEffectiveMetadataPaths(&metadata, assigned.final)
|
||||
|
||||
return postDecodeOverrideContext{
|
||||
structuralInput: document.Clone(input.document),
|
||||
preCLI: document.Clone(before.final),
|
||||
preCLIOrigins: cloneOrigins(before.origins),
|
||||
decoded: after,
|
||||
metadata: metadata,
|
||||
historyBuilder: metadata.historyBuilder,
|
||||
resolution: resolution,
|
||||
applications: applications,
|
||||
postDecodeApps: postDecodeApps,
|
||||
referenceInput: documentWithMetadataLocations(assigned.final, metadata, input.document),
|
||||
}
|
||||
}
|
||||
|
||||
// Source history is already assembled, with inheritance projected at query time.
|
||||
// Reuse overlay event construction for CLI changes without reapplying displaced
|
||||
// source definitions after those later assignments.
|
||||
func appendPostDecodeCLIHistory(metadata *Metadata, records []overlayRecord, applications []historyApplication, before *document.Node) {
|
||||
metadata.historyBuilder.setScratch(before)
|
||||
metadata.historyBuilder.observeCLIEvidence(applications, records)
|
||||
cli := Metadata{fields: metadata.fields}
|
||||
applyOverlayMetadata(&cli, records)
|
||||
for pointer, history := range cli.history {
|
||||
for _, change := range history {
|
||||
if change.Origin.Layer == LayerCLI {
|
||||
appendInputChangeEvent(metadata.history, nil, pointer, change)
|
||||
}
|
||||
}
|
||||
decoded: after,
|
||||
metadata: metadata,
|
||||
resolution: resolution,
|
||||
referenceInput: documentWithMetadataLocations(assigned.final, metadata, input.document),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,19 +139,14 @@ func collectAffectedOverrideOrigins(displaced *[]displacedDefinition, existing,
|
||||
}
|
||||
}
|
||||
|
||||
func (context postDecodeOverrideContext) historyApplications() []historyApplication {
|
||||
applications := cloneHistoryApplications(context.applications)
|
||||
return append(applications, cloneHistoryApplications(context.postDecodeApps)...)
|
||||
}
|
||||
|
||||
func structuralHistoryApplications(input assembledInput) []historyApplication {
|
||||
if input.composition != nil {
|
||||
return cloneHistoryApplications(input.composition.applications)
|
||||
return input.composition.applications
|
||||
}
|
||||
if input.document == nil {
|
||||
return nil
|
||||
}
|
||||
return []historyApplication{{layer: LayerBase, value: document.Clone(input.document)}}
|
||||
return []historyApplication{{layer: LayerBase, value: input.document}}
|
||||
}
|
||||
|
||||
// documentWithMetadataLocations attaches effective origin coordinates to a
|
||||
@@ -289,7 +254,7 @@ func metadataFieldLocation(metadata Metadata, path Path, origin Origin) (documen
|
||||
if location, ok := latestOriginDocumentLocation(origin); ok {
|
||||
return location, true
|
||||
}
|
||||
if model := metadata.currentHistoryModel(); model != nil {
|
||||
if model := metadata.historyEvidence(); model != nil {
|
||||
location, ok := model.latestHistoricalLocation(path)
|
||||
if ok {
|
||||
return document.Location{SourceID: location.SourceID, Line: location.Line, Column: location.Column}, true
|
||||
|
||||
Reference in New Issue
Block a user