{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sneakoscope.local/schemas/codex/image-ux-issue-ledger.schema.json",
  "title": "SKS Image UX Issue Ledger v3",
  "type": "object",
  "required": ["schema", "schema_version", "issues"],
  "properties": {
    "schema": { "const": "sks.image-ux-issue-ledger.v3" },
    "schema_version": { "const": 3 },
    "extraction_source": { "type": "string" },
    "extraction_method": { "type": "string" },
    "extraction_schema": { "type": "string" },
    "extracted_from_generated_callout": { "type": "boolean" },
    "blocking_issue_count": { "type": "integer", "minimum": 0 },
    "p0_p1_zero": { "type": "boolean" },
    "blockers": { "type": "array", "items": { "type": "string" } },
    "passed": { "type": "boolean" },
    "validation": {
      "type": "object",
      "required": ["ok", "issues"],
      "properties": {
        "ok": { "type": "boolean" },
        "issues": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    },
    "issues": {
      "type": "array",
      "items": { "$ref": "#/$defs/issue" }
    }
  },
  "$defs": {
    "bbox": {
      "type": "array",
      "prefixItems": [
        { "type": "number", "minimum": 0 },
        { "type": "number", "minimum": 0 },
        { "type": "number", "exclusiveMinimum": 0 },
        { "type": "number", "exclusiveMinimum": 0 }
      ],
      "minItems": 4,
      "maxItems": 4
    },
    "issue": {
      "type": "object",
      "required": [
        "id",
        "severity",
        "source_screen_id",
        "generated_review_image_id",
        "callout_id",
        "bbox",
        "region",
        "title",
        "detail",
        "likely_cause",
        "fix_action",
        "target_surface",
        "status",
        "confidence",
        "source",
        "extracted_from_generated_image",
        "extraction_provider",
        "extraction_schema",
        "generated_image_sha256",
        "bbox_coordinate_space",
        "bbox_confidence",
        "severity_visible",
        "callout_number_visible",
        "text_ocr_confidence",
        "fix_verification_status"
      ],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "severity": { "enum": ["P0", "P1", "P2", "P3"] },
        "source_screen_id": { "type": "string", "minLength": 1 },
        "screen_id": { "type": "string" },
        "generated_review_image_id": { "type": "string", "minLength": 1 },
        "evidence_image_id": { "type": "string" },
        "callout_id": { "type": "string", "minLength": 1 },
        "bbox": { "$ref": "#/$defs/bbox" },
        "region": { "type": "string", "minLength": 1 },
        "title": { "type": "string", "minLength": 1 },
        "detail": { "type": "string", "minLength": 1 },
        "likely_cause": { "type": "string" },
        "fix_action": { "type": "string", "minLength": 1 },
        "target_surface": { "type": "string" },
        "candidate_files": { "type": "array", "items": { "type": "string" } },
        "status": { "enum": ["open", "fixed", "accepted_not_applicable", "blocked", "needs_human", "suggestion_only", "remains_open"] },
        "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
        "source": { "enum": ["real_gpt_image_2_callout", "mock_fixture"] },
        "extracted_from_generated_image": { "type": "boolean" },
        "extraction_provider": { "type": "string", "minLength": 1 },
        "extraction_schema": { "type": "string", "minLength": 1 },
        "generated_image_sha256": { "type": "string", "minLength": 1 },
        "bbox_coordinate_space": { "const": "generated_image" },
        "bbox_confidence": { "type": "number", "minimum": 0, "maximum": 1 },
        "severity_visible": { "type": "boolean" },
        "callout_number_visible": { "type": "boolean" },
        "text_ocr_confidence": { "type": "number", "minimum": 0, "maximum": 1 },
        "fix_verification_status": { "enum": ["not_verified", "patch_attempted", "recapture_required", "recheck_verified", "blocked", "accepted_not_applicable"] },
        "post_fix_recheck_issue_id": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
