{
  "$defs": {
    "CohortResult": {
      "description": "Cohort breakdown (e.g. by tenure-band, role-family, region).",
      "properties": {
        "cohort": {
          "description": "Cohort label (e.g. \"tenure_0_to_1y\", \"region_dach\").",
          "type": "string"
        },
        "enps": {
          "description": "eNPS, when applicable.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "question_rollups": {
          "items": {
            "$ref": "#/$defs/QuestionRollup"
          },
          "type": "array"
        },
        "response_count": {
          "format": "int32",
          "type": "integer"
        },
        "size": {
          "format": "int32",
          "type": "integer"
        }
      },
      "required": [
        "cohort",
        "size",
        "response_count",
        "question_rollups"
      ],
      "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"
    },
    "QuestionRollup": {
      "description": "Per-question rollup (aggregate across respondents in a cohort).",
      "properties": {
        "key": {
          "description": "Question key (stable across surveys for trend analysis).",
          "type": "string"
        },
        "mean": {
          "description": "Mean response on a 1-5 Likert or single-numeric question.",
          "format": "double",
          "type": "number"
        },
        "median": {
          "format": "double",
          "type": "number"
        },
        "n": {
          "description": "Response count (informs statistical significance).",
          "format": "int32",
          "type": "integer"
        },
        "stddev": {
          "format": "double",
          "type": "number"
        },
        "text": {
          "type": "string"
        }
      },
      "required": [
        "key",
        "text",
        "mean",
        "median",
        "stddev",
        "n"
      ],
      "type": "object"
    },
    "SurveyKind": {
      "description": "Survey type.",
      "oneOf": [
        {
          "enum": [
            "other"
          ],
          "type": "string"
        },
        {
          "const": "enps",
          "description": "Employee Net Promoter Score (single question, -100..100).",
          "type": "string"
        },
        {
          "const": "engagement",
          "description": "Quarterly engagement.",
          "type": "string"
        },
        {
          "const": "pulse",
          "description": "Lightweight pulse / weekly.",
          "type": "string"
        },
        {
          "const": "manager_effectiveness",
          "description": "Manager effectiveness.",
          "type": "string"
        },
        {
          "const": "deib",
          "description": "Diversity, Equity, Inclusion, Belonging.",
          "type": "string"
        },
        {
          "const": "exit",
          "description": "Exit survey (leavers).",
          "type": "string"
        },
        {
          "const": "onboarding_experience",
          "description": "Onboarding satisfaction.",
          "type": "string"
        }
      ]
    },
    "SurveyStatus": {
      "description": "Survey status.",
      "enum": [
        "draft",
        "open",
        "closed",
        "analysed",
        "archived"
      ],
      "type": "string"
    }
  },
  "$id": "https://corpospec.com/schemas/v0.16.0/engagement-survey.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Engagement survey.",
  "properties": {
    "anonymity_floor": {
      "description": "Minimum cohort size below which results are suppressed to\nprotect anonymity (typical: 5).",
      "format": "int32",
      "type": "integer"
    },
    "close_at": {
      "$ref": "#/$defs/IsoDate"
    },
    "cohort_results": {
      "items": {
        "$ref": "#/$defs/CohortResult"
      },
      "type": "array"
    },
    "enps": {
      "description": "Overall eNPS (only for kind == Enps).",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "entity": {
      "$ref": "#/$defs/PathRef"
    },
    "id": {
      "$ref": "#/$defs/PathRef"
    },
    "kind": {
      "$ref": "#/$defs/SurveyKind"
    },
    "methodology_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef into the methodology / vendor description."
    },
    "name": {
      "type": "string"
    },
    "open_at": {
      "$ref": "#/$defs/IsoDate"
    },
    "population_size": {
      "format": "int32",
      "type": "integer"
    },
    "response_count": {
      "format": "int32",
      "type": "integer"
    },
    "retention_until": {
      "$ref": "#/$defs/IsoDate",
      "description": "Retention 3 years (BGB §195 default civil claims)."
    },
    "status": {
      "$ref": "#/$defs/SurveyStatus"
    }
  },
  "required": [
    "id",
    "entity",
    "kind",
    "name",
    "open_at",
    "close_at",
    "population_size",
    "response_count",
    "cohort_results",
    "status",
    "retention_until",
    "anonymity_floor"
  ],
  "title": "EngagementSurvey",
  "type": "object",
  "x-corpospec-pillar": "people"
}