{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://cognitivedelivery.co.uk/contract/1.0.0/cdi-assessment.schema.json",
  "title": "CDF CDI assessment record",
  "description": "A recorded human assessment against the six Index dimensions, on a ninety-day cadence. Distinct from the signal log: signals are emitted automatically, this is a judgement someone made and put their name to. CORRECTED against real artefacts: every field is snake_case on disk (level_label, average_score, lowest_score, lowest_dimensions) while the TypeScript interface is camelCase. The writer wins.",
  "type": "object",
  "required": [
    "schema_version",
    "assessment_id",
    "created_at",
    "assessor",
    "participants",
    "dimensions",
    "summary",
    "ninety_day_priority",
    "next_assessment_due",
    "source"
  ],
  "properties": {
    "schema_version": {
      "type": "string"
    },
    "assessment_id": {
      "type": "string"
    },
    "created_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$",
      "description": "ISO 8601 with a timezone."
    },
    "assessor": {
      "type": "string"
    },
    "participants": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "dimensions": {
      "type": "array",
      "description": "One entry per dimension. The dimension set is closed because it is the instrument.",
      "items": {
        "type": "object",
        "required": [
          "id",
          "score",
          "evidence",
          "name",
          "level_label"
        ],
        "properties": {
          "id": {
            "$ref": "#/definitions/dimensionId"
          },
          "score": {
            "type": "number",
            "minimum": 1,
            "maximum": 5,
            "description": "1 Absent, 2 Informal, 3 Documented, 4 Complete, 5 Substantive. The four-to-five step is the distinction between a control that exists and a control that changes what someone does."
          },
          "evidence": {
            "type": "string",
            "description": "Why this score. A score without evidence is an opinion."
          },
          "name": {
            "type": "string"
          },
          "level_label": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "summary": {
      "type": "object",
      "required": [
        "average_score",
        "lowest_score",
        "lowest_dimensions",
        "profile"
      ],
      "properties": {
        "profile": {
          "type": "string",
          "enum": [
            "flat",
            "audit-ready",
            "split",
            "brittle",
            "emerging"
          ]
        },
        "average_score": {
          "type": "number"
        },
        "lowest_score": {
          "type": "number"
        },
        "lowest_dimensions": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/dimensionId"
          }
        }
      },
      "additionalProperties": true
    },
    "ninety_day_priority": {
      "type": "object",
      "required": [
        "dimension",
        "action",
        "success_measure",
        "review_date"
      ],
      "properties": {
        "dimension": {
          "$ref": "#/definitions/dimensionId"
        },
        "action": {
          "type": "string"
        },
        "success_measure": {
          "type": "string",
          "description": "How you will know it worked. Required, so that a priority cannot be recorded without one."
        },
        "review_date": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "next_assessment_due": {
      "type": "string"
    },
    "source": {
      "type": "object",
      "description": "Self-describing, so a record found on its own still says what instrument produced it.",
      "required": [
        "instrument",
        "version"
      ],
      "properties": {
        "instrument": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true,
  "definitions": {
    "dimensionId": {
      "type": "string",
      "enum": [
        "provenance-integrity",
        "supervisory-clarity",
        "scope-definition",
        "review-substance",
        "constraint-fidelity",
        "capability-calibration"
      ]
    }
  }
}
