{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sarnai-dev/json-schema/sarnai-dev-verify-schema-request-schema.json",
  "title": "VerifySchemaRequest",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/verify-openapi.json#/components/schemas/VerifySchemaRequest",
  "properties": {
    "task_id": {
      "type": "string",
      "maxLength": 200,
      "minLength": 1,
      "pattern": "^[^\\x00-\\x1f\\x7f]+$",
      "title": "Task Id",
      "description": "Your own identifier for this verification. 1-200 printable characters, no control characters and no lone Unicode surrogate; a request outside that range is rejected (422), not truncated."
    },
    "expected_schema": {
      "additionalProperties": true,
      "type": "object",
      "title": "Expected Schema",
      "description": "Required. The JSON Schema (draft-04 to 2020-12) that submitted_output must satisfy: your own requirements, as a JSON object."
    },
    "submitted_output": {
      "title": "Submitted Output",
      "description": "Required. The output being checked: any JSON value (object, array, string, number, boolean or null), exactly as the AI agent produced it."
    },
    "agent_id": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 200,
          "minLength": 1,
          "pattern": "^[^\\x00-\\x1f\\x7f]+$"
        },
        {
          "type": "null"
        }
      ],
      "title": "Agent Id",
      "description": "Optional label identifying the AI agent that produced submitted_output (for example, the seller), used for /reputation and the trust score: records and scores belong to the producer, not to whoever calls this endpoint. It is an unauthenticated label. agent_ids starting with 'test-' are reserved for testing: the verification runs normally but is never recorded, so it cannot affect any reputation or trust score. 1-200 printable characters (same rule as GET /score/{agent_id}); a longer or malformed value is rejected (422), not truncated."
    },
    "strict_content_check": {
      "type": "boolean",
      "title": "Strict Content Check",
      "description": "Opt-in. When true, any string in submitted_output containing control characters (e.g. null bytes) or embedded HTML/script markup makes the result 'fail'. When false (default) this is not checked at all.",
      "default": false
    },
    "bounds": {
      "anyOf": [
        {
          "additionalProperties": {
            "$ref": "#/$defs/Bound"
          },
          "type": "object",
          "maxProperties": 50
        },
        {
          "type": "null"
        }
      ],
      "title": "Bounds",
      "description": "Optional per-field min/max, keyed by dotted path with '[]' array wildcard (e.g. 'items[].price'). Numbers or ISO-8601 dates. Violations are reported as informational flags unless enforce_rules is true."
    },
    "rules": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/ConsistencyRule"
          },
          "type": "array",
          "maxItems": 50
        },
        {
          "type": "null"
        }
      ],
      "title": "Rules",
      "description": "Optional cross-field rules: sum_equals, gte, lte, exists_in, unique (duplicate detection). Violations are reported as informational flags unless enforce_rules is true."
    },
    "enforce_rules": {
      "type": "boolean",
      "title": "Enforce Rules",
      "description": "Opt-in. When true, every configured bound and consistency rule must hold, or the result is 'fail' (like strict_content_check), with an 'enforce_rules: ...' entry in errors. That includes a rule or bound that cannot run (its path is missing, a value is not comparable, a value has nothing to be compared against): it fails rather than passing silently, so omitting a field, in the whole path or in any array element the rule applies to, cannot skip a binding rule. A rule or bound with if_present: true is skipped where its field is absent instead. When false (default) nothing changes: violations and unrunnable rules stay informational flags. Echoed back in the signed response.",
      "default": false
    },
    "detail": {
      "type": "string",
      "enum": [
        "full",
        "compact"
      ],
      "title": "Detail",
      "description": "'full' (default) returns everything; 'compact' returns only the summary, next actions, receipt and signature. Use compact inside verify-repair loops to save tokens. 'compact' fields: summary, next_actions, result, the receipt fields (verification_id, task_id, agent_id, output_hash, schema_hash, rules_hash, verified_at, verifier_version, enforce_rules, strict_content_check), verify and attestation - errors, errors_detail, flags, hints and the scores are left out entirely, not just emptied. Both shapes are fully signed.",
      "default": "full"
    }
  },
  "type": "object",
  "required": [
    "task_id",
    "expected_schema",
    "submitted_output"
  ],
  "$defs": {
    "Bound": {
      "properties": {
        "min": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Min"
        },
        "max": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Max"
        },
        "if_present": {
          "type": "boolean",
          "title": "If Present",
          "description": "Optional. When true, the check is skipped where this field is absent (the whole path, or an element of an array it applies to) instead of being reported as unable to run: no flag, and enforce_rules does not fail on it. When false (default) an absent field is a flag, and a failure under enforce_rules.",
          "default": false
        }
      },
      "type": "object",
      "title": "Bound",
      "description": "Optional inclusive min/max for one field. Numbers, or ISO-8601 date /\ndatetime strings (compared as datetimes; naive values are treated as UTC)."
    },
    "ConsistencyRule": {
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "sum_equals",
            "gte",
            "lte",
            "exists_in",
            "unique"
          ],
          "title": "Type"
        },
        "field": {
          "type": "string",
          "title": "Field"
        },
        "equals_field": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Equals Field"
        },
        "equals": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Equals"
        },
        "other_field": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Other Field"
        },
        "value": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Value"
        },
        "in_field": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "In Field"
        },
        "values": {
          "anyOf": [
            {
              "items": {},
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Values"
        },
        "tolerance": {
          "type": "number",
          "minimum": 0.0,
          "title": "Tolerance",
          "description": "Absolute tolerance for sum_equals and the near-match check gte/lte use. The default (1e-9) suits exact arithmetic but is usually too tight for money that passed through any floating-point math (e.g. percentage discounts, tax, unit-price * quantity): 0.1 + 0.2 != 0.3 in IEEE-754 floats by about 5.5e-17, and real pricing data regularly carries larger rounding drift than that. For a field in major currency units (dollars, euros), 0.01 (one cent) is a reasonable tolerance; for minor units (cents) already stored as integers, the default is fine. Too loose a tolerance can mask a genuine mismatch, so prefer the smallest value that tolerates your data's own rounding, not a large one 'to be safe.'",
          "default": 1e-09
        },
        "if_present": {
          "type": "boolean",
          "title": "If Present",
          "description": "Optional. When true, the check is skipped where this field is absent (the whole path, or an element of an array it applies to) instead of being reported as unable to run: no flag, and enforce_rules does not fail on it. When false (default) an absent field is a flag, and a failure under enforce_rules. Applies to this rule's own `field`; fields it refers to (equals_field, other_field, in_field) must still exist.",
          "default": false
        }
      },
      "type": "object",
      "required": [
        "type",
        "field"
      ],
      "title": "ConsistencyRule",
      "description": "One caller-supplied cross-field rule. Paths use dotted keys with '[]'\nas an array wildcard, e.g. 'items[].price' or 'order.total'.\n\n  sum_equals: sum of `field` values == `equals_field` value (or `equals`)\n  gte / lte:  `field` >= / <= `other_field` value (or `value`)\n  exists_in:  every `field` value is among `in_field` values (or `values`)\n  unique:     no duplicates among `field` values; if `field` names an\n              array itself, no duplicate elements in it"
    }
  }
}