フック
SessionStart、PreToolUse、Stop で発火するツールイベントハンドラ。git 隔離と計画規律を強制するメッセージコンテキストを読み込みます。
フックはツールイベントで発火し、アシスタントが追加のシステムプロンプトとして扱う
メッセージコンテキストを読み込みます。配線は Claude Code の settings.json フックブロック、
Codex の hooks.json フックファイル、Qwen Code の settings.json フックマップに
存在します。
| イベント | タイムアウト | 目的 |
|---|---|---|
| SessionStart | 30 秒 | メモリの読み取り、計画状態の確認、準備完了の報告 |
| PreCompact | 30 秒 | 圧縮前に状態が外部化されていることを検証 |
| PostCompact | 30 秒 | 圧縮後に作業状態を復元 |
| Stop | 60 秒 | セッション終了時の外部化 |
| PreToolUse (Bash) | 10 秒 | Bash の検証 — git 成果物の隔離 |
| PreToolUse (Write/Edit/NotebookEdit/apply_patch) | 10 秒 | 計画参照の隔離、frontmatter のチェック |
ディスパッチャ
インストールされたフックエントリは、絶対スクリプトパスでディスパッチャを呼び出します。
設定テンプレートは ${HARNESS_ROOT} トークンを保持し——
python "${HARNESS_ROOT}/apothem/hooks/dispatch.py" <event> [<message-name>]
——インストーラはインストール時にこれを harness ルートの実パスへとレンダリングします
(Claude Code と Qwen Code はディスパッチャを <harness-root>/apothem/hooks/ の下に、
Codex は <harness-root>/hooks/ の下に具現化します)。ディスパッチャは自己完結型の
標準ライブラリスクリプトです。自身の sys.path をブートストラップするため、
ホスト上にインポート可能な apothem パッケージは不要です。ソースチェックアウトからは、
モジュール形式 python -m apothem.hooks.dispatch <event>(PYTHONPATH=src 付き)が
開発用に同じコードを実行します。ディスパッチャはエコシステムルートの解決のために
hooks/lib/resolve_root.py を読み込み、hooks/emit_hook_context.py および
hooks/session_start_bootstrap.py に委譲します。
メッセージコンテキスト
イベントごとの Markdown コンテキストは src/apothem/hooks/messages/ の下に存在します。
postcompact.md、precompact.md、stop.mdpretooluse-bash.md、pretooluse-write.md、pretooluse-edit.md、pretooluse-notebookedit.md
各コンテキストファイルは、そのイベントが発火し、そのコンテキスト引数が設定ファイルに 登録されているときに、ディスパッチャによって読み込まれます。
生成されたフックメッセージのインベントリ
| Name | Description | Source |
|---|---|---|
postcompact | Post-compaction Blind Bootstrap (CM-24 §6.2). Restore working state from durable files; conversation context is now compressed. | src/apothem/hooks/messages/postcompact.md |
posttooluse-proactive-compaction | Proactive-compaction tracker for PostToolUse tool calls. | src/apothem/hooks/messages/posttooluse-proactive-compaction.md |
precompact | Pre-compaction protocol (CM-24 §2.3). Externalize all in-conversation state BEFORE the harness compresses context. | src/apothem/hooks/messages/precompact.md |
pretooluse-askuserquestion-recommended | Call-time (Recommended)-marker guard for AskUserQuestion tool calls. | src/apothem/hooks/messages/pretooluse-askuserquestion-recommended.md |
pretooluse-bash-plan-guard | Plans-Discipline write guard for Bash tool calls (companion to pretooluse-write-plan-guard.md). | src/apothem/hooks/messages/pretooluse-bash-plan-guard.md |
pretooluse-bash | CM-7 git-artifact isolation + M12 numeric-prefix discipline + M15 human-only authorship. | src/apothem/hooks/messages/pretooluse-bash.md |
pretooluse-conformity | > Advisory: this hook reports; it does not block. Mechanical enforcement runs in CI. | src/apothem/hooks/messages/pretooluse-conformity.md |
pretooluse-dependency-guard | Dependency-manifest supply-chain guard (advisory). | src/apothem/hooks/messages/pretooluse-dependency-guard.md |
pretooluse-edit-header-guard | SPDX-header inject guard for Edit tool calls. | src/apothem/hooks/messages/pretooluse-edit-header-guard.md |
pretooluse-edit | Codebase isolation (Edit scope). | src/apothem/hooks/messages/pretooluse-edit.md |
pretooluse-eval-guard | Dynamic-eval / unsafe-deserialization guard — advisory prompt-injection defense. | src/apothem/hooks/messages/pretooluse-eval-guard.md |
pretooluse-notebookedit | Codebase isolation (notebook scope). | src/apothem/hooks/messages/pretooluse-notebookedit.md |
pretooluse-write-header-guard | SPDX-header inject guard for Write tool calls. | src/apothem/hooks/messages/pretooluse-write-header-guard.md |
pretooluse-write-plan-guard | Plans-Discipline write guard for Write / Edit / NotebookEdit tool calls. | src/apothem/hooks/messages/pretooluse-write-plan-guard.md |
pretooluse-write | Codebase isolation + frontmatter compliance. | src/apothem/hooks/messages/pretooluse-write.md |
sessionstart | Session-start conformity posture. | src/apothem/hooks/messages/sessionstart.md |
stop | Session-end protocol (CM-14 + CM-24 §2.5 + CM-26 + CM-22 §2/§4). | src/apothem/hooks/messages/stop.md |