{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:kali-maintenance-window-draft-v1",
  "title": "Kali 112 Maintenance Window Draft v1",
  "description": "定義 Kali 192.168.0.112 維護窗口草案、owner 回覆欄位、rollback、post-check 與禁止動作。此契約不授權 apt upgrade、restart、hardening、reboot、active scan 或 /execute。",
  "type": "object",
  "required": [
    "schema_version",
    "status",
    "date",
    "mode",
    "source_evidence_refs",
    "summary",
    "observed_gaps",
    "owner_response_handoff",
    "maintenance_window_draft",
    "rollback_plan_draft",
    "post_check_plan",
    "acceptance_rules",
    "forbidden_actions"
  ],
  "properties": {
    "schema_version": {
      "const": "kali_maintenance_window_draft_v1"
    },
    "status": {
      "type": "string",
      "enum": ["draft_waiting_owner_review"]
    },
    "date": {
      "type": "string"
    },
    "mode": {
      "type": "string",
      "enum": ["maintenance_window_draft_only"]
    },
    "source_evidence_refs": {
      "type": "array",
      "items": {"type": "string"},
      "minItems": 1
    },
    "summary": {
      "type": "object",
      "required": [
        "host",
        "asset_key",
        "pending_update_count",
        "failed_systemd_unit_count",
        "service_hardening_enabled_count",
        "service_hardening_expected_count",
        "reboot_required",
        "maintenance_window_package_ready",
        "maintenance_window_completion_percent",
        "maintenance_window_approved",
        "host_update_authorized",
        "service_restart_authorized",
        "hardening_authorized",
        "reboot_authorized",
        "active_scan_authorized",
        "execute_endpoint_authorized"
      ],
      "properties": {
        "host": {"type": "string"},
        "asset_key": {"type": "string"},
        "pending_update_count": {"type": "integer", "minimum": 0},
        "failed_systemd_unit_count": {"type": "integer", "minimum": 0},
        "service_hardening_enabled_count": {"type": "integer", "minimum": 0},
        "service_hardening_expected_count": {"type": "integer", "minimum": 0},
        "reboot_required": {"type": "boolean"},
        "maintenance_window_package_ready": {"type": "boolean"},
        "maintenance_window_completion_percent": {"type": "integer", "minimum": 0, "maximum": 100},
        "maintenance_window_approved": {"type": "boolean", "const": false},
        "host_update_authorized": {"type": "boolean", "const": false},
        "service_restart_authorized": {"type": "boolean", "const": false},
        "hardening_authorized": {"type": "boolean", "const": false},
        "reboot_authorized": {"type": "boolean", "const": false},
        "active_scan_authorized": {"type": "boolean", "const": false},
        "execute_endpoint_authorized": {"type": "boolean", "const": false}
      },
      "additionalProperties": false
    },
    "observed_gaps": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["gap_id", "current_evidence", "risk", "required_before_action"],
        "properties": {
          "gap_id": {"type": "string"},
          "current_evidence": {"type": "string"},
          "risk": {"type": "string", "enum": ["LOW", "MEDIUM", "HIGH"]},
          "required_before_action": {
            "type": "array",
            "items": {"type": "string"},
            "minItems": 1
          }
        },
        "additionalProperties": false
      },
      "minItems": 1
    },
    "owner_response_handoff": {
      "type": "object",
      "required": [
        "status",
        "request_dispatch_authorized",
        "required_response_fields",
        "forbidden_inputs",
        "response_received",
        "response_accepted"
      ],
      "properties": {
        "status": {"type": "string", "enum": ["ready_not_dispatched"]},
        "request_dispatch_authorized": {"type": "boolean", "const": false},
        "required_response_fields": {
          "type": "array",
          "items": {"type": "string"},
          "minItems": 1
        },
        "forbidden_inputs": {
          "type": "array",
          "items": {"type": "string"},
          "minItems": 1
        },
        "response_received": {"type": "boolean", "const": false},
        "response_accepted": {"type": "boolean", "const": false}
      },
      "additionalProperties": false
    },
    "maintenance_window_draft": {
      "type": "object",
      "required": ["window_status", "candidate_window", "change_lanes", "pre_window_checks"],
      "properties": {
        "window_status": {"type": "string", "enum": ["waiting_owner_selection"]},
        "candidate_window": {"type": "string"},
        "change_lanes": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["lane_id", "description", "authorization_required", "current_authorized"],
            "properties": {
              "lane_id": {"type": "string"},
              "description": {"type": "string"},
              "authorization_required": {"type": "string"},
              "current_authorized": {"type": "boolean", "const": false}
            },
            "additionalProperties": false
          },
          "minItems": 1
        },
        "pre_window_checks": {
          "type": "array",
          "items": {"type": "string"},
          "minItems": 1
        }
      },
      "additionalProperties": false
    },
    "rollback_plan_draft": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["rollback_item", "required_evidence", "owner_status"],
        "properties": {
          "rollback_item": {"type": "string"},
          "required_evidence": {
            "type": "array",
            "items": {"type": "string"},
            "minItems": 1
          },
          "owner_status": {"type": "string", "enum": ["waiting_owner_assignment"]}
        },
        "additionalProperties": false
      },
      "minItems": 1
    },
    "post_check_plan": {
      "type": "array",
      "items": {"type": "string"},
      "minItems": 1
    },
    "acceptance_rules": {
      "type": "array",
      "items": {"type": "string"},
      "minItems": 1
    },
    "forbidden_actions": {
      "type": "array",
      "items": {"type": "string"},
      "minItems": 1
    }
  },
  "additionalProperties": false
}
