{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.driftframe.org/site-reading-governance/v2.0/acceptance.schema.json",
  "title": "Accountable Acceptance Decision",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "acceptance_id",
    "acceptance_type",
    "scope",
    "intended_use",
    "evidence_mode",
    "authority",
    "actual_acceptance_required",
    "status",
    "receipt_ids",
    "decision_basis",
    "residual_risks",
    "conditions",
    "effective_at",
    "authority_actor",
    "reviewers",
    "requalification_triggers",
    "metadata"
  ],
  "properties": {
    "acceptance_id": {
      "$ref": "common.schema.json#/$defs/identifier"
    },
    "acceptance_type": {
      "type": "string",
      "enum": [
        "scientific",
        "quality",
        "regulatory",
        "security_privacy",
        "operations",
        "business"
      ]
    },
    "scope": {
      "type": "string",
      "minLength": 20,
      "maxLength": 1200
    },
    "intended_use": {
      "type": "string",
      "minLength": 20,
      "maxLength": 1200
    },
    "evidence_mode": {
      "$ref": "common.schema.json#/$defs/evidenceMode"
    },
    "authority": {
      "type": "string",
      "enum": [
        "simulated_projection",
        "actual_accountable"
      ]
    },
    "actual_acceptance_required": {
      "type": "boolean"
    },
    "status": {
      "type": "string",
      "enum": [
        "approved",
        "conditionally_approved",
        "returned_for_evidence",
        "pending"
      ]
    },
    "receipt_ids": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "common.schema.json#/$defs/identifier"
      }
    },
    "decision_basis": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 10,
        "maxLength": 800
      }
    },
    "residual_risks": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "risk",
          "owner_role",
          "control",
          "review_date"
        ],
        "properties": {
          "risk": {
            "type": "string",
            "minLength": 10,
            "maxLength": 700
          },
          "owner_role": {
            "type": "string",
            "minLength": 2,
            "maxLength": 120
          },
          "control": {
            "type": "string",
            "minLength": 10,
            "maxLength": 700
          },
          "review_date": {
            "type": "string",
            "format": "date"
          }
        }
      }
    },
    "conditions": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 5,
        "maxLength": 700
      }
    },
    "effective_at": {
      "type": "string",
      "format": "date-time"
    },
    "authority_actor": {
      "$ref": "common.schema.json#/$defs/actor"
    },
    "reviewers": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "common.schema.json#/$defs/actor"
      }
    },
    "requalification_triggers": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 5,
        "maxLength": 300
      }
    },
    "metadata": {
      "$ref": "common.schema.json#/$defs/recordMetadata"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "evidence_mode": {
            "const": "simulated"
          }
        },
        "required": [
          "evidence_mode"
        ]
      },
      "then": {
        "properties": {
          "authority": {
            "const": "simulated_projection"
          },
          "actual_acceptance_required": {
            "const": true
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "authority": {
            "const": "actual_accountable"
          }
        },
        "required": [
          "authority"
        ]
      },
      "then": {
        "properties": {
          "evidence_mode": {
            "const": "observed"
          },
          "actual_acceptance_required": {
            "const": false
          }
        }
      }
    }
  ]
}
