{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentproof.hatchable.site/standards/autonomous-trust-resolution-v0.2.schema.json",
  "title": "Autonomous Trust Resolution Request v0.2",
  "type": "object",
  "required": [
    "principal",
    "agent",
    "mandate",
    "counterparty",
    "action",
    "transaction",
    "authority_chain"
  ],
  "properties": {
    "principal": {
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "agent": {
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "mandate": {
      "type": "object",
      "required": [
        "scope"
      ],
      "properties": {
        "scope": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "valid_from": {
          "type": "string",
          "format": "date-time"
        },
        "valid_until": {
          "type": "string",
          "format": "date-time"
        },
        "limits": {
          "type": "object",
          "properties": {
            "max_amount": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "currency": {
              "type": "string"
            },
            "allowed_counterparties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "min_evidence": {
              "type": "integer",
              "minimum": 0
            },
            "min_attestations": {
              "type": "integer",
              "minimum": 0
            },
            "require_recourse_above": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            },
            "require_human_above": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    },
    "counterparty": {
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "action": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "transaction": {
      "type": "object",
      "properties": {
        "amount": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "currency": {
          "type": "string"
        },
        "jurisdiction": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "attestations": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "recourse": {
      "type": "object",
      "properties": {
        "available": {
          "type": "boolean"
        },
        "limit": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        }
      },
      "additionalProperties": true
    },
    "human_approval": {
      "type": "object",
      "properties": {
        "present": {
          "type": "boolean"
        },
        "ref": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "protocol": {
      "const": "agentproof.resolution/0.2"
    },
    "authority_chain": {
      "type": "array",
      "minItems": 1,
      "maxItems": 128,
      "items": {
        "type": "object",
        "required": [
          "delegator",
          "delegatee",
          "scope"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "delegator": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "delegatee": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "scope": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "valid_from": {
            "type": "string",
            "format": "date-time"
          },
          "valid_until": {
            "type": "string",
            "format": "date-time"
          },
          "limits": {
            "type": "object",
            "properties": {
              "max_amount": {
                "oneOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "currency": {
                "type": "string"
              },
              "allowed_counterparties": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "min_evidence": {
                "type": "integer",
                "minimum": 0
              },
              "min_attestations": {
                "type": "integer",
                "minimum": 0
              },
              "require_recourse_above": {
                "oneOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "require_human_above": {
                "oneOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            },
            "additionalProperties": true
          },
          "credential_refs": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "attestations": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "authority_ref": {
            "type": "object",
            "required": ["id", "delegation_sha256"],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "delegation_sha256": {
                "type": "string",
                "pattern": "^[A-Fa-f0-9]{64}$"
              },
              "status_url": {
                "type": "string",
                "format": "uri"
              }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      }
    }
  },
  "additionalProperties": true
}