{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://varexis.tech/schemas/index-response-v1.json",
  "title": "VAREXIS INDEX qualify_workload Response v1",
  "description": "Query-time reliance result. No numeric master score exists.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "reliance",
    "correctness",
    "economics",
    "events_missed",
    "refusal",
    "recheck_if",
    "evidence_pack_ids",
    "matching_record_ids",
    "authority_boundary"
  ],
  "properties": {
    "reliance": {
      "type": "string",
      "enum": [
        "SUPPORTED",
        "CONDITIONAL",
        "REVALIDATION_REQUIRED",
        "INSUFFICIENT_EVIDENCE",
        "NON_RELIANCE",
        "NOT_DEMONSTRATED"
      ]
    },
    "correctness": {
      "$ref": "#/$defs/qualificationDimension"
    },
    "economics": {
      "$ref": "#/$defs/qualificationDimension"
    },
    "events_missed": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/missedEvent"
      }
    },
    "refusal": {
      "$ref": "#/$defs/refusal"
    },
    "recheck_if": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "evidence_pack_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "matching_record_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "authority_boundary": {
      "const": "VAREXIS INDEX informs evidence reliance; it does not grant authority to deploy or act."
    }
  },
  "$defs": {
    "basisIds": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "metric": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "status",
        "value",
        "unit",
        "basis_record_ids"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "enum": [
            "OBSERVED",
            "REPORTED",
            "DERIVED",
            "NOT_REPORTED",
            "NOT_APPLICABLE"
          ]
        },
        "value": {
          "type": [
            "number",
            "integer",
            "string",
            "boolean",
            "null"
          ]
        },
        "unit": {
          "type": [
            "string",
            "null"
          ]
        },
        "basis_record_ids": {
          "$ref": "#/$defs/basisIds"
        }
      }
    },
    "qualificationDimension": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "summary",
        "metrics",
        "basis_record_ids"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "SUPPORTED",
            "CONDITIONAL",
            "REVALIDATION_REQUIRED",
            "INSUFFICIENT_EVIDENCE",
            "NON_RELIANCE",
            "NOT_DEMONSTRATED"
          ]
        },
        "summary": {
          "type": [
            "string",
            "null"
          ]
        },
        "metrics": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/metric"
          }
        },
        "basis_record_ids": {
          "$ref": "#/$defs/basisIds"
        }
      }
    },
    "missedEvent": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "event",
        "count",
        "basis_record_ids"
      ],
      "properties": {
        "event": {
          "type": "string",
          "minLength": 1
        },
        "count": {
          "type": "integer",
          "minimum": 1
        },
        "basis_record_ids": {
          "$ref": "#/$defs/basisIds"
        }
      }
    },
    "disqualifier": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "code",
        "summary",
        "record_ids"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "MISSED_REQUIRED_EVENT",
            "SAFETY_FAILURE",
            "ABORT",
            "SAFE_REFUSAL",
            "ECONOMIC_FAILURE",
            "CONFLICTING_EVIDENCE",
            "ENVIRONMENT_MISMATCH",
            "WORKLOAD_MISMATCH",
            "REVALIDATION_TRIGGERED",
            "EVIDENCE_REQUIREMENT_UNMET",
            "NO_QUALIFIED_EVIDENCE"
          ]
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "record_ids": {
          "$ref": "#/$defs/basisIds"
        }
      }
    },
    "refusal": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "active",
        "code",
        "reason",
        "disqualifiers"
      ],
      "properties": {
        "active": {
          "type": "boolean"
        },
        "code": {
          "type": "string",
          "enum": [
            "NONE",
            "NEGATIVE_EVIDENCE",
            "ENVIRONMENT_MISMATCH",
            "WORKLOAD_MISMATCH",
            "REVALIDATION_TRIGGERED",
            "EVIDENCE_REQUIREMENT_UNMET",
            "CONFLICTING_EVIDENCE",
            "NO_QUALIFIED_EVIDENCE"
          ]
        },
        "reason": {
          "type": [
            "string",
            "null"
          ]
        },
        "disqualifiers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/disqualifier"
          }
        }
      }
    }
  }
}
