Skip to content

実装: worktree-agent-runtime-smoke に JSON 出力オプションを追加し claude-gpt launcher 経由の live causal-evidence 検証を行う - #2310

Merged
squne121 merged 5 commits into
mainfrom
worktree-issue-2231-claude-gpt-live-causal-evidence
Aug 23, 2026
Merged

squne121 merged 5 commits into
mainfrom
worktree-issue-2231-claude-gpt-live-causal-evidence

Conversation

@squne121

@squne121 squne121 commented Aug 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

run_worktree_agent_runtime_smoke.py の既存 schema_summary(WORKTREE_AGENT_RUNTIME_SMOKE_RESULT_V1)に --evidence-json <path> オプションを追加し、Claude-GPT launcher(scripts/claude-gpt/launch.sh)経由と native Claude Code 経由それぞれの live positive run で causal_evidence_source: hook_id_correlated かつ exit_code: 0 を machine-generated JSON として取得できるようにした。新規 regression test test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py を追加し、AC1(claude-gpt live)/ AC2(native live)/ AC3(deterministic negative fixture)/ AC4(live parent-only diagnostic)/ AC5(generic secret scanner + 非commit)を検証する。

raw JSON receipt は worktree-local artifacts/ にのみ書き出し、リポジトリへコミットしない。本 PR 本文には sanitized summary(hashed fields のみ)のみを掲載する。

Checks

以下の検証コマンドを実行し、すべて成功したことを確認した。

  • コマンド1(AC1、claude-gpt live): uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac1_claude_gpt_positive_hook_correlated — 成功
  • コマンド2(AC2、native live): uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac2_native_positive_hook_correlated — 成功
  • コマンド3(AC3、決定論的 negative fixture): uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac3_negative_fixture_marker_only_insufficient — 成功
  • コマンド4(AC4、live parent-only 診断): uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac4_live_parent_only_negative_diagnostic — 成功
  • コマンド5(AC5、secret scan + 非commit): uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac5_evidence_json_no_secrets_and_not_committed — 成功
  • 既存の回帰テスト一式: uv run pytest scripts/agent-ops/tests/ — 744 件成功、18 件スキップ、退行なしを確認
  • モデルルーティングの必須テスト: uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py — 24 件成功
  • 静的解析: uv run ruff check scripts/agent-ops/run_worktree_agent_runtime_smoke.py scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py — エラーなし

Schema Change Applicability

  • decision: not_schema_change
  • 理由: WORKTREE_AGENT_RUNTIME_SMOKE_RESULT_V1 の既存フィールド集合・型は変更していない。--evidence-json は既存 schema_summary を追加でファイルへダンプするオプトインの出力チャネルであり、summary.md(既存)と全く同じ内容を JSON 化して書き出すだけで、新規フィールドの追加・既存フィールドの削除・改名・型変更は一切行っていない。

Schema Consumer Inventory

該当なし。decision: not_schema_change のため、本セクションは対象外とする。

Safety Claim Matrix

reason: 本 PR は transport / permission / sandbox / auth / mcp のいずれも変更しない(N/A)。変更対象は scripts/agent-ops/ 配下の runner 拡張とテストのみであり、安全境界に関する主張は行わない。

Claim Implemented? Not controlled Evidence Follow-up
N/A(安全境界変更なし) N/A N/A N/A N/A

Runtime Verification Evidence(動作検証証跡)

Runtime Verification Applicability(live Issue #2231)は decision: immediate、対象 AC は AC1, AC2, AC4 である。以下は本 PR の final implementation commit(tested_head、コミット 5f045fa1b3b8ea1e056f9bc800d8667aca9798c5)に対する live 実行の sanitized summary(hashed fields のみ。raw prompt・token・tool 入出力・transcript 全文は一切含まない)。

本 PR は main 取り込みにより旧 head 31a27b83... から 5f045fa1... へ進んだ(scripts/agent-ops/run_worktree_agent_runtime_smoke.py / scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py 自体には差分なし)。この head では main 側 CI(scripts/agent-guards/tests/test_isolated_anchor_single_authority.py 経由の credentialless GitHub live call)が transient GH_API_FAILURE により一時的に failing していたが、PR #2310 の Allowed Paths 外・実差分と無関係であることを確認した上で CI を再実行し、required checks(typecheck / lint / test / build / python-test / validate-generated-artifact)は全て green になった。以下の証跡は current head 5f045fa1... に対して再実行した live 検証である。

AC1 の検証結果: Claude-GPT launcher 経由の structured lane positive run

  • 判定: PASS(成功)
  • 実行環境: Claude-GPT launcher(scripts/claude-gpt/launch.sh、proxy と ChatGPT Pro Codex subscription 認証を利用)
  • 終了コード: 0
  • run_id(実行識別子): 32c6f75f1c20
  • tested_head(検証対象コミット): 5f045fa1b3b8ea1e056f9bc800d8667aca9798c5
  • causal_evidence_source(因果証拠の分類): hook_id_correlated
  • 観測値: subagent_start_observed=true、subagent_stop_observed=true、tool_invocation_id_correlated=true(いずれも真)
  • evidence_json_sha256(証跡ファイルのハッシュ値): 3ba41c4562a1baa9a22d10d42f4a9f3452c4f3a151fa34d4c70ce647eb0a4116

AC2 の検証結果: native Claude Code 経由の structured lane positive run(同一コミット)

  • 判定: PASS(成功)
  • 実行環境: native Claude Code(--claude-adapter 未指定、ローカル認証を利用)
  • 終了コード: 0
  • run_id(実行識別子): 35e389af90ad
  • tested_head(検証対象コミット): 5f045fa1b3b8ea1e056f9bc800d8667aca9798c5
  • runtime_version(実行バージョン): 2.1.241 (Claude Code)
  • causal_evidence_source(因果証拠の分類): hook_id_correlated
  • 観測値: subagent_start_observed=true、subagent_stop_observed=true、tool_invocation_id_correlated=true(いずれも真)
  • evidence_json_sha256(証跡ファイルのハッシュ値): 70a93ecefefd247ae5c0046f8b657a9319b2ec5cad7baee80be9f0ab57d8762a

AC3 の検証結果: 決定論的な negative fixture(parent-marker-only、hermetic)

  • 判定: PASS(成功、current head で再確認済み)
  • 概要: causal_evidence_source(因果証拠の分類)が正確に marker_only_insufficient となり、no_evidence には昇格しないことを決定論的に検証した。この検証は完全に hermetic であり、live 実行のプロセスは一切起動していない。

AC4 の検証結果: live の parent-only negative run(診断記録)

  • 判定: PASS(診断記録として成功)
  • 実行環境: native Claude Code
  • run_id(実行識別子): ef7b0ef1fdac
  • tested_head(検証対象コミット): 5f045fa1b3b8ea1e056f9bc800d8667aca9798c5
  • runner 自身の終了コード: 1(--expect-marker の既定ゲートによる FAIL。これは runner 自身が持つ PASS/FAIL ゲートの仕様であり、AC4 テスト自体の合否基準ではない。Claude Code プロセス自体の終了コードは 0)
  • causal_evidence_source(因果証拠の分類): marker_only_insufficient(親が直接応答し SubAgent の起動なしを観測した、期待どおりの診断結果)
  • 区別の記録: model の判断により Agent が起動された場合は inconclusive(判定保留)として明確に区別してテストコードへ記録する仕組みを実装済みであり、evaluator の欠陥とは混同しない
  • 観測値: subagent_start_observed=false、subagent_stop_observed=false(いずれも偽)
  • evidence_json_sha256(証跡ファイルのハッシュ値): a71cb5a8eb88e8c60e93f4a8bb3b4abe5f871d86bd77d6c0d5d4a843bb975260

AC5 の検証結果: raw JSON receipt の secret scan と非commit確認

  • 判定: PASS(成功)
  • 概要: 軽量な generic secret scanner(Bearer / sk-ant- / OAUTH_TOKEN / Authorization: の各パターンを検査)を、意図的に仕込んだ secret 文字列に対する positive control(検出されることを確認)と、実際に runner が生成した receipt に対する scan(検出件数が0件であることを確認)の両方で検証した。
  • 保存方針: raw receipt は artifacts/(worktree-local、.gitignore の対象)へのみ書き出しており、リポジトリへは commit していない。

引用の必須事項の遵守について

  • PASS(AC1・AC2・AC4)については、正常系(AC1・AC2)と診断用の負例(AC4)の両方の証跡を上記に引用した。
  • SKIP(実行環境不可のケース)については、今回の実行環境では proxy・ChatGPT Pro Codex subscription 認証・native Claude Code 認証のすべてが利用可能であったため発生しなかった。SKIP 条件(launcher 起動前提の不足、または native 認証の不能)はテストコード内の pytest.skip() として実装済みである(_native_claude_available() / _claude_gpt_available() の各ヘルパー関数を参照)。

Notes

本 PR がクローズする Issue: Closes #2231

…er 経由の live causal-evidence 検証を行う (#2231)

既存 run_worktree_agent_runtime_smoke.py の schema_summary に --evidence-json
オプションを追加し、Claude-GPT launcher / native Claude Code の live positive
run で causal_evidence_source: hook_id_correlated を machine-generated JSON
として取得できるようにした。新規 regression test
(test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py)
で AC1(claude-gpt live)/AC2(native live)/AC3(deterministic negative
fixture)/AC4(live parent-only diagnostic)/AC5(secret scanner + 非commit)を
検証する。raw JSON receipt は worktree-local artifacts/ に保存し commit しない。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Preview URL

✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2310/

The preview will be removed when this PR is closed.

@squne121

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST_CHANGES

Evidence Check

  • Allowed Paths Gate(allowed_paths_review_gate.py を直接実行): status: ok。変更ファイルは scripts/agent-ops/run_worktree_agent_runtime_smoke.py と新規 scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py の2件のみで、Issue 実装: worktree-agent-runtime-smoke の Claude-GPT launcher 経由 live causal-evidence 検証を実施し native Claude Code との比較 receipt を記録する #2231 の Allowed Paths と完全一致。
  • 必須 CI(build/lint/test/typecheck/validate-generated-artifact)は head 78240135... で全て SUCCESS。e2e-core/python-test-core も含め gh pr checks 全20件 PASS。
  • 実装差分を精読: --evidence-json は既存 schema_summary の追加的オプトイン出力(既定 None・既存呼び出し元へ非破壊)。新規テストの AC1/AC2/AC4 は実際に subprocess.run() で runner を起動し、生成された JSON を読み込んで assert する実装であり、Issue の Verification Commands(uv run pytest ... -k <test_name> 1行、live 起動はテスト関数内部)と一致。AC3 は subagent_causal_evidence_verdict() の再設計なしに既存判定を直接呼ぶ hermetic テスト。AC5 は secret scanner の positive control を含み vacuous でない。Schema Change Applicability: not_schema_change は妥当(既存フィールド集合・型は無変更)。Safety Claim Matrix は N/A(安全境界変更なし)で整合。Out of Scope(subagent_causal_evidence_verdict() 再設計・launcher 本体変更・専用 validator/専用ドキュメント新設)はいずれも遵守されている。

Blockers

  • AC1/AC2/AC4(Runtime Verification Applicability: immediate)の live PASS 証跡(causal_evidence_source: hook_id_correlated、exit_code: 0、run_id・sha256 群)は、PR本文の Runtime Verification Evidence セクションと Issue 側の implement-issue: 実装完了 コメントという、実装者自身の self-report にのみ依拠している。CI(python-test-core/test ジョブのログを実際に確認)では live claude-gpt/native 認証が利用不能なためこれら3テストは(もし収集されていても)SKIP になっているとみられ、CI 側に PASS の直接的裏付けは無い。また PR/Issue の全コメントを gh api .../comments --paginate で走査したが、独立実行された test-runner の VC 確認コメント(TEST_VERDICT 等)は見つからなかった。PR_REVIEW_JUDGE_VC_EVIDENCE_POLICY により PR_BODY_SELF_REPORT は単独では APPROVE の根拠にできない。独立実行された VC 証跡(同一 head SHA・literal command SHA256 束縛)を Issue または PR へ追加投稿するか、CI 上で再現可能な形にすることを求める。

Non-blockers(参考)

  • 実装者の self-report は run_id・evidence_json_sha256・prompt_sha256・秒単位タイムスタンプを伴う具体的な内容であり、机上の作文ではなく genuine な live 実行を示唆する徴候はある。ただし本ポリシー上は独立裏付けが必須。
verdict: REQUEST_CHANGES
reviewed_head_sha: "7824013587322a4398aa87a9bfde614f70011f99"
blockers:
  - "AC1/AC2/AC4 (immediate runtime verification) の live PASS evidence が実装者の self-report(PR本文 Runtime Verification Evidence セクション + Issue実装完了コメント)にのみ依拠しており、独立実行された corroborating VC(CI_CHECK_RUN_SCOPEDまたは独立実行Issue VCコメント)がGitHub上に見当たらない。PR_REVIEW_JUDGE_VC_EVIDENCE_POLICYによりPR_BODY_SELF_REPORT単独ではAPPROVE不可。"
warnings:
  - "self-reportはrun_id/evidence_json_sha256/prompt_sha256/秒単位タイムスタンプを伴う具体的な内容であり、fabricationを示唆する兆候は見られない。"

@squne121

Copy link
Copy Markdown
Owner Author

Independent VC Adjudication(control-plane 実行、実装者 self-report とは別経路)

本コメントは impl-review-loop orchestrator(control-plane)が Step 2 で test-runner SubAgent へ委譲し、実装者(Step 1 implementation-worker)とは別プロセス・別 SubAgent で独立実行した Verification Commands の結果です。実装者本人による PR 本文の self-report ではありません。

AC test name exit_code status duration
AC1 test_ac1_claude_gpt_positive_hook_correlated 0 PASS 31.17s
AC2 test_ac2_native_positive_hook_correlated 0 PASS 13.92s
AC3 test_ac3_negative_fixture_marker_only_insufficient 0 PASS 0.02s
AC4 test_ac4_live_parent_only_negative_diagnostic 0 PASS 4.35s
AC5 test_ac5_evidence_json_no_secrets_and_not_committed 0 PASS 6.43s

AC1/AC2 は claude-gpt launcher / native Claude Code の実際の live runtime 実行(fabricated fallback なし、SKIP への昇格なし)を伴い、両方とも subprocess.run() 経由で実起動して --evidence-json の生成物を assert した結果として exit_code 0 / PASS を独立に確認しました。AC4 は live parent-only negative diagnostic を実行し、期待どおりの診断結果を確認しています。SKIP は 0 件でした。

VC_ADJUDICATION_RESULT_V1:
  overall_status: PASS
  blocking: false
  head_sha: "7824013587322a4398aa87a9bfde614f70011f99"
  fail_count: 0
  skip_count: 0
  allowed_paths_compliance: true
  executed_by: test-runner SubAgent (independent from implementation-worker)

この結果は Step 4 レビューの blocker「AC1/AC2/AC4 の live PASS 証跡が実装者 self-report のみに依拠している」に対応する、GitHub 上の独立裏付けとして記録するものです。

@squne121

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Mergeability

  • mergeable=MERGEABLE, merge_state_status=CLEAN (isDraft=true, not a blocker)

Evidence Check

Blockers

(なし)

Non-blockers(参考)

  • Draft PR のままである(人間の最終マージ判断待ちの運用方針に合致するため blocker としない)。
verdict: APPROVE
reviewed_head_sha: "7824013587322a4398aa87a9bfde614f70011f99"
blockers: []
warnings:
  - "Draft PR のままである(Delivery Rule により人間の最終マージ判断待ち)。"

@squne121

Copy link
Copy Markdown
Owner Author

結論

PR #2310 は、現時点で追加のコード修正を必要としません。

現在の live state は次のとおりです。

項目 | 状態 -- | -- PR | Open / Draft base | main / 26e79f2 head | 7824013 mergeable | true main | PR base と同一 SHA 最新 verdict | APPROVE 独立VC | AC1〜AC5すべて PASS、FAIL 0、SKIP 0 required CI | 6件すべて SUCCESS blocker | なし

新しい汎用SubAgentや新しい高頻度Hookは推奨しません。リポジトリはlive Issue/PR・実diff・実テスト・CI・独立reviewをauthorityとするminimal harnessを明示し、新規graph policy、ledger、digest authority、enforcing hookを追加しない方針です。


Issue草案1 — #88 本文差し替え

現在の #88 は、test-runner自身が TEST_VERDICT_MACHINE コメントを投稿し、未投稿時にCI fallbackを使う契約です。これは現在のread-only test-runnerとevidence policyの正反対なので、追加Issueではなく #88 をin-place reframeするのが適切です。

# 修正: impl-review-loop の独立VCを Step 4 起動前の current-head gate に接続し TEST_VERDICT 旧経路を非規範化する

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "独立Issue VCの完了・束縛・adjudication前にpr-reviewerを起動しないことで、同一headの不要なREQUEST_CHANGES→再reviewを防止する"
change_kind: workflow
reframes_previous_contract: "#88"</code></pre><h2>Background</h2><p>PR #2310 では、実装差分・Allowed Paths・required CIに問題がなかったにもかかわらず、<br>独立Issue VCがStep 4初回reviewer起動前に渡されなかったため、<br>同一headに対して以下の2回のreviewが発生した。</p><ol><li><p>independent VC missing → REQUEST_CHANGES</p></li><li><p>independent VC PASS追加後 → APPROVE</p></li></ol><p>現行evidence policyでは以下だけがauthoritativeである。</p><ul><li><p>current-head required CI</p></li><li><p>exact head SHA + literal command SHA256に束縛された独立Issue VC</p></li></ul><p>TEST_VERDICT_MACHINEはdiagnostics-onlyであり、approval、blocking、routingを変更しない。</p><h2>Outcome</h2><p>linked IssueにVerification Commandsがある場合、<br>current-head independent VCが完了し、<br><code inline="">VC_ADJUDICATION_RESULT_V1.blocking == false</code> になるまで<br>pr-reviewerを起動できない。</p><p>happy pathでは同一binding tupleに対して、</p><ul><li><p>test-runner 1回</p></li><li><p>pr-reviewer 1回</p></li></ul><p>だけが実行される。</p><p>test-runnerはread-only reportだけを返し、PRコメントを投稿しない。<br>TEST_VERDICT comment/artifactは通常routingの入力にならない。</p><h2>Binding Tuple</h2><pre><code class="language-yaml">repository: &lt;owner/repo&gt;
issue_number: &lt;int&gt;
pr_number: &lt;int&gt;
contract_body_sha256: sha256:&lt;hex&gt;
head_sha: &lt;40-hex&gt;
literal_command_sha256_list:
  - sha256:&lt;hex&gt;</code></pre><h2>Required Design</h2><ol><li><p>Step 2でtest-runner completionとfinal resultの両方を確認する。</p></li><li><p><code inline="">adjudicate_vc_result.py</code> の既存ロジックを再利用する。</p></li><li><p><code inline="">VC_ADJUDICATION_RESULT_V1</code>をLOOP_STATEへ保持する。</p></li><li><p>Step 4起動直前にbinding tupleを再照合する。</p></li><li><p>次のいずれかならpr-reviewerを起動しない。</p><ul><li><p>adjudication missing</p></li><li><p>malformed</p></li><li><p>blocking true</p></li><li><p>head mismatch</p></li><li><p>body mismatch</p></li><li><p>command mismatch</p></li><li><p>FAIL</p></li><li><p>SKIP</p></li><li><p>fallback</p></li></ul></li><li><p>同一root invocation内で同一binding tupleのvalid adjudicationが存在する場合、<br>test-runnerを再実行しない。</p></li><li><p>head/body/commandのいずれかが変われば旧adjudicationをstaleにする。</p></li><li><p>TEST_VERDICT comment検索をnormal flowから除去する。</p></li><li><p>新規persistent ledger、authorization packet、publisher、hook、schemaを作らない。</p></li></ol><h2>In Scope</h2><ul><li><p><code inline="">.claude/skills/impl-review-loop/SKILL.md</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/steps/step-2-verification.md</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/steps/step-4-pr-review.md</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/steps/context-protocol-and-guardrails.md</code></p></li><li><p><code inline="">.claude/agents/test-runner.md</code></p></li><li><p><code inline="">.claude/skills/pr-review-judge/references/evidence-policy.md</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/scripts/adjudicate_vc_result.py</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/tests/test_adjudicate_vc_result_non_regression_gate.py</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/tests/test_step4_requires_current_vc.py</code></p></li></ul><h2>Out of Scope</h2><ul><li><p>TEST_VERDICT legacy parser/schema/materializerの物理削除</p></li><li><p>required CI policy変更</p></li><li><p>PR comment publisherの新設</p></li><li><p>merge automation</p></li><li><p>persistent run-state store</p></li><li><p>graph policy<br>-新規Custom SubAgent</p></li><li><p>新規Hook</p></li></ul><h2>Acceptance Criteria</h2><ul class="contains-task-list"><li class="task-list-item"><p><input type="checkbox" disabled=""> AC1: linked IssueにVCがある場合、current-head nonblocking adjudicationなしでpr-reviewerを起動しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC2: current head、body SHA、ordered command hashesがすべて一致した場合だけadjudicationを採用する。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC3: head/body/commandsのdriftで旧adjudicationがstaleになる。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC4: FAIL/SKIP/fallback/missing/malformedはreviewer spawn前にblockingとなる。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC5: 同一binding tupleのvalid adjudicationを同一loop内で再利用し、test-runnerを二重実行しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC6: happy-path fixtureでtest-runner 1回、pr-reviewer 1回になる。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC7: independent VC missing fixtureではpr-reviewer invocation countが0になる。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC8: test-runnerのactive contractがread-only/no PR commentで統一されている。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC9: active docsに「test-runnerが投稿するコメント」「gh pr view commentsからTEST_VERDICTを取得」がnormal routingとして残らない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC10: TEST_VERDICT_MACHINEはdiagnostics-onlyとしてのみ記述される。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC11: Claude Code / Codex CLIで同一semantic contractを使用する。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC12: 新規persistent ledger、digest authority、publisher、enforcing hookを追加していない。</p></li></ul><h2>Verification Commands</h2><pre><code class="language-bash">uv run --locked pytest \
  .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result.py \
  .claude/skills/impl-review-loop/tests/test_adjudicate_vc_result_non_regression_gate.py \
  .claude/skills/impl-review-loop/tests/test_step4_requires_current_vc.py \
  -q

uv run --locked ruff check \
  .claude/skills/impl-review-loop/scripts/adjudicate_vc_result.py \
  .claude/skills/impl-review-loop/tests/</code></pre><h2>Negative Controls</h2><ul><li><p>adjudicationを削除するとAC1/AC7 fixtureがFAILする。</p></li><li><p>head照合を無効化するとstale-head fixtureがFAILする。</p></li><li><p>command hash照合を無効化するとmodified-command fixtureがFAILする。</p></li><li><p>SKIPをPASSへ変更するとnegative fixtureがFAILする。</p></li><li><p>TEST_VERDICT commentだけを与えてもStep 4 gateが開かない。</p></li></ul><h2>Stop Conditions</h2><ul><li><p>Agent tool起動を強制するための新規enforcing hookが必要になる。</p></li><li><p>persistent authorization packetが必要になる。</p></li><li><p>evidence policy自体のauthority変更が必要になる。</p></li><li><p>Allowed Paths外の変更が必要になる。</p></li><li><p>TEST_VERDICT legacy subsystemの物理削除が必要になる。</p></li></ul><pre><code>
---

## Issue草案2 — #1909 契約改訂

#1909 はすでに「新規SubAgentを追加せず、Claude/Codex共通のbounded local context bundleを使う」スコープを持っています。したがって新規Issueを作らず、Step 2/4向けのreview evidence sectionを追加します。

```markdown
# 契約改訂: bounded SubAgent context bundle に review evidence を統合し Step 2/4 の全文再埋め込みを除去する

## Contract Delta

parent_issue: "#1889"
existing_issue: "#1909"
change_kind: workflow
goal_ref: "test-runner/pr-reviewerへfull Issue、full diff、full commentsを再埋め込みせず、同一bounded bundleをClaude/Codexでconsumeする"

## Required Changes to Existing Contract

### Canonical Path

旧案:

```text
.claude/tmp/subagent-context/&lt;run-id&gt;/&lt;agent&gt;.json</code></pre><p>新正本:</p><pre><code class="language-text">tmp/subagent-context/&lt;run-id&gt;/&lt;task-name&gt;.json</code></pre><p><code inline="">AGENTS.md</code> が <code inline="">tmp/</code> をcanonical temporary workspace、<br><code inline="">.claude/tmp/</code> をlegacy rootとしているため、新規bundleは <code inline="">tmp/</code> に生成する。</p><h3>Bundle Schema</h3><p>既存 <code inline="">dispatch_context_bundle/v1</code> に optional な<br><code inline="">review_evidence</code> sectionを追加する。<br>新しい独立schema familyは作らない。</p><pre><code class="language-yaml">review_evidence:
  repository: &lt;owner/repo&gt;
  issue_number: &lt;int&gt;
  pr_number: &lt;int&gt;
  contract_body_sha256: sha256:&lt;hex&gt;
  base_sha: &lt;sha&gt;
  head_sha: &lt;sha&gt;
  acceptance_criteria:
    - id: AC1
      compact_text: "&lt;bounded&gt;"
  verification_commands:
    - ac: AC1
      literal_command: "&lt;exact&gt;"
      command_sha256: sha256:&lt;hex&gt;
  allowed_paths:
    - "&lt;path&gt;"
  diff:
    changed_paths: []
    additions: &lt;int&gt;
    deletions: &lt;int&gt;
    bounded_hunks: []
    full_diff_artifact_ref: "&lt;ref|null&gt;"
  required_ci:
    status: pass | fail | pending | missing
    checks: []
  vc_adjudication:
    status: PASS | FAIL | STALE | MISSING
    blocking: &lt;bool&gt;
    tested_head_sha: &lt;sha|null&gt;
    fail_count: &lt;int&gt;
    skip_count: &lt;int&gt;
  unresolved_blockers: []
  source_observations:
    - kind: issue_body | pr_metadata | pr_diff | comment | ci | local_file
      identity: "&lt;number/blob-sha/comment-id/check-id&gt;"
      observed_sha256: "sha256:&lt;hex&gt;|null"</code></pre><h3>Size and Privacy Bounds</h3><ul><li><p>serialized bundle: 64 KiB以下</p></li><li><p>individual prose fragment: 4 KiB以下</p></li><li><p>full diff、full comments、full logs、raw transcriptはartifact refにする</p></li><li><p>credential、token、cookie、absolute repository pathを含めない</p></li><li><p>mode <code inline="">0600</code></p></li><li><p>atomic write</p></li><li><p>child完了後に削除</p></li><li><p>resume時は再生成し、古いbundleを再利用しない</p></li></ul><h3>Dispatch Contract</h3><p>親promptに全文を埋め込まず、以下だけを渡す。</p><pre><code class="language-yaml">objective: "&lt;bounded objective&gt;"
context_bundle_path: "tmp/subagent-context/&lt;run-id&gt;/&lt;task-name&gt;.json"
expected_bundle_id: "&lt;id&gt;"
expected_head_sha: "&lt;sha&gt;"</code></pre><p>childはresultに以下を返す。</p><pre><code class="language-yaml">bundle_id: "&lt;id&gt;"
context_source: local_bundle
observed_head_sha: "&lt;sha&gt;"</code></pre><h3>SubAgent Policy</h3><ul><li><p>新規Custom SubAgentを追加しない。</p></li><li><p>既存implementation-worker / test-runner / pr-reviewerを利用する。</p></li><li><p>childによる再帰delegationは禁止。</p></li><li><p>missing fieldがある場合、childは推測せず <code inline="">INSUFFICIENT_CONTEXT</code> を返す。</p></li><li><p>live mutable stateの最終照合はrootが所有する。</p></li></ul><h2>Revised Acceptance Criteria</h2><ul class="contains-task-list"><li class="task-list-item"><p><input type="checkbox" disabled=""> AC1: Step 2/4のSubAgent起動前にbundleが生成される。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC2: bundle完成前にchildをspawnしない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC3: test-runner/pr-reviewer promptにfull Issue、full diff、full commentsを埋め込まない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC4: current full-inline fixture比でchild message bytesを30%以上削減する。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC5: bundleが64KiBを超える場合、full payloadを展開せずartifact refへ退避する。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC6: required identity/binding欠落時はfail-closed。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC7: child resultのbundle_id/head_shaが不一致ならstale扱い。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC8: child完了後にbundleを削除する。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC9: resume時に古いbundleを再利用しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC10: Claude Code / Codex CLIが同一semantic input contractをconsumeする。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC11:新規SubAgent、persistent state、GitHub publisherを追加しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC12: <code inline="">.claude/tmp/</code> ではなく <code inline="">tmp/</code> を利用する。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC13: raw transcript、full tool output、secret、credentialがbundleに含まれない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC14: Step 2 independent VCとStep 4 review evidenceを同じbundle lineageで渡せる。</p></li></ul><h2>Verification Commands</h2><pre><code class="language-bash">uv run --locked pytest \
  scripts/agent-ops/tests/test_build_subagent_context_bundle.py \
  -q

rg -n \
  -e "context_bundle_path" \
  -e "bundle_id" \
  -e "context_source" \
  .claude/agents \
  .codex/agents \
  .claude/skills/impl-review-loop

git diff --check</code></pre><h2>Stop Conditions</h2><ul><li><p>新しいpersistent state storeが必要になる。</p></li><li><p>GitHub上のmachine-readable経路を廃止する必要がある。</p></li><li><p>bundleをapproval authorityにする必要がある。<br>-新規Custom SubAgentが必要になる。</p></li><li><p>64KiB内にidentity/binding情報を表現できない。</p></li></ul><pre><code>
---

## Issue草案3 — #2052 契約改訂

#2052 はruntime stateの再読、duplicate command、wait polling、context budgetをすでに所有しています。新規cache Issueではなく、`impl-review-loop` へのconsumer接続とreview-cycle metricsを追加します。

```markdown
# 契約改訂: SHA-bound evidence index を impl-review-loop に接続し same-head反復と重複readを可視化する

## Existing Issue

#2052

## Goal Delta

`issue-refinement-loop` だけでなく `impl-review-loop` の
Preparation / Step 2 / Step 4でもevidence indexを利用し、
同一revisionのIssue/comment/file/command再取得を抑制する。

cacheはapproval、CI status、mergeability、mutation authorityの代替にしない。

## Added In Scope

- `impl-review-loop` Preparationでintake capsule由来のsource observationsをindexへ登録
- Step 2でIssue body、literal commands、head-bound test resultをindexへ登録
- Step 4でdiff blob、relevant comments、required-check summaryをindexへ登録
- same binding tupleに対する重複read/command/reviewer invocationの計測
- fresh-required mutable readの明示
- context budget reportへのreview-cycle metrics追加

## Binding and Freshness

Cacheable:

- immutable file blob SHA
- Issue body SHAに束縛されたparsed contract
- comment ID + body SHA
- PR diff head SHA
- literal command fingerprint
- deterministic command result
- context bundle digest

Always fresh-required:

- current PR head
- current Issue body SHA
- mergeability
- required CI status
- latest human veto/blocker
- mutation postcondition

## Added Metrics

```yaml
review_cycle_metrics:
  source_read_count: &lt;int&gt;
  cache_hit_count: &lt;int&gt;
  duplicate_read_prevented_count: &lt;int&gt;
  command_execution_count: &lt;int&gt;
  command_cache_hit_count: &lt;int&gt;
  fresh_required_bypass_count: &lt;int&gt;
  vc_execution_count: &lt;int&gt;
  pr_reviewer_invocation_count: &lt;int&gt;
  same_binding_reviewer_repeat_count: &lt;int&gt;
  wait_only_turn_count: &lt;int&gt;
  expanded_output_bytes: &lt;int&gt;
  artifact_ref_output_count: &lt;int&gt;</code></pre><p>数値のみを保存し、raw content、prompt、tool outputは保存しない。</p><h2>Added Acceptance Criteria</h2><ul class="contains-task-list"><li class="task-list-item"><p><input type="checkbox" disabled=""> AC11: impl-review-loopが同一body/headのIssue bodyをphase内で再取得しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC12:同一comment ID/body SHAを複数回main contextへ展開しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC13:current head/CI/mergeabilityは常にfresh-requiredでcache authorityにしない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC14:同一literal command fingerprintのno-progress再実行を検出する。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC15:PR #2310相当fixtureでsame_binding_reviewer_repeat_countを記録できる。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC16:#88修正後fixtureではhappy pathのsame_binding_reviewer_repeat_countが0になる。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC17:full diff/log/commentsはartifact refを返し、main contextへ展開しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC18:cache miss/hitはrouting authorityにならない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC19:head/body/config/tool version driftでinvalidationする。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC20:wait-only model turnを増やさずhelper側pollingを利用する。</p></li></ul><h2>Expanded Allowed Paths</h2><ul><li><p><code inline="">.claude/skills/impl-review-loop/SKILL.md</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/steps/preparation.md</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/steps/step-2-verification.md</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/steps/step-4-pr-review.md</code></p></li><li><p><code inline="">scripts/agent-ops/evidence_index.py</code></p></li><li><p><code inline="">scripts/agent-ops/context_budget_report.py</code></p></li><li><p><code inline="">scripts/agent-ops/tests/test_evidence_index.py</code></p></li><li><p><code inline="">scripts/agent-ops/tests/test_context_budget_report.py</code></p></li></ul><h2>Verification Commands</h2><pre><code class="language-bash">uv run --locked pytest \
  scripts/agent-ops/tests/test_evidence_index.py \
  scripts/agent-ops/tests/test_context_budget_report.py \
  -q</code></pre><h2>Stop Conditions</h2><ul><li><p>CI結果やreview approvalをcache authorityにする必要がある。</p></li><li><p>mutable GitHub stateへ無期限TTLを導入する必要がある。</p></li><li><p>raw prompt/transcript/comment bodyをindexへ保存する必要がある。<br>-新規persistent event ledgerが必要になる。</p></li></ul><pre><code>
---

## Issue草案4 — #1117を#1093のintegration childへreframe

#1093と#1117は、どちらもAGENTS/CLAUDE/skills/hooks/subagents/rules/scriptsのinventory、10K token cap、compact output、session manifest metricsを扱っており、現状では実装スコープがかなり重複しています。#1093をinventory core、#1117をimpl-review-loop integrationに限定するのが適切です。 

```markdown
# 契約改訂: #1093 のcontext budget inventoryをimpl-review-loopと既存session manifest hooksへ接続する

## Existing Issue

#1117

## Dependency

blocked_by:
  - "#1093"

## Ownership Split

### #1093 owns

- `agent_ops_inventory.py`
- `agent_context_budget.py`
- token estimation / hard cap
- inventory JSON schema
- stale artifact/source SHA detection
- shared unit tests

### #1117 owns

- impl-review-loopのinventory-first接続
- context budget decisionのrouting
- existing Stop/SubagentStop/PostToolUse manifest pipelineとの接続
- privacy-preserving run metrics
- integration tests

#1117ではinventory generatorを再実装しない。

## Outcome

impl-review-loopがAGENTS/CLAUDE/skills/hooks/subagents/rules/scriptsを
個別に読み始める前に、#1093が生成するcompact inventoryと
`CONTEXT_BUDGET_DECISION_V1`をconsumeする。

既存session manifest pipelineは、取得可能な場合のみtoken usageを記録し、
取得不能時は `unavailable / null` を維持する。
0への偽装やAI自己申告は使用しない。

新しいHookは追加しない。

## Existing Hook Reuse

利用する既存経路:

- PostToolUse → `session_manifest_debounce.mjs`
- Stop → `session_manifest_coordinator.sh`
- SubagentStop → `session_manifest_coordinator.sh`

必要なmetrics抽出は上記producer/coordinatorに追加する。
PreToolUseへ新しい高頻度Hookを追加しない。

## Context Budget Flow

1. impl-review-loop開始時に#1093 inventoryを1回生成。
2. compact stdoutだけをmain contextへ返す。
3. full inventoryはartifactへ保存。
4. total budgetが上限内なら対象fragmentだけ読む。
5. warning fragmentは明示理由付きで読む。
6. hard-cap超過時は全文展開せずartifact refと対象pathだけを返す。
7. SubAgentには#1909 bundle経由で必要fragmentだけ渡す。
8. Stop/SubagentStop時にcontext budget artifact refをsession manifestへ追加する。

## Token Usage Policy

```yaml
token_usage:
  availability: measured | estimated | unavailable
  source: provider_api | tool_log | entire_cli | manual_report | none
  prompt: &lt;int|null&gt;
  completion: &lt;int|null&gt;
  total: &lt;int|null&gt;</code></pre><ul><li><p>runtimeがusage fieldを提供する場合のみ <code inline="">measured</code></p></li><li><p>repository-approved estimatorを使う場合のみ <code inline="">estimated</code><br>-取得不能なら <code inline="">unavailable</code></p></li><li><p>nullを0へ変換しない</p></li><li><p>AIの自然言語自己申告をmeasuredとして扱わない</p></li></ul><h2>Context Metrics</h2><p>token usageと別に、context budget artifactへ以下を記録する。</p><pre><code class="language-yaml">context_metrics:
  inventory_file_count: &lt;int&gt;
  inventory_estimated_tokens: &lt;int&gt;
  main_context_expanded_bytes: &lt;int&gt;
  child_prompt_bytes: &lt;int&gt;
  bundle_bytes: &lt;int&gt;
  duplicate_reads_prevented: &lt;int&gt;
  artifact_refs_returned: &lt;int&gt;
  compaction_count: &lt;int|null&gt;</code></pre><p>session manifestにはfull metricsを直接埋め込まず、<br>sanitized summaryまたはartifact refを記録してよい。</p><h2>Revised Acceptance Criteria</h2><ul class="contains-task-list"><li class="task-list-item"><p><input type="checkbox" disabled=""> AC1: #1117がinventory generatorを重複実装しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC2: impl-review-loopはraw file read前に#1093 inventoryをconsumeする。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC3: &gt;1K token fragmentはwarning、total &gt;10K tokenはfull expansionをfail-closedにする。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC4:full inventoryはartifactへ退避し、stdoutはcompact JSONのみ。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC5:既存Stop/SubagentStop/PostToolUse pipelineを再利用する。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC6:新規Hookを追加しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC7:token usage取得不能時に0を記録しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC8:token/context metricsにraw prompt、transcript、tool output、credentialを含めない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC9:session manifestからcontext budget artifactを追跡できる。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC10:Claude/Codexで同じinventory artifactをconsumeできる。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC11:stale source SHAのinventoryを再利用しない。</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC12:SubAgent prompt payload bytesをfixtureで計測できる。</p></li></ul><h2>Allowed Paths</h2><ul><li><p><code inline="">.claude/skills/impl-review-loop/SKILL.md</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/steps/preparation.md</code></p></li><li><p><code inline="">.claude/skills/impl-review-loop/steps/context-protocol-and-guardrails.md</code></p></li><li><p><code inline="">.claude/hooks/session_manifest_coordinator.sh</code></p></li><li><p><code inline="">.claude/hooks/session_manifest_debounce.mjs</code></p></li><li><p><code inline="">.claude/hooks/generate_session_manifest_from_hook.mjs</code></p></li><li><p><code inline="">scripts/generate-session-manifest.mjs</code></p></li><li><p><code inline="">docs/schemas/agent-session-manifest.schema.json</code></p></li><li><p><code inline="">docs/dev/agent-run-report.md</code></p></li><li><p>integration tests</p></li></ul><h2>Verification Commands</h2><pre><code class="language-bash">uv run python3 scripts/agent_ops_inventory.py \
  --task-kind impl-review-loop-audit \
  --artifact-out tmp/agent_ops_inventory.json

uv run python3 scripts/agent_context_budget.py \
  --inventory tmp/agent_ops_inventory.json \
  --max-fragment-tokens 1000 \
  --max-total-tokens 10000

uv run --locked pytest \
  tests/test_agent_ops_inventory.py \
  tests/test_agent_context_budget.py \
  -q</code></pre><h2>Stop Conditions</h2><ul><li><p>新規Hookが必要になる。</p></li><li><p>raw transcriptの保存が必要になる。</p></li><li><p>provider token APIへの新規credentialが必要になる。</p></li><li><p>#1093のgeneratorと競合する第二実装が必要になる。</p></li><li><p>session manifestをapproval/routing authorityにする必要がある。</p></li></ul><pre><code>
---

## 推奨する実装順

1. **#88 reframe**  
   同一head二重レビューを直ちに防止します。

2. **#1909 contract revision**  
   Step 2/4 promptの全文再埋め込みを除去します。

3. **#2052 integration revision**  
   再読、重複command、same-head review、wait-only turnを観測・抑制します。

4. **#1093 → #1117 の依存整理**  
   静的inventoryの二重実装を避け、既存Hookとmanifestへ接続します。

この順なら、先に実際の迷走原因であるrouting順序を直し、その後にcontext量と観測性を改善できます。PR #2310 自体は変更せず、人間によるDraft解除・merge判断へ渡すのが妥当です。</code></pre></body></html><!--EndFragment-->
</body>
</html>

squne121 added a commit that referenced this pull request Aug 23, 2026
* 修正: impl-review-loop の独立VCを Step 4 起動前の current-head gate に接続する (#88)

PR #2310 で独立Issue VCがStep 4初回reviewer起動前に渡されず、同一headに対して
不要な二重review(REQUEST_CHANGES→PASS追加後APPROVE)が発生した。

adjudicate_vc_result.py に evaluate_step4_vc_gate() / Step4AdjudicationCache
を追加し、既存の VC_ADJUDICATION_RESULT_V1 判定ロジックを再利用したまま、
current head SHA・Issue body SHA256・literal command SHA256 のいずれかが
drift すれば adjudication を stale として扱い、pr-reviewer を起動しない
fail-closed gate を Step 4 起動直前に接続した。同一 binding tuple の
valid adjudication は同一 root invocation 内で再利用し、test-runner の
二重実行を避ける(新規 persistent ledger・publisher・hook は追加しない)。

test-runner の contract を read-only report(PRコメント投稿なし)に統一し、
Claude Code(.claude/agents/test-runner.md)と Codex CLI
(.codex/agents/test-runner.toml)で同一 semantic contract を明記した。
evidence-policy.md には TEST_VERDICT_MACHINE が diagnostics-only である旨を
明記した。

Closes #88

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* 修正: PR #2312 OWNER REQUEST_CHANGES を反映し Step4 current-head gate を LOOP_STATE ベースに再設計する (#88)

- VC_ADJUDICATION_RESULT_V1 を LOOP_STATE.vc_adjudication へ永続化し、TEST_VERDICT_MACHINE/v2 -> baseline_vc_preflight/v1 の canonical adapter (adapt subcommand) と step4-gate CLI subcommand (exit 0/1/2) を実運用経路へ接続する
- 各プロセス呼び出し間で状態が残らない Step4AdjudicationCache (in-memory object) を廃止し、LOOP_STATE 経由の再利用へ置き換える
- ordered command hashes の照合を sorted 比較から順序保持比較へ修正し、reorder-only の binding を stale として検出する negative test を追加する
- test-runner.md の read-only report 契約と矛盾する「PRコメントに明記」等の文言を修正する
- evaluate_step4_vc_gate() に schema_version / errors / rerun_required / evidence_complete / evidence_fresh の malformed 判定を追加する

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Test <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

推奨は コード修正から再開しない です。旧独立 VC と APPROVE は head 7824013587322a4398aa87a9bfde614f70011f99 に束縛されていますが、現在の head は 31a27b83b55bc9f02cc43d279d98be7da9820800 です。現在の head は main 取り込みの merge commit なので、旧 APPROVE は current-head evidence として再利用できません。旧 APPROVE 自体は blocker なしでした。

一方、PR 自身の差分は現在も Issue #2231 の Allowed Paths である2ファイルだけです。PR 本文の Runtime Verification Evidence は依然 78240135... を tested head として記載しているため、ここを current head で作り直すのが本筋です。

また current head の CI run 32616407756 は最新確認時点でまだ in_progress です。したがって、CI完了待ち + current-head 独立VC → 必要なら局所修正 → VC再実行 → current-head review の順序を推奨します。

以下をそのまま Claude Code に渡す形がよいです。

PR #2310 実装再開 — current-head 再検証・必要時のみ fix_delta

対象:

  • Repository: squne121/loop-protocol
  • PR: #2310
  • Linked Issue: #2231
  • 観測時 current head: 31a27b83b55bc9f02cc43d279d98be7da9820800
  • 観測時 base: 5f508ef9b1897aebb6b34d9b397633ed1c7687f5
  • 旧 independent VC / APPROVE head: 7824013587322a4398aa87a9bfde614f70011f99

目的は、PR #2310 の実装を current head から再開し、Issue #2231 の Acceptance Criteria を current final head に再束縛した状態で満たすこと。

旧 head 782401... に対する PASS / APPROVE を current head の成功証拠として再利用してはならない。

最重要ルール

  1. 必ず SubAgent を使用すること。
  2. SubAgent を起動しただけで成功扱いしてはならない。各 SubAgent の作業完了を待ち、最終結果を回収してから次の phase へ進むこと。
  3. 複数 SubAgent を並列起動した場合は、全 SubAgent の completion を join barrier とすること。1件でも未完了なら synthesis / 実装 / review に進まないこと。
  4. 最初からコードを変更しない。まず current-head reconciliation と独立 verification を行う。
  5. head が途中で変わった場合、それ以前の VC、CI 判定、review は stale とする。新しい head に対して必要な検証をやり直す。
  6. SKIP、fallback、認証不能、runtime unavailable を PASS に昇格しない。
  7. Issue 実装: worktree-agent-runtime-smoke の Claude-GPT launcher 経由 live causal-evidence 検証を実施し native Claude Code との比較 receipt を記録する #2231 の live body、PR live state、current diff を正本とする。過去コメントの状態を無条件に信用しない。
  8. 新規 Custom SubAgent、新規 enforcing Hook、新規 persistent ledger、新規 authorization packet 等をこの PR のために追加しない。
  9. destructive operation、秘密情報の要求・露出、Issue 実装: worktree-agent-runtime-smoke の Claude-GPT launcher 経由 live causal-evidence 検証を実施し native Claude Code との比較 receipt を記録する #2231 Allowed Paths 外の変更が不可避な場合のみ停止して報告する。
  10. merge は行わない。通常の調査・テスト・必要な修正・commit/push・PR本文更新・レビュー対応までは人間承認を待たず進めてよい。

Phase 0 — live state の再取得

最初に GitHub とローカル状態を fresh に確認する。

最低限確認するもの:

git status --short
git rev-parse HEAD
git fetch origin
gh pr view 2310 --json headRefOid,baseRefOid,headRefName,baseRefName,isDraft,mergeable,mergeStateStatus,statusCheckRollup
gh issue view 2231 --json state,title,body,comments
gh pr diff 2310 --name-only

期待値を hard-code して成功判定してはならない。

観測時点では current head は:

31a27b83b55bc9f02cc43d279d98be7da9820800

だが、実行開始時に head が変わっていた場合は live head を新しい H として採用し、以後すべて H に束縛する。

dirty worktree が存在する場合は内容を破壊しない。勝手に reset --hard / clean / checkout overwrite しない。

現在 PR #2310 自身の changed paths は次の2ファイルだけであることが期待される:

scripts/agent-ops/run_worktree_agent_runtime_smoke.py
scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py

live Issue #2231 の Allowed Paths と再照合すること。

Phase 1 — SubAgent 調査 wave

以下を既存 SubAgent で起動する。

可能なら並列実行してよいが、両方の完了を必ず待つこと。

SubAgent A: codebase-investigator

read-only。

調査対象:

目的:

「main 取り込みによって PR #2310 の実装に新しい修正が必要になったか」を判断する。

出力:

CODEBASE_RECONCILIATION:
  observed_head_sha: <H>
  changed_paths: [...]
  allowed_paths_compliant: true|false
  findings:
    - severity: P0|P1|P2
      evidence: ...
      recommendation: ...
  code_change_required: true|false

推測だけで code_change_required: true にしない。

SubAgent B: test-runner

read-only。

Issue #2231 の live body に記載されている literal Verification Commands を current head H に対して実行する。

少なくとも AC1〜AC5:

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac1_claude_gpt_positive_hook_correlated

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac2_native_positive_hook_correlated

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac3_negative_fixture_marker_only_insufficient

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac4_live_parent_only_negative_diagnostic

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac5_evidence_json_no_secrets_and_not_committed

ただし live Issue のコマンドが上記から変わっていた場合は live body の方を正本とする。

各コマンドの直前・直後に head H が変化していないことを確認する。

AC1 / AC2 / AC4 は genuine live runtime verification である。

以下を厳守:

  • Claude-GPT launcher 実行不能 → SKIP/blocked。PASS にしない。
  • native Claude Code 認証不能 → SKIP/blocked。PASS にしない。
  • fallback execution → PASS にしない。
  • raw receipt を repository に commit しない。
  • raw prompt、token、credential、tool transcript 全文を GitHub コメントやPR本文へ出さない。

出力:

CURRENT_HEAD_VC:
  tested_head_sha: <H>
  overall: PASS|FAIL|SKIP|BLOCKED
  fail_count: <n>
  skip_count: <n>
  results:
    - ac: AC1
      command_sha256: ...
      exit_code: ...
      status: PASS|FAIL|SKIP
      evidence_summary: ...

JOIN BARRIER

ここで SubAgent A と SubAgent B の両方が completion するまで待つこと。

Agent tool の invocation が返ったこと、hook の Start が観測されたこと、途中メッセージが来たことは completion ではない。

両者の final result を回収してからのみ Phase 2 へ進む。

Phase 2 — 修正が本当に必要か判定

ケース A: AC1〜AC5 がすべて PASS、codebase-investigator も blocker なし

コードを変更しない。

「実装再開」を理由に不要な差分を作らない。

Phase 3 の evidence refresh へ進む。

ケース B: concrete な PR 起因 regression がある

既存 implementation-worker SubAgent を起動する。

対象は Issue #2231 の Allowed Paths のみ。

現在想定:

scripts/agent-ops/run_worktree_agent_runtime_smoke.py
scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py

修正方針:

implementation-worker の完了を必ず待つこと。

完了後:

  1. diff を確認
  2. commit
  3. push
  4. fresh PR head H2 を取得
  5. 旧 H の VC は全て stale とする
  6. test-runner SubAgent をもう一度起動
  7. AC1〜AC5 を H2 に対して全件再実行
  8. test-runner の完了を待つ

一部 AC だけを再利用しない。

ケース C: environment blocker / SKIP

コードを変更して無理に PASS にしない。

例:

  • Claude-GPT auth unavailable
  • proxy unavailable
  • native Claude Code auth unavailable
  • required live runtime 自体が利用不能

Issue #2231 の fallback policy に従い BLOCKED/SKIP として報告する。

ケース D: Allowed Paths 外の修正が必要

勝手に scope を広げない。

具体的な原因、必要 path、なぜ #2231 内で直せないかを報告して停止する。

Phase 3 — CI と current-head evidence の再束縛

current final head Hfinal を確定する。

PRの current CI を terminal state まで確認する。

モデルが何度も手動 polling してコンテキストを浪費するのではなく、既存の wait helper / gh pr checks --watch 等の適切な待機手段があれば利用する。

CI が pending の間に「green」と推定しない。

CI failure があれば:

  • PR差分起因か
  • current main の既存 failure か
  • flaky/infrastructure か

を証拠ベースで分類する。

Phase 4 — PR本文 Runtime Verification Evidence の更新

現在の PR 本文には old head:

7824013587322a4398aa87a9bfde614f70011f99

に束縛された Runtime Verification Evidence が残っている。

current-head VC が PASS した場合、PR本文を Hfinal の証跡へ更新する。

要件:

Phase 5 — current-head independent adjudication

現在 main には Issue #88 / PR #2312 由来の current-head VC gate が入っているため、その現行フローを利用する。

重要:

  • test-runner は read-only。
  • legacy TEST_VERDICT_MACHINE comment を approval authority として扱わない。
  • current VC_ADJUDICATION_RESULT_V1 を current head / Issue body SHA / ordered literal command hashes に束縛する。
  • head/body/commands の drift があれば stale とし、再検証する。
  • old 782401... の adjudication は current Hfinal に流用しない。

current-head nonblocking VC が成立してからのみ review phase へ進む。

Phase 6 — pr-reviewer SubAgent

current-head VC が nonblocking で、必要な CI が terminal になった後、既存 pr-reviewer SubAgent を起動する。

レビュー対象:

pr-reviewer の completion を必ず待つこと。

途中結果で終了しない。

reviewer = REQUEST_CHANGES

blocker が PR #2310 scope 内なら:

  1. implementation-worker SubAgent を起動
  2. 完了を待つ
  3. commit / push
  4. 新 head を取得
  5. current-head VC を全件再実行
  6. test-runner completion を待つ
  7. CI を確認
  8. pr-reviewer を再起動
  9. completion を待つ

head が動くたびに旧 evidence を stale 化する。

reviewer = APPROVE

次を最終確認:

満たせば Draft のまま、人間による最終 Draft 解除 / merge 判断へ渡す。

自動 merge は行わない。

やらないこと

最終報告フォーマット

作業終了時は次を簡潔に報告する。

PR_2310_RESUME_RESULT:
  final_head_sha: <sha>
  base_sha: <sha>
  subagents:
    codebase_investigator: completed|failed
    test_runner_initial: completed|failed
    implementation_worker: not_needed|completed|failed
    test_runner_final: completed|failed
    pr_reviewer: completed|failed
  join_barriers_satisfied: true|false
  changed_paths: [...]
  implementation_delta:
    required: true|false
    summary: ...
  current_head_vc:
    AC1: PASS|FAIL|SKIP
    AC2: PASS|FAIL|SKIP
    AC3: PASS|FAIL|SKIP
    AC4: PASS|FAIL|SKIP
    AC5: PASS|FAIL|SKIP
    fail_count: <n>
    skip_count: <n>
  ci:
    status: PASS|FAIL|PENDING
    failures: [...]
  pr_body_runtime_evidence:
    tested_head_sha: <sha>
    refreshed: true|false
  review:
    verdict: APPROVE|REQUEST_CHANGES|BLOCKED
    reviewed_head_sha: <sha|null>
    blockers: [...]
  ready_for_human_draft_release_and_merge: true|false

「SubAgent を開始した」ではなく、全必須 SubAgent の完了を確認したことを最終報告で明示すること。

このプロンプトでの重要点は、旧 APPROVE を捨てるのではなく historical evidence として保持しつつ、current head には一切流用しないことです。current-head VC がそのまま全 PASS なら、実装 worker は起動せず、PR本文更新と再レビューだけで終えるのが最小かつ適切です。

@squne121

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

current-head 再検証について

旧 approved/VC head 7824013587...11f99 から main 取り込みにより現在の head 31a27b83b55bc9f02cc43d279d98be7da9820800 へ進んだため、本 PR の実装を current head から再開し、旧 head の証跡を current head へ再束縛した。

Mergeability

  • mergeable=MERGEABLE, merge_state_status=BLOCKED(current-head required-CI evaluator の判定に委ねる。人間の Draft 解除/レビュー承認待ちとして扱う)

Current-head VC binding

Required CI

  • wait_ci_checks.py による判定: status=passed(head 31a27b83b55bc9f02cc43d279d98be7da9820800)
  • deploy-pr の cancelled は required set 外であり non-blocking

Allowed Paths

PR本文

  • Runtime Verification Evidence セクションを current head の証跡(tested_head=31a27b83...)へ更新済み

Blockers

(なし)

verdict: APPROVE
reviewed_head_sha: "31a27b83b55bc9f02cc43d279d98be7da9820800"
blockers: []
warnings: []

@squne121
squne121 marked this pull request as ready for review August 23, 2026 04:20
@squne121

Copy link
Copy Markdown
Owner Author

確認した限り、まず PR #2310 のコードを修正するべきではありません。今回の3件は独立した3障害ではなく、1件の Python live-network test 失敗が上位ゲートへ伝播しています。

32617957047 では python-test-core だけが実テストで失敗し、python-test はその aggregate policy、ci-verdict-summary は required-check 結論の検証で連鎖的に失敗しています。それ以外の build / lint / typecheck / e2e 等は green です。

根因になったテストはこれです。

test_ac5_ac6_skill_runtime_exec_with_human_context_live_subprocess_resolves_anchor_via_credentialless_authority

実際の失敗出力は STATUS: environment_failure / BLOCKERS: GH_API_FAILURE。PR #2310 自身が変更している causal-evidence runner ではなく、既存の issue-refinement-loop → credentialless GitHub REST の live subprocess test です。しかもこのテストは、ネットワーク障害時に rate_limited / upstream_environment_failure / transport_connectivity_failure が stdout/stderr に現れたときだけ SKIP する実装です。 一方 production preflight 側は environment failure の reason_code を構造化 result に保持する設計になっています。 このため、実際には transient failure なのに compact stdout が GH_API_FAILURE までしか露出せず、テスト側が SKIP 判定できない可能性を重点的に調べる価値があります。

さらに、credentialless transport 自体が unauthenticated GitHub REST を使う設計で、rate-limit / 5xx / connectivity を明示的に別クラスへ分類しています。 直前にマージされた PR #2314 の Python suite は同じ既存テスト群を通過しているため、現時点では PR #2310 の regression より transient external failure の蓋然性が高いです。

ただしもう1点あります。PR #2310 の現 head は 5f045fa1b3b8ea1e056f9bc800d8667aca9798c5 です。 前回の current-head APPROVE / independent VC は 31a27b83b55bc9f02cc43d279d98be7da9820800 に束縛されています。 したがって CI が rerun で green になっても、Issue #2231 の live VC → independent adjudication → review は 5f045fa... に対して再実行する必要があります。

推奨順序

  1. current head を再確認し、勝手にコード変更しない。
  2. SubAgent に「CI forensic」「credentialless error-path」「PR scope/evidence」の3調査を分担させ、全SubAgent完了を待ってから判断する。
  3. 同じ head の failed jobs を1回だけ rerunする。
  4. green なら今回の CI failure は transient と扱い、実装: worktree-agent-runtime-smoke に JSON 出力オプションを追加し claude-gpt launcher 経由の live causal-evidence 検証を行う #2310 は変更せず current-head VC/review へ進む。
  5. 同じ GH_API_FAILURE が再現するなら、実装: worktree-agent-runtime-smoke に JSON 出力オプションを追加し claude-gpt launcher 経由の live causal-evidence 検証を行う #2310 の Allowed Paths を汚さない。Issue 実装: worktree-agent-runtime-smoke の Claude-GPT launcher 経由 live causal-evidence 検証を実施し native Claude Code との比較 receipt を記録する #2231 の write scope は runner とその専用 test の2ファイルに限定されています。
  6. 再現時は別 Issue で、「structured reason_code があるのに live test の transient 判定が stdout substring 依存」という設計差を直す。単純に GH_API_FAILURE 全体を SKIP に追加するのは、404/auth/実装バグまで隠し得るので避ける。

Claude Code には以下を渡すのがよいです。

PR #2310 CI failure triage → current-head 再検証

Repository: squne121/loop-protocol
PR: #2310
Linked Issue: #2231

対象 CI:

  • run: 32617957047
  • python-test-core: job 97141657017
  • python-test: job 97142314313
  • ci-verdict-summary: job 97142337301

観測時の PR head:

5f045fa1b3b8ea1e056f9bc800d8667aca9798c5

ただし、作業開始時に GitHub の live state を再取得し、head が変わっていれば新しい head を H とすること。以降の CI / VC / review evidence はすべて H に束縛すること。

Objective

PR #2310 の current head に対して、

  1. CI failure の真因を切り分ける
  2. PR 実装: worktree-agent-runtime-smoke に JSON 出力オプションを追加し claude-gpt launcher 経由の live causal-evidence 検証を行う #2310 固有の regression でなければ不要なコード変更をしない
  3. 必要な場合のみ最小修正する
  4. required CI を green にする
  5. Issue 実装: worktree-agent-runtime-smoke の Claude-GPT launcher 経由 live causal-evidence 検証を実施し native Claude Code との比較 receipt を記録する #2231 の Verification Commands を current final head に再束縛して独立実行する
  6. current-head review まで完了させる

こと。

旧 head に対する PASS / APPROVE / VC を current head の証拠として流用してはならない。

Mandatory SubAgent barrier

必ず SubAgent を使用すること。

最初に以下の独立調査を SubAgent へ委譲する。

SubAgent A — CI forensic

調査対象:

  • run 32617957047
  • jobs 97141657017, 97142314313, 97142337301
  • failing test の full traceback
  • 同時 run の他 job conclusions
  • 直近の同テストを含む成功 CI
  • PR head / base / merge ref

判定すること:

  • primary failure
  • cascading failures
  • deterministic regression / flaky test / external environment failure のどれが最も整合するか
  • rerun が妥当か

SubAgent B — credentialless error-path tracer

以下を実コードから end-to-end で追跡すること。

skill_runtime_exec.py
  -> command_registry.py
  -> run_refinement_preflight.py
  -> github_credentialless_read.py
  -> GitHub REST

特に:

GH_API_FAILURE
rate_limited
upstream_environment_failure
transport_connectivity_failure
reason_code
environment_failure

を検索する。

確認事項:

  • github_credentialless_read.py が HTTP 403/429/5xx/DNS/timeout をどう分類するか
  • _fetch_issue() / _fetch_issue_comments() / _fetch_single_comment() から、その分類がどの形式で上位へ渡るか
  • run_refinement_preflight.py の structured reason_code と compact stdout の差
  • failing test
    test_ac5_ac6_skill_runtime_exec_with_human_context_live_subprocess_resolves_anchor_via_credentialless_authority
    が何を見て transient failure を SKIP しているか
  • 実際の transient reason が structured artifact に存在するのに stdout で失われていないか
  • GH_API_FAILURE 全体を SKIP にする修正が genuine regression を false-green にしないか

SubAgent C — PR scope / evidence auditor

確認すること:

特に、CI failure を直すために Issue #2231 の Allowed Paths 外を #2310 に混入させる必要があるかを判断すること。


親エージェントは、上記で起動した全 SubAgent の completion と final result を受領するまで、コード変更・commit・push・CI rerun・最終判断へ進んではならない。

1つでも未完了なら synthesis を開始しないこと。

SubAgent の結果を推測で補完してはならない。

全件完了後に、親が live GitHub state と照合して synthesis すること。

Known observation to verify, not blindly trust

現在観測されている primary failure は:

scripts/agent-guards/tests/test_isolated_anchor_single_authority.py::
test_ac5_ac6_skill_runtime_exec_with_human_context_live_subprocess_resolves_anchor_via_credentialless_authority

であり、production subprocess の stdout は概ね:

STATUS: environment_failure
NEXT_ACTION: fix_environment
BLOCKERS:
  - GH_API_FAILURE

となり、

raw_issue_snapshot.json

が生成されなかったため assertion failure している。

一方、python-test と ci-verdict-summary はこの upstream python-test-core failure の aggregate failure である可能性が高い。

必ず live logs で確認すること。

Phase 1 — live state / scope

最初に最低限以下を確認する。

gh pr view 2310 \
  --json headRefOid,baseRefOid,headRefName,baseRefName,isDraft,mergeable,mergeStateStatus,statusCheckRollup

gh issue view 2231 --json state,title,body,comments

gh pr diff 2310 --name-only

gh run view 32617957047

必要な job log も取得する。

dirty worktree がある場合は破壊しない。

禁止:

git reset --hard
git clean -fd
未確認ファイルの削除
force push
既存ユーザー作業の上書き

Phase 2 — rerun decision

SubAgent 全件完了後の evidence が、

を支持する場合、コードを変更せず、同一 head H に対する failed jobs rerun を1回だけ実行する。

例:

gh run rerun 32617957047 --failed

その後は run/checks を polling し、terminal を離脱せず最終 conclusion まで確認する。

「何回か rerun すればそのうち通る」を解決策にしてはならない。

Branch A — rerun が green

rerun で python-test-core、python-test、ci-verdict-summary が green になった場合:

Issue body を authoritative source とし、コマンドを手で改変しない。

現時点で想定される selectors は以下だが、必ず live Issue body と照合すること。

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac1_claude_gpt_positive_hook_correlated

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac2_native_positive_hook_correlated

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac3_negative_fixture_marker_only_insufficient

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac4_live_parent_only_negative_diagnostic

uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_live_causal_evidence.py -k test_ac5_evidence_json_no_secrets_and_not_committed

Independent VC

ここでも test-runner SubAgent を使用する。

  • implementation/self-report と独立した SubAgent に VC を実行させる
  • head SHA
  • Issue contract/body hash
  • literal command hashes
  • PASS / FAIL / SKIP
  • runtime evidence

を current H_final に束縛する。

test-runner SubAgent の完了と final result を待つこと。
完了前に reviewer を起動してはならない。

SKIP を PASS に昇格しない。
fallback を成功扱いしない。

必要なら PR body の Runtime Verification Evidence を H_final の evidence へ更新する。

更新後に head が変わった場合は、新 head を採用し VC を stale として再評価すること。

Current-head review

VC が nonblocking PASS になった後だけ pr-reviewer SubAgent を起動する。

pr-reviewer には:

  • current Issue contract
  • current head
  • current diff
  • current required CI
  • current independent VC
  • relevant review/comments

を渡す。

pr-reviewer SubAgent の completion / final verdict を必ず待つこと。

APPROVE ならそこで終了。
勝手に merge はしない。

Branch B — rerun でも同じ failure

同じ

GH_API_FAILURE

または同一 credentialless live path の failure が再現した場合は、単なる rerun で閉じない。

まず targeted reproduction を実施する。

uv run --locked pytest \
  scripts/agent-guards/tests/test_isolated_anchor_single_authority.py::test_ac5_ac6_skill_runtime_exec_with_human_context_live_subprocess_resolves_anchor_via_credentialless_authority \
  -vv

必要に応じて credentialless transport の既存 targeted tests も実行する。

この段階でも #2310 の Allowed Paths 外を同ブランチで修正してはならない。

修正判断

以下を区別すること。

Transient environment

例:

  • rate limit
  • HTTP 5xx
  • DNS / connection / timeout

この場合、production structured result が正しい reason を既に持つなら、live test がその structured evidence を参照せず stdout substring に依存していることが問題ではないか検討する。

Genuine failure

例:

  • unexpected authentication dependency
  • public canonical resource の 404
  • bare forbidden 403
  • invalid/malformed contract
  • wrong anchor
  • credentialless authority bypass
  • gh CLI fallback
  • production code exception

これは SKIP にしてはならない。

禁止する安易な修正

次のような修正を証拠なしで行わない。

if "GH_API_FAILURE" in stdout:
    pytest.skip(...)

GH_API_FAILURE は広すぎ、genuine failure まで false-green にする可能性がある。

別 Issue として扱う条件

修正対象が Issue #2231 Allowed Paths 外、たとえば:

scripts/agent-guards/github_credentialless_read.py
scripts/agent-guards/tests/test_isolated_anchor_single_authority.py
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py

等になる場合、PR #2310 に混ぜない。

再現証拠と root cause をまとめた別 Issue を作成し、以下を記載する。

  • exact failing job/run
  • exact failing nodeid
  • head/base SHA
  • stdout/stderr の sanitized excerpt
  • structured environment failure reason が取得可能か
  • compact stdout と structured artifact の observability gap
  • transient/genuine の分類境界
  • false-green にしない acceptance criteria
  • deterministic tests
  • live test の役割

別修正が必要なら別 branch / PR とする。
PR #2310 の feature diff を無関係な CI-harness 修正で汚染しない。

Final verification

最終的に以下を報告すること。

PR_2310_RECOVERY_RESULT_V1:
  initial_head: <sha>
  final_head: <sha>
  root_failure:
    job: <job>
    test: <nodeid>
    classification: transient_external | deterministic_regression | harness_observability_bug | other
  subagents:
    started: <n>
    completed: <n>/<n>
    all_completed_before_synthesis: true
  rerun:
    performed: true|false
    result: pass|fail|not_needed
  code_change_on_pr_2310:
    performed: true|false
    paths: []
    reason: <text>
  required_ci:
    status: pass|fail
  current_head_vc:
    status: PASS|FAIL|SKIP
    tested_head_sha: <sha>
    fail_count: <n>
    skip_count: <n>
  current_head_review:
    verdict: APPROVE|REQUEST_CHANGES|NOT_RUN
    reviewed_head_sha: <sha|null>
  follow_up_issue:
    created: true|false
    number: <number|null>
  blockers: []

作業途中の古い PASS、旧 head の VC、旧 APPROVE を current-head evidence として流用しないこと。

今回のケースでは、**「failed jobs を1回 rerun → green なら #2310 無変更 → 5f045fa... に VC/review を再束縛」**が最短経路です。再現した場合だけ credentialless error-path の別 Issue 化へ進むのが、PR のスコープと CI 品質の両方を守れます。

@squne121

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE(CI failure triage → current-head 再検証)

CI failure の真因

run 32617957047(head 5f045fa1b3b8ea1e056f9bc800d8667aca9798c5)で python-test-core/python-test/ci-verdict-summary が failing していた。

実施した対応

PR #2310のコード変更は行っていない。

  1. gh run rerun 32617957047 --failed → python-test-core/python-testはPASSしたが、ci-verdict-summaryが別の既知問題(部分rerun特有のsentinel run_attempt不整合)でFAIL。
  2. gh run rerun 32617957047(full rerun)→ run全体がconclusion=successに到達。
  3. PR本文編集トリガーで新規CI run 32619829615 が走ったため、そちらもterminalまで待機し確認: conclusion=success。

Current-head 再検証(head 5f045fa1b3b8ea1e056f9bc800d8667aca9798c5)

  • Required CI: typecheck/lint/test/build/python-test/validate-generated-artifact 全てPASS(branches/main/protection/required_status_checks.contextsで確認済み)。visual-impact-policy-trustedは非required(既存 実装: visual-impact-trusted-consumer.yml の gh api --output 未対応バグを修正する #2076 track)。
  • mergeStateStatus: CLEAN(CI green化に伴いBLOCKEDから好転)。
  • Independent VC: test-runner SubAgentがIssue #2231のlive Verification Commands(AC1〜AC5)をcurrent head Hに対し独立実行、全てPASS(SKIP/FAIL 0件)。AC1/AC2/AC4はgenuine live実行でcausal_evidence_source: hook_id_correlated(AC1/AC2)・marker_only_insufficient(AC3/AC4想定通り)を観測。run_id(32c6f75f1c20/35e389af90ad/ef7b0ef1fdac)は新規生成分。
  • PR本文: Runtime Verification Evidenceをcurrent head Hの証跡へ更新済み。
  • pr-reviewer: APPROVE、blockers=0。
verdict: APPROVE
reviewed_head_sha: "5f045fa1b3b8ea1e056f9bc800d8667aca9798c5"
blockers: []
warnings:
  - "visual-impact-policy-trusted check は required_status_checks 対象外(#2076で既存トラック)"

マージは人間判断に委ねる。

@squne121
squne121 merged commit 6f2289d into main Aug 23, 2026
74 of 78 checks passed
@squne121
squne121 deleted the worktree-issue-2231-claude-gpt-live-causal-evidence branch August 23, 2026 05:34
squne121 added a commit that referenced this pull request Aug 23, 2026
…eベースに改修する (#2319)

* fix: test_isolated_anchor_single_authority のtransient判定を構造化reason_codeベースに改修する (#2317)

PR #2310 CI failure triage(run 32617957047)で発覚した、既存の broad substring
OR-chain(`"rate_limited" in stdout or ... or ... in result.stderr`)が
production 側の `BLOCKERS: GH_API_FAILURE` genuine failure を見落とし
transient skip として false-green 化しうる問題を修正する。

- run_refinement_preflight.py: _build_compact_stdout() に、
  status == "environment_failure" のときのみ REASON_CODE/SOURCE/OPERATION
  の3行を一貫して出力する最小限の追加を行う(#2257 AC4 未実装差分の解消)。
- test_isolated_anchor_single_authority.py: stdout の REASON_CODE: 行を
  厳密パースし、値が closed set
  {rate_limited, upstream_environment_failure, transport_connectivity_failure}
  の完全一致の場合にのみ True を返す
  _is_transient_environment_failure_reason_code() predicate を新設し、
  live subprocess テストの skip 判定を旧 substring OR-chain から置き換える。
  stderr は判定ソースとして使用しない。
- test_refinement_preflight.py: formatter (_build_compact_stdout()) の
  contract unit test を追加する(既存 TestBuildCompactStdout に集約)。

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: PR #2319 review fix_delta iteration 1 (Issue #2317)

OWNER REQUEST_CHANGES on PR #2319 (4 blockers):
- Fix schema-invalid source/operation fixture values in the newly added
  formatter tests (github_api/fetch_issue -> credentialless_transport/
  read_issue, the values valid for status: environment_failure per
  refinement_preflight_result/v1 schema).
- Harden _stdout_indicates_transient_environment_failure() to also require
  STATUS: environment_failure to appear exactly once, in addition to the
  pre-existing REASON_CODE exactly-once check.
- Mark the two real-network tests with @pytest.mark.github_live so they are
  excluded from the default python-test run, and generalize the marker's
  pyproject.toml description beyond "gh CLI write access" to cover
  unauthenticated live GitHub REST reads too.
- Remove the near-duplicate formatter-contract tests and the
  _load_run_refinement_preflight_module() helper from
  test_isolated_anchor_single_authority.py; test_refinement_preflight.py
  already owns formatter contract testing.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Test <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant