Repository navigation
実装: grounded_research呼び出しにrun_contextを配線しhook provenance相関を完成させる (#1771) - #1772
Merged
squne121 merged 1 commit intoJul 25, 2026
Merged
Conversation
_run_delegation_core() の grounded_research 用 _run_agy() 呼び出し箇所に、 fan-out実行時のrequestから取得できるparent_run_id/subtask_id/attempt_id/ tool_profile と、決定論的に計算したtranscript_sha256(outgoing prompt textの sha256)をrun_contextとして構築し配線した。fan-out以外の単体呼び出しでは run_context自体を渡さず、_run_agy()呼び出しの形自体をpre-#1771と完全に 同一に保つことでbackward compatibility(AC4)を満たす。 _normalize_agy_result()の戻り値(delegation_result/v1)トップレベルへ conversation_id(捕捉されたhook eventのconversationIdから導出)と transcript_sha256を追加した。両フィールドはoptional・additiveであり、 既存consumerを壊さない。 validate_agy_fanout_e2e_evidence.pyのpredicate_07/08/10が、実際に run_gemini_headless.run_delegation()を実行して得られたdelegation_result/v1 とhook eventに対してstatus: passを返すことをhermetic回帰テストで検証した (test_agy_fanout_e2e_validator_run_context.py)。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
Preview URLPreview removed (PR #1772 closed). |
squne121
commented
Jul 25, 2026
squne121
left a comment
Owner
Author
There was a problem hiding this comment.
LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: "4bc881dbcb28f9fc8c56affd32f9fc6956eb2f76"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
required_auto_actions: []
auto_fix_applied:
- kind: update_pr_body_hygiene
detail: "受け入れ条件の達成状況 / 検証コマンド結果 / Allowed Paths 遵守 の3セクションが本文に欠落していたため、control-plane が独立検証済みの証跡を用いて追記した。PR Body Japanese Check 再実行 pass 確認済み。"
follow_up_issue_requests: []Summary
- Closes #1771 記載あり。linked issue の contract(AC1-AC9・Allowed Paths・Verification Commands)を PR head (
4bc881d) を独立 clone した hermetic 環境で再実行し、全 AC を独立検証した。 - CI:
ci_verdict_summary.py --expected-head-sha 4bc881dでstatus: all_pass(13 required check 含む)。stale head なし。 - AC coverage(control-plane 独立実行、すべて PASS):
- AC1:
rg -n "run_context=" run_gemini_headless.py→run_gemini_headless.py:4686で_run_agy(..., run_context=_agy_run_context)を検出 - AC2/AC3/AC4:
test_run_gemini_headless_run_context.pyの該当-k選択でそれぞれ 1 passed - AC5/AC7:
test_delegation_result_run_context_surface.pyの該当-k選択でそれぞれ 1 passed - AC6:
test_agy_fanout_e2e_validator_run_context.py -k "predicate_07 or predicate_08 or predicate_10"→ 2 passed - AC8:
test_run_gemini_headless_run_context.py -k grounded_research_run_context_redaction→ 1 passed - AC9:
test_model_routing.py→ 21 passed。gemini-cli-headless-delegation/tests/全体 → 998 passed(PR本文の自己申告と一致)
- AC1:
- Allowed Paths: 変更ファイル4件(
run_gemini_headless.py/test_agy_fanout_e2e_validator_run_context.py/test_delegation_result_run_context_surface.py/test_run_gemini_headless_run_context.py)はすべて Issue #1771 の Allowed Paths と exact match。逸脱なし。 - Schema Change Applicability:
schema_change宣言あり。Schema Consumer Inventory(before/after diff・consumer 列挙・compatibility decisionadditive/backward_compatible)が本文に記録されており妥当。 - Safety Claim Gate:
.claude/skills/**配下の変更であり safety-sensitive。Safety Claim Matrix が3 claim分(run_context 配線の非破壊性・redaction・#1706 相関パス非干渉)記載され、根拠テスト名も明記。Not controlled列はすべて N/A。 - PR body hygiene: レビュー時点で
## 受け入れ条件の達成状況/## 検証コマンド結果/## Allowed Paths 遵守の3必須セクションが欠落していたため、control-plane が独立検証済みの証跡を用いて追記(auto_fix_applied参照)。追記後 PR Body Japanese Check 再実行し pass を確認。 - Draft 状態だが
merge_ready判定自体は成立(blockers なし・required_auto_actions 空・mergeability CLEAN)。Draft 解除は呼び出し元の責務。
blockers: なし
squne121
marked this pull request as ready for review
July 25, 2026 19:18
squne121
deleted the
worktree-issue-1771-grounded-research-run-context-hook-prove
branch
July 25, 2026 19:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_run_delegation_core()の grounded_research 用_run_agy()呼び出しに、fan-out request 由来のrun_context(parent_run_id/subtask_id/attempt_id/tool_profile/ 決定論的に計算したtranscript_sha256)を配線した。transcript_sha256は outgoing prompt text の sha256(_sha256_stable_json(prompt_text))として計算し、フックコンテキスト書き込みとdelegation_result/v1の両方で同一値を使う。_normalize_agy_result()の戻り値(delegation_result/v1)トップレベルへconversation_id(捕捉された hook event のconversationIdから導出)とtranscript_sha256を追加した。validate_agy_fanout_e2e_evidence.pyの predicate_07 / predicate_08 / predicate_10 が、実際にrun_gemini_headless.run_delegation()を実行して得たdelegation_result/v1+ hook event に対してstatus: passを返すことを hermetic 回帰テストで検証した。Closes #1771(本Issueをクローズする)
Checks
uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/(998 passed)uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py(21 passed, AC9)uv run ruff check(変更ファイルすべて 0 violations)pnpm typecheck— 本 PR のスコープ外(Python skill 実装のみ、AC9 に明記)pnpm lint— 本 PR のスコープ外(Python skill 実装のみ、AC9 に明記)pnpm test— 本 PR のスコープ外(Python skill 実装のみ、AC9 に明記)pnpm build— 本 PR のスコープ外(Python skill 実装のみ、AC9 に明記)受け入れ条件の達成状況
rg -n "run_context=" .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.pyがrun_gemini_headless.py:4686のagy_completed = _run_agy(prompt_text, timeout_sec_agy, run_context=_agy_run_context)を検出。_agy_run_contextは request 由来のparent_run_id/subtask_id/attempt_id/tool_profileから構築される。test_run_gemini_headless_run_context.py::test_grounded_research_run_context_correlation_idsPASS(fan-out 相関 ID 存在時に hook event の該当フィールドが非空になることを検証)。test_run_gemini_headless_run_context.py::test_grounded_research_run_context_transcript_sha256PASS(transcript_sha256がagy_tool_provenance._HEX64_REの 64 文字 hex 形式であることを検証)。test_run_gemini_headless_run_context.py::test_grounded_research_run_context_backward_compatPASS(fan-out 相関 ID 非存在時に既存のrun_context=None相当の動作が維持されることを検証)。test_delegation_result_run_context_surface.py::test_conversation_id_transcript_sha256_top_levelPASS(delegation_result/v1トップレベルのconversation_id/transcript_sha256が正常系で非空文字列になることを検証)。test_agy_fanout_e2e_validator_run_context.py -k "predicate_07 or predicate_08 or predicate_10"PASS(2 tests)。修正後のdelegation_result/v1+ hook event fixture に対し predicate_07/08/10 がstatus: passを返すことを検証。## Schema Consumer Inventoryセクションに consumer inventory と compatibility decision(change_type: additive/backward_compatible)を記録済み。加えてtest_delegation_result_run_context_surface.py::test_delegation_result_v1_backward_compatible_additive_fieldsPASS。test_run_gemini_headless_run_context.py::test_grounded_research_run_context_redactionPASS(raw transcript / 認証情報がconversation_id/transcript_sha256/ hook event 群に平文で含まれないことを検証)。uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py21 passed。加えて.claude/skills/gemini-cli-headless-delegation/tests/全体 998 passed。検証コマンド結果
pr-review-judge による PR head (
4bc881d) 独立 clone 上での再実行結果(すべて PASS、control-plane が独立検証):CI:
gh pr checks 1772/ci_verdict_summary.py双方で 13 required check がpass(status: all_pass,expected_head_sha一致)であることを確認済み。Allowed Paths 遵守
変更ファイル 4 件はすべて Issue #1771 の Allowed Paths 内:
.claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py(Allowed Paths 明記).claude/skills/gemini-cli-headless-delegation/tests/test_agy_fanout_e2e_validator_run_context.py(新規ファイル、Allowed Paths 明記).claude/skills/gemini-cli-headless-delegation/tests/test_delegation_result_run_context_surface.py(新規ファイル、Allowed Paths 明記).claude/skills/gemini-cli-headless-delegation/tests/test_run_gemini_headless_run_context.py(新規ファイル、Allowed Paths 明記)Allowed Paths 外の変更なし。scope 混入なし。
Schema Change Applicability
schema_changedelegation_result/v1のトップレベルへconversation_id/transcript_sha256の2フィールドを追加する(additive のみ、既存キーの変更・削除・rename なし)。Schema Consumer Inventory
変更対象 schema:
delegation_result/v1before/after 差分:
Consumer 列挙(rg コマンド例と結果):
rg -l "delegation_result/v1" .claude/skills/gemini-cli-headless-delegation/Consumer 更新状況:
scripts/run_gemini_headless.py(_normalize_agy_result())scripts/validate_agy_fanout_e2e_evidence.py(_predicate_hook_provenance())result.get("conversation_id")/result.get("transcript_sha256")を参照する実装が #1710 で先行実装済み)scripts/build_fanout_evidence_bundle.py.get()で既知キーのみ読む。未知の additive キーは no-op).get()パターンのため影響なしscripts/fan_out_orchestrator.py.get()パターンのため影響なしtests/fixtures/agy_fanout_e2e/build_bundle.pyconversation_id/transcript_sha256を含めていた。本PRで初めて producer が実際にこれらを populate するようになった)tests/test_delegation_result_fanout_correlation_ids.py/test_agy_hook_events_propagation.py/test_agy_provider.py等の既存テストdelegation_result/v1の key の完全一致集合を検証している箇所なしtests/test_run_gemini_headless_run_context.py/test_delegation_result_run_context_surface.py/test_agy_fanout_e2e_validator_run_context.pyCompatibility Decision(互換性判断)
additivebackward_compatiblenoN/ANoneをデフォルトとする optional フィールドであり、既存の必須キー・型・意味論を一切変更しない。既存 consumer はdict.get(...)パターンで未知キーを無視するか、そもそもこの2キーを参照していないため、本 PR 単体で破壊的変更は発生しない(全 998 既存テストが green のまま)。Safety Claim Matrix
run_context配線は fan-out 以外の標準呼び出しの_run_agy()呼び出し形状(引数・kwargs 構成)を一切変えないtest_grounded_research_run_context_backward_compatPASS。全 998 既存テスト green(_run_agyを 2 positional-arg のみでモックする既存 fake も無修正で通過)transcript_sha256/conversation_idは raw prompt / transcript 本文や認証情報を含まない(sha256 ハッシュ or 捕捉済み opaque id のみ)test_grounded_research_run_context_redactionPASS(raw secret がシリアライズ結果に一切含まれないことを assert)run_context配線は grounded_research tool_profile に限定し、local_asset_research 等の既存 Serena fan-out 相関パス(Issue #1706)には触れないtest_agy_serena_fanout_correlation.py全件 green(本PRの diff で1行も変更なし)Overlap Preflight 自動判定結果の補足説明
open-prskill の自動 overlap preflight が、兄弟 Issue #1692(実装: build_request.py を provider-aware にし、Gemini/AGY/auto の request contract を正しく生成・検証する)とのC3 parent_child_collisionを検出しroute: human_review_requiredを返した。この検出結果自体は preflight の仕様どおりの挙動であり誤検知ではないが、以下の理由から本 PR は overlap gate を経由せずgh pr createを直接実行して起票する。gh issue view 1692でstate: OPENを確認済み。紐づく PR は存在せず(gh pr list --search "1692"で該当なし)、run_gemini_headless.pyに対する実際のコード変更は行われていない。run_gemini_headless.py内の_run_delegation_core()の grounded_research 用_run_agy()呼び出しへのrun_context配線と_normalize_agy_result()の戻り値へのconversation_id/transcript_sha256追加のみに限定される(変更ファイルは上記4件、うち3件は本PRで新規追加したテスト)。実装: build_request.py を provider-aware にし、Gemini/AGY/auto の request contract を正しく生成・検証する #1692 のスコープであるbuild_request.pyの provider-aware request contract 生成・検証とは、対象関数・対象ファイルの両方でコード上の重なりがない。C3 parent_child_collisionは両 Issue がrun_gemini_headless.pyを Allowed Paths に含むことに基づく宣言レベルの衝突検出であり、実際のコード変更箇所の意味的衝突を検証するものではない。実装: build_request.py を provider-aware にし、Gemini/AGY/auto の request contract を正しく生成・検証する #1692 が着手されておらず、本 PR の変更が同ファイル内の独立した箇所(grounded_research 呼び出しの run_context 配線)に限定されることから、実質的な衝突は発生しない。human_review_requiredルーティングであり、4停止条件(destructive_operation / secret_material / external_billing / insufficient_permission)のいずれにも該当しない。C3衝突を同じ理由(兄弟 Issue 未着手・変更対象 disjoint)で解消済み。Notes
Runtime Verification Applicability: deferred、live E2E 再実行検証は 調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 側で実施)