{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://nocip.com/assets/api/self-assessment.schema.json",
 "title": "NOCIP self-assessment (catalogue 1.0)",
 "description": "One answer per criterion of the tier applied for (all C criteria, plus G, S (of the variant) or B). Submitted with POST /api/v1/cases/{case}/self-assessment or the MCP tool submit_self_assessment.",
 "type": "object",
 "additionalProperties": false,
 "required": [
  "schema",
  "criteria_version",
  "tier",
  "product",
  "ai_functions",
  "answers"
 ],
 "properties": {
  "schema": {
   "const": "nocip-self-assessment/1"
  },
  "criteria_version": {
   "type": "string",
   "description": "the catalogue version pinned to the case, e.g. 1.0"
  },
  "tier": {
   "enum": [
    "G",
    "S",
    "B"
   ]
  },
  "variant": {
   "enum": [
    null,
    "a",
    "b",
    "ab"
   ],
   "description": "Silver only: a = AI run by the vendor, b = router, ab = both"
  },
  "product": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "name",
    "version",
    "platforms"
   ],
   "properties": {
    "name": {
     "type": "string",
     "minLength": 1,
     "maxLength": 200
    },
    "version": {
     "type": "string",
     "minLength": 1,
     "maxLength": 50
    },
    "platforms": {
     "type": "array",
     "minItems": 1,
     "maxItems": 10,
     "items": {
      "type": "string",
      "maxLength": 40
     }
    }
   }
  },
  "ai_functions": {
   "type": "array",
   "minItems": 1,
   "maxItems": 50,
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "name",
     "location"
    ],
    "properties": {
     "name": {
      "type": "string",
      "maxLength": 200
     },
     "location": {
      "enum": [
       "customer",
       "vendor",
       "third-party"
      ]
     },
     "model": {
      "type": "string",
      "maxLength": 200
     },
     "provider": {
      "type": "string",
      "maxLength": 200
     },
     "country": {
      "type": "string",
      "maxLength": 60
     }
    }
   }
  },
  "answers": {
   "type": "object",
   "additionalProperties": false,
   "patternProperties": {
    "^[CGSB]-[0-9]{2}$": {
     "$ref": "#/$defs/answer"
    }
   }
  },
  "index": {
   "type": "object",
   "additionalProperties": false,
   "patternProperties": {
    "^I-[1-5]$": {
     "type": "object",
     "additionalProperties": false,
     "required": [
      "claim"
     ],
     "properties": {
      "claim": {
       "enum": [
        0,
        1,
        2
       ]
      },
      "text": {
       "type": "string",
       "maxLength": 2000
      },
      "evidence": {
       "type": "array",
       "maxItems": 20,
       "items": {
        "type": "string",
        "maxLength": 500,
        "pattern": "^(https://\\S+|sha256:[0-9a-f]{64})$"
       },
       "description": "https URL (NOCIP fetches it) or sha256:<hex> of an uploaded file"
      }
     }
    }
   }
  }
 },
 "$defs": {
  "answer": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "answer",
    "text"
   ],
   "properties": {
    "answer": {
     "enum": [
      "yes",
      "no",
      "partly",
      "na"
     ]
    },
    "text": {
     "type": "string",
     "minLength": 1,
     "maxLength": 4000
    },
    "evidence": {
     "type": "array",
     "maxItems": 20,
     "items": {
      "type": "string",
      "maxLength": 500,
      "pattern": "^(https://\\S+|sha256:[0-9a-f]{64})$"
     },
     "description": "https URL (NOCIP fetches it) or sha256:<hex> of an uploaded file"
    }
   }
  }
 }
}
