{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://litlfred.github.io/bootstrap/0.1.0/schemas/requirement.schema.json",
  "$comment": "Generated by the bootstrap toolset (https://github.com/litlfred/bootstrap-tools, scripts/gen-bootstrap-schemas.ts) from its Zod source — do not edit; change the Zod.",
  "title": "Requirement",
  "description": "What a harness, or something built with one, must do, said so it can be checked: a titled set of numbered statements, each with a level (SHALL, SHOULD, MAY, SHALL NOT), one sentence, and — optional for now, required once existing statements are migrated — at least one success criterion saying how it is judged met (test, inspection, review or analysis). A test run points at a statement as `req:<slug>#<key>`, or at one criterion as `req:<slug>#<key>/<criterion>`; the requirement does not list its tests. Statement keys are unique within a requirement, criterion keys within a statement.",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^req:[a-z0-9][a-z0-9-]*$"
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "description": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "type": "string",
      "enum": [
        "proposed",
        "in-force",
        "superseded",
        "retired"
      ]
    },
    "derivedFrom": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "actors": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "statements": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "conformance": {
            "type": "string",
            "enum": [
              "SHALL",
              "SHOULD",
              "MAY",
              "SHALL NOT"
            ]
          },
          "requirement": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "type": "string",
            "enum": [
              "functional",
              "non-functional"
            ]
          },
          "activity": {
            "type": "string",
            "minLength": 1
          },
          "capability": {
            "type": "string",
            "minLength": 1
          },
          "benefit": {
            "type": "string",
            "minLength": 1
          },
          "category": {
            "type": "string",
            "minLength": 1
          },
          "actors": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "dependsOn": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "successCriteria": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]*$"
                },
                "criterion": {
                  "type": "string",
                  "minLength": 1
                },
                "verification": {
                  "type": "string",
                  "enum": [
                    "test",
                    "inspection",
                    "review",
                    "analysis"
                  ]
                }
              },
              "required": [
                "key",
                "criterion",
                "verification"
              ]
            }
          }
        },
        "required": [
          "key",
          "label",
          "conformance",
          "requirement"
        ]
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "proposedIn": {
      "type": "string",
      "minLength": 1
    },
    "supersededBy": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "id",
    "title",
    "description",
    "actors",
    "statements"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "superseded"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "required": [
          "supersededBy"
        ]
      }
    },
    {
      "properties": {
        "statements": {
          "items": {
            "allOf": [
              {
                "if": {
                  "properties": {
                    "kind": {
                      "const": "functional"
                    }
                  },
                  "required": [
                    "kind"
                  ]
                },
                "then": {
                  "not": {
                    "required": [
                      "category"
                    ]
                  }
                }
              },
              {
                "if": {
                  "properties": {
                    "kind": {
                      "const": "non-functional"
                    }
                  },
                  "required": [
                    "kind"
                  ]
                },
                "then": {
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "activity"
                        ]
                      },
                      {
                        "required": [
                          "capability"
                        ]
                      },
                      {
                        "required": [
                          "benefit"
                        ]
                      }
                    ]
                  }
                }
              }
            ]
          }
        }
      }
    }
  ]
}
