{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://studio-fug.github.io/rules_requirements/schema/rules_requirements.schema.json",
  "title": "rules_requirements model file",
  "description": "A requirements model document: either sections (user_needs, requirements, risks, mitigations, test_methods, config, project) or one object with a `kind`. Referential integrity and coverage rules are checked by `rr validate`, not by this schema.",
  "oneOf": [
    {
      "type": "object",
      "additionalProperties": false,
      "not": {
        "required": [
          "kind"
        ]
      },
      "properties": {
        "schema_version": {
          "type": "integer"
        },
        "config": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "prefixes": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "id_pattern": {
              "type": "string"
            },
            "levels": {
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "required": [
                      "name"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "ordered": {
                        "type": "boolean"
                      },
                      "description": {
                        "type": "string"
                      }
                    }
                  }
                ]
              }
            },
            "default_level": {
              "type": "string"
            },
            "default_provided_level": {
              "type": "string"
            },
            "autonomous_max_level": {
              "type": "string"
            },
            "pyramid_min_level": {
              "type": "string"
            },
            "pyramid_cheap_levels": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "severities": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "likelihoods": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "acceptable_risk_score": {
              "type": [
                "integer",
                "null"
              ]
            },
            "high_severities": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "rules": {
              "type": "object",
              "properties": {
                "need-unsatisfied": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "error",
                  "description": "A user need no requirement satisfies can never be validated."
                },
                "requirement-orphan": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "error",
                  "description": "A requirement that neither satisfies a need, refines another requirement, nor implements a mitigation is untraceable (\"gold plating\" or a lost link)."
                },
                "risk-unmitigated": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "error",
                  "description": "A risk with no mitigation (and no recorded acceptance) is uncontrolled."
                },
                "mitigation-unimplemented": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "error",
                  "description": "A mitigation that no requirement implements is a promise, not a control."
                },
                "risk-unacceptable": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "Residual risk above the acceptability threshold."
                },
                "unknown-field": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "error",
                  "description": "Unknown keys usually mean a typo that silently drops a trace."
                },
                "bare-target-reference": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "A legacy verified_by item (a bare label, {target} or {target, level}): it claims the whole target. Error by default from 0.4."
                },
                "whole-target-reference": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "A `whole: true` claim without a `reason`."
                },
                "coarse-claim": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "`whole: true` on a target that reports per-case results (report time)."
                },
                "glob-selector": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "off",
                  "description": "Any selector with a '*' (opt in to require literal case lists)."
                },
                "redundant-selector": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "Two selectors of one entity on one target can select the same case."
                },
                "tag-mismatch": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "A case's single tag names another entity than the one whose claim owns it."
                },
                "unclaimed-tag": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "Model mode: a single-id tag on a case no claim covers."
                },
                "suite-level-requirement": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "A requirement property on a JUnit testsuite (no longer inherited by its cases)."
                },
                "duplicate-case": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "The same case key twice in one run."
                },
                "level-mismatch": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "The case's own level differs from the level of the claim that owns it."
                },
                "same-path-multiple-owners": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "Equal case paths in different targets with different owners and no source file to tell whether they are the same test code."
                },
                "multi-parent-refines": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "error",
                  "description": "A requirement that refines two or more parents: refines must form a tree, so each test case's evidence rolls up one chain of requirements."
                },
                "multi-parent-implements": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "error",
                  "description": "A requirement that implements a mitigation and has another parent (a second mitigation, or a requirement it refines): each test case's evidence would roll up two chains of verified entities."
                },
                "parent-with-claims": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "A requirement with refining children also claims cases of its own."
                },
                "multi-verifies-annotation": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "warning",
                  "description": "`rr scan`: a verifies annotation naming several ids. Error by default from 0.4."
                },
                "lock-stale": {
                  "$ref": "#/$defs/ruleSeverity",
                  "default": "error",
                  "description": "A lock entry that no claim of its owner matches (model mode), or the entry of an absent suite:/record: pseudo-target whose case now runs under another target."
                }
              },
              "additionalProperties": false,
              "propertyNames": {
                "not": {
                  "enum": [
                    "attribution-conflict",
                    "bad-selector",
                    "bad-target",
                    "lock-invalid",
                    "lock-owner-changed",
                    "multi-tag",
                    "same-code-multiple-owners",
                    "shared-case",
                    "unknown-target"
                  ]
                },
                "description": "Hard errors and report-time quarantines are not rules and cannot be configured; any other name that is not a rule is an unknown rule."
              }
            },
            "annotation_patterns": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "attribution": {
              "enum": [
                "hybrid",
                "model"
              ],
              "description": "hybrid: a single-id tag may own a case no claim covers; model: only claims own cases."
            },
            "main_repo": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9._-]*$",
              "description": "The apparent name of this repository: '@<main_repo>//x:y' means '//x:y'."
            },
            "sets_lock": {
              "type": "string",
              "minLength": 1,
              "description": "The verification-set lock, relative to this file."
            },
            "flaky": {
              "enum": [
                "accept",
                "flag",
                "under-verify",
                "fail"
              ]
            },
            "set_consistency": {
              "enum": [
                "off",
                "warn",
                "enforce",
                false
              ]
            },
            "variants": {
              "type": "array",
              "description": "Groups of targets that run the same test code.",
              "items": {
                "type": "array",
                "minItems": 2,
                "uniqueItems": true,
                "items": {
                  "$ref": "#/$defs/label"
                }
              }
            }
          }
        },
        "project": {
          "type": "object"
        },
        "meta": {
          "type": "object"
        },
        "user_needs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/user_need"
          }
        },
        "requirements": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/requirement"
          }
        },
        "risks": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/risk"
          }
        },
        "mitigations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/mitigation"
          }
        },
        "test_methods": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/test_method"
          }
        }
      }
    },
    {
      "type": "object",
      "description": "What a user must be able to do (validated).",
      "required": [
        "kind",
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "rationale": {
          "type": "string"
        },
        "validated_by": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/verifiedBy"
          },
          "description": "Validation evidence: claims in the same namespace as verified_by."
        },
        "kind": {
          "const": "user_need"
        }
      }
    },
    {
      "type": "object",
      "description": "A verifiable product requirement.",
      "required": [
        "kind",
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "rationale": {
          "type": "string"
        },
        "category": {
          "type": "string"
        },
        "satisfies": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ],
          "description": "User need ids."
        },
        "refines": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ],
          "description": "Parent requirement ids."
        },
        "method": {
          "type": "string",
          "description": "Test method id or verification level the verification demands."
        },
        "verified_by": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/verifiedBy"
          }
        },
        "modules": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "kind": {
          "const": "requirement"
        }
      }
    },
    {
      "type": "object",
      "description": "A hazard -> harm chain (ISO 14971).",
      "required": [
        "kind",
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "hazard": {
          "type": "string"
        },
        "hazardous_situation": {
          "type": "string"
        },
        "harm": {
          "type": "string"
        },
        "severity": {
          "type": "string"
        },
        "likelihood": {
          "type": "string"
        },
        "residual_severity": {
          "type": "string"
        },
        "residual_likelihood": {
          "type": "string"
        },
        "residual": {
          "type": "string"
        },
        "mitigated_by": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "kind": {
          "const": "risk"
        }
      }
    },
    {
      "type": "object",
      "description": "A risk control measure.",
      "required": [
        "kind",
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "type": {
          "enum": [
            "inherent",
            "protective",
            "information"
          ]
        },
        "mitigates": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "implemented_by": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "verified_by": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/verifiedBy"
          },
          "description": "Effectiveness evidence of the control (ISO 14971 §7.2)."
        },
        "kind": {
          "const": "mitigation"
        }
      }
    },
    {
      "type": "object",
      "description": "A named verification procedure at a rigor level.",
      "required": [
        "kind",
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "level": {
          "type": "string"
        },
        "procedure": {
          "type": "string"
        },
        "kind": {
          "const": "test_method"
        }
      }
    }
  ],
  "$defs": {
    "user_need": {
      "type": "object",
      "description": "What a user must be able to do (validated).",
      "required": [
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "rationale": {
          "type": "string"
        },
        "validated_by": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/verifiedBy"
          },
          "description": "Validation evidence: claims in the same namespace as verified_by."
        }
      }
    },
    "requirement": {
      "type": "object",
      "description": "A verifiable product requirement.",
      "required": [
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "rationale": {
          "type": "string"
        },
        "category": {
          "type": "string"
        },
        "satisfies": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ],
          "description": "User need ids."
        },
        "refines": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ],
          "description": "Parent requirement ids."
        },
        "method": {
          "type": "string",
          "description": "Test method id or verification level the verification demands."
        },
        "verified_by": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/verifiedBy"
          }
        },
        "modules": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        }
      }
    },
    "risk": {
      "type": "object",
      "description": "A hazard -> harm chain (ISO 14971).",
      "required": [
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "hazard": {
          "type": "string"
        },
        "hazardous_situation": {
          "type": "string"
        },
        "harm": {
          "type": "string"
        },
        "severity": {
          "type": "string"
        },
        "likelihood": {
          "type": "string"
        },
        "residual_severity": {
          "type": "string"
        },
        "residual_likelihood": {
          "type": "string"
        },
        "residual": {
          "type": "string"
        },
        "mitigated_by": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        }
      }
    },
    "mitigation": {
      "type": "object",
      "description": "A risk control measure.",
      "required": [
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "type": {
          "enum": [
            "inherent",
            "protective",
            "information"
          ]
        },
        "mitigates": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "implemented_by": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "verified_by": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/verifiedBy"
          },
          "description": "Effectiveness evidence of the control (ISO 14971 §7.2)."
        }
      }
    },
    "test_method": {
      "type": "object",
      "description": "A named verification procedure at a rigor level.",
      "required": [
        "id",
        "title"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique id, e.g. REQ-12 (prefix configurable)."
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "status": {
          "enum": [
            "draft",
            "proposed",
            "approved",
            "implemented",
            "obsolete"
          ]
        },
        "owner": {
          "type": "string"
        },
        "tags": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "notes": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "comment",
                      "gap",
                      "question",
                      "todo"
                    ]
                  },
                  "status": {
                    "enum": [
                      "open",
                      "resolved"
                    ]
                  },
                  "author": {
                    "type": "string"
                  },
                  "created": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "level": {
          "type": "string"
        },
        "procedure": {
          "type": "string"
        }
      }
    },
    "label": {
      "type": "string",
      "pattern": "^\\s*(?:(?:@@?[A-Za-z0-9_.~+-]*)?//(?:(?:(?!\\.{1,3}(?:[/:]|\\s*$))[^\\s#*\"'\\\\/:\\x00-\\x1f\\x7f]+(?:/(?!\\.{1,3}(?:[/:]|\\s*$))[^\\s#*\"'\\\\/:\\x00-\\x1f\\x7f]+)*)?:(?!\\.{1,2}(?:/|\\s*$))[^\\s#*\"'\\\\/:\\x00-\\x1f\\x7f]+(?:/(?!\\.{1,2}(?:/|\\s*$))[^\\s#*\"'\\\\/:\\x00-\\x1f\\x7f]+)*|(?!\\.{1,3}(?:[/:]|\\s*$))[^\\s#*\"'\\\\/:\\x00-\\x1f\\x7f]+(?:/(?!\\.{1,3}(?:[/:]|\\s*$))[^\\s#*\"'\\\\/:\\x00-\\x1f\\x7f]+)*)|@@?[A-Za-z0-9_.~+-]+|(?:suite|record):[^#\\n]*[^\\s#][^#\\n]*)\\s*$",
      "description": "A Bazel label (//pkg:name, //pkg, @repo//pkg:name, @repo; every spelling of one target is normalized to one) or a pseudo-target (suite:<testsuite>, record:<stem>). The pattern accepts exactly what labels.normalize_label accepts."
    },
    "verifiedBy": {
      "description": "One claim item: the cases of one target an entity claims. Claims of two entities that can select one case are a shared-case error.",
      "oneOf": [
        {
          "$ref": "#/$defs/label",
          "description": "DEPRECATED: whole target (rule bare-target-reference).",
          "deprecated": true
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "target",
            "cases"
          ],
          "properties": {
            "target": {
              "$ref": "#/$defs/label"
            },
            "cases": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "string",
                "minLength": 1
              },
              "description": "Case selectors: whole case paths; '*' matches anything ('\\\\*' a literal star)."
            },
            "level": {
              "type": "string",
              "description": "Level for cases that declare none (default: config.default_provided_level)."
            },
            "reason": {
              "type": "string",
              "description": "Why the target cannot be claimed per case."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "target",
            "whole"
          ],
          "properties": {
            "target": {
              "$ref": "#/$defs/label"
            },
            "whole": {
              "const": true,
              "description": "Every result of the target; its single synthetic result when it reports no cases."
            },
            "level": {
              "type": "string",
              "description": "Level for cases that declare none (default: config.default_provided_level)."
            },
            "reason": {
              "type": "string",
              "description": "Why the target cannot be claimed per case."
            }
          }
        },
        {
          "type": "object",
          "description": "DEPRECATED: {target} / {target, level} claims the whole target (rule bare-target-reference).",
          "additionalProperties": false,
          "required": [
            "target"
          ],
          "properties": {
            "target": {
              "$ref": "#/$defs/label"
            },
            "level": {
              "type": "string",
              "description": "Level for cases that declare none (default: config.default_provided_level)."
            }
          },
          "deprecated": true
        }
      ]
    },
    "ruleSeverity": {
      "enum": [
        "error",
        "warning",
        "off",
        false
      ]
    }
  }
}
