{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/PatchedEvaluationReport",
  "title": "PatchedEvaluationReport",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "readOnly": true
    },
    "evaluation": {
      "type": "string",
      "format": "uuid",
      "description": "UUID of the evaluation this report config belongs to."
    },
    "frequency": {
      "allOf": [
        {
          "$ref": "#/components/schemas/EvaluationReportFrequencyEnum"
        }
      ],
      "description": "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.\n\n* `scheduled` - Scheduled\n* `every_n` - Every N"
    },
    "rrule": {
      "type": "string",
      "description": "RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART \u2014 the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise."
    },
    "starts_at": {
      "type": "string",
      "format": "date-time",
      "nullable": true,
      "description": "Anchor datetime for the rrule (ISO 8601, UTC \u2014 must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise."
    },
    "timezone_name": {
      "type": "string",
      "description": "IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'.",
      "maxLength": 64
    },
    "next_delivery_date": {
      "type": "string",
      "format": "date-time",
      "readOnly": true,
      "nullable": true
    },
    "delivery_targets": {
      "description": "List of delivery targets. Each entry is either {type: 'email', value: 'user@example.com'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team."
    },
    "max_sample_size": {
      "type": "integer",
      "maximum": 2147483647,
      "minimum": -2147483648,
      "description": "Maximum number of evaluation runs included in each report. Defaults to 200."
    },
    "enabled": {
      "type": "boolean",
      "description": "Whether report delivery is active. Disabled configs do not fire."
    },
    "deleted": {
      "type": "boolean",
      "description": "Set to true to soft-delete this report config."
    },
    "last_delivered_at": {
      "type": "string",
      "format": "date-time",
      "readOnly": true,
      "nullable": true
    },
    "report_prompt_guidance": {
      "type": "string",
      "description": "Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt."
    },
    "trigger_threshold": {
      "type": "integer",
      "maximum": 10000,
      "minimum": 10,
      "nullable": true,
      "description": "Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'."
    },
    "cooldown_minutes": {
      "type": "integer",
      "maximum": 1440,
      "minimum": 60,
      "description": "Minimum minutes between count-triggered reports to prevent spam (every_n mode only). Min 60, max 1440 (24 hours). Defaults to 60."
    },
    "daily_run_cap": {
      "type": "integer",
      "maximum": 24,
      "minimum": 1,
      "description": "Maximum count-triggered report runs per calendar day (UTC). Min 1, max 24 (one per cooldown window). Defaults to 10."
    },
    "created_by": {
      "type": "integer",
      "readOnly": true,
      "nullable": true
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    }
  }
}