{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentproof.hatchable.site/standards/agent-transaction-passport-v0.1.schema.json",
  "title": "Agent Transaction Passport™ v0.1",
  "description": "Portable record for an agent-mediated transaction.",
  "type": "object",
  "required": [
    "spec",
    "passport_id",
    "issued_at",
    "issuer",
    "principal",
    "agent",
    "mandate",
    "counterparty",
    "agreement",
    "evidence",
    "fulfillment",
    "settlement",
    "attestations",
    "integrity_sha256"
  ],
  "properties": {
    "spec": {
      "const": "agentproof.atp/0.1"
    },
    "passport_id": {
      "type": "string",
      "minLength": 8
    },
    "issued_at": {
      "type": "string",
      "format": "date-time"
    },
    "issuer": {
      "$ref": "#/$defs/entity"
    },
    "principal": {
      "$ref": "#/$defs/entity"
    },
    "agent": {
      "$ref": "#/$defs/agent"
    },
    "mandate": {
      "$ref": "#/$defs/mandate"
    },
    "counterparty": {
      "$ref": "#/$defs/entity"
    },
    "agreement": {
      "type": "object",
      "additionalProperties": true
    },
    "evidence": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/evidence"
      }
    },
    "fulfillment": {
      "type": "object",
      "additionalProperties": true
    },
    "settlement": {
      "$ref": "#/$defs/settlement"
    },
    "attestations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/attestation"
      }
    },
    "jurisdiction": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "privacy": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "previous_passport_hash": {
      "type": [
        "string",
        "null"
      ]
    },
    "integrity_sha256": {
      "type": "string",
      "pattern": "^[A-Fa-f0-9]{64}$"
    }
  },
  "$defs": {
    "entity": {
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "credentials": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    },
    "agent": {
      "allOf": [
        {
          "$ref": "#/$defs/entity"
        },
        {
          "type": "object",
          "properties": {
            "runtime": {
              "type": "string"
            },
            "model": {
              "type": "string"
            },
            "instance_id": {
              "type": "string"
            }
          }
        }
      ]
    },
    "mandate": {
      "type": "object",
      "required": [
        "scope"
      ],
      "properties": {
        "scope": {
          "type": [
            "string",
            "array"
          ]
        },
        "limits": {
          "type": "object",
          "additionalProperties": true
        },
        "valid_from": {
          "type": "string",
          "format": "date-time"
        },
        "valid_until": {
          "type": "string",
          "format": "date-time"
        },
        "credential_refs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    },
    "evidence": {
      "type": "object",
      "required": [
        "type",
        "ref"
      ],
      "properties": {
        "type": {
          "type": "string"
        },
        "ref": {
          "type": "string"
        },
        "sha256": {
          "type": "string"
        },
        "observed_at": {
          "type": "string",
          "format": "date-time"
        },
        "issuer": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "settlement": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "rail": {
          "type": "string"
        },
        "network": {
          "type": "string"
        },
        "asset": {
          "type": "string"
        },
        "amount": {
          "type": [
            "string",
            "number"
          ]
        },
        "transaction_ref": {
          "type": "string"
        },
        "settled_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": true
    },
    "attestation": {
      "type": "object",
      "required": [
        "type",
        "issuer"
      ],
      "properties": {
        "type": {
          "type": "string"
        },
        "issuer": {
          "type": "string"
        },
        "signature": {
          "type": "string"
        },
        "credential_ref": {
          "type": "string"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}