{
  "$defs": {
    "HealthBand": {
      "description": "Health band (traffic-light).",
      "enum": [
        "red",
        "yellow",
        "green"
      ],
      "type": "string"
    },
    "HealthComponent": {
      "description": "Health component (one weighted dimension).",
      "properties": {
        "key": {
          "description": "Component key (e.g. \"usage\", \"engagement\", \"sentiment\",\n\"support_load\", \"billing\", \"advocacy\").",
          "type": "string"
        },
        "score": {
          "description": "Component score 0–100.",
          "format": "double",
          "type": "number"
        },
        "trend_30d": {
          "description": "Trend over last 30 days (delta in score units).",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "weight": {
          "description": "Weight in the composite (0.0-1.0).",
          "format": "double",
          "type": "number"
        }
      },
      "required": [
        "key",
        "score",
        "weight"
      ],
      "type": "object"
    },
    "HealthSignal": {
      "description": "One open risk or signal.",
      "properties": {
        "band": {
          "$ref": "#/$defs/HealthBand"
        },
        "label": {
          "type": "string"
        },
        "note": {
          "description": "Free-form narrative.",
          "type": "string"
        },
        "source_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/PathRef"
            },
            {
              "type": "null"
            }
          ],
          "description": "PathRef to triggering record (incident, support ticket)."
        }
      },
      "required": [
        "label",
        "band",
        "note"
      ],
      "type": "object"
    },
    "IsoDate": {
      "description": "ISO 8601 date (YYYY-MM-DD).",
      "format": "date",
      "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"
    },
    "PiiClass": {
      "description": "Personal-data classification on every record carrying personal data, per\nBDR 0070 / BDR 0069 / BDR 0078. Used by `corpospec-report` to gate\nrendering and by the privacy pillar's RoPA records to determine\nsafeguards.",
      "oneOf": [
        {
          "const": "none",
          "description": "No personal data.",
          "type": "string"
        },
        {
          "const": "public_personal",
          "description": "Public personal data (already disclosed by the subject, e.g. CEO name).",
          "type": "string"
        },
        {
          "const": "internal",
          "description": "Internal-only personal data (employee directory).",
          "type": "string"
        },
        {
          "const": "personal",
          "description": "Personal data per GDPR Art. 4(1).",
          "type": "string"
        },
        {
          "const": "special_category",
          "description": "Special-category data per GDPR Art. 9 (health, biometric, genetic,\nreligion, ethnicity, sex life, political opinion, trade union).",
          "type": "string"
        },
        {
          "const": "criminal_data",
          "description": "Criminal data per GDPR Art. 10.",
          "type": "string"
        },
        {
          "const": "sensitive",
          "description": "CCPA / CPRA \"sensitive personal information\".",
          "type": "string"
        }
      ]
    },
    "RenewalLikelihood": {
      "description": "Renewal-likelihood category.",
      "oneOf": [
        {
          "enum": [
            "unlikely",
            "at_risk",
            "likely",
            "committed"
          ],
          "type": "string"
        },
        {
          "const": "renewed",
          "description": "Already renewed.",
          "type": "string"
        }
      ]
    }
  },
  "$id": "https://corpospec.com/schemas/v0.16.0/customer-health.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Customer-health snapshot.",
  "properties": {
    "band": {
      "$ref": "#/$defs/HealthBand"
    },
    "captured_at": {
      "$ref": "#/$defs/IsoDate"
    },
    "components": {
      "items": {
        "$ref": "#/$defs/HealthComponent"
      },
      "type": "array"
    },
    "composite_score": {
      "description": "Composite score 0–100.",
      "format": "double",
      "type": "number"
    },
    "csm_owner": {
      "$ref": "#/$defs/PathRef",
      "description": "PathRef to the customer-success owner."
    },
    "customer": {
      "$ref": "#/$defs/PathRef",
      "description": "PathRef to the customer."
    },
    "days_to_renewal": {
      "description": "Days to renewal at capture.",
      "format": "int32",
      "type": "integer"
    },
    "id": {
      "$ref": "#/$defs/PathRef"
    },
    "pii_class": {
      "$ref": "#/$defs/PiiClass"
    },
    "recommended_action": {
      "description": "Recommended action (free-form).",
      "type": [
        "string",
        "null"
      ]
    },
    "renewal_date": {
      "$ref": "#/$defs/IsoDate",
      "description": "Renewal date."
    },
    "renewal_likelihood": {
      "$ref": "#/$defs/RenewalLikelihood"
    },
    "signals": {
      "description": "Active risk signals.",
      "items": {
        "$ref": "#/$defs/HealthSignal"
      },
      "type": "array"
    },
    "trend_snapshots": {
      "description": "PathRefs to historical snapshots feeding the trend.",
      "items": {
        "$ref": "#/$defs/PathRef"
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "customer",
    "captured_at",
    "composite_score",
    "band",
    "components",
    "renewal_likelihood",
    "renewal_date",
    "days_to_renewal",
    "signals",
    "csm_owner",
    "pii_class"
  ],
  "title": "CustomerHealth",
  "type": "object",
  "x-corpospec-pillar": "market"
}