From 7db5572b621f79ae9b33cd8ccd3ab47a01e98d47 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Thu, 5 Nov 2026 14:33:04 +0000 Subject: [PATCH] Remove unused captured state and orphan helpers --- docs/roadmap/implementation.md | 5 +++++ internal/backend/registry_test.go | 2 +- internal/configuration/load.go | 4 ---- internal/configuration/load_test.go | 7 ++----- internal/configuration/targets.go | 1 - internal/configuration/targets_test.go | 2 +- internal/domain/domain.go | 1 - internal/domain/resource_identity.go | 8 -------- internal/domain/resource_identity_test.go | 22 --------------------- internal/filecatalog/catalog.go | 9 --------- internal/filecatalog/catalog_test.go | 10 ---------- internal/usecase/runner_test.go | 4 ---- internal/usecase/smoke_reachability.go | 13 ++++++------ internal/usecase/smoke_reachability_test.go | 2 +- 14 files changed, 16 insertions(+), 74 deletions(-) diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 94821d0..b311792 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -779,6 +779,11 @@ tests and one-iteration checks of both benchmark paths pass on Go 1.27.3. discovery and identity/listing behavior remain covered. Optional public helpers, capability fallbacks, and embedded/release assets are not deletion candidates. +Completion: unused backend presence and queue bookkeeping, the reachability +endpoint echo, and the named orphan helpers were removed after caller checks. +Queue, provenance, reachability, identity, discovery, and related public tests +pass on Go 1.27.3. The remaining file-source caller uses its three results. + ## Stage 31: Remove Redundant Captured Prompt Fields **Catalog:** 31. **Files:** domain prompt values, configuration capture, runner/fixtures. diff --git a/internal/backend/registry_test.go b/internal/backend/registry_test.go index 5d6bee8..3a12147 100644 --- a/internal/backend/registry_test.go +++ b/internal/backend/registry_test.go @@ -25,7 +25,7 @@ func TestEffectiveRegistryOwnsDefinitionsAndCapacityPolicies(t *testing.T) { registry, err := backend.NewEffectiveRegistry(map[string]domain.Backend{ " local.v1 ": { Endpoint: "https://backend.example/v1", ExtraParams: params, - ConcurrencyLimit: 2, QueueCapacity: 3, QueueCapacitySet: true, + ConcurrencyLimit: 2, QueueCapacity: 3, SmokeTests: smokeTests, }, }) diff --git a/internal/configuration/load.go b/internal/configuration/load.go index f3996c6..2cf8070 100644 --- a/internal/configuration/load.go +++ b/internal/configuration/load.go @@ -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), } diff --git a/internal/configuration/load_test.go b/internal/configuration/load_test.go index e3eae5c..a1e392e 100644 --- a/internal/configuration/load_test.go +++ b/internal/configuration/load_test.go @@ -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) } } diff --git a/internal/configuration/targets.go b/internal/configuration/targets.go index 4b6c361..d374742 100644 --- a/internal/configuration/targets.go +++ b/internal/configuration/targets.go @@ -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 } diff --git a/internal/configuration/targets_test.go b/internal/configuration/targets_test.go index 72eb8fe..e7b7920 100644 --- a/internal/configuration/targets_test.go +++ b/internal/configuration/targets_test.go @@ -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") diff --git a/internal/domain/domain.go b/internal/domain/domain.go index 78a423d..4412087 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -184,7 +184,6 @@ type Backend struct { SmokeTests *BackendSmokeTestConfig ConcurrencyLimit int QueueCapacity int - QueueCapacitySet bool } // BackendCapacityPolicy describes normalized run and generation capacity for diff --git a/internal/domain/resource_identity.go b/internal/domain/resource_identity.go index 3a3143a..806142a 100644 --- a/internal/domain/resource_identity.go +++ b/internal/domain/resource_identity.go @@ -31,14 +31,6 @@ func qualifyResourceID(id, namespace string) (string, bool) { return namespace + "/" + id, true } -func resourceNamespaceFromID(id string) (string, bool) { - if !validResourceID(id) || !strings.Contains(id, "/") { - return "", false - } - namespace, _, _ := strings.Cut(id, "/") - return namespace, true -} - // IsValidResourceID reports whether id is an unqualified resource ID or one // valid namespace/local-ID pair. func IsValidResourceID(id string) bool { return validResourceID(id) } diff --git a/internal/domain/resource_identity_test.go b/internal/domain/resource_identity_test.go index 5e54a81..e4306a1 100644 --- a/internal/domain/resource_identity_test.go +++ b/internal/domain/resource_identity_test.go @@ -86,25 +86,3 @@ func TestQualifyResourceID(t *testing.T) { }) } } - -func TestResourceNamespaceFromID(t *testing.T) { - tests := []struct { - name string - id string - namespace string - wantOK bool - }{ - {name: "qualified", id: "team/item", namespace: "team", wantOK: true}, - {name: "same-prefix namespace stays distinct", id: "team-extra/item", namespace: "team-extra", wantOK: true}, - {name: "unqualified", id: "item", wantOK: false}, - {name: "malformed", id: "team/sub/item", wantOK: false}, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got, ok := resourceNamespaceFromID(test.id) - if got != test.namespace || ok != test.wantOK { - t.Fatalf("resourceNamespaceFromID(%q) = (%q, %t), want (%q, %t)", test.id, got, ok, test.namespace, test.wantOK) - } - }) - } -} diff --git a/internal/filecatalog/catalog.go b/internal/filecatalog/catalog.go index dcc148d..22ef0cc 100644 --- a/internal/filecatalog/catalog.go +++ b/internal/filecatalog/catalog.go @@ -67,15 +67,6 @@ func FindFSYAMLFiles(ctx context.Context, fsys fs.FS, root string) ([]string, er return files, err } -// RelativePath computes a clean relative path from root to path. -func RelativePath(root string, filePath string) string { - rel, err := filepath.Rel(root, filePath) - if err != nil { - return filepath.Clean(filePath) - } - return filepath.Clean(rel) -} - // CleanFSRoot normalizes a root path for use with fs.FS while preserving // nonblank leading and trailing whitespace. func CleanFSRoot(root string) string { diff --git a/internal/filecatalog/catalog_test.go b/internal/filecatalog/catalog_test.go index 171e7cd..16d315e 100644 --- a/internal/filecatalog/catalog_test.go +++ b/internal/filecatalog/catalog_test.go @@ -81,16 +81,6 @@ func TestFindFSYAMLFilesHonorsContextCancellation(t *testing.T) { } } -func TestRelativePathNested(t *testing.T) { - root := t.TempDir() - path := filepath.Join(root, "nested", "profiles", "local.yaml") - got := RelativePath(root, path) - want := filepath.Join("nested", "profiles", "local.yaml") - if got != want { - t.Fatalf("expected relative path %q, got %q", want, got) - } -} - func TestCleanFSRoot(t *testing.T) { tests := []struct { name string diff --git a/internal/usecase/runner_test.go b/internal/usecase/runner_test.go index a7da313..3c4bdcb 100644 --- a/internal/usecase/runner_test.go +++ b/internal/usecase/runner_test.go @@ -2586,10 +2586,6 @@ func float64Ptr(v float64) *float64 { return &v } -func stringPtr(v string) *string { - return &v -} - func intPtr(v int) *int { return &v } diff --git a/internal/usecase/smoke_reachability.go b/internal/usecase/smoke_reachability.go index 503dbaf..e4ce444 100644 --- a/internal/usecase/smoke_reachability.go +++ b/internal/usecase/smoke_reachability.go @@ -21,12 +21,11 @@ type reachabilityProbe struct { } type reachabilityProbeOutcome struct { - supported bool - reason domain.SmokeTestReason - initialEndpoint string - reachable *bool - evidence llm.HTTPExecutionEvidence - failure domain.ExecutionFailureKind + supported bool + reason domain.SmokeTestReason + reachable *bool + evidence llm.HTTPExecutionEvidence + failure domain.ExecutionFailureKind } func (p reachabilityProbe) run( @@ -44,7 +43,7 @@ func (p reachabilityProbe) run( if err != nil { return reachabilityProbeOutcome{}, fmt.Errorf("prepare reachability endpoint: %w", err) } - result := reachabilityProbeOutcome{supported: true, initialEndpoint: endpoint} + result := reachabilityProbeOutcome{supported: true} response, evidence, requestErr := p.client.GetWithEvidence(ctx, endpoint, timeoutSeconds) if response != nil && response.Body != nil { _ = response.Body.Close() diff --git a/internal/usecase/smoke_reachability_test.go b/internal/usecase/smoke_reachability_test.go index 66997a9..d6a8883 100644 --- a/internal/usecase/smoke_reachability_test.go +++ b/internal/usecase/smoke_reachability_test.go @@ -62,7 +62,7 @@ func TestReachabilityProbeRemovesURLCredentials(t *testing.T) { if observed == nil || observed.URL.User != nil || observed.Header.Get("Authorization") != "" { t.Fatalf("probe request retained URL credentials: %+v", observed) } - if result.initialEndpoint != "https://example.invalid/health?check=1" || result.evidence.CredentialsSupplied { + if result.evidence.Endpoint != "https://example.invalid/health?check=1" || result.evidence.CredentialsSupplied { t.Fatalf("credential-free evidence = %+v", result) } }