Keep prompt selection free of schema payloads

This commit is contained in:
2026-11-20 16:20:27 +00:00
parent 1bfb6eb301
commit 2c436d14d9
6 changed files with 30 additions and 6 deletions

View File

@@ -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

View File

@@ -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]

View File

@@ -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
}

View File

@@ -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")}})

View File

@@ -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.

View File

@@ -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...),
}
}