{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "AnalysisResultV1",
  "description": "Result of a single-page AI-findability analysis (API v1).",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "url",
    "analyzed_at",
    "api_version",
    "methodology_version",
    "page_type",
    "overall_score",
    "pillars",
    "metrics",
    "top_recommendations"
  ],
  "properties": {
    "url": {
      "type": "string",
      "minLength": 1
    },
    "analyzed_at": {
      "type": "string",
      "format": "date-time"
    },
    "api_version": {
      "const": "v1"
    },
    "methodology_version": {
      "type": "string",
      "pattern": "^\\d{4}\\.\\d{2}\\.\\d+$"
    },
    "page_type": {
      "description": "Detected page type. New values MAY be added within v1; clients must tolerate unknown values.",
      "enum": [
        "blog-post",
        "listicle",
        "how-to",
        "comparison",
        "pillar-page",
        "faq",
        "case-study",
        "knowledge-base",
        "product",
        "service",
        "landing-page",
        "pricing",
        "category",
        "homepage",
        "about",
        "contact",
        "legal",
        "team",
        "portfolio"
      ]
    },
    "overall_score": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100
    },
    "pillars": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "items": {
        "$ref": "#/$defs/pillar"
      }
    },
    "metrics": {
      "type": "array",
      "minItems": 22,
      "maxItems": 22,
      "items": {
        "$ref": "#/$defs/metric"
      }
    },
    "top_recommendations": {
      "type": "array",
      "maxItems": 5,
      "items": {
        "$ref": "#/$defs/topRecommendation"
      }
    }
  },
  "$defs": {
    "pillarId": {
      "enum": [
        "content_quality",
        "ai_readiness",
        "technical_basis",
        "authority_trust"
      ]
    },
    "metricId": {
      "enum": [
        "readability",
        "comprehensiveness",
        "transition_words",
        "lsi_keywords",
        "answer_completeness",
        "factual_density",
        "citability",
        "ai_optimization",
        "structure",
        "image_alt_text",
        "platform_specificity",
        "content_type_matching",
        "semantic_clarity",
        "ai_bot_crawler",
        "schema_validator",
        "sitemap_discoverability",
        "page_speed",
        "freshness",
        "citations",
        "eeat",
        "knowledge_graph",
        "topical_authority"
      ]
    },
    "priority": {
      "enum": [
        "high",
        "medium",
        "low"
      ]
    },
    "pillar": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "score"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/pillarId"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "score": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        }
      }
    },
    "metric": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "pillar",
        "score",
        "status",
        "explanation",
        "recommendation",
        "priority"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/metricId"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "pillar": {
          "$ref": "#/$defs/pillarId"
        },
        "score": {
          "oneOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            },
            {
              "type": "null"
            }
          ]
        },
        "status": {
          "enum": [
            "pass",
            "warn",
            "fail",
            "not_applicable"
          ]
        },
        "explanation": {
          "type": "string",
          "minLength": 1
        },
        "recommendation": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "priority": {
          "oneOf": [
            {
              "$ref": "#/$defs/priority"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "topRecommendation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "metric_id",
        "title",
        "recommendation",
        "priority"
      ],
      "properties": {
        "metric_id": {
          "$ref": "#/$defs/metricId"
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "recommendation": {
          "type": "string",
          "minLength": 1
        },
        "priority": {
          "$ref": "#/$defs/priority"
        }
      }
    }
  }
}
