From 75949de63cfa6dc3c57afed960fe8a929495fa56 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Sat, 21 Nov 2026 20:53:36 +0000 Subject: [PATCH] Fix campaign prompt identity resolution --- docs/roadmap/remediation.md | 23 +++++-- .../ckprompt/examples/composed/main.go | 2 +- .../ckprompt/examples/composed/main_test.go | 62 +++++++++++++++++++ 3 files changed, 81 insertions(+), 6 deletions(-) diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index d98ceed..aedd63c 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -1,7 +1,7 @@ # ConfigKit and PromptKit adoption review Reviewed revision: `e70a0ef301a3d34f64a6cba86dd68b728436534d`. -Status: one open finding. Reviewed 2026-11-21. +Status: all findings addressed. Reviewed and remediated 2026-11-21. ## Scope and results @@ -15,7 +15,7 @@ the implementation, changed tests, and documentation. | 2 — Native path enumeration | Optional `View.Paths` and the metadata fallback preserve the distinction between an unavailable reader and an empty native list. Existing metadata-backed filters remain in use. | | 3 — Subtree adapter | The typed loader/path API shares acquisition and diagnostics, delegates focused inspection and comparison, and retains whole-load evidence and native ancestor differences. | | 4 — PromptKit migration | Native inspection supplies the new path capability; fixtures use the new destinations. Native schema, repair-budget, hash, requirements, and supported error evidence pass through the existing adapters. | -| 5 — Shared-load example | Shared loading and storage scope wiring are present, but campaign prompt-ID derivation has the correctness defect in R1. | +| 5 — Shared-load example | Shared loading and storage scope wiring are present. The campaign prompt-ID defect identified in R1 has been corrected. | | 6 — Documentation | Current guidance and candidate notes describe the new APIs and migration, distinguishing candidates from published dependencies. | | 7 — Validation and coordination | Workspace and isolated-local-dependency checks pass. The ckprompt released-dependency limitation and coordinated releases are explicitly pending as planned. | @@ -25,7 +25,14 @@ limitation follows the upstream error contract and is not an integration defect. ## R1 — Campaign prompt-ID changes fail configuration resolution -Priority: P2. Status: open. +Priority: P2. Status: completed 2026-11-21. + +Completion: the resolver now records prompt-ID normalization at the collection +path, retaining the existing reason and campaign dependencies. Added +`TestComposedCampaignPromptID` for a main configuration selecting `custom`; +it verifies successful loading, matching application/engine inspection values, +and the selected ID in the CLI catalog. The test failed before the fix and +passed afterward. The original override reproduction also now succeeds. Relevant code: the application resolve callback in [`loadApplicationConfig`](../../integrations/ckprompt/examples/composed/main.go), @@ -83,5 +90,11 @@ That result does not establish an independent build against the still-selected published ckconfig v0.9.0, as already recorded in [release coordination](future.md#pending-integration-release-coordination). -The R1 reproduction fails despite those passing suites. No production code or -tests were modified during this review. +At review time the R1 reproduction failed despite those passing suites; the +review itself changed no production code or tests. + +After remediation, `GOTOOLCHAIN=local go test ./integrations/ckprompt/... +-count=1` passed with Go 1.27.4, including the composed example and regression. +The isolated ckprompt suite with a temporary local ckconfig replacement also +passed. The original override command now reports a valid app scope and exits +successfully. The published-dependency release coordination remains unchanged. diff --git a/integrations/ckprompt/examples/composed/main.go b/integrations/ckprompt/examples/composed/main.go index 24c8aed..f80221c 100644 --- a/integrations/ckprompt/examples/composed/main.go +++ b/integrations/ckprompt/examples/composed/main.go @@ -135,7 +135,7 @@ func loadApplicationConfig(ctx context.Context, selection ckconfig.Selection, in } if chosen.PromptID != prompt.ID { prompt.ID = chosen.PromptID - resolution.RecordNormalization(promptPath.Index(index).Key("id"), "Selected campaign prompt", deps...) + resolution.RecordNormalization(promptPath, "Selected campaign prompt", deps...) } if prompt.DefaultProfile == nil { prompt.DefaultProfile = new(chosen.ProfileID) diff --git a/integrations/ckprompt/examples/composed/main_test.go b/integrations/ckprompt/examples/composed/main_test.go index dabad2c..f5a16d2 100644 --- a/integrations/ckprompt/examples/composed/main_test.go +++ b/integrations/ckprompt/examples/composed/main_test.go @@ -7,6 +7,8 @@ import ( "errors" "fmt" "io" + "os" + "path/filepath" "reflect" "strings" "testing" @@ -803,3 +805,63 @@ func TestComposedStorageScopeAndSharedResult(t *testing.T) { t.Fatalf("failed load: %#v %q", outcome, diagnostics.String()) } } + +func TestComposedCampaignPromptID(t *testing.T) { + path := filepath.Join(t.TempDir(), "campaign.yml") + if err := os.WriteFile(path, []byte("campaigns:\n spring:\n prompt_id: custom\n profile_id: spring\n model: spring-model\n"), 0600); err != nil { + t.Fatal(err) + } + selection := ckconfigSelection(path) + cache := &runCache{} + input := &inspectionInput{} + result, err := loadApplicationConfig(t.Context(), selection, input, cache) + if err != nil { + t.Fatal(err) + } + engine, err := loadPromptEngine(t.Context(), selection, input, cache) + if err != nil { + t.Fatal(err) + } + view, ok := result.InspectSubtree(configkit.Keys("promptkit")) + if !ok { + t.Fatal("missing application inspection") + } + inspection, err := engine.InspectConfiguration() + if err != nil { + t.Fatal(err) + } + var applicationOutput, engineOutput bytes.Buffer + if err := view.WriteEffective(&applicationOutput); err != nil { + t.Fatal(err) + } + if err := inspection.WriteEffective(&engineOutput); err != nil { + t.Fatal(err) + } + applicationValue, err := commandkit.DecodeYAMLReport(&applicationOutput) + if err != nil { + t.Fatal(err) + } + engineValue, err := commandkit.DecodeYAMLReport(&engineOutput) + if err != nil || !reflect.DeepEqual(applicationValue, engineValue) { + t.Fatalf("shared inspection mismatch: application=%#v engine=%#v error=%v", applicationValue, engineValue, err) + } + app, err := newApp() + if err != nil { + t.Fatal(err) + } + var output, diagnostics bytes.Buffer + outcome := app.Execute(t.Context(), []string{"promptkit", "list", "prompts", "--config=" + path, "--format=json"}, commandkit.Streams{Out: &output, Err: &diagnostics}) + if outcome.Kind != commandkit.OutcomeSuccess { + t.Fatalf("catalog failed: %#v, %s", outcome, diagnostics.String()) + } + var prompts []struct{ ID string } + if err := json.Unmarshal(output.Bytes(), &prompts); err != nil { + t.Fatal(err) + } + for _, prompt := range prompts { + if prompt.ID == "custom" { + return + } + } + t.Fatalf("catalog lacks selected campaign prompt: %s", output.String()) +}