Document prompt-owned schemas and finalize migration

This commit is contained in:
2026-11-20 15:46:39 +00:00
parent 9bed36282a
commit e9a12d43c2
16 changed files with 174 additions and 106 deletions

View File

@@ -39,7 +39,7 @@ const (
ValidationBasic ValidationMode = "basic"
// ValidationJSON requires syntactically valid JSON.
ValidationJSON ValidationMode = "json"
// ValidationJSONSchema requires JSON that satisfies OutputContract.SchemaPath.
// ValidationJSONSchema requires JSON satisfying the selected schema.
ValidationJSONSchema ValidationMode = "json_schema"
)
@@ -494,7 +494,11 @@ type ExecutionTargetPresence struct {
//
// A non-nil RunRequest.Validation replaces the complete prompt contract. It
// does not merge fields. The public Engine performs bounded correction after a
// failed eligible validation when RepairAttempts is positive.
// failed eligible validation when RepairAttempts is positive. A JSON Schema
// request replacement requires exactly one of Schema and SchemaPath; other
// modes ignore them. A replacement uses the prompt's configured root for
// SchemaPath. For a configured source-relative file, prepared output contracts
// expose neither selection; StructuredOutput contains the selected document.
type OutputContract struct {
// Format selects generated artifact metadata. An empty value in a non-nil
// request replacement defaults to FormatText.
@@ -502,7 +506,9 @@ type OutputContract struct {
// ValidationMode selects the content check. Use one of the declared
// ValidationMode constants.
ValidationMode ValidationMode `json:"validation_mode"`
// Schema supplies an inline JSON Schema. Nil means no inline selection.
// Schema supplies an inline JSON Schema. Nil or a value encoding as JSON
// null means no selection; false and an empty object are selections. In
// JSON Schema mode the value must be JSON-encodable.
Schema any `json:"schema,omitempty"`
// SchemaPath identifies a schema under the applicable configured root.
SchemaPath string `json:"schema_path"`
@@ -522,7 +528,8 @@ type ValidationResult struct {
Mode ValidationMode `json:"mode"`
// Errors contains validation diagnostics when Status is ValidationFailed.
Errors []string `json:"errors,omitempty"`
// SchemaPath is the effective schema path for JSON Schema validation.
// SchemaPath is the explicit-root path for JSON Schema validation. It is
// empty for inline and source-relative schema selections.
SchemaPath string `json:"schema_path,omitempty"`
// RepairAttempts is the number of corrective generation calls actually
// started for this result.