Skip to content

実装: process-group cancellation 統合 test の固定 0.6s outer deadline を readiness 同期へ置き換え、負荷下の timing flake を解消する #2883

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "process-group cancellation 統合 test の固定 0.6s outer deadline が負荷下で readiness marker 未作成の flake を起こす問題を、readiness 観測後に production outer-timeout handling path を test-local deterministic fault injection で発火させる形へ置換して解消する(PR #2876 CI run 37068873394 の python-test-core failure 起点)"
change_kind: test

Parent Issue

なし(単独改善)

Parent Goal Ref

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

Current Validated Scope

  • 対象は .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py の test_outer_deadline_via_run_baseline_vc_preflight_reaps_full_process_tree(HEAD 1974fdd で実在確認済み)。
  • production script(baseline_vc_preflight.py / contract_readiness_check.py)の timeout semantics は正しいと判断しており変更しない。
  • current production API では outer deadline は baseline_vc_preflight.run_subprocess_with_cooperative_supervisor() が child を Popen した直後に process.communicate(timeout=timeout_seconds) へ入った時点で arm される。contract_readiness_check.run_baseline_vc_preflight() の test seam は override_timeout_seconds / override_grace_seconds / _test_extra_env のみで、「readiness 後に timer を arm する」入口は存在しない。したがって「readiness 観測後に outer deadline を発火」は production seam の追加ではなく、test file 内の test-local deterministic fault injection で実現する(本 Issue で accepted mechanism として固定する。下記 In Scope 参照)。
  • .github/ci/python-test-plan.json は .claude/skills/issue-contract-review/scripts/tests/ ディレクトリを既に対象に含むため、既存ファイルへの変更なら plan 登録変更は不要。

Remaining Parent Gaps

なし

Outcome

test_vc_process_group_cancellation.py の outer-timeout 統合 test が、固定 _OUTER_DEADLINE_SECONDS = 0.6 の elapsed wall-clock 前提ではなく、「real な VC leader + SIGTERM を無視する real な grandchild が readiness marker に到達したことを同期で確認した後に、production supervisor の outer-timeout handling branch を test-local fault injection で発火させる」構造へ変更され、CPU 負荷の有無に関わらず決定論的に PASS し、fixture readiness を遅延させる deterministic な regression test と共にコミットされた状態。product code・required CI は変更しない。

Runtime Verification Applicability

  • decision: not_applicable
  • reason: pytest のみの test 設計変更であり、live 環境での runtime 検証は不要。ローカル pytest(無負荷・xdist 下)で完結する

