{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sitelensapi.com/schemas/sitelens-report-v1.json",
  "title": "SiteLensReportV1",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schemaVersion",
    "product",
    "reportType",
    "profile",
    "title",
    "generatedAt",
    "generator",
    "identity",
    "status",
    "summary",
    "sensitivity",
    "sourceEvidence"
  ],
  "properties": {
    "schemaVersion": { "const": 1 },
    "product": { "const": "SiteLens Reports" },
    "reportType": {
      "type": "string",
      "enum": [
        "local-flow-run",
        "local-qa-run",
        "local-scenario-run",
        "visual-comparison",
        "aggregate"
      ]
    },
    "profile": {
      "type": "string",
      "enum": ["summary", "investigation", "full"]
    },
    "title": { "type": "string", "minLength": 1 },
    "description": { "type": "string" },
    "generatedAt": { "type": "string", "minLength": 1 },
    "generator": {
      "type": "object",
      "required": ["name", "version"],
      "additionalProperties": true,
      "properties": {
        "name": { "type": "string" },
        "version": { "type": "string" }
      }
    },
    "identity": {
      "type": "object",
      "required": ["reportId"],
      "additionalProperties": true,
      "properties": {
        "reportId": { "type": "string" },
        "runId": { "type": "string" },
        "scenarioId": { "type": "string" }
      }
    },
    "status": {
      "type": "string",
      "enum": ["passed", "warning", "failed", "error", "partial"]
    },
    "summary": {
      "type": "object",
      "required": ["status"],
      "additionalProperties": true,
      "properties": {
        "status": {
          "type": "string",
          "enum": ["passed", "warning", "failed", "error", "partial"]
        },
        "completion": {
          "type": "string",
          "enum": ["complete", "partial", "aborted"]
        }
      }
    },
    "visualComparisons": {
      "type": "array",
      "items": { "type": "object", "additionalProperties": true }
    },
    "diagnostics": {
      "type": "object",
      "description": "Optional, schema-additive since Phase G — BrowserDiagnosticsEngine findings summary from diagnostics.json. Absent on reports predating Phase G or when no diagnostics.json was captured.",
      "required": ["findingCount", "findings", "source"],
      "additionalProperties": true,
      "properties": {
        "schemaVersion": { "type": "number" },
        "generatedAt": { "type": "string" },
        "findingCount": { "type": "number" },
        "droppedFindingCount": { "type": "number" },
        "findings": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["findingId", "ruleId", "severity", "title", "source"],
            "additionalProperties": true,
            "properties": {
              "findingId": { "type": "string" },
              "ruleId": { "type": "string" },
              "severity": {
                "type": "string",
                "enum": ["info", "warning", "error", "critical"]
              },
              "title": { "type": "string" },
              "summary": { "type": "string" },
              "category": { "type": "string" },
              "stepId": { "type": "string" }
            }
          }
        },
        "source": { "type": "object", "additionalProperties": true }
      }
    },
    "geographic": {
      "type": "object",
      "description": "Optional public geographic capture metadata. Absent on reports that predate geographic capture. Must not include proxy credentials.",
      "required": ["countriesRequested", "countriesObserved", "sides"],
      "additionalProperties": true,
      "properties": {
        "countriesRequested": {
          "type": "array",
          "items": { "type": ["string", "null"] }
        },
        "countriesObserved": {
          "type": "array",
          "items": { "type": ["string", "null"] }
        },
        "sides": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "requestedCountry",
              "observedCountry",
              "proxyType",
              "verificationStatus",
              "outcome",
              "exitChecked"
            ],
            "additionalProperties": true,
            "properties": {
              "requestedCountry": { "type": ["string", "null"] },
              "observedCountry": { "type": ["string", "null"] },
              "proxyType": { "type": ["string", "null"], "enum": ["datacenter", "residential", null] },
              "verificationStatus": {
                "type": ["string", "null"],
                "enum": ["verified", "mismatch", "unverified", null]
              },
              "outcome": { "type": ["string", "null"], "enum": ["captured", "failed", "error", null] },
              "exitChecked": { "type": "boolean" }
            }
          }
        }
      }
    },
    "sensitivity": {
      "type": "object",
      "required": [
        "level",
        "redactionApplied",
        "containsScreenshots",
        "containsNetworkPreviews",
        "warnings"
      ],
      "additionalProperties": true
    },
    "sourceEvidence": { "type": "object", "additionalProperties": true }
  }
}
