Skip to content

実装: fan-out timeout/cancellation テストを readiness 同期と責務分離で決定論化する #2371

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #2366 CI stabilization (Issue #2308) の post-merge-cleanup で発見した flake なテスト設計を、readiness 同期と責務分離で決定論化する(OWNER 敵対的レビュー reframe_in_place, 2026-08-28)"
change_kind: code

Parent Issue

none

Parent Goal Ref

  • Goal: 単独改善(parent なし)
  • Desired Destination: N/A

Current Validated Scope

  • .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py と .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py の overall timeout / cancel_event / fanout / process_exit を扱うテストのうち、time.sleep ベースの固定タイムアウトへの readiness race に依存している assert(test_timeout_termination_recorded / test_sigkill_escalation_recorded / test_subprocess_runner_terminates_process_group_on_timeout / test_overall_timeout_cancels_pending_and_terminates_running)を、pid sentinel 同期と責務分離された assert へ書き換える

Remaining Parent Gaps

なし

Outcome

fan-out の timeout/cancellation テストを、次の独立した責務へ分離し、コミットされた状態。

  1. actual overall-timeout watcher が発火し、overall_timeout_reached を記録し、未起動 subtask を cancelled にすることだけを保証する orchestration test
  2. 実 child process の readiness を pid sentinel で確認した後、cancel_event により SIGTERM され lifecycle telemetry(process_start/process_exit)が対になることを保証する runner test
  3. SIGTERM を無視する実 child process が readiness 確認後に SIGKILL escalation されることを保証する runner test

subprocess readiness の証拠として無条件の time.sleep や短い overall_timeout_sec を使用せず、production code・CI aggregate policy・外部サービス・新規 pytest plugin は変更しない。

Runtime Verification Applicability

  • decision: not_applicable
  • reason: Python pytest のみの変更であり、CI 負荷下でのレース再現を live 環境で確認する必要はない。静的な local pytest 実行(fresh process 20 回連続実行によるフレーク不在の確認を含む)で完結する

In Scope

  • test_fan_out_process_lifecycle.py の test_timeout_termination_recorded を test_running_process_cancellation_records_sigterm へ rename し、overall_timeout_sec の固定タイムアウト watcher 経路に依存せず、make_fake_provider_script() の既存 pid_file 引数で子プロセスの readiness sentinel を確認してから cancel_event.set() を呼ぶ設計へ書き換える
  • test_sigkill_escalation_recorded も同じ pid sentinel readiness helper を使用するよう変更し、termination_reason == "sigkill" を assert する
  • 両テストとも、process_start と process_exit が各1件、両者と sentinel の PID が一致することを assert する
  • test_fan_out_orchestrator.py の test_subprocess_runner_terminates_process_group_on_timeout(ok is False と "timeout" in failure_class のみで Popen 到達を確認しない false-green)を、同じ sentinel 方式で実 subprocess 起動を assert する形に修正するか削除する
  • test_overall_timeout_cancels_pending_and_terminates_running(または同等の orchestration timeout テスト)を test_overall_timeout_cancels_pending_subtasks 等の名称に整理し、overall_timeout_reached event と pending subtask の cancellation のみを assert する(slow runner の実際の起動確認は本テストの責務としない)
  • sentinel 待機の timeout・assertion failure・thread 内例外の全経路で、生成した thread と child process を finally で cleanup し、thread.join() 後に is_alive() が False であることを assert する

Out of Scope