In Scope

  • accepted mechanism(test-local deterministic fault injection): 既存 Allowed Path の test file 内だけで、real baseline_vc_preflight.py + real VC leader + real SIGTERM-ignoring grandchild + real readiness marker を使い、process tree が ready になったことを決定論的に確認した後で、production supervisor の outer-timeout handling branch(TimeoutExpired 後の SIGTERM → grace → SIGKILL → reap → typed timeout result)を test-local に発火させる。具体的な injection point(例: supervisor が Popen する baseline_vc_preflight.py 子プロセスに限定した Popen.communicate(timeout=...) の test-local subclass / monkeypatch)は current code で設計してよい。ただし注入してよいのは「TimeoutExpired が発生する時点」だけであり、supervisor 自身の SIGTERM 送信・grace 待機・SIGKILL escalation・reap・typed result 構築・run_baseline_vc_preflight() の呼び出し経路を stub / 再実装 / 迂回してはならない(production の outer-timeout handling path を実際に通すこと)。
  • この test は「0.6 秒という elapsed wall-clock deadline 自体」を試験するものではなく、「ready な real process tree に対して production outer-timeout handling path が実行された場合の cooperative cancellation / full reap / typed timeout result」を検証する fault-injection integration test であることを、test の docstring と本 Issue 上に明記する。これは synthetic timeout の禁止対象ではなく、accepted mechanism である。
  • 新規 regression test test_outer_timeout_fault_injection_waits_for_ready_process_tree を同 test file に追加する(命名は同 file の既存 test_scaled_fault_injection_* / test_outer_deadline_* の test_<subject>_<action>_<outcome> 規約に整合)。
  • 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2207 / 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2221 の integration guarantee を後退させない: 責務分離を採用する場合でも、少なくとも1つの integration test は、同一 run_baseline_vc_preflight() invocation について「ready な real VC leader + grandchild → production outer-timeout handling path 発火 → baseline_vc_preflight.py の SIGTERM handler(marker)→ wrapper / VC leader / grandchild の full reap → typed timeout result(status == "runtime_error" / failure_class == "timeout" / timeout_phase == "baseline_vc_preflight_aggregate" / retryable is False)」を一続きで検証する。timeout と reap を完全に別 test へ分離して 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2221 が埋めた coverage gap を再導入する変更は不可。_OUTER_DEADLINE_REPEAT_COUNT 回の repeat による register/unregister race 検出も維持する。
  • deterministic delayed-readiness regression: fixture の readiness(self.pid / grandchild.pid の書き込み)を test が制御する同期 primitive(release marker file / threading.Event 等)で旧 _OUTER_DEADLINE_SECONDS(0.6s)を超えて確実に遅延させ、旧設計(固定 0.6s で deadline を発火)なら必ず readiness 前に発火して破綻する条件を作る。新設計では readiness 観測後にのみ timeout path を発火するため、この条件でも決定論的に PASS する。実 CPU 飽和(busy loop 等)を required test に埋め込まない。
  • 既存の test_outer_deadline_via_run_baseline_vc_preflight_reaps_full_process_tree が持つ readiness 依存 assertion(self.pid / grandchild.pid の存在確認と reap 確認)は、wall-clock deadline 依存のまま残さない。この test は新設計へ置換・改名するか、readiness 非依存の assertion(typed payload 等)のみへ縮小する。test_scaled_fault_injection_inner_timeout_precedes_outer_deadline は per-command の inner timeout のみを検証し、supervisor の outer communicate(timeout=...) を自然に時間切れにしないため、natural outer-timeout coverage を担わない(OWNER 指摘 PR test: outer-timeout 統合 test の固定 0.6s deadline を readiness 同期の fault injection へ置換する #2885 issuecomment-5963140832 P1。前提誤りの訂正)。
  • 旧 600ms 設計根拠コメントを新設計に合わせて更新する。
  • natural outer-timeout regression(P1 訂正): 同 test file に test_outer_timeout_natural_elapsed_timeout_returns_typed_timeout_result を 1 本追加する。fault injection を一切使わず、readiness assertion / grandchild readiness 依存を持たず、real run_baseline_vc_preflight() に十分長く動く VC と小さな override_timeout_seconds を渡し、production の communicate(timeout=...) が実経過時間で自然に TimeoutExpired を起こす経路を通す。実装条件: override_grace_seconds に小さな値を渡して実行時間を bound し、VC は有限長 sleep 等で orphan を残さないものにする。検証は typed result(status == "runtime_error" / failure_class == "timeout" / timeout_phase == "baseline_vc_preflight_aggregate" / retryable is False)と、経過時間が指定 timeout 以上であること(下限のみ。上限・startup 速度は assert しない)に限る。grandchild の readiness / full reap の integration guarantee は fault-injection test 側が担う。
  • injection validation failure 時の cleanup(P2): fault injection 実装(例: PR test: outer-timeout 統合 test の固定 0.6s deadline を readiness 同期の fault injection へ置換する #2885 の _OuterTimeoutFaultInjection.fire()。具体的な構造は実装時に決めてよい)は、自身の内部検証(例: timeout 値不一致、readiness wait 失敗)の失敗を記録しても、matched outer process に必ず TimeoutExpired を送出して production cleanup branch(SIGTERM → grace → SIGKILL → reap)を完遂させ、cleanup 完了後に記録した failure を test failure として表面化する。回帰 test test_outer_timeout_fault_injection_validation_failure_still_reaps_process_tree が、意図的に不一致の expected timeout を与えた injection でも wrapper / VC leader / grandchild が reap され、failure が記録されることを固定する。generic cleanup framework は追加しない。
  • 本 test file の docstring / コメントから「別 test が real elapsed timeout coverage を担う」という誤記述を除去し、natural outer-timeout regression を参照する。

Out of Scope

Acceptance Criteria

  • AC1: test_vc_process_group_cancellation.py に test_outer_timeout_fault_injection_waits_for_ready_process_tree が存在し、self.pid / grandchild.pid の readiness marker を観測した後にのみ outer-timeout handling path を test-local fault injection で発火させる。readiness 依存 assertion が固定 0.6s deadline 内に fixture が readiness へ到達する wall-clock 前提に依存しない
  • AC2: 同一 run_baseline_vc_preflight() invocation について、typed result(status == "runtime_error" / failure_class == "timeout" / timeout_phase == "baseline_vc_preflight_aggregate" / retryable is False)、SIGTERM handler marker、wrapper / VC leader / grandchild の full reap の assertion が一続きで存在する(timeout と reap を別 test に分離していない)
  • AC3: run_baseline_vc_preflight() 経由・real baseline_vc_preflight.py / real VC leader / real SIGTERM-ignoring grandchild・_OUTER_DEADLINE_REPEAT_COUNT 回 repeat の production-shaped integration 構造が維持され、fault injection は TimeoutExpired の発生時点のみを注入し supervisor の SIGTERM / grace / SIGKILL / reap / typed result 構築を stub していない
  • AC4: fixture readiness を同期 primitive で旧 0.6s を超えて確実に遅延させる deterministic delayed-readiness regression が存在し、CPU 負荷を一切かけない状態でも PASS する(旧 0.6s 固定 deadline 設計なら readiness 前に発火して破綻する条件である)。CPU 飽和(busy loop)を required test に含めない
  • AC5: production script・CI 設定・.github/ci/python-test-plan.json・pyproject.toml・uv.lock に branch 起因の diff がなく、新規 dependency / pytest plugin が追加されていない
  • AC7: test_outer_timeout_natural_elapsed_timeout_returns_typed_timeout_result が存在し、fault injection fixture を使わず real run_baseline_vc_preflight() の communicate(timeout=...) が実経過時間で自然に timeout し、typed result(status == "runtime_error" / failure_class == "timeout" / timeout_phase == "baseline_vc_preflight_aggregate" / retryable is False)が返ること、および経過時間が指定 timeout 以上であることを検証する。readiness assertion / readiness marker wait を持たず、fault injection fixture を参照せず、elapsed >= timeout を assert する
  • AC8: injection 内部検証が失敗した場合でも production の timeout cleanup branch が最後まで実行され(wrapper / VC leader / grandchild が reap される)、記録された injection failure が cleanup 完了後に test failure として表面化する。test_outer_timeout_fault_injection_validation_failure_still_reaps_process_tree がこれを deterministic に固定する(意図的に不一致な expected timeout を injection に与え、cleanup 後に failure が記録・表面化されることと、tree が reap されることの両方を assert する。reap のみの assert は不可)
  • AC6: 対象ファイルが無負荷および xdist(-n 4 --dist loadscope)下で PASS する(xdist compatibility の secondary check であり、CPU 飽和 regression の authority ではない)

Verification Commands

# AC1
# AC2
# AC3
# AC4
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py::test_outer_timeout_fault_injection_waits_for_ready_process_tree -q
# AC1
# AC2
# AC3
# AC4
# AC6
# AC7
# AC8
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py -q
# AC6
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py -n 4 --dist loadscope -q
# AC7
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py::test_outer_timeout_natural_elapsed_timeout_returns_typed_timeout_result -q
# AC8
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py::test_outer_timeout_fault_injection_validation_failure_still_reaps_process_tree -q
# AC2
# baseline-expect: pass
$ rg -n -F 'assert result["timeout_phase"] == "baseline_vc_preflight_aggregate"' .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py
# AC3
# baseline-expect: pass
$ rg -n "= crc\.run_baseline_vc_preflight\(" .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py
# AC5
# baseline-expect: pass
$ git diff --quiet origin/main...HEAD -- .github .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py .claude/skills/issue-contract-review/scripts/contract_readiness_check.py .github/ci/python-test-plan.json pyproject.toml uv.lock

Allowed Paths

  • .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合(production script の変更・production への seam 追加が必要と判明した場合を含む。test-local fault injection で production の outer-timeout handling branch を実際に通せないことが実証された場合は、独自に production seam を追加せず停止して refinement へ戻す)
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • pytest / Python テスト設計(readiness 同期・test-local fault injection による決定論的 timing test)
  • subprocess ライフサイクル(process group / SIGTERM / SIGKILL)の理解

Required Design References

  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py(run_subprocess_with_cooperative_supervisor、SIGTERM cooperative cancellation / _kill_process_group)
  • .claude/skills/issue-contract-review/scripts/contract_readiness_check.py(run_baseline_vc_preflight と test seam)
  • .claude/skills/issue-contract-review/SKILL.md(baseline VC preflight / baseline-expect の契約)

Scope Delta(任意)

N/A

Background

PR #2876(Issue #2872)の CI run https://github.com/squne121/loop-protocol/actions/runs/37068873394 (attempt 1)で python-test-core(job 111043458302)が failure。依存 failure は python-test(111045684905、aggregate policy core='failure')と ci-verdict-summary(111045926568、AC9 violations → blocked)。同一 HEAD 6d47db9 の先行 run 37066185633 は success。失敗 test は test_outer_deadline_via_run_baseline_vc_preflight_reaps_full_process_tree、AssertionError: marker file not created within 5.0s: .../iter_2/self.pid(suite は 1 failed, 17580 passed)。PR #2876 は issue-contract-review に触れておらず PR 起因ではない。

root cause: test は 10 回、0.6s の outer deadline を発火させた後に fixture の readiness marker を要求する。fixture は python3 -m pytest として起動され、interpreter 起動 + pytest import(無負荷で約 200ms)と grandchild spawn が 0.6s 内に完了する wall-clock 前提を持つ。CPU 飽和(busy loop 48 本)で PR 非関与の main checkout(origin/main 6ee0823)でも 3/3 失敗し CI と同一メッセージ、無負荷では 3/3 PASS(約 9s)。コメントは startup jitter を 50-200ms から 600ms へ拡大してきた履歴(Issue #2207 OWNER P1-2 item 5、PR #2221)を示しており、wall-clock 拡大での追従は限界に来ている。

設計の理由: production supervisor は child を Popen した直後に communicate(timeout=...) で deadline を arm するため、「readiness 後に timer を arm する」入口が production API に無い。production seam の追加は個人開発のコストに見合わないため、test file 内の fault injection で「readiness 後に timeout branch を発火」する。#2221 の OWNER review が要求した「production wrapper の outer deadline → active VC tree → cooperative reap の合成経路」の証明は、fault injection 後も real process tree と production の timeout handling branch を通すことで維持する。近い precedent は #2371 / PR #2373(fan-out test の readiness 同期 + 責務分離)だが、本 test は timeout と reap を一続きで証明する必要があるため、責務分離ではなく同一 invocation の fault injection を採る。

dedupe 結果: OPEN Issue に同一 root cause・同一 scope のものなし。#2371(fan-out test の readiness 同期、CLOSED、別 test)・#2792(調査、CLOSED)・#1796(別 test の hermetic 化、OPEN、別 scope)は別 concern。

Notes for Reviewer

  • 重大度は CI flake(required check を稀に赤くする)。product 挙動の不具合ではない。

  • 本 contract は OWNER の REQUEST_CHANGES(https://github.com/squne121/loop-protocol/issues/2883#issuecomment-5962624631)を反映した reframe である: test-local deterministic fault injection を accepted mechanism として許可(BLOCKER)、CPU 飽和 regression を deterministic delayed-readiness regression へ置換(P1)、baseline-red の named regression VC を追加(P1)、同一 invocation の integration guarantee を明記(P1)、rg -c の false-green VC を assertion shape 検査へ修正(P2)、origin/main...HEAD の merge-base diff へ修正(P2)。

  • fault injection は elapsed wall-clock deadline 自体の試験ではない。real elapsed outer timeout の coverage は同 file に追加する natural outer-timeout regression(AC7)が担う(既存 inner-timeout test は outer timeout を通さないため担えない。OWNER PR test: outer-timeout 統合 test の固定 0.6s deadline を readiness 同期の fault injection へ置換する #2885 issuecomment-5963140832 による前提訂正)。

  • readiness 同期の具体的な injection point は実装時に current code で設計してよい。production code の seam 追加が必要になる場合は Stop Condition として停止する。

  • AC7/AC8 の named pytest VC は存在確認だけでなく、上記の構造条件(AC7: injection 非使用・readiness wait 非含有・elapsed 下限 assert、AC8: 不一致 expected timeout と failure 表面化の assert)を満たすことを pr-reviewer が diff で確認する。pytest VC は semantic proof を担う一次 VC であり、rg VC(AC2/AC3)は secondary check である。

Source

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Oct 2, 2026
  2. squne121 commented on Oct 2, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — reframe_in_place が妥当です。

    Issue #2883 の root cause 診断自体はかなり強いです。PR #2876 由来の deterministic regression ではなく、test_outer_deadline_via_run_baseline_vc_preflight_reaps_full_process_tree が「0.6 秒以内に fixture が readiness へ到達する」という wall-clock 仮定を持つ timing flake、という説明は CI 実ログ・current code・#2207/#2221 の履歴と整合しています。pytest 公式も、CI/並列実行で顕在化する flake は未制御の状態・timing dependency を疑い、固定 timing ではなく制御可能な同期へ移す方向を支持しています。[pytest ドキュメント](https://docs.pytest.org/en/latest/explanation/flaky.html?utm_source=chatgpt.com)

    ただし、現在の Issue contract には実装不能または false-green になり得る穴が残っています。

    1. BLOCKER — 「readiness 後に outer deadline を発火」と「production code 不変更」が current API では両立していない

    current main 1974fddf76ca1c0956e3eb77df52c8a5c31dd382 で確認すると、contract_readiness_check.run_baseline_vc_preflight() の test seam は override_timeout_seconds、override_grace_seconds、_test_extra_env までです。

    実際の deadline は baseline_vc_preflight.run_subprocess_with_cooperative_supervisor() が child を Popen した直後に、

    process.communicate(timeout=timeout_seconds)

    へ入ることで開始されます。Python の Popen.communicate(timeout=...) も、プロセス終了まで待ち、指定時間を超えれば TimeoutExpired を発生させる契約です。[Python documentation](https://docs.python.org/3/library/subprocess.html?highlight=universal_newlines\&utm_source=chatgpt.com)

    一方 #2883 は、

    • self.pid / grandchild.pid readiness を確認してから outer deadline を発火
    • actual outer-timeout semantics を維持
    • run_baseline_vc_preflight() production path を維持
    • production script は変更禁止
    • production seam が必要なら Stop Condition

    を同時に要求しています。

    current API には「readiness 到達後に timer を arm する」入口がありません。 このままだと実装者は、① production seam が必要として停止するか、② test-local monkeypatch で synthetic timeout を注入するが「actual outer deadline ではない」と reviewer に却下される、のどちらかになり得ます。

    これは #2221 の OWNER review と特に衝突します。あの review がこの test を要求した理由は、以前の「baseline へ手動 SIGTERM」と「inner timeout」の個別テストだけでは、production wrapper の outer deadline → active VC tree → cooperative reap の合成経路を証明できなかったからです。

    最小修正: #2883 本文で accepted mechanism を固定してください。個人趣味開発のコストを考えると、新しい production harness より次が小さいです。

    test file 内だけの deterministic fault injection を許可し、real baseline_vc_preflight.py + real VC leader + real SIGTERM-ignoring grandchild が readiness に到達した後、supervisor の timeout branch を test-local に発火させる。この test は「elapsed wall-clock deadline」のテストではなく「production outer-timeout handling path」の fault-injection integration test と明記する。real elapsed timeout 自体の既存 coverage は別に維持する。

    これを許可しないなら、Allowed Paths に最小限の test-only deadline-arm seam を追加する必要があります。

    2. P1 — AC4 の「CPU 飽和下 regression」を現在の Verification Commands は検証していない

    AC4 は CPU 飽和下での再発防止を要求していますが、VC は、

    pytest test_vc_process_group_cancellation.py -n 4 --dist loadscope -q
    

    です。

    pytest-xdist 公式仕様では loadscope は top-level test function を module 単位で grouping し、その group 全体を1 workerに割り当てます。したがって、この1 moduleだけを対象にした invocation は、CI のように4 workerが別 module を並列実行して CPU を奪い合う負荷を再現しません。[pytest-xdist.readthedocs.io](https://pytest-xdist.readthedocs.io/en/stable/distribution.html?utm_source=chatgpt.com)

    つまり AC4 は実装が間違っていても green になれます。

    ここでは 48本の busy loop のような負荷 generator を required CI に埋め込むのも推奨しません。workflow を無駄に重くします。より良い regression は「CPU が遅い状況」を wall-clock load で再現するのではなく、fixture の readiness を決定論的に遅延・gate して、旧 0.6s 仮定なら必ず失敗する状態を作ることです。

    -n 4 --dist loadscope は「xdist compatibility」の secondary VC として残して構いませんが、AC4 の主要証拠にはしない方がよいです。

    3. P1 — 新しい regression test を追加しなくても全 VC が baseline で通り得る

    現在の Verification Commands はすべて # baseline-expect: pass です。

    しかし #2883 の中心成果は「この failure class を固定する regression を追加する」です。現状の full-file pytest、rg -c、production file diff は、新しい regression test を1件も追加せずとも通ります。

    repository の current create-issue/references/body-authoring.md は、このケースを明示的に扱っています。既存 Allowed Path の test file に新しい test function を追加する場合は、missing node-id に対して直前に、

    # baseline-expect: fail
    

    を付ける canonical form があります。

    したがって例えば AC1/AC4 用に名前を固定し、

    # AC1
    # AC4
    # baseline-expect: fail
    $ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py::test_outer_timeout_fault_injection_waits_for_ready_process_tree -q
    

    のような baseline red → implementation後 green の VC を1本入れるべきです。

    4. P1 — 「責務分離」を無条件に許すと #2221 が修復した coverage gap を再導入できる

    Outcome/In Scope は「readiness 同期 または readiness 非依存 assertion / 依存 assertion への責務分離」を許しています。

    責務分離そのものは悪くありません。実際、closed Issue #2371 / PR #2373 は、

    • actual overall-timeout watcher のテスト
    • readiness 後の SIGTERM lifecycle test
    • readiness 後の SIGKILL escalation test

    へ責務を分けて flake を解消しており、良い precedent です。

    ただし、この test は事情が異なります。#2221 では、まさに「timeout」と「reap」を別々に確認するだけでは不十分として、run_baseline_vc_preflight() → actual outer timeout → already-running leader/grandchild → handler → full reap を一つにつないだ integration test が追加されました。

    したがって #2883 には次の制約を明記すべきです。

    責務分離を採用しても、少なくとも1つの integration test は「ready な real VC leader + grandchild が存在する状態で production outer-timeout handling path を発火し、その同一 invocation について typed timeout と全 descendant reap を検証する」こと。これを失う分離は不可。

    これなら #2371 の知見を利用しつつ、#2207/#2221 の safety claim を後退させません。

    5. P2 — rg -c の AC2/AC3 検証は semantic false-green

    現在、

    rg -c "baseline_vc_preflight_aggregate" ...
    rg -c "run_baseline_vc_preflight" ...
    

    がありますが、対象 token は docstring/comment に残っているだけでも成功します。

    たとえば実 assertion を削除しても "baseline_vc_preflight_aggregate" がコメントに残れば AC2 の VC は PASS します。

    ここは named pytest regression を authority にするのが最も良いです。static check も残すなら少なくとも、

    rg -F 'assert result["timeout_phase"] == "baseline_vc_preflight_aggregate"' ...
    

    のように actual assertion shape へ寄せるべきです。ただし最終的な semantic sufficiency は pytest 側で担保する方が堅いです。

    6. P2 — AC5 の git diff origin/main は moving base に弱い

    現在は、

    git diff --quiet origin/main -- <production paths>
    

    ですが、実装中に origin/main が進むと、その upstream change を「この branch が production を変更した」かのように検出できます。逆方向の取り違えも起こり得ます。

    branch が導入した差分だけを見るなら、単一コマンドのまま、

    git diff --quiet origin/main...HEAD -- <production paths>
    

    の方が意図に近いです。あるいは repository-native な changed-path authority があればそちらを使うべきです。

    確認できた関連関係

    GitHub live state では、#2883 は open、現時点で issue comment はなく、2883 を直接参照する実装 PR は検索上まだ見つかっていません。

    起点の PR #2876 は現在も open ですが、対象 flake は #2872 の Allowed Paths 外です。元 CI attempt 37068873394 の python-test-core は実際に [gw0] で iteration 2 の self.pid が生成されず、1 failed, 17580 passed で終了しています。これは #2883 の Background と一致します。

    関連履歴では、#2207 / merged PR #2221 がこの production outer-timeout integration test の起源、closed #2371 / PR #2373 が「wall-clock race を readiness synchronization + responsibility separation に変える」近い precedent です。#1796 は別 snapshot fixture timeout の hermetic 化、#2792 は別の CI 並列非決定 failure 調査であり、live dedupe 検索でも #2883 と同一 scope の open Issue は確認できませんでした。

    推奨する reframe の中心

    #2883 の方向性は変えなくてよく、generic framework、pytest plugin、CI gate 緩和、production timeout 緩和は不要です。変更すべきなのは contract の精度です。

    特に次の3点を固定すれば実装可能性と review convergence が大きく上がります。

    1. readiness 後の timeout 発火手段を contract で明示し、test-local deterministic fault injection を許可するのかを決める。
    2. 新しい named regression node-id を AC1/AC4 に追加し baseline-expect: fail にする。
    3. CPU saturationそのものを required regression にせず、「旧0.6sなら確実に race する delayed-readiness 状態」を同期 primitive で決定論的に作る。 -n4 --dist loadscope は compatibility check に降格する。

    pytest 側も、flake は未制御の system state/timing を制御する方向で修正することを推奨しており、単なる timeout 延長より今回の readiness synchronization 方針の方が適切です。[pytest ドキュメント](https://docs.pytest.org/en/latest/explanation/flaky.html?utm_source=chatgpt.com)

    セキュリティ/ハーネス面で新たな blocker は見つけていません。 問題は process lifecycle 自体ではなく、現在の Issue contract が「何を deterministic に注入すれば #2221 の integration guarantee を維持したとみなすか」をまだ固定できていない点です。

  3. squne121 commented on Oct 2, 2026

    @squne121
    OwnerAuthor

    live GitHub と current issue-refinement-loop を確認しました。対象コメントは REQUEST_CHANGES / reframe_in_place で、current Skill ではこの種のユーザー指定コメントを preflight.run.with_human_context として扱い、canonical Step 2 は issue-reviewer SubAgent ではなく root-owned review pipeline を background 起動して完了 join 必須です。以下をそのまま既存の auto mode Claude Code に貼り付けてください。

    repo=squne121/loop-protocol

    対象:

    この対話セッションは既に auto mode で起動済みである。
    Claude Code の permission mode は変更しないこと。bypassPermissions、--dangerously-skip-permissions、その他 permission bypass を要求・使用しないこと。

    目的

    Issue #2883 に対して、current HEAD の issue-refinement-loop を正式な control-plane として使用し、指定した human-context comment の REQUEST_CHANGES / reframe_in_place を反映して Issue contract を改善する。

    人間による iteration ごとの承認は不要。
    repository の current loop policy が許す範囲で、調査 → contract rewrite → fresh review → readiness/final gate → 必要なら再修正、を bounded に自律継続し、refinement が terminal state に到達するまで行う。

    これは Issue refinement の依頼であり implementation の依頼ではない。
    impl-review-loop、implementation worker、production/test implementation、commit/push/PR 作成へ進んではならない。
    approved になったら refinement の正式な termination/handoff を完了して停止する。

    明示的に承認する作業

    以下の非破壊的作業は、人間への追加確認なしで実施してよい。

    通常の needs-fix、rewrite 要求、checker failure、stale review、freshness mismatch、修正可能な contract defect は停止理由にしない。current Skill に従い、修正して fresh state で再検証すること。

    最初に必ず fresh 確認すること

    過去セッションの状態やこの prompt に書かれた repository details を正本にしない。

    最初に current repository / GitHub から以下を再取得する。

    1. Issue 実装: process-group cancellation 統合 test の固定 0.6s outer deadline を readiness 同期へ置き換え、負荷下の timing flake を解消する #2883 current body / labels / state / comments
    2. anchor comment issuecomment-5962624631 の current snapshot
    3. default branch の current HEAD
    4. .claude/skills/issue-refinement-loop/SKILL.md
    5. SKILL.md が今回必要と指示する references
      • 特に anchor-comment handling
      • AC/VC reflection
      • termination policy
      • follow-up materialization
      • semantic design review
    6. current .claude/agents/** のうち実際に dispatch する SubAgent contract
    7. Issue 実装: process-group cancellation 統合 test の固定 0.6s outer deadline を readiness 同期へ置き換え、負荷下の timing flake を解消する #2883 に既存 implementation PR / follow-up / duplicate Issue が新たに存在しないか
    8. reviewer comment が参照している関連履歴 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2207 / PR 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2221 / 実装: fan-out timeout/cancellation テストを readiness 同期と責務分離で決定論化する #2371 / PR fix: fan-out timeout/cancellation テストを readiness sentinel 同期へ書き換える #2373 と、必要な current code

    古い Skill contract、古い command syntax、古い agent role を推測で再利用しないこと。

    anchor comment の扱い

    今回はユーザーが明示的に指定した direct human context である。

    したがって canonical root/default-branch context から、current command registry に従って
    preflight.run.with_human_context
    lane を使用し、次の anchor URL を binding すること。

    https://github.com/squne121/loop-protocol/issues/2883#issuecomment-5962624631

    preflight.run.with_anchor や agent-report lane にすり替えないこと。

    current Skill に書かれている canonical executor / command registry を使う。
    run_refinement_preflight.py を policy を迂回して直接叩かない。

    planner / checker / routing authority が出した structured decision を prose で再実装・再判定しない。

    今回の reframe で達成すべき中心事項

    anchor comment の findings は単なる参考意見ではなく、今回の refinement input として扱う。

    fresh evidence と current repository contract に矛盾しない限り、以下を Issue #2883 の contract に反映させる方向を優先する。

    1. BLOCKER 解消: deterministic fault injection を明示的に許可

    現在の Issue は、

    • readiness 後に timeout を発火
    • production run_baseline_vc_preflight() path を保持
    • actual outer-timeout handling semantics を保持
    • production script は変更禁止

    を要求しつつ、current production API に readiness 後に wall-clock timer を arm する seam がない、という矛盾を持つ。

    この refinement では、既存 Allowed Path 内の test-local deterministic fault injection を明示的に accepted mechanism として許可する reframe を第一選択とする。

    意図は:

    • real baseline_vc_preflight.py
    • real VC leader
    • real SIGTERM-ignoring grandchild
    • real readiness markers

    を使って process tree が ready になったことを決定論的に確認した後に、test-local fault injection により production supervisor の outer-timeout handling branch を発火させること。

    この integration test は「0.6 秒という elapsed wall-clock deadline 自体」を試験するものではなく、
    ready な real process tree に対して production outer-timeout handling path が実行された場合の cooperative cancellation / full reap / typed timeout result
    を検証する fault-injection integration test であることを Issue contract に明記する。

    real elapsed timeout 自体の既存 coverage は、別の既存 coverage として保持する。

    単に timeout を延長する、blind sleep を増やす、generic test harness / pytest plugin を追加する、といった解決は採用しない。

    fresh code evidence により test-local injection では本当に production timeout branch を通せないことが実証された場合のみ、別案を検討する。
    その場合も勝手に production seam を追加する implementation decisionへ進まず、refinement contract 上で必要な scope を current Skill の trusted reframe rules に従って扱うこと。

    2. CPU saturation regression を deterministic delayed-readiness regression に置換

    AC4 の主要 regression proof として 48 busy-loop 等の実 CPU saturation を required CI に埋め込まない。

    代わりに、

    • fixture readiness を同期 primitive で決定論的に gate/delay する
    • 旧 0.6s wall-clock assumption なら確実に破綻する条件を作る
    • 新設計では readiness 後に timeout path を発火するので deterministic に成功する

    という regression にする。

    pytest -n 4 --dist loadscope は必要なら xdist compatibility の secondary check として保持してよいが、CPU saturation regression の authority として扱わない。

    3. baseline-red の named regression VC を追加

    現在の VC はすべて baseline pass で、新しい regression test を実装しなくても green になり得る。

    current repository の authoring contract に従い、新しい regression node-id を contract 上で固定し、implementation 前には missing node-id により red になる VC を追加する。

    候補名として anchor comment が示した

    test_outer_timeout_fault_injection_waits_for_ready_process_tree

    を検討する。

    current naming convention / current code と整合するならこれを使用し、例えば AC1/AC4 に対して:

    # baseline-expect: fail

    の named pytest VC を持たせる。

    名前を変更する場合は、なぜ current code / repository convention 上その方が正しいか evidence を残すこと。

    4. #2207 / #2221 の integration guarantee を後退させない

    責務分離を採用しても、少なくとも1つの integration test は、同一 invocation について以下を一続きで証明する contract にする。

    ready な real VC leader + grandchild
    → production outer-timeout handling path 発火
    → SIGTERM handler
    → wrapper / leader / grandchild の full reap
    → typed timeout result

    最低限、既存 safety claim である以下を保持する。

    • status == "runtime_error"
    • failure_class == "timeout"
    • timeout_phase == "baseline_vc_preflight_aggregate"
    • retryable is False
    • SIGTERM handler marker
    • wrapper / VC leader / grandchild の reap
    • run_baseline_vc_preflight() production-shaped path
    • _OUTER_DEADLINE_REPEAT_COUNT の意図する register/unregister race coverage

    timeout と reap を完全に別 test に分離し、#2221 が埋めた coverage gap を再導入する contract にしてはならない。

    5. semantic false-green な VC を修正

    単なる

    rg -c "baseline_vc_preflight_aggregate"
    rg -c "run_baseline_vc_preflight"

    を semantic authority にしない。

    named pytest regression を主要な verification authority とする。
    static verification を残す場合は actual assertion / invocation shape を検査するものへ寄せるが、semantic sufficiency は pytest で担保する。

    6. moving origin/main に弱い diff VC を修正

    branch が導入した差分を確認する目的なら、current repository-native changed-path authority が存在する場合はそれを優先する。

    単純 git command が適切なら、

    origin/main...HEAD

    の merge-base based diff を使う方向で contract を修正し、moving upstream の差分を当該 branch の変更と誤認しないようにする。

    7. Issue contract 全体の整合性を取る

    上記変更に伴い、必要な範囲で以下を相互整合させる。

    • Outcome
    • Current Validated Scope
    • In Scope
    • Out of Scope
    • Acceptance Criteria
    • Verification Commands
    • Allowed Paths
    • Stop Conditions
    • Notes for Reviewer
    • Background / rationale

    特に、「test-local deterministic fault injection を accepted mechanism とする」と決めたのに、それを synthetic timeout として禁止するような記述を残さない。

    一方で production code / CI policy / generic harness へ scope を膨らませない。

    SubAgent 利用要件

    SubAgent は current Skill が要求・許可する役割だけを使う。

    Investigation

    REFINEMENT_LOOP_PLAN_V1.decisions.investigation_policy.required == true の場合は、
    codebase-investigator を使用する。

    dispatch 時には親会話の暗黙 context に依存させず、最低限以下を明示する。

    SubAgent を dispatch しただけで完了扱いにしない。
    terminal completion を待ち、最終結果を取得してから次工程へ進むこと。

    Web research

    planner の web_research_policy.required == true の場合だけ web-researcher を使用する。

    pytest / pytest-xdist / Python subprocess semantics 等、external claim が disposition に影響する場合は一次資料を優先する。

    Investigation と Web research がともに required なら並列実行してよいが、
    両方の最終結果を join してから Step 2 へ進むこと。

    Rewrite

    canonical routing が Step 4 / issue_editor_required を要求する場合は current issue-editor / edit-issue contract を使用する。

    これも dispatch だけで成功扱いにしない。

    • editor の terminal result を取得
    • GitHub の fresh body readback を取得
    • post-mutation checker を実行
    • fresh preflight
    • fresh Step 2 review
    • fresh readiness

    まで完了して初めて rewrite が downstream authorization を得たとみなす。

    canonical Step 2 に関する重要事項

    current issue-refinement-loop の canonical Step 2 では、issue-reviewer SubAgent を起動しないこと。

    current .claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py produce を root-owned producer として使用し、current Skill が規定する通り Claude Code Bash で 明示的 background launch する。

    そして、background task の起動を Step 2 完了とみなしてはならない。

    task notification / completion result を mandatory join し、実際の完成 JSON を取得してから canonical_step2_route を読むこと。

    routing は canonical_step2_route を唯一の authority とし、status / verdict / next_action から独自に再計算しない。

    refinement loop の継続方針

    current Skill の default bounded loop を使用する。明示的理由がなければ max_iterations は current default を使う。

    needs-fix の場合、上限未到達なら自動で rewrite → fresh review を継続する。

    各 iteration で人間承認を要求しない。

    以下は途中停止理由にしない。

    • reviewer の通常 REQUEST_CHANGES
    • deterministic contract repair
    • structural repair
    • AC/VC reflection repair
    • trusted human-context に基づく controlled reframe
    • stale review の再取得
    • body freshness の再検証
    • semantic false-green VC の修正
    • current Skill が canonical に処理できる issue-editor handoff

    ただし current canonical authority が明示的に
    human_judgment_required
    または environment/integrity failure を返した場合は、その route を無視して突破しない。

    Final Gate

    Issue body を rewrite した後は、古い review/readiness result を再利用しない。

    fresh body に対して current canonical final review/readiness gate を通す。

    通常の implementation Issue なので、current policy が要求する
    CONTRACT_REVIEW_RESULT_V1.status == "go"
    および freshness 条件を満たすまで approved 終了しない。

    status: blocked で修正可能なら refinement loop を継続する。

    next_action: human_judgment の場合のみ human escalation とする。

    approved に到達しても、この invocation から impl-review-loop を開始してはならない。
    current termination policy に従い LOOP_HANDOFF_RESULT_V1 / termination report を正式に publish して終了する。

    再発防止 Issue の扱い

    今回の refinement 中に、#2883 自体を直すだけでは再発する 別 scope の concrete systemic defect を確認した場合は follow-up Issue を検討する。

    例:

    • repository-native contract authoring/checker が、同種の「全 VC baseline pass で regression node が存在しなくても green」Issue を継続的に生成できてしまう
    • semantic assertion を rg -c token の存在だけで満たす false-green が複数 Issue で繰り返される
    • current refinement tooling の producer / consumer divergence により同じ reframe failure が再発する

    ただし generic hardening や speculative security/harness Issue を増やさない。

    起票前に必ず:

    1. open/closed Issue を検索
    2. same root cause / same intended fix の既存 Issue がないか確認
    3. repository-native dedupe_key を設計
      4.既存 Issue があるなら重複起票しない

    新規 Issue が本当に必要なら、current issue-refinement-loop の follow-up materialization policy に従って起票してよい。
    これは明示的に承認する。

    単に #2883 の contract rewrite で十分な事項を別 Issue に分割しないこと。

    品質方針

    個人趣味開発であるため、具体的 defect を解決しない enterprise hardening、追加 approval layer、generic wrapper、恒久 gate、schema 増殖は避ける。

    優先順位は:

    1. false-green / timing flake の根本原因除去
    2. deterministic で実装可能な Issue contract
    3. 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2207/実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2221 の実際の coverage guarantee 維持
    4. review convergence
    5. workflow の軽量性

    security/harness は正規 workflow を妨げない範囲にする。

    停止境界

    以下の場合のみ停止/escalate する。

    • current canonical authority が human_judgment_required を返した
    • destructive operation が必要
    • secret / credential の取得・変更・公開が必要
    • force push / history rewrite が必要
    • current Skill の bounded iteration 上限に到達
    • evidence integrity を維持できない
    • environment/integrity failure が canonical route で解消不能
    • trusted human directive と repository canonical contract が irreconcilable
    • policy bypass が必要

    通常の reviewer finding や修正可能な checker failureだけでは停止しない。

    最終報告

    terminal completion 後、簡潔に以下を報告する。

    調査や提案だけで止まらず、current issue-refinement-loop の terminal state まで実際に実行すること。

    特に重要なのは、指定コメントを with_human_context として処理すること、Step 2 の background task を必ず join すること、そして refinement 完了後にそのまま実装へ越境しないことです。

  4. squne121 commented on Oct 2, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(approved)

    Issue #2883 の refinement を完了しました。OWNER の REQUEST_CHANGES / reframe_in_place(https://github.com/squne121/loop-protocol/issues/2883#issuecomment-5962624631)を preflight.run.with_human_context lane で反映し、承認済み本文は sha256:242b6d91ba1993fc9ba1bea7edc27ba2b6c024fad6607e2a6e7a62ba9a0ef95c です。

    • 終了理由: approved(iteration 1 / max 3)
    • 調査: codebase-investigator で current main(1974fddf)を fact-check(production seam なしで test-local fault injection が成立することを root が独立にコード確認)
    • 本文更新: issue-editor 経由の controlled transaction。GitHub readback で本文一致を確認
    • fresh review: produce の canonical_step2_route は step_2_5(approve / proceed)、semantic_review_applicable は false のため Step 4.5 へ。final review gate は final_review_allowed: true
    • contract readiness: CONTRACT_REVIEW_ONCE_RESULT_V1(execute mode)が status: go。名前付き regression VC は baseline で expected_fail
    • follow-up Issue: なし(材料なし・planner の follow_up_materialization も候補 0 件)
    • 注記: 実装は開始していません。impl-review-loop は起動していません。approved は実装開始の代替承認ではありません
    LOOP_HANDOFF_RESULT_V1:
      status: refinement_approved
      routing_action: none
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: "none(本 session の CONTRACT_REVIEW_ONCE_RESULT_V1 execute mode の go 結果。comment 永続化なし)"
        generated_at: 2026-10-02T22:56:26Z
        body_sha256: sha256:242b6d91ba1993fc9ba1bea7edc27ba2b6c024fad6607e2a6e7a62ba9a0ef95c
      metadata:
        title_prefix_ready: true
      label_sync_observation:
        kind: presentation_sync
        result: noop
        detail: label は presentation-only のため変更していない
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: 2026-10-02T22:56:26Z
      checked_body_sha256: sha256:242b6d91ba1993fc9ba1bea7edc27ba2b6c024fad6607e2a6e7a62ba9a0ef95c
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
  5. squne121 commented on Oct 2, 2026

    @squne121
    OwnerAuthor

    live GitHub を再確認したところ、#2883 は現在も open で実装契約が確定済み、refinement 終了コメントは fresh_go、current main は 1974fddf76ca1c0956e3eb77df52c8a5c31dd382、#2883 を参照する既存 PR は現時点の検索では見つかっていません。前セッションも「実装・commit・PR は開始していない」状態で終了しています。貼り付けたテキスト(1)

    推奨アクションは、fresh session から current impl-review-loop の Root-Owned Synchronous Entry Transition を正規入口として実行し、pre-Step-1 の landing disposition が通常 dispatch を返した場合だけ実装開始です。過去の LOOP_HANDOFF_RESULT_V1 を実装 authorization として再利用しない点が重要です。

    以下を、そのまま既に auto mode で起動済みの fresh Claude Code に貼り付けてください。

    repo=squne121/loop-protocol

    対象:

    この対話は fresh Claude Code session で、既に auto mode で起動済みである。

    Claude Code の現在の permission mode は変更しないこと。
    bypassPermissions、--dangerously-skip-permissions、その他 permission bypass を要求・使用してはならない。

    目的

    Issue #2883 を current HEAD の canonical impl-review-loop で、

    fresh intake → implementation → independent verification → PR review → fix → re-test → fresh re-review

    まで bounded に自律実行し、人間が merge 判断できる直前の terminal state まで進める。

    iteration ごとの人間承認は不要。

    通常の implementation failure、test failure、REQUEST_CHANGES、修正可能な CI failure、stale review、main drift、BEHIND、reviewer が要求する bounded fix は、人間確認の理由にせず current canonical routing に従って自動修正・再検証すること。

    実 merge、auto-merge、force push、history rewrite は行わない。


    1. 最初に必ず fresh state を取得する

    この prompt や過去 session の SHA、PR 不在、refinement 結果を current authority とみなさない。

    最初に live repository / GitHub から以下を fresh 取得すること。

    1. Issue 実装: process-group cancellation 統合 test の固定 0.6s outer deadline を readiness 同期へ置き換え、負荷下の timing flake を解消する #2883
      • state
      • title
      • body
      • labels
      • 全 comments
      • updatedAt
    2. refinement 終了コメント
    3. current default branch と main HEAD
    4. 実装: process-group cancellation 統合 test の固定 0.6s outer deadline を readiness 同期へ置き換え、負荷下の timing flake を解消する #2883 を close / reference / implement している open・draft・merged・closed PR
    5. 実装: process-group cancellation 統合 test の固定 0.6s outer deadline を readiness 同期へ置き換え、負荷下の timing flake を解消する #2883 に対応する既存 branch / worktree
    6. current .claude/skills/impl-review-loop/SKILL.md
    7. SKILL.md が指定する current steps、最低限:
      • steps/preparation.md
      • steps/step-1-implementation.md
      • steps/step-2-verification.md
      • steps/step-4-pr-review.md
      • steps/step-5-feedback-and-termination.md
      • steps/step-5-mergeability-handling.md
      • 必要なら conflicting PR runbook / context protocol
    8. 実際に dispatch する current SubAgent contract:
      • .claude/agents/implementation-worker.md
      • .claude/agents/test-runner.md
      • .claude/agents/pr-reviewer.md
      • follow-up Issue が必要になった場合のみ .claude/agents/issue-creator.md
    9. Issue が参照する relevant source / tests / design references
    10. current required CI / branch state / relevant PR evidence

    古い command syntax、古い agent role、過去 session の LOOP_STATE を推測で再利用しない。


    2. 過去の refinement handoff を implementation authorization にしない

    Issue #2883 には過去の:

    LOOP_HANDOFF_RESULT_V1.status: refinement_approved

    が存在するが、current impl-review-loop の契約上、それ自体は Step 1 起動 authorization ではない。

    current impl-review-loop の Root-Owned Synchronous Entry Transition を正規入口とすること。

    root/main thread が current Skill の SSOT に従い、同一の continuous invocation / control flow 内で少なくとも:

    1. capability preflight
    2. live Issue fetch
    3. current-run issue-contract-review
    4. 直後の live Issue re-fetch
    5. current routing decision
    6. route が implementation invocation を許可した場合のみ Step 1 dispatch

    を連続して行うこと。

    過去 comment、artifact、body SHA、snapshot、handoff marker、旧 invocation token を Step 1 起動 authority として代用しない。

    current repository の
    .claude/skills/issue-refinement-loop/scripts/root_entry_router.py
    および current termination-policy が正本として要求する route を使用すること。

    structured routing result を prose で再実装・再解釈しない。


    3. Step 1 より前に Evidence-Based Landing Disposition を必ず評価する

    worker dispatch、worktree 作成、新規 PR 作成より前に current impl-review-loop の pre-Step-1 landing disposition を実行する。

    特に次を fresh に確認する:

    current producer が返す disposition を authority とし、独自判定しない。

    routing:

    • implementation_already_landed
      → worker / new worktree / duplicate PR を開始しない
    • existing_pr_resume
      → 既存 PR / branch / worktree を再利用し、新規 PR を作らない
    • already_satisfied
      → current canonical already-satisfied route に従い no-op recommendation を報告
    • ordinary_dispatch_or_explicit_recovery
      → Step 1 へ進む
    • reconciliation_required
      → current workflow の reconciliation を実行。証拠を無視して新規 PR を作らない

    現時点では live GitHub 検索上 #2883 の PR は見つかっていないが、これは prompt 作成時点の観測にすぎない。必ず fresh に再検索すること。


    4. 明示的に承認する作業

    以下の作業は、この依頼により追加の人間承認なしで実施してよい。

    ただし current canonical Skill / SubAgent / controlled executor の責務分担を守ること。root thread が data-plane operation を直接行うべきでない場合は適切な SubAgent に委譲する。

    承認する:

    • repository / GitHub / Issue / PR / CI の read-only 調査
    • current Skill / steps / agents / SSOT の読取
    • canonical intake capsule / root entry / landing disposition の実行
    • canonical issue worktree の非破壊的作成・再利用
    • canonical branch の作成・再利用
    • Issue 実装: process-group cancellation 統合 test の固定 0.6s outer deadline を readiness 同期へ置き換え、負荷下の timing flake を解消する #2883 の Allowed Paths 内だけの実装変更
    • implementation-worker によるファイル編集
    • test-runner による Verification Commands の独立実行
    • narrow pytest / xdist verification
    • repository-native lint / checker 等、current workflow が要求する検証
    • implementation commit 作成
    • non-force push
    • current open-pr route を使った PR 作成
    • 既存 PR があればその再利用・更新
    • PR body hygiene / closing keyword 等の canonical mechanical repair
    • PR review comment / audit comment の canonical publish
    • pr-reviewer による fresh HEAD review
    • REQUEST_CHANGES の blocker 修正
    • fix_delta 適用
    • branch update / main drift reconciliation
    • update_branch 後の verification + re-review
    • stale reviewed HEAD の fresh re-review
    • current-head required CI の確認
    • current canonical workflow が許す修正可能な CI failure の原因調査・修正
    • current workflow が許す場合の failed CI job の bounded retry
    • review/fix iteration
    • concrete systemic defect に対する follow-up Issue の dedupe 調査と、必要な場合の起票

    承認しない:


    5. Issue #2883 の実装 scope

    fresh live Issue body を最終 authority とする。

    prompt 作成時点では Allowed Paths は:

    .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py

    の1ファイルだけである。

    live contract が変化していなければ このファイル以外を編集しない。

    production scripts、CI policy、dependency、pytest plugin、generic framework 等へ scope を膨らませない。

    特に以下は current contract 上 Out of Scope のため変更禁止:

    • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
    • .claude/skills/issue-contract-review/scripts/contract_readiness_check.py
    • .github/ci/python-test-plan.json
    • pyproject.toml
    • uv.lock
    • production timeout semantics
    • production test seam
    • required CI policy

    production seam が本当に不可避だと実証された場合、独自に scope を拡張せず current Stop Condition / routing に従う。


    6. 実装上の load-bearing requirements

    Issue body の AC/VC を authority としつつ、少なくとも以下の設計意図を失わないこと。

    A. wall-clock 0.6s dependency を除去

    旧設計の:

    _OUTER_DEADLINE_SECONDS = 0.6

    以内に fixture startup + pytest import + grandchild spawn が完了するという assumption に依存しない。

    単なる timeout 延長、blind sleep 増加では修正しない。

    B. test-local deterministic fault injection

    real:

    • baseline_vc_preflight.py
    • VC leader
    • SIGTERM-ignoring grandchild
    • readiness marker

    を使用する。

    real process tree が ready になったことを同期で確認した後に、test-local fault injection で production supervisor の outer-timeout handling branch を発火させる。

    注入してよいのは timeout 発生点のみ。

    以下を stub / fake / 再実装 / bypass しない:

    • supervisor の SIGTERM
    • grace wait
    • SIGKILL escalation
    • process reap
    • typed timeout result construction
    • run_baseline_vc_preflight() production-shaped invocation path

    C. 同一 invocation の integration guarantee を維持

    少なくとも1つの integration test で同一 invocation 内に:

    ready real VC leader + grandchild
    → production outer-timeout handling branch
    → SIGTERM handler marker
    → wrapper / VC leader / grandchild full reap
    → typed timeout result

    を一続きで検証する。

    最低限維持する assertion:

    • status == "runtime_error"
    • failure_class == "timeout"
    • timeout_phase == "baseline_vc_preflight_aggregate"
    • retryable is False
    • SIGTERM handler marker
    • wrapper dead
    • VC leader dead
    • grandchild dead
    • run_baseline_vc_preflight() 経由
    • contract が要求する repeat semantics

    timeout と reap を完全に別々の test に分離して #2207 / #2221 の coverage guarantee を後退させない。

    D. deterministic delayed-readiness regression

    current Issue が指定する named regression:

    test_outer_timeout_fault_injection_waits_for_ready_process_tree

    を実装する。

    fixture readiness を test-controlled synchronization primitive で deterministic に gate / delay し、旧 0.6s 設計なら readiness 前に timeout して失敗する failure class を固定する。

    required regression に CPU busy loop を入れない。

    -n 4 --dist loadscope は xdist compatibility check として扱い、CPU saturation proof の代用にしない。


    7. SubAgent を必ず使用し、terminal completion を join する

    SubAgent dispatch だけで作業完了扱いにしてはならない。

    すべての必要な SubAgent は最終 result / terminal completion を取得してから downstream step へ進む。

    Step 1 — implementation-worker

    current implementation-worker を使用する。

    child message は current Step 1 contract に従い、親会話の暗黙 context に依存させず実値を渡す。

    最低限:

    を明示する。

    worker が current .claude/skills/implement-issue/SKILL.md を実行し、

    worktree → implementation → local verify → commit → push → PR create/update

    まで current Skill が担当する範囲を完了させる。

    dispatch 後は worker の terminal completion を必ず待つ。

    IMPLEMENT_RESULT_V1.status: ok を取得する前に Step 2 へ進まない。

    Step 2 — test-runner

    implementation の exact HEAD を対象に test-runner を sibling SubAgent として起動する。

    最低限:

    • actual Issue number
    • actual PR number
    • contract body SHA
    • exact diff HEAD SHA
    • literal AC list
    • literal Verification Commands
    • exact verification cwd

    を materialize して渡す。

    independent read-only verification とする。

    test-runner の terminal result を取得するまで Step 4 に進まない。

    current canonical VC adjudication / current-head gate を使用し、過去 HEAD の PASS を再利用しない。

    Step 4 — pr-reviewer

    exact current PR HEAD を対象に pr-reviewer を起動する。

    current .claude/skills/pr-review-judge/SKILL.md の手順に従わせる。

    最低限:

    • PR number
    • exact reviewed HEAD SHA
    • live linked Issue
    • current test / CI evidence

    を与える。

    Allowed Paths Gate は live Issue body を authority にする。

    pr-reviewer の terminal completion を必ず待ち、最低限:

    • verdict
    • reviewed_head_sha
    • blockers
    • warnings

    を取得する。

    reviewer が自己申告する mergeability を authority にしない。
    mergeability は root/control-plane が live GitHub から取得する。


    8. review/fix loop を人間承認なしで継続する

    current default loop policy を使用する。
    明示的な別値が current SSOT にない限り max_iterations は current default(現在は 3)を用いる。

    REQUEST_CHANGES

    actual conflict がなければ停止しない。

    • blockers を構造化された fix_delta にする
    • implementation-worker に再委譲
    • terminal completion を待つ
    • fresh exact HEAD で Step 2 を再実行
    • Step 2 terminal result を待つ
    • Step 4 を fresh HEAD で再実行
    • terminal result を待つ
    • Step 5 を再判定

    stale reviewed HEAD

    human escalation しない。

    fresh current HEAD で pr-reviewer を再実行する。

    BEHIND / update_branch

    current router が route_to_update_branch を返した場合は current implementation-worker の canonical update_branch mode に委譲する。

    worker 完了後:

    • verification を再実行
    • PR review を再実行
    • new HEAD で Step 5 を再判定

    する。

    ordinary test / CI failure

    修正可能で #2883 scope 内なら自動修正する。

    test/CI failure を「人間承認が必要」として停止しない。

    false-green を作るために test を削る、assertion を弱める、CI policy を緩和する、timeout を単純延長することは禁止。


    9. Step 5 は current deterministic router に従う

    reviewer verdict と live mergeability を独自 prose で判定しない。

    current route_loop_verdict_v2() / current Step 5 procedure を使用する。

    main drift facts も current SSOT の方法で fresh に構築する。

    特に:

    • live PR head
    • live base/main SHA
    • evidence base SHA
    • Allowed Paths
    • latest main net diff
    • semantic ambiguity

    を必要に応じて current canonical implementation から取得する。

    semantic ambiguity を推測値 false で埋めない。

    actual Git conflict:

    • mergeable == CONFLICTING
    • merge_state_status == DIRTY

    だけは current runbook に従う hard stop とする。

    BLOCKED / UNSTABLE / DRAFT / UNKNOWN を自動的に Git conflict と扱わない。


    10. PR 作成・再利用

    pre-Step-1 landing disposition で既存 PR が検出された場合、それを再利用する。

    duplicate PR を作らない。

    新規 PR が必要な場合は implementation-worker → current implement-issue → open-pr の正規経路を使う。

    current repository policy が Draft PR を要求するなら Draft のまま進める。

    PR body / closing relationship / Issue reference は current open-pr contract に従う。

    PR が既に存在している状態で fix iteration に入った場合、新規 PR を作らず同一 branch / PR を更新する。


    11. 再発防止 Issue

    今回の実装・review 中に、#2883 を直すだけでは再発する 具体的な別 scope の systemic defect が確認された場合は follow-up GitHub Issue を起票する。

    これはこのユーザー指示により明示的に承認する。

    ただし generic hardening、enterprise-style gate、wrapper、schema、approval layer を理由なく追加しない。

    対象例:

    • 同種の timing-dependent integration test を繰り返し生成する canonical test-authoring defect
    • semantic assertion を token existence だけで判定して同じ false-green が再発する tooling defect
    • producer / consumer の semantic divergence
    • current regression authoring/checker が同じ failure class を防止できない concrete defect

    起票前に必ず:

    1. open Issue を検索
    2. closed Issue も検索
    3. related PR / historical fix を確認
    4. same root cause / same intended fix の Issue がないか dedupe
    5. repository-native dedupe_key を設計
    6. existing canonical Issue があれば新規起票しない

    新規起票が必要なら、root/main thread から sibling の current issue-creator SubAgent を使用する。

    current .claude/agents/issue-creator.md
    +
    .claude/skills/create-issue/SKILL.md

    を fresh に読み、FOLLOW_UP_ISSUE_REQUEST_V1 等の current canonical input を使う。

    raw gh issue create を即席で組み立てない。
    current controlled transaction route を使う。

    issue-creator を dispatch したら terminal completion を待ち、Issue URL / number / dedupe result を取得する。

    follow-up Issue の起票は #2883 の Allowed Paths を拡張する権限ではない。

    もし live #2883 contract の Stop Condition が scope split を要求する場合:


    12. 品質方針

    個人趣味開発である。

    優先順位:

    1. timing flake の根本原因除去
    2. deterministic regression
    3. 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2207 / 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2221 の integration guarantee 維持
    4. false-green 防止
    5. review convergence
    6. workflow の軽量性

    具体的 defect を解決しない generic security hardening、追加 approval layer、恒久 gate、wrapper/schema 増殖は避ける。

    security / harness は正規 workflow を妨げない範囲にする。


    13. 停止境界

    以下の場合のみ停止 / escalation 候補とする。

    • current canonical authority が human_judgment_required / human escalation を返す
    • actual Git conflict が current conflict runbook で自動解決不能
    • Allowed Paths 外の implementation が不可避
    • 実装: process-group cancellation 統合 test の固定 0.6s outer deadline を readiness 同期へ置き換え、負荷下の timing flake を解消する #2883 の fixed contract と実 repository reality が irreconcilable
    • destructive operation が必要
    • secret / credential の取得・変更・公開が必要
    • force push / history rewrite が必要
    • policy / permission bypass が必要
    • foreign dirty worktree / unrelated work を壊さないと続行できない
    • evidence integrity を維持できない
    • canonical bounded iteration 上限に到達
    • environment failure が current canonical recovery route で解消不能

    以下は停止理由ではない:

    • ordinary test failure
    • ordinary CI failure
    • reviewer REQUEST_CHANGES
    • stale reviewed HEAD
    • BEHIND
    • fixable PR body hygiene
    • fixable branch drift
    • bounded current-head re-review
    • deterministic regression が最初に赤いこと
    • implementation-worker / test-runner / pr-reviewer の通常の修正可能 finding

    14. merge 直前で停止する

    最終目的は 人間が merge を判断できる直前。

    current canonical terminal conditionが満たされるまで進める。

    期待状態は current Skill が定義する approved / draft_pr_ready 相当:

    • current PR HEAD に対する independent verification が pass
    • required/current-head CI が current policy を満たす
    • pr-reviewer が fresh HEAD を review 済み
    • blockers が空
    • current router が approved terminal route
    • actual merge conflict なし
    • Allowed Paths compliance
    • unresolved REQUEST_CHANGES なし

    ここまで到達したら停止する。

    gh pr merge、merge API、auto-merge enable は実行しない。


    15. 最終報告

    terminal completion 後、簡潔に以下を報告する。

    • Issue 実装: process-group cancellation 統合 test の固定 0.6s outer deadline を readiness 同期へ置き換え、負荷下の timing flake を解消する #2883 の live state
    • implementation loop termination reason
    • landing disposition
    • 使用した worktree / branch
    • PR number / URL
    • final PR HEAD SHA
    • main/base SHA
    • 実装した変更の要旨
    • AC1〜AC6 の結果
    • Verification Commands の結果
    • required/current-head CI の結果
    • review iteration 数
    • 最終 pr-reviewer verdict
    • live mergeability / mergeStateStatus
    • 使用した SubAgent 一覧
    • 各 SubAgent について terminal completion を取得してから次工程へ進んだこと
    • REQUEST_CHANGES とその修正履歴
    • follow-up Issue の有無
      • 起票した場合: Issue number / URL / dedupe_key / root cause
      • dedupe で既存 Issue に route した場合: canonical Issue
    • unresolved blocker
    • merge / auto-merge は実行していないこと

    調査・計画・SubAgent dispatch だけで止まらないこと。

    current impl-review-loop の terminal state、または上記の正当な停止境界に到達するまで、実際に implementation / verification / review / fix loop を遂行すること。

    この形なら、直前の refinement 成果を尊重しつつも、fresh session が古い handoff を authorization と誤認するのを防ぎ、現在の impl-review-loop が要求する synchronous entry と pre-Step-1 duplicate detection から開始できます。

  6. squne121 commented on Oct 2, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了

  7. squne121 commented on Oct 2, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  8. squne121 commented on Oct 3, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-10-03)

    今回の経緯: OWNER コメント(https://github.com/squne121/loop-protocol/pull/2885#issuecomment-5963140832)の P1(自然発火する outer timeout の coverage 消失)と P2(injection 検証失敗時の cleanup 迂回)を human-context として取り込み、#2883 の契約を最小 reframe(AC7 と AC8 を追加)したうえで、既存 PR を再開して修正しました。

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2885"
      head_sha: "b56d06035767c232e46c18ca145af5f755af85b4"
      issue_number: 2883
      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

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions