{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.cuddler.dev/standards/specification-root-1.0.0.json",
  "title": "Specification Root",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "meta",
    "content"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "const": "https://www.cuddler.dev/standards/specification-root-1.0.0.json"
    },
    "meta": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "standardId",
        "standardVersion",
        "documentType",
        "domainSpecificationId",
        "version",
        "title",
        "status",
        "publishedAt",
        "updatedAt",
        "canonicalVersionUrl",
        "canonicalDocumentRoleSpecificationUrl",
        "summary",
        "authors",
        "license",
        "copyright"
      ],
      "properties": {
        "standardId": {
          "type": "string",
          "const": "specification-root"
        },
        "standardVersion": {
          "type": "string",
          "const": "1.0.0"
        },
        "documentType": {
          "type": "string",
          "const": "document-role-specification"
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+$"
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "enum": [
            "Public normative publication"
          ]
        },
        "publishedAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "summary": {
          "type": "string",
          "minLength": 40
        },
        "authors": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        },
        "license": {
          "type": "string",
          "minLength": 1
        },
        "copyright": {
          "type": "string",
          "minLength": 1
        },
        "canonicalVersionUrl": {
          "type": "string",
          "pattern": "^https://www\\.cuddler\\.dev/standards/document-role/[a-z][a-z0-9-]*/$"
        },
        "canonicalDocumentRoleSpecificationUrl": {
          "type": "string",
          "pattern": "^https://www\\.cuddler\\.dev/standards/document-role/[a-z][a-z0-9-]*/v\\d+\\.\\d+\\.\\d+/document-role-specification\\.json$"
        },
        "domainSpecificationId": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$"
        }
      }
    },
    "content": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "abstract",
        "documentMediaType",
        "documentHtml",
        "execution",
        "artifactGroups",
        "sectionSummaries",
        "references"
      ],
      "properties": {
        "abstract": {
          "type": "string",
          "minLength": 40
        },
        "documentMediaType": {
          "type": "string",
          "const": "text/html"
        },
        "documentHtml": {
          "type": "string",
          "minLength": 1000,
          "pattern": "<h2"
        },
        "execution": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "implementerRequirements",
            "validationWorkflow",
            "publicationNotes"
          ],
          "properties": {
            "implementerRequirements": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "validationWorkflow": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "publicationNotes": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        },
        "artifactGroups": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "key",
              "title",
              "items"
            ],
            "properties": {
              "key": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9-]*$"
              },
              "title": {
                "type": "string",
                "minLength": 1
              },
              "items": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "title",
                    "role",
                    "publicationClass",
                    "mediaType",
                    "url"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9-]*$"
                    },
                    "title": {
                      "type": "string",
                      "minLength": 1
                    },
                    "role": {
                      "type": "string",
                      "minLength": 1
                    },
                    "publicationClass": {
                      "type": "string",
                      "enum": [
                        "normative",
                        "supporting",
                        "informative",
                        "example"
                      ]
                    },
                    "mediaType": {
                      "type": "string",
                      "minLength": 1
                    },
                    "url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "sha256": {
                      "type": "string",
                      "pattern": "^[A-Fa-f0-9]{64}$"
                    },
                    "notes": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              }
            }
          }
        },
        "sectionSummaries": {
          "type": "array",
          "minItems": 8,
          "maxItems": 8,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "key",
              "title",
              "summary"
            ],
            "properties": {
              "key": {
                "type": "string",
                "enum": [
                  "overview",
                  "scope",
                  "implementation",
                  "validation",
                  "artifacts",
                  "security",
                  "change-management",
                  "references"
                ]
              },
              "title": {
                "type": "string",
                "minLength": 1
              },
              "summary": {
                "type": "string",
                "minLength": 20
              }
            }
          },
          "allOf": [
            {
              "contains": {
                "type": "object",
                "properties": {
                  "key": {
                    "const": "overview"
                  }
                }
              },
              "minContains": 1
            },
            {
              "contains": {
                "type": "object",
                "properties": {
                  "key": {
                    "const": "scope"
                  }
                }
              },
              "minContains": 1
            },
            {
              "contains": {
                "type": "object",
                "properties": {
                  "key": {
                    "const": "implementation"
                  }
                }
              },
              "minContains": 1
            },
            {
              "contains": {
                "type": "object",
                "properties": {
                  "key": {
                    "const": "validation"
                  }
                }
              },
              "minContains": 1
            },
            {
              "contains": {
                "type": "object",
                "properties": {
                  "key": {
                    "const": "artifacts"
                  }
                }
              },
              "minContains": 1
            },
            {
              "contains": {
                "type": "object",
                "properties": {
                  "key": {
                    "const": "security"
                  }
                }
              },
              "minContains": 1
            },
            {
              "contains": {
                "type": "object",
                "properties": {
                  "key": {
                    "const": "change-management"
                  }
                }
              },
              "minContains": 1
            },
            {
              "contains": {
                "type": "object",
                "properties": {
                  "key": {
                    "const": "references"
                  }
                }
              },
              "minContains": 1
            }
          ]
        },
        "references": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "normative",
            "informative"
          ],
          "properties": {
            "normative": {
              "type": "array",
              "minItems": 1,
              "items": {
                "$ref": "#/$defs/reference"
              }
            },
            "informative": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/reference"
              }
            }
          }
        }
      }
    }
  },
  "$defs": {
    "reference": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "title",
        "locator"
      ],
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1
        },
        "locator": {
          "type": "string",
          "minLength": 1
        }
      }
    }
  },
  "for-ai": [
    {
      "instruction": "Use this guidance when preparing a valid value for this schema node.",
      "input": "",
      "output": "Schema for the topmost canonical node in the Cuddler specification hierarchy. Published Document Role Specifications comply with this root, while the shared Artifact Specification remains a distinct cross-domain governing standard for Artifact Definitions."
    }
  ]
}
