{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://torneo.ai/schemas/key_drill.v1",
  "title": "key_drill.v1",
  "description": "Receipt of the rotation and compromise drill of the signing keys on scratch keys only (tools/key_drill.py run_drill). Only public fingerprints are recorded. PASS means every scenario observed what it expected.",
  "type": "object",
  "required": [
    "schema",
    "scratch_keys_only",
    "drilled_at",
    "keys",
    "scenarios",
    "verdict",
    "proves",
    "does_not_prove"
  ],
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "key_drill.v1"
    },
    "scratch_keys_only": {
      "const": true
    },
    "drilled_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"
    },
    "keys": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "object",
        "required": [
          "fingerprint"
        ],
        "additionalProperties": false,
        "properties": {
          "fingerprint": {
            "type": "string",
            "pattern": "^[0-9a-f]{16}$"
          }
        }
      }
    },
    "scenarios": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "name",
          "expected",
          "observed",
          "ok"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "expected": true,
          "observed": true,
          "ok": {
            "type": "boolean"
          }
        }
      }
    },
    "verdict": {
      "enum": [
        "PASS",
        "FAIL"
      ]
    },
    "proves": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "does_not_prove": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "verdict": {
            "const": "PASS"
          }
        },
        "required": [
          "verdict"
        ]
      },
      "then": {
        "properties": {
          "scenarios": {
            "items": {
              "properties": {
                "ok": {
                  "const": true
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "verdict": {
            "const": "FAIL"
          }
        },
        "required": [
          "verdict"
        ]
      },
      "then": {
        "properties": {
          "scenarios": {
            "contains": {
              "properties": {
                "ok": {
                  "const": false
                }
              }
            }
          }
        }
      }
    }
  ]
}
