{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:service-health-failure-notification-policy-v1",
  "title": "AWOOOI 服務健康失敗限定通知政策 v1",
  "description": "服務健康 failure-only 通知合約；只描述成功降噪、action-required 與 failure escalation，不授權 Telegram / AwoooP 發送、live probe、重啟、endpoint 修改、workflow 觸發、runtime execution，也不得顯示工作視窗對話內容。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "source_service_health_matrix_ref",
    "source_refs",
    "program_status",
    "rollups",
    "notification_channels",
    "policy_rules",
    "message_template_contract",
    "display_redaction_contract",
    "agent_roles",
    "operation_boundaries",
    "approval_boundaries"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "service_health_failure_notification_policy_v1"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "source_service_health_matrix_ref": {
      "type": "string",
      "minLength": 1
    },
    "source_refs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "program_status": {
      "type": "object",
      "required": [
        "overall_completion_percent",
        "current_priority",
        "current_task_id",
        "next_task_id",
        "read_only_mode"
      ],
      "properties": {
        "overall_completion_percent": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "current_priority": {
          "type": "string",
          "enum": ["P0", "P1", "P2", "P3"]
        },
        "current_task_id": {
          "type": "string",
          "minLength": 1
        },
        "next_task_id": {
          "type": "string",
          "minLength": 1
        },
        "read_only_mode": {
          "type": "boolean",
          "const": true
        }
      },
      "additionalProperties": false
    },
    "rollups": {
      "type": "object",
      "required": [
        "total_rules",
        "by_decision",
        "immediate_escalation_rule_ids",
        "suppressed_success_rule_ids",
        "action_required_rule_ids",
        "notification_send_allowed_count"
      ],
      "additionalProperties": true
    },
    "notification_channels": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "channel_id",
          "purpose",
          "immediate_allowed",
          "success_immediate_allowed",
          "requires_operator_action"
        ],
        "additionalProperties": true
      }
    },
    "policy_rules": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "rule_id",
          "event_kind",
          "service_state",
          "severity",
          "decision",
          "channels",
          "owner_agent",
          "requires_incident",
          "requires_approval_record",
          "message_contract",
          "evidence_refs"
        ],
        "additionalProperties": true
      }
    },
    "message_template_contract": {
      "type": "object",
      "required": [
        "required_fields",
        "forbidden_fields",
        "success_message_policy",
        "failure_message_policy"
      ],
      "additionalProperties": true
    },
    "display_redaction_contract": {
      "type": "object",
      "required": [
        "frontend_display_policy",
        "allowed_frontend_fields",
        "forbidden_frontend_content",
        "conversation_transcript_display_allowed",
        "redaction_required"
      ],
      "properties": {
        "frontend_display_policy": {
          "type": "string",
          "minLength": 1
        },
        "allowed_frontend_fields": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "forbidden_frontend_content": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "conversation_transcript_display_allowed": {
          "type": "boolean",
          "const": false
        },
        "redaction_required": {
          "type": "boolean",
          "const": true
        }
      },
      "additionalProperties": false
    },
    "agent_roles": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "operation_boundaries": {
      "type": "object",
      "additionalProperties": {
        "type": "boolean"
      }
    },
    "approval_boundaries": {
      "type": "object",
      "additionalProperties": {
        "type": "boolean",
        "const": false
      }
    }
  },
  "additionalProperties": false
}
