{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://xn----8sbalkoao1agd1bnbgj5cxk.xn--p1ai/.well-known/agent-constitution.schema.json",
  "title": "Заявление о присоединении к Конституции агента",
  "description": "Файл /.well-known/agent-constitution.json на сайте участника. Уровни К2 и К3 (статья 38).",
  "type": "object",
  "required": [
    "constitution",
    "version",
    "level",
    "role",
    "organization",
    "responsible_contact",
    "declared_at"
  ],
  "properties": {
    "constitution": {
      "type": "string",
      "description": "Адрес Конституции",
      "enum": [
        "https://конституция-агента.рф",
        "https://xn----8sbalkoao1agd1bnbgj5cxk.xn--p1ai"
      ]
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+$",
      "examples": [
        "0.1"
      ]
    },
    "level": {
      "type": "string",
      "enum": [
        "K1",
        "K2",
        "K3",
        "K4"
      ]
    },
    "role": {
      "type": "string",
      "enum": [
        "operator",
        "seller",
        "developer"
      ]
    },
    "organization": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 2
        },
        "inn": {
          "type": "string",
          "pattern": "^(\\d{10}|\\d{12})$"
        }
      }
    },
    "responsible_contact": {
      "type": "string",
      "description": "Контакт ответственного человека (статья 33)"
    },
    "agents": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "irreversible_actions_require_confirmation",
          "log_available_to_principal"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "purpose": {
            "type": "string"
          },
          "irreversible_actions_require_confirmation": {
            "type": "boolean",
            "description": "Статья 12"
          },
          "log_available_to_principal": {
            "type": "boolean",
            "description": "Статья 28"
          },
          "stop_endpoint": {
            "type": "string",
            "format": "uri",
            "description": "Статья 16"
          }
        }
      }
    },
    "machine_readable_offer": {
      "type": "string",
      "format": "uri",
      "description": "Статья 18"
    },
    "drift_report": {
      "type": "string",
      "format": "uri",
      "description": "Отчёт о проверке на дрейф для К3 (статья 34)"
    },
    "declared_at": {
      "type": "string",
      "format": "date"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "role": {
            "const": "operator"
          }
        }
      },
      "then": {
        "required": [
          "agents"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "level": {
            "const": "K3"
          }
        }
      },
      "then": {
        "required": [
          "drift_report"
        ]
      }
    }
  ]
}