{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:backup-notification-policy-v1",
  "title": "AWOOOI Backup notification policy v1",
  "description": "備份成功降噪、失敗 / action-required 升級、每日摘要與 Agent 角色邊界的只讀通知政策。此 schema 不授權通知發送、備份執行、restore、offsite sync、credential marker 寫入、排程變更、workflow 寫入或任何生產操作。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "source_readiness_matrix_ref",
    "source_refs",
    "program_status",
    "rollups",
    "notification_channels",
    "policy_rules",
    "daily_summary_contract",
    "agent_roles",
    "operation_boundaries",
    "approval_boundaries"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "backup_notification_policy_v1"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "source_readiness_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"
      ],
      "properties": {
        "total_rules": {
          "type": "integer",
          "minimum": 1
        },
        "by_decision": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "immediate_escalation_rule_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "suppressed_success_rule_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "notification_channels": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "channel_id",
          "purpose",
          "immediate_allowed",
          "success_immediate_allowed",
          "requires_operator_action"
        ],
        "properties": {
          "channel_id": {
            "type": "string",
            "minLength": 1
          },
          "purpose": {
            "type": "string",
            "minLength": 1
          },
          "immediate_allowed": {
            "type": "boolean"
          },
          "success_immediate_allowed": {
            "type": "boolean",
            "const": false
          },
          "requires_operator_action": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      }
    },
    "policy_rules": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "rule_id",
          "event_kind",
          "backup_state",
          "severity",
          "decision",
          "channels",
          "owner_agent",
          "requires_incident",
          "requires_approval_record",
          "message_contract",
          "evidence_refs"
        ],
        "properties": {
          "rule_id": {
            "type": "string",
            "minLength": 1
          },
          "event_kind": {
            "type": "string",
            "minLength": 1
          },
          "backup_state": {
            "type": "string",
            "enum": [
              "success",
              "warning",
              "failed",
              "action_required",
              "blocked",
              "needs_metric_binding"
            ]
          },
          "severity": {
            "type": "string",
            "enum": ["info", "warning", "high", "critical"]
          },
          "decision": {
            "type": "string",
            "enum": [
              "suppress_immediate_success",
              "escalate_immediate",
              "create_action_required"
            ]
          },
          "channels": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "owner_agent": {
            "type": "string",
            "enum": ["openclaw", "hermes", "nemotron"]
          },
          "requires_incident": {
            "type": "boolean"
          },
          "requires_approval_record": {
            "type": "boolean"
          },
          "message_contract": {
            "type": "string",
            "minLength": 1
          },
          "evidence_refs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "additionalProperties": false
      }
    },
    "daily_summary_contract": {
      "type": "object",
      "required": [
        "summary_time_taipei",
        "success_immediate_notifications_allowed",
        "success_signal_sources",
        "failure_rows_require_action_refs",
        "mandatory_sections"
      ],
      "properties": {
        "summary_time_taipei": {
          "type": "string",
          "minLength": 1
        },
        "success_immediate_notifications_allowed": {
          "type": "boolean",
          "const": false
        },
        "success_signal_sources": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "failure_rows_require_action_refs": {
          "type": "boolean",
          "const": true
        },
        "mandatory_sections": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "agent_roles": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "agent_id",
          "role",
          "allowed_actions",
          "blocked_actions"
        ],
        "properties": {
          "agent_id": {
            "type": "string",
            "enum": ["openclaw", "hermes", "nemotron"]
          },
          "role": {
            "type": "string",
            "minLength": 1
          },
          "allowed_actions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "blocked_actions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "additionalProperties": false
      }
    },
    "operation_boundaries": {
      "type": "object",
      "required": [
        "read_only_policy_allowed",
        "notification_send_allowed",
        "backup_execution_allowed",
        "restore_execution_allowed",
        "offsite_sync_execution_allowed",
        "credential_marker_write_allowed",
        "schedule_change_allowed",
        "workflow_write_allowed",
        "telegram_test_message_allowed"
      ],
      "properties": {
        "read_only_policy_allowed": {
          "type": "boolean",
          "const": true
        },
        "notification_send_allowed": {
          "type": "boolean",
          "const": false
        },
        "backup_execution_allowed": {
          "type": "boolean",
          "const": false
        },
        "restore_execution_allowed": {
          "type": "boolean",
          "const": false
        },
        "offsite_sync_execution_allowed": {
          "type": "boolean",
          "const": false
        },
        "credential_marker_write_allowed": {
          "type": "boolean",
          "const": false
        },
        "schedule_change_allowed": {
          "type": "boolean",
          "const": false
        },
        "workflow_write_allowed": {
          "type": "boolean",
          "const": false
        },
        "telegram_test_message_allowed": {
          "type": "boolean",
          "const": false
        }
      },
      "additionalProperties": false
    },
    "approval_boundaries": {
      "type": "object",
      "required": [
        "sdk_installation_allowed",
        "paid_api_call_allowed",
        "shadow_or_canary_allowed",
        "production_routing_allowed",
        "destructive_operation_allowed"
      ],
      "properties": {
        "sdk_installation_allowed": {
          "type": "boolean",
          "const": false
        },
        "paid_api_call_allowed": {
          "type": "boolean",
          "const": false
        },
        "shadow_or_canary_allowed": {
          "type": "boolean",
          "const": false
        },
        "production_routing_allowed": {
          "type": "boolean",
          "const": false
        },
        "destructive_operation_allowed": {
          "type": "boolean",
          "const": false
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
