{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://eips.ethereum.org/assets/eip-8506/schemas/grade.schema.json",
  "title": "AITO Grade",
  "description": "A versioned set of deliverable specifications, applicable conditions and constraints. A Grade carries no default global ordering.",
  "type": "object",
  "required": [
    "aito",
    "kind",
    "unit",
    "ordering",
    "executionObject",
    "verificationPolicy"
  ],
  "properties": {
    "aito": {
      "const": "1",
      "description": "Record format version."
    },
    "kind": {
      "const": "grade"
    },
    "name": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "supersedes": {
      "$ref": "#/$defs/bytes32",
      "description": "Identifier of the record this one replaces."
    },
    "unit": {
      "$ref": "#/$defs/bytes32"
    },
    "ordering": {
      "type": "string",
      "description": "none, or the identifier of the profile that defines a comparison between Grades."
    },
    "executionObject": {
      "type": "object",
      "required": [
        "kind",
        "identity",
        "config"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "description": "fixed-model, service-version, routing-policy, qualifying-pool, or another declared kind."
        },
        "identity": {
          "type": "object",
          "description": "Weights digest, service version commitment or policy digest."
        },
        "config": {
          "description": "Execution configuration, or the string undeclared."
        }
      },
      "additionalProperties": true
    },
    "requirements": {
      "type": "array",
      "description": "What is promised to be reached. Measured values belong in Assessments.",
      "items": {
        "type": "object",
        "required": [
          "id",
          "statement",
          "scope",
          "compensable"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "family": {
            "type": "string"
          },
          "statement": {
            "type": "string"
          },
          "comparator": {
            "enum": [
              "==",
              ">=",
              "<=",
              ">",
              "<"
            ]
          },
          "value": {
            "type": "string"
          },
          "method": {
            "$ref": "#/$defs/bytes32"
          },
          "scope": {
            "enum": [
              "per-request",
              "window",
              "sample"
            ],
            "description": "Whether every request must satisfy it, a service window must, or a stated sample must."
          },
          "window": {
            "type": "string"
          },
          "compensable": {
            "type": "boolean",
            "description": "False for a condition that no other attribute or quantity may offset."
          }
        },
        "additionalProperties": true
      }
    },
    "obligations": {
      "type": "array",
      "description": "Duties that are not established by measurement.",
      "items": {
        "type": "object",
        "required": [
          "id",
          "statement",
          "obligor",
          "compensable"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "family": {
            "type": "string"
          },
          "statement": {
            "type": "string"
          },
          "obligor": {
            "type": "string"
          },
          "compensable": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      }
    },
    "verificationPolicy": {
      "type": "object",
      "required": [
        "origin",
        "metering",
        "execution",
        "quality",
        "deliverySettlement"
      ],
      "properties": {
        "origin": {
          "type": "object",
          "required": [
            "evidence"
          ],
          "properties": {
            "evidence": {
              "type": "string",
              "description": "Kind of evidence required, for example self-attested, counterparty-signed, third-party-assessed, tee-attested, zk-proof, onchain."
            },
            "acceptance": {
              "type": "string",
              "description": "Rule by which the evidence is accepted."
            }
          },
          "additionalProperties": true
        },
        "metering": {
          "type": "object",
          "required": [
            "evidence"
          ],
          "properties": {
            "evidence": {
              "type": "string",
              "description": "Kind of evidence required, for example self-attested, counterparty-signed, third-party-assessed, tee-attested, zk-proof, onchain."
            },
            "acceptance": {
              "type": "string",
              "description": "Rule by which the evidence is accepted."
            }
          },
          "additionalProperties": true
        },
        "execution": {
          "type": "object",
          "required": [
            "evidence"
          ],
          "properties": {
            "evidence": {
              "type": "string",
              "description": "Kind of evidence required, for example self-attested, counterparty-signed, third-party-assessed, tee-attested, zk-proof, onchain."
            },
            "acceptance": {
              "type": "string",
              "description": "Rule by which the evidence is accepted."
            }
          },
          "additionalProperties": true
        },
        "quality": {
          "type": "object",
          "required": [
            "evidence"
          ],
          "properties": {
            "evidence": {
              "type": "string",
              "description": "Kind of evidence required, for example self-attested, counterparty-signed, third-party-assessed, tee-attested, zk-proof, onchain."
            },
            "acceptance": {
              "type": "string",
              "description": "Rule by which the evidence is accepted."
            }
          },
          "additionalProperties": true
        },
        "deliverySettlement": {
          "type": "object",
          "required": [
            "evidence"
          ],
          "properties": {
            "evidence": {
              "type": "string",
              "description": "Kind of evidence required, for example self-attested, counterparty-signed, third-party-assessed, tee-attested, zk-proof, onchain."
            },
            "acceptance": {
              "type": "string",
              "description": "Rule by which the evidence is accepted."
            }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    },
    "attributes": {
      "type": "object",
      "description": "Further descriptive attributes by family. A family may be the string undeclared."
    }
  },
  "additionalProperties": true,
  "$defs": {
    "bytes32": {
      "type": "string",
      "pattern": "^0x[0-9a-f]{64}$"
    },
    "account": {
      "type": "string",
      "pattern": "^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}:[-.%a-zA-Z0-9]{1,128}$",
      "description": "CAIP-10 account identifier."
    },
    "decimal": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$",
      "description": "A non-negative decimal written as a string. Records carry no floating-point numbers."
    },
    "integer": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)$"
    },
    "time": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
    },
    "undeclared": {
      "const": "undeclared"
    }
  }
}
