{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Decapod Constitution Core Discovery Graph",
  "version": "3.0.0",
  "type": "object",
  "required": [
    "$schema",
    "version",
    "nodes",
    "lookup"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "version": {
      "type": "string"
    },
    "nodes": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "$ref": "#/definitions/node"
      }
    },
    "lookup": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "maxItems": 12,
        "items": {
          "type": "string",
          "pattern": "^(core|architecture|docs|interfaces|methodology|plugins|specs|metadata|data|research)/[a-zA-Z0-9_./-]+$"
        }
      }
    }
  },
  "definitions": {
    "node": {
      "type": "object",
      "required": [
        "id",
        "category",
        "title",
        "authority",
        "binding",
        "summary",
        "terms",
        "links",
        "sections"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^(core|architecture|docs|interfaces|methodology|plugins|specs|metadata|data|research)/[a-zA-Z0-9_./-]+$"
        },
        "category": {
          "type": "string",
          "enum": [
            "core",
            "architecture",
            "docs",
            "interfaces",
            "methodology",
            "plugins",
            "specs",
            "metadata",
            "data",
            "research"
          ]
        },
        "title": {
          "type": "string",
          "minLength": 3,
          "maxLength": 80
        },
        "authority": {
          "type": "string",
          "enum": [
            "root-router",
            "namespace-router",
            "doctrine"
          ]
        },
        "binding": {
          "type": "string",
          "enum": [
            "binding",
            "advisory"
          ]
        },
        "summary": {
          "type": "string",
          "minLength": 40,
          "maxLength": 240
        },
        "terms": {
          "type": "array",
          "minItems": 5,
          "maxItems": 16,
          "items": {
            "type": "string",
            "minLength": 2,
            "maxLength": 40
          },
          "uniqueItems": true
        },
        "links": {
          "$ref": "#/definitions/links"
        },
        "sections": {
          "type": "object",
          "minProperties": 4,
          "maxProperties": 8,
          "propertyNames": {
            "pattern": "^[a-z][a-z0-9_]{2,32}$"
          },
          "additionalProperties": {
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "items": {
              "type": "string",
              "minLength": 20,
              "maxLength": 320
            }
          }
        }
      }
    },
    "links": {
      "type": "object",
      "required": [
        "references",
        "referenced_by"
      ],
      "additionalProperties": false,
      "properties": {
        "references": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "referenced_by": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      }
    }
  }
}
