{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://releases.jtryba.com/friidump/schemas/friidump-test-result.v1.schema.json",
  "title": "FriiDump single-run test result",
  "description": "One FriiDump execution using one drive and one disc.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "format",
    "generated_utc",
    "generator",
    "run",
    "drive",
    "media",
    "seed",
    "dump",
    "hashes",
    "reference",
    "profile",
    "notes",
    "artifacts"
  ],
  "properties": {
    "schema": {
      "const": "friidump-test-result.v1"
    },
    "format": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "generation",
        "serialization"
      ],
      "properties": {
        "name": {
          "const": "FriiDump Interchange Format"
        },
        "generation": {
          "const": 1
        },
        "serialization": {
          "const": "json"
        }
      }
    },
    "generated_utc": {
      "type": "string",
      "format": "date-time"
    },
    "generator": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "version",
        "build_commit"
      ],
      "properties": {
        "name": {
          "const": "FriiDump"
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "build_commit": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-fA-F]{40}$"
        }
      }
    },
    "run": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "run_id",
        "started_utc",
        "completed_utc",
        "test_type",
        "result"
      ],
      "properties": {
        "run_id": {
          "type": "string",
          "format": "uuid"
        },
        "started_utc": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "completed_utc": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "test_type": {
          "enum": [
            "full_dump",
            "seed_only",
            "partial_dump",
            "diagnostic_no_media",
            "diagnostic_wrong_media",
            "media_transition",
            "other"
          ]
        },
        "result": {
          "enum": [
            "pass",
            "partial",
            "fail",
            "not_applicable"
          ]
        }
      }
    },
    "drive": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "vendor",
        "model",
        "firmware_revision",
        "interface",
        "device_path",
        "firmware_modified",
        "modification_note"
      ],
      "properties": {
        "vendor": {
          "type": "string",
          "maxLength": 64
        },
        "model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "firmware_revision": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "interface": {
          "type": "string",
          "maxLength": 40
        },
        "device_path": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 255
        },
        "firmware_modified": {
          "type": "boolean"
        },
        "modification_note": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 1000
        }
      }
    },
    "media": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "platform",
        "title",
        "region",
        "disc_id"
      ],
      "properties": {
        "platform": {
          "enum": [
            "gamecube",
            "wii",
            "xbox",
            "dvd",
            "unknown"
          ]
        },
        "title": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 255
        },
        "region": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 80
        },
        "disc_id": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 120
        }
      }
    },
    "seed": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "attempted",
        "result",
        "duration_seconds"
      ],
      "properties": {
        "attempted": {
          "type": "boolean"
        },
        "result": {
          "enum": [
            "pass",
            "partial",
            "fail",
            "not_attempted",
            "not_applicable"
          ]
        },
        "duration_seconds": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        }
      }
    },
    "dump": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "attempted",
        "result",
        "sector_count",
        "byte_count",
        "duration_seconds",
        "failure_stage",
        "failure_sector",
        "output_path"
      ],
      "properties": {
        "attempted": {
          "type": "boolean"
        },
        "result": {
          "enum": [
            "pass",
            "partial",
            "fail",
            "not_attempted",
            "not_applicable"
          ]
        },
        "sector_count": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "byte_count": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "duration_seconds": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        },
        "failure_stage": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 160
        },
        "failure_sector": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "output_path": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 1024
        }
      }
    },
    "hashes": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "crc32",
        "md5",
        "sha1",
        "sha256"
      ],
      "properties": {
        "crc32": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-fA-F]{8}$"
        },
        "md5": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-fA-F]{32}$"
        },
        "sha1": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-fA-F]{40}$"
        },
        "sha256": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-fA-F]{64}$"
        }
      }
    },
    "reference": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "provider",
        "result",
        "reference_id"
      ],
      "properties": {
        "provider": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 80
        },
        "result": {
          "enum": [
            "match",
            "mismatch",
            "not_checked",
            "not_applicable"
          ]
        },
        "reference_id": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 160
        }
      }
    },
    "profile": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "support_tier",
        "cdb_offset",
        "gate_address"
      ],
      "properties": {
        "support_tier": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 120
        },
        "cdb_offset": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^0x[0-9a-fA-F]+$"
        },
        "gate_address": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^0x[0-9a-fA-F]+$"
        }
      }
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 2000
      },
      "maxItems": 100
    },
    "artifacts": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "path",
          "bytes",
          "sha256"
        ],
        "properties": {
          "type": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "path": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1024
          },
          "bytes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "sha256": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9a-fA-F]{64}$"
          }
        }
      }
    }
  }
}
