{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://medgauge.org/schemas/0.1.0/capability.schema.json",
  "title": "capability",
  "description": "A capability or cross-cutting constraint (capability registry): definition, domain, dependencies and the artifact that demonstrates it.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[ABCDEX]\\.\\d+(\\.\\d+)?$"
    },
    "name_zh": {
      "type": "string",
      "minLength": 1
    },
    "name_en": {
      "type": "string"
    },
    "domain": {
      "type": "string",
      "enum": [
        "A",
        "B",
        "C",
        "D",
        "E",
        "X"
      ]
    },
    "definition_zh": {
      "type": "string",
      "minLength": 1
    },
    "definition_en": {
      "type": "string"
    },
    "evidence_grade": {
      "type": "string",
      "enum": [
        "program",
        "checkpoint",
        "rubric"
      ]
    },
    "oneshot_veto": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[ABCDEX]\\.\\d+(\\.\\d+)?$"
      }
    },
    "depends_on": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[ABCDEX]\\.\\d+(\\.\\d+)?$"
      }
    },
    "task_families": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "harness_components": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "standards": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "external_anchors": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "datasets": {
      "type": "object",
      "properties": {
        "pretrain": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "eval": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "sft": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "preference": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "trajectory": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "levels": {
      "type": "object",
      "properties": {
        "L1": {
          "type": "string"
        },
        "L2": {
          "type": "string"
        },
        "L3": {
          "type": "string"
        },
        "L4": {
          "type": "string"
        },
        "L5": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "human_time_minutes": {
      "type": "number",
      "minimum": 0
    },
    "regulatory_context": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "proposed",
        "retired"
      ]
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$"
    },
    "changelog": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "pattern": "^\\d+\\.\\d+\\.\\d+$"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "note": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "version",
          "date",
          "note"
        ]
      }
    },
    "introduced_in": {
      "type": "string",
      "description": "Spec revision that introduced or last changed the status of this entry"
    },
    "detail": {
      "type": "object",
      "additionalProperties": false,
      "description": "Extended definition shown on the capability page",
      "properties": {
        "rationale": {
          "type": "string",
          "minLength": 1
        },
        "inputs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "artifact": {
          "type": "string",
          "minLength": 1
        },
        "grading": {
          "type": "string",
          "minLength": 1
        },
        "in_scope": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "out_of_scope": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "typical_failures": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Hypothesised unless a result record is cited"
        },
        "standards_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "ids in the standards registry"
        }
      },
      "required": [
        "rationale",
        "inputs",
        "artifact",
        "grading",
        "in_scope",
        "out_of_scope",
        "typical_failures"
      ]
    }
  },
  "required": [
    "id",
    "name_en",
    "domain",
    "definition_en",
    "evidence_grade",
    "status",
    "version"
  ]
}
