{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://cognitive-delivery.github.io/contract/1.x/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",
      "pattern": "^\\d+\\.\\d+$",
      "description": "Contract version this record was written against, as `major.minor`. One rule across every schema (schema set 1.2): a reader compares the major only, and a minor it has not met is additive by the contract's own rule.",
      "$comment": "stability: stable"
    },
    "assessment_id": {
      "type": "string",
      "$comment": "stability: stable"
    },
    "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.",
      "$comment": "stability: stable"
    },
    "assessor": {
      "type": "string",
      "$comment": "stability: stable"
    },
    "participants": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "$comment": "stability: stable"
    },
    "dimensions": {
      "type": "array",
      "description": "One entry per dimension, each of the six exactly once (schema set 1.2: `minItems`, `maxItems` and one `contains` per id). The dimension set is closed because it is the instrument; an assessment of five dimensions is not an assessment.",
      "items": {
        "type": "object",
        "required": [
          "id",
          "score",
          "evidence",
          "name",
          "level_label"
        ],
        "properties": {
          "id": {
            "$ref": "#/definitions/dimensionId",
            "$comment": "stability: stable"
          },
          "score": {
            "type": "integer",
            "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. A whole number: the levels are discrete and a 3.7 is a score nobody can act on.",
            "$comment": "stability: stable"
          },
          "evidence": {
            "type": "string",
            "description": "Why this score. A score without evidence is an opinion.",
            "$comment": "stability: stable"
          },
          "name": {
            "type": "string",
            "$comment": "stability: stable"
          },
          "level_label": {
            "type": "string",
            "$comment": "stability: stable"
          }
        },
        "additionalProperties": true
      },
      "minItems": 6,
      "maxItems": 6,
      "allOf": [
        {
          "contains": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "enum": [
                  "provenance-integrity"
                ],
                "$comment": "stability: stable"
              }
            }
          }
        },
        {
          "contains": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "enum": [
                  "supervisory-clarity"
                ],
                "$comment": "stability: stable"
              }
            }
          }
        },
        {
          "contains": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "enum": [
                  "scope-definition"
                ],
                "$comment": "stability: stable"
              }
            }
          }
        },
        {
          "contains": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "enum": [
                  "review-substance"
                ],
                "$comment": "stability: stable"
              }
            }
          }
        },
        {
          "contains": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "enum": [
                  "constraint-fidelity"
                ],
                "$comment": "stability: stable"
              }
            }
          }
        },
        {
          "contains": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "enum": [
                  "capability-calibration"
                ],
                "$comment": "stability: stable"
              }
            }
          }
        }
      ],
      "$comment": "stability: stable"
    },
    "summary": {
      "type": "object",
      "required": [
        "average_score",
        "lowest_score",
        "lowest_dimensions",
        "profile"
      ],
      "properties": {
        "profile": {
          "type": "string",
          "enum": [
            "flat",
            "audit-ready",
            "split",
            "brittle",
            "emerging"
          ],
          "$comment": "stability: stable"
        },
        "average_score": {
          "type": "number",
          "$comment": "stability: stable"
        },
        "lowest_score": {
          "type": "number",
          "$comment": "stability: stable"
        },
        "lowest_dimensions": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/dimensionId"
          },
          "$comment": "stability: stable"
        }
      },
      "additionalProperties": true,
      "$comment": "stability: stable"
    },
    "ninety_day_priority": {
      "type": "object",
      "required": [
        "dimension",
        "action",
        "success_measure",
        "review_date"
      ],
      "properties": {
        "dimension": {
          "$ref": "#/definitions/dimensionId",
          "$comment": "stability: stable"
        },
        "action": {
          "type": "string",
          "$comment": "stability: stable"
        },
        "success_measure": {
          "type": "string",
          "description": "How you will know it worked. Required, so that a priority cannot be recorded without one.",
          "$comment": "stability: stable"
        },
        "review_date": {
          "type": "string",
          "$comment": "stability: stable"
        }
      },
      "additionalProperties": true,
      "$comment": "stability: stable"
    },
    "next_assessment_due": {
      "type": "string",
      "$comment": "stability: stable"
    },
    "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",
          "$comment": "stability: stable"
        },
        "version": {
          "type": "string",
          "$comment": "stability: stable"
        }
      },
      "additionalProperties": true,
      "$comment": "stability: stable"
    }
  },
  "additionalProperties": true,
  "definitions": {
    "dimensionId": {
      "type": "string",
      "enum": [
        "provenance-integrity",
        "supervisory-clarity",
        "scope-definition",
        "review-substance",
        "constraint-fidelity",
        "capability-calibration"
      ]
    }
  }
}
