{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.querentdata.com/schema/1.0.0-rc.1/geo-delivery-1.0.0-rc.1.schema.json",
  "title": "GEO delivery contract 1.0.0-rc.1 — review candidate",
  "description": "Review candidate, not client approval. Structural validation must be followed by the companion semantic validator and independent evidence checks.",
  "type": "object",
  "properties": {
    "schema_version": {
      "const": "1.0.0-rc.1"
    },
    "delivery": {
      "$ref": "#/$defs/delivery"
    },
    "collection_run": {
      "$ref": "#/$defs/collection_run"
    },
    "brands": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/brand"
      },
      "minItems": 1
    },
    "prompts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/prompt"
      },
      "minItems": 1
    },
    "samples": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/sample"
      },
      "minItems": 0
    },
    "failures": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/failure"
      },
      "minItems": 0
    }
  },
  "required": [
    "schema_version",
    "delivery",
    "collection_run",
    "brands",
    "prompts",
    "samples",
    "failures"
  ],
  "additionalProperties": false,
  "$defs": {
    "unavailable_reasons": {
      "type": "object",
      "propertyNames": {
        "pattern": "^(?:/(?:[^~/]|~[01])*)+$"
      },
      "additionalProperties": {
        "type": "string",
        "minLength": 1
      },
      "minProperties": 1
    },
    "range": {
      "type": "object",
      "properties": {
        "start": {
          "type": "integer",
          "minimum": 0
        },
        "end": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    },
    "answer_link": {
      "type": "object",
      "properties": {
        "quote": {
          "type": "string",
          "minLength": 1
        },
        "start": {
          "type": "integer",
          "minimum": 0
        },
        "end": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "quote",
        "start",
        "end"
      ],
      "additionalProperties": false
    },
    "acceptance_profile": {
      "type": "object",
      "properties": {
        "confirmation_state": {
          "type": "string",
          "enum": [
            "proposed",
            "confirmed"
          ]
        },
        "approval_reference": {
          "type": "string",
          "minLength": 1
        },
        "require_logged_in": {
          "type": "boolean"
        },
        "require_original_prompt": {
          "type": "boolean"
        },
        "require_complete_answer": {
          "type": "boolean"
        },
        "require_complete_citations": {
          "type": "boolean"
        },
        "require_complete_screenshots": {
          "type": "boolean"
        },
        "require_verified_geography": {
          "type": "boolean"
        },
        "require_all_brand_evaluations": {
          "type": "boolean"
        }
      },
      "required": [
        "confirmation_state",
        "require_logged_in",
        "require_original_prompt",
        "require_complete_answer",
        "require_complete_citations",
        "require_complete_screenshots",
        "require_verified_geography",
        "require_all_brand_evaluations"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "confirmation_state": {
                "enum": [
                  "confirmed"
                ]
              }
            },
            "required": [
              "confirmation_state"
            ]
          },
          "then": {
            "required": [
              "approval_reference"
            ]
          }
        }
      ]
    },
    "plan": {
      "type": "object",
      "properties": {
        "plan_id": {
          "type": "string",
          "minLength": 1
        },
        "prompt_id": {
          "type": "string",
          "minLength": 1
        },
        "platform": {
          "type": "string",
          "minLength": 1
        },
        "sample_index": {
          "type": "integer",
          "minimum": 1
        },
        "outcome": {
          "type": "string",
          "enum": [
            "accepted",
            "failed",
            "excluded"
          ]
        },
        "final_sample_id": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "plan_id",
        "prompt_id",
        "platform",
        "sample_index",
        "outcome"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "outcome": {
                "enum": [
                  "accepted"
                ]
              }
            },
            "required": [
              "outcome"
            ]
          },
          "then": {
            "required": [
              "final_sample_id"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "outcome": {
                "enum": [
                  "failed"
                ]
              }
            },
            "required": [
              "outcome"
            ]
          },
          "then": {
            "not": {
              "required": [
                "final_sample_id"
              ]
            }
          }
        }
      ]
    },
    "delivery": {
      "type": "object",
      "properties": {
        "delivery_id": {
          "type": "string",
          "minLength": 1
        },
        "delivered_at_utc": {
          "type": "string",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
        },
        "planned_sample_count": {
          "type": "integer",
          "minimum": 0
        },
        "delivered_sample_count": {
          "type": "integer",
          "minimum": 0
        },
        "recorded_sample_count": {
          "type": "integer",
          "minimum": 0
        },
        "failed_final_count": {
          "type": "integer",
          "minimum": 0
        },
        "repeats_per_prompt": {
          "type": "integer",
          "minimum": 1
        },
        "aggregation_note": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "delivery_id",
        "delivered_at_utc",
        "planned_sample_count",
        "delivered_sample_count",
        "recorded_sample_count",
        "failed_final_count"
      ],
      "additionalProperties": false
    },
    "collection_run": {
      "type": "object",
      "properties": {
        "collector_version": {
          "type": "string",
          "minLength": 1
        },
        "annotation": {
          "type": "object",
          "properties": {
            "method": {
              "type": "string",
              "enum": [
                "rule",
                "llm",
                "human",
                "hybrid"
              ]
            },
            "version": {
              "type": "string",
              "minLength": 1
            },
            "reviewed_by": {
              "type": "string",
              "enum": [
                "none",
                "sampled",
                "full"
              ]
            }
          },
          "required": [
            "method",
            "version",
            "reviewed_by"
          ],
          "additionalProperties": false
        },
        "translation": {
          "type": "object",
          "properties": {
            "method": {
              "type": "string",
              "enum": [
                "none",
                "machine",
                "human"
              ]
            },
            "source_language": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "method"
          ],
          "additionalProperties": false
        },
        "sample_plan": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/plan"
          },
          "minItems": 1
        },
        "acceptance_profile": {
          "$ref": "#/$defs/acceptance_profile"
        },
        "evidence_policy": {
          "type": "object",
          "properties": {
            "availability_until_utc": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "refresh_method": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "availability_until_utc",
            "refresh_method"
          ],
          "additionalProperties": false
        },
        "unavailable_reasons": {
          "$ref": "#/$defs/unavailable_reasons"
        }
      },
      "required": [
        "collector_version",
        "annotation",
        "sample_plan",
        "acceptance_profile",
        "evidence_policy"
      ],
      "additionalProperties": false
    },
    "brand": {
      "type": "object",
      "properties": {
        "brand_id": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "excluded_aliases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "brand_type": {
          "type": "string",
          "enum": [
            "client",
            "competitor",
            "industry_reference"
          ]
        },
        "location_text": {
          "type": "string",
          "minLength": 1
        },
        "official_domains": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0,
          "uniqueItems": true
        }
      },
      "required": [
        "brand_id",
        "name",
        "aliases",
        "brand_type"
      ],
      "additionalProperties": false
    },
    "prompt": {
      "type": "object",
      "properties": {
        "prompt_id": {
          "type": "string",
          "minLength": 1
        },
        "original": {
          "type": "string",
          "minLength": 1
        },
        "language": {
          "type": "string",
          "minLength": 1
        },
        "intent": {
          "type": "string",
          "enum": [
            "brand_intro",
            "comparison",
            "recommendation",
            "reputation",
            "how_to",
            "other"
          ]
        },
        "topic_tags": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "monitored_brand_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1,
          "uniqueItems": true
        },
        "brands_in_prompt": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0,
          "uniqueItems": true
        }
      },
      "required": [
        "prompt_id",
        "original",
        "language",
        "intent",
        "monitored_brand_ids",
        "brands_in_prompt"
      ],
      "additionalProperties": false
    },
    "geography": {
      "type": "object",
      "properties": {
        "country": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "city": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "source": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "observed_at_utc": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "country",
        "source",
        "observed_at_utc"
      ],
      "additionalProperties": false
    },
    "environment": {
      "type": "object",
      "properties": {
        "account_state": {
          "type": "string",
          "enum": [
            "logged_in",
            "logged_out",
            "unknown"
          ]
        },
        "model_ui": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "search_enabled": {
          "type": "string",
          "enum": [
            "on",
            "off",
            "auto",
            "unknown"
          ]
        },
        "search_ui": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "conversation_state": {
          "type": "string",
          "enum": [
            "new_chat",
            "continued",
            "unknown"
          ]
        },
        "memory_personalization": {
          "type": "string",
          "enum": [
            "off",
            "on",
            "unknown"
          ]
        },
        "ui_language": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "network_geography": {
          "$ref": "#/$defs/geography"
        }
      },
      "required": [
        "account_state",
        "model_ui",
        "search_enabled",
        "conversation_state",
        "memory_personalization",
        "ui_language",
        "network_geography"
      ],
      "additionalProperties": false
    },
    "mention": {
      "type": "object",
      "properties": {
        "name_in_answer": {
          "type": "string",
          "minLength": 1
        },
        "evidence_quote": {
          "type": "string",
          "minLength": 1
        },
        "start": {
          "type": "integer",
          "minimum": 0
        },
        "end": {
          "type": "integer",
          "minimum": 0
        },
        "name_start": {
          "type": "integer",
          "minimum": 0
        },
        "name_end": {
          "type": "integer",
          "minimum": 0
        },
        "position_kind": {
          "type": "string",
          "enum": [
            "ordered_list",
            "unordered_list",
            "inline",
            "comparison"
          ]
        },
        "list_position": {
          "type": "integer",
          "minimum": 1
        },
        "sentiment": {
          "type": "string",
          "enum": [
            "positive",
            "neutral",
            "negative",
            "mixed"
          ]
        },
        "citation_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "factual_issue": {
          "type": "string",
          "enum": [
            "none",
            "suspected",
            "confirmed"
          ]
        }
      },
      "required": [
        "name_in_answer",
        "evidence_quote",
        "start",
        "end",
        "name_start",
        "name_end",
        "citation_ids"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "position_kind": {
                "enum": [
                  "ordered_list"
                ]
              }
            },
            "required": [
              "position_kind"
            ]
          },
          "then": {
            "required": [
              "list_position"
            ]
          }
        },
        {
          "if": {
            "required": [
              "list_position"
            ]
          },
          "then": {
            "required": [
              "position_kind"
            ],
            "properties": {
              "position_kind": {
                "const": "ordered_list"
              }
            }
          }
        }
      ]
    },
    "brand_result": {
      "type": "object",
      "properties": {
        "brand_id": {
          "type": "string",
          "minLength": 1
        },
        "mention_status": {
          "type": "string",
          "enum": [
            "mentioned",
            "not_mentioned",
            "uncertain",
            "not_evaluated"
          ]
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "mentions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/mention"
          },
          "minItems": 0
        }
      },
      "required": [
        "brand_id",
        "mention_status",
        "mentions"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "mention_status": {
                "enum": [
                  "uncertain",
                  "not_evaluated"
                ]
              }
            },
            "required": [
              "mention_status"
            ]
          },
          "then": {
            "required": [
              "reason"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "mention_status": {
                "enum": [
                  "mentioned",
                  "uncertain"
                ]
              }
            },
            "required": [
              "mention_status"
            ]
          },
          "then": {
            "properties": {
              "mentions": {
                "minItems": 1
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "mention_status": {
                "enum": [
                  "not_mentioned",
                  "not_evaluated"
                ]
              }
            },
            "required": [
              "mention_status"
            ]
          },
          "then": {
            "properties": {
              "mentions": {
                "maxItems": 0
              }
            }
          }
        }
      ]
    },
    "entity": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "evidence_quote": {
          "type": "string",
          "minLength": 1
        },
        "start": {
          "type": "integer",
          "minimum": 0
        },
        "end": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "name",
        "evidence_quote",
        "start",
        "end"
      ],
      "additionalProperties": false
    },
    "surface": {
      "type": "object",
      "properties": {
        "surface": {
          "type": "string",
          "enum": [
            "source_panel",
            "inline",
            "search_result",
            "footnote"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "complete",
            "partial",
            "none_shown",
            "not_checked",
            "unavailable"
          ]
        },
        "captured_count": {
          "type": "integer",
          "minimum": 0
        },
        "displayed_total": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "null"
            }
          ]
        },
        "scope_note": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "surface",
        "status",
        "captured_count"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "enum": [
                  "partial",
                  "not_checked",
                  "unavailable"
                ]
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "required": [
              "scope_note"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "status": {
                "enum": [
                  "none_shown",
                  "not_checked",
                  "unavailable"
                ]
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "properties": {
              "captured_count": {
                "const": 0
              }
            }
          }
        }
      ]
    },
    "occurrence": {
      "type": "object",
      "properties": {
        "occurrence_id": {
          "type": "string",
          "minLength": 1
        },
        "surface": {
          "type": "string",
          "enum": [
            "source_panel",
            "inline",
            "search_result",
            "footnote",
            "unknown"
          ]
        },
        "display_order": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "citation_marker": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "answer_links": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/answer_link"
          },
          "minItems": 0
        }
      },
      "required": [
        "occurrence_id",
        "surface",
        "answer_links"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "surface": {
                "enum": [
                  "source_panel",
                  "search_result",
                  "footnote"
                ]
              }
            },
            "required": [
              "surface"
            ]
          },
          "then": {
            "required": [
              "display_order"
            ]
          }
        }
      ]
    },
    "citation": {
      "type": "object",
      "properties": {
        "citation_id": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "url": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri",
              "pattern": "^https?://[^\\s]+$"
            },
            {
              "type": "null"
            }
          ]
        },
        "final_url": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri",
              "pattern": "^https?://[^\\s]+$"
            },
            {
              "type": "null"
            }
          ]
        },
        "domain": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "excerpt": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "source_type": {
          "type": "string",
          "enum": [
            "official_brand",
            "government",
            "media",
            "health_platform",
            "ugc",
            "academic",
            "encyclopedia",
            "other",
            "unknown"
          ]
        },
        "owner_brand_id": {
          "type": "string",
          "minLength": 1
        },
        "fetch_status": {
          "type": "string",
          "enum": [
            "ok",
            "failed",
            "not_attempted"
          ]
        },
        "occurrences": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/occurrence"
          },
          "minItems": 1
        }
      },
      "required": [
        "citation_id",
        "url",
        "source_type",
        "fetch_status",
        "occurrences"
      ],
      "additionalProperties": false
    },
    "citations": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "complete",
            "partial",
            "none_shown",
            "not_checked"
          ]
        },
        "checked_surfaces": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "source_panel",
              "inline",
              "search_result",
              "footnote"
            ]
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "scope_note": {
          "type": "string",
          "minLength": 1
        },
        "surfaces": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/surface"
          },
          "minItems": 4
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/citation"
          },
          "minItems": 0
        }
      },
      "required": [
        "status",
        "checked_surfaces",
        "surfaces",
        "items"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "enum": [
                  "partial"
                ]
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "required": [
              "scope_note"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "status": {
                "enum": [
                  "none_shown",
                  "not_checked"
                ]
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "properties": {
              "items": {
                "maxItems": 0
              }
            }
          }
        }
      ]
    },
    "screenshot": {
      "type": "object",
      "properties": {
        "sequence": {
          "type": "integer",
          "minimum": 1
        },
        "kind": {
          "type": "string",
          "enum": [
            "answer",
            "citations",
            "search_result",
            "settings",
            "other"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https?://[^\\s]+$"
        },
        "access_mode": {
          "type": "string",
          "enum": [
            "public",
            "signed_url"
          ]
        },
        "expires_at_utc": {
          "type": "string",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
        },
        "sha256": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "width": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "height": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "captured_at_utc": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "access_checked_at_utc": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "answer_ranges": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/range"
          },
          "minItems": 0
        },
        "citation_occurrence_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0,
          "uniqueItems": true
        }
      },
      "required": [
        "sequence",
        "kind",
        "url",
        "access_mode",
        "sha256",
        "width",
        "height",
        "captured_at_utc",
        "access_checked_at_utc",
        "answer_ranges",
        "citation_occurrence_ids"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "access_mode": {
                "enum": [
                  "signed_url"
                ]
              }
            },
            "required": [
              "access_mode"
            ]
          },
          "then": {
            "required": [
              "expires_at_utc"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "access_mode": {
                "enum": [
                  "public"
                ]
              }
            },
            "required": [
              "access_mode"
            ]
          },
          "then": {
            "not": {
              "required": [
                "expires_at_utc"
              ]
            }
          }
        }
      ]
    },
    "raw_capture": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "dom_snapshot",
            "network_response",
            "html"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https?://[^\\s]+$"
        },
        "sha256": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "contains_pii": {
          "const": false
        },
        "access_mode": {
          "type": "string",
          "enum": [
            "public",
            "signed_url"
          ]
        },
        "expires_at_utc": {
          "type": "string",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
        }
      },
      "required": [
        "kind",
        "url",
        "sha256",
        "contains_pii",
        "access_mode"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "access_mode": {
                "enum": [
                  "signed_url"
                ]
              }
            },
            "required": [
              "access_mode"
            ]
          },
          "then": {
            "required": [
              "expires_at_utc"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "access_mode": {
                "enum": [
                  "public"
                ]
              }
            },
            "required": [
              "access_mode"
            ]
          },
          "then": {
            "not": {
              "required": [
                "expires_at_utc"
              ]
            }
          }
        }
      ]
    },
    "evidence": {
      "type": "object",
      "properties": {
        "screenshots": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/screenshot"
          },
          "minItems": 0
        },
        "answer_coverage": {
          "type": "string",
          "enum": [
            "complete",
            "partial",
            "not_checked"
          ]
        },
        "citations_coverage": {
          "type": "string",
          "enum": [
            "complete",
            "partial",
            "none_shown",
            "not_checked"
          ]
        },
        "redaction_status": {
          "type": "string",
          "enum": [
            "verified",
            "not_checked"
          ]
        },
        "access_status": {
          "type": "string",
          "enum": [
            "accessible",
            "inaccessible",
            "not_checked"
          ]
        },
        "raw_capture": {
          "$ref": "#/$defs/raw_capture"
        }
      },
      "required": [
        "screenshots",
        "answer_coverage",
        "citations_coverage",
        "redaction_status",
        "access_status"
      ],
      "additionalProperties": false
    },
    "sample": {
      "type": "object",
      "properties": {
        "sample_id": {
          "type": "string",
          "minLength": 1
        },
        "plan_id": {
          "type": "string",
          "minLength": 1
        },
        "prompt_id": {
          "type": "string",
          "minLength": 1
        },
        "platform": {
          "type": "string",
          "minLength": 1
        },
        "sample_index": {
          "type": "integer",
          "minimum": 1
        },
        "attempt_index": {
          "type": "integer",
          "minimum": 1
        },
        "origin": {
          "type": "string",
          "enum": [
            "native_capture",
            "legacy_import",
            "example"
          ]
        },
        "legacy_source": {
          "type": "object",
          "properties": {
            "file_name": {
              "type": "string",
              "minLength": 1
            },
            "sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "record_path": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "file_name",
            "sha256",
            "record_path"
          ],
          "additionalProperties": false
        },
        "collection_method": {
          "type": "string",
          "enum": [
            "web",
            "app",
            "api"
          ]
        },
        "prompt_submitted": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "submitted_at_utc": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "captured_at_utc": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "environment": {
          "$ref": "#/$defs/environment"
        },
        "answer_original": {
          "type": "string",
          "minLength": 1
        },
        "answer_language": {
          "type": "string",
          "minLength": 1
        },
        "answer_translated": {
          "type": "string",
          "minLength": 1
        },
        "translation_target_language": {
          "type": "string",
          "minLength": 1
        },
        "brand_results": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/brand_result"
          },
          "minItems": 0
        },
        "other_entities_mentioned": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/entity"
          },
          "minItems": 0
        },
        "citations": {
          "$ref": "#/$defs/citations"
        },
        "evidence": {
          "$ref": "#/$defs/evidence"
        },
        "quality_flags": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "prompt_modified",
              "citation_list_not_confirmed_complete",
              "citation_origin_unknown",
              "model_unavailable",
              "search_state_unknown",
              "answer_truncated",
              "translation_machine_only",
              "annotation_unreviewed",
              "possible_factual_error",
              "demo_only",
              "legacy_import",
              "brand_evaluation_incomplete",
              "screenshot_incomplete",
              "account_state_unknown",
              "geography_unavailable"
            ]
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "quality": {
          "type": "object",
          "properties": {
            "answer_status": {
              "type": "string",
              "enum": [
                "complete",
                "partial",
                "unknown"
              ]
            },
            "acceptance_status": {
              "type": "string",
              "enum": [
                "accepted",
                "excluded"
              ]
            },
            "exclusion_reasons": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "minItems": 0,
              "uniqueItems": true
            }
          },
          "required": [
            "answer_status",
            "acceptance_status",
            "exclusion_reasons"
          ],
          "additionalProperties": false
        },
        "unavailable_reasons": {
          "$ref": "#/$defs/unavailable_reasons"
        }
      },
      "required": [
        "sample_id",
        "plan_id",
        "prompt_id",
        "platform",
        "sample_index",
        "attempt_index",
        "origin",
        "collection_method",
        "prompt_submitted",
        "submitted_at_utc",
        "captured_at_utc",
        "environment",
        "answer_original",
        "answer_language",
        "brand_results",
        "other_entities_mentioned",
        "citations",
        "evidence",
        "quality_flags",
        "quality"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "origin": {
                "enum": [
                  "legacy_import"
                ]
              }
            },
            "required": [
              "origin"
            ]
          },
          "then": {
            "required": [
              "legacy_source"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "origin": {
                "enum": [
                  "example"
                ]
              }
            },
            "required": [
              "origin"
            ]
          },
          "then": {
            "properties": {
              "quality_flags": {
                "contains": {
                  "const": "demo_only"
                }
              }
            }
          }
        },
        {
          "dependentRequired": {
            "answer_translated": [
              "translation_target_language"
            ],
            "translation_target_language": [
              "answer_translated"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "quality": {
                "properties": {
                  "acceptance_status": {
                    "const": "excluded"
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "quality": {
                "properties": {
                  "exclusion_reasons": {
                    "minItems": 1
                  }
                }
              }
            }
          },
          "else": {
            "properties": {
              "quality": {
                "properties": {
                  "exclusion_reasons": {
                    "maxItems": 0
                  }
                }
              }
            }
          }
        }
      ]
    },
    "attempt": {
      "type": "object",
      "properties": {
        "attempt_id": {
          "type": "string",
          "minLength": 1
        },
        "attempt_index": {
          "type": "integer",
          "minimum": 1
        },
        "started_at_utc": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "ended_at_utc": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "succeeded",
            "failed",
            "excluded"
          ]
        },
        "reason_code": {
          "type": "string",
          "enum": [
            "login_required",
            "captcha",
            "rate_limited",
            "timeout",
            "no_answer",
            "content_blocked",
            "platform_error",
            "network_error",
            "other"
          ]
        },
        "reason_detail": {
          "type": "string",
          "minLength": 1
        },
        "evidence_urls": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "pattern": "^https?://[^\\s]+$"
          },
          "minItems": 0,
          "uniqueItems": true
        }
      },
      "required": [
        "attempt_id",
        "attempt_index",
        "started_at_utc",
        "ended_at_utc",
        "status",
        "evidence_urls"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "enum": [
                  "failed",
                  "excluded"
                ]
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "required": [
              "reason_code"
            ]
          }
        }
      ]
    },
    "failure": {
      "type": "object",
      "properties": {
        "failure_id": {
          "type": "string",
          "minLength": 1
        },
        "plan_id": {
          "type": "string",
          "minLength": 1
        },
        "prompt_id": {
          "type": "string",
          "minLength": 1
        },
        "platform": {
          "type": "string",
          "minLength": 1
        },
        "sample_index": {
          "type": "integer",
          "minimum": 1
        },
        "attempts": {
          "type": "integer",
          "minimum": 0
        },
        "final_status": {
          "type": "string",
          "enum": [
            "failed",
            "excluded",
            "recovered"
          ]
        },
        "reason_code": {
          "type": "string",
          "enum": [
            "login_required",
            "captcha",
            "rate_limited",
            "timeout",
            "no_answer",
            "content_blocked",
            "platform_error",
            "network_error",
            "other"
          ]
        },
        "reason_detail": {
          "type": "string",
          "minLength": 1
        },
        "last_attempt_at_utc": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "recovered_sample_id": {
          "type": "string",
          "minLength": 1
        },
        "attempt_records": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/attempt"
          },
          "minItems": 0
        },
        "unavailable_reasons": {
          "$ref": "#/$defs/unavailable_reasons"
        }
      },
      "required": [
        "failure_id",
        "plan_id",
        "prompt_id",
        "platform",
        "sample_index",
        "attempts",
        "final_status",
        "reason_code",
        "last_attempt_at_utc",
        "attempt_records"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "final_status": {
                "enum": [
                  "recovered"
                ]
              }
            },
            "required": [
              "final_status"
            ]
          },
          "then": {
            "required": [
              "recovered_sample_id"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "final_status": {
                "enum": [
                  "failed",
                  "excluded"
                ]
              }
            },
            "required": [
              "final_status"
            ]
          },
          "then": {
            "not": {
              "required": [
                "recovered_sample_id"
              ]
            }
          }
        }
      ]
    }
  }
}
