{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kanoniq.extenza.dev/schema/adr.schema.json",
  "title": "Kanoniq decision record frontmatter",
  "$comment": "GENERATED FILE — do not edit. See x-generated below.",
  "x-generated": {
    "warning": "GENERATED FILE — do not edit.",
    "copyright": "© 2026 Extenza Works. Licensed under PolyForm Shield 1.0.0; see LICENSE.",
    "source": "src/lib-core/src/site/",
    "generator": "src/lib-core/scripts/generate-json-schema.ts",
    "documentation": "https://kanoniq.extenza.dev/docs/site/decision-records",
    "version": "0.4.1",
    "regenerate": "pnpm --filter @extenza-works/kanoniq-lib-core generate:schema"
  },
  "description": "Shape of the YAML frontmatter of one *.adr.md file. Shape only: whether the element's Id names an element of the model and its path is where that element is, and whether Lucide has an icon, are checked by kq portal:build.",
  "type": "object",
  "properties": {
    "title": {
      "description": "The record's title. Defaults to its name as it reads, from its file name.",
      "type": "string",
      "minLength": 1
    },
    "description": {
      "type": "string",
      "pattern": "^[^\\r\\n]*\\S[^\\r\\n]*$",
      "description": "One line of plain text: under the title, and on its tile."
    },
    "status": {
      "type": "string",
      "enum": [
        "proposed",
        "accepted",
        "rejected",
        "deprecated",
        "superseded"
      ],
      "description": "The decision's state. Not a page's status: a record is rendered whenever the page above it is.",
      "enumDescriptions": [
        "Put forward, not yet decided.",
        "Decided, and in force.",
        "Considered and turned down.",
        "No longer in force, with nothing in its place.",
        "Replaced by a later decision."
      ]
    },
    "superseded-by": {
      "type": "string",
      "pattern": "\\.adr\\.md$",
      "description": "The decision record that replaced this one: its file, by its path from portal/, such as Home/Selling/0005-Search-runs-on-OpenSearch.adr.md. Required when status is superseded, and only then."
    },
    "date": {
      "description": "When the decision was made, YYYY-MM-DD.",
      "type": "string",
      "format": "date",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
    },
    "icon": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
      "description": "The record's icon, by its Lucide name; scroll-text if none."
    },
    "element": {
      "description": "The model element the decision is about, or a list of them; left out for a decision about no one element.",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
              "description": "The element's Id, as the model's ids block holds it. The Id decides which element the record is about."
            },
            "path": {
              "type": "string",
              "minLength": 1,
              "description": "The element's path, such as shop/platform-orders/order-service, for a reader of the file. A path the element is no longer at is a warning."
            }
          },
          "required": [
            "id",
            "path"
          ],
          "additionalProperties": false,
          "description": "The model element the decision is about."
        },
        {
          "minItems": 1,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "description": "The element's Id, as the model's ids block holds it. The Id decides which element the record is about."
              },
              "path": {
                "type": "string",
                "minLength": 1,
                "description": "The element's path, such as shop/platform-orders/order-service, for a reader of the file. A path the element is no longer at is a warning."
              }
            },
            "required": [
              "id",
              "path"
            ],
            "additionalProperties": false,
            "description": "The model element the decision is about."
          },
          "description": "The model elements the decision is about, each by its Id and path."
        }
      ]
    }
  },
  "required": [
    "description",
    "status"
  ],
  "additionalProperties": false,
  "if": {
    "properties": {
      "status": {
        "const": "superseded"
      }
    },
    "required": [
      "status"
    ]
  },
  "then": {
    "required": [
      "superseded-by"
    ]
  },
  "else": {
    "not": {
      "required": [
        "superseded-by"
      ]
    }
  }
}
