{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Design file",
  "description": "The root of a design file: the design under design: \u2014 the risk analysis, the requirements tree, the architecture and the SOUP list. A file that keeps those sections at the root still reads; `verio design restructure` moves them into place.",
  "type": "object",
  "properties": {
    "title": {
      "type": "string"
    },
    "design": {
      "type": "object",
      "description": "The design itself: what is being built, and what could go wrong with it.",
      "properties": {
        "risk_management": {
          "type": "object",
          "description": "The ISO 14971 analysis: the risks, each carrying its own hazard and harm.",
          "properties": {
            "risks": {
              "type": "object",
              "description": "The risk analysis itself, keyed by identifier: hazard, sequence of events, hazardous situation, harm, the initial and residual estimates, and the control measures with what verifies them.",
              "additionalProperties": {
                "$ref": "risk.schema.json#/$defs/risk"
              }
            }
          },
          "additionalProperties": false
        },
        "requirements": {
          "$ref": "#/$defs/itemMap"
        },
        "architecture": {
          "description": "Software architecture (IEC 62304 5.3), as named sections of prose.",
          "$ref": "architecture.schema.json#/$defs/sections"
        },
        "soup": {
          "$ref": "#/$defs/soupList"
        }
      },
      "additionalProperties": false
    }
  },
  "$defs": {
    "itemMap": {
      "description": "Map of item name -> item. Keys are free-form names, e.g. \"My First item\".",
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/item"
      }
    },
    "item": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "description": "Display title of the item."
        },
        "type": {
          "enum": [
            "grouping",
            "group",
            "requirement",
            "specification",
            "test"
          ],
          "description": "Kind of node in the tree."
        },
        "description": {
          "type": "string"
        },
        "children": {
          "description": "Nested items. May be omitted or left empty (YAML parses a bare 'children:' as null).",
          "anyOf": [
            {
              "$ref": "#/$defs/itemMap"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "title",
        "type"
      ],
      "additionalProperties": false
    },
    "soupList": {
      "type": "object",
      "description": "IEC 62304 software of unknown provenance: third-party runtime software, keyed by package name. The editor can fill and refresh this from the project's own dependencies.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "version": {
            "type": [
              "string",
              "null"
            ],
            "description": "Version actually in use."
          },
          "supplier": {
            "type": [
              "string",
              "null"
            ]
          },
          "license": {
            "type": [
              "string",
              "null"
            ]
          },
          "purpose": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why this item is in the product."
          },
          "anomaly_list": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the published anomaly list lives, e.g. the issue tracker."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Assessment of the anomaly list, version pinning, alternatives considered."
          }
        },
        "additionalProperties": true
      }
    }
  },
  "$id": "https://verio.dev/schema/root.schema.json"
}
