{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/avala-ai/json-schema/avala-ai-quality-target-schema.json",
  "title": "QualityTarget",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/avala-ai-openapi.json#/components/schemas/QualityTarget",
  "required": [
    "name",
    "metric",
    "threshold"
  ],
  "type": "object",
  "properties": {
    "uid": {
      "title": "Uid",
      "type": "string",
      "format": "uuid",
      "readOnly": true
    },
    "name": {
      "title": "Name",
      "description": "Human-readable name, e.g. 'Max rejection rate'.",
      "type": "string",
      "maxLength": 255,
      "minLength": 1
    },
    "metric": {
      "title": "Metric",
      "type": "string",
      "enum": [
        "issue_rate",
        "acceptance_rate",
        "rejection_rate",
        "mean_resolution_time",
        "critical_issue_count"
      ]
    },
    "operator": {
      "title": "Operator",
      "type": "string",
      "enum": [
        "gt",
        "lt",
        "gte",
        "lte"
      ]
    },
    "threshold": {
      "title": "Threshold",
      "description": "The threshold value. For rates this is 0-1 (e.g. 0.15 = 15%). For counts this is an integer. For time this is seconds.",
      "type": "number"
    },
    "severity": {
      "title": "Severity",
      "type": "string",
      "enum": [
        "warning",
        "critical"
      ]
    },
    "is_active": {
      "title": "Is active",
      "type": "boolean"
    },
    "notify_webhook": {
      "title": "Notify webhook",
      "description": "Emit a quality.alert webhook event when threshold is breached.",
      "type": "boolean"
    },
    "notify_emails": {
      "description": "Email addresses to notify (future use).",
      "type": "array",
      "items": {
        "title": "Notify emails",
        "type": "string",
        "format": "email",
        "maxLength": 254,
        "minLength": 1
      }
    },
    "last_evaluated_at": {
      "title": "Last evaluated at",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "readOnly": true
    },
    "last_value": {
      "title": "Last value",
      "description": "The last computed metric value.",
      "type": [
        "number",
        "null"
      ],
      "readOnly": true
    },
    "is_breached": {
      "title": "Is breached",
      "description": "Whether the target is currently breached.",
      "type": "boolean",
      "readOnly": true
    },
    "breach_count": {
      "title": "Breach count",
      "description": "Total number of times this target has been breached.",
      "type": "integer",
      "readOnly": true
    },
    "last_breached_at": {
      "title": "Last breached at",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "readOnly": true
    },
    "created_at": {
      "title": "Created at",
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "updated_at": {
      "title": "Updated at",
      "type": "string",
      "format": "date-time",
      "readOnly": true
    }
  }
}