{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "const": "testing.aiwg.io/v1"
    },
    "kind": {
      "const": "TestNormalizationReceipt"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "createdAt": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
        },
        "toolVersion": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "name",
        "createdAt",
        "toolVersion"
      ]
    },
    "spec": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "root": {
          "type": "string",
          "minLength": 1
        },
        "purpose": {
          "type": "string"
        },
        "changes": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "path": {
                "type": "string",
                "minLength": 1
              },
              "before": {
                "oneOf": [
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "content": {
                        "type": "null"
                      },
                      "hash": {
                        "type": "null"
                      },
                      "mode": {
                        "type": "null"
                      }
                    },
                    "required": [
                      "content",
                      "hash",
                      "mode"
                    ]
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "content": {
                        "type": "string"
                      },
                      "hash": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      },
                      "mode": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 511
                      }
                    },
                    "required": [
                      "content",
                      "hash",
                      "mode"
                    ]
                  }
                ]
              },
              "after": {
                "oneOf": [
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "content": {
                        "type": "null"
                      },
                      "hash": {
                        "type": "null"
                      },
                      "mode": {
                        "type": "null"
                      }
                    },
                    "required": [
                      "content",
                      "hash",
                      "mode"
                    ]
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "content": {
                        "type": "string"
                      },
                      "hash": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      },
                      "mode": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 511
                      }
                    },
                    "required": [
                      "content",
                      "hash",
                      "mode"
                    ]
                  }
                ]
              }
            },
            "required": [
              "path",
              "before",
              "after"
            ]
          },
          "maxItems": 1000
        },
        "planHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "status": {
          "enum": [
            "applying",
            "applied",
            "partial",
            "rolling-back",
            "rolled-back"
          ]
        },
        "completed": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "receiptPath": {
          "type": "string",
          "minLength": 1
        },
        "error": {
          "type": "string"
        },
        "observed": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "path": {
                    "type": "string",
                    "minLength": 1
                  },
                  "state": {
                    "oneOf": [
                      {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "content": {
                            "type": "null"
                          },
                          "hash": {
                            "type": "null"
                          },
                          "mode": {
                            "type": "null"
                          }
                        },
                        "required": [
                          "content",
                          "hash",
                          "mode"
                        ]
                      },
                      {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "content": {
                            "type": "string"
                          },
                          "hash": {
                            "type": "string",
                            "pattern": "^[a-f0-9]{64}$"
                          },
                          "mode": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 511
                          }
                        },
                        "required": [
                          "content",
                          "hash",
                          "mode"
                        ]
                      }
                    ]
                  }
                },
                "required": [
                  "path",
                  "state"
                ]
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "path": {
                    "type": "string",
                    "minLength": 1
                  },
                  "error": {
                    "type": "string"
                  }
                },
                "required": [
                  "path",
                  "error"
                ]
              }
            ]
          }
        },
        "journalError": {
          "type": "string"
        }
      },
      "required": [
        "root",
        "purpose",
        "changes",
        "planHash",
        "status",
        "completed",
        "receiptPath"
      ]
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://aiwg.io/schemas/testing/normalization-receipt.v1.schema.json",
  "title": "TestNormalizationReceipt"
}
