Prepare resolution entry provenance view

This commit is contained in:
2026-09-12 13:10:48 +00:00
parent 818d36f836
commit 88f21d09c7
4 changed files with 142 additions and 3 deletions

View File

@@ -6,6 +6,42 @@ import (
"gitea.maximumdirect.net/eric/ConfigKit/internal/document"
)
// resolutionInput is the immutable entry-state provenance available to a
// resolution callback. It owns detached metadata and source records so later
// resolution updates cannot change the entry view.
type resolutionInput struct {
metadata Metadata
sources map[string]SourceInfo
}
func newResolutionInput(metadata Metadata, final *document.Node, sources []SourceInfo) resolutionInput {
frozen := cloneMetadata(metadata)
frozen.effectivePaths = effectivePathIndex(final)
indexed := make(map[string]SourceInfo, len(sources))
for _, source := range sources {
if source.ID == "" {
panic("configkit: source identity is missing")
}
if _, exists := indexed[source.ID]; exists {
panic("configkit: source identity is duplicated")
}
indexed[source.ID] = cloneSourceInfo(source)
}
return resolutionInput{metadata: frozen, sources: indexed}
}
func (input resolutionInput) lookup(path Path) (FieldInfo, bool) {
return input.metadata.Lookup(path)
}
func (input resolutionInput) source(id string) (SourceInfo, bool) {
source, ok := input.sources[id]
if !ok {
return SourceInfo{}, false
}
return cloneSourceInfo(source), true
}
func metadataFromDecoded(decoded decodedConfiguration) Metadata {
metadata := Metadata{
fields: make(map[string]FieldInfo),