{
  "title": "SmartMart Operational Analysis (AI structured output)",
  "description": "JSON object expected by SmartMart /api/v1/ai-operations/recommendations. Mirrors the strict Laravel side validation (AIRecommendationService).",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "incident_id",
    "incident_type",
    "severity",
    "confidence",
    "summary",
    "root_causes",
    "business_impact",
    "recommended_actions"
  ],
  "properties": {
    "incident_id": {
      "type": "string",
      "minLength": 1
    },
    "incident_type": {
      "type": "string",
      "enum": [
        "fulfillment_sla",
        "inventory_shortage",
        "workforce_capacity",
        "support_pressure",
        "operations_risk"
      ]
    },
    "severity": {
      "type": "string",
      "enum": ["NORMAL", "WATCH", "ELEVATED", "HIGH", "CRITICAL"]
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "summary": {
      "type": "string",
      "minLength": 1
    },
    "evidence": {
      "type": "array",
      "items": { "type": "object" }
    },
    "root_causes": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string" }
    },
    "business_impact": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string" }
    },
    "affected_products": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sku": { "type": "string" },
          "name": { "type": "string" }
        }
      }
    },
    "recommended_actions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["action", "title", "reason", "requires_approval"],
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "create_replenishment_task",
              "create_task",
              "send_internal_notification",
              "escalate",
              "reallocate_staff",
              "create_supplier_purchase",
              "request_refund"
            ]
          },
          "action_type": {
            "type": "string"
          },
          "title": { "type": "string" },
          "reason": { "type": "string" },
          "description": { "type": "string" },
          "requires_approval": { "type": "boolean" },
          "payload": { "type": "object" }
        }
      }
    }
  }
}