{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/commentary-dev/json-schema/commentary-dev-agent-inbox-policy-proposal-schema.json",
  "title": "AgentInboxPolicyProposal",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/commentary-dev-inbox-api-openapi.yml#/components/schemas/AgentInboxPolicyProposal",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "name",
    "precedence",
    "definition"
  ],
  "properties": {
    "scope": {
      "type": "string",
      "enum": [
        "personal",
        "workspace"
      ],
      "default": "personal"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "precedence": {
      "type": "integer",
      "minimum": 0,
      "maximum": 1000
    },
    "definition": {
      "$ref": "#/$defs/InboxAttentionPolicyDefinition"
    }
  },
  "$defs": {
    "InboxAttentionPolicyCondition": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "clause"
          ],
          "properties": {
            "kind": {
              "const": "clause"
            },
            "clause": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "field",
                "operator",
                "value"
              ],
              "properties": {
                "field": {
                  "type": "string",
                  "enum": [
                    "workspace",
                    "interaction_type",
                    "resource_type",
                    "source_category",
                    "agent",
                    "recipient",
                    "role",
                    "status",
                    "priority_band",
                    "deadline_window",
                    "age_days",
                    "business_hours"
                  ]
                },
                "operator": {
                  "type": "string",
                  "enum": [
                    "is",
                    "is_not",
                    "in",
                    "gte",
                    "lte"
                  ]
                },
                "value": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    },
                    {
                      "type": "array",
                      "maxItems": 12,
                      "items": {
                        "type": "string"
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "conditions"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "all",
                "any"
              ]
            },
            "conditions": {
              "type": "array",
              "minItems": 1,
              "maxItems": 24,
              "items": {
                "$ref": "#/$defs/InboxAttentionPolicyCondition"
              }
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "condition"
          ],
          "properties": {
            "kind": {
              "const": "not"
            },
            "condition": {
              "$ref": "#/$defs/InboxAttentionPolicyCondition"
            }
          }
        }
      ]
    },
    "InboxAttentionPolicyDefinition": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "condition",
        "effects"
      ],
      "properties": {
        "schemaVersion": {
          "const": 1
        },
        "condition": {
          "$ref": "#/$defs/InboxAttentionPolicyCondition"
        },
        "effects": {
          "type": "array",
          "minItems": 1,
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/InboxAttentionPolicyEffect"
          }
        }
      }
    },
    "InboxAttentionPolicyEffect": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "points"
          ],
          "properties": {
            "kind": {
              "const": "rank_adjustment"
            },
            "points": {
              "type": "integer",
              "minimum": -100,
              "maximum": 100
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "queueId"
          ],
          "properties": {
            "kind": {
              "const": "route"
            },
            "queueId": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "recipientId"
          ],
          "properties": {
            "kind": {
              "const": "assign"
            },
            "recipientId": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "preference"
          ],
          "properties": {
            "kind": {
              "const": "notification_preference"
            },
            "preference": {
              "type": "string",
              "enum": [
                "in_app",
                "digest",
                "none"
              ]
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "durationMinutes"
          ],
          "properties": {
            "kind": {
              "const": "snooze"
            },
            "durationMinutes": {
              "type": "integer",
              "enum": [
                15,
                60,
                240,
                1440,
                10080
              ]
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "afterMinutes"
          ],
          "properties": {
            "kind": {
              "const": "resurface"
            },
            "afterMinutes": {
              "type": "integer",
              "enum": [
                15,
                60,
                240,
                1440,
                10080
              ]
            }
          }
        }
      ]
    }
  }
}