Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "runtime smoke の structured Claude run が lifecycle verdict で失敗した場合に、lifecycle attribution に必要な raw event だけを bounded かつ opt-in で保全し、次回の失敗で証跡を失わない"
change_kind: code
dedupe_key: "follow-up:squne121/loop-protocol:issues/2953:lifecycle-raw-evidence-on-failure"Parent Issue
なし(単独改善)
Parent Goal Ref
- Origin: 調査: runtime smoke の duplicate_completions が生成された channel を raw event 証跡付きで特定し最小修正の ownership を確定する #2953 の AC3(b) が求める follow-up ownership(Refs 調査: runtime smoke の duplicate_completions が生成された channel を raw event 証跡付きで特定し最小修正の ownership を確定する #2953、Closes ではない)。
- Goal: 実装: runtime smoke の SubAgent causal evidence fixture を pr-reviewer persona 非依存の child に是正し 2.1.289 で hook_id_correlated を成立させる #2941 / PR fix: runtime smoke fixture の child 起動先を general-purpose に是正し 2.1.289 で hook_id_correlated を成立させる (#2941) #2946 で観測された
multi_child_lifecycleのduplicate_completionsのような lifecycle failure が次に起きたとき、どの channel の raw event が原因かを事後に特定できるようにする。 - Desired Destination: N/A(単独改善 Issue)。
Current Validated Scope
#2953 の OWNER human-context review(https://github.com/squne121/loop-protocol/issues/2953#issuecomment-6004641038)と #2953 本文 AC3(b) を根拠とする。
- 事象: 実装: runtime smoke の SubAgent causal evidence fixture を pr-reviewer persona 非依存の child に是正し 2.1.289 で hook_id_correlated を成立させる #2941 / PR fix: runtime smoke fixture の child 起動先を general-purpose に是正し 2.1.289 で hook_id_correlated を成立させる (#2941) #2946 の単発 FAIL(run_id
5ce699c75585、incident head6736a926b2c93259976aace06d437d635b7d1bd3)でmulti_child_lifecycleがduplicate_completions=['a8bcdb5faaae506a2']を報告し、subagent_causal_evidence.agent_id=None、native_event_countは 55(通常 47〜49)だった。3 回の clean rerun では再現しなかった。 - 欠落:
scripts/agent-ops/run_worktree_agent_runtime_smoke.pyが永続化するのはsummary.mdと任意の--evidence-json(summary 由来の field)だけであり、どの channel / raw event が重複を生んだかを事後に判定できない。 - 再利用できる既存 event field:
extract_claude_hook_lifecycle_events()が返すhook_event/stream_index/agent_id/agent_type/agent_transcript_path/session_id/prompt_id/stop_hook_active/contradictory、userevent のtool_use_resultの agentId / status、extract_claude_task_notification_completions()が扱う task-notification の completion block、および既存のsettings_provenance.digest_sha256。 - 関連 Issue(吸収しない): 実装: worktree-agent-runtime-smoke に generic hook-chain evidence capability を追加する #2663(closed)は handler-level の hook-chain evidence であり failure 時の raw lifecycle 保全ではない。実装: claude-gpt adapter の runtime smoke が launcher の解決した underlying Claude Code binary の version を runtime_version に記録するようにする #2954 は
runtime_versionのみ、実装: runtime smoke の expected_markers_missing が prompt echo を child marker と誤認する false-green を除去する #2944 は prompt-echo の false-green のみを所有する。 - dedupe search(2026-10-06、open / closed): dedupe_key、
duplicate_completions、lifecycle raw evidence、stop_hook_active、raw lifecycle eventで検索し、本件を所有する open Issue は存在しない。
Remaining Parent Gaps
duplicate_completionsの根本原因の特定と修正は 調査: runtime smoke の duplicate_completions が生成された channel を raw event 証跡付きで特定し最小修正の ownership を確定する #2953 の調査結果に従う別 Issue で扱い、本 Issue は所有しない。- 実装: runtime smoke の SubAgent causal evidence fixture を pr-reviewer persona 非依存の child に是正し 2.1.289 で hook_id_correlated を成立させる #2941 / PR fix: runtime smoke fixture の child 起動先を general-purpose に是正し 2.1.289 で hook_id_correlated を成立させる (#2941) #2946 は、その原因を解消する修正を取り込んだ新しい PR head ができるまで blocked のままである。本 Issue はそれを unblock しない。
- raw の重複 task-notification が current classifier で dedupe されることを固定する regression test は follow-up 候補であり、本 Issue では実装しない。
Outcome
scripts/agent-ops/run_worktree_agent_runtime_smoke.py に opt-in の --lifecycle-failure-evidence-json <path> を追加し、structured Claude run の lifecycle verdict が失敗した場合(multi_child_lifecycle が verified False、duplicate_completions が非空、または subagent_causal_evidence が no_evidence)に限り、上記の許可リストに載った raw event と settings_provenance.digest_sha256 だけを、run の output dir 配下の worktree-local な JSON として新規作成する状態にする。assistant message 本文・prompt・secret・無関係な transcript は書き出さず、verdict と exit code は変わらない。この挙動は fake-claude stream を使う新規 test scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_lifecycle_failure_evidence.py で固定される。
Runtime Verification Applicability
decision: immediate
reason: 変更対象 scripts/agent-ops/** と .claude/skills/**/SKILL.md は docs/dev/extension-surface-runtime-policy.yaml の hard trigger(subagent-lifecycle-start-stop-delegation-fallback / skill-invocation-procedure-or-contract-change)に一致し、最も制約の強い default_decision が immediate である。runner に opt-in flag を追加した後も、実 Claude Code の structured run が従来どおり成立し(flag を指定した成功 lifecycle の run が exit 0 で完了し、evidence file を作らない)、SubagentStart / SubagentStop の causal evidence が実 runtime で current run に束縛されて成立することは、fake-claude stream の hermetic test だけでは証明できないため、実 run を AC8 で検証する。lifecycle failure 時の evidence の中身は、failure の再現が非決定的であり(#2941 の incident は 3 回の rerun で再現しなかった)実 run を条件にできないため、引き続き AC1〜AC6 の fake-claude test で固定する。
applicable_acs: [AC8]
execution_environment: 現在の Claude Code session と repository の scripts/agent-ops/run_worktree_agent_runtime_smoke.py(claude 実行ファイルが PATH 上にあること、uv が利用可能であること)。live smoke は SubAgent が text の marker を 1 行返すだけの無害な fixture prompt を使う。mutation・外部 code 実行・permission 緩和・credential 利用は行わない。--output-dir は排他的に新規作成されるため、再実行時は worktree-local の uncommitted な artifacts/runtime-smoke/lifecycle-failure-evidence-optin だけを事前に削除する。
skip_conditions: claude 実行ファイルまたは uv が利用不能な場合は、runner / VC は exit 77 と stdout 先頭 SKIP: で SKIP を宣言する(docs/dev/runtime-verification-policy.md の SKIP 規約に従う)。SKIP は PASS ではなく Stop Condition として扱う。
fallback_policy: pytest の PASS・fake claude・runner の SKIP を AC8 の PASS として扱わない。実 run の lifecycle verdict が失敗して evidence file が作られた場合は AC8 を PASS にせず、その file の allowlist 内容を failure の証跡として保全して報告する。
artifact_requirements: AC8 は worktree-local の artifacts/runtime-smoke/lifecycle-failure-evidence-optin/(main へ commit しない)配下の runner evidence(summary.md)を証跡とする。新しい schema・receipt・publisher は追加しない。
runtime_assertion_bindings:
- profile: skill-invocation-runtime-smoke
assertion: output_contract_schema_fields_present
disposition: not_applicable
reason: 本 Issue の SKILL.md 変更は opt-in flag の使い方の記載だけであり、いずれの Skill の output contract schema の field も追加・変更しない。新しい failure evidence JSON は schema family ではなく、diagnostic 用の opt-in file である。 - profile: skill-invocation-runtime-smoke
assertion: procedure_steps_executed_in_declared_order
disposition: not_applicable
reason: 本 Issue の SKILL.md 変更は flag の使い方の記載だけであり、いずれの Skill の Procedure step の追加・削除・並べ替えも行わない。 - profile: subagent-lifecycle-causal-evidence-smoke
assertion: subagent_start_stop_causal_evidence_correlated
ac: AC8
disposition: dispositive
In Scope
scripts/agent-ops/run_worktree_agent_runtime_smoke.pyへの opt-in flag--lifecycle-failure-evidence-json <path>の追加。未指定時は何も保存せず、既存 caller の挙動は変わらない。- lifecycle verdict が失敗した run でのみ、次の許可リストの項目を bounded に(件数に上限を設けて)保存する。
- SubagentStart / SubagentStop の hook event の既存 field(
hook_event/stream_index/agent_id/agent_type/agent_transcript_pathの有無 /session_id/prompt_id/stop_hook_active/contradictory)。last_assistant_messageは保存しない。 userevent のtool_use_resultの agentId / status。- task-notification の completion block から得られる agent id と status。本文は保存しない。
- 既存の
settings_provenance.digest_sha256の参照。
- SubagentStart / SubagentStop の hook event の既存 field(
- 出力先は run の
--output-dir配下の worktree-local path に限定し、既存 file は上書きしない(排他的に新規作成し、既存の場合は上書きせず non-fatal な警告だけを出す)。 scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_lifecycle_failure_evidence.py(新規)への fake-claude stream test。scripts/agent-ops/tests/はすでに.github/ci/python-test-plan.jsonの target に含まれているため、plan への追加は不要の見込みである(実装時に確認し、不要なら変更しない)。.claude/skills/worktree-agent-runtime-smoke/SKILL.mdへの opt-in flag の使い方の記載。- 同じ runner file を 実装: claude-gpt adapter の runtime smoke が launcher の解決した underlying Claude Code binary の version を runtime_version に記録するようにする #2954 / 実装: runtime smoke の expected_markers_missing が prompt echo を child marker と誤認する false-green を除去する #2944 も触る。本 Issue は別関数・別 flag の範囲に限定し、競合は後から merge する側が rebase して解消する(scope rollup として認識するのみで吸収しない)。
Out of Scope
runtime_versionの記録(実装: claude-gpt adapter の runtime smoke が launcher の解決した underlying Claude Code binary の version を runtime_version に記録するようにする #2954)、prompt-echo の false-green(実装: runtime smoke の expected_markers_missing が prompt echo を child marker と誤認する false-green を除去する #2944)。duplicate_completionsの根本原因の修正。- 実装: runtime smoke の SubAgent causal evidence fixture を pr-reviewer persona 非依存の child に是正し 2.1.289 で hook_id_correlated を成立させる #2941 / PR fix: runtime smoke fixture の child 起動先を general-purpose に是正し 2.1.289 で hook_id_correlated を成立させる (#2941) #2946 の変更、および 実装: runtime smoke の SubAgent causal evidence fixture を pr-reviewer persona 非依存の child に是正し 2.1.289 で hook_id_correlated を成立させる #2941 の unblock(新しい PR head ができるまで blocked のまま)。
- 新しい schema family、wrapper、daemon、lock、approval layer、attestation framework、汎用の trace / observability platform の追加。
- verdict と exit code の semantics の変更。
- task-notification の dedupe の regression test の追加(follow-up 候補として記録するに留める)。
- diagnostics の再実行。
Acceptance Criteria
- AC1: fake-claude の stream で lifecycle が失敗し(重複した SubagentStop を注入)、
--lifecycle-failure-evidence-jsonを指定した run で、出力 JSON に許可リストの event(hook event の既存 field、tool_use_resultの agentId / status、task-notification completion の agent id)とsettings_provenance.digest_sha256が保存される。 - AC2: AC1 の出力 JSON に、assistant message 本文、prompt 文字列、
last_assistant_message、secret / credential 風の文字列(stream に混入させた sentinel)、無関係な transcript 内容が含まれない。 - AC3: lifecycle が成功した stream では、flag を指定しても file が作られない。flag を指定しない場合は、失敗した stream でも何も保存されない。
- AC4: flag の有無にかかわらず、verdict と exit code と
summary.mdの既存 field が変わらない(同一 stream を flag あり / なしで走らせて比較する)。 - AC5: 出力先が既存 file の場合は上書きせず内容が不変であり、verdict と exit code は変わらない。出力 path が
--output-dir配下でない場合は拒否される。 - AC6: 保存する event 数に上限があり、上限を超える大量の event を持つ stream でも出力が bounded である。
- AC7:
.claude/skills/worktree-agent-runtime-smoke/SKILL.mdに新 flag が記載されている。 - AC8: runner に opt-in flag を追加した後も、無害な fixture prompt に対する実 runtime の structured run で
--lifecycle-failure-evidence-jsonを指定した成功 lifecycle の run が exit 0 で完了し、SubagentStart / SubagentStop の causal evidence が current run に束縛されて成立し、evidence file は作られない。
Verification Commands
# AC1
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_lifecycle_failure_evidence.py -k allowlisted_events_preserved_on_lifecycle_failure -q
# AC2
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_lifecycle_failure_evidence.py -k excludes_message_prompt_and_secret_content -q
# AC3
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_lifecycle_failure_evidence.py -k nothing_preserved_on_pass_or_without_flag -q
# AC4
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_lifecycle_failure_evidence.py -k verdict_and_exit_code_unchanged -q
# AC5
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_lifecycle_failure_evidence.py -k existing_file_not_overwritten_and_path_confined -q
# AC6
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_lifecycle_failure_evidence.py -k output_is_bounded -q
# AC7
# baseline-expect: fail
$ rg -n -- "--lifecycle-failure-evidence-json" .claude/skills/worktree-agent-runtime-smoke/SKILL.md
# AC8
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode structured --worktree "$PWD" --prompt-file scripts/agent-ops/tests/fixtures/runtime_vc_lifecycle_smoke_prompt.md --output-dir artifacts/runtime-smoke/lifecycle-failure-evidence-optin --timeout-seconds 300 --max-turns 6 --agent-type pr-reviewer --expect-marker-source subagent --expect-marker "RUNTIME_VC_LIFECYCLE_SMOKE_OK" --require-subagent-causal-evidence --require-min-subagents 1 --require-clean-postcondition --lifecycle-failure-evidence-json artifacts/runtime-smoke/lifecycle-failure-evidence-optin/lifecycle-failure-evidence.json
# preflight-scope: runtime_only
$ test ! -e artifacts/runtime-smoke/lifecycle-failure-evidence-optin/lifecycle-failure-evidence.json
# regression (既存 runner の挙動不変)
# baseline-expect: pass
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -qAllowed Paths
- scripts/agent-ops/run_worktree_agent_runtime_smoke.py
- scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_lifecycle_failure_evidence.py
- .claude/skills/worktree-agent-runtime-smoke/SKILL.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合(
.github/ci/python-test-plan.jsonへの登録が必要と判明した場合を含む) - In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合(verdict / exit code / summary の既存 key の変更が必要になった場合を含む)
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 許可リスト外の内容(message 本文・prompt・secret)を保存しないと lifecycle attribution が成立しないと判明した場合(実装を止めて報告する)
Required Skills
なし
Required Design References
- docs/dev/runtime-verification-policy.md
- .claude/skills/worktree-agent-runtime-smoke/SKILL.md
Delivery Rule
1 Issue = 1 PR。Draft PR を既定とする。Refs #2953(Closes ではない)。実装: runtime smoke の SubAgent causal evidence fixture を pr-reviewer persona 非依存の child に是正し 2.1.289 で hook_id_correlated を成立させる #2941 / PR fix: runtime smoke fixture の child 起動先を general-purpose に是正し 2.1.289 で hook_id_correlated を成立させる (#2941) #2946 は新しい PR head ができるまで blocked のままであり、本 Issue はそれを unblock しない。- 同じ runner file を触る 実装: claude-gpt adapter の runtime smoke が launcher の解決した underlying Claude Code binary の version を runtime_version に記録するようにする #2954 / 実装: runtime smoke の expected_markers_missing が prompt echo を child marker と誤認する false-green を除去する #2944 とは別関数・別 flag の範囲で進め、競合は後から merge する側が rebase して解消する。
Notes for Reviewer
- flag 名
--lifecycle-failure-evidence-jsonは暫定の提案であり、既存の--evidence-jsonと命名を揃えるための調整は Allowed Paths の範囲で実装者が行ってよい(AC の意味を変えない)。 - AC1〜AC6 の
-k名は新規 test 関数名の固定であり、test file 未作成の baseline は exit 4 で fail する。
Activity
fix: SKILL.md の uv run 例に --locked を付与し governed Python invocation po…
fix: lifecycle 失敗 evidence の cap を失敗原因優先にし、task-notification 抽出を even…
squne121 commentedon Oct 6, 2026
issue-refinement-loop 終了要約(approved)
OWNER の operator decision(Runtime Verification Applicability を current policy に従い
immediateへ改訂する)に基づく再 refinement を完了しました。not_applicableからimmediateへ改訂しました。applicable_acs: [AC8]を宣言し、runtime_assertion_bindingsは skill-invocation-runtime-smoke の 2 assertion をnot_applicable(SKILL.md の変更が flag の使い方の記載のみで output contract と Procedure に触れないため)、subagent-lifecycle-causal-evidence-smoke を AC8 にdispositiveで束縛しました。runtime_onlyの Verification Commands を追加しました。AC1〜AC7 は変更していません。# baseline-expect: fail (exit 4: …)の 6 行を許可された annotation# baseline-expect: failに是正しました。approve/proceed(canonical_step2_route: step_2_5)、semantic review は非適用です。この終了は実装開始の代替承認ではありません。#2944 / #2954 / #2941 / PR #2946 の scope は吸収していません。
squne121 commentedon Oct 6, 2026
Contract Review Result
feat: runtime smoke の lifecycle failure 時に raw lifecycle event を opt-…