{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "memory/schemas/v36_runtime_harness_decision.schema.json",
  "title": "V36 Runtime Harness Decision Schema",
  "description": "회장 verbatim 2026-05-28 운영층 contract 의 결정 record schema. 8 layer contract 의 마커/이벤트/판정/audit JSONL 통합 schema. 본 schema 는 설계 패킷 — 구현 dispatch 0.",
  "type": "object",
  "required": [
    "schema_version",
    "decision_id",
    "ts",
    "task_id",
    "contract_layer",
    "decision_class",
    "evidence",
    "decision_outcome",
    "actor_attribution",
    "reason_code",
    "chair_authorization_id"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "v36.runtime_harness.decision.v1"
    },
    "decision_id": {
      "type": "string",
      "description": "결정 record uuid 또는 hash"
    },
    "ts": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 KST"
    },
    "task_id": {
      "type": "string",
      "pattern": "^task-[0-9]+(\\+[0-9a-z]+)?(\\.[a-z_]+)?$"
    },
    "contract_layer": {
      "type": "string",
      "enum": [
        "layer_0_task_md_sha",
        "layer_1_dispatch_marker",
        "layer_2_spawn_detection",
        "layer_3_watchdog",
        "layer_4_callback_closeout",
        "layer_5_finish_task_profile",
        "layer_6_actor_attribution",
        "layer_7_incident_routing"
      ]
    },
    "decision_class": {
      "type": "string",
      "enum": [
        "ALLOW",
        "DENY",
        "HOLD_FOR_CHAIR",
        "STATE_TRANSITION",
        "ALERT_INFO",
        "ALERT_WARN",
        "ESCALATE_CHAIR",
        "SUPPRESSED",
        "UNKNOWN"
      ]
    },
    "evidence": {
      "type": "object",
      "description": "신호 source 별 evidence — single source decisive 금지 · 최소 2 신호 권장",
      "properties": {
        "task_md_sha": {
          "type": "object",
          "properties": {
            "expected_sha": {"type": "string"},
            "actual_sha": {"type": "string"},
            "content_verbatim_match": {"type": "boolean"},
            "metadata_patch_detected": {"type": "boolean"},
            "continue_allowed": {"type": "boolean"}
          }
        },
        "dispatch_marker": {
          "type": "object",
          "properties": {
            "marker_path": {"type": "string"},
            "schedule_id": {"type": "string"},
            "executor": {"type": "string"},
            "bot_key_hash": {"type": "string", "description": "sha256(bot_key)[:16] · raw key 금지"},
            "fire_time": {"type": "string", "format": "date-time"},
            "prompt_sha": {"type": "string"},
            "task_md_sha_before": {"type": "string"},
            "dispatch_method": {
              "type": "string",
              "enum": ["dispatch_py", "direct_cron_bot_key", "fallback_safety_net"]
            }
          }
        },
        "spawn_signals": {
          "type": "object",
          "description": "8 source 교차 evidence",
          "properties": {
            "task_id_present": {"type": "boolean"},
            "schedule_id_present": {"type": "boolean"},
            "bot_key_present": {"type": "boolean"},
            "session_id_present": {"type": "boolean", "description": "별도 system_prompt hex 관측"},
            "timer_status": {
              "type": "string",
              "enum": ["absent", "running", "completed", "completed_owner_decision_accepted", "cancelled"]
            },
            "worktree_or_artifact_mtime_seconds": {"type": ["integer", "null"], "description": "<900 = fresh"},
            "bot_output_present": {"type": "boolean"},
            "schedule_history_present": {"type": "boolean"}
          }
        },
        "spawn_state": {
          "type": "string",
          "enum": [
            "NOT_REGISTERED",
            "REGISTERED",
            "FIRED",
            "SESSION_SEEN",
            "WORK_STARTED",
            "ARTIFACT_SEEN",
            "CALLBACK_REGISTERED",
            "DONE",
            "UNKNOWN"
          ]
        },
        "watchdog_alive_signals": {
          "type": "object",
          "properties": {
            "dispatch_marker_present": {"type": "boolean"},
            "closeout_marker_present": {"type": "boolean"},
            "escalate_marker_present": {"type": "boolean"},
            "spawn_state_ge_work_started": {"type": "boolean"},
            "bot_session_process_active": {"type": "boolean"},
            "worktree_mtime_lt_900s": {"type": "boolean"},
            "recent_artifact_mtime_lt_900s": {"type": "boolean"}
          }
        },
        "watchdog_state": {
          "type": "string",
          "enum": ["QUIET", "WATCH", "ALERT_INFO", "ALERT_WARN", "ESCALATE_CHAIR", "SUPPRESSED"]
        },
        "closeout_state": {
          "type": "string",
          "enum": [
            "WORK_CLOSEOUT_STARTED",
            "FINISH_IN_PROGRESS",
            "CALLBACK_LAUNCHED",
            "DONE",
            "ANU_RECEIVED",
            "CHAIR_REPORTED"
          ]
        },
        "callback_path": {
          "type": "string",
          "enum": ["normal_callback", "closeout_marker_watcher", "fallback_safety_net"]
        },
        "finish_task_profile": {
          "type": "object",
          "properties": {
            "task_mode": {
              "type": "string",
              "enum": ["code", "system_hook", "local_runtime", "read_only", "callback_only", "closeout_marker_only"]
            },
            "git_evidence_result": {
              "type": "string",
              "enum": ["PASS", "WARN", "FAIL", "NOT_APPLICABLE"]
            },
            "l1_smoke_result": {
              "type": "string",
              "enum": ["PASS", "WARN", "FAIL", "NOT_APPLICABLE"]
            },
            "scope_guard_result": {
              "type": "string",
              "enum": ["PASS", "WARN", "FAIL", "NOT_APPLICABLE"]
            }
          }
        },
        "matched_rule": {
          "type": "string",
          "description": "v3.6 harness rule id (예: pattern.session_bound_direct_polling)"
        },
        "tool": {"type": "string"},
        "command": {"type": "string"},
        "elapsed_ms": {"type": "number"}
      },
      "additionalProperties": true
    },
    "decision_outcome": {
      "type": "object",
      "required": ["next_state", "next_action"],
      "properties": {
        "next_state": {"type": "string"},
        "next_action": {
          "type": "string",
          "enum": [
            "PROCEED",
            "POLL_NEXT_SAMPLE",
            "REPORT_TO_CHAIR",
            "SUPPRESS",
            "BLOCK_TOOL_CALL",
            "HOLD_AWAIT_DECISION",
            "REGISTER_FALLBACK",
            "RECEIVE_AND_REPORT",
            "ESCALATE"
          ]
        },
        "tool_call_decision": {
          "type": ["string", "null"],
          "enum": [null, "ALLOW", "DENY", "HOLD_FOR_CHAIR"]
        }
      }
    },
    "actor_attribution": {
      "type": "object",
      "required": ["evidence_level", "claimed_actor"],
      "properties": {
        "evidence_level": {
          "type": "string",
          "enum": ["L1_SELF_ATTESTATION", "L2_AUDIT_LOG_OR_COMMIT_TRAILER", "L3_RUNTIME_HOOK_EVIDENCE"]
        },
        "claimed_actor": {"type": "string", "description": "예: hermes / vulcan / maat / anu_body / dev1_bot"},
        "verifiable": {"type": "boolean"},
        "evidence_path": {"type": "string"}
      }
    },
    "reason_code": {
      "type": "string",
      "description": "결정 사유 enum — 자연어 자유 입력 금지",
      "enum": [
        "verbatim_match_metadata_patch_ok",
        "verbatim_mismatch_block",
        "expected_sha_outdated_resync",
        "spawn_signals_insufficient_unknown",
        "spawn_state_progressed_normal",
        "watchdog_alive_signal_majority",
        "watchdog_silently_stalled_cycle_1",
        "watchdog_silently_stalled_cycle_2",
        "watchdog_escalate_critical7",
        "watchdog_escalate_chair_explicit",
        "watchdog_suppressed_by_escalate_marker",
        "closeout_marker_observed_anu_signal_required",
        "callback_normal_received",
        "callback_fallback_triggered",
        "anu_reception_delay_alert",
        "tool_call_pattern_match_deny",
        "tool_call_pattern_match_hold",
        "tool_call_pattern_no_match_allow",
        "actor_attribution_verifiable_l3",
        "actor_attribution_self_attestation_only_l1",
        "incident_routed_to_contract"
      ]
    },
    "chair_authorization_id": {
      "type": ["string", "null"],
      "description": "회장 verbatim 발급 id 또는 null (운영 자동 결정)"
    },
    "dry_run": {"type": "boolean"},
    "linked_decision_ids": {
      "type": "array",
      "items": {"type": "string"},
      "description": "연관 결정 record (예: 같은 task 의 spawn → watchdog → closeout 체인)"
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "schema_version": "v36.runtime_harness.decision.v1",
      "decision_id": "task-2703.spawn-state.20260528T133000+0900",
      "ts": "2026-05-28T13:30:00+09:00",
      "task_id": "task-2703",
      "contract_layer": "layer_2_spawn_detection",
      "decision_class": "STATE_TRANSITION",
      "evidence": {
        "spawn_signals": {
          "task_id_present": true,
          "schedule_id_present": true,
          "bot_key_present": true,
          "session_id_present": false,
          "timer_status": "running",
          "worktree_or_artifact_mtime_seconds": 30,
          "bot_output_present": false,
          "schedule_history_present": false
        },
        "spawn_state": "UNKNOWN"
      },
      "decision_outcome": {
        "next_state": "UNKNOWN",
        "next_action": "POLL_NEXT_SAMPLE",
        "tool_call_decision": null
      },
      "actor_attribution": {
        "evidence_level": "L3_RUNTIME_HOOK_EVIDENCE",
        "claimed_actor": "anu_body",
        "verifiable": true,
        "evidence_path": "memory/system/.v36_harness_decision.jsonl"
      },
      "reason_code": "spawn_signals_insufficient_unknown",
      "chair_authorization_id": null,
      "dry_run": false,
      "linked_decision_ids": []
    },
    {
      "schema_version": "v36.runtime_harness.decision.v1",
      "decision_id": "task-2703.watchdog-alert.20260528T134200+0900",
      "ts": "2026-05-28T13:42:00+09:00",
      "task_id": "task-2703",
      "contract_layer": "layer_3_watchdog",
      "decision_class": "ALERT_INFO",
      "evidence": {
        "watchdog_alive_signals": {
          "dispatch_marker_present": false,
          "closeout_marker_present": false,
          "escalate_marker_present": false,
          "spawn_state_ge_work_started": true,
          "bot_session_process_active": true,
          "worktree_mtime_lt_900s": false,
          "recent_artifact_mtime_lt_900s": false
        },
        "watchdog_state": "ALERT_INFO"
      },
      "decision_outcome": {
        "next_state": "ALERT_INFO",
        "next_action": "POLL_NEXT_SAMPLE",
        "tool_call_decision": null
      },
      "actor_attribution": {
        "evidence_level": "L3_RUNTIME_HOOK_EVIDENCE",
        "claimed_actor": "watchdog",
        "verifiable": true,
        "evidence_path": "logs/session-watchdog.log"
      },
      "reason_code": "watchdog_silently_stalled_cycle_1",
      "chair_authorization_id": null,
      "dry_run": false,
      "linked_decision_ids": []
    },
    {
      "schema_version": "v36.runtime_harness.decision.v1",
      "decision_id": "task-2703.tool-call.deny.20260528T043828+0000",
      "ts": "2026-05-28T04:38:28+00:00",
      "task_id": "task-2703",
      "contract_layer": "layer_5_finish_task_profile",
      "decision_class": "DENY",
      "evidence": {
        "matched_rule": "pattern.forbidden_tool_or_shell",
        "tool": "Bash",
        "command": "git push origin main --force",
        "elapsed_ms": 6.688
      },
      "decision_outcome": {
        "next_state": "BLOCKED",
        "next_action": "BLOCK_TOOL_CALL",
        "tool_call_decision": "DENY"
      },
      "actor_attribution": {
        "evidence_level": "L3_RUNTIME_HOOK_EVIDENCE",
        "claimed_actor": "v36_harness_pre_tool_use",
        "verifiable": true,
        "evidence_path": "/home/jay/.claude/hooks/pre_tool_use_v36_harness.py"
      },
      "reason_code": "tool_call_pattern_match_deny",
      "chair_authorization_id": "CHAIR-AUTH-TASK-2703-V36-HARNESS-MVP-260528",
      "dry_run": false,
      "linked_decision_ids": []
    }
  ]
}
