Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1939"
goal_ref: >-
#1939 Workstream 2(completion transaction and reconciliation)を、Claude Code /
Claude-GPT の agent run terminal observation(runtime_lane / completion_outcome /
completion_source)を agent_session_manifest/v1 の最小拡張として materialize し、
idempotent completion transaction と provider telemetry unavailable coverage を
確立する。Codex CLI は新規 hook infrastructure を追加せず、既存経路で取得できない
path を unavailable として coverage に残す。
change_kind: workflow
dedupe_key: "1939:workstream-2:completion-transaction-and-reconciliation:v1"human_context_comment
- https://github.com/squne121/loop-protocol/issues/2489#issuecomment-5539261190(OWNER 敵対的レビュー、No-Go as-is 判定。本 Issue はこのレビューを反映して scope を reframe したもの)
- https://github.com/squne121/loop-protocol/pull/2496#issuecomment-5546874328(PR #2496上のOWNER敵対的レビュー。AC2のcompletion_outcome/completion_source turn-level誤設定と、AC4のcontext payload構築断絶をP0として撤回・修正要求)
- https://github.com/squne121/loop-protocol/issues/2489#issuecomment-5546983884(上記PRレビューを本Issueへ橋渡ししたコメント。本Issue改訂の直接の契機)
Parent Issue
Parent Goal Ref
- Goal(#1939本文より、一字一句引用): 「repository URL、calendar date、timezoneを入力にcanonical daily worksetとartifact coverageを再現可能に解決し、ChatGPTがGitHub connectorだけで正式entrypointを発見して、人間の依頼時にpublic-safeなretrospectiveを実施できる状態を作る。Claude CodeおよびCodex CLIのagent run完了は、public-safeなrun report、retro index、context markerを一つのcompletion transactionとして生成・投稿し、未投稿・失敗・interruptをreconciliationで検出できるようにする。」
- 訂正の経緯: 旧版本文は 導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 ではなく 導入: EntireCLI + Latitude の観測データを agent_run_report に接続し、GitHub 経由の ChatGPT レトロ動線を確立する #1153(3 CLI capture capability verdict の Goal)を誤転記していた(human_context_comment P1-1)。本 Child が引き継ぐのは 導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 の Goal であり、導入: EntireCLI + Latitude の観測データを agent_run_report に接続し、GitHub 経由の ChatGPT レトロ動線を確立する #1153 とは別 Issue である。
- 本Child(Workstream 2)が引き継ぐParentのAcceptance Criteria(#1939本文より一字一句引用):
- AC4: 「Workstream 2がClaude CodeとCodex CLIのadapter差を明示し、normal completion、failure、interrupt、cancel、crash、hook timeout、network failure、retryをcoverage状態として記録する」
- AC5: 「Workstream 2がrun report、retro index、context markerの生成・検査・投稿をidempotent completion transactionとして扱い、partial success recoveryとduplicate comment preventionを検証する」
- AC6: 「Workstream 2はprovider telemetry unavailableでもpublic-safe completion artifactまたは明示的unavailable coverageを残し、provider-side traceをsuccess gateにしない」
Background / Problem
2026-08-28〜09-03のClaude-GPT / Native Claude Code retrospective調査(本Issue起票元セッション)で、以下が判明した:
agent_run_report/v1の実インスタンス(GitHub Issue/PRコメントとして投稿されたもの)が、2026-08-28〜09-03の期間内コメント全文検索で0件だったdocs/schemas/agent-session-manifest.schema.json(agent_session_manifest/v1)はhuman_intervention.{required, type, summary}とphase.main_loopを持つが、「セッションが最後まで完走したか・どう止まったか」「どの runtime lane で実行されたか」を表現する専用フィールドを持たない- 結果として、「raw terminal completion rate」「native vs Claude-GPT の completion率」「completion artifact 欠落率」等の指標を、既存証跡から厳密に算出することができなかった
この構造的ギャップは #1939 Workstream 2(AC4-AC6、上記引用)が射程に入れている内容だが、Workstream 2はparent #1939の「Child Issues」セクションに未起票のまま記載されており、現時点でこのAC群を所有する子Issueが存在しなかった。
Owner 敵対的レビュー(human_context_comment)による指摘と本改訂での対応:
-
観測不能な stop_reason enum の要求(P0): 現在
.claude/settings.jsonが session manifest producer に接続しているのはStop/SubagentStop/PostToolUseのみで、StopFailureは未登録。加えて Claude Code のStopは user interrupt では発火しない(Claude Code hooks reference)。したがってinterrupt/timeout/permission_interruption/human_clarification_requestを1本の enum に含め、producer に「実際に値を埋める」ことを要求する設計は、観測できていない事象を推測させる false data 生成の危険がある。
→ 本改訂では stop_reason という単一 enum を廃止し、runtime_lane/completion_outcome/completion_sourceの3フィールドへ reframe する。unavailable/unknownを正規値として認め、未観測を推測しない。permission_interruptionやhuman_clarification_requestは既存human_interventionオブジェクト側の責務とし、terminal taxonomy には含めない。retryも terminal reason ではなく transition/action として扱い、taxonomy に含めない。さらなる訂正(PR #2496上のOWNER敵対的レビュー feat: agent_session_manifest/v1 に runtime_lane/completion_outcome/completion_source を追加 (#2489) #2496 (comment) 、ブリッジコメント 実装: #1939 Workstream 2 — completion transaction and reconciliation(stop reason taxonomy / runtime lane識別) #2489 (comment) 、P0):
Stop/StopFailureは Claude Code upstream仕様(hooks reference)上 turn-level event であり、SessionEndが session-level event である。rootcompletion_outcome/completion_source(session/run completionを表すフィールドとしてschemaに定義済み)をStop/StopFailureから直接設定する設計は、観測していないsession/run completionをturn観測から推測することになり、意味論的に誤りだった。本Issueはこれを反映し、completion_outcome/completion_sourceをStop/StopFailureからは設定しない(hook_event.event_typeへのStopFailure追加と optionalerror_typeフィールドのみをturn-level evidenceとして保持する)ようscopeを再修正する。root completion値は、scripts/generate-session-manifest.mjsが--completion-outcome/--completion-sourceCLI引数を受け取った場合にその値をそのまま書き込むCLI引数プラミングとしてのみ本Issueで用意し、launcher process exit時に実際にこれらの引数を渡す具体的呼び出し元(launcher本体)の新規配線は本Issueのスコープに含めない(別Issueに委ねる)。なお既存のtests/agent-logs/runtime-verification/test_hook_stop_failure_wiring.pyは本改訂前の誤った意味論(Stop/StopFailureからcompletion_outcome/completion_sourceを設定する前提)で実装・CI PASS済みであり、実装側もこのIssue改訂に追従して再修正が必要になる(実装修正自体は本rewriteの作業ではなく、後続のimpl-review-loop fix_deltaの責務)。 -
Codex CLI coverage の欠落(P0): 変更対象ファイルが Claude Code launcher 内の native/Claude-GPT 2 laneのみを区別しており、導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 Workstream 2 が要求する Codex CLI adapter 差が扱われていなかった。
→ 本改訂ではruntime_laneenum にcodex_cliを含め schema レベルの coverage を維持しつつ、Codex CLI 向けの新規 hook infrastructure はこの Issue のスコープに含めない(.codex/hooks.jsonは現時点でリポジトリに存在しない)。既存観測経路から Codex CLI の terminal evidence が取得できないため、producer 側の Codex CLI wiring は unavailable のまま coverage に残し、将来の別 Issue に委ねる。 -
runtime_lane の provenance 未定義(P1): producer が
actor.name等から runtime lane を推測する設計は fragile。
→ 本改訂では launcher が明示的に渡す provenance のみを使う。具体的には.claude/hooks/generate_session_manifest_from_hook.mjsが既存の launcher-set 環境変数CLAUDE_GPT_CLAUDE_BIN(調査: structured causal-evidence smoke の markerless FAIL を --no-session-persistence 契約と照合する #2338 で既に claude-gpt pin 識別に使われている既存の explicit provenance signal)の有無だけでclaude_gpt/native_claude_codeを判定し、producer 自身(scripts/generate-session-manifest.mjs)は--runtime-laneCLI 引数の値をそのまま受け取るだけで、名前や transcript からの推測は一切行わない。値を取得できない呼び出し元はunknownを渡す。 -
completion transaction の owner が曖昧(P1):
scripts/agent-logs/finalize-agent-run.mjsは実際には report JSON の生成・atomic write のみを行い、GitHub posting は行わない(scripts/agent-logs/post-agent-run-report.mjsの責務)。retro index upsert はscripts/agent-logs/update-retro-index.mjs、context marker upsert はscripts/agent-logs/lib/chatgpt-retro-context-marker-helper.mjsが担う。
→ 本改訂ではfinalize-agent-run.mjsへ transaction を寄せない。既存3つの exported 関数(postAgentRunReport/updateRetroIndex/upsertChatgptRetroContextComment)を順番に呼び出すだけの薄い coordinator(新規ファイル1つ)を追加し、各 operation の結果をcreated|updated|unchanged|failed程度で返す。DB・transaction log・2-phase commit は追加しない。途中失敗時は既存 operation の idempotency を利用し、同じ completion command を再実行して convergence させる。 -
AC3(partial success recovery)が「既存テストで確認」で完結してしまう(P1): 具体的な決定論的検証ケースを AC に明記する(後述 AC5 参照)。
-
provider telemetry unavailable は既存実装でかなりカバー済み(P2):
docs/schemas/agent-run-report.schema.jsonのobservation_sources[].safety.reason_codesに既にsource_unavailableがあり、tests/agent-logs/observation-source-adapter.test.ts等で unavailable ケースがテストされている。新しい fallback system は追加しない。既存 adapter が unavailable でも validation/finalization できることを focused test で確認する。
なお、duplicate-comment-prevention / upsert機構自体はゼロから作る必要はない。scripts/agent-logs/lib/chatgpt-retro-context-marker-helper.mjs の upsertChatgptRetroContextComment/findMalformedMarkerIntentComment/blocked_duplicate、および scripts/agent-logs/update-retro-index.mjs の updateRetroIndex、scripts/agent-logs/post-agent-run-report.mjs の postAgentRunReport 等、既存のupsert/duplicate検出インフラを最大限再利用し、再実装しない。
Current Validated Scope
docs/schemas/agent-session-manifest.schema.jsonに、以下3つの optional フィールドを追加する(既存 manifest との backward compatibility のため rootrequiredには含めない。producer は新規生成 manifest に対して常にこれらを埋める):runtime_lane: closed enumnative_claude_code | claude_gpt | codex_cli | unknowncompletion_outcome: closed enumcompleted | failed | interrupted | incomplete | unavailable(session/run-levelのcompletionを表す。turn-level event であるStop/StopFailurehookからは設定しない)completion_source: closed enumhook | launcher | reconciliation | unavailable(completion_outcomeの値がどの経路から得られたかを示す。hook値はturn-level hookからの推測ではなく、launcher/reconciliation側がturn-level evidenceを集約した上で明示的に設定する場合にのみ使う)
- 既存
hook_event.event_typeenum(optional object)にStopFailureを追加する(新規フィールドではなく既存フィールドの拡張)。hook_eventはturn-level evidenceを保存するオブジェクトであり、ここへの追加はrootcompletion_outcome/completion_sourceの設定を意味しない。SessionEndは Claude Code の reason enum が run-level crash taxonomy として粒度不足のため、本 Issue のスコープでは追加しない。 - 既存
hook_eventオブジェクトへ、StopFailure発火時のupstream structured error taxonomy(rate_limit | overloaded | authentication_failed | billing_error | invalid_request | model_not_found | server_error | max_output_tokens | unknown)を保存するoptionalerror_typeフィールドを追加する(turn-level evidenceの粒度向上。root completionフィールドとは独立)。 .claude/settings.jsonのStophooks 配列に、既存スクリプトsession_manifest_coordinator.shを再利用したままStopFailureイベントを追加登録する(新規 hook script は作らない。既存スクリプトを追加イベントへ接続するだけ)。この追加登録が実際に埋めるのはhook_event.event_type(とerror_type)のturn-level evidenceのみであり、rootcompletion_outcome/completion_sourceはこの経路からは埋めない。- schemaへのフィールド追加だけでなく、実際に値を埋めるproducer側を最小変更する:
scripts/generate-session-manifest.mjsに--runtime-laneCLI引数を追加し、.claude/hooks/generate_session_manifest_from_hook.mjsがイベント種別とCLAUDE_GPT_CLAUDE_BIN環境変数からこの値を導出してproducerへ渡す(既存方針を維持)。scripts/generate-session-manifest.mjsは--completion-outcome/--completion-sourceCLI引数を受け取った場合、その値をそのまま(推測を挟まず)manifestへ書き込む。hook wrapper(.claude/hooks/generate_session_manifest_from_hook.mjs、turn-level)はこれらの引数を一切渡さない(root completion値がhookから設定されないことを保証する)。CLI引数受け取り→manifest書き込みのプラミングは本Issueで実装するが、launcher process exit時に実際にこれらのCLI引数を渡す具体的呼び出し元(launcher本体)の新規配線は本Issueのスコープに含めない。値を埋める実際のトリガー配線は将来の別Issueに委ねる。- hook wrapperは
hook_event.event_type(Stop/StopFailure等)とoptionalerror_typeをproducerへ渡す。
(schema定義のみでproducerが値を出力しない状態でAC1/AC2を満たしたことにしない)
agent_run_report/v1/agent_retro_index/v1/CHATGPT_RETRO_CONTEXT_V1の生成・投稿を idempotent completion transaction として扱えるよう、既存3 upsert(postAgentRunReport/updateRetroIndex/upsertChatgptRetroContextComment)を順に呼び出す薄い coordinator(新規ファイルscripts/agent-logs/complete-agent-run.mjs1つ)を追加し、package.jsonにagent-run:completescript entry を追加する。3番目のupsertへ渡すcontext payloadは1・2の実際の戻り値(comment_url・digest類)から構築し、事前生成済みMarkdownファイルの内容をそのまま渡さない(PR #2496上のOWNER敵対的レビュー feat: agent_session_manifest/v1 に runtime_lane/completion_outcome/completion_source を追加 (#2489) #2496 (comment) P0-2参照)。partial success recoveryとduplicate comment preventionを決定論的 test で検証する(AC5相当)- provider telemetry(Latitude等)がunavailableな場合でも、public-safe completion artifactまたは明示的unavailable coverageを残す既存ロジック(
agent-run-report.schema.jsonのobservation_sources[].safety.reason_codes等)が provider trace absence を completion failure の gate にしていないことを focused test で確認する(AC6相当。新規 fallback 実装は行わない)
Remaining Parent Gaps
本Issue(#1939 Workstream 2)が閉じない #1939 の残課題:
- Workstream 1(daily workset contract/result schema)— 未起票(別Child Issue)
- Workstream 3(repository-level ChatGPT discovery entrypoint)— 未起票(別Child Issue、Workstream 1 に依存)
- Workstream 4(follow-up Issue candidate materialization handoff)— 未起票(別Child Issue)
- Workstream 5(opaque public evidence/private local audit resolver)— 未起票(別Child Issue、Workstream 2 に依存)
- Codex CLI 向けの completion transaction producer wiring — 本Issueでは
runtime_lane: codex_cliの schema enum coverage のみ提供し、実際の値充填(Codex CLI producer wiring)は別Issueへ委ねる(human_context_comment P0-2) - launcher process exit時に
--completion-outcome/--completion-sourceCLI引数を実際に渡す具体的呼び出し元(launcher本体)の新規配線 — 本Issueではscripts/generate-session-manifest.mjsのCLI引数受け取り→manifest書き込みのプラミングのみ提供し、実際の値充填トリガー(launcher呼び出し元)の新規実装は別Issueへ委ねる(semantic design review P0対応)
Outcome
agent_session_manifest/v1 に runtime_lane / completion_outcome / completion_source フィールドが追加され、runtime_lane フィールドおよび hook_event.event_type(StopFailure 追加分)/ error_type は Claude Code の Stop / StopFailure イベント(turn-level hook-provenance)から実際に値が埋まり、一方で completion_outcome / completion_source は Stop / StopFailure 等のturn-level hookからは設定されず、scripts/generate-session-manifest.mjs が --completion-outcome/--completion-source CLI引数を受け取った場合にその値をそのまま書き込むCLI引数プラミングが実装され(launcher process exit時に実際にこれらの引数を渡す具体的呼び出し元の新規配線は別Issueに委ねる)、新規の薄い coordinator(scripts/agent-logs/complete-agent-run.mjs)が run report / retro index / context marker の3 artifactをidempotentに生成・投稿でき、partial success recoveryとduplicate comment preventionが決定論的testで証明されており、pnpm typecheck && pnpm lint && pnpm test && pnpm build が全てPASSしている状態。
In Scope
docs/schemas/agent-session-manifest.schema.jsonへのruntime_lane/completion_outcome/completion_source追加とhook_event.event_typeenum へのStopFailure追加scripts/generate-session-manifest.mjsへの--runtime-lane/--completion-outcome/--completion-sourceCLI引数追加.claude/hooks/generate_session_manifest_from_hook.mjsのCLAUDE_GPT_CLAUDE_BIN環境変数・イベント種別からのvalue導出.claude/settings.jsonへのStopFailureイベント登録(既存session_manifest_coordinator.sh再利用)scripts/agent-logs/complete-agent-run.mjs(新規の薄い completion transaction coordinator)とpackage.jsonのagent-run:completescript entry- 上記に対応する
tests/agent-logs/配下の focused test(動作検証 VC を含む)
Out of Scope
- Workstream 1(daily workset contract/result schema)、Workstream 3(repository-level ChatGPT discovery entrypoint)、Workstream 4(follow-up Issue candidate materialization handoff)、Workstream 5(opaque public evidence/private local audit resolver)は本Issueでは扱わない(#1939の別Child Issueとして分離)。
- Codex CLI 向けの新規 hook infrastructure(
.codex/hooks.jsonの新設、Codex CLI producer wiring)は本Issueのスコープに含めない。runtime_laneenum にcodex_cliを schema レベルで含めるに留め、実際の値の充填は将来の別 Issue に委ねる(human_context_comment P0-2 対応)。 - launcher process exit時に
--completion-outcome/--completion-sourceCLI引数を実際に渡す具体的呼び出し元(launcher本体)の新規配線は本Issueのスコープに含めない。 本Issueが実装するのはscripts/generate-session-manifest.mjs側のCLI引数受け取り→manifest書き込みのプラミングのみであり、値を実際に埋める起動トリガーの新規実装は将来の別Issueに委ねる(semantic design review 対応)。 SessionEndhook の新規登録、およびSessionEndの reason を completion taxonomy へマッピングする設計は行わない(reason enum が粗く false precision を生むため)。permission_interruption/human_clarification_requestを terminal taxonomy の enum 値として追加しない(既存human_interventionオブジェクト側の責務とする)。- Latitude/EntireCLIのraw trace内容そのものを公開artifactへ含めることは行わない(既存のpublic-safe boundaryを維持)。
- 新しいpermission broker、新しいenforcing hook、新しいledger/digest checkerの追加は行わない(
#1860の既存owner decisionと衝突するため)。 - stop_reasonから自動的にfollow-up Issue起票やdeterministic remediationへ誘導する自動化(導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 Workstream 4の範囲)は本Issueでは扱わない。
scripts/agent-logs/finalize-agent-run.mjsへ completion transaction の責務を寄せることは行わない(既存の責務分離を維持する。human_context_comment P1-3)。completion_outcome/completion_sourceをStop/StopFailure等のturn-level hookから直接設定する設計(root-levelのsession/run completionとしては使わない。turn観測からsession/run completionを推測しない。PR feat: agent_session_manifest/v1 に runtime_lane/completion_outcome/completion_source を追加 (#2489) #2496 feat: agent_session_manifest/v1 に runtime_lane/completion_outcome/completion_source を追加 (#2489) #2496 (comment) P0参照)。--chatgpt-payload-markdown-fileから読み込んだ事前生成済み Markdown をそのままupsertChatgptRetroContextCommentへ渡す設計(既存digest-chain resolverとの整合を壊すため。同レビューP0-2参照)。
Acceptance Criteria
- AC1(導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 AC4相当):
agent_session_manifest/v1にruntime_lane(native_claude_code | claude_gpt | codex_cli | unknown)フィールドが追加され、schema validatorがこれを検証し、かつ.claude/hooks/generate_session_manifest_from_hook.mjsが既存の launcher-set 環境変数CLAUDE_GPT_CLAUDE_BINの有無だけから(actor.nameや transcript からの推測ではなく)値を導出してscripts/generate-session-manifest.mjsへ渡し、実際にこの値が埋まることを既存test配置(tests/agent-logs/)に準じたfocused testで確認する - AC2(導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 AC4相当):
agent_session_manifest/v1のcompletion_outcome(completed | failed | interrupted | incomplete | unavailable)とcompletion_source(hook | launcher | reconciliation | unavailable)は session/run-level のcompletionを表すフィールドであり、turn-level event であるStop/StopFailurehookからは設定しない(Claude Code upstream仕様上Stop/StopFailureはturn-level、SessionEndがsession-level。観測していないsession/run completionをturn観測から推測しない。PR #2496上のOWNER敵対的レビュー feat: agent_session_manifest/v1 に runtime_lane/completion_outcome/completion_source を追加 (#2489) #2496 (comment) 、ブリッジコメント 実装: #1939 Workstream 2 — completion transaction and reconciliation(stop reason taxonomy / runtime lane識別) #2489 (comment) 対応)。.claude/settings.jsonへStopFailureイベント(既存session_manifest_coordinator.shを再利用)を追加登録し、既存hook_event.event_typeenumへのStopFailure追加が turn-level evidence として実際に記録されることを、.claude/hooks/generate_session_manifest_from_hook.mjsを実プロセスとして起動する動作検証で確認する 。この動作検証は、Stop/StopFailureいずれの起動でも rootcompletion_outcome/completion_sourceが producer によって設定されない(hook_event配下にのみturn-level evidenceが記録される)ことを固定条件として含む。加えて、StopFailure発火時にupstream structured error taxonomy(rate_limit/overloaded/authentication_failed/billing_error/invalid_request/model_not_found/server_error/max_output_tokens/unknown等)をhook_event配下のoptionalerror_typeフィールドとして保存できることを同じ動作検証で確認する(判定困難な場合はunknownにfallbackしてよいが、値の有無自体は必ず記録する)。scripts/generate-session-manifest.mjsが--completion-outcome/--completion-sourceCLI引数を受け取った場合はその値をそのまま(推測を挟まず)manifestへ書き込むこと、および hook wrapper(.claude/hooks/generate_session_manifest_from_hook.mjs)経由ではこれらのCLI引数が一切渡されない(rootcompletion_outcome/completion_sourceがhookから設定されない)ことをコードレベルで確認する。launcher process exit時に実際にこれらのCLI引数を渡す具体的呼び出し元(launcher本体)の新規配線は本Issueのスコープに含めない。CI required checks のうち少なくとも1レーンで、この動作検証testが実際にプロセスを起動してPASSすること(ローカル自己申告のみ・SKIP-onlyでの充足は認めない)を確認する - AC3(導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 AC4相当): Codex CLI については本Issueで新規 hook infrastructure を追加せず、
runtime_lane: codex_cliが schema enumとして存在し、既存観測経路から値を取得できないケースがunavailableとして coverage に残ることをドキュメント(本Issue本文 Out of Scope)と schema test で確認する(Codex CLI producer wiring自体は本Issueのスコープ外) - AC4(導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 AC5相当):
scripts/agent-logs/complete-agent-run.mjs(新規の薄い coordinator)が既存3 upsert(postAgentRunReport/updateRetroIndex/upsertChatgptRetroContextComment)を順番に呼び出し、各結果をcreated|updated|unchanged|failedとして返すことを、以下4ケースの決定論的 focused test で証明する。upsertChatgptRetroContextCommentへ渡すcontext payloadはpostAgentRunReport/updateRetroIndexの実際の戻り値(comment_url・report digest・canonical_index_digest・source_comment_set_digest 等)から構築すること。事前生成済み Markdown ファイル(--chatgpt-payload-markdown-file由来のcontent)をそのまま3番目のupsertへ渡してはならない(PR #2496上のOWNER敵対的レビュー feat: agent_session_manifest/v1 に runtime_lane/completion_outcome/completion_source を追加 (#2489) #2496 (comment) P0-2、ブリッジコメント 実装: #1939 Workstream 2 — completion transaction and reconciliation(stop reason taxonomy / runtime lane識別) #2489 (comment) が指摘した、既存CHATGPT_RETRO_CONTEXT_V1digest-chain resolver(PR #1251由来)に対するreference chain断絶の是正)。run reportまたはretro indexがfailed/blockedの場合、そのinvocationではcontext markerを作成せず、既存artifact status vocabulary(created|updated|unchanged|failed)の範囲内でreason_code: prerequisite_failedを伴うfailedとして表現する:- 初回実行 → run report / retro index / context marker の3 artifactが作成され、3番目のcontext marker payloadが1・2の実際の戻り値(comment_url・digest類)から構築されていることを確認する
- 同一 run を再実行 → GitHub コメント数が増えない(noop/unchanged)
- run report 投稿成功後、retro index 投稿が失敗するケースをモックし、同じ coordinator command を再実行すると run report を重複させず、残り(retro index / context marker)が完成し、かつretryで生成されたcontext markerを既存resolverへ渡した結果、actual report/index referencesとactual digestsが一致したresolved状態まで到達することを確認する(comment数が増えないことの確認だけで完結させない)
- malformed/ambiguous marker が既に存在するケースで、既存 policy(
findMalformedMarkerIntentComment等)に従って deterministic に blocked/repair されることを確認する
- AC5(導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 AC6相当): provider telemetry(Latitude等)がunavailableな場合でも、既存
observation-source-adapterがavailability: unavailableを持つ report を生成・validation/finalization できることと、provider trace absence だけでは agent completion failure(gate)にならないことを、tests/agent-logs/配下の既存またはfocused testで確認する(新規 fallback system は追加しない) - AC6: 既存の
pnpm typecheck && pnpm lint && pnpm test && pnpm buildが全てPASSする
Verification Commands
# AC6
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build
# AC1
$ pnpm test
# AC3
$ pnpm test
# AC4
$ pnpm test
# AC5
$ pnpm test
# AC2
$ uv run pytest tests/agent-logs/runtime-verification/test_hook_stop_failure_wiring.pyRuntime Verification Applicability
- decision: immediate
- reason: AC2 は
.claude/settings.json(hook_configurationcomponent、hook-lifecycle-matcher-or-handler-changerisk-trigger)へのStopFailureイベント追加登録を含み、docs/dev/extension-surface-runtime-policy.yamlのhook-lifecycle-matcher-or-handler-changeルールがdefault_decision: immediateを要求する。hook wrapper(.claude/hooks/generate_session_manifest_from_hook.mjs)を実プロセスとして起動し、synthetic Stop / StopFailure stdin JSON を与えて実際に manifest artifact が期待どおりのruntime_lane/hook_event.event_type(StopFailure追加後の値)/ optionalerror_typeで書き出されること、および rootcompletion_outcome/completion_sourceがこのhook経路からは設定されない(推測されない)ことを、本Issueの実装範囲内でプロセス起動・I/Oを伴う動作検証として確認できるため、deferred ではなく immediate とする。
applicable_acs: [AC2]
execution_environment:
cli_tools: [node]
auth_required: false
network_required: false
skip_conditions:- "node 実行環境が無い場合は SKIP として exit 77"
fallback_policy:
fallback_success_is_pass: false
notes: "fallback 経由の推測値(producer が埋めた値)を検出した場合は FAIL として扱い、PASS と判定しない"
artifact_requirements: - "artifacts/runtime-verification-AC2-.log"
- "node 実行環境が無い場合は SKIP として exit 77"
- 動作検証 AC: AC2(
<!-- runtime-verification: true -->タグ付与済み) - VC:
tests/agent-logs/runtime-verification/test_hook_stop_failure_wiring.py(uv run pytestで実行する。実装者が新規実装する。正常系:Stopstdin JSON を与えて.claude/hooks/generate_session_manifest_from_hook.mjsを実プロセスとして起動し、hook_event.event_type: Stopの manifest artifact が書かれ、rootcompletion_outcome/completion_sourceがこの起動では設定されない(キー自体が存在しないかunavailable/unknownである)ことを確認。異常系:StopFailurestdin JSON →hook_event.event_type: StopFailureとoptionalerror_type(upstream taxonomy値、または未判定時unknown)が manifest に書かれ、同様にrootcompletion_outcome/completion_sourceがこのhook起動からは設定されないことを確認。加えてCLAUDE_GPT_CLAUDE_BIN環境変数の有無でruntime_laneがclaude_gpt/native_claude_codeに切り替わることを確認。node 実行環境が無い場合はpytest.skip(...)で SKIP 相当(exit 77 に準じる非PASS扱い)とし、PASS と誤判定しない。fallback 経由の値(producer が推測で埋めた値)を検出した場合、またはhookからrootcompletion_outcome/completion_sourceが設定されてしまった場合は test failure(FAIL)とし、PASS と判定しない) - 証跡: test-runner が
artifacts/runtime-verification-AC2-<timestamp>.logに本ポリシー第4節の必須フィールド(AC / Timestamp / Environment / Input / Output / Verdict)で書き出し、PR 本文の## Runtime Verification Evidenceセクションへ inline 引用する
Allowed Paths
docs/schemas/agent-session-manifest.schema.json(runtime_lane/completion_outcome/completion_sourceフィールド追加、hook_event.event_typeenumへStopFailure追加、hook_event配下へのoptionalerror_typeフィールド追加。completion_outcomeとcompletion_sourceのpair constraint(両方存在するか両方存在しないか、JSON SchemadependentRequired相当)の明記を検討する)docs/schemas/agent-session-manifest.md(companion doc。フィールド追加をここに反映する)scripts/generate-session-manifest.mjs(producer本体、--runtime-lane/--completion-outcome/--completion-sourceCLI引数を追加し、CLI引数として受け取った値をそのままmanifestへ書き込む変更。--completion-outcome/--completion-sourceはhook wrapperからは渡されない設計とするが、launcher process exit時に実際にこれらの引数を渡す具体的呼び出し元(launcher本体)の新規配線は本Issueのスコープに含めない).claude/hooks/generate_session_manifest_from_hook.mjs(hook経由のproducer。イベント種別とCLAUDE_GPT_CLAUDE_BIN環境変数からruntime_laneとhook_event.event_type/optionalerror_typeを導出しproducerへ渡す。rootcompletion_outcome/completion_sourceはこのhook wrapperからは渡さない).claude/settings.json(Stophooks配列に既存session_manifest_coordinator.shを再利用したままStopFailureイベント登録を追加する。新規 hook script は追加しない)scripts/agent-logs/complete-agent-run.mjs(新規。既存3 upsertを順番に呼び出す薄い coordinator。3番目のupsertへ渡すcontext payloadは1・2の実際の戻り値から構築し、事前生成済みMarkdownファイルの内容をそのまま渡さない)scripts/agent-logs/lib/chatgpt-retro-context-marker-helper.mjs(P0-2対応のため、既存upsertChatgptRetroContextComment/findMalformedMarkerIntentComment/blocked_duplicate等の再利用に加え、新規exported関数buildChatgptRetroContextPayloadFromResults()(postAgentRunReport/updateRetroIndexの実際の戻り値からcontext payloadを構築する関数)の追加に限定する。既存 upsert 本体の再実装は行わない)package.json(agent-run:completescript entry を追加)docs/dev/agent-run-report.md(新規 coordinator command のresponsibility boundary記述を追加。既存のagent-run:finalize/agent-run:post/chatgpt-retro-context:postの責務境界説明は変更しない。--chatgpt-payload-markdown-fileはfresh completionの必須入力から外す方向を優先し、互換性のため残す場合もtemplate/supplemental text程度に限定し、comment URLやdigestのauthorityを持たせない旨を記述する)tests/agent-logs/(既存test配置。新規focused testをここに追加する)tests/test_hook_boundaries_doc.py(.claude/settings.json↔ docs drift 検出用の既存 SSOT 契約テスト。StopFailurehandler追加に伴い、意図的な追加のみを許容するallowlist調整が必要になった場合に限り変更する。未申告のhandler追加を引き続き検出できる設計を維持すること)docs/dev/hook-boundaries.md(tests/test_hook_boundaries_doc.pyが参照する hook配線ドキュメント。StopFailurehandler追加に対応するエントリを追加する場合のみ変更する).github/ci/python-test-plan.json(新規pytestファイル追加に伴うCI test-plan registration。新規追加した pytest ファイルのtarget登録が必要な場合のみ変更する。AC2動作検証testをnode-backed-hook-testsレーンへ移す場合は、同ファイルのdeselect[]/secondary_coverage.dedicated_lanesへ既存パターン(pytest_session_recording_fixed_location_cutover等)に倣って登録する).github/workflows/ci.yml(node-backed-hook-testsjob のみ、既存のpytest_session_recording_fixed_location_cutoverステップと同じパターンで、AC2動作検証test(tests/agent-logs/runtime-verification/test_hook_stop_failure_wiring.py、実 node child processを起動するためpython-test-coreの Python-only invariant=Issue 実装: Codex execpolicyを専用jobへ分離しpython-testのPython-only invariantを復元する #1760 と衝突する)の nodeid を明示的に追加登録する場合のみ変更する。他のjob・他の変更は行わない。編集前に.claude/skills/ci-test-performance/SKILL.mdを読むこと)
以下は実装時に必要性を評価するが、既存責務(読み取り専用参照・exported関数の再利用のみ)を超える変更が不要と判明した場合は変更しない:
scripts/agent-logs/finalize-agent-run.mjs(変更不要の想定。completion transactionの責務をここへ寄せない)scripts/agent-logs/post-agent-run-report.mjs/scripts/agent-logs/update-retro-index.mjs(exported関数をcoordinatorから呼び出すのみで、gapが見つからない限り本体は変更しない)
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- schema変更が既存の
agent_run_report/v1public-safe validatorとの整合を壊す場合は、実装を進めず設計を再検討する #1860(minimal harnessへの縮退方針)のowner reviewと衝突する新規enforcing機構が必要と判明した場合は、実装を止めてscopeを見直す- Codex CLI producer wiringが本Issueのスコープに実質的に必要と判明した場合は、スコープを拡張せず別Issueへ分離する
Required Skills
なし
Required Design References
- Issue 導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939(parent、delivery-rollup)
- human_context_comment(本Issueの敵対的レビュー、上記参照)
docs/dev/agent-run-report.md(agent_run_report/v1側の背景理解用、コマンド責務境界の記述箇所)docs/schemas/agent-session-manifest.schema.json/docs/schemas/agent-session-manifest.md(本Issueが変更するschemaとそのcompanion doc)docs/schemas/agent-run-report.schema.json(隣接schema、混同しないよう参照)docs/dev/agent-skill-boundaries.md(CHILD_MATERIALIZATION_PLAN_V2、child issueの親body更新ルール)- Claude Code hooks reference(Stop / StopFailure / SessionEnd / SubagentStop / PermissionDenied の現在の仕様)
Dependencies / Overlaps
- 親Issue 導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939(delivery-rollup parent)。本Issueは 導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 の「Child Issues」セクションの「Workstream 2」を materialize するものであり、parentの他Workstreamとは独立。
- Issue 導入: EntireCLI + Latitude の観測データを agent_run_report に接続し、GitHub 経由の ChatGPT レトロ動線を確立する #1153(EntireCLI + Latitude観測データ統合の別parent)とは隣接領域だが、#1153の「Remaining Parent Gaps」は明示的に「Latitude metadata keys / annotation taxonomy のSSOT化」等を本Issueのスコープ外としており、重複しない。導入: EntireCLI + Latitude の観測データを agent_run_report に接続し、GitHub 経由の ChatGPT レトロ動線を確立する #1153 の Goal(3 CLI capture capability verdict)と 導入: repo URL起点の日次retrospective worksetとagent completion artifact投稿を確立する #1939 の Goal(daily workset / completion transaction)は別物であり混同しない。
#1860(minimal harness縮退方針)と設計思想上の緊張関係があるため、実装時は新規enforcing機構を追加しない方針を厳守する。
Delivery Rule
1 Issue = 1 PR。#1939 parent bodyの「Child Issues」セクションのWorkstream 2行を、本Issue起票後に 未起票 から起票済みのissue参照へ更新する(親body更新は本Issueのdeliveryの一部ではなく、issue-refinement-loop / edit-issue skillの通常の child materialization手順に従う)。
Activity
squne121 commentedon Sep 4, 2026
結論
現状の #2489 は No-Go as-is です。
方向性自体は有用ですが、Issue contract と実際に取得できる runtime evidence が噛み合っていません。特に
stop_reasonを追加するだけでは、今回欲しい「Claude-GPT はなぜ途中停止が多いのか」を正確に測れず、むしろ 観測できない理由を producer が推測して埋める false data を作る危険があります。個人趣味開発としての優先順位なら、大きな completion control-plane は作らず、既存の upsert 群を薄く束ねる + terminal event を best-effort に記録するところまで縮めるのが適切です。
敵対的レビュー
Severity | Finding | 判定 -- | -- | -- P0 | stop_reason AC が現在の Claude Code hook では観測不能な事象まで要求している | 修正必須 P0 | #1939 Workstream 2 は Claude Code と Codex CLI を扱うのに、#2489 は実質 Claude Code / Claude-GPT に縮退している | 修正必須 P1 | Parent Goal Ref が #1939 ではなく #1153 の内容を誤転記している | 修正必須 P1 | retry / permission_interruption / human_clarification_request を stop reason と同一 enum に入れる設計が意味論的に崩れている | 修正推奨 P1 | runtime_lane の authoritative source が未定義で、現 producer から native / Claude-GPT を判別できない | 修正必須 P1 | completion transaction の owner が曖昧。finalize-agent-run.mjs 自体は transaction coordinator ではない | 修正必須 P1 | AC3 は「既存テストでカバー済みなら確認」で終われるため、partial success recovery の実証が弱い | 修正推奨 P2 | provider telemetry unavailable は既存実装ですでにかなり表現可能で、新実装を増やしすぎる恐れ | scope削減 P2 | runtime verification を漠然と「数回実運用後」へ defer しており、producer wiring の誤りをマージ前に捕まえにくい | 改善推奨P0-1: 現在の hook では AC1 の stop reason を作れない
現在
.claude/settings.jsonが session manifest producer に接続しているのはStop、SubagentStop、PostToolUseです。StopFailureやSessionEndは登録されていません。さらに現行 Claude Code 公式仕様では、
Stopは main agent が応答を終えたときに発火しますが、ユーザー interrupt で止まった場合には発火しません。API error の場合もStopではなくStopFailureが発火します。(Claude)したがって #2489 AC1 が要求する
normal_completion / runtime_failure / interrupt / timeout / permission_interruption / human_clarification_requestを現在の hook producer だけから決定論的に生成するのは不可能です。#2489 は schema を定義するだけでなく producer に値を「実際に埋める」ことを要求しているので、実装者は次のどちらかに追い込まれます。
観測できていない停止理由を actor name、transcript、終了時の状況から推測するか、ほぼ全 run を normal_completion にするかです。どちらも、Claude-GPT と native Claude Code の完走率比較という今回の用途には悪影響です。現在の hook wrapper 自体も、producer error を常に best-effort で無視する設計です。これは workflow friction の観点では良いのですが、completion completeness の authority にはできません。
ここは
stop_reasonという名前そのものを再検討した方がよいです。推奨する最小モデルは、例えば以下です。
重要なのは、
unavailableを正規値として認めることです。retryは stop reason ではなく、その後の action/transition です。permission_interruptionも tool permission event であって terminal result とは限りません。human_clarification_requestも質問した状態であって、run が終わった理由とは限りません。これらを1本の enum に押し込むと分析時の分母・分子が壊れます。P0-2: Parent AC4 の Codex CLI coverage が落ちている
#1939 の Workstream 2 は明示的に Claude Code と Codex CLI の adapter 差を扱い、normal completion / failure / interrupt / cancel / crash / hook timeout / network failure / retry を coverage として記録するよう要求しています。
しかし #2489 の具体的な producer変更は、
scripts/generate-session-manifest.mjs.claude/hooks/generate_session_manifest_from_hook.mjsruntime_lane: native / claude_gptが中心です。つまり Claude Code launcher の中の2 laneを区別するIssueに変質しており、Codex CLI adapterが消えています。
これは parent Workstream を materialize した child としては scope loss です。
ただし個人開発前提なら、ここで Codex 用の新しい大量 hook infrastructure を作る必要はありません。むしろ次のように明記するのがよいです。
これなら #1939 AC4 を失わず、#1860 の minimal harness 方針とも整合します。
P1-1: Parent Goal Ref が別Issueの内容
#2489 は Parent #1939 の Goal として、
を記載しています。
しかし #1939 の実際の Goal は、repository URL / date / timezone から daily workset と artifact coverage を導出して、GitHub connector 経由の retrospective を成立させることです。
3 CLI の capture capability verdict は #1153 の Goal です。
単なる文章ミスに見えますが、今回は scope authority に使っている箇所なので軽視しない方がいいです。実際、上記の Codex/Claude-GPT scope drift とも符合しています。
実装前に Parent Goal Ref を #1939 の実文へ直すべきです。
P1-2:
runtime_laneは良いが、値の出所がないruntime_lane追加自体は今回の目的にかなり有効です。現状 hook wrapper は actor を基本的に
claude-code-hookとし、SubAgentならclaude-code-subagent-*にしています。producer arguments に runtime lane はありません。つまり、producer側で
のように判定すると fragile です。
runtime_laneは launcherが明示的に producer に渡す provenance にしてください。例えば、程度で十分です。
Claude-GPT launcher が環境変数をすでに設定しているならそこから渡すのでも構いませんが、producer自身が infer しないことが重要です。
さらに
nativeという値だけでは何の native なのか曖昧なので、native_claude_codeの方が後から見て安全です。P1-3: completion transaction の責務が間違ったファイルに寄っている
#2489 は
scripts/agent-logs/finalize-agent-run.mjsを completion transaction の主要実装候補として挙げています。しかし現在の責務は明確に分離されています。
finalize-agent-run.mjsは report JSON を生成して atomic write するだけです。GitHub posting はしません。post-agent-run-report.mjsが validated run report の GitHub upsert を担当しています。repository docs も
agent-run:finalize= artifact generation、agent-run:post= run report upsert、context marker = 別 command、と明記しています。retro index も独立した
update-retro-index.mjsで upsert されています。context marker にも malformed-marker detection、ownership marker、digest、upsert系の既存基盤があります。
したがって、既存責務を1ファイルへ寄せるべきではありません。
趣味開発として最も安い transaction は、
を順番に呼び、結果だけ、
として返す薄い coordinator です。
DB、transaction log、ledger、two-phase commit は不要です。
途中で2番目が失敗しても、同じ command をもう一度全部実行するだけにします。各処理が既に upsert/idempotent だからです。
これは #1860 の「過剰な control-plane を増やさない」という owner decision にも合っています。#1860 は新しい graph policy、ledger、digest checker、enforcing hook を避け、live state / actual tests / CIを authority にする方針です。
P1-4: AC3 はもっと具体的にした方がよい
現状のAC3は、
なので、「関連テストはある」と確認するだけでも通り得ます。
completion transaction の価値を証明するなら、次の4ケースだけ固定してください。
初回実行 → 3 artifact が作成/更新される
同じ run を再実行 → comment 数が増えない
run report 投稿後、retro index で失敗 → retry で report を重複させず残りが完成する
malformed/ambiguous marker が既にある → 既存 policy に従って deterministic に blocked/repairされる
これだけで十分です。failure injection frameworkのようなものは不要です。
P2: provider telemetry unavailable はかなり既存実装で足りている
ここは #2489 の中でも最も実装を増やしすぎやすい部分です。
現行 report schema / adapter には
source_unavailableの扱いがすでにあり、テスト資産にも unavailable ケースがあります。したがってAC4はまず、
ことを focused test で証明すればよいです。
新しい fallback system は不要です。
Claude Code 現行仕様から見た最小の観測設計
Claude Code は現在、1 turn の終端に
StopまたはStopFailure、session 終端にSessionEndを提供しています。StopFailureは API error type も構造化されています。(Claude)一方で
Stopでは user interrupt を捕まえられません。SessionEnd の reason もclear / resume / logout / prompt_input_exit / other程度で、run-level crash taxonomyではありません。(Claude)なので、完全な stop taxonomy を hook だけで作ろうとしない方がいいです。
今回の目的に必要なのはむしろ、
という集計です。
これだけでも、
native vs Claude-GPT の terminal completion率
API failure率
completion artifact欠落率
human intervention有無
unknown/unresolved率
を比較できます。
特に unknown率を出すこと自体が重要な観測結果です。unknownを無理に permission / timeout / interrupt へ分類する必要はありません。
#2489 をどう直すか
私なら Issueは維持して scope を縮めて reframe します。別Issueへ捨てる必要はありません。
推奨する変更は、
stop_reasonを絶対的な terminal truth とする設計をやめ、runtime_lane:native_claude_code | claude_gpt | codex_cli | unknownterminal_event:stop | stop_failure | session_end | reconciliation | unavailablecompletion_outcome:completed | failed | interrupted | incomplete | unavailableprovider-specific reason は取得できた場合のみ保存
observation source を必須化
未観測を推測しない
という形です。
ただし schema をここまで増やしたくなければ、さらに削って、
の3フィールドでも今回の分析用途には十分です。
permission_interruptionやhuman_clarification_requestは既存human_interventionや別イベント側から後で集計すればよく、terminal taxonomyへ詰め込まない方がデータ品質が上がります。最終判定
REQUEST_CHANGES 相当です。
特にマージ前ではなく実装着手前に直したい blocker は3点です。
Parent Goal Ref の訂正、観測不能な stop_reason AC の再設計、Codex CLI coverage の扱いの明文化です。
そのうえで completion transaction は、既存3 upsertを再利用する「再実行可能な薄い coordinator」に限定するのが最も費用対効果が高いです。新規 ledger、専用state DB、enforcing hook、permission brokerは不要です。
なお #2489 には現時点で Issue comment はありません。 実装PRも
## 結論#2489および completion-transaction 関連の検索では特定できなかったため、今が contract を直す最も安いタイミングです。現状の #2489 は No-Go as-is です。
方向性自体は有用ですが、Issue contract と実際に取得できる runtime evidence が噛み合っていません。特に
stop_reasonを追加するだけでは、今回欲しい「Claude-GPT はなぜ途中停止が多いのか」を正確に測れず、むしろ 観測できない理由を producer が推測して埋める false data を作る危険があります。個人趣味開発としての優先順位なら、大きな completion control-plane は作らず、既存の upsert 群を薄く束ねる + terminal event を best-effort に記録するところまで縮めるのが適切です。
敵対的レビュー
stop_reasonAC が現在の Claude Code hook では観測不能な事象まで要求しているretry/permission_interruption/human_clarification_requestを stop reason と同一 enum に入れる設計が意味論的に崩れているruntime_laneの authoritative source が未定義で、現 producer から native / Claude-GPT を判別できないfinalize-agent-run.mjs自体は transaction coordinator ではないP0-1: 現在の hook では AC1 の stop reason を作れない
現在
.claude/settings.jsonが session manifest producer に接続しているのはStop、SubagentStop、PostToolUseです。StopFailureやSessionEndは登録されていません。さらに現行 Claude Code 公式仕様では、
Stopは main agent が応答を終えたときに発火しますが、ユーザー interrupt で止まった場合には発火しません。API error の場合もStopではなくStopFailureが発火します。(Claude)したがって #2489 AC1 が要求する
normal_completion / runtime_failure / interrupt / timeout / permission_interruption / human_clarification_requestを現在の hook producer だけから決定論的に生成するのは不可能です。#2489 は schema を定義するだけでなく producer に値を「実際に埋める」ことを要求しているので、実装者は次のどちらかに追い込まれます。
観測できていない停止理由を actor name、transcript、終了時の状況から推測するか、ほぼ全 run を normal_completion にするかです。どちらも、Claude-GPT と native Claude Code の完走率比較という今回の用途には悪影響です。現在の hook wrapper 自体も、producer error を常に best-effort で無視する設計です。これは workflow friction の観点では良いのですが、completion completeness の authority にはできません。
ここは
stop_reasonという名前そのものを再検討した方がよいです。推奨する最小モデルは、例えば以下です。
重要なのは、
unavailableを正規値として認めることです。retryは stop reason ではなく、その後の action/transition です。permission_interruptionも tool permission event であって terminal result とは限りません。human_clarification_requestも質問した状態であって、run が終わった理由とは限りません。これらを1本の enum に押し込むと分析時の分母・分子が壊れます。P0-2: Parent AC4 の Codex CLI coverage が落ちている
#1939 の Workstream 2 は明示的に Claude Code と Codex CLI の adapter 差を扱い、normal completion / failure / interrupt / cancel / crash / hook timeout / network failure / retry を coverage として記録するよう要求しています。
しかし #2489 の具体的な producer変更は、
scripts/generate-session-manifest.mjs.claude/hooks/generate_session_manifest_from_hook.mjsruntime_lane: native / claude_gptが中心です。つまり Claude Code launcher の中の2 laneを区別するIssueに変質しており、Codex CLI adapterが消えています。
これは parent Workstream を materialize した child としては scope loss です。
ただし個人開発前提なら、ここで Codex 用の新しい大量 hook infrastructure を作る必要はありません。むしろ次のように明記するのがよいです。
これなら #1939 AC4 を失わず、#1860 の minimal harness 方針とも整合します。
P1-1: Parent Goal Ref が別Issueの内容
#2489 は Parent #1939 の Goal として、
を記載しています。
しかし #1939 の実際の Goal は、repository URL / date / timezone から daily workset と artifact coverage を導出して、GitHub connector 経由の retrospective を成立させることです。
3 CLI の capture capability verdict は #1153 の Goal です。
単なる文章ミスに見えますが、今回は scope authority に使っている箇所なので軽視しない方がいいです。実際、上記の Codex/Claude-GPT scope drift とも符合しています。
実装前に Parent Goal Ref を #1939 の実文へ直すべきです。
P1-2:
runtime_laneは良いが、値の出所がないruntime_lane追加自体は今回の目的にかなり有効です。現状 hook wrapper は actor を基本的に
claude-code-hookとし、SubAgentならclaude-code-subagent-*にしています。producer arguments に runtime lane はありません。つまり、producer側で
のように判定すると fragile です。
runtime_laneは launcherが明示的に producer に渡す provenance にしてください。例えば、程度で十分です。
Claude-GPT launcher が環境変数をすでに設定しているならそこから渡すのでも構いませんが、producer自身が infer しないことが重要です。
さらに
nativeという値だけでは何の native なのか曖昧なので、native_claude_codeの方が後から見て安全です。P1-3: completion transaction の責務が間違ったファイルに寄っている
#2489 は
scripts/agent-logs/finalize-agent-run.mjsを completion transaction の主要実装候補として挙げています。しかし現在の責務は明確に分離されています。
finalize-agent-run.mjsは report JSON を生成して atomic write するだけです。GitHub posting はしません。post-agent-run-report.mjsが validated run report の GitHub upsert を担当しています。repository docs も
agent-run:finalize= artifact generation、agent-run:post= run report upsert、context marker = 別 command、と明記しています。retro index も独立した
update-retro-index.mjsで upsert されています。context marker にも malformed-marker detection、ownership marker、digest、upsert系の既存基盤があります。
したがって、既存責務を1ファイルへ寄せるべきではありません。
趣味開発として最も安い transaction は、
を順番に呼び、結果だけ、
{ "run_report": "unchanged|created|updated|failed", "retro_index": "unchanged|created|updated|failed", "context_marker": "unchanged|created|updated|failed" }として返す薄い coordinator です。
DB、transaction log、ledger、two-phase commit は不要です。
途中で2番目が失敗しても、同じ command をもう一度全部実行するだけにします。各処理が既に upsert/idempotent だからです。
これは #1860 の「過剰な control-plane を増やさない」という owner decision にも合っています。#1860 は新しい graph policy、ledger、digest checker、enforcing hook を避け、live state / actual tests / CIを authority にする方針です。
P1-4: AC3 はもっと具体的にした方がよい
現状のAC3は、
なので、「関連テストはある」と確認するだけでも通り得ます。
completion transaction の価値を証明するなら、次の4ケースだけ固定してください。
これだけで十分です。failure injection frameworkのようなものは不要です。
P2: provider telemetry unavailable はかなり既存実装で足りている
ここは #2489 の中でも最も実装を増やしすぎやすい部分です。
現行 report schema / adapter には
source_unavailableの扱いがすでにあり、テスト資産にも unavailable ケースがあります。したがってAC4はまず、
ことを focused test で証明すればよいです。
新しい fallback system は不要です。
Claude Code 現行仕様から見た最小の観測設計
Claude Code は現在、1 turn の終端に
StopまたはStopFailure、session 終端にSessionEndを提供しています。StopFailureは API error type も構造化されています。([Claude]1)一方で
Stopでは user interrupt を捕まえられません。SessionEnd の reason もclear / resume / logout / prompt_input_exit / other程度で、run-level crash taxonomyではありません。(Claude)なので、完全な stop taxonomy を hook だけで作ろうとしない方がいいです。
今回の目的に必要なのはむしろ、
という集計です。
これだけでも、
を比較できます。
特に unknown率を出すこと自体が重要な観測結果です。unknownを無理に permission / timeout / interrupt へ分類する必要はありません。
#2489 をどう直すか
私なら Issueは維持して scope を縮めて reframe します。別Issueへ捨てる必要はありません。
推奨する変更は、
stop_reasonを絶対的な terminal truth とする設計をやめ、runtime_lane:native_claude_code | claude_gpt | codex_cli | unknownterminal_event:stop | stop_failure | session_end | reconciliation | unavailablecompletion_outcome:completed | failed | interrupted | incomplete | unavailableという形です。
ただし schema をここまで増やしたくなければ、さらに削って、
の3フィールドでも今回の分析用途には十分です。
permission_interruptionやhuman_clarification_requestは既存human_interventionや別イベント側から後で集計すればよく、terminal taxonomyへ詰め込まない方がデータ品質が上がります。最終判定
REQUEST_CHANGES 相当です。
特にマージ前ではなく実装着手前に直したい blocker は3点です。
Parent Goal Ref の訂正、観測不能な stop_reason AC の再設計、Codex CLI coverage の扱いの明文化です。
そのうえで completion transaction は、既存3 upsertを再利用する「再実行可能な薄い coordinator」に限定するのが最も費用対効果が高いです。新規 ledger、専用state DB、enforcing hook、permission brokerは不要です。
なお #2489 には現時点で Issue comment はありません。 実装PRも
#2489および completion-transaction 関連の検索では特定できなかったため、今が contract を直す最も安いタイミングです。squne121 commentedon Sep 4, 2026
対象コメントを前提にすると、いきなり現行 #2489 を
impl-review-loopに渡すのではなく、同じ Claude Code セッション内で Issue contract を最小修正 → current-run contract review を通過 →impl-review-loopへ連続遷移させるのが適切です。対象コメント自身がREQUEST_CHANGES相当で、Parent Goal Ref、観測不能なstop_reason、Codex CLI coverage の3点を実装着手前 blocker としています。推奨アクションは以下です。
stop_reasonを「推測された真実」にしない。現行.claude/settings.jsonはStop/SubagentStop/PostToolUseだけを session-manifest producer に接続しています。 Claude Code 公式仕様でもStopは user interrupt では発火せず、API error はStopFailureへ流れます。([Claude]1)runtime_lane + completion_outcome + completion_sourceを最低限にし、必要なら観測できたterminal_event/ provider reason を追加する形がよいです。runtime_laneはactor.name等から推定せず、launcher/provenance からnative_claude_code | claude_gpt | codex_cli | unknownを明示的に渡す。Codex CLI は新しい重い hook を作らず、観測不能な path はunavailable/incompleteとして coverage に残す。finalize-agent-run.mjsに責務を集めない。同ファイルは現状 JSON の atomic write までで、GitHub upsert はpost-agent-run-report.mjsが担当しています。 既存の run-report / retro-index / context-marker upsert を順番に呼べる薄い再実行可能 coordinatorだけにする。新規 ledger、state DB、permission broker、enforcing hook は作らない。これは 導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860 の minimal harness 方針とも一致します。impl-review-loopは現在、implementation-worker → test-runner → pr-reviewer の SubAgent ループを持ち、APPROVE + live mergeability まで自律反復する設計です。 Claude Code は現在 background SubAgent がデフォルトになり得るため、「spawnしただけで次へ行かず、完了通知まで待つ」を明示しておく価値があります。公式にも background SubAgent の結果は completion notification 後に受け取る仕様です。([Claude]2)gh pr merge *まで allow 済みなので、今回のプロンプトでは merge / auto-merge を明示禁止し、merge-ready で止めるのが重要です。以下をそのまま、Auto mode の対話的 Claude Code の root/main thread に渡すのを推奨します。
対象リポジトリ:
https://github.com/squne121/loop-protocol
対象 Issue:
#2489
今回の human context:
#2489 (comment)
目的:
Issue #2489 について、上記 human context の敵対的レビューを反映して Issue contract を必要最小限修正したうえで、impl-review-loop を実行し、実装・検証・PRレビュー・レビュー指摘修正・CI確認を自律的に反復してください。
人間への通常の承認要求は行わず、PR が current-head で review APPROVE、required verification/CI が通過し、merge conflict がなく、マージ直前の状態になるまで進めてください。
ただし実際の merge は行わないでください。
gh pr merge、auto-merge の有効化、その他 merge を成立させる操作は禁止です。最終状態は merge-ready / draft_pr_ready 相当で停止してください。
0. 基本方針
これは個人趣味開発です。
品質・実用性・単純さを優先してください。
security / harness / control-plane を増やすこと自体を目的にしないでください。
既存の live Issue / PR、実 diff、実 test、current-head CI、独立 review を authority としてください。
以下を新設しないでください。
既存の upsert / validator / producer / poster を最大限再利用してください。
routine な実装判断、ファイル編集、test実行、commit、push、Draft PR作成、PR更新、レビュー対応について私への確認は不要です。
AskUserQuestion は、repository、Issue、human context、既存コード、test、公式仕様から合理的に決定できる事項には使わないでください。
複数案がある場合は、最小変更で既存設計と整合する案を自分で選んで進めてください。
Auto mode の classifier が routine operation を拒否した場合、classifier を迂回しようとせず、より低リスクな等価操作、既存 allow 済み経路、または設計変更で継続してください。
1. 最初に live state を再取得する
作業開始時点の main を authority としてください。
最低限、以下を再取得してください。
.claude/skills/impl-review-loop/**.claude/settings.json.codex/hooks.jsondocs/schemas/agent-session-manifest.schema.jsondocs/schemas/agent-session-manifest.mddocs/schemas/agent-run-report.schema.jsonscripts/generate-session-manifest.mjs.claude/hooks/generate_session_manifest_from_hook.mjsscripts/agent-logs/finalize-agent-run.mjsscripts/agent-logs/post-agent-run-report.mjsscripts/agent-logs/update-retro-index.mjsscripts/agent-logs/lib/chatgpt-retro-context-marker-helper.mjstests/agent-logs/**過去の artifact / snapshot / digest が live state と食い違う場合は live state を優先してください。
2. SubAgent を使って contract repair を独立確認する
実装前に read-only SubAgent を1つ以上使い、次を独立確認させてください。
A. #2489 human context の blocker と #1939 AC4-AC6 の対応
B. 現在の Claude Code / Codex CLI observation path から実際に観測可能な terminal evidence
C. 既存 completion artifact upsert の責務分離
D. 現行テストで既にカバーされている idempotency / unavailable ケース
E. #1860 minimal harness 方針との衝突有無
必要なら公式 Claude Code documentation も確認してください。
特に Stop / StopFailure / SessionEnd / SubagentStop / PermissionDenied の現在の仕様を authoritative source で確認してください。
SubAgent を起動しただけで次へ進まないでください。
SubAgent が foreground の場合は終了するまで待ってください。
background で起動した場合も completion notification / task status が terminal になるまで待ってください。
全 SubAgent の結果を受け取る前に Issue mutation や implementation を開始しないでください。
3. #2489 contract を先に修正する
human context #5539261190 を human_context_comment として明示的に扱ってください。
現状の #2489 をそのまま実装開始しないでください。
root/main thread が Issue mutation を所有し、human context と live readback に基づき #2489 本文を必要最小限修正してください。
最低限、以下を解消してください。
3.1 Parent Goal Ref
#1939 の実際の Goal / Workstream 2 に合わせて訂正すること。
#1153 の capture capability goal を #1939 の Goal として扱わないこと。
3.2 stop_reason の再設計
観測不能な terminal reason を producer が推測する設計を廃止してください。
最低限必要な分析軸は次です。
必要性が実装・既存schemaから明確なら、追加で
を持たせても構いません。
推奨 enum の方向性:
runtime_lane:
completion_outcome:
completion_source:
terminal_event を採用する場合:
重要:
未観測状態を normal_completion / interrupt / permission / timeout 等へ推測分類しないでください。
unknown / unavailable / incomplete を正常な観測結果として許容してください。
retry は terminal reason ではなく transition/action として扱ってください。
permission interruption や human clarification request は terminal outcome と混同せず、既存 human_intervention や event evidence から分析可能にしてください。
3.3 runtime_lane provenance
runtime_lane を actor.name、文字列パターン、transcript内容から infer しないでください。
launcher、explicit CLI argument、既存の明示的 environment/provenance のいずれかから producer へ渡してください。
値を取得できない場合は
unknownとしてください。false precision を避けてください。
3.4 Codex CLI coverage
#1939 Workstream 2 の Claude Code / Codex CLI adapter coverage を維持してください。
ただし Codex CLI のためだけに重い新規 hook infrastructure を作らないでください。
既存観測経路から terminal evidence が得られる場合は materialize。
得られない path は
unavailable/incompleteとして coverage に残してください。3.5 completion transaction
finalize-agent-run.mjsに posting transaction 全体を押し込まないでください。現在の責務分離を維持してください。
必要なら、これらを順番に呼び出す薄い coordinator を1つ追加してください。
概念的には:
completion coordinator
-> run-report upsert
-> retro-index upsert
-> context-marker upsert
各 operation の結果を
created / updated / unchanged / failed
程度で返せれば十分です。
partial failure 時は独自 transaction log で復旧するのではなく、既存 operation の idempotency を利用し、同じ completion command を再実行して convergence させてください。
3.6 Allowed Paths
human context によって責務の所在が判明したため、Allowed Paths も live implementation に合わせて修正してください。
少なくとも必要性を評価する対象:
.claude/settings.json.claude/hooks/generate_session_manifest_from_hook.mjsdocs/schemas/agent-session-manifest.schema.jsondocs/schemas/agent-session-manifest.mdscripts/generate-session-manifest.mjsscripts/agent-logs/finalize-agent-run.mjsscripts/agent-logs/post-agent-run-report.mjsscripts/agent-logs/update-retro-index.mjsscripts/agent-logs/lib/chatgpt-retro-context-marker-helper.mjsscripts/agent-logs/配下の薄い coordinatortests/agent-logs/**実際に変更不要なファイルまで変更しないでください。
3.7 Acceptance Criteria
AC は「既存テストを確認した」で終了できない形にしてください。
completion transaction について最低限、次を決定論的に検証してください。
provider telemetry unavailable については、
ことを focused test で証明してください。
producer wiring についても fixture/test で merge 前に確認してください。
実運用を数回待たなければ何も検証できない contract にしないでください。
4. contract repair 後に current-run contract review を通す
Issue body 更新後、古い GO / snapshot を authority にしないでください。
root-owned synchronous entry policy に従い、current live body に対して current-run
issue-contract-reviewを実行してください。body drift があれば同一 control flow 内で fresh review を取り直してください。
GO にならない場合でも、単なる修正可能な contract defect を理由に私へ承認を求めないでください。
human context と live repository から修正可能なら root/main thread で修正して再レビューしてください。
5. GO 後、そのまま impl-review-loop #2489 を開始する
current-run contract review が GO になったら、同一 continuous root/main control flow のまま
impl-review-loopを開始してください。入力概念:
issue_number: 2489
human_context_comment_urls:
max_iterations: 6
古い contract snapshot URL を authorization として使用しないでください。
impl-review-loopの現在の root-owned synchronous entry transition を尊重してください。6. SubAgent completion を必ず待つ
impl-review-loop 内では既存設計どおり SubAgent を使用してください。
最低限:
各 dependent step で、SubAgent の完了を待たずに次へ進んではいけません。
implementation-worker 完了
→ 結果と current HEAD を確認
→ test-runner 起動
→ test-runner 完了
→ current-head verification を確認
→ pr-reviewer 起動
→ pr-reviewer 完了
→ LOOP_VERDICT を route
という同期境界を守ってください。
background SubAgent が使われた場合も、
「起動済み」「running」「async_launched」を完了扱いしないでください。
completion notification / terminal task state / final report を受け取るまで待ってください。
失敗した SubAgent は、原因が一時的 API error 等で再実行可能なら resume/retry してください。
途中出力を completed result と誤認しないでください。
7. 実装・レビュー修正ループ
implementation-worker:
Closes #2489を含めるtest-runner:
を実行する
pr-reviewer:
を基準に独立レビューする
REQUEST_CHANGES の場合:
stale-head review を承認扱いしないでください。
BEHIND なら既存 impl-review-loop policy に従って branch update を行い、その後 verification + review を再実行してください。
8. 外部仕様の確認
Claude Code の hook semantics に依存する実装では、記憶で仕様を決めず、現在の公式 documentation を確認してください。
少なくとも確認すること:
ただし外部仕様調査を理由に過剰な abstraction を追加しないでください。
公式仕様から取得できない terminal reason は
unknown/unavailableとしてください。9. human escalation を極小化する
以下は人間停止理由にしないでください。
human_review_required: true自己申告だけこれらは自律的に修正・再試行・再評価してください。
本当に継続不能な場合だけ停止してください。
例:
秘密情報を表示・ログ・Issue/PRへ投稿しないでください。
10. merge は絶対に行わない
この作業のゴールは「マージ直前」です。
以下は禁止:
gh pr mergeCloses #2489を PR body に入れ、Issue close は merge に委ねてください。APPROVE かつ current-head verification / required CI が pass し、live mergeability が merge-ready になったところで終了してください。
11. 最終報告
最終回答を返す前に、起動した全 SubAgent が completed / failed / explicitly stopped のいずれかの terminal state になっていることを確認してください。
running の SubAgent を残したまま最終回答しないでください。
最後に簡潔に以下を報告してください。
PR が merge-ready なら、そこで停止してください。
私への追加承認要求や「次に何をしますか?」は不要です。
この形なら、対象コメントによる contract blocker の解消も同一セッションで自動化し、その後は既存
impl-review-loopの実装→独立検証→PRレビュー循環を使い切る構成になります。特に background SubAgent の完了待ちとgh pr merge禁止を明文化している点が、現行 Claude Code Auto mode では重要です。squne121 commentedon Sep 4, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
squne121 commentedon Sep 4, 2026
implement-issue: 実装完了 (2026-09-04T11:57:20Z)
.claude/worktrees/issue-2489-completion-transaction-runtime-laneworktree-issue-2489-completion-transaction-runtime-lanedocs/dev/hook-boundaries.mdと.github/ci/python-test-plan.jsonは Allowed Paths 外だが、既存 SSOT 契約テスト(tests/test_hook_boundaries_doc.py の settings.json drift 検出、CI の uncovered_changed_test_files gate)との整合のため機械的な最小追従を行った。詳細は PR 本文の Scope Delta セクション参照。fix: TestBaseHeadHookTopologyDelta の StopFailure handler 追加を allowlist 化
squne121 commentedon Sep 4, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
fix: harden test_hook_stop_failure_wiring.py against CI-only transien…
fix: root-cause CI failure as ajv/ajv-formats absence in python-test-…
squne121 commentedon Sep 4, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
fix: wire AC2 runtime-verification test into node-backed-hook-tests C…
fix: drop test_hook_stop_failure_wiring.py from python-test-core targ…
squne121 commentedon Sep 4, 2026
Human Context Bridge(issue-refinement-loop anchor 用)
本コメントは PR #2496 上の OWNER レビュー #2496 (comment) (REQUEST_CHANGES)を、issue-refinement-loop の
--anchor-comment-urlが受理する canonicalissues/<N>#issuecomment-<M>形式へブリッジするために、root/main thread が機械的に投稿するものです(PR comment URL はこの正規表現の対象外のため)。元レビューの要旨(本文全文は上記 PR コメントを参照。root/main が repository facts と突き合わせて正規化する前段の生データとして扱う)
判定: REQUEST_CHANGES
Stop/StopFailurehook を session/run のcompletion_outcome/completion_sourceとして記録している設計が、Claude Code upstream 仕様(Stop/StopFailureは turn-level event、SessionEndが session-level)と一致しない。現在 Issue 実装: #1939 Workstream 2 — completion transaction and reconciliation(stop reason taxonomy / runtime lane識別) #2489 AC2 が要求するStop → completed/StopFailure → failedの動作検証 VC はこの誤った意味論を literal に固定しており、契約自体の修正が必要。scripts/agent-logs/complete-agent-run.mjsの completion transaction coordinator が、upsertChatgptRetroContextCommentへ渡す context payload をpostAgentRunReport()/updateRetroIndex()の実際の戻り値(comment_url・digest)ではなく事前生成済み Markdown ファイルからそのまま構築しており、partial failure 後の retry で既存CHATGPT_RETRO_CONTEXT_V1resolver がresolvedへ収束しない。StopFailureの structured error type(upstream taxonomy)を保存していない。completion_outcome/completion_sourceの pair constraint(JSON SchemadependentRequired相当)が未設定。推奨技術判断(元コメントより):
Stop/StopFailureから rootcompletion_outcomeを設定しない。run/session completion は launcher process exit または後段 reconciliation evidence からのみ設定する。hook_event.event_typeは evidence として保持する。新規turn_outcome等は最小変更で目的を達成できるなら追加しない。StopFailure.errorは既存hook_eventに optionalerror_typeとして保存する案を優先し、upstream error taxonomy の値を扱い、未知値はunknownへ正規化する。completion_outcome/completion_sourceにdependentRequiredの pair constraint を検討する(新規 runtime guard は追加しない)。この矛盾を残したまま Issue #2489 の現行 AC2 / VC を literal に実装しても、正しい実装が誤った VC に fail するため収束しません。以降の refinement は本コメントと上記元 PR コメントの両方を参照し、live repository facts / upstream Claude Code hooks 仕様と突き合わせて Issue 本文を再整合します。
fix: #2489 fix_delta iteration 4 — Stop/StopFailureをturn-level eviden…
squne121 commentedon Sep 4, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
fix: hook-boundaries.mdのStopFailure notesがroot completion_outcome/sou…
feat: agent_session_manifest/v1 に runtime_lane/completion_outcome/com…