Document prompt-owned schemas and finalize migration
This commit is contained in:
@@ -10,11 +10,17 @@ import (
|
||||
|
||||
func TestPreparationRejectsInvalidOutputContractWithPublicError(t *testing.T) {
|
||||
engine := newSimpleEngine(t, "message")
|
||||
cycle := map[string]any{}
|
||||
cycle["self"] = cycle
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
contract promptkit.OutputContract
|
||||
}{
|
||||
{
|
||||
name: "cyclic inline schema",
|
||||
contract: promptkit.OutputContract{Format: promptkit.FormatJSON, ValidationMode: promptkit.ValidationJSONSchema, Schema: cycle},
|
||||
},
|
||||
{
|
||||
name: "inline schema cannot be encoded",
|
||||
contract: promptkit.OutputContract{
|
||||
@@ -67,3 +73,18 @@ func TestPreparationRejectsInvalidOutputContractWithPublicError(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInactiveSchemaDoesNotInterpretCyclicValue(t *testing.T) {
|
||||
cycle := map[string]any{}
|
||||
cycle["self"] = cycle
|
||||
engine := newSimpleEngine(t, "message")
|
||||
prepared, err := engine.Prepare(context.Background(), promptkit.RunRequest{PromptID: "prompt", Validation: &promptkit.OutputContract{Format: promptkit.FormatText, ValidationMode: promptkit.ValidationNone, Schema: cycle}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
copy := prepared.OutputContract.Schema.(map[string]any)
|
||||
copy["self"].(map[string]any)["changed"] = true
|
||||
if copy["changed"] != true || cycle["changed"] != nil {
|
||||
t.Fatal("inactive schema copy shares caller storage")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user