{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://executiongovernance.org/schemas/v0.9.7.2/eg-authorization-request.schema.json",
  "title": "EG Authorization Request",
  "x-eg-schema-version": "0.9.7.2",
  "$comment": "Execution Governance Reference Specification v0.9.7.2. Independent public technical draft for review.",
  "type": "object",
  "required": [
    "action",
    "agent",
    "mandate",
    "constraints",
    "live_context",
    "accountable_party",
    "evidence_references",
    "nonce"
  ],
  "properties": {
    "action": {
      "type": "object",
      "required": [
        "ref",
        "op",
        "target"
      ],
      "properties": {
        "ref": {
          "type": "string",
          "minLength": 22,
          "pattern": "^[A-Za-z0-9_-]{22,}$"
        },
        "op": {
          "type": "string"
        },
        "target": {
          "type": "string"
        },
        "params": {
          "type": "object"
        }
      }
    },
    "agent": {
      "type": "object",
      "required": [
        "sub",
        "authn"
      ],
      "properties": {
        "sub": {
          "type": "string"
        },
        "authn": {
          "type": "string"
        }
      }
    },
    "mandate": {
      "type": "object",
      "required": [
        "token"
      ],
      "properties": {
        "token": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "jti": {
          "type": "string"
        },
        "iss": {
          "type": "string"
        },
        "sub": {
          "type": "string"
        },
        "scope": {
          "type": [
            "string",
            "array"
          ],
          "items": {
            "type": "string"
          }
        },
        "exp": {
          "type": "string",
          "format": "date-time"
        },
        "valid_until": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "constraints": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "uri",
          "hash"
        ],
        "properties": {
          "uri": {
            "type": "string",
            "format": "uri"
          },
          "hash": {
            "type": "string",
            "pattern": "^sha256:[a-f0-9]{64}$"
          },
          "valid_until": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "minItems": 1
    },
    "live_context": {
      "type": "object",
      "required": [
        "ts",
        "env"
      ],
      "properties": {
        "ts": {
          "type": "string",
          "format": "date-time"
        },
        "env": {
          "type": "string"
        },
        "jurisdiction": {
          "type": "string"
        },
        "valid_until": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "accountable_party": {
      "type": "object",
      "required": [
        "namespace",
        "id",
        "contact"
      ],
      "properties": {
        "namespace": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "contact": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "evidence_references": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "type",
          "uri",
          "hash"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "uri": {
            "type": "string",
            "format": "uri"
          },
          "hash": {
            "type": "string",
            "pattern": "^sha256:[a-f0-9]{64}$"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    },
    "nonce": {
      "type": "string",
      "minLength": 22,
      "pattern": "^[A-Za-z0-9_-]{22,}$"
    }
  }
}
