{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/Bubble252/motion-tracker/schemas/evaluation_manifest.schema.json",
  "title": "WirelessIMU Evaluation Manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "experiment_id",
    "recorded_at",
    "software_revision",
    "firmware_revision",
    "hardware_revision",
    "calibration_revision",
    "public_scope",
    "samples",
    "failure_handling",
    "metrics",
    "artifacts"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "experiment_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"
    },
    "recorded_at": {
      "type": "string",
      "format": "date-time"
    },
    "software_revision": {
      "type": "string",
      "minLength": 1
    },
    "firmware_revision": {
      "type": "string",
      "minLength": 1
    },
    "hardware_revision": {
      "type": "string",
      "minLength": 1
    },
    "calibration_revision": {
      "type": "string",
      "minLength": 1
    },
    "public_scope": {
      "enum": [
        "public",
        "derived_only",
        "private"
      ]
    },
    "samples": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "total",
        "valid",
        "excluded"
      ],
      "properties": {
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "valid": {
          "type": "integer",
          "minimum": 0
        },
        "excluded": {
          "type": "integer",
          "minimum": 0
        },
        "exclusion_reasons": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "reason",
              "count"
            ],
            "properties": {
              "reason": {
                "type": "string",
                "minLength": 1
              },
              "count": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        }
      }
    },
    "failure_handling": {
      "type": "string",
      "minLength": 1
    },
    "metrics": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "statistic",
          "unit",
          "value",
          "scope"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "statistic": {
            "type": "string",
            "minLength": 1
          },
          "unit": {
            "type": "string",
            "minLength": 1
          },
          "value": {
            "type": "number"
          },
          "scope": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "artifacts": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "path",
          "public"
        ],
        "properties": {
          "kind": {
            "enum": [
              "raw",
              "derived",
              "config",
              "script",
              "figure",
              "report"
            ]
          },
          "path": {
            "type": "string",
            "pattern": "^(?!/)(?!.*\\.\\.)(?!.*\\\\).+$"
          },
          "public": {
            "type": "boolean"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        }
      }
    }
  }
}
