{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:backup-dr-target-inventory-v1",
  "title": "AWOOOI Backup / DR 目標盤點 v1",
  "description": "由既有備份 runbook 與 scripts 產生的只讀 Backup / DR 目標盤點。此 schema 不授權執行備份、restore、offsite sync、credential marker 寫入、排程變更或 destructive prune。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "source_refs",
    "program_status",
    "target_taxonomy",
    "rollups",
    "backup_targets",
    "readiness_surfaces",
    "operation_boundaries",
    "approval_boundaries"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "backup_dr_target_inventory_v1"
    },
    "generated_at": {
      "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
    },
    "target_taxonomy": {
      "type": "object",
      "required": [
        "target_types",
        "statuses",
        "gate_statuses",
        "storage_classes"
      ],
      "properties": {
        "target_types": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": [
              "database",
              "repository",
              "registry",
              "volume",
              "configuration",
              "route_evidence",
              "ai_artifact",
              "offsite_mirror",
              "credential_escrow",
              "k8s_resource",
              "status_check"
            ]
          }
        },
        "statuses": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": ["active", "partial", "blocked", "deferred"]
          }
        },
        "gate_statuses": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": [
              "read_only_allowed",
              "backup_execution_blocked",
              "restore_approval_required",
              "offsite_sync_blocked",
              "credential_approval_required",
              "blocked_by_live_evidence",
              "deferred_until_service_active"
            ]
          }
        },
        "storage_classes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": ["restic_local", "restic_offsite", "file_export", "velero_minio", "evidence_marker", "read_only_metric"]
          }
        }
      },
      "additionalProperties": false
    },
    "rollups": {
      "type": "object",
      "required": [
        "total_targets",
        "by_status",
        "by_target_type",
        "by_gate_status",
        "blocked_target_ids"
      ],
      "properties": {
        "total_targets": {
          "type": "integer",
          "minimum": 0
        },
        "by_status": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "by_target_type": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "by_gate_status": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "blocked_target_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "backup_targets": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "target_id",
          "display_name",
          "target_type",
          "status",
          "risk_level",
          "owner_host",
          "primary_script",
          "schedule",
          "rpo",
          "storage_class",
          "storage_ref",
          "offsite_policy",
          "automation_gate_status",
          "restore_gate_status",
          "secret_policy",
          "evidence_refs",
          "next_action"
        ],
        "properties": {
          "target_id": {
            "type": "string",
            "minLength": 1
          },
          "display_name": {
            "type": "string",
            "minLength": 1
          },
          "target_type": {
            "type": "string",
            "enum": [
              "database",
              "repository",
              "registry",
              "volume",
              "configuration",
              "route_evidence",
              "ai_artifact",
              "offsite_mirror",
              "credential_escrow",
              "k8s_resource",
              "status_check"
            ]
          },
          "status": {
            "type": "string",
            "enum": ["active", "partial", "blocked", "deferred"]
          },
          "risk_level": {
            "type": "string",
            "enum": ["low", "medium", "high", "critical"]
          },
          "owner_host": {
            "type": "string",
            "minLength": 1
          },
          "primary_script": {
            "type": "string",
            "minLength": 1
          },
          "schedule": {
            "type": "string",
            "minLength": 1
          },
          "rpo": {
            "type": "string",
            "minLength": 1
          },
          "storage_class": {
            "type": "string",
            "enum": ["restic_local", "restic_offsite", "file_export", "velero_minio", "evidence_marker", "read_only_metric"]
          },
          "storage_ref": {
            "type": "string",
            "minLength": 1
          },
          "offsite_policy": {
            "type": "string",
            "minLength": 1
          },
          "automation_gate_status": {
            "type": "string",
            "minLength": 1
          },
          "restore_gate_status": {
            "type": "string",
            "minLength": 1
          },
          "secret_policy": {
            "type": "string",
            "minLength": 1
          },
          "evidence_refs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "next_action": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "readiness_surfaces": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "surface_id",
          "display_name",
          "script_or_metric",
          "mode",
          "status",
          "evidence_refs",
          "next_action"
        ],
        "properties": {
          "surface_id": {
            "type": "string",
            "minLength": 1
          },
          "display_name": {
            "type": "string",
            "minLength": 1
          },
          "script_or_metric": {
            "type": "string",
            "minLength": 1
          },
          "mode": {
            "type": "string",
            "enum": ["read_only", "approval_required"]
          },
          "status": {
            "type": "string",
            "enum": ["active", "partial", "blocked", "deferred"]
          },
          "evidence_refs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "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
}
