{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dicworkflowkit.local/schemas/contract-obligations.schema.json",
  "title": "DIC Contract Obligations",
  "type": "object",
  "required": ["schema", "version", "changeId", "changeLifecycle", "authorityPolicy", "sources", "counts", "obligations"],
  "properties": {
    "schema": { "const": "dic.contract-obligations.v1" },
    "version": { "type": "string" },
    "changeId": { "type": "string" },
    "changeLifecycle": { "enum": ["active", "archived"] },
    "authorityPolicy": { "type": "string" },
    "sources": { "type": "array", "items": { "type": "string" } },
    "counts": {
      "type": "object",
      "required": ["requirements", "scenarios", "total"],
      "properties": {
        "requirements": { "type": "integer", "minimum": 0 },
        "scenarios": { "type": "integer", "minimum": 0 },
        "total": { "type": "integer", "minimum": 0 }
      }
    },
    "obligations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "capabilityId", "kind", "title", "statement", "source", "line", "authority", "parentId", "acceptanceClauses"],
        "properties": {
          "id": { "type": "string", "pattern": "^obl-[0-9a-f]{12}$" },
          "capabilityId": { "type": "string" },
          "kind": { "enum": ["requirement", "scenario"] },
          "title": { "type": "string" },
          "statement": { "type": "string" },
          "source": { "type": "string" },
          "line": { "type": "integer", "minimum": 1 },
          "authority": { "enum": ["active-change", "current-baseline"] },
          "parentId": { "type": ["string", "null"] },
          "acceptanceClauses": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["keyword", "text", "line"],
              "properties": {
                "keyword": { "enum": ["GIVEN", "WHEN", "THEN", "AND", "BUT"] },
                "text": { "type": "string" },
                "line": { "type": "integer", "minimum": 1 }
              }
            }
          }
        }
      }
    }
  },
  "additionalProperties": false
}
