{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "schemas/callback_next_action_decision_v1.json",
  "title": "callback_next_action_decision_v1",
  "description": "task-2644 회장 verbatim 보강-5 — next_action 4 필수 필드 + 6 result enum + 11 decided enum + 3 mutually exclusive branch. spec sha256: b27da557d4245bce476cd63f4ab174aefc8a25d2da07ec2c8d2c83b01ee96153. ANCHOR-12/15.",
  "type": "object",
  "required": [
    "schema_version",
    "next_action_decided",
    "next_action_branch",
    "next_action_attempted",
    "next_action_result",
    "next_action_evidence_path"
  ],
  "properties": {
    "schema_version": {"const": "v1"},
    "callback_id": {"type": "string"},
    "next_action_decided": {
      "type": "string",
      "enum": [
        "REQUEST_CHAIR_MERGE_APPROVAL",
        "REPORT_CRITICAL7",
        "REPORT_PERMISSION_OR_CREDENTIAL_EXPANSION",
        "DISPATCH_AUTO_REMEDIATION",
        "RERUN_ALLOWED_GATE",
        "RUN_OWNER_GEMINI_TRIGGER_ROUTER",
        "CREATE_FOLLOWUP_TASK_SPEC",
        "WAIT_FOR_BATCH_SIBLINGS",
        "BATCH_ADJUDICATE",
        "NOOP_TERMINAL",
        "HOLD_FOR_CHAIR"
      ]
    },
    "next_action_branch": {
      "type": "string",
      "enum": ["auto-executable", "chair-required", "terminal_noop"]
    },
    "next_action_attempted": {"type": "boolean"},
    "next_action_result": {
      "type": "string",
      "enum": [
        "DISPATCH_REGISTERED",
        "TELEGRAM_SENT",
        "LEDGER_ONLY",
        "HOLD_PACKET_CREATED",
        "BATCH_WAIT_RECORDED",
        "FAILED"
      ]
    },
    "next_action_evidence_path": {"type": "string", "minLength": 1},
    "recovery_action": {
      "type": ["string", "null"],
      "description": "next_action_result=FAILED 일 때 후속 recovery action (Stop hook 추가 차단 조건)"
    },
    "merge_policy_lock_applied": {"type": "boolean",
      "description": "MERGE_READY 의 경우 REQUEST_CHAIR_MERGE_APPROVAL 강제 override 불가 (보강-3)"},
    "telegram_emitted": {"type": "boolean",
      "description": "chair-required branch 에서만 true 허용 · auto/terminal_noop 에서 true 면 invariant violation"},
    "decided_at": {"type": "string", "format": "date-time"}
  },
  "allOf": [
    {
      "if": {"properties": {"next_action_decided": {
        "enum": ["DISPATCH_AUTO_REMEDIATION", "RERUN_ALLOWED_GATE", "RUN_OWNER_GEMINI_TRIGGER_ROUTER",
                 "CREATE_FOLLOWUP_TASK_SPEC", "WAIT_FOR_BATCH_SIBLINGS", "BATCH_ADJUDICATE"]}}},
      "then": {"properties": {"next_action_branch": {"const": "auto-executable"}}}
    },
    {
      "if": {"properties": {"next_action_decided": {
        "enum": ["REQUEST_CHAIR_MERGE_APPROVAL", "REPORT_CRITICAL7",
                 "REPORT_PERMISSION_OR_CREDENTIAL_EXPANSION", "HOLD_FOR_CHAIR"]}}},
      "then": {"properties": {"next_action_branch": {"const": "chair-required"}}}
    },
    {
      "if": {"properties": {"next_action_decided": {"const": "NOOP_TERMINAL"}}},
      "then": {"properties": {"next_action_branch": {"const": "terminal_noop"}}}
    }
  ],
  "additionalProperties": true
}
