{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "CrossBorderAppraisalRecordSchema",
  "description": "JSON schema defining a governed performance appraisal record bridging unlicensed regional teams and licensed HQ approvers / 跨境績效評核紀錄、跨境同意證據與確定性計分之標準 JSON 資料結構",
  "type": "object",
  "properties": {
    "Title": {
      "type": "string",
      "pattern": "^DEMO-2026-[0-9]{4}$",
      "description": "Unique appraisal identifier generated after TEMP-<ResponseID> placeholder / 唯一評核編號"
    },
    "SubmissionKey": {
      "type": "string",
      "minLength": 8,
      "maxLength": 8,
      "description": "8-character record-matching secret for external forms (not strong auth) / 外部表單記錄比對用 8 位提交驗證碼"
    },
    "Status": {
      "type": "string",
      "enum": [
        "1_SelfAppraisalPending",
        "2_ManagerScoringPending",
        "3_EmployeeConfirmPending",
        "4_ManagerSignOffPending",
        "5_HRReviewPending",
        "6_ManagementApprovalPending",
        "7_Archived"
      ],
      "description": "Seven-stage workflow state machine gate / 七階段狀態機流程閘門"
    },
    "AppraiseeEmail": {
      "type": "string",
      "format": "email",
      "description": "Unlicensed regional employee email used for record matching / 區域受評員工電郵（記錄比對用）"
    },
    "AppraiserEmail": {
      "type": "string",
      "format": "email",
      "description": "Licensed HQ line manager email verified via Entra ID / 總部評審主管電郵（Entra ID 驗證）"
    },
    "CommencementDate": {
      "type": "string",
      "format": "date",
      "description": "Join date used to auto-exempt prior-year goal review if > 2026-01-01 / 入職日期（用於判斷去年目標檢視免答規則）"
    },
    "CrossBorderConsent": {
      "type": "boolean",
      "description": "Mandatory affirmative consent captured at regional intake prior to cross-border transfer to Hong Kong HQ / 區域員工提交自評時勾選之跨境個人資料傳輸與處理確認（配合 Version History 留存時間戳記）"
    },
    "InnovationGovernance": {
      "type": "object",
      "description": "Dual-evidence deterministic control for Criterion 8 (Innovation) / 第 8 項追求創新之雙向實證確定性控制",
      "properties": {
        "SupQ08_Original": {
          "type": "number",
          "minimum": 0,
          "maximum": 5,
          "description": "Preserved raw manager score for auditability / 永久保留之主管原始評分"
        },
        "SupQ08_Effective": {
          "type": "number",
          "minimum": 0,
          "maximum": 5,
          "description": "Effective score (auto-zeroed if either side lacks concrete examples) / 實際計分（任一方缺具體事例即計 0 分）"
        },
        "EvidenceMissing": {
          "type": "boolean",
          "description": "True when deterministic evidence validation fails / 實證檢核未通過標記"
        }
      },
      "required": ["SupQ08_Original", "SupQ08_Effective", "EvidenceMissing"]
    },
    "TotalScore": {
      "type": "number",
      "minimum": 0,
      "maximum": 100,
      "description": "Weighted total score (triggers mandatory justification if <= 50 or > 80) / 加權總分（<=50 或 >80 觸發必填原因門檻）"
    },
    "HRApproved": {
      "type": "boolean",
      "description": "HR calibration sign-off flag triggering Flow 3 batch gate / HR 審核完成開關（觸發批次總表閘門）"
    },
    "IsExempt": {
      "type": "boolean",
      "description": "Excludes resigned or long-leave staff from batch completion count / 豁免評核標記（防止批次閘門卡死）"
    }
  },
  "required": [
    "Title",
    "SubmissionKey",
    "Status",
    "AppraiseeEmail",
    "AppraiserEmail",
    "CrossBorderConsent",
    "TotalScore",
    "HRApproved"
  ]
}
