{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "/schemas/3.1.0-rc.4/content-standards/validate-content-delivery-response.json",
  "title": "Validate Content Delivery Response",
  "description": "Response payload with per-record verdicts and optional feature breakdown",
  "type": "object",
  "allOf": [
    {
      "$ref": "/schemas/3.1.0-rc.4/core/version-envelope.json"
    },
    {
      "$ref": "/schemas/3.1.0-rc.4/core/protocol-envelope.json"
    }
  ],
  "oneOf": [
    {
      "type": "object",
      "description": "Success response",
      "properties": {
        "summary": {
          "type": "object",
          "description": "Summary counts across all records",
          "properties": {
            "total_records": {
              "type": "integer"
            },
            "passed_records": {
              "type": "integer"
            },
            "failed_records": {
              "type": "integer"
            }
          },
          "required": [
            "total_records",
            "passed_records",
            "failed_records"
          ]
        },
        "results": {
          "type": "array",
          "description": "Per-record evaluation results",
          "items": {
            "type": "object",
            "properties": {
              "record_id": {
                "type": "string",
                "description": "Which delivery record was evaluated"
              },
              "verdict": {
                "$ref": "/schemas/3.1.0-rc.4/enums/binary-verdict.json"
              },
              "features": {
                "type": "array",
                "description": "Per-feature breakdown. When present, SHOULD include all failed and warning features. MAY include passed features. Oracle pattern: exposes verdict + rule pointer, never the seller's threshold or the caller's submitted value (the seller authored the content standards).",
                "items": {
                  "type": "object",
                  "properties": {
                    "feature_id": {
                      "type": "string",
                      "description": "Which feature was evaluated. Data features come from the content-standards feature catalog (e.g., 'brand_safety', 'brand_suitability', 'image_dpi'). Record-level structural checks use reserved namespaces: 'record:malformed_artifact', 'delivery:authorization'. Reserved prefixes: 'record:', 'delivery:'."
                    },
                    "status": {
                      "$ref": "/schemas/3.1.0-rc.4/enums/feature-check-status.json"
                    },
                    "policy_id": {
                      "type": "string",
                      "description": "Registry policy ID that triggered this result. Present when the result originates from a specific registry policy (e.g., GARM category, CSBS standard). Enables programmatic routing by looking up the policy in the registry.",
                      "x-entity": "governance_registry_policy"
                    },
                    "explanation": {
                      "type": "string",
                      "description": "Directional human-readable explanation (e.g., 'Below minimum resolution for display placement'). Avoid quantitative thresholds — the evaluator is the oracle."
                    },
                    "confidence": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1,
                      "description": "Optional evaluator confidence in this result (0-1). Distinguishes certain verdicts from ambiguous ones."
                    }
                  },
                  "required": [
                    "feature_id",
                    "status"
                  ]
                }
              }
            },
            "required": [
              "record_id",
              "verdict"
            ]
          }
        },
        "context": {
          "$ref": "/schemas/3.1.0-rc.4/core/context.json"
        },
        "ext": {
          "$ref": "/schemas/3.1.0-rc.4/core/ext.json"
        }
      },
      "required": [
        "summary",
        "results"
      ]
    },
    {
      "type": "object",
      "description": "Error response",
      "properties": {
        "errors": {
          "type": "array",
          "items": {
            "$ref": "/schemas/3.1.0-rc.4/core/error.json"
          }
        },
        "context": {
          "$ref": "/schemas/3.1.0-rc.4/core/context.json"
        },
        "ext": {
          "$ref": "/schemas/3.1.0-rc.4/core/ext.json"
        }
      },
      "required": [
        "errors"
      ]
    }
  ],
  "properties": {}
}
