Add generic raw output validators
This commit is contained in:
@@ -248,9 +248,10 @@ type Validator interface {
|
||||
}
|
||||
|
||||
type ResponseSchema struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
JSONSchema []byte `json:"-"`
|
||||
}
|
||||
|
||||
type ExtractOutput struct {
|
||||
|
||||
@@ -322,6 +322,32 @@ func TestLLMInputSetCloneCopiesContent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseSchemaJSONOmitRawSchemaContent(t *testing.T) {
|
||||
schema := ResponseSchema{
|
||||
ID: "schema-id",
|
||||
Name: "schema-name",
|
||||
Version: "v1",
|
||||
JSONSchema: []byte(`{"type":"object"}`),
|
||||
}
|
||||
encoded, err := json.Marshal(schema)
|
||||
if err != nil {
|
||||
t.Fatalf("json.Marshal() error = %v, want nil", err)
|
||||
}
|
||||
var got map[string]any
|
||||
if err := json.Unmarshal(encoded, &got); err != nil {
|
||||
t.Fatalf("json.Unmarshal() error = %v, want nil", err)
|
||||
}
|
||||
if got["id"] != "schema-id" || got["name"] != "schema-name" || got["version"] != "v1" {
|
||||
t.Fatalf("encoded schema = %#v, want schema provenance", got)
|
||||
}
|
||||
if _, ok := got["json_schema"]; ok {
|
||||
t.Fatalf("encoded schema leaked raw schema content: %s", encoded)
|
||||
}
|
||||
if _, ok := got["JSONSchema"]; ok {
|
||||
t.Fatalf("encoded schema leaked raw schema content: %s", encoded)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFakeMergeNormalizeAndOutputContracts(t *testing.T) {
|
||||
extractOutput := ExtractOutput{
|
||||
LaneID: "generic-lane",
|
||||
|
||||
Reference in New Issue
Block a user