{
  "id": "messaging.message.send.v1",
  "name": "Messaging Protection Policy",
  "description": "Pre-action governance for messaging operations. Enforces rate limits, channel restrictions, mention policies, and content validation for PLG on-ramp.",
  "version": "1.0.0",
  "status": "active",
  "requires_capabilities": ["messaging.send"],
  "min_assurance": "L0",
  "limits_required": [
    "msgs_per_min",
    "msgs_per_day",
    "allowed_recipients",
    "approval_required"
  ],
  "required_fields": ["channel_id", "message", "message_type"],
  "optional_fields": ["mentions", "attachments", "thread_id", "reply_to"],
  "enforcement": {
    "channels_allowlist_enforced": true,
    "mention_policy_enforced": true,
    "rate_limits_enforced": true
  },
  "mcp": {
    "require_allowlisted_if_present": true
  },
  "advice": [
    "Implement rate limiting per agent and per channel",
    "Monitor for spam patterns and suspicious activity",
    "Log all message attempts for Verifiable Attestation",
    "Consider implementing channel-specific limits",
    "Use mention policies to prevent @everyone abuse",
    "Subscribe to status webhooks for instant suspend",
    "Implement content filtering for inappropriate messages",
    "Use progressive rate limiting for new agents"
  ],
  "required_context": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "required": ["channel_id", "message", "message_type"],
    "properties": {
      "channel_id": {
        "type": "string",
        "minLength": 1,
        "description": "Target channel identifier"
      },
      "message": {
        "type": "string",
        "minLength": 1,
        "maxLength": 2000,
        "description": "Message content"
      },
      "message_type": {
        "type": "string",
        "enum": ["text", "embed", "file", "reaction"],
        "description": "Type of message"
      },
      "mentions": {
        "type": "array",
        "items": { "type": "string" },
        "description": "User or role mentions in the message"
      },
      "attachments": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "url": { "type": "string" },
            "filename": { "type": "string" },
            "size": { "type": "integer" }
          }
        },
        "description": "File attachments"
      },
      "thread_id": {
        "type": "string",
        "description": "Thread identifier for threaded messages"
      },
      "reply_to": {
        "type": "string",
        "description": "Message ID being replied to"
      },
      "mcp_servers": {
        "type": "array",
        "items": { "type": "string" },
        "description": "MCP servers being used in this request (e.g., [\"https://mcp.slack.com\"])"
      },
      "mcp_tools": {
        "type": "array",
        "items": { "type": "string" },
        "description": "MCP tools being used in this request (e.g., [\"slack.messages.send\"])"
      },
      "mcp_server": {
        "type": "string",
        "description": "Single MCP server being used (backward compatibility - use mcp_servers array for multiple)"
      },
      "mcp_tool": {
        "type": "string",
        "description": "Single MCP tool being used (backward compatibility - use mcp_tools array for multiple)"
      },
      "mcp_session": {
        "type": "string",
        "description": "MCP session identifier for audit trail (optional)"
      }
    }
  },
  "evaluation_rules": [
    {
      "name": "passport_status_active",
      "condition": "passport.status == 'active'",
      "deny_code": "oap.passport_suspended",
      "description": "Passport must be active"
    },
    {
      "name": "messaging_capability",
      "condition": "'messaging.send' in passport.capabilities",
      "deny_code": "oap.unknown_capability",
      "description": "Agent must have messaging.send capability"
    },
    {
      "name": "rate_limit_minute",
      "condition": "minute_count < limits.msgs_per_min",
      "deny_code": "oap.rate_limit_exceeded",
      "description": "Per-minute rate limit must not be exceeded"
    },
    {
      "name": "rate_limit_daily",
      "condition": "daily_count < limits.msgs_per_day",
      "deny_code": "oap.rate_limit_exceeded",
      "description": "Daily rate limit must not be exceeded"
    },
    {
      "name": "content_validation",
      "condition": "message.length <= 2000",
      "deny_code": "oap.content_too_long",
      "description": "Message must not exceed length limit"
    }
  ],
  "cache": {
    "default_ttl_seconds": 60,
    "suspend_invalidate_seconds": 30
  },
  "deprecation": null,
  "created_at": "2025-01-16T00:00:00Z",
  "updated_at": "2025-01-30T00:00:00Z"
}
