Repository navigation
feat: runtime smoke の lifecycle failure 時に raw lifecycle event を opt-in で保全する - #2959
Conversation
…in で保全する (#2958) structured Claude run の lifecycle verdict が失敗した場合に限り、 --lifecycle-failure-evidence-json 指定時のみ、許可リストの raw lifecycle event (hook event の既存 field、tool_use_result の agentId/status、task-notification の agent id/status) と settings_provenance.digest_sha256 を channel ごとに 100 件上限で --output-dir 配下へ排他的に新規作成する。message 本文・prompt・secret・ last_assistant_message・transcript は保存せず、verdict / exit code / summary.md は flag の有無で変わらない。 Refs #2953 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Preview URLPreview removed (PR #2959 closed). |
…licy へ適合させる (#2958) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
判定REQUEST_CHANGES です。方向性は妥当で、#2953 で失われた failure 時の lifecycle evidence を #2958 で opt-in / bounded に保全する判断自体は適切です。ただし、現状は「failure が起きたのに、その原因 event が evidence から落ちる」「diagnostic が verdict と同じ parser の誤認を再生する」という2点があり、#2958 の目的を満たし切れていません。 Findings
外部仕様との照合では、 一方、最近の upstream でも background-agent lifecycle/notification は単純ではなく、#96849 は resume 後に completed task notification が届く一方で handback が失われるケースや、関連する重複 notification 問題を記録しています。これは今回の incident と同一 bug の証明ではありませんが、現段階で upstream / launcher / parser のどれかへ早期帰属せず raw evidence を残すという #2958 の設計方針を支持します。[GitHub](https://github.com/anthropics/claude-code/issues/96849?utm_source=chatgpt.com) 現在の Claude Code 最新 release は v2.1.291 で、incident で使われた v2.1.289 の release notes に SubagentStop / lifecycle duplicate 修正は記載されていません。「upgrade 済みだから解消」とは扱えません。[GitHub](https://github.com/anthropics/claude-code/releases?utm_source=chatgpt.com) セキュリティ/harness 面では、現状の 修正優先順位は P1-1 failure-preserving cap → P1-2 event-local diagnostic extraction → P1-3 allowlist/completion semantics → fresh HEAD 再検証 が最短です。これらを直せれば、#2958 の本来の価値を保ったまま大きな仕組み追加なしで merge-ready に近づきます。 |
|
確認した live state では、PR #2959 は Draft/Open、HEAD 推奨は #2959 をそのまま再利用し、コメント そのまま現在の fresh / auto mode Claude Code に貼れる実行プロンプトです。 repo = 対象:
使用する repository-native Skill: この interactive Claude Code / Claude-GPT session は既に fresh / auto mode で起動済みです。 新しい session の起動、 目的PR #2959 の OWNER comment
まで current canonical loop に従って自律的に進め、人間が merge 判断できる直前まで到達してください。 merge / auto-merge は実行しないでください。 通常の:
は、それ自体を人間確認の停止理由にせず、current 調査だけ、SubAgent dispatch だけ、修正 commit だけ、review 開始だけで終了しないでください。 今回ユーザーが明示的に承認する作業以下を人間への iteration ごとの再確認なしで実行してよいです。
ただし merge / auto-merge、force push、history rewrite、foreign worktree/branch の削除、credential 操作は承認していません。 最初に current live state を fresh 取得するprompt 内の SHA は authority ではありません。開始時に必ず fresh read してください。 参考値(2026-10-06 20:15 JST 頃):
ただしこれらは開始時に再確認してください。 最低限確認:
過去 transcript の skill semantics や以前の contract-snapshot hard stop を authority にしないでください。 human-context の渡し方OWNER comment: を、current raw comment をそのまま shell instruction として連結せず、repository source / current diff / tests と照合した current 既存 PR を必ず再利用するlanding disposition / pre-Step-1 data-plane を current canonical producer から取得し、既存 PR resume と判定される場合は:
既存 foreign worktree や別 task の dirty state を勝手に変更・削除しないでください。 contract snapshot / readiness の扱い過去セッションでは #2958 の Runtime Verification Applicability が その過去判断を固定知識として再適用しないでください。 current main の current current Skill が:
等を advisory として Step 1 continuation 可能と定義しているなら、以前の 一方、current canonical policy が本当に live trusted-owner veto / OWNER REQUEST_CHANGES の修正優先順位comment P1-1: bounded evidence が failure-causing event を落とす問題current implementation の単純な prefix truncation:
のため、cap より後ろで発生した duplicate / contradictory 等の failure-causing event が evidence から消える問題を直してください。 要求:
を優先する設計を検討する ただし新しい generic tracing platform、daemon、lock、attestation、schema family は作らないでください。 少なくとも regression として:
という poison case を固定してください。 実際の selection algorithm は current source と #2958 contract に最小変更で整合するものを選んでください。 P1-2: task-notification diagnostic を verdict parser と独立させるdiagnostic evidence が verdict と同じ global 目的は: verdict / classifier semantics 自体はこの Issue で変更しません。 diagnostic 専用 extraction は:
ようにしてください。 current stream shape は必ず repository tests / parser source から確認し、carrier field を推測で invent しないでください。 regression:
P1-3: #2958 の固定 allowlist に実装を合わせるcurrent Issue #2958 の In Scope が authority です。 現 contract のまま修正できるなら、以下を優先してください:
position field が本当に必要だから固定 allowlist を変えたい、という方向へ安易に進まないでください。 もし source を検証した結果、本当に current fixed contract / Allowed Paths の変更が不可避なら:
してください。 P2: current HEAD への evidence binding現在 PR body には古い:
が残っています。 修正 commit 後の 最終 fresh HEAD に対して:
を取り直してください。 PR body の:
を最終 HEAD と一致させてください。 古い head の PASS や現在 SubAgent 使用の必須条件current 少なくとも current workflow が引き続き使用しているなら:
を適切に利用してください。 各 SubAgent dispatch では独立 context であることを前提に、最低限:
を明示してください。 SubAgent を background dispatch しただけで次へ進まないでください。 必ず:
こと。 SubAgent final result 不在を成功扱いしないでください。 verification / review loop修正後は current 特に:
pr-reviewer 自身の review output / prose を terminal approval と同一視しないでください。 CI開始時点の final HEAD で required checks を fresh に確認してください。 通常の CI failure は停止理由ではありません。 flaky の可能性だけで rerun するのではなく、まず failure class を確認してください。 #2944 / #2954 / #2941 の scope 分離維持してください。
今回 #2959 に吸収しないでください。 再発防止 Issue今回の P1-1 / P1-2 / P1-3 は #2958 自体の未達 finding なので、まず #2958 / PR #2959 で直接修正してください。これらをそのまま別 Issue に逃がさないでください。 ただし作業中に、今回の個別実装を越えて今後も再発しそうな repository workflow / harness / producer-consumer defect を発見した場合は:
今回のユーザー指示は、この narrow な再発防止 Issue の dedupe 後の起票を明示的に承認しています。 ただし follow-up Issue 起票を理由に #2959 の current in-scope 修正を放棄しないでください。 明示的停止条件次の場合のみ停止 / escalation してください。
通常の REQUEST_CHANGES、test failure、CI failure、stale head、BEHIND、warning、advisory snapshot failure は停止理由ではありません。 禁止
到達点current canonical loop が正常に完了した場合:
まで進めてください。 最終報告root/main session から最後に簡潔に以下を報告してください。 live state
target comment
verification
review loop
GitHub
terminalexactly one:
最後に、merge / auto-merge を実行していないことを明記してください。 今回の3つの P1 は #2958 内で直すべき defect なので、現時点では別 Issue 化しない方がよいです。再発防止 Issue の対象は、修正中に見つかる「この PR 固有ではない canonical workflow / harness の再発 defect」に限定するのが適切です。 |
…t-local な診断へ独立させる (#2958) - 上限超過時も duplicate/orphan/unknown の agent と contradictory hook event を優先保存し、元の stream 順で出力する - task-notification は queue-operation event の content/prompt 1 field 内の completed block のみを採用し、verdict の global regex と独立させる - tool_use_results / task_notification_completions を agent_id と status のみに固定(stream_index/match_index 削除) - regression test と SKILL.md の許可リスト・上限の記述を実装に整合 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
判断は (a) を推奨します。#2958 を current policy に合わせて 理由は、current main の extension-surface policy が ただし1点、前回報告の「(a) でも独立 VC はそのまま有効なので reviewer 以降だけで済む」は訂正が必要です。貼り付けたテキスト(1) test-runner report は旧 Issue body の 再発防止 Issue は今回は新規起票しません。live dedupe では runtime assertion applicability は #2852 / #2775 / #2917、comment-only false-required は #2961 が既に所有しています。また test-runner の 以下を、そのまま既に fresh / auto mode で起動済みの対話的 Claude Code に貼ってください。 repo = 対象:
この interactive Claude Code session は既に fresh / auto mode で起動済みです。現在の session と repository-owned launcher/profile をそのまま継続してください。新しい session、 OWNER / operator decision選択肢 (a) を採用します。 #2958 の Runtime Verification Applicability を current repository policy に適合する この判断に必要な以下の通常作業を、人間への iteration ごとの再承認なしで実行して構いません。
ただし merge / auto-merge は行わないでください。破壊的操作、secret/credential の取得・変更・公開、force push 等の履歴破壊、policy bypass が必要な場合は停止してください。 重要な訂正旧 test-runner report をそのまま再利用して reviewer から再開してはいけません。 #2958 の Issue body を refinement すると したがって:
Phase A — #2958 issue-refinement-loop最初に current repository / GitHub state を fresh 取得してください。過去 transcript の main SHA、Skill procedure、policy result、CI 状態を current truth として再利用しないでください。 current main の以下を最低限確認してください。
repository-native 今回の human judgment はすでに解決済みです: したがって、この exact choice を再度人間へ質問しないでください。新たな別論点の RVA refinement の原則top-level ただし #2852 の semantics を守り、各 assertion は change surface に応じて正直に分類してください。
既存の #2958 goal: runtime verification が必要なら、既存 SubAgent必要な codebase-investigator / web-researcher 等を current Skill の手順どおり使用してください。 SubAgent を dispatch しただけで完了扱いにしないでください。各 SubAgent について:
を守ってください。 refinement loop は max iteration 内で自律継続してください。needs-fix は通常停止理由ではありません。 最終的に:
まで到達してください。 Phase B — existing PR #2959 を impl-review-loop で resumerefinement 完了後、repository-native current duplicate PR / branch / worktree を作成しないでください。 fresh intake / landing disposition を canonical producer から取得し、
を再利用してください。 implementation の扱いまず refined contract と HEAD refinement が runtime verification contract のみを変更し、実装 diff が新 contract の AC / scope を既に満たす場合は、implementation-worker に不要なコード書換えをさせないでください。 コード修正が本当に必要な場合だけ implementation-worker を dispatch し、Allowed Paths と fix_delta を明示してください。 implementation-worker を使う場合も terminal completion と final Phase C — fresh independent VC#2958 body が変わったため、旧 Step 2 evidence を stale として扱ってください。 live Issue body から canonical parse-only metadata を再取得し:
を fresh に materialize してください。 test-runner SubAgent を fresh task name で dispatchしてください。 test-runner には current Step 2 contract の実値をすべて渡してください。暗黙 context に依存させないでください。 特に:
test-runner の:
の両方を取得するまで downstream に進まないでください。 report を root が手修正しないでください。 Phase D — canonical Step 4 adjudication → fresh pr-reviewerfresh contract snapshot を canonical producer から取得してください。 手組み snapshot を作らないでください。
fresh:
を渡し、exit 0 / pr-reviewer も SubAgent dispatch のみで完了扱いにせず、terminal completion + final review result を取得してください。 REQUEST_CHANGES が返った場合は current 通常の test failure / review finding / stale evidence / fixable CI failure は人間停止理由ではありません。 Phase E — CI / terminalcurrent HEAD の required CI を terminal 状態まで確認してください。 現時点の過去情報では CI が in-progress だったため、過去の green/pending を流用せず fresh state を取得してください。 base/main 更新で BEHIND になった場合は current impl-review-loop の Step 5 routing に従ってください。branch update により HEAD が変わった場合は旧 VC / review を stale とし、必要な verification / review を current HEAD で取り直してください。 最後は canonical
merge / auto-merge は行わず、人間が merge 判断できる直前で停止してください。 recurrence prevention今回の作業中に再発性のある repository defect を発見した場合:
特に次は新規 defect と決めつけないでください:
これらは phase 別の current contract としてまず current source を照合してください。 また test-runner の 最終報告最後に簡潔に以下を報告してください。
調査だけ、Issue refinement だけ、SubAgent dispatch だけ、test 実行だけ、reviewer 起動だけで終了しないでください。canonical loop が merge 直前の terminal state に達するか、上記の genuine stop condition に到達するまで進めてください。 この prompt では、(a) の承認を明示しつつ、Issue body 更新で old VC binding が失効する点も織り込んでいます。 |
impl-review-loop 結果(terminal gate 通過)
|
Summary
--lifecycle-failure-evidence-json <path>を追加しました。multi_child_lifecycleが verified False、duplicate_completionsが非空、または causal evidence を要求した run でsubagent_causal_evidenceがno_evidenceの場合のみです。成功 stream・flag 未指定では何も保存しません。summary.mdの既存 field は flag の有無で変わりません(判定は既存 verdict の読み取りのみで、書き込みはwrite_evidenceの後に行います)。Refsのみの関係です。本 PR は次の Issue を扱います。
Closes #2958(本 Issue を完了させる)
Refs #2953(参照のみで close しない)
上記のとおり #2953 は参照のみで、close しません。
受け入れ条件の達成状況
allowlisted_events_preserved_on_lifecycle_failureで検証。excludes_message_prompt_and_secret_contentで検証(top-level key 集合も固定)。nothing_preserved_on_pass_or_without_flagで検証。[FAIL]行が一致することをverdict_and_exit_code_unchangedで検証。--output-dir配下でない path(絶対 path、..経由、output dir 自身)は起動前に exit 2 で拒否、symlink 経由の脱出も拒否することをexisting_file_not_overwritten_and_path_confinedで検証。*_totalに残ることをoutput_is_boundedで検証。cap 超過位置の duplicate SubagentStop が evidence に残る regression(failure_beyond_cap)を追加(優先選択を外す mutation で失敗することを確認)。.claude/skills/worktree-agent-runtime-smoke/SKILL.mdに新 flag の使い方・保存条件・許可リスト・上限・出力先の規則を記載。--lifecycle-failure-evidence-jsonを指定した成功 lifecycle の run が exit 0 で完了し、SubagentStart / SubagentStop の causal evidence が current run に束縛されて成立し(causal_evidence_source: hook_id_correlated)、evidence file は作られない。証跡は下記の「Runtime Verification Evidence」節を参照。検証コマンド結果
保存する lifecycle evidence の許可リストとプライバシー境界
hook_event/stream_index/agent_id/agent_type/agent_transcript_path_present(path 自体は保存せず有無のみ)/session_id/prompt_id/stop_hook_active/contradictory、userevent のtool_use_resultのagentId/statusのみ(位置 field なし)、task-notification は completion block の agent id と status(completedのみ、位置 field・本文なし。queue-operationevent のcontent/prompt1 field 内の block だけを event-local に解析し、verdict 側の正規表現とは独立)、settings_provenance.digest_sha256。last_assistant_message、assistant message 本文、prompt、secret、transcript 内容、task-notification 本文。文字列値は既存の_redactを通し 128 文字で切り詰めます。--output-dir配下のみで、排他的に新規作成(O_EXCL|O_NOFOLLOW)し、既存 file は上書きしません(warning のみ)。extract_claude_hook_lifecycle_events、_iter_claude_stream_events、_CLAUDE_TASK_NOTIFICATION_REを再利用しています。subagent_causal_evidenceのno_evidenceは、causal evidence を要求した run(実際にno_evidenceで run が失敗する条件)でのみ lifecycle failure として扱います。何も要求していない run には lifecycle verdict がないため保存しません。実 runtime 検証証跡(Runtime Verification Evidence)
AC8(
immediate、runtime_only)の実 runtime 検証結果です。検証対象 HEAD は9bdd634c03772152609f6aac61659c67bd9999e5(Issue body sha256:608a10302570bf10d675b468f16e649fb14f22dc705bd3719acf7f792d0bcc85)です。独立 test-runner が実行し、root が worktree の実summary.mdを別途読んで確認しました。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.json9bdd634c03772152609f6aac61659c67bd9999e5、runtime_version2.1.291 (Claude Code)、run_id2d67c22c635e。multi_child_lifecycle.verified: True(spawned / completed / paired が同一 agent_id 1 件、orphan_starts・unknown_children・duplicate_completions は空)。subagent_causal_evidenceはsubagent_start_observed: True/subagent_stop_observed: True/tool_invocation_id_correlated: True/marker_provenance_verified: True/causal_evidence_source: hook_id_correlated。test ! -e artifacts/runtime-smoke/lifecycle-failure-evidence-optin/lifecycle-failure-evidence.jsonは exit 0 で、evidence file は作られていません(AC3 の挙動が実 runtime でも成立)。artifacts/runtime-smoke/lifecycle-failure-evidence-optin/summary.md(main へ commit しない。新しい schema・receipt・publisher は追加していません)。runtime_assertion_bindingsのskill-invocation-runtime-smokeの 2 assertion は、本 PR の SKILL.md 変更が flag の使い方の記載のみで output contract と Procedure に触れないためnot_applicableと宣言しています(assertion 単位のnot_applicableは runtime PASS の主張ではありません)。Allowed Paths 遵守
.github/ci/python-test-plan.jsonはscripts/agent-ops/tests/が既に target のため変更不要)pnpm typecheck/lint/test/buildは本 fix_delta が Python と SKILL.md のみの変更のため再実行しておらず、旧 HEAD の結果であり本 HEAD の証跡ではない。required CI は本 HEAD で別途確認する)Checks
pnpm typecheckpnpm lintpnpm testpnpm buildSchema Change Applicability
not_schema_changeSchema Consumer Inventory
N/A: not_schema_change のため。新規 JSON は opt-in の診断用 file で、repo 内に consumer はありません。
Compatibility Decision(互換性判定)
N/AN/AN/AN/ASafety Claim Matrix
N/A: runner の失敗時の診断証跡保全であり、安全境界・権限・sandbox・transport・auth には触れません。
Notes
duplicate_completionsの根本原因修正と task-notification dedupe の regression test は follow-up 候補です。