Acceptance Criteria

  • AC1: test_timeout_termination_recorded が test_running_process_cancellation_records_sigterm へ rename され、実際の overall_timeout_sec deadline watcher 経路ではなく readiness sentinel 確認後の手動 cancel_event.set() によって SIGTERM を検証する設計になっている(「actual timeout を検証している」という誤った主張を除去する)
  • AC2: rename 後のテストは、既存 make_fake_provider_script() の pid_file 引数で書き込まれる sentinel ファイルが parse 可能な PID を持つまで待機した後にのみ cancel_event.set() を呼ぶ
  • AC3: rename 後のテストは process_start と process_exit が各1件、両者と sentinel の PID が一致し、termination_reason == "sigterm" であることを assert する
  • AC4: test_sigkill_escalation_recorded も同じ readiness sentinel helper を使用し、termination_reason == "sigkill" であることを assert する
  • AC5: test_subprocess_runner_terminates_process_group_on_timeout の false-green(Popen 未到達でも ok is False と "timeout" in failure_class だけで PASS してしまう構造)を、sentinel 方式で実 subprocess 起動を assert する形に修正するか、より強い lifecycle テストと責務が重複する場合は削除する
  • AC6: orchestration の timeout テスト(test_overall_timeout_cancels_pending_and_terminates_running またはその改名後のテスト)は overall_timeout_reached event と pending subtask の cancellation のみを assert し、起動済み process の termination まで保証しているとは主張しない(テスト名に terminates_running を含めない)
  • AC7: sentinel timeout・assertion failure・thread 内例外のいずれの経路でも、生成した non-daemon thread と child process が finally で cleanup され、thread.join() 後に not thread.is_alive() が assert される
  • AC8: .claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py に diff がなく、新規 dependency・live AGY/外部サービス呼び出し・追加セキュリティハーネスも導入されていない

Verification Commands

# AC1
# baseline-expect: fail
$ rg -q "def test_running_process_cancellation_records_sigterm" .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py
# AC1
# AC2
# AC3
# AC4
# AC5
# AC6
# AC7
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py -q
# AC1
# AC2
# AC3
# AC4
# AC7
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py -n 4 --dist load -q
# AC8
# baseline-expect: pass
$ git diff --quiet main -- .claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py

Allowed Paths

  • .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py
  • .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合(fan_out_orchestrator.py 側の変更が必要と判明した場合を含む)

Required Skills

  • pytest / Python テスト設計(同期プリミティブによる決定論的タイミングテスト)
  • subprocess ライフサイクル(Popen / SIGTERM / SIGKILL / cancel_event)の理解

Required Design References

  • .claude/skills/gemini-cli-headless-delegation/SKILL.md
  • .claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py(run_fanout() / _watch_deadline() / make_subprocess_runner() / RunnerContext.cancel_event / RunnerContext.terminate_all() の overall timeout・cancel・process_start/process_exit テレメトリ実装)

Scope Delta(任意)

N/A

Background

PR #2366(Issue #2308 の impl-review-loop)の CI 安定化作業中、python-test-core の CI failure を root-cause / PR-scope の 2 つの read-only SubAgent 調査と local 再現試行で調査した。結論: test_timeout_termination_recorded(.claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py)は overall_timeout_sec=0.3 を使用しており、この締切は run_fanout() が Popen 前(_load_run_gemini_headless_module() + _prepare_and_validate_subtasks() の preflight パイプライン中)からカウントを開始する。CI 負荷下(pytest-xdist -n 4、13,318 テストの suite、共有 GitHub Actions runner)では、0.3 秒の締切が Popen 到達前に正当に経過しうるため、コードは文書化済みの cancel-before-Popen パス(_run_one() と make_subprocess_runner()._runner() 両方の overall_timeout_pending_cancelled)を取り、process_start/process_exit テレメトリが一切記録されない。このためテストは assert len(exits) == 1(実際は len(exits) == 0)で失敗する。

収集した証跡(当初調査):

2026-08-28 OWNER 敵対的レビュー(reframe_in_place): 上記の根本原因分析自体は妥当だが、当初の契約(単一テストを手動 cancel_event.set() に置き換えるだけ)では「overall timeout のテストを手動キャンセルのテストへすり替えたまま、同じテスト名と保証を残す」ことになり、actual timeout 経路(_watch_deadline() → overall_timeout_reached journal → terminate_all())の検証が失われる指摘を受けた。さらに、同じ readiness race を持つ隣接テスト(test_sigkill_escalation_recorded)と、Popen 未到達でも通ってしまう false-green テスト(test_subprocess_runner_terminates_process_group_on_timeout)が残る点も指摘された。

本 refinement loop の codebase-investigator による fact-check(read-only、HEAD 97fd045ab36cbc57221c4527f5995854792a5d80)で、OWNER レビューが挙げた技術的主張(_watch_deadline() の起動タイミング、cancel_event セット時の overall_timeout_pending_cancelled 返却、test_sigkill_escalation_recorded と test_subprocess_runner_terminates_process_group_on_timeout の readiness race 構造、test_overall_timeout_cancels_pending_and_terminates_running の slow runner 起動未確認、make_fake_provider_script() の既存 pid_file 機構、RunnerContext.cancel_event/terminate_all() の存在)は全て HEAD のコードと一致することを確認した(pytest-repeat が dev dependency に存在しないという指摘のみ、AC2 の VC 表記修正が必要という文脈で真)。この fact-check の結果を踏まえ、Issue を reframe_in_place で更新した。

Notes for Reviewer

  • 決定論性の追加確認として、uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py -k 'running_process_cancellation_records_sigterm or running_process_cancellation_escalates_to_sigkill' -q を手動で複数回連続実行してフレークがないことを確認することを推奨する。リポジトリの VC 契約(単一コマンド・compound shell 禁止、body-authoring.md#VC_SINGLE_COMMAND_GUARDRAIL)上、shell ループや pytest-repeat 依存を伴う形式的な繰り返し実行 VC は追加していない。また、pytest -k フィルタが対象テスト未実装時に exit 5(no tests collected)を返す関係で、rename 完了前提の VC(AC1)は rg によるテスト関数存在確認へ切り替えている
  • 重大度: optional follow-up(低緊急度)。flake は稀(当初調査でローカル 33 回試行して再現せず、main では安定して PASS)であり、現行作業をブロックしない。PR fix: retrospective-run marker malformed comment を discard せず記録する #2366 は CI rerun で一度の失敗を解消後、既にマージ済み
  • 変更対象はテスト2ファイル(test_fan_out_process_lifecycle.py / test_fan_out_orchestrator.py)に限定され、production code・新規 pytest plugin・live service・CI gate 緩和・追加セキュリティハーネスは不要
  • test_subprocess_runner_terminates_process_group_on_timeout について、より強い lifecycle テスト(AC1-AC4 の rename 後テスト)と責務が重複すると判断される場合は削除を優先してよい(本 Issue は当該テストの修正・削除いずれも許容する)
  • repo-root .pytest_cache/** を runtime guard が誤検知する問題は Issue 実装: runtime guard が peer pytest nodeids を child write と誤帰属しないようにする #1526 で既に解消済みであり、-p no:cacheprovider や cache path 変更を新たに導入する必要はない

Notes for Reviewer (Scope Overlap Advisory)

check_issue_overlap.py の overlap preflight(policy_class: C1, decision: overlap_requires_comment)により、本 Issue の Allowed Paths(.claude/skills/gemini-cli-headless-delegation/tests/ 配下の対象ファイル)が、同ディレクトリ配下を広く Allowed Paths に含む既存 OPEN Issue(#2042 / #2002 / #258 / #101 / #73 / #29 / #28 / #27 / #14 等)と文字列レベルで重複する。これらはいずれも tests/ ディレクトリ全体または別テストファイルを対象としており、本 Issue が対象とする test_fan_out_process_lifecycle.py の readiness-race テスト群および test_fan_out_orchestrator.py の test_subprocess_runner_terminates_process_group_on_timeout と実質的な作業対象は重複しない(#1860 Owner Decision により、declared Allowed Paths の文字列重複自体は起票停止理由にしない)。実際の Git conflict は worktree/PR 作成時に別途検出される想定。

Source

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 28, 2026
  2. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    敵対的レビュー結果

    Verdict: REQUEST_CHANGES — reframe_in_place

    プロダクト上の緊急度: 低
    Issue 契約上の状態: implementation-ready ではない

    Issue #2371 の根本原因分析は妥当です。run_fanout() は timeout watcher を subprocess 起動前の validation/preflight より先に開始し、make_subprocess_runner() は呼び出し時点で cancel_event が立っていれば Popen() せず overall_timeout_pending_cancelled を返します。そのため、overall_timeout_sec=0.3 で常に process_exit が1件あるという現行テストの期待が誤っています。PR #2366 の CI でも、13,318件中この1件だけが process_exit == 0 で失敗しており、aggregate gate や PR #2366 本体を変更しない判断も正しいです。

    ただし、現在の契約どおり実装すると、overall timeout のテストを手動キャンセルのテストへすり替えたまま、同じテスト名と保証を残せます。さらに、同じ欠陥を持つ隣接テストと、実際には subprocess を起動しなくても通る false-green テストが残ります。

    レビュー時点では #2371 にコメントはなく、タイムラインもラベル付与だけです。また、対象ファイル名を明記した open PR はありません。現在なら Issue をそのまま reframe するコストは低い状態です。

    P0 — cancel_event.set() は actual overall timeout を検証しない

    Issue は、子プロセスの sentinel を確認した後で cancel_event.set() を呼ぶ設計を要求しています。これは test runner wrapper から RunnerContext.cancel_event を捕捉すれば、production code を変更せず実装可能です。

    しかし、実際の timeout 経路は次です。

    run_fanout()
      └─ _watch_deadline()
           ├─ overall_timeout_sec 経過
           ├─ cancel_event.set()
           ├─ overall_timeout_reached を journal
           └─ ctx.terminate_all()
    

    提案されているテストは次の経路です。

    test code
      └─ cancel_event.set()
           └─ subprocess runner が SIGTERM
    

    後者では _watch_deadline()、deadline の成立、overall_timeout_reached event、watcher からの terminate_all() をすべて迂回します。検証できるのは、起動済み subprocess にキャンセルが入力された後の termination と lifecycle telemetryだけです。現在の test_timeout_termination_recorded は実際の overall_timeout_sec=0.3 を入力しており、元の Issue #1707 も独立ケースとして「overall timeout termination」を要求していました。

    したがって、次のどちらかが必要です。

    1. 推奨: テストを test_running_process_cancellation_records_sigterm 等へ rename し、deadline watcher と subprocess termination の検証を別テストへ責務分離する。
    2. actual timeout の E2E 性を維持するため、deadline/clock の test seam を production code に追加する。

    個人趣味開発としては、2は過剰です。production API をテスト都合で拡張せず、1の責務分離を採用するべきです。

    P1 — 同じ欠陥のテストと false-green が残る

    test_sigkill_escalation_recorded

    同じ test_fan_out_process_lifecycle.py に、次の構造があります。

    thread.start()
    time.sleep(0.3)
    cancel_event.set()

    CI が0.3秒以内に runner thread を schedule しなければ、cancel_event が Popen() より先に立ち、process_exit が存在せず失敗します。今回直そうとしているものと同一の readiness race です。

    test_subprocess_runner_terminates_process_group_on_timeout

    test_fan_out_orchestrator.py にも同じ thread.start() → time.sleep(0.3) → cancel_event.set() があります。さらに、このテストは次しか確認していません。

    assert result["ok"] is False
    assert "timeout" in result["failure_class"]

    runner thread が0.3秒以内に開始しなかった場合、production runner は Popen() 前に overall_timeout_pending_cancelled を返します。この文字列にも "timeout" が含まれるため、subprocess を一度も起動せず、process group を一度も terminate していなくてもテストが PASS します。これは flake より悪い false-green です。

    test_overall_timeout_cancels_pending_and_terminates_running

    このテストは pending-1 と pending-2 が起動していないことは確認しますが、slow runner が実際に起動したことを確認していません。timeout が preflight 中に成立して全 runner が未起動でも通るため、テスト名の terminates_running 部分は保証されていません。

    必須修正: #2371 のスコープを単一テストではなく、以下の責務整理まで拡張するべきです。

    • SIGTERM テストを pid sentinel 同期へ変更
    • SIGKILL テストも同じ同期へ変更
    • 弱い duplicate の test_subprocess_runner_terminates_process_group_on_timeout を削除するか、同じ sentinel 方式で実 subprocess 起動を assert
    • orchestration の timeout テストは test_overall_timeout_cancels_pending_subtasks 等へ rename し、overall_timeout_reached event と pending cancellation のみを保証

    これなら変更対象はテスト2ファイルだけです。

    P1 — Verification Commands が再現可能になっていない

    --count=20 は pytest core のオプションではない

    --count は pytest-repeat plugin が提供するオプションです。リポジトリの dev dependency は pytest、pytest-xdist、ruff であり、pytest-repeat は宣言されておらず、リポジトリ内にも参照がありません。したがって、現在の AC2 は ambient environment に偶然 plugin が入っている場合しか再現できません。 ([GitHub]1)

    この1件のために plugin を追加する必要はありません。新しい依存関係は workflow を重くするだけです。fresh pytest process を shell loop で20回起動すれば足ります。

    bare pytest では CI と環境が一致しない

    現行 CI は uv run --locked pytest を使用しています。Issue の全 Verification Commands もこれに合わせるべきです。

    AC3 は committed production change を検出できない

    現在のコマンドは次です。

    git diff --name-only HEAD -- \
      .claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py

    これは HEAD と現在の working tree の差を見るだけです。production file を変更して commit した後なら空になります。また、差分を表示するだけで、差分が存在しても command 自体は通常成功します。

    Issue の Outcome は「コミットされた状態」を要求しているため、merge-base から working tree までを --quiet で確認する必要があります。

    base="$(git merge-base main HEAD)"
    git diff --quiet "$base" -- \
      .claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py

    実際には既存の Allowed Paths gate に任せ、重複する AC3 自体を削除する方が簡潔です。

    P1 — failure 時の thread/process cleanup が契約されていない

    fake provider は60秒 sleep します。sentinel 待機や途中 assertion が失敗して cancel_event.set() へ到達しなければ、non-daemon thread と child process が残り、テスト終了を長時間妨げる可能性があります。

    pytest は、テストが生成した thread を teardown で必ず待つよう明示的に推奨しています。Python の Thread.join(timeout) は戻り値で timeout を示さないため、join 後に is_alive() を確認する必要があります。([pytest]2) ([Python documentation]3)

    最低限、次の構造が必要です。

    thread.start()
    try:
        child_pid = wait_for_pid_sentinel(pid_file, timeout_sec=5.0)
        cancel_event.set()
        thread.join(timeout=10)
    finally:
        cancel_event.set()
        ctx.terminate_all(grace_period=0.1)
        thread.join(timeout=2)
    
    assert not thread.is_alive()

    thread 内例外も result holder とは別に捕捉し、main test thread で再送出または明示的に fail させるべきです。

    P2 — 新しい sentinel 機構は不要

    make_fake_provider_script() はすでに pid_file 引数を持ち、fake child 内で PID を書き込めます。SIGKILL 用の fixture では、SIGTERM handler の設定後に PID が書かれるため、handler readiness の証拠としても利用できます。新しい helper script や production hook を追加する必要はありません。

    待機 helper は「ファイルが存在する」だけでなく、PID が parse 可能になるまで待つ方が安全です。

    def wait_for_pid_sentinel(path: Path, *, timeout_sec: float = 5.0) -> int:
        deadline = time.monotonic() + timeout_sec
        while time.monotonic() < deadline:
            try:
                value = path.read_text(encoding="utf-8").strip()
                if value:
                    return int(value)
            except (FileNotFoundError, ValueError):
                pass
            time.sleep(0.01)
        raise AssertionError(f"child readiness sentinel was not completed: {path}")

    ここでの timeout は「5秒後にキャンセルする」という動作トリガーではなく、ready condition が永遠に成立しない場合のテスト上限です。threading.Event も thread 間の明示的な signal/wait 用プリミティブとして定義されています。([Python documentation]4)

    events.ndjson を実行中に繰り返し parse して process_start を探す方式より、既存 pid sentinel の方が単純です。実行中 journal を読む場合は、書き込み途中の行を一時的に観測するケースまで扱う必要が生じます。

    P2 — Background の「常にペア」は言い過ぎ

    Issue は process_start と process_exit が「構造的に常にペア」と断定しています。しかし production runner では、Popen() 後の process_start journal と register_process() が、主要な wait/reap の try/finally より前にあります。journal callback や registration 自体が例外を出すあらゆるケースまで、無条件に pair が保証されているわけではありません。

    この Issue で production hardening を追加する必要はありません。記述だけ次へ弱めるべきです。

    観測された CI failure は、文書化済みの cancel-before-Popen 経路と整合しており、production の lifecycle event pairing defect を示す証拠ではない。

    これは証拠から言える範囲であり、不要な production scope 拡張も避けられます。

    推奨する Issue 再定義

    タイトル

    実装: fan-out timeout/cancellation テストを readiness 同期と責務分離で決定論化する
    

    Outcome

    fan-out の timeout/cancellation テストを、次の独立した責務へ分離する。
    
    1. actual overall-timeout watcher が発火し、overall_timeout_reached を記録し、
       未起動 subtask を cancelled にする orchestration test
    2. 実 child process の readiness を pid sentinel で確認した後、
       cancel_event により SIGTERM され lifecycle telemetry が対になる runner test
    3. SIGTERM を無視する実 child process が readiness 確認後に
       SIGKILL escalation される runner test
    
    subprocess readiness の証拠として無条件の time.sleep や短い overall_timeout を
    使用せず、本番コード・CI aggregate policy・外部サービス・新規 pytest plugin は変更しない。
    

    Acceptance Criteria

    1. test_timeout_termination_recorded を test_running_process_cancellation_records_sigterm 等へ rename し、actual timeout を検証しているという誤った主張を除去する。
    2. SIGTERM テストは既存 pid_file sentinel が parse 可能になった後にのみ cancel_event.set() を行う。
    3. SIGTERM テストは、process_start と process_exit が各1件、両者と sentinel の PID が一致し、termination_reason == "sigterm" であることを確認する。
    4. test_sigkill_escalation_recorded も同じ readiness helper を使用し、termination_reason == "sigkill" を確認する。
    5. test_subprocess_runner_terminates_process_group_on_timeout の false-green を削除する。より強い lifecycle テストと重複するなら削除を優先する。
    6. actual timeout テストは overall_timeout_reached と pending cancellation を assert し、起動済み process の termination まで保証しているとは名乗らない。
    7. sentinel timeout・assertion failure・thread exception の全経路で child と thread が cleanup される。
    8. production code、新規 dependency、live AGY/外部サービス、追加セキュリティハーネスを変更しない。

    Allowed Paths

    .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py
    .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py
    

    tests/ ディレクトリ全体の broad allowance は不要です。

    Verification Commands

    # focused behavior
    uv run --locked pytest \
      .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py \
      -k 'running_process_cancellation_records_sigterm or running_process_cancellation_escalates_to_sigkill' \
      -q
    # affected test files
    uv run --locked pytest \
      .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py \
      .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py \
      -q
    # CI-like worker execution
    uv run --locked pytest \
      .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py \
      .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_orchestrator.py \
      -n 4 --dist load -q
    # 20 fresh pytest processes; pytest-repeat dependencyは追加しない
    for i in $(seq 1 20); do
      uv run --locked pytest \
        .claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py \
        -k 'running_process_cancellation_records_sigterm or running_process_cancellation_escalates_to_sigkill' \
        -q || exit 1
    done
    # production file unchanged
    base="$(git merge-base main HEAD)"
    git diff --quiet "$base" -- \
      .claude/skills/gemini-cli-headless-delegation/scripts/fan_out_orchestrator.py

    なお、repo-root .pytest_cache/** を runtime guard が誤検知する問題は Issue #1526 で既に閉じられており、#2371 側で -p no:cacheprovider や cache path 変更を新たに導入する必要はありません。通常の uv run --locked pytest を使用するのが妥当です。

    最終 disposition

    #2371 は close や分割ではなく、同じ Issue を reframe して継続するのが妥当です。

    変更はテスト2ファイルに限定し、production code、新規 pytest plugin、live service、CI gate 緩和、追加セキュリティハーネスは不要です。現行契約のまま実装へ進めると「CI は緑だが、timeout の保証を黙って失ったテスト」になるため、先に契約更新が必要です。

    今回、リポジトリの checkout と pytest 実行は行っていません。判定は current repository code、Issue/PR 履歴、CI 証跡、Python・pytest の公式仕様の照合に基づきます。

  3. changed the title [-]実装: fan-out timeout flake テストを sentinel 同期で決定論的に再設計する[/-] [+]実装: fan-out timeout/cancellation テストを readiness 同期と責務分離で決定論化する[/+] on Aug 28, 2026
  4. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 完了報告(人間承認不要モード)

    結果: approved

    対象コメント #2371 (comment) (OWNER 敵対的レビュー、reframe_in_place)を反映し、Issue 本文を全面書き換えました。

    実施内容

    1. codebase-investigator による read-only fact-check(HEAD 97fd045ab36cbc57221c4527f5995854792a5d80)で、anchor comment の9個の技術的主張のうち8個が現行コードと一致することを確認(pytest-repeat dev dependency 未導入という主張のみ、VC 表記修正の根拠として妥当)。
    2. OWNER 提案の reframe(テストを3責務へ分離: actual timeout watcher / SIGTERM readiness runner / SIGKILL escalation runner)を Issue 本文へ反映。
    3. deterministic checker(contract_readiness_check.py / run_root_review_pipeline.py produce)との反復で以下を修正:
      • Required Design References に既存の design-doc path(.claude/skills/gemini-cli-headless-delegation/SKILL.md)を追加
      • Verification Commands を単一コマンド化(compound shell / line continuation / command substitution を除去)し、# baseline-expect: pass|fail annotation を付与
      • pytest -k フィルタが未実装テスト名に対して exit 5(no tests collected)を返し blocker になる問題を回避するため、rename 完了確認用の AC1 VC を rg によるテスト関数存在確認に変更
      • AC/VC 番号整合のため bare # AC<N> marker 形式へ統一
    4. タイトルを 実装: fan-out timeout/cancellation テストを readiness 同期と責務分離で決定論化する へ更新。

    最終レビュー結果

    • VERDICT: approve / BLOCKERS: 0(body_sha256: sha256:d368d69671917abc44674af382e43a316954ef235b4d716e7eea5d2ba126632e)
    • 残存する非 blocking 警告: scope_cvs_in_scope_mismatch(Current Validated Scope と In Scope のトークン一致率が低い。severity: warning、実装着手のブロッカーではない)
    schema: LOOP_HANDOFF_RESULT_V1
    issue_number: 2371
    issue_kind: implementation
    termination_cause: approved
    reviewed_body_sha256: "sha256:d368d69671917abc44674af382e43a316954ef235b4d716e7eea5d2ba126632e"
  5. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  6. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-28T12:59:26Z)

  7. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-08-28T13:20:00Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2373"
      head_sha: "f664bfa6e0b977fb454e00fa878fe2b24d36c824"
      issue_number: 2371
      termination_reason: approved
      merge_ready: true
      iteration: 0
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
  8. self-assigned this
    on Aug 28, 2026
  9. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-08-28T13:57:00Z)(stale-head再検証・更新)

    前回の終了報告(issuecomment-5453071773, head f664bfa...)投稿後、main が更に進み GitHub 側で
    PR ブランチが自動的に再度更新されたため(head f664bfa... → 2e22d6b...)、stale-head 再検証を実施した。
    gh pr diff --name-only で対象2ファイル以外の差分がないことを確認し、4件の Verification Commands を
    新head上で独立に再実行して全 PASS、CI 20 checks 全 green、pr-reviewer による再レビューも APPROVE(blockers 0)
    であることを確認した。

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2373"
      head_sha: "2e22d6ba124e37aad5a4b23f0fb0180124ebd504"
      issue_number: 2371
      termination_reason: approved
      merge_ready: true
      iteration: 0
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
  10. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-08-29T04:00:00Z)(OWNER REQUEST_CHANGES → fix_delta → 再APPROVE)

    OWNERの敵対的レビュー(#issuecomment-5456314258、REQUEST_CHANGES — fix_in_place, reviewed_head_sha f664bfa6...)を受け、以下2件のP1 blockerをfix_deltaとしてimplementation-workerへ委譲し解消した:

    1. thread/process cleanupが検証対象のcancel_event経路に依存し、thread内部例外時のchild leakを防げない
      → finallyでthread例外を独立捕捉し、ctx.terminate_all()をcancel_event経路とは独立に必ず呼び、必要時のみchild_pidベースのtest-only SIGKILL fallbackを実行するよう修正
    2. test_sigkill_escalation_recordedがprocess_start/process_exit pairingを検証していない
      → SIGTERM側と対称なprocess_start件数・PID一致assertを追加

    修正後、4件のVerification Commandsを新head上で独立に再実行し全PASS、CI全green、pr-reviewerによる2件のP1 blockerの1対1照合確認を経てAPPROVE(blockers 0)を確認した。OWNERが明示的にnon-blocking指定した2件のP2事項(fresh-process 20回検証の記載・低レベルテスト名の過大表現)は本fix_deltaでは未対応(マージ条件外のためAPPROVEをブロックしない)。

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2373"
      head_sha: "e31647c2d5322732bf09d1c7b4993103809e7dab"
      issue_number: 2371
      termination_reason: approved
      merge_ready: true
      iteration: 1
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementationtriage-required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions