{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paloframework.org/schemas/palo-agentic-action-claim.schema.json",
  "title": "PALO Agentic Action Claim",
  "description": "Developer-preview interoperability contract for a proposed agent action. Schema validity is not authorization, safety evidence, legal approval, or proof of execution.",
  "type": "object",
  "required": ["format", "schemaVersion", "claimId", "agentId", "caseId", "action", "requestedScopes", "externalNetwork", "delegation", "requestedAt", "expiresAt", "nonce", "idempotencyKey", "sequenceNumber"],
  "properties": {
    "format": { "const": "palo-agentic-action-claim" },
    "schemaVersion": { "enum": ["1.1.0", "1.2.0", "1.3.0", "1.4.0"] },
    "claimId": { "type": "string", "pattern": "^claim-[a-f0-9-]{36}$" },
    "agentId": { "type": "string", "pattern": "^agent-[a-zA-Z0-9][a-zA-Z0-9-]{5,63}$" },
    "caseId": { "type": "string", "minLength": 1, "maxLength": 128 },
    "action": {
      "type": "object",
      "required": ["tool", "operation", "resource", "path", "networkIntent", "arguments", "argumentsDigest", "argumentSchemaDigest"],
      "properties": {
        "tool": { "type": "string", "minLength": 1, "maxLength": 200 },
        "operation": { "enum": ["read", "create", "update", "delete", "execute", "delegate"] },
        "resource": { "type": "string", "minLength": 1, "maxLength": 1000 },
        "path": { "type": "string", "minLength": 1, "maxLength": 1000, "pattern": "^/" },
        "networkIntent": { "enum": ["none", "read", "write", "bidirectional"] },
        "networkHost": { "type": "string", "minLength": 1, "maxLength": 253, "pattern": "^[a-z0-9.-]+$" },
        "arguments": { "type": "object", "maxProperties": 100, "additionalProperties": true },
        "argumentsDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
        "argumentSchemaDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
      },
      "additionalProperties": false
    },
    "requestedScopes": {
      "type": "object",
      "required": ["read", "write"],
      "properties": {
        "read": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
        "write": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } }
      },
      "additionalProperties": false
    },
    "externalNetwork": { "type": "boolean" },
    "delegation": {
      "type": "object",
      "required": ["depth", "subagentCount"],
      "properties": {
        "depth": { "type": "integer", "minimum": 0 },
        "subagentCount": { "type": "integer", "minimum": 0 },
        "parentAgentId": { "type": "string", "pattern": "^agent-[a-zA-Z0-9][a-zA-Z0-9-]{5,63}$" },
        "requestedSubagentRole": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "authorityContext": {
      "type": "object",
      "required": ["authorityContextId", "humanPrincipal", "workloadIdentity", "agentIdentity", "delegationChain"],
      "properties": {
        "authorityContextId": { "type": "string", "pattern": "^authority-[a-f0-9-]{36}$" },
        "humanPrincipal": {
          "type": "object",
          "required": ["subject", "issuer", "authenticatedAt", "credentialDigest"],
          "properties": {
            "subject": { "type": "string", "minLength": 1, "maxLength": 512 },
            "issuer": { "type": "string", "format": "uri", "maxLength": 1000 },
            "authenticatedAt": { "type": "string", "format": "date-time" },
            "credentialDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
            "proofReference": { "type": "string", "format": "uri", "maxLength": 2000 }
          },
          "additionalProperties": false
        },
        "workloadIdentity": {
          "type": "object",
          "required": ["subject", "issuer", "audience", "proofType", "credentialDigest"],
          "properties": {
            "subject": { "type": "string", "minLength": 1, "maxLength": 1000 },
            "issuer": { "type": "string", "format": "uri", "maxLength": 1000 },
            "audience": { "type": "string", "minLength": 1, "maxLength": 1000 },
            "proofType": { "enum": ["mtls", "dpop", "http-message-signature", "spiffe-svid"] },
            "credentialDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
            "proofReference": { "type": "string", "format": "uri", "maxLength": 2000 }
          },
          "additionalProperties": false
        },
        "agentIdentity": {
          "type": "object",
          "required": ["agentId", "instanceId"],
          "properties": {
            "agentId": { "type": "string", "pattern": "^agent-[a-zA-Z0-9][a-zA-Z0-9-]{5,63}$" },
            "instanceId": { "type": "string", "minLength": 1, "maxLength": 256 }
          },
          "additionalProperties": false
        },
        "tenantId": { "type": "string", "minLength": 1, "maxLength": 128 },
        "delegationChain": {
          "type": "array",
          "maxItems": 16,
          "items": {
            "type": "object",
            "required": ["delegationId", "from", "to", "scopes", "issuedAt", "expiresAt"],
            "properties": {
              "delegationId": { "type": "string", "pattern": "^delegation-[a-f0-9-]{36}$" },
              "from": { "type": "string", "minLength": 1, "maxLength": 1000 },
              "to": { "type": "string", "minLength": 1, "maxLength": 1000 },
              "scopes": {
                "type": "object",
                "required": ["read", "write"],
                "properties": {
                  "read": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
                  "write": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } }
                },
                "additionalProperties": false
              },
              "issuedAt": { "type": "string", "format": "date-time" },
              "expiresAt": { "type": "string", "format": "date-time" }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "requestedAt": { "type": "string", "format": "date-time" },
    "expiresAt": { "type": "string", "format": "date-time" },
    "nonce": { "type": "string", "pattern": "^[a-zA-Z0-9_-]{16,128}$" },
    "idempotencyKey": { "type": "string", "pattern": "^[a-zA-Z0-9._:-]{16,200}$" },
    "sequenceNumber": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
    "effectContract": { "$ref": "palo-agentic-effect-contract.schema.json" },
    "dataGovernance": {
      "type": "object",
      "required": ["subject", "purpose", "fitnessDecisionId", "fitnessDecisionDigest", "disclosureContractId", "disclosureContractDigest"],
      "properties": {
        "subject": {
          "type": "object",
          "required": ["type", "id"],
          "properties": {
            "type": { "enum": ["dataset", "data-product", "model", "ai-system", "agent", "tool", "access-entitlement", "other"] },
            "id": { "type": "string", "minLength": 1, "maxLength": 1000 }
          },
          "additionalProperties": false
        },
        "purpose": { "type": "string", "minLength": 1, "maxLength": 300 },
        "fitnessDecisionId": { "type": "string", "pattern": "^fitness-decision-[a-f0-9-]{36}$" },
        "fitnessDecisionDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
        "disclosureContractId": { "type": "string", "pattern": "^disclosure-[a-f0-9-]{36}$" },
        "disclosureContractDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
      },
      "additionalProperties": false
    },
    "metadata": { "type": "object", "additionalProperties": true }
  },
  "allOf": [
    {
      "if": { "properties": { "schemaVersion": { "enum": ["1.1.0", "1.2.0"] } }, "required": ["schemaVersion"] },
      "then": { "properties": { "authorityContext": false } }
    },
    {
      "if": { "properties": { "schemaVersion": { "const": "1.2.0" } }, "required": ["schemaVersion"] },
      "then": { "properties": { "effectContract": { "$ref": "palo-agentic-effect-contract.schema.json" } }, "required": ["effectContract"] }
    },
    {
      "if": { "properties": { "schemaVersion": { "const": "1.3.0" } }, "required": ["schemaVersion"] },
      "then": { "properties": { "effectContract": { "$ref": "palo-agentic-effect-contract.schema.json" }, "authorityContext": { "type": "object" } }, "required": ["effectContract", "authorityContext"] }
    },
    {
      "if": { "properties": { "schemaVersion": { "const": "1.4.0" } }, "required": ["schemaVersion"] },
      "then": { "properties": { "effectContract": { "$ref": "palo-agentic-effect-contract.schema.json" }, "authorityContext": { "type": "object" }, "dataGovernance": { "type": "object" } }, "required": ["effectContract", "authorityContext", "dataGovernance"] }
    }
  ],
  "additionalProperties": false
}
