{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paloframework.org/schemas/palo-stack-governance-model.schema.json",
  "title": "PALO stack architecture extension",
  "type": "object",
  "properties": {
    "format": {
      "const": "palo-stack-governance-model"
    },
    "schemaVersion": {
      "const": "1.0.0"
    },
    "extensionVersion": {
      "const": "0.1.0"
    },
    "status": {
      "const": "draft"
    },
    "foundationRef": {
      "type": "string",
      "minLength": 1
    },
    "foundationVersion": {
      "const": "3.1.0"
    },
    "reviewedAt": {
      "type": "string",
      "format": "date"
    },
    "authorityBoundary": {
      "type": "string",
      "minLength": 1
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "id",
          "url"
        ],
        "additionalProperties": false
      }
    },
    "entityTypes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "semanticId": {
            "type": "string",
            "format": "uri"
          },
          "origin": {
            "enum": [
              "palo-3.1",
              "stack-extension-0.1"
            ]
          }
        },
        "required": [
          "id",
          "semanticId",
          "origin"
        ],
        "additionalProperties": false
      }
    },
    "relationshipTypes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "sourceTypes": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "targetTypes": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "meaning": {
            "type": "string",
            "minLength": 1
          },
          "maxPerSource": {
            "type": "integer",
            "minimum": 1
          },
          "minPerSource": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "id",
          "sourceTypes",
          "targetTypes",
          "meaning"
        ],
        "additionalProperties": false
      }
    },
    "view": {
      "type": "object",
      "properties": {
        "nodes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/node"
          }
        },
        "links": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/link"
          }
        }
      },
      "required": [
        "nodes",
        "links"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "format",
    "schemaVersion",
    "extensionVersion",
    "status",
    "foundationRef",
    "foundationVersion",
    "reviewedAt",
    "authorityBoundary",
    "sources",
    "entityTypes",
    "relationshipTypes",
    "view"
  ],
  "additionalProperties": false,
  "$defs": {
    "authorityClass": {
      "type": "object",
      "required": [
        "label",
        "meaning",
        "authoritative"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "meaning": {
          "type": "string",
          "minLength": 1
        },
        "authoritative": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "node": {
      "type": "object",
      "required": [
        "id",
        "label",
        "type",
        "phaseId",
        "role",
        "status",
        "semanticId",
        "definitionVersion",
        "evidenceClass",
        "authorityBoundary",
        "sourceRefs",
        "lastReviewed"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]*$"
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "enum": [
            "layer",
            "plane",
            "component"
          ]
        },
        "phaseId": {
          "enum": [
            "frame",
            "classify",
            "assess",
            "control",
            "measure",
            "prove"
          ]
        },
        "role": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "minLength": 1
        },
        "semanticId": {
          "type": "string",
          "format": "uri"
        },
        "definitionVersion": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+$"
        },
        "evidenceClass": {
          "enum": [
            "canonical-definition",
            "source-backed-context",
            "illustrative-local-preview",
            "human-review-required"
          ]
        },
        "authorityBoundary": {
          "type": "string",
          "minLength": 1
        },
        "sourceRefs": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string"
          }
        },
        "lastReviewed": {
          "type": "string",
          "format": "date"
        },
        "properties": {
          "type": "object"
        },
        "outputs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    },
    "link": {
      "type": "object",
      "required": [
        "source",
        "target",
        "verb",
        "weight",
        "meaning",
        "artifactTransferred",
        "relationType",
        "semanticId",
        "relationshipVersion",
        "mappingBasis"
      ],
      "properties": {
        "source": {
          "type": "string"
        },
        "target": {
          "type": "string"
        },
        "verb": {
          "type": "string",
          "minLength": 1
        },
        "weight": {
          "type": "string",
          "pattern": "^W[2-5]$"
        },
        "meaning": {
          "type": "string",
          "minLength": 1
        },
        "artifactTransferred": {
          "type": "string"
        },
        "relationType": {
          "enum": [
            "operational",
            "evidence",
            "feedback",
            "context",
            "support",
            "navigation"
          ]
        },
        "semanticId": {
          "type": "string",
          "format": "uri"
        },
        "relationshipVersion": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+$"
        },
        "mappingBasis": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    }
  }
}
