{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://qrtrust.local/contracts/ios-provider-profile-evidence.schema.json",
  "title": "QR Trust iOS provider profile evidence packet",
  "type": "object",
  "required": [
    "artifact_type",
    "packet_id",
    "generated_at",
    "scanner_app",
    "provider_profile_fixture",
    "evidence_rows",
    "reviewer",
    "privacy"
  ],
  "properties": {
    "artifact_type": {
      "const": "ios_provider_profile_evidence_packet"
    },
    "packet_id": {
      "type": "string",
      "minLength": 1
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "scanner_app": {
      "type": "object",
      "required": [
        "name",
        "platform",
        "build_version"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "platform": {
          "type": "string",
          "minLength": 1
        },
        "build_version": {
          "type": "string",
          "minLength": 1
        },
        "os_version": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "provider_profile_fixture": {
      "type": "object",
      "required": [
        "path",
        "profile_id",
        "profile_version",
        "profile_fingerprint"
      ],
      "properties": {
        "path": {
          "type": "string",
          "pattern": "^docs/public/fixtures/ios/"
        },
        "profile_id": {
          "type": "string",
          "minLength": 1
        },
        "profile_version": {
          "type": "integer",
          "minimum": 1
        },
        "profile_fingerprint": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        }
      },
      "additionalProperties": false
    },
    "evidence_rows": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/evidence_row"
      }
    },
    "reviewer": {
      "type": "object",
      "required": [
        "name",
        "role",
        "reviewed_at"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "role": {
          "type": "string",
          "minLength": 1
        },
        "reviewed_at": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        }
      },
      "additionalProperties": false
    },
    "privacy": {
      "type": "object",
      "required": [
        "raw_endpoints_redacted",
        "secrets_included"
      ],
      "properties": {
        "raw_endpoints_redacted": {
          "type": "boolean"
        },
        "secrets_included": {
          "const": false
        },
        "notes": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "$defs": {
    "evidence_row": {
      "type": "object",
      "required": [
        "fixture_id",
        "profile_state",
        "expected_status",
        "expected_user_signal",
        "screenshot_ref",
        "accessibility_ref",
        "required_labels"
      ],
      "properties": {
        "fixture_id": {
          "type": "string",
          "minLength": 1
        },
        "profile_state": {
          "enum": [
            "active",
            "stale",
            "revoked",
            "rejected",
            "local_reviewer_exception"
          ]
        },
        "expected_status": {
          "type": "string",
          "minLength": 1
        },
        "expected_user_signal": {
          "enum": [
            "green",
            "orange",
            "red"
          ]
        },
        "screenshot_ref": {
          "type": "string",
          "pattern": "^docs/public/evidence/iphone/.*\\.png$"
        },
        "accessibility_ref": {
          "type": "string",
          "pattern": "^docs/public/evidence/iphone/.*\\.txt$"
        },
        "required_labels": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    }
  }
}
