{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/welkaim/ea-codex/schemas/v1/architecture-package.json",
  "title": "ArchitecturePackage",
  "description": "BMAD-staged unit of architectural change. Each instance carries the artifact's content across the four BMAD stages: Brief (intent), Map (architecture), Act (executable artifacts), Double-check (evidence). Introduced in Chapter 7. Note: this kind places identifiers at the top level rather than under metadata, preserved from the book.",
  "type": "object",
  "required": ["apiVersion", "kind", "id", "name", "brief", "map", "act", "doubleCheck"],
  "properties": {
    "apiVersion": { "$ref": "_common.json#/$defs/apiVersion" },
    "kind": { "type": "string", "const": "ArchitecturePackage" },
    "id": { "$ref": "_common.json#/$defs/identifier" },
    "name": { "type": "string", "minLength": 1 },
    "domain": { "type": "string" },
    "status": { "$ref": "_common.json#/$defs/lifecycleStatus" },
    "version": { "$ref": "_common.json#/$defs/version" },
    "brief": {
      "type": "object",
      "description": "Brief stage: intent, scope, and decision obligations.",
      "required": ["intent", "capabilityScope"],
      "properties": {
        "intent": {
          "type": "object",
          "required": ["outcome"],
          "properties": {
            "outcome": { "type": "string" },
            "value": { "type": "string" }
          },
          "additionalProperties": true
        },
        "capabilityScope": {
          "type": "array",
          "items": { "type": "string" },
          "minItems": 1
        },
        "decisionObligations": {
          "type": "array",
          "items": { "type": "string" }
        }
      },
      "additionalProperties": true
    },
    "map": {
      "type": "object",
      "description": "Map stage: architectural binding to family, variation points, and design decisions.",
      "properties": {
        "familyBinding": {
          "type": "object",
          "properties": {
            "productLine": { "type": "string" },
            "variant": { "type": "string" },
            "permittedVariationPoints": {
              "type": "array",
              "items": { "type": "string" }
            },
            "forbiddenVariationPoints": {
              "type": "array",
              "items": { "type": "string" }
            }
          },
          "additionalProperties": true
        },
        "designDecisions": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "topic", "option"],
            "properties": {
              "id": { "$ref": "_common.json#/$defs/decisionRef" },
              "topic": { "type": "string" },
              "option": { "type": "string" },
              "rationale": { "type": "string" }
            },
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    },
    "act": {
      "type": "object",
      "description": "Act stage: executable Codex assets the package produces or consumes.",
      "properties": {
        "codexAssets": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    },
    "doubleCheck": {
      "type": "object",
      "description": "Double-check stage: evidence that closes the package.",
      "properties": {
        "evidence": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
