{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/welkaim/ea-codex/schemas/v1/architecture-change-packet.json",
  "title": "ArchitectureChangePacket",
  "description": "TOGAF ADM-aligned change packet. Carries the architectural content of one change end-to-end across Architecture Vision, Business Architecture, Architecture Decisions, and downstream phases. Introduced in Chapter 12.",
  "type": "object",
  "required": ["apiVersion", "kind", "metadata", "spec"],
  "properties": {
    "apiVersion": { "$ref": "_common.json#/$defs/apiVersion" },
    "kind": { "type": "string", "const": "ArchitectureChangePacket" },
    "metadata": {
      "allOf": [
        { "$ref": "_common.json#/$defs/metadata" },
        {
          "type": "object",
          "properties": {
            "title": { "type": "string" }
          }
        }
      ]
    },
    "spec": {
      "type": "object",
      "required": ["intent", "capabilityScope", "policies", "designDecision"],
      "properties": {
        "intent": {
          "type": "object",
          "required": ["objectiveRef", "statement"],
          "properties": {
            "objectiveRef": { "$ref": "_common.json#/$defs/objectiveRef" },
            "statement": { "type": "string" },
            "successMeasures": {
              "type": "array",
              "items": {
                "type": "object",
                "required": ["name", "target"],
                "properties": {
                  "name": { "type": "string" },
                  "target": { "type": "string" }
                },
                "additionalProperties": true
              }
            }
          },
          "additionalProperties": true
        },
        "capabilityScope": {
          "type": "object",
          "properties": {
            "primary": {
              "type": "array",
              "items": { "type": "string" },
              "minItems": 1
            },
            "related": {
              "type": "array",
              "items": { "type": "string" }
            }
          },
          "additionalProperties": true
        },
        "policies": {
          "type": "array",
          "description": "Each entry is a single-key map from policy identifier to its requirement statement, in the form { POL-XXX-NNN: \"...\" }.",
          "items": {
            "type": "object",
            "minProperties": 1,
            "maxProperties": 1
          }
        },
        "designDecision": {
          "type": "object",
          "required": ["id", "topic", "context", "choice"],
          "properties": {
            "id": { "$ref": "_common.json#/$defs/decisionRef" },
            "topic": { "type": "string" },
            "context": { "type": "string" },
            "choice": { "type": "string" },
            "rationale": { "type": "string" },
            "alternatives": {
              "type": "array",
              "items": { "type": "string" }
            }
          },
          "additionalProperties": true
        },
        "controls": {
          "type": "array",
          "items": { "type": "string" }
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
