{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cainstudio.online/spec/sovereign/action-request/1.0.0",
  "title": "CAIN Sovereign action request v1",
  "description": "What an agent proposes. Extends cain.action/v1 (platform-gateway/spec/ActionDecision.schema.json) with the binding fields the authorization-to-execution path needs. action_digest = sha256 of RFC 8785 canonical JSON of {tool, action, resource, parameters} with every key starting '_cain_' removed (same rule as cain.formal.proof_action.compute_arguments_digest). Mapping to cain.action/v1: agent.id->who, action.type->action, action.resource->resource, intent->intent, policy_version->policy_version. STATUS: ARCHITECTURALLY_SPECIFIED; no gateway route validates this schema yet (Evolution 2).",
  "type": "object",
  "additionalProperties": false,
  "required": ["protocol_version", "request_id", "tenant_id", "agent", "action", "action_digest", "audience", "policy_version", "request_epoch", "issued_at"],
  "properties": {
    "protocol_version": {"const": "cain.sovereign.action-request/1"},
    "request_id": {"type": "string", "minLength": 16, "maxLength": 128, "description": "Unique per request; duplicate request_id with a different action_digest is refused."},
    "tenant_id": {"type": "string", "minLength": 1},
    "agent": {
      "type": "object", "additionalProperties": false, "required": ["id"],
      "properties": {
        "id": {"type": "string", "minLength": 1},
        "model_id": {"type": "string"},
        "model_version": {"type": "string"},
        "authenticated_by": {"type": "string", "description": "Set by the boundary from the authenticated channel (API key principal, mTLS identity). An agent-supplied value is ignored."}
      }
    },
    "action": {
      "type": "object", "additionalProperties": false, "required": ["type", "tool", "resource", "parameters"],
      "properties": {
        "type": {"type": "string", "minLength": 1},
        "tool": {"type": "string", "minLength": 1},
        "resource": {"type": "string", "minLength": 1},
        "parameters": {"type": "object"}
      }
    },
    "action_digest": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "capability_scope": {"type": "array", "items": {"type": "string"}, "description": "Requested scope, e.g. tool:read_file. Never wider than the identity's registered grant."},
    "audience": {"type": "string", "minLength": 1, "description": "The enforcement point that may consume the resulting permit (e.g. mcpgate:<server-id>)."},
    "policy_version": {"type": "string", "minLength": 1},
    "request_epoch": {"type": "integer", "minimum": 0},
    "issued_at": {"type": "number"},
    "nonce": {"type": "string", "minLength": 16},
    "challenge_ref": {"type": "string", "description": "Required when policy demands a fresh challenge."},
    "approval_ref": {"type": "string", "description": "Reference to a human approval record from the configured approval service. A value supplied by the agent is a lookup key, never proof of approval."},
    "environment_evidence": {"type": "array", "items": {"type": "object", "required": ["kind", "digest"], "properties": {"kind": {"type": "string"}, "digest": {"type": "string"}, "verified": {"type": "boolean"}}}},
    "intent": {"type": "string"}
  }
}
