From 2c436d14d941a0697e554f00946a5a70783e432d Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Fri, 20 Nov 2026 16:20:27 +0000 Subject: [PATCH] Keep prompt selection free of schema payloads --- docs/roadmap/remediation.md | 7 +++++- internal/configuration/interpretation_test.go | 2 +- internal/configuration/prompts.go | 2 -- internal/configuration/schema_capture_test.go | 22 +++++++++++++++++++ internal/domain/domain.go | 1 - internal/usecase/runner_test.go | 2 +- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index fa00d8d..44f7f00 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -75,9 +75,14 @@ the existing active-schema ownership coverage. ## 2. P2 — Keep Lightweight Prompt Selection Independent Of Inline Schemas -Status: open. Identified by the follow-up integration audit. Relevant stages: +Status: complete. Identified by the follow-up integration audit. Relevant stages: 1, 3, and 5. +Resolution: removed the output contract from the internal lightweight selection +type and its fixture/projection paths. Selection no longer visits schema trees; +the full resource and execution views retain their schema data. Focused selection, +requirements, smoke, and schema tests pass. + Locations: - `internal/configuration/prompts.go:147`: the internal requirement-selection diff --git a/internal/configuration/interpretation_test.go b/internal/configuration/interpretation_test.go index 32c4961..6b0de6b 100644 --- a/internal/configuration/interpretation_test.go +++ b/internal/configuration/interpretation_test.go @@ -73,7 +73,7 @@ func TestPromptResolutionNormalizesOutputAndRejectsDuplicateNames(t *testing.T) t.Fatal(err) } selected, inspection, err := state.prompt("example") - if err != nil || selected.Validation.SchemaPath != "schema.json" || inspection.OutputContract.SchemaPath != "schema.json" || selected.Inputs[0].Name != "document" { + if err != nil || selected.Validation.SchemaPath != "schema.json" || selected.Inputs[0].Name != "document" { t.Fatalf("interpreted prompt = %+v, %+v, %v", selected, inspection, err) } composed := state.result.Config.Prompts[0] diff --git a/internal/configuration/prompts.go b/internal/configuration/prompts.go index aede9c6..7156a70 100644 --- a/internal/configuration/prompts.go +++ b/internal/configuration/prompts.go @@ -147,7 +147,6 @@ func (state *loaded) materializePrompt(id string, raw promptConfig, base configk entry.inspection = domain.PromptInspection{ PromptID: id, PromptHash: hash, DefaultProfileID: definition.DefaultProfile, Inputs: append([]domain.PromptInput(nil), definition.Inputs...), - OutputContract: contract, } return entry, nil } @@ -349,7 +348,6 @@ func ownPromptDefinition(definition domain.PromptDefinition) *domain.PromptDefin } func ownPromptInspection(inspection domain.PromptInspection) *domain.PromptInspection { - inspection.OutputContract = ownOutputContract(inspection.OutputContract) inspection.Inputs = append([]domain.PromptInput(nil), inspection.Inputs...) return &inspection } diff --git a/internal/configuration/schema_capture_test.go b/internal/configuration/schema_capture_test.go index 721216f..1fef226 100644 --- a/internal/configuration/schema_capture_test.go +++ b/internal/configuration/schema_capture_test.go @@ -14,6 +14,28 @@ func schemaPrompt(id string, output map[string]any) map[string]any { return map[string]any{"id": id, "messages": []any{map[string]any{"role": "user", "content": "hello"}}, "output": output} } +func TestLightweightPromptSelectionKeepsSchemaInResourceView(t *testing.T) { + schema := map[string]any{"type": "object", "examples": make([]any, 1024)} + definition := schemaPrompt("selected", map[string]any{"format": "json", "validation_mode": "json_schema", "schema": schema}) + definition["default_profile"] = "partial" + state, err := load(mapping("selection", map[string]any{ + "profiles": []any{map[string]any{"id": "partial"}}, + "prompts": []any{definition}, + }), nil) + if err != nil { + t.Fatal(err) + } + selection, err := state.GetPromptInspection(context.Background(), "selected") + if err != nil || selection.PromptID != "selected" || selection.DefaultProfileID != "partial" { + t.Fatalf("selection = %+v, %v", selection, err) + } + // The selection type has no output contract; the full resource view still does. + resource, err := state.InspectPrompt(context.Background(), "selected") + if err != nil || resource.Output.Schema.(map[string]any)["type"] != "object" { + t.Fatalf("resource schema = %+v, %v", resource, err) + } +} + func TestSchemaFileCaptureUsesEffectiveSource(t *testing.T) { first := configkit.NewFilesystem("first", fstest.MapFS{"a/placeholder": {Data: []byte("x")}, "a/schema.json": {Data: []byte("first")}}) second := configkit.NewFilesystem("second", fstest.MapFS{"b/placeholder": {Data: []byte("x")}, "b/schema.json": {Data: []byte("second")}}) diff --git a/internal/domain/domain.go b/internal/domain/domain.go index e835d89..7c4aeaf 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -167,7 +167,6 @@ type PromptInspection struct { PromptHash string DefaultProfileID string Inputs []PromptInput - OutputContract OutputContract } // PromptInput describes one named input expected by a prompt definition. diff --git a/internal/usecase/runner_test.go b/internal/usecase/runner_test.go index 17f7ba3..6ac81c6 100644 --- a/internal/usecase/runner_test.go +++ b/internal/usecase/runner_test.go @@ -97,7 +97,7 @@ func fixturePromptInspection(definition *domain.PromptDefinition, hash string) * } return &domain.PromptInspection{ PromptID: definition.ID, PromptHash: hash, DefaultProfileID: definition.DefaultProfile, - Inputs: append([]domain.PromptInput(nil), definition.Inputs...), OutputContract: definition.Validation, + Inputs: append([]domain.PromptInput(nil), definition.Inputs...), } }