{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://corank-prompt-source-gap-triage.pages.dev/ai-answer-evidence-ledger/schema.json",
  "title": "AI Answer Evidence Observation Ledger Row",
  "description": "Version 1.0 structural validation for one citation occurrence in a dated AI-answer observation.",
  "type": "object",
  "additionalProperties": false,
  "required": ["observation_id", "prompt_id", "prompt_version", "answer_system", "answer_surface", "run_timestamp", "market", "citation_id", "mention_present", "citation_present", "primary_role", "publisher_relationship", "taxonomy_version", "verification_status", "reviewer_id", "review_status", "is_synthetic"],
  "properties": {
    "observation_id": {"type": "string", "minLength": 1},
    "prompt_id": {"type": "string", "minLength": 1},
    "prompt_version": {"type": "string", "minLength": 1},
    "answer_system": {"type": "string", "minLength": 1},
    "answer_surface": {"type": "string", "minLength": 1},
    "run_timestamp": {"type": "string", "format": "date-time"},
    "market": {"type": "string", "minLength": 1},
    "citation_id": {"type": "string", "minLength": 1},
    "citation_position": {"type": ["integer", "null"], "minimum": 1},
    "observed_url": {"type": ["string", "null"], "format": "uri", "pattern": "^https?://"},
    "link_label": {"type": ["string", "null"]},
    "mention_present": {"type": "boolean"},
    "citation_present": {"type": "boolean"},
    "answer_evidence_span": {"type": ["string", "null"]},
    "claim_summary": {"type": ["string", "null"]},
    "primary_role": {"enum": ["entity", "definition", "evidence", "comparison", "implementation", "validation", "action"]},
    "secondary_roles": {"type": "array", "uniqueItems": true, "items": {"enum": ["entity", "definition", "evidence", "comparison", "implementation", "validation", "action"]}},
    "publisher_relationship": {"enum": ["owned", "partner", "independent", "unknown", "not_applicable"]},
    "taxonomy_version": {"const": "1.0"},
    "normalization_policy_version": {"type": ["string", "null"]},
    "normalized_key": {"type": ["string", "null"], "format": "uri"},
    "verification_status": {"enum": ["not_checked", "reachable", "redirected", "access_limited", "not_found", "error"]},
    "verified_final_url": {"type": ["string", "null"], "format": "uri"},
    "publisher_canonical": {"type": ["string", "null"], "format": "uri"},
    "verification_timestamp": {"type": ["string", "null"], "format": "date-time"},
    "reviewer_id": {"type": "string", "minLength": 1},
    "review_status": {"enum": ["reviewed", "needs_review", "excluded"]},
    "notes": {"type": ["string", "null"]},
    "is_synthetic": {"type": "boolean"}
  },
  "allOf": [
    {
      "if": {"properties": {"citation_present": {"const": true}}},
      "then": {"required": ["citation_position", "observed_url"]}
    }
  ]
}
