{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "daggry/observation@1",
  "title": "daggry/observation@1: a protected-restored or a step-failed record",
  "type": "object",
  "required": [
    "record",
    "reason"
  ],
  "additionalProperties": false,
  "properties": {
    "record": {
      "enum": [
        "protected-restored",
        "step-failed"
      ],
      "x-fact-class": "derived"
    },
    "path": {
      "type": "string",
      "minLength": 1,
      "x-fact-class": "derived"
    },
    "reason": {
      "type": "string",
      "minLength": 1,
      "x-fact-class": "derived"
    },
    "step": {
      "type": "string",
      "minLength": 1,
      "x-fact-class": "derived"
    },
    "attempt": {
      "type": "integer",
      "minimum": 1,
      "x-fact-class": "derived"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "record": {
            "const": "protected-restored"
          }
        },
        "required": [
          "record"
        ]
      },
      "then": {
        "required": [
          "path"
        ],
        "properties": {
          "step": false,
          "attempt": false
        }
      }
    },
    {
      "if": {
        "properties": {
          "record": {
            "const": "step-failed"
          }
        },
        "required": [
          "record"
        ]
      },
      "then": {
        "required": [
          "step",
          "attempt"
        ],
        "properties": {
          "path": false
        }
      }
    }
  ]
}
