{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openstandard.readinessindex.io/tests.schema.json",
  "title": "AI Readiness Index test registry",
  "description": "The shape of tests.yaml: the version, the four scored categories, and every test with its points, applicability and verification mode. The words about each test live in AI-READINESS-INDEX.md, never here.",
  "type": "object",
  "additionalProperties": false,
  "required": ["index_version", "index_date", "dimensions", "checks"],
  "properties": {
    "index_version": {"type": "string", "pattern": "^\\d+\\.\\d+$"},
    "index_date": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
    "dimensions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "name", "weight"],
        "properties": {
          "id": {"type": "integer", "minimum": 1},
          "name": {"type": "string", "minLength": 1},
          "weight": {"type": "integer", "minimum": 1}
        }
      }
    },
    "checks": {
      "type": "array",
      "minItems": 1,
      "items": {"$ref": "#/$defs/test"}
    }
  },
  "$defs": {
    "test": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "title", "weight", "applicability", "verification", "effort"],
      "properties": {
        "id": {"type": "string", "pattern": "^(RCH|RED|UND|ACT|PST|EXT|MSR)-[0-9]+$"},
        "title": {"type": "string", "minLength": 1},
        "dimension": {"type": "integer", "minimum": 1, "description": "Present for a scored test, absent for one in Posture, Extras or Measurement."},
        "tier": {"enum": ["core", "posture", "extras", "measurement"], "description": "Omitted for a scored test."},
        "weight": {"type": "integer", "minimum": 0, "description": "Whole points. Zero for every unscored test."},
        "applicability": {"enum": ["always", "conditional", "vertical"]},
        "precondition": {"type": ["string", "null"]},
        "requires": {
          "type": ["object", "null"],
          "additionalProperties": false,
          "properties": {
            "check": {"type": "string"},
            "any_of": {"type": "array", "items": {"type": "string"}},
            "min_band": {"type": "integer", "minimum": 0, "maximum": 4}
          }
        },
        "verification": {"enum": ["auto", "auto-partial", "manual"]},
        "effort": {"enum": ["small", "medium", "large"]},
        "gate": {"type": "boolean"},
        "presets": {"type": "array", "items": {"type": "string"}},
        "first_run_cap": {"type": ["integer", "null"], "minimum": 0, "maximum": 4},
        "unattested_ceiling": {"type": ["integer", "null"], "minimum": 0, "maximum": 4}
      },
      "allOf": [
        {
          "if": {"properties": {"tier": {"enum": ["posture", "extras", "measurement"]}}, "required": ["tier"]},
          "then": {"properties": {"weight": {"const": 0}}, "not": {"required": ["dimension"]}},
          "else": {"required": ["dimension"], "properties": {"weight": {"minimum": 1}}}
        }
      ]
    }
  }
}
