{
  "$defs": {
    "CorrectiveAction": {
      "description": "Corrective-action item.",
      "properties": {
        "completed": {
          "type": "boolean"
        },
        "completed_on": {
          "anyOf": [
            {
              "$ref": "#/$defs/IsoDate"
            },
            {
              "type": "null"
            }
          ]
        },
        "description": {
          "type": "string"
        },
        "due_date": {
          "$ref": "#/$defs/IsoDate"
        },
        "owner": {
          "$ref": "#/$defs/PathRef"
        },
        "tracker_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/PathRef"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "description",
        "owner",
        "due_date",
        "completed"
      ],
      "type": "object"
    },
    "IncidentTimeline": {
      "description": "One timeline entry.",
      "properties": {
        "actor": {
          "$ref": "#/$defs/PathRef"
        },
        "at": {
          "$ref": "#/$defs/IsoDate"
        },
        "note": {
          "type": "string"
        }
      },
      "required": [
        "at",
        "actor",
        "note"
      ],
      "type": "object"
    },
    "IsoDate": {
      "description": "ISO 8601 date (YYYY-MM-DD).",
      "format": "date",
      "type": "string"
    },
    "OpIncidentKind": {
      "description": "Incident kind.",
      "oneOf": [
        {
          "const": "outage",
          "description": "Full outage.",
          "type": "string"
        },
        {
          "const": "partial_outage",
          "description": "Partial outage.",
          "type": "string"
        },
        {
          "const": "performance_degradation",
          "description": "Performance degradation.",
          "type": "string"
        },
        {
          "const": "data_correctness",
          "description": "Data correctness / consistency.",
          "type": "string"
        },
        {
          "const": "billing",
          "description": "Billing error.",
          "type": "string"
        },
        {
          "const": "feature_breakage",
          "description": "Customer-facing UX / feature broken.",
          "type": "string"
        },
        {
          "const": "dependency_failure",
          "description": "Third-party dependency failure.",
          "type": "string"
        },
        {
          "const": "deployment_rollback",
          "description": "Deployment / release-introduced regression.",
          "type": "string"
        },
        {
          "const": "capacity",
          "description": "Capacity / saturation.",
          "type": "string"
        },
        {
          "const": "configuration",
          "description": "Configuration error.",
          "type": "string"
        }
      ]
    },
    "OpIncidentSeverity": {
      "description": "Incident severity.",
      "oneOf": [
        {
          "const": "sev5",
          "description": "Sev-5 — informational / non-impacting.",
          "type": "string"
        },
        {
          "const": "sev4",
          "description": "Sev-4 — minor degradation; few users affected.",
          "type": "string"
        },
        {
          "const": "sev3",
          "description": "Sev-3 — partial outage / significant degradation.",
          "type": "string"
        },
        {
          "const": "sev2",
          "description": "Sev-2 — major outage / many users impacted.",
          "type": "string"
        },
        {
          "const": "sev1",
          "description": "Sev-1 — full outage / business-critical.",
          "type": "string"
        }
      ]
    },
    "OpIncidentStatus": {
      "description": "Lifecycle.",
      "enum": [
        "detected",
        "investigating",
        "mitigating",
        "resolved",
        "postmortem",
        "closed"
      ],
      "type": "string"
    },
    "PathRef": {
      "description": "Path-based cross-reference relative to .corpospec/ root.\nPattern: `^[a-z0-9_-]+(/[a-z0-9_.-]+)+$`",
      "pattern": "^[a-z0-9_-]+(/[a-z0-9_.-]+)+$",
      "type": "string"
    }
  },
  "$id": "https://corpospec.com/schemas/v0.16.0/incident.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Operational incident.",
  "properties": {
    "affected_customers": {
      "description": "Affected customer count (best estimate).",
      "format": "int32",
      "type": "integer"
    },
    "affected_services": {
      "description": "PathRefs to affected services.",
      "items": {
        "$ref": "#/$defs/PathRef"
      },
      "type": "array"
    },
    "contributing_factors": {
      "description": "Contributing factors (non-blameless framing).",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "corrective_actions": {
      "items": {
        "$ref": "#/$defs/CorrectiveAction"
      },
      "type": "array"
    },
    "created_at": {
      "$ref": "#/$defs/IsoDate"
    },
    "customer_facing": {
      "description": "Whether customers were directly impacted.",
      "type": "boolean"
    },
    "detected_at": {
      "$ref": "#/$defs/IsoDate"
    },
    "entity": {
      "$ref": "#/$defs/PathRef"
    },
    "id": {
      "$ref": "#/$defs/PathRef"
    },
    "impact_started_at": {
      "anyOf": [
        {
          "$ref": "#/$defs/IsoDate"
        },
        {
          "type": "null"
        }
      ],
      "description": "When users first felt impact (may pre-date detection)."
    },
    "incident_commander": {
      "$ref": "#/$defs/PathRef"
    },
    "kind": {
      "$ref": "#/$defs/OpIncidentKind"
    },
    "mitigated_at": {
      "anyOf": [
        {
          "$ref": "#/$defs/IsoDate"
        },
        {
          "type": "null"
        }
      ]
    },
    "postmortem_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to the postmortem document."
    },
    "resolved_at": {
      "anyOf": [
        {
          "$ref": "#/$defs/IsoDate"
        },
        {
          "type": "null"
        }
      ]
    },
    "root_cause": {
      "description": "Root-cause narrative.",
      "type": [
        "string",
        "null"
      ]
    },
    "runbook_refs": {
      "description": "PathRefs to runbooks used.",
      "items": {
        "$ref": "#/$defs/PathRef"
      },
      "type": "array"
    },
    "severity": {
      "$ref": "#/$defs/OpIncidentSeverity"
    },
    "sla_credit_pct": {
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "sla_credit_triggered": {
      "description": "Whether SLA credit was triggered (cross-link to\nservice_level_agreement.rs).",
      "type": "boolean"
    },
    "status": {
      "$ref": "#/$defs/OpIncidentStatus"
    },
    "status_page_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to status-page artefact."
    },
    "status_page_updated": {
      "description": "Whether a status-page update was published.",
      "type": "boolean"
    },
    "summary": {
      "type": "string"
    },
    "timeline": {
      "items": {
        "$ref": "#/$defs/IncidentTimeline"
      },
      "type": "array"
    },
    "title": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "entity",
    "kind",
    "severity",
    "status",
    "title",
    "summary",
    "detected_at",
    "affected_services",
    "affected_customers",
    "customer_facing",
    "status_page_updated",
    "incident_commander",
    "timeline",
    "corrective_actions",
    "sla_credit_triggered",
    "created_at"
  ],
  "title": "Incident",
  "type": "object",
  "x-corpospec-pillar": "operations"
}