{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "policy.schema.json",
  "title": "ADRF Dispute Policy document",
  "description": "The published description of a Dispute Policy. The on-chain PolicySpec is the executed rule; this document explains it, carries the evidence rules and the economic declaration, and is bound to the spec through descriptorHash and economicDeclaration.",
  "type": "object",
  "required": [
    "kind",
    "adrf",
    "name",
    "family",
    "version",
    "objectKind",
    "methods",
    "effects",
    "track",
    "standing",
    "resultProfile",
    "evidenceRules",
    "economicDeclaration"
  ],
  "properties": {
    "kind": {
      "const": "adrf-policy"
    },
    "adrf": {
      "const": "0.1"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "description": {
      "type": "string"
    },
    "family": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "integer",
      "minimum": 1
    },
    "previous": {
      "$ref": "common.schema.json#/$defs/bytes32"
    },
    "updateAuthority": {
      "$ref": "common.schema.json#/$defs/address"
    },
    "objectKind": {
      "type": "string",
      "minLength": 1
    },
    "obligationKinds": {
      "type": "array",
      "items": {
        "$ref": "common.schema.json#/$defs/obligationKind"
      }
    },
    "methods": {
      "type": "array",
      "minItems": 1,
      "maxItems": 32,
      "items": {
        "type": "object",
        "required": [
          "obligationKind",
          "qType",
          "method",
          "params",
          "onUndetermined",
          "supports"
        ],
        "properties": {
          "obligationKind": {
            "type": "integer",
            "minimum": 0,
            "maximum": 255
          },
          "qType": {
            "$ref": "common.schema.json#/$defs/questionType"
          },
          "method": {
            "$ref": "common.schema.json#/$defs/address"
          },
          "codeHash": {
            "$ref": "common.schema.json#/$defs/bytes32"
          },
          "params": {
            "$ref": "common.schema.json#/$defs/bytes32"
          },
          "paramsMeaning": {
            "type": "string"
          },
          "onUndetermined": {
            "$ref": "common.schema.json#/$defs/onUndetermined"
          },
          "supports": {
            "type": "array",
            "items": {
              "$ref": "common.schema.json#/$defs/supportKind"
            },
            "minItems": 1
          },
          "trustAssumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "onFailure": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "effects": {
      "type": "array",
      "maxItems": 32,
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "category"
        ],
        "properties": {
          "id": {
            "$ref": "common.schema.json#/$defs/bytes32"
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "category": {
            "$ref": "common.schema.json#/$defs/effectCategory"
          },
          "description": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "track": {
      "type": "object",
      "required": [
        "filingWindow",
        "acceptanceWindow",
        "evidenceWindow",
        "decisionWindow",
        "reviewWindow",
        "maxReviews",
        "reviewTypes",
        "reviewMode",
        "maxTotalDuration",
        "enactmentMargin",
        "optimistic",
        "answerWindow",
        "silenceRule"
      ],
      "properties": {
        "filingWindow": {
          "$ref": "common.schema.json#/$defs/uint"
        },
        "acceptanceWindow": {
          "$ref": "common.schema.json#/$defs/uint"
        },
        "evidenceWindow": {
          "$ref": "common.schema.json#/$defs/uint"
        },
        "decisionWindow": {
          "$ref": "common.schema.json#/$defs/uint"
        },
        "reviewWindow": {
          "$ref": "common.schema.json#/$defs/uint"
        },
        "maxReviews": {
          "$ref": "common.schema.json#/$defs/uint"
        },
        "reviewTypes": {
          "type": "array",
          "items": {
            "$ref": "common.schema.json#/$defs/reviewType"
          }
        },
        "reviewMode": {
          "$ref": "common.schema.json#/$defs/reviewMode"
        },
        "maxTotalDuration": {
          "$ref": "common.schema.json#/$defs/uint"
        },
        "enactmentMargin": {
          "$ref": "common.schema.json#/$defs/uint"
        },
        "optimistic": {
          "type": "boolean"
        },
        "answerWindow": {
          "$ref": "common.schema.json#/$defs/uint"
        },
        "silenceRule": {
          "$ref": "common.schema.json#/$defs/silenceRule"
        }
      },
      "additionalProperties": false
    },
    "standing": {
      "$ref": "common.schema.json#/$defs/standingMode"
    },
    "resultProfile": {
      "const": "adrf:result/v1"
    },
    "evidenceRules": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "appliesTo",
          "provisionDuty",
          "access",
          "verificationPeriod",
          "onFailureToProvide"
        ],
        "properties": {
          "appliesTo": {
            "type": "string"
          },
          "provisionDuty": {
            "type": "string"
          },
          "access": {
            "type": "string"
          },
          "verificationPeriod": {
            "type": "string"
          },
          "closeOfEvidence": {
            "type": "string"
          },
          "onFailureToProvide": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "burden": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "claimKind",
          "whoProves",
          "threshold",
          "onShortfall"
        ],
        "properties": {
          "claimKind": {
            "type": "string"
          },
          "whoProves": {
            "type": "string"
          },
          "threshold": {
            "type": "string"
          },
          "onShortfall": {
            "type": "string",
            "enum": [
              "NOT_SUSTAINED",
              "NO_DECISION"
            ]
          }
        },
        "additionalProperties": false
      }
    },
    "economicDeclaration": {
      "type": "object",
      "required": [
        "arrangements",
        "assumptions"
      ],
      "properties": {
        "arrangements": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "instrument",
              "executor",
              "purposes",
              "flows",
              "onFailure"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "instrument": {
                "type": "string"
              },
              "executor": {
                "type": "string"
              },
              "purposes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "minItems": 1
              },
              "flows": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "onFailure": {
                "type": "string"
              },
              "effectId": {
                "$ref": "common.schema.json#/$defs/bytes32"
              }
            },
            "additionalProperties": false
          }
        },
        "assumptions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "note": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "judgment": {
      "type": "object",
      "properties": {
        "acdfRegistry": {
          "$ref": "common.schema.json#/$defs/address"
        },
        "acdfPolicyId": {
          "$ref": "common.schema.json#/$defs/bytes32"
        },
        "independence": {
          "type": "string"
        },
        "selection": {
          "type": "string"
        },
        "appealStanding": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "objectCategory": {
      "type": "string",
      "enum": [
        "ai-resource",
        "ai-system-or-service",
        "ai-execution-or-delivery",
        "ai-evaluation-or-declaration",
        "ai-governance-or-intervention",
        "other"
      ],
      "description": "open classification of the objects the policy serves"
    },
    "evaluationConfigs": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "appliesTo",
          "unit",
          "sampleSelection",
          "versionScope",
          "metric",
          "threshold",
          "uncertainty"
        ],
        "properties": {
          "appliesTo": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "sampleSelection": {
            "type": "string"
          },
          "versionScope": {
            "type": "string"
          },
          "metric": {
            "type": "string"
          },
          "threshold": {
            "type": "string"
          },
          "uncertainty": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "description": "how statistical quality obligations are evaluated"
    }
  },
  "additionalProperties": false
}
