Use resolved configuration for construction

This commit is contained in:
2026-11-03 03:29:41 +00:00
parent 7a98feb399
commit 9f33fed823
5 changed files with 10 additions and 20 deletions

View File

@@ -119,7 +119,6 @@ const (
type loaded struct {
result *configkit.Result[document]
interpreted document
backends map[string]map[string]fieldState
profiles map[string]map[string]fieldState
promptMetadata map[string][]promptInputPresence
@@ -250,8 +249,7 @@ func configurationDefinition(state *loaded) configkit.Definition[document] {
return nil
},
Validate: func(config *document, validation *configkit.Validation) {
state.interpreted = interpretConfiguration(config, validation)
validateEffective(&state.interpreted, validation)
validateEffective(config, validation)
},
}
}
@@ -278,7 +276,7 @@ func load(main configkit.Input, underlays []configkit.Underlay) (*loaded, error)
if err := state.buildExecutionProfiles(); err != nil {
return nil, fmt.Errorf("load configuration: %w", err)
}
state.backendIDs = sortedKeys(indexedBackends(&state.interpreted))
state.backendIDs = sortedKeys(indexedBackends(&state.result.Config))
state.profileIDs = sortedKeys(state.indexedProfiles)
for _, id := range sortedKeys(state.prompts) {
state.promptIDs = append(state.promptIDs, domain.PromptIdentity{ID: id})
@@ -408,18 +406,6 @@ func sortedKeys[T any](entries map[string]T) []string {
return keys
}
func interpretConfiguration(config *document, validation *configkit.Validation) document {
interpreted := *config
if config.Collections != nil {
interpreted.Collections = make(map[string]collectionConfig, len(config.Collections))
for namespace, original := range config.Collections {
collection := original
interpreted.Collections[namespace] = collection
}
}
return interpreted
}
func validateEffective(config *document, validation *configkit.Validation) {
sets := resourceSets(config)
backendIDs := make(map[string]struct{})

View File

@@ -38,7 +38,7 @@ func (state *loaded) materializePrompts() error {
}
return metadata.Lookup(path)
}
for _, resources := range resourceSets(&state.interpreted) {
for _, resources := range resourceSets(&state.result.Config) {
for index, raw := range resources.prompts {
promptBase := resources.bases.prompts.Index(index)
if strings.TrimSpace(raw.ID) == "" {

View File

@@ -12,8 +12,8 @@ import (
)
func (state *loaded) buildExecutionProfiles() error {
backendConfigs := indexedBackends(&state.interpreted)
profileConfigs := indexedProfiles(&state.interpreted)
backendConfigs := indexedBackends(&state.result.Config)
profileConfigs := indexedProfiles(&state.result.Config)
definitions := make(map[string]domain.Backend, len(backendConfigs))
for _, id := range sortedKeys(backendConfigs) {
config := backendConfigs[id]