{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/welkaim/ea-codex/schemas/v1/product-line-specification.json",
  "title": "ProductLineSpecification",
  "description": "Software product line family definition. Captures the stable common core, named variation points with binding times, and the rules that link variant selection to policy consequences. Introduced in Chapter 9. All sub-fields use camelCase; the artifact uses the standard metadata + spec envelope.",
  "type": "object",
  "required": ["apiVersion", "kind", "metadata", "spec"],
  "properties": {
    "apiVersion": { "$ref": "_common.json#/$defs/apiVersion" },
    "kind": { "type": "string", "const": "ProductLineSpecification" },
    "metadata": { "$ref": "_common.json#/$defs/metadata" },
    "spec": {
      "type": "object",
      "required": ["intent", "scope", "commonality", "variationPoints"],
      "properties": {
        "intent": {
          "type": "object",
          "required": ["statement"],
          "properties": {
            "statement": { "type": "string" }
          },
          "additionalProperties": true
        },
        "scope": {
          "type": "object",
          "required": ["capabilities"],
          "properties": {
            "capabilities": {
              "type": "array",
              "items": { "type": "string" },
              "minItems": 1
            }
          },
          "additionalProperties": true
        },
        "commonality": {
          "type": "object",
          "description": "Stable core that every family member inherits.",
          "properties": {
            "coreServices": {
              "type": "array",
              "items": { "type": "string" }
            },
            "canonicalObjects": {
              "type": "array",
              "items": { "type": "string" }
            },
            "mandatoryControls": {
              "type": "array",
              "items": { "type": "string" }
            }
          },
          "additionalProperties": true
        },
        "variationPoints": {
          "type": "object",
          "description": "Map from variation-point name to its definition.",
          "minProperties": 1,
          "additionalProperties": {
            "type": "object",
            "required": ["type", "bindingTime"],
            "properties": {
              "type": {
                "type": "string",
                "enum": ["alternative", "optional", "multiple"]
              },
              "values": {
                "type": "array",
                "items": { "type": ["string", "number", "boolean"] }
              },
              "bindingTime": {
                "type": "string",
                "enum": ["design", "decision", "build", "deployment", "runtime"]
              }
            },
            "additionalProperties": true
          }
        },
        "rules": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "when": { "type": "string" },
              "require": {
                "type": "array",
                "items": { "type": "string" }
              },
              "forbid": {
                "type": "array",
                "items": { "type": "string" }
              }
            },
            "additionalProperties": true
          }
        },
        "decisions": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "statement"],
            "properties": {
              "id": { "$ref": "_common.json#/$defs/decisionRef" },
              "statement": { "type": "string" }
            },
            "additionalProperties": true
          }
        },
        "derivationOutputs": {
          "type": "array",
          "items": { "type": "string" }
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
