{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:causalis:mandate-schema:0.1",
  "title": "CAUSALIS Agent Mandate",
  "type": "object",
  "required": ["agent", "authority", "limits", "controls", "audit"],
  "properties": {
    "agent": {
      "type": "object",
      "required": ["name", "version", "chain"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "version": { "type": "string", "minLength": 1 },
        "chain": { "type": "string", "const": "solana" }
      },
      "additionalProperties": true
    },
    "authority": {
      "type": "object",
      "required": ["owner", "allowedPrograms"],
      "properties": {
        "owner": { "type": "string", "minLength": 1 },
        "allowedPrograms": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } }
      },
      "additionalProperties": true
    },
    "limits": {
      "type": "object",
      "required": ["perTransaction", "perDay", "denomination"],
      "properties": {
        "perTransaction": { "type": "number", "minimum": 0 },
        "perDay": { "type": "number", "minimum": 0 },
        "denomination": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": true
    },
    "controls": {
      "type": "object",
      "required": ["humanApprovalAbove", "emergencyStop"],
      "properties": {
        "humanApprovalAbove": { "type": "number", "minimum": 0 },
        "emergencyStop": { "type": "boolean" }
      },
      "additionalProperties": true
    },
    "audit": {
      "type": "object",
      "required": ["logActions", "retentionDays"],
      "properties": {
        "logActions": { "type": "boolean" },
        "retentionDays": { "type": "integer", "minimum": 1 }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
