{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:backup-dr-readiness-matrix-v1",
  "title": "AWOOOI Backup / DR 準備度矩陣 v1",
  "description": "由 Backup / DR 目標盤點與 runbook live-refresh 摘要產生的只讀準備度矩陣。此 schema 不授權 restore drill、offsite sync、credential marker 寫入或任何備份執行。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "source_target_inventory_ref",
    "source_refs",
    "program_status",
    "rollups",
    "readiness_rows",
    "operation_boundaries",
    "approval_boundaries"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "backup_dr_readiness_matrix_v1"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "source_target_inventory_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_rows",
        "by_overall_readiness",
        "by_restore_drill_status",
        "by_offsite_status",
        "blocked_row_ids",
        "action_required_row_ids"
      ],
      "properties": {
        "total_rows": {
          "type": "integer",
          "minimum": 0
        },
        "by_overall_readiness": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "by_restore_drill_status": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "by_offsite_status": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "blocked_row_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "action_required_row_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "readiness_rows": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "target_id",
          "display_name",
          "overall_readiness",
          "freshness_status",
          "integrity_status",
          "restore_drill_status",
          "offsite_status",
          "notification_policy",
          "gate_status",
          "evidence_level",
          "evidence_refs",
          "blocker_summary",
          "next_action"
        ],
        "properties": {
          "target_id": {
            "type": "string",
            "minLength": 1
          },
          "display_name": {
            "type": "string",
            "minLength": 1
          },
          "overall_readiness": {
            "type": "string",
            "enum": ["ready", "action_required", "blocked", "deferred"]
          },
          "freshness_status": {
            "type": "string",
            "enum": ["verified", "needs_metric_binding", "blocked", "deferred", "not_applicable"]
          },
          "integrity_status": {
            "type": "string",
            "enum": ["verified", "needs_metric_binding", "blocked", "deferred", "not_applicable"]
          },
          "restore_drill_status": {
            "type": "string",
            "enum": ["approval_required", "blocked", "deferred", "not_applicable"]
          },
          "offsite_status": {
            "type": "string",
            "enum": ["verified", "needs_metric_binding", "blocked", "deferred", "not_applicable"]
          },
          "notification_policy": {
            "type": "string",
            "minLength": 1
          },
          "gate_status": {
            "type": "string",
            "enum": [
              "read_only_allowed",
              "restore_approval_required",
              "blocked_by_live_evidence",
              "credential_approval_required",
              "deferred_until_service_active"
            ]
          },
          "evidence_level": {
            "type": "string",
            "enum": ["runbook_live_refresh", "committed_script", "blocked_live_evidence", "deferred"]
          },
          "evidence_refs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "blocker_summary": {
            "type": "string",
            "minLength": 1
          },
          "next_action": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "operation_boundaries": {
      "type": "object",
      "required": [
        "read_only_api_allowed",
        "backup_execution_allowed",
        "restore_execution_allowed",
        "offsite_sync_execution_allowed",
        "credential_marker_write_allowed",
        "schedule_change_allowed",
        "destructive_prune_allowed"
      ],
      "properties": {
        "read_only_api_allowed": {
          "type": "boolean",
          "const": true
        },
        "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
        },
        "destructive_prune_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
}
