{
  "format": "agent-article-v0",
  "article_id": "GX-0005",
  "content_family": "GX",
  "public_kind": "ARTICLE_PRODUCT",
  "revision_id": "GX-0005-R20261027-01",
  "canonical_url": "/providers/gx-0005-anthropic-claude-code-hooks-enforcement-failure-and-observabilit",
  "page_type": "reference",
  "claim_ids": [],
  "evidence_ids": [],
  "unknown_ids": [
    "GX-0005-UNKNOWN-01"
  ],
  "operational_object_ids": [],
  "provider": [
    "Anthropic"
  ],
  "models": [
    "hooks"
  ],
  "plans": [],
  "surfaces": [
    "lifecycle interception"
  ],
  "regions": [],
  "current_status": "CURRENT",
  "observation_status": "UNOBSERVED",
  "freshness": "CURRENT",
  "last_verified": "2026-10-27",
  "supersedes": [],
  "superseded_by": [],
  "provenance": [],
  "article_sources": [],
  "research_sections": [
    {
      "heading": "要点と前提",
      "text": "Claude Code hooksは、sessionやtool lifecycleの特定eventでcommand、HTTP endpoint、MCP tool、prompt、agent等を起動する拡張・制御機構である。PreToolUseはtool実行前に発火し、明示的なdenyでtool callを止められる。ただし、設定ファイルにhookが存在すること自体は、そのhookが実際に発火し、意図したdecisionが適用されたことの証明ではない。"
    },
    {
      "heading": "Current contract",
      "text": "2026-10-27時点のClaude Code Hooks referenceでは、PreToolUseとPostToolUseはagentic loop内の各tool callで発火する（EndConversationは例外）。matcherはtool name等を対象にし、PreToolUseはpermissionDecision=denyでtool callをblockできる。hook sourceはuser/project/local/managed/plugin等に分かれ、subagent tool callsでも同じconfigured hooksが動く一方、managed policyのallowManagedHooksOnly等によりeffective hook setが制限され得る。したがって、設定sourceと実際のeffective hook setを分離して扱う。"
    },
    {
      "heading": "Failure semantics",
      "text": "command hookはexit code 2などevent-specific blocking pathを持つ一方、通常のその他exit codeはnon-blocking errorとなり得る。HTTP hookについて現行referenceはnon-2xx、connection failure、timeoutをnon-blocking errorとして扱い、明示的な2xx JSON decisionでblock/denyする契約を示す。安全制御としてhookを使う場合、spawn失敗、path/executable不備、matcher不一致、HTTP endpoint outageを自動的なfail-closedと仮定しない。"
    },
    {
      "heading": "Counterevidence / runtime conformance",
      "text": "Author-maintained issue #85430は2026-08-10、同じproject settingsからpermissions.denyは効くのにPreToolUse hookが特定working directoryで発火しないという再現報告を残している。原因は確定しておらず、全環境へ一般化しない。issue #46193はClaude Code 2.1.100 / Windowsで、unreachableなPermissionRequest HTTP hookがdocumented non-blocking contractに反してtool callをdenyしたという報告である。issue #94362はClaude Code 2.1.270 / macOSで、実行bitを失ったPreToolUse commandがnon-blocking failureとなりguardがfail-openしたという報告である。issue #85904は2.1.219 / Windowsで、再測定時にはPreToolUse自体は発火したがdefaultMode=auto下でpermissionDecision=askが無視されたというversion-scoped報告を含む。\n\nこれらはprovider contractではなくruntime counterevidenceであり、issue closureや単一reportからcurrent latestの修正状態を断定しない。"
    },
    {
      "heading": "Operational meaning",
      "text": "高影響操作のguardrailにhooksを使う場合は、設定存在確認だけでなく、対象version/platform/modeでpositive probeとnegative probeを行う。少なくとも、(1) matcher対象toolでhook invocationが観測できること、(2) deny pathが実際にtool executionを止めること、(3) hook failure時のfail-open/fail-closed挙動、(4) auto/headless/subagent等の実行mode差、(5) managed policyによるeffective hook set、をreadbackする。hook側にもinvocation/decision/errorの監査ログを持たせ、設定済みと実行済みを分離する。\n\n外部APIやdatabase等のside effectでは、hook deny成功を唯一のauthorization boundaryにせず、対象system側のcredential scope、transaction、approval、idempotency等と組み合わせる。hookが発火したことは外部side effectのexactly-onceや取消し可能性を保証しない。"
    },
    {
      "heading": "Unconfirmed",
      "text": "- #85430、#46193、#94362、#85904で報告された挙動のcurrent latest releaseでの完全な修正状態。\n- terminal / IDE / desktop / cloud / headless / subagent間の全platform・全mode conformance。\n- auto mode等のpermission pipeline変更時にhook decision precedenceが将来どのように変化するか。\n- hook invocation/decisionの標準的なdurable audit schemaと保持保証。"
    },
    {
      "heading": "原著の公式参照先（未検証）",
      "text": "以下は原研究に記録された公式資料へのリンクです。現在の内容、資料の更新日、個別主張の妥当性を新たに検証したものではありません。\n- https://code.claude.com/docs/en/hooks"
    }
  ],
  "human_url": "/providers/gx-0005-anthropic-claude-code-hooks-enforcement-failure-and-observabilit",
  "markdown_url": "/agent/article.md?path=%2Fproviders%2Fgx-0005-anthropic-claude-code-hooks-enforcement-failure-and-observabilit",
  "json_url": "/agent/article.json?path=%2Fproviders%2Fgx-0005-anthropic-claude-code-hooks-enforcement-failure-and-observabilit"
}