Remove unused captured state and orphan helpers

This commit is contained in:
2026-11-05 14:33:04 +00:00
parent a91bc1608b
commit 7db5572b62
14 changed files with 16 additions and 74 deletions

View File

@@ -119,7 +119,6 @@ const (
type loaded struct {
result *configkit.Result[document]
backends map[string]map[string]fieldState
profiles map[string]map[string]fieldState
promptMetadata map[string][]promptInputPresence
prompts map[string]*promptEntry
@@ -212,7 +211,6 @@ func indexedProfiles(config *document) map[string]profileConfig {
var envName = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_]*$`)
var backendFields = []string{"endpoint", "api_key_env", "concurrency_limit", "queue_capacity", "extra_params", "smoke_tests"}
var profileFields = []string{"backend", "endpoint", "model", "temperature", "top_p", "max_tokens", "timeout_seconds", "service_tier", "reasoning_effort", "api_key_env", "api_key_required", "extra_params"}
// Load captures one immutable effective configuration for internal consumers.
@@ -237,7 +235,6 @@ func configurationDefinition(state *loaded) configkit.Definition[document] {
Sensitive: secretProviderPath,
Resolve: func(config *document, resolution *configkit.Resolution) error {
for _, resources := range resourceSets(config) {
captureFields(resources.backends, func(v backendConfig) string { return v.ID }, resources.bases.backends, resources.namespace, backendFields, resolution, state.backends)
captureFields(resources.profiles, func(v profileConfig) string { return v.ID }, resources.bases.profiles, resources.namespace, profileFields, resolution, state.profiles)
capturePromptMetadata(resources.prompts, resources.bases.prompts, resources.namespace, resolution, state.promptMetadata)
}
@@ -257,7 +254,6 @@ func configurationDefinition(state *loaded) configkit.Definition[document] {
// load performs one ConfigKit lifecycle over the selected source tiers.
func load(main configkit.Input, underlays []configkit.Underlay) (*loaded, error) {
state := &loaded{
backends: make(map[string]map[string]fieldState),
profiles: make(map[string]map[string]fieldState),
promptMetadata: make(map[string][]promptInputPresence),
}

View File

@@ -496,7 +496,7 @@ func TestLoadComposesLiteralKeysAndEffectivePresence(t *testing.T) {
t.Fatalf("recursive overlay failed: %+v", provider)
}
backend := loaded.result.Config.Backends[0]
if backend.QueueCapacity == nil || *backend.QueueCapacity != 0 || loaded.backends["local.v1"]["queue_capacity"] != fieldValue {
if backend.QueueCapacity == nil || *backend.QueueCapacity != 0 {
t.Fatalf("explicit zero queue capacity was lost: %+v", backend)
}
if _, err := loaded.registry.GetBackend("base/local.v1"); err != nil {
@@ -582,9 +582,6 @@ func TestLoadInterpretsBackendNormalizationAndNullDefault(t *testing.T) {
composed.APIKeyEnv == nil || *composed.APIKeyEnv != "TOKEN_NAME" || composed.QueueCapacity == nil || *composed.QueueCapacity != 1024 {
t.Fatalf("resolved backend was not normalized: %+v", composed)
}
if loaded.backends["local"]["queue_capacity"] != fieldNull {
t.Fatalf("explicit null was not retained: %+v", loaded.backends["local"])
}
field, found := loaded.result.Metadata().Lookup(configkit.Keys("backends").Index(0).Key("endpoint"))
if !found || field.Origin.Operation != configkit.ChangeNormalization {
t.Fatalf("endpoint origin was not preserved: %+v", field)
@@ -763,7 +760,7 @@ func TestLoadDefaultsAbsentQueueCapacity(t *testing.T) {
t.Fatal(err)
}
backend, err := loaded.GetBackend("local")
if err != nil || backend.APIKeyEnv != "" || backend.QueueCapacity != 1024 || loaded.result.Config.Backends[0].QueueCapacity == nil || *loaded.result.Config.Backends[0].QueueCapacity != 1024 || loaded.backends["local"]["queue_capacity"] != fieldAbsent {
if err != nil || backend.APIKeyEnv != "" || backend.QueueCapacity != 1024 || loaded.result.Config.Backends[0].QueueCapacity == nil || *loaded.result.Config.Backends[0].QueueCapacity != 1024 {
t.Fatalf("absent queue capacity did not receive its default: %+v", backend)
}
}

View File

@@ -62,7 +62,6 @@ func captureBackend(id string, config backendConfig) domain.Backend {
}
if config.QueueCapacity != nil {
definition.QueueCapacity = *config.QueueCapacity
definition.QueueCapacitySet = definition.ConcurrencyLimit > 0
}
return definition
}

View File

@@ -119,7 +119,7 @@ func TestLoadBuildsEffectiveTargetsAfterInheritance(t *testing.T) {
t.Fatal(err)
}
selected, err := state.registry.GetBackend("second")
if err != nil || selected.QueueCapacity != 0 || !selected.QueueCapacitySet {
if err != nil || selected.QueueCapacity != 0 || selected.ConcurrencyLimit != 2 {
t.Fatalf("backend capacity was not preserved: %+v, %v", selected, err)
}
child, err := state.GetProfile(context.Background(), "child")