Skip to content

実装: root review outer timeout と invocation-local budget の parity を固定する #2610

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "root_review_pipeline.produce のtimeoutをregistryから実際に消費するrepository-owned consumerが存在する場合に限り、full produce envelopeより短いouter deadlineを再発不能にする"
change_kind: code

Parent Issue

none

Parent Goal Ref

Current Validated Scope

  • 最初に root_review_pipeline.produce の execution surface(.claude/skills/issue-refinement-loop/SKILL.md のStep 2記述)/registry timeout consumer/outer deadline owner/signal producer/process cleanup owner の5項目を個別にinventoryし、rendered command・caller・deadline値の対応で証明する(consumer不在を無条件no-op停止の理由にしない。下記「In Scope」a/b参照)。
  • 実consumerが確認された場合だけ、.claude/skills/issue-refinement-loop/scripts/command_registry.py、.claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py、.claude/skills/issue-contract-review/scripts/contract_readiness_check.py の範囲で、そのconsumerが読むbounded timeout contractを変更する。実consumerが確認されない場合でも、command_registry.pyのtimeout_secondsが未強制/informational値であることを明記する注記追加(下記In Scope d)は行う。
  • .claude/skills/issue-refinement-loop/SKILL.md のStep 2実行契約を「明示的background launch(run_in_background: true)+ mandatory completion join」に変更し、background起動時点をStep 2完了として扱わないことを明記する(OWNER REQUEST_CHANGES、下記In Scope c)。
  • ReviewBudget のinner deadlineではなく、body fetch/pin、canonical-plan/setup、accepted bodyのReviewBudget.total_seconds、TERM/KILL wait、bounded reader join、result/artifact finalizationを含むfull produce envelopeをnamed SSOTまたはexplicit bounded transportで扱う。inner(ReviewBudget)/outer(SKILL.md background+join契約)の責務分離を維持し、outerがbody-specific budgetを事前二重計算・transportする新protocolは追加しない。
  • .claude/skills/issue-refinement-loop/tests/test_review_budget_wiring.py、.claude/skills/issue-contract-review/tests/test_run_contract_review_once_wrapper_wiring.py、新規.claude/skills/issue-refinement-loop/tests/test_root_review_pipeline_outer_timeout_budget.pyでfocused parity/integration testを追加する。既存のcommand_registry.py --validate CLI機能に対しては、新規thin pytest wrapper .claude/skills/issue-refinement-loop/tests/test_command_registry_validate_cli.py を追加し、uv run python3 直呼びをVCから排除する(下記In Scope e、VC preflight allowlist制約対応)。
  • skill_runtime_exec.pyをroot-review eligible commandへ追加して回避しない。inventoryで実行ownerと確認できた場合だけ、Allowed Paths外のためStop Conditionsに従う。

Remaining Parent Gaps

  • なし。AGY authentication persistenceは別Issueで扱い、本Issueに含めない。

Outcome

repository-owned outer consumerが確認された場合に、そのouter deadlineがcurrent canonical VC planから導かれる合法なfull produce envelopeを下回らず、inner budgetの将来変更がstatic/parityまたはproduction-shaped regression testで検出される状態。repository外harnessだけがdeadline ownerの場合は、コード変更を開始せず、その証跡を残して停止する状態。加えて、SKILL.md Step 2実行契約がbackground launch + mandatory completion joinとして明記され、registryのtimeout_secondsが実consumer不在の現状で未強制/informational値であることが明示され、Issue #2584に対する1回限りのread-only canaryで実際のexecution surfaceを検証した状態。

Runtime Verification Applicability

decision: immediate
applicable_acs: [AC2, AC3, AC4, AC5, AC9]
execution_environment: "network/auth不要のlocal pytest。deadline/clockはtest-only injectionまたはproduction-shaped fixtureで制御する。AC9のみ#2584に対する1回限りのread-only GitHub呼び出しを伴う(常設CI live mutation gateにはしない)。"
skip_conditions:
  - "registry timeoutを読むrepository-owned outer consumerをinventoryで確認できない(AC2/AC3のnamed SSOT変更のみskipし、AC1/AC6/AC7/AC8/AC9のtest-onlyまたは注記系ACはskipしない)"
  - "outer deadline ownerがrepository外harnessのみである(同上)"
fallback_policy: "skip conditionではコード変更・成功主張を行わずStop Conditionsに従って停止し、ownerへexecution ownerの証跡を返す。"
artifact_requirements:
  - "focused pytestの結果: review-budget wiring、wrapper wiring、outer-envelope parity、command_registry --validate wrapper"
  - "command_registry.py --validateの成功出力(pytest wrapper経由)"
  - "AC9 canary実行の証跡(route/approve/implementation authorizationを捏造していないことの確認込み)"
reason: "AC2/AC4/AC5はtimeout ownershipとfail-closed cleanupを実行形fixtureで検証する必要があり、AC9はcanonical execution surfaceに対する1回限りのread-only実地確認を必要とする。"

Current Evidence

  • Evidence cut: 2026-09-10; repository source was checked at a2568fdad178b9e22b74595a982f0550c2595f49. 9b54baadb6ff971d17be95cadf1729236172eeec is prior evidence, not the current checked-out HEAD.
  • 実装: repair_action.apply の unauthorized_write_path false negative を解消する #2584 comment 5611908804は、preflight.run.with_human_context成功後にroot-owned reviewがregistered 90-second budget後にterminateされ、exit 143となりcanonical_step2_routeを生成しなかったと記録する。Issue本文はrewriteされずimplementation-readyではない。
  • current registryはroot_review_pipeline.produce.timeout_seconds: 90を宣言する。
  • current sourceのminimum compatibility ReviewBudgetはN<=2でbaseline aggregate 350s、readiness wrapper 400s、reviewer per-attempt 480s、reviewer total 520s。
  • current 実装: repair_action.apply の unauthorized_write_path false negative を解消する #2584 bodyをside-effect-free canonical VC-plan producerで計算すると、command_occurrence_count=4、aggregate=660s、ReviewBudgetはbaseline=680s / readiness=730s / per-attempt=810s / total=850s。
  • 90秒はminimum 520秒と#2584固有の850秒のいずれも下回る。ただしこれだけではouter 90秒のconsumer・signal producer・active phase・repository内外のexecution ownerは証明しない。
  • skill_runtime_exec.pyはgeneric registry executor向けSIGTERM→grace→SIGKILL cleanupを持つが、root_review_pipeline.produceはcurrent policyのeligible commandとして確認されていない。#2584のexit 143を当該executorへ帰属しない。
  • 5項目inventoryの現状調査結果(OWNER REQUEST_CHANGES反映): (1) execution surface = .claude/skills/issue-refinement-loop/SKILL.md Step 2記述(main-thread直接Bash実行、canonical Step 2 routing authority); (2) registry timeout consumer = scripts/agent-guards/skill_runtime_command_policy.py の SKILL_RUNTIME_COMMAND_POLICY_V2["eligible_command_ids"] に root_review_pipeline.produce は含まれず、registryのtimeout_seconds: 90を読むrepository-owned callerは調査時点で確認できない(証拠: eligible_command_idsキー集合の直接確認); (3) outer deadline owner = 現状なし(repository内に明示的なouter watchdog実装が存在しない); (4) signal producer = exit 143はSIGTERM示唆だが送信元は未証明のまま維持する; (5) process cleanup owner = 現状なし(skill_runtime_exec.pyのcleanup契約は対象外のため適用されない)。この5項目inventory結果は、consumerが見つからないことを理由に無条件no-op停止する根拠にはしない(下記In Scope a/b)。

Timeout Ownership Decision

  • fact (high confidence): registryのstatic 90s宣言はpipelineのcurrent legitimate ReviewBudgetより短い。registryをouter deadlineとして消費するconsumerではcontract driftとなる。
  • fact (medium confidence): #2584での90秒terminationとexit 143のsignal producer、inner active phase、cleanup telemetry、repository内外のownerは未証明である。
  • fact (high confidence, OWNER REQUEST_CHANGES反映): registryのtimeout_secondsフィールドは、実consumerが存在しない現状では repository codeによって強制されない、ドキュメント/意図表示専用の値である。現在の90という値はminimum legitimate ReviewBudget(520秒)や#2584相当(850秒)を大きく下回り、"canonical runtime budget"であるかのように誤解を招くdriftである。実consumerがない場合でも、この値をそのまま放置せず、command_registry.py内のコメントに「unenforced / informational, see SKILL.md Step 2 background+join contract for actual execution model」相当の注記を追加して是正する(下記In Scope d、AC7)。
  • required design: outer timeoutをbody-derived ReviewBudgetだけでなくfull produce envelopeから導出し、static integerが必要なconsumerではaccepted policy ceilingから同じpure derivationでmaximum envelopeを作る。単なる90 → 任意の固定大値は不可。
  • inner/outer責務分離(OWNER REQUEST_CHANGES反映): 既存のinvocation-local ReviewBudget(body取得後にVC occurrence数から計算、実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2207/#2221実装)はinner semantic/runtime deadlineのSSOTとして維持し、outer(SKILL.mdのbackground+join契約)がbody-specific budgetを事前に二重計算・transportする新protocolは追加しない。
  • outer supervisionの実装方式(OWNER REQUEST_CHANGES反映): monotonic absolute deadlineの要求は、既存のinner ReviewBudget実装(run_root_review_pipeline.py/reviewer_transport.pyのSIGTERM→grace→SIGKILL/reap実装)に対して維持し弱化しない。新しいouter watchdogスクリプトの新規実装は、Stop Conditions(control-plane増殖回避、新schema/ledger/receipt禁止)により行わない。outer supervisionはClaude Code自体のbackground task機構(run_in_background: true + mandatory completion join。既定BASH_DEFAULT_TIMEOUT_MS=120000ms、BASH_MAX_TIMEOUT_MS上限=600000ms、timeout到達時はkillでなく自動background転換、main conversation発のbackground taskはresponse後も実行継続する。Web-researcher確認のfresh公式仕様)に委ねる。global BASH_MAX_TIMEOUT_MS 自体の変更は引き続きOut of Scope。

In Scope

  • (a) rendered command、caller、deadline値によるregistry consumer inventoryと、repository-owned ownerのproof gate。execution surface(.claude/skills/issue-refinement-loop/SKILL.md)/registry timeout consumer(scripts/agent-guards/skill_runtime_command_policy.py)/outer deadline owner/signal producer/process cleanup owner の5項目を独立に確認・記載し、consumer不在を理由に無条件no-op停止としない(AC1)。
  • (b) legitimate full produce envelope + required cleanup/grace <= outer supervisor deadlineをminimum compatibility、#2584相当N=4、static-policy-elevated planで保証する(.claude/skills/issue-refinement-loop/scripts/command_registry.py、.claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py、.claude/skills/issue-contract-review/scripts/contract_readiness_check.py、AC2/AC3)。
  • (c) .claude/skills/issue-refinement-loop/SKILL.md のStep 2実行契約を「明示的background launch + mandatory completion join」に変更する: root_review_pipeline.produce をClaude Code main threadのBash toolから呼ぶ際、run_in_background: true で明示的にbackground実行し、完了を示すtask notificationをjoinしてから(=完了したJSON結果を実際に取得してから)canonical Step 2 routingに進む契約をSKILL.md本文に明記する。background起動した時点でStep 2完了扱いにしないことを明記する(AC6)。
  • (d) .claude/skills/issue-refinement-loop/scripts/command_registry.py のtimeout_secondsフィールドについて、実consumerが存在しない現状は repository codeによって強制されない、ドキュメント/意図表示専用の値であることをコード内コメントで明記する(AC7)。
  • (e) command_registry.py --validate の既存呼び出しを、VC preflight allowlist準拠の新規thin pytest wrapper .claude/skills/issue-refinement-loop/tests/test_command_registry_validate_cli.py(subprocessまたはimport経由でCLI/関数を呼び出しexit codeをassertする)に置き換える(AC8)。
  • (f) runaway processのbounded termination、SIGTERM→grace→SIGKILL、fail-closed環境/integrity semantics、timeout時にcanonical_step2_routeを推測しないことの維持(AC4/AC5)。
  • (g) test-only deadline/clock injection又は同等のproduction-shaped fixtureで、実時間90秒待機なしにouter timeout/cleanup provenanceを検証する(AC4/AC5)。
  • (h) 実装後、Issue #2584に対して実際のcanonical Step 2 execution surface(background+join契約後のroot_review_pipeline.produce)を1回だけread-onlyで通す run-time canaryを実行し証跡を残す(AC9。常設CI live mutation gateにはしない)。

Out of Scope

  • AGY authentication、credential、provider、permission mode、launcher設定の変更。
  • root review commandをskill_runtime_exec.pyのeligible commandへ新規追加すること、cleanup policyを弱めること、repository外harnessの設定変更。
  • 全commandのtimeout一律拡大、無制限timeout、retry回数増加、live GitHub mutation canary(AC9のread-only canaryを除く。AC9はmutationを行わない)。
  • Issue #2584本文の変更、implementation-ready判断、古いpreflight/review evidenceの再利用。
  • BASH_MAX_TIMEOUT_MS等、Claude Code自体のglobal設定変更。
  • outer timeout supervisionのための新規watchdogスクリプト実装、新schema/ledger/receipt/persistent stateの追加、root-review専用exact-executor profileの新設。

Acceptance Criteria

  • AC1: root_review_pipeline.produceのouter timeout ownershipを、execution surface/registry timeout consumer/outer deadline owner/signal producer/process cleanup ownerの5項目として実装前に独立にinventoryし、#2584のexit 143の生成主体を未証明のままskill_runtime_exec.pyへ帰属せず、consumer不在を理由に無条件no-op停止としない。
  • AC2: in-repo outer consumerが確認された場合、outer deadlineはnamed SSOTから導くfull produce envelope以上である。envelopeは少なくともbody fetch/pin、canonical-plan/setup、accepted bodyのReviewBudget.total_seconds、TERM wait、KILL wait、bounded reader join、result/artifact finalizationを含み、各addendはsource constant又は明示的にboundedなcontractに対応付ける。
  • AC3: static integerが必要なconsumerではaccepted policy ceilingからmaximum full envelopeを同じpure derivationで生成し、invocation-local budgetを読めるconsumerではexplicit transportを行う。90 → 任意の固定大値、独立コピー、未証明consumerへの値変更を禁止する。
  • AC4: test-only production-shaped fixtureがouter deadline前にinner合法deadlineをkillしないこと、timeout時にもSIGTERM→grace→SIGKILLとreap/cleanup契約を維持することを検証する。
  • AC5: timeoutの場合はfail-closedのままであり、canonical_step2_route、approve、implementation authorizationを捏造しない。
  • AC6: .claude/skills/issue-refinement-loop/SKILL.md のStep 2実行契約に、root_review_pipeline.produce を run_in_background: true で明示的にbackground実行し、完了を示すtask notificationをjoinしてから(完了JSON結果取得後に)canonical Step 2 routingへ進むことを明記し、background起動時点でStep 2完了扱いにしないことを明記する。
  • AC7: .claude/skills/issue-refinement-loop/scripts/command_registry.py のroot_review_pipeline.produce.timeout_seconds宣言近傍に、実consumer不在の現状ではrepository codeによって強制されないunenforced/informational値であり、実際のexecution modelはSKILL.md Step 2 background+join契約を参照する旨のコメントを追加する。
  • AC8: command_registry.py --validate の検証を、新規thin pytest wrapper .claude/skills/issue-refinement-loop/tests/test_command_registry_validate_cli.py 経由で行い、focused pytestとregistry validationがPASSし、全agent-guards suiteやlive GitHub mutationを無条件local gateにしない。
  • AC9: 実装後、Issue #2584に対して実際のcanonical Step 2 execution surface(background+join契約後のroot_review_pipeline.produce)を1回だけread-onlyで通すrun-time canaryを実行し、(1) 旧90秒boundaryでpremature terminationしないこと、(2) background実行後に確実にjoinされること、(3) genuineなcanonical_step2_routeまたは genuineなtyped failureを取得すること、(4) timeout/failure時にroute/approve/implementation authorizationを捏造しないこと、を確認して証跡を残す。常設CI live mutation gateにはしない。

Verification Commands

AC9 は実装後1回限りの read-only canary であり、常設 CI live mutation gate にはしない(Out of Scope 参照)。test_step2_execution_surface_canary.py は docs/dev/runtime-verification-policy.md のSKIP規約(exit code 77、SKIP: prefix)に従い、明示的な live-canary有効化(例: 環境変数)がない限りSKIPし、有効化時のみ実際に#2584に対してread-onlyでcanonical Step 2 execution surfaceを1回通す。

# AC1
# baseline-expect: pass
$ rg -n "root_review_pipeline.produce" .claude/skills/issue-refinement-loop/SKILL.md .claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py
# baseline-expect: pass
$ rg -n "run_root_review_pipeline.py" .claude/skills/issue-refinement-loop/SKILL.md scripts/agent-guards/skill_runtime_command_policy.py
# baseline-expect: pass
$ rg -n "timeout_seconds" .claude/skills/issue-refinement-loop/scripts/command_registry.py scripts/agent-guards/skill_runtime_command_policy.py

# AC2
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_review_budget_wiring.py -v

# AC3
$ uv run --locked pytest .claude/skills/issue-contract-review/tests/test_run_contract_review_once_wrapper_wiring.py -v
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_root_review_pipeline_outer_timeout_budget.py -v

# AC4
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_root_review_pipeline_outer_timeout_budget.py -v

# AC5
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_root_review_pipeline_outer_timeout_budget.py -v

# AC6
$ rg -n "background起動した時点でStep 2完了扱いにしない" .claude/skills/issue-refinement-loop/SKILL.md

# AC7
$ rg -n "unenforced / informational, see SKILL.md Step 2 background\+join contract" .claude/skills/issue-refinement-loop/scripts/command_registry.py

# AC8
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_command_registry_validate_cli.py -v

# AC9
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_step2_execution_surface_canary.py -v

Allowed Paths

(scripts/agent-guards/skill_runtime_command_policy.py は read-only reference であり、変更しない)

  • .claude/skills/issue-refinement-loop/scripts/command_registry.py
  • .claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py
  • .claude/skills/issue-contract-review/scripts/contract_readiness_check.py
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/tests/test_review_budget_wiring.py
  • .claude/skills/issue-refinement-loop/tests/test_root_review_pipeline_outer_timeout_budget.py
  • .claude/skills/issue-contract-review/tests/test_run_contract_review_once_wrapper_wiring.py
  • .claude/skills/issue-refinement-loop/tests/test_command_registry_validate_cli.py
  • scripts/agent-guards/skill_runtime_command_policy.py
  • .claude/skills/issue-refinement-loop/tests/test_step2_execution_surface_canary.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • registry timeoutを読むrepository-owned consumerを確認できない、又はouter deadline ownerがrepository外harnessのみと判明した場合(AC2/AC3のnamed SSOT変更のみ停止し、AC1/AC6/AC7/AC8/AC9は継続する)
  • full envelopeにunbounded addendが残る、又はconsumerのownerをproofできない場合
  • timeout envelopeの修正にskill_runtime_exec.py又はAllowed Paths外のconsumer変更が必要と判明した場合
  • outer timeout supervisionのための新規watchdogスクリプト・新schema・ledger・receipt・persistent stateの追加が必要と判明した場合
  • skill_runtime_exec.pyへのcommand eligibility拡張(root-review eligible command追加)が必要と判明した場合

Required Skills

なし

Required Design References

  • docs/dev/agent-skill-boundaries.md#オーケストレーター設計原則
  • docs/dev/workflows/issue-refinement-loop-design.md
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-contract-review/SKILL.md

Scope Delta(任意)

N/A

Overlap Resolution

Related / Prior Art

Activity

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

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    #2610 が捉えている障害は実在します。#2584 の refinement では、Step 0f 成功後の root_review_pipeline.produce が registered 90-second budget で終了し、exit 143、canonical_step2_route 未生成のまま停止しています。current registry にも root_review_pipeline.produce.timeout_seconds: 90 が残っています。

    また、#2165→PR #2177、#2207→PR #2221 で inner review pipeline はすでに「90秒固定」から大きく進化しています。現在は pinned body の VC occurrence 数から invocation-local ReviewBudget を計算し、N<=2 でも total 520秒、#2584 の N=4 では total 850秒になる設計です。process-group cancellation も SIGTERM→grace→SIGKILL/reap まで既に実装されています。したがって 「inner は動的850秒を許すのに、その外側に90秒が残っている」contract drift を問題視する方向は正しいです。

    ただし、現状の #2610 には実装を開始する前に直した方がよい設計上の穴があります。

    重大度 | Finding | 推奨 -- | -- | -- P0 | Issue が「原因を特定して停止するだけ」で終わり得る | canonical owner が repo の SKILL.md に記述された main-thread invocation なら、その経路を本 Issue で修正対象にする P0 | Claude Code 自身の Bash timeout/background semantics が未考慮 | foreground timeout を伸ばすだけでなく、長時間 produce の 明示 background + deterministic join を検討する P1 | invocation-local budget は produce 起動後にしか確定しない | outer へ body-specific budget を事前 transport しようとせず、outer は emergency watchdog、inner budget は既存 ReviewBudget に分離 P1 | policy ceiling から static timeout を作ると最大約113分になる | static 最大値を通常 foreground timeout として使わない P1 | full envelope を加算式だけで定義すると deadline reset/drift が起こりやすい | absolute time.monotonic() deadline + remaining-budget 方式に固定 P1 | pytest fixture だけでは今回の親 boundary を false-green にできる | 最後に actual Step 2 execution surface を通す read-only runtime canary を1本だけ置く P2 | control-plane を増やす誘惑がある | skill_runtime_exec の新 profile、ledger/schema/receipt 等は追加しない

    P0-1 — 現在の timeout consumer 仮説と Allowed Paths が噛み合っていない

    skill_runtime_exec.py は確かに registry の timeout_seconds を読む generic executor です。 しかし current SKILL_RUNTIME_COMMAND_POLICY_V2["eligible_command_ids"] を確認すると、root_review_pipeline.produce は登録されていません。

    一方、current issue-refinement-loop/SKILL.md は canonical Step 2 を「orchestrator/main thread が run_root_review_pipeline.py produce を直接実行する」契約にしています。 さらに command_registry.render_command() 自体は argv を返すだけで、timeout を command line に埋め込んでいません。つまり registry の90秒を誰かが別途読まなければ kill deadline にはなりません。

    ここで #2610 は「repository-owned consumer が見つからなければ停止」「skill_runtime_exec.py が必要なら停止」としています。 これは調査としては安全ですが、implementation Issue としては no-op completion を許してしまいます。

    推奨は skill_runtime_exec.py を拡張することではありません。むしろ .claude/skills/issue-refinement-loop/SKILL.md を Allowed Paths に加え、現在すでに authority になっている main-thread execution contract を修正対象にしてください。root review を privileged exact-executor に押し込むと、policy/parser/guard/cancellation/parity tests まで広がり、#1860 の minimal-harness 方針にも逆行します。

    P0-2 — 850秒の仕事を Claude Code の通常 foreground Bash として扱う前提が成立しない

    これは #2610 に追加すべき重要な外部仕様です。

    現在の Claude Code 公式ドキュメントでは、Bash の標準 timeout は2分、model が指定できる標準最大値は 10分 (BASH_MAX_TIMEOUT_MS=600000) です。さらに timeout に達した Bash command は、現在の仕様では単純 kill ではなく background へ移される動作が記載されています。(code.claude.com) (Claude)

    #2584 の合法 ReviewBudget.total_seconds=850 は約14分10秒です。つまり、

    main thread → ordinary Bash foreground → produce → JSONを同期consume

    というモデルでは、registry の90秒だけ直しても次の ceiling に衝突します。

    また exit 143 は一般的な shell 慣行では SIGTERM と整合しますが、誰が SIGTERM を送ったかの証拠にはなりません。現在の Claude Code 公式 timeout 動作とも単純には一致しないため、#2610 が signal producer の attribution を保留している点は維持すべきです。(The Open Group)

    このプロジェクトなら、グローバルな BASH_MAX_TIMEOUT_MS を何時間にも拡張するより、

    long-running root_review_pipeline.produce は明示的に background 起動 → completion を必ず join → 完了後の JSON を canonical Step 2 が consume

    という orchestration contract の方を推します。追加 control-plane は不要です。ただし non-interactive invocation の場合も、セッション終了に任せず join が完了するまで Step 2 を進めないことを契約にしてください。

    P1 — outer と inner の責務を分離した方が単純になる

    現在の ReviewBudget は pinned Issue body を取得した後で canonical VC plan から計算されます。 したがって、produce を spawn する前の outer runner に同じ invocation-local budget を正確に教えるには、outer 側でも body fetch/parse を再実行するか、新しい prepare protocol が必要になります。

    それは避けるべきです。#2207/#2221 がわざわざ body SHA に budget を bind した設計を再び二重化します。

    責務は次の形が最小です。

    • inner semantic/runtime deadline: 既存 invocation-local ReviewBudget が所有する。

    • outer supervision: 正当な inner deadline を先に殺さない emergency watchdog と process cleanup だけを所有する。

    • Claude main-thread surface: 長時間なら background + explicit join で同期 consumer 契約を維持する。

    • registry timeout_seconds: 実 consumer があるなら policy ceiling から導出した emergency ceiling として意味を固定する。consumer がなくても90秒を「canonical runtime budget」であるかのように残さない。

    特に policy cap は現在 MAX_VC_EXECUTION_SLOTS=40 です。現行式をそのまま当てると ReviewBudget.total_seconds は最大 6790秒、約113分に達します。 これを「通常の foreground command timeout」にするのは数学的には整合していても運用として悪いです。static max は watchdog 用、通常の完走制御は invocation-local budget + join と分離する方が有用です。

    P1 — deadline は monotonic な一つの時計にする

    #2610 は full envelope に body fetch、setup、ReviewBudget.total_seconds、TERM/KILL wait、reader join、finalization を含める方針で、これは正しいです。

    ただし「各 timeout を足して、それぞれで新しい timeout を始める」実装より、

    deadline_at = time.monotonic() + full_envelope_seconds

    を一度作り、各 phase が deadline_at - time.monotonic() の remaining budget だけを消費する方式を AC に明記することを勧めます。Python の monotonic() は system clock 更新の影響を受けず deadline 計測向きですし、repo の reviewer_transport.py / cooperative supervisor もすでに monotonic clock を利用しています。(Python Docs)

    #2610 へ入れる修正

    Issue を refine するなら、以下まで固定すると implementation-ready に近づきます。

    1. SKILL.md を Allowed Paths に追加し、「repo-owned direct main-thread invocation だった場合」は Stop Condition から除外する。skill_runtime_exec.py への新規登録は引き続き禁止する。

    2. AC1 で actual execution surface / timeout consumer / signal producer を別々に inventory する。exit 143 だけから sender を推定しない。

    3. ReviewBudget は inner SSOT のまま維持し、outer へ body-specific budget を二重計算して transport しない。

    4. canonical Claude Code path では、合法 budget が foreground ceiling を超え得るため background + mandatory completion join を正式な実行方法として扱う。global timeout 設定変更は原則不要。

    5. outer supervisor が必要な経路では、policy ceiling 由来の full-envelope emergency ceiling + absolute monotonic deadline を使い、既存 SIGTERM→grace→SIGKILL/reap を再利用する。Python の通常の subprocess.run(timeout=...) だけへ簡略化しない。(Python Docs)

    6. scaled pytest に加え、修正後に 実装: repair_action.apply の unauthorized_write_path false negative を解消する #2584 を actual canonical Step 2 surface から read-only で1回だけ再実行し、「90秒で脱落しない」「background なら join される」「最終的に genuine canonical_step2_route を取得する」を runtime evidence にする。CI の常設 live gate にはしない。

    この形なら、#2177/#2221 で得た timeout/cancellation の品質を落とさず、#1860 の「live state・実 test を authority にする minimal harness」にも沿います。新しい timeout schema、receipt、ledger、exact-executor profile は不要です。

    結論として、原因設定は良いが、現在の #2610 のままでは「consumer を証明できず停止」で実障害が残る可能性が高いです。最優先の修正は timeout 数値そのものではなく、canonical main-thread execution ownership と Claude Code の long-running Bash/join semantics を Issue contract に取り込むことです。

    ## 判定: **REQUEST_CHANGES**

    #2610 が捉えている障害は実在します。#2584 の refinement では、Step 0f 成功後の root_review_pipeline.produce が registered 90-second budget で終了し、exit 143、canonical_step2_route 未生成のまま停止しています。current registry にも root_review_pipeline.produce.timeout_seconds: 90 が残っています。

    また、#2165→PR #2177、#2207→PR #2221 で inner review pipeline はすでに「90秒固定」から大きく進化しています。現在は pinned body の VC occurrence 数から invocation-local ReviewBudget を計算し、N<=2 でも total 520秒、#2584 の N=4 では total 850秒になる設計です。process-group cancellation も SIGTERM→grace→SIGKILL/reap まで既に実装されています。したがって 「inner は動的850秒を許すのに、その外側に90秒が残っている」contract drift を問題視する方向は正しいです。

    ただし、現状の #2610 には実装を開始する前に直した方がよい設計上の穴があります。

    重大度 Finding 推奨
    P0 Issue が「原因を特定して停止するだけ」で終わり得る canonical owner が repo の SKILL.md に記述された main-thread invocation なら、その経路を本 Issue で修正対象にする
    P0 Claude Code 自身の Bash timeout/background semantics が未考慮 foreground timeout を伸ばすだけでなく、長時間 produce の 明示 background + deterministic join を検討する
    P1 invocation-local budget は produce 起動後にしか確定しない outer へ body-specific budget を事前 transport しようとせず、outer は emergency watchdog、inner budget は既存 ReviewBudget に分離
    P1 policy ceiling から static timeout を作ると最大約113分になる static 最大値を通常 foreground timeout として使わない
    P1 full envelope を加算式だけで定義すると deadline reset/drift が起こりやすい absolute time.monotonic() deadline + remaining-budget 方式に固定
    P1 pytest fixture だけでは今回の親 boundary を false-green にできる 最後に actual Step 2 execution surface を通す read-only runtime canary を1本だけ置く
    P2 control-plane を増やす誘惑がある skill_runtime_exec の新 profile、ledger/schema/receipt 等は追加しない

    P0-1 — 現在の timeout consumer 仮説と Allowed Paths が噛み合っていない

    skill_runtime_exec.py は確かに registry の timeout_seconds を読む generic executor です。 しかし current SKILL_RUNTIME_COMMAND_POLICY_V2["eligible_command_ids"] を確認すると、root_review_pipeline.produce は登録されていません。

    一方、current issue-refinement-loop/SKILL.md は canonical Step 2 を「orchestrator/main thread が run_root_review_pipeline.py produce を直接実行する」契約にしています。 さらに command_registry.render_command() 自体は argv を返すだけで、timeout を command line に埋め込んでいません。つまり registry の90秒を誰かが別途読まなければ kill deadline にはなりません。

    ここで #2610 は「repository-owned consumer が見つからなければ停止」「skill_runtime_exec.py が必要なら停止」としています。 これは調査としては安全ですが、implementation Issue としては no-op completion を許してしまいます。

    推奨は skill_runtime_exec.py を拡張することではありません。むしろ .claude/skills/issue-refinement-loop/SKILL.md を Allowed Paths に加え、現在すでに authority になっている main-thread execution contract を修正対象にしてください。root review を privileged exact-executor に押し込むと、policy/parser/guard/cancellation/parity tests まで広がり、#1860 の minimal-harness 方針にも逆行します。

    P0-2 — 850秒の仕事を Claude Code の通常 foreground Bash として扱う前提が成立しない

    これは #2610 に追加すべき重要な外部仕様です。

    現在の Claude Code 公式ドキュメントでは、Bash の標準 timeout は2分、model が指定できる標準最大値は 10分 (BASH_MAX_TIMEOUT_MS=600000) です。さらに timeout に達した Bash command は、現在の仕様では単純 kill ではなく background へ移される動作が記載されています。([code.claude.com]1) ([Claude]2)

    #2584 の合法 ReviewBudget.total_seconds=850 は約14分10秒です。つまり、

    main thread → ordinary Bash foreground → produce → JSONを同期consume

    というモデルでは、registry の90秒だけ直しても次の ceiling に衝突します。

    また exit 143 は一般的な shell 慣行では SIGTERM と整合しますが、誰が SIGTERM を送ったかの証拠にはなりません。現在の Claude Code 公式 timeout 動作とも単純には一致しないため、#2610 が signal producer の attribution を保留している点は維持すべきです。([The Open Group]3)

    このプロジェクトなら、グローバルな BASH_MAX_TIMEOUT_MS を何時間にも拡張するより、

    long-running root_review_pipeline.produce は明示的に background 起動 → completion を必ず join → 完了後の JSON を canonical Step 2 が consume

    という orchestration contract の方を推します。追加 control-plane は不要です。ただし non-interactive invocation の場合も、セッション終了に任せず join が完了するまで Step 2 を進めないことを契約にしてください。

    P1 — outer と inner の責務を分離した方が単純になる

    現在の ReviewBudget は pinned Issue body を取得した後で canonical VC plan から計算されます。 したがって、produce を spawn する前の outer runner に同じ invocation-local budget を正確に教えるには、outer 側でも body fetch/parse を再実行するか、新しい prepare protocol が必要になります。

    それは避けるべきです。#2207/#2221 がわざわざ body SHA に budget を bind した設計を再び二重化します。

    責務は次の形が最小です。

    • inner semantic/runtime deadline: 既存 invocation-local ReviewBudget が所有する。
    • outer supervision: 正当な inner deadline を先に殺さない emergency watchdog と process cleanup だけを所有する。
    • Claude main-thread surface: 長時間なら background + explicit join で同期 consumer 契約を維持する。
    • registry timeout_seconds: 実 consumer があるなら policy ceiling から導出した emergency ceiling として意味を固定する。consumer がなくても90秒を「canonical runtime budget」であるかのように残さない。

    特に policy cap は現在 MAX_VC_EXECUTION_SLOTS=40 です。現行式をそのまま当てると ReviewBudget.total_seconds は最大 6790秒、約113分に達します。 これを「通常の foreground command timeout」にするのは数学的には整合していても運用として悪いです。static max は watchdog 用、通常の完走制御は invocation-local budget + join と分離する方が有用です。

    P1 — deadline は monotonic な一つの時計にする

    #2610 は full envelope に body fetch、setup、ReviewBudget.total_seconds、TERM/KILL wait、reader join、finalization を含める方針で、これは正しいです。

    ただし「各 timeout を足して、それぞれで新しい timeout を始める」実装より、

    deadline_at = time.monotonic() + full_envelope_seconds

    を一度作り、各 phase が deadline_at - time.monotonic() の remaining budget だけを消費する方式を AC に明記することを勧めます。Python の monotonic() は system clock 更新の影響を受けず deadline 計測向きですし、repo の reviewer_transport.py / cooperative supervisor もすでに monotonic clock を利用しています。([Python Docs]4)

    #2610 へ入れる修正

    Issue を refine するなら、以下まで固定すると implementation-ready に近づきます。

    1. SKILL.md を Allowed Paths に追加し、「repo-owned direct main-thread invocation だった場合」は Stop Condition から除外する。skill_runtime_exec.py への新規登録は引き続き禁止する。
    2. AC1 で actual execution surface / timeout consumer / signal producer を別々に inventory する。exit 143 だけから sender を推定しない。
    3. ReviewBudget は inner SSOT のまま維持し、outer へ body-specific budget を二重計算して transport しない。
    4. canonical Claude Code path では、合法 budget が foreground ceiling を超え得るため background + mandatory completion join を正式な実行方法として扱う。global timeout 設定変更は原則不要。
    5. outer supervisor が必要な経路では、policy ceiling 由来の full-envelope emergency ceiling + absolute monotonic deadline を使い、既存 SIGTERM→grace→SIGKILL/reap を再利用する。Python の通常の subprocess.run(timeout=...) だけへ簡略化しない。([Python Docs]5)
    6. scaled pytest に加え、修正後に 実装: repair_action.apply の unauthorized_write_path false negative を解消する #2584 を actual canonical Step 2 surface から read-only で1回だけ再実行し、「90秒で脱落しない」「background なら join される」「最終的に genuine canonical_step2_route を取得する」を runtime evidence にする。CI の常設 live gate にはしない。

    この形なら、#2177/#2221 で得た timeout/cancellation の品質を落とさず、#1860 の「live state・実 test を authority にする minimal harness」にも沿います。新しい timeout schema、receipt、ledger、exact-executor profile は不要です。

    結論として、原因設定は良いが、現在の #2610 のままでは「consumer を証明できず停止」で実障害が残る可能性が高いです。最優先の修正は timeout 数値そのものではなく、canonical main-thread execution ownership と Claude Code の long-running Bash/join semantics を Issue contract に取り込むことです。

  3. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor

    推奨アクションは #2610 の実装開始ではなく、comment 5616040399 を direct human context / OWNER directive として固定し、issue-refinement-loop を再実行して Issue 契約自体を修正することです。

    理由は明確です。現行 #2610 は「repository-owned consumer を証明できなければ停止」という条件を持つため、implementation Issue なのに実障害を残したまま no-op で終了し得ます。対象コメントはここを P0 として修正し、canonical main-thread execution surface、background + mandatory join、inner ReviewBudget と outer watchdog の責務分離、monotonic absolute deadline、read-only runtime canary を Issue 契約へ入れるよう要求しています。

    外部仕様も再確認しました。現在の Claude Code 公式仕様では Bash のデフォルト timeout は120秒、model が指定できる標準上限は600秒で、timeout 到達時には条件を満たす command が background に移行します。したがって #2584 相当の ReviewBudget.total_seconds=850 を ordinary foreground Bash だけで同期実行する設計は不十分、というコメントの指摘は現在も妥当です。([Claude]1) また、PR #2221 は invocation-local budget と cooperative cancellation を既に導入済みです。

    そのまま貼るなら以下です。

    対象リポジトリ: squne121/loop-protocol

    対象:

    現在の対話的 Claude Code セッションは既に auto mode で起動済みです。
    このセッションをそのまま使用し、.claude/skills/issue-refinement-loop を Issue #2610 に対して実行してください。

    実行方針

    このプロンプト自体を direct interactive human instruction として扱ってください。

    anchor comment 5616040399 は、このプロンプトによって明示的に OWNER / human context として指定されています。
    URLだけから human origin を推定するのではなく、この現在の対話指示を provenance として、canonical な preflight.run.with_human_context lane を使用してください。

    repo 側の loop_iteration_approval_gate について途中承認は不要です。
    needs-fix になった場合も、skill の canonical routing と iteration 上限の範囲で自律的に rewrite → fresh review を継続してください。

    Claude Code 自体の permission mode、/permissions、launcher 設定、--dangerously-skip-permissions 等は変更しないでください。
    repo workflow の approval と Claude Code runtime permission を混同しないでください。

    このタスクの完了条件は Issue #2610 の refinement 完了です。
    implementation-ready になっても、コード実装・branch作成・PR作成・mergeには進まないでください。

    最初に行うこと

    1. Issue 実装: root review outer timeout と invocation-local budget の parity を固定する #2610 の current body と全コメントを取得する。
    2. anchor comment 5616040399 を snapshot 固定する。
    3. current HEAD、関連 Issue / PR / repository assets を fresh に確認する。
    4. .claude/skills/issue-refinement-loop/SKILL.md と planner が要求する references/ を読み、現在の canonical procedure を authority とする。
    5. preflight.run.with_human_context を canonical main root / default branch から実行する。
    6. trusted contract patch plan が生成され、canonical procedure が要求する場合は contract_update.run.with_human_context を使用する。
    7. その後、通常の issue-refinement-loop を最後まで実行する。

    手書きの代替フローで skill の planner / routing / review 判定を再実装しないでください。

    anchor comment の REQUEST_CHANGES を refinement input として解決すること

    comment 5616040399 の finding を単なる参考情報ではなく、Issue #2610 の current contract に対する明示的 REQUEST_CHANGES として扱ってください。

    少なくとも以下を調査・Issue本文へ反映すべきか判定してください。

    1. canonical execution ownership

    root_review_pipeline.produce について、以下を別々に inventory してください。

    • actual execution surface
    • registry timeout consumer
    • outer deadline owner
    • signal producer
    • process cleanup owner

    exit 143 だけを根拠に SIGTERM sender を帰属しないでください。

    repository-owned generic registry consumer が見つからなかったことを理由に、そのまま no-op completion してはいけません。

    current .claude/skills/issue-refinement-loop/SKILL.md が canonical Step 2 を orchestrator/main-thread の direct run_root_review_pipeline.py produce invocation と定義しているなら、その execution contract 自体を Issue #2610 の修正対象として扱えるよう scope / Allowed Paths / Stop Conditions を見直してください。

    ただし root_review_pipeline.produce を skill_runtime_exec.py の新規 eligible command/profile に押し込むことをデフォルト解にしないでください。

    2. Claude Code long-running Bash semantics

    Claude Code の現在の公式仕様を web-researcher で fresh に確認してください。

    特に:

    • BASH_DEFAULT_TIMEOUT_MS
    • BASH_MAX_TIMEOUT_MS
    • Bash timeout 到達時の background 移行 semantics
    • explicit background execution
    • background task completion/output の取得方法
    • interactive / non-interactive invocation での lifetime 差

    を確認してください。

    #2584 相当の合法な ReviewBudget.total_seconds が通常の foreground Bash ceiling を超える場合を Issue contract が扱えるようにしてください。

    推奨設計の第一候補は:

    root_review_pipeline.produce
    → explicit background launch
    → mandatory deterministic completion join
    → genuine producer result取得
    → canonical Step 2 routing

    です。

    background に投げた時点で Step 2 完了扱いしてはいけません。
    必ず completion を join し、結果を取得してから後続 routing に進む契約にしてください。

    global BASH_MAX_TIMEOUT_MS を巨大化することを通常解にしないでください。

    3. inner budget と outer supervision の責務分離

    既存の invocation-local ReviewBudget を semantic/runtime deadline の SSOT のまま維持する方向を優先してください。

    outer launcher が pinned body を再取得・再parseして invocation-local budget を二重計算する新 protocol は、明確な必要性がない限り追加しないでください。

    原則:

    • inner semantic/runtime deadline:
      existing invocation-local ReviewBudget
    • outer supervision:
      legitimate inner executionを先にkillしない emergency watchdog + cleanup
    • Claude main-thread execution:
      long-runningなら background + mandatory join
    • registry static timeout:
      実 consumer が存在するなら emergency ceiling として意味を固定

    としてください。

    90 -> 600 等の arbitrary fixed-number replacement だけで AC を満たしたことにしないでください。

    4. monotonic absolute deadline

    full produce envelope を複数 phase ごとの timeout reset の集合にしないでください。

    必要な outer supervisor が存在する場合は原則として、

    deadline_at = time.monotonic() + full_envelope_seconds

    という invocation 単位の absolute deadline を一度だけ作り、各 phase は remaining budget を消費する形を検討してください。

    full envelope に含める addend は source constant または explicit bounded contract に対応付けてください。

    既存の SIGTERM → bounded grace → SIGKILL → reap / reader join / finalization contract は弱化しないでください。

    5. runtime verification

    pytest fixture だけで parent execution boundary を false-green にしないようにしてください。

    Issue #2610 の実装後 verification requirement として、必要なら #2584 に対して actual canonical Step 2 execution surface を通す read-only runtime canary 1回を要求してください。

    確認対象は少なくとも:

    • 旧90秒 boundary で premature termination しない
    • background execution を採るなら必ず completion join される
    • genuine canonical_step2_route または genuine typed failure を取得する
    • timeout時に route / approve / implementation authorization を捏造しない

    としてください。

    これは常設 CI の live mutation gate にしないでください。

    6. control-plane の増殖を避ける

    以下は明確な必要性が証明されない限り追加しないでください。

    • 新しい timeout schema
    • 新しい ledger
    • 新しい receipt
    • 新しい persistent state
    • root review専用の新 exact-executor profile
    • skill_runtime_exec.py への安易な command eligibility 拡張

    既存 SSOT / helper / cancellation primitive を再利用してください。

    関連 evidence

    最低限、以下を fresh に確認してください。

    関連 Issue / PR の current scope と merged implementation を見て、historical description を current truth と誤認しないでください。

    SubAgent 使用

    SubAgent を積極的に使用してください。

    少なくとも canonical skill が要求する:

    • codebase-investigator
    • external/current specification が decision-relevant なら web-researcher
    • semantic design review 用に current skill / planner が指定する SubAgent

    を使用してください。

    独立に実行可能な investigation と web research は並列化して構いません。

    ただし:

    • SubAgent に nested SubAgent delegation をさせない
    • main orchestrator が routing authority を保持する
    • 起動した全 SubAgent の completion を必ず待つ
    • 全 SubAgent の結果を join する前に rewrite / final judgment / completion report へ進まない
    • background SubAgent を「起動済み」で完了扱いしない

    こと。

    canonical Step 2 が現在 run_root_review_pipeline.py produce の root-owned direct consumption を要求しているなら、そこで legacy issue-reviewer SubAgent に置き換えないでください。

    rewrite policy

    Issue body の semantic rewrite が必要なら human confirmation を求めず実施してください。

    anchor comment により明示的に解決された scope decision、特に:

    • SKILL.md を必要なら Allowed Paths に含める
    • direct main-thread execution contract を legitimate implementation surface として扱う
    • consumer-not-found を無条件 no-op stop にしない
    • foreground-only assumption を廃止する
    • background + mandatory join を検討・契約化する
    • invocation-local inner budget と emergency outer watchdog を分離する
    • monotonic absolute deadline を要求する
    • read-only actual-surface canary を verification に含める
    • control-plane 増殖を避ける

    について、既存本文の Stop Conditions を機械的に優先して再び human escalation しないでください。

    この current human instruction + anchor comment は、それら既知の設計判断に対する human context です。

    一方で、anchor commentにもrepository evidenceにも答えがなく、新しい product/scope choice が本当に必要な場合のみ canonical human_judgment_required を尊重してください。
    単なる「安全のため」「Allowed Paths が旧本文と違うため」「既存 Stop Condition に文字列上該当するため」だけで停止しないでください。まず trusted contract update / semantic rewrite で今回の human directive を反映してください。

    完了条件

    以下をすべて満たすまで続行してください。

    1. anchor comment の P0/P1 findings が解消または evidence に基づき明示的に reject されている。
    2. Issue body の Goal / Scope / Outcome / AC / Verification Commands / Allowed Paths / Stop Conditions が相互整合している。
    3. timeout ownership、Claude Code execution surface、inner/outer budget責務が曖昧でない。
    4. implementation が arbitrary timeout increase に退化できない AC がある。
    5. runtime verification が production-shaped boundary を検査する。
    6. fresh deterministic/static readiness が通る。
    7. fresh semantic review が approve/proceed 相当になる。
    8. current issue body の最終 readback を行う。
    9. 起動した全 SubAgent が completion join 済みである。
    10. issue-refinement-loop の canonical final classification / report を出す。

    iteration 上限内の needs-fix では人間承認を求めず自動継続してください。

    このタスクでは Issue refinement 完了後に implementation へ進まないでください。

    最後に簡潔に以下を報告してください。

    • final verdict / next action
    • iteration 数
    • Issue body が変更されたか
    • anchor comment の各主要 finding の disposition
    • final body SHA 等、skill が生成する canonical evidence
    • 実行した SubAgent と completion join 状態
    • web research の主要 external facts
    • remaining blocker があれば exact reason code
    • implementation-ready か否か

    通常の途中承認は求めず、canonical workflow が許す範囲で最後まで完走してください。

    このプロンプトでは、特に 旧本文の Stop Conditions をそのまま適用して再度 human_judgment_required に落ちるループを避けるため、今回のコメントで既に判断済みの scope delta を human context として明示しています。また、Step 2 自体は現行スキルどおり root-owned のまま維持し、SubAgent 化して別の execution semantics に変えないようにしています。

  4. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor

    Issue Refinement Loop 完了報告

    Verdict: approved(refinement完了。実装・branch・PR作成には進みません — human instructionによる明示的停止)

    Iteration数

    • 4回のbody rewrite(issue-editor経由、controlled executor lane)
      1. anchor comment (OWNER REQUEST_CHANGES, comment 5616040399) 反映のための大規模rewrite
      2. baseline_vc_preflight blocker修正(broad search path / VC preflight allowlist)
      3. baseline-expect annotation追加(unexpected_pass blocker解消)
    • 最終body SHA: 79c1ff72323eede20811a166f1258905cd5bc2451d7ccdbbc99d1ba5125e799e

    Anchor Comment (comment 5616040399, OWNER, REQUEST_CHANGES) の各finding disposition

    • P0-1 execution ownership: 反映済み。.claude/skills/issue-refinement-loop/SKILL.md をAllowed Pathsへ追加し、main-thread直接invocation契約をこのIssueの修正対象に含めた。
    • P0-2 Claude Code Bash timeout/background semantics: 反映済み。web-researcherがfreshに確認した一次資料(BASH_DEFAULT_TIMEOUT_MS=120000ms、BASH_MAX_TIMEOUT_MS=600000ms、timeout到達時は自動background転換)に基づき、AC6として「明示background launch + mandatory completion join」契約を新設。
    • P1 inner/outer budget分離: 反映済み(Timeout Ownership Decision, AC7として登録)。
    • P1 policy ceiling static max: 既存Out of Scope文言(グローバルtimeout設定変更禁止)を維持。
    • P1 monotonic absolute deadline: 既存inner ReviewBudget実装(SIGTERM→grace→SIGKILL/reap)を維持・弱化しない方針で反映。新規outer watchdog scriptは追加しない。
    • P1 runtime canary: 反映済み(AC9として新設、test_step2_execution_surface_canary.py、SKIP規約準拠、常設CI化しない)。
    • P2 control-plane増殖回避: Stop Conditions/Out of Scopeに明記済み(skill_runtime_exec.py拡張禁止、新schema/ledger/receipt禁止を維持)。

    Review結果

    • deterministic checker (run_root_review_pipeline.py produce): approve / canonical_step2_route: step_2_5(最終review, body_sha256: 79c1ff72...)
    • semantic design review (issue-design-reviewer, Step 2.5): findings(medium×1, low×2、いずれもblocker/high以外のためfinding_policyによりeffective_verdict: approve)
      • 残存warning(非blocking、将来のfollow-upまたは実装時判断で解消可能):
        1. [medium, requires_owner_choice] AC2/AC3の「実consumerが確認された場合のみ実施」という条件がIn Scope(b)/AC本文/VCに一貫して反映されておらず、consumer未確認時(Current Evidenceで既に「未確認」と判明済み)にtest_root_review_pipeline_outer_timeout_budget.pyを作成すべきか否かが実装者の解釈に委ねられている。
        2. [low] absolute monotonic deadline方式の実装制約がAC2/AC3本文に直接記載されていない(Timeout Ownership Decisionのみ)。
        3. [low, requires_owner_choice] Related/Prior Artの「追加の人間承認は不要」自己宣言が、実装後の通常PRレビューでのOWNER再指摘可能性まで排除すると誤読されるリスク。

    実行したSubAgentとcompletion join状態

    • codebase-investigator(root_review_pipeline.produce timeout consumer inventory): completion join済み。捏造検知: 「run_root_review_pipeline.pyが未マージ・存在しない」という主張は誤りと直接検証で判明(実際は1817行で稼働中)。他の核心的事実(registry timeout_seconds未消費、eligible_command_ids未登録)は独立に再検証し正確と確認。
    • web-researcher(Claude Code Bash timeout semantics): completion join済み。BASH_DEFAULT_TIMEOUT_MS=120000ms/BASH_MAX_TIMEOUT_MS=600000ms/timeout時background転換を一次資料で確認。
    • issue-editor ×3(body rewrite): 各回completion join済み、body SHA readbackで適用確認。
    • issue-design-reviewer(Step 2.5 semantic review): completion join済み。

    Runtime Verification Applicability

    decision: immediate(AC2/AC4/AC5)。本Issueのrefinement段階では未実行(実装Issueのため、実装後にAC9の一時canaryとAC2/AC4/AC5のpytestで検証される)。

    Implementation-ready か

    Yes(refinement完了)。ただし本セッションの明示指示により、このIssueのimplementation・branch作成・PR作成には進みません。次のアクションが必要な場合は、通常の実装フロー(impl-review-loop等)を別途開始してください。

  5. self-assigned this
    on Sep 10, 2026
  6. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor

    推奨アクションは 再refinementではなく、#2610 に対して impl-review-loop を開始です。直近の refinement は approved / implementation-ready で完了しており、実装フェーズへ進むことが明示されています。 現行 main では root_review_pipeline.produce.timeout_seconds: 90 がまだ残っているため、実装対象も未解消です。

    一点だけ、refinement 最終レビューの 「consumer 不在時に AC2/AC3 と outer-timeout test をどこまで実装するか」 という medium warning は、今回の直接指示で先に解決しておくのを推奨します。具体的には「fresh inventory でも consumer 不在なら仮想的な outer supervisor を作らず、conditional な production timeout変更はしない。一方 AC1/AC6/AC7/AC8/AC9 と既存 timeout/fail-closed 契約の検証は進める」と固定します。Claude Code公式仕様でも Bash の既定timeoutは120秒、モデル指定上限は通常600秒で、長時間コマンドは明示的 run_in_background: true が利用できます。timeout到達時のbackground移行も現在の仕様です。([Claude]1)

    そのまま対話的 Claude Code に貼れる形です。

    対象リポジトリ: squne121/loop-protocol

    対象 Issue:
    https://github.com/squne121/loop-protocol/issues/2610

    現在のこの対話的 Claude Code セッションは、すでに auto mode で起動済みです。

    .claude/skills/impl-review-loop を Issue #2610 に対して実行し、実装 → 検証 → PR作成 → PRレビュー → fix → 再検証・再レビューを自律的に反復してください。

    目標は「人間が merge 操作を行う直前」まで完了させることです。
    通常の設計判断、実装判断、テスト修正、PR作成、レビュー指摘対応、branch update、CI対応について途中の人間承認を求めないでください。

    実際の merge は実行しないでください。auto-mergeも有効化しないでください。

    このプロンプト自体を current direct interactive human instruction / OWNER directive として扱ってください。Issue #2610 の refinement 後に残った非blockingな owner-choice warning については、下記の判断を現在の人間判断として使用し、同じ点で再度 human escalation しないでください。

    今回の Owner Decision

    fresh inventory の結果、root_review_pipeline.produce の timeout_seconds を実際に強制する repository-owned outer consumer / outer deadline owner が依然として存在しない場合:

    • AC2/AC3 の conditional な production timeout SSOT変更を成立させるためだけに、仮想的な consumer、outer watchdog、exact-executor profile、schema、ledger、receipt、persistent state を新設しない。
    • 90 -> 600 や巨大な固定値など、未消費の timeout_seconds を arbitrary に変更して解決したことにしない。
    • Issue本文に従い AC1、AC6、AC7、AC8、AC9 は実装する。
    • AC4/AC5については、既存 production timeout / cancellation / fail-closed semantics を実際の既存コードまたは production-shaped fixture で検証する。
    • test_root_review_pipeline_outer_timeout_budget.py は、存在しない outer supervisor を捏造するための production plumbing を要求してはならない。現行 architecture の non-enforcement / budget boundary / fail-closed regression を意味のある形で固定できる範囲で実装する。
    • hypothetical outer consumer が無ければ成立しない assertion については、repositoryに未使用 production mechanismを追加するより、Issueの conditional applicability と既存 runtime-verification SKIP/non-applicable 規約を使い、なぜ適用不能かを evidence とともに明示する。
    • ただし fresh inventory で実際の repository-owned consumer が発見された場合は、この判断を no-consumer case に誤適用せず、Issue AC2/AC3どおり named SSOT / pure derivation / full produce envelope parity を実装する。

    この判断は refinement 完了報告に残った
    「consumer未確認時に test_root_review_pipeline_outer_timeout_budget.py をどこまで作成すべきか」
    という owner-choice ambiguity を解決するためのものです。

    また、Issue本文の「追加の人間承認は不要」は、PR review の REQUEST_CHANGES を無視する意味ではありません。
    PR reviewer が concrete blocker / REQUEST_CHANGES を返した場合は、それを fix_delta として自律的に修正し、verification と review を必要なだけ再実行してください。

    実行手順

    1. Fresh state を取得する。
      Issue 実装: root review outer timeout と invocation-local budget の parity を固定する #2610 の current body、全コメント、current default-branch HEAD、関連 Issue / PR、open PR overlap、対象ファイルの現在内容を取得してください。refinement 時点の evidence SHA を current truth とみなさないでください。既存 branch / worktree / PR が存在する場合は重複作成せず、live state に基づいて canonical recovery/reuse を行ってください。

    2. canonical skill を authority として読む。
      .claude/skills/impl-review-loop/SKILL.md と、その steps/、必要な references、docs/dev/workflow.md を読み、現在の procedure に従ってください。手書きの簡易 implementation loop で代替しないでください。

    3. root-owned implementation entry transition を fresh に実行する。
      過去の refinement result や comment を implementation authorization packet として再利用せず、current run の canonical preflight / issue-contract-review / live Issue readback / routing を通してください。
      triage-required 等の presentation label 自体を implementation permission の authority にしないでください。

    4. SubAgent を実際に使用する。
      canonical impl-review-loop が定義する implementation-worker、test-runner、pr-reviewer 等を使ってください。追加の codebase investigation が必要なら適切な SubAgent を使用してください。
      独立した read-only investigation は安全な範囲で並列化して構いません。
      SubAgent に nested SubAgent delegation はさせず、main Claude Code が routing authority を保持してください。
      起動した全SubAgentの完了を必ず待ち、結果をjoinしてください。
      background/asyncで起動しただけの状態を完了扱いして、次の judgment、commit、PR review、最終報告へ進んではいけません。

    5. Issue 実装: root review outer timeout と invocation-local budget の parity を固定する #2610 の実装を行う。
      Issue の Current Validated Scope / In Scope / Allowed Paths / Acceptance Criteria を current contract として実装してください。
      特に root_review_pipeline.produce の execution surface、registry timeout consumer、outer deadline owner、signal producer、process cleanup owner の5項目を fresh inventory してください。
      exit 143だけから signal sender を推測しないでください。

      canonical Step 2 execution contract は、Issueが要求する
      explicit background launch -> mandatory completion join -> genuine completed JSON result -> canonical routing
      を満たしてください。
      background launch 時点を Step 2 completion と扱わないでください。

      invocation-local ReviewBudget は inner semantic/runtime budget のSSOTとして維持し、outer側でIssue bodyを再fetch/reparseして同じbudgetを二重計算する新protocolは作らないでください。

      既存 SIGTERM → bounded grace → SIGKILL → reap / reader join / fail-closed semantics を弱化しないでください。
      timeout/failure時に canonical_step2_route、approve、implementation authorization を推測・捏造しないでください。

    6. テストと検証を完遂する。
      Issue 実装: root review outer timeout と invocation-local budget の parity を固定する #2610 の Verification Commands とACを満たす focused tests を実行してください。
      必要なら関連 regression tests、typecheck、lint、build、および変更範囲に対応する既存 test plan も実行してください。
      test failure を「既存failure」と推測せず、current HEAD / base との比較で attribution してください。

      AC9 の 実装: repair_action.apply の unauthorized_write_path false negative を解消する #2584 read-only runtime canary は、Issue contract の opt-in / SKIP規約を守って実施してください。
      live mutation gateへ拡張してはいけません。

    7. PRを作成し、review loopを完走する。
      canonical worktree / branch workflow に従って commit・push・PR作成まで進めてください。
      PR本文には Issue 実装: root review outer timeout と invocation-local budget の parity を固定する #2610 を閉じる canonical closing keyword、原則 Closes #2610 を含めてください。
      current head のCIを確認し、失敗が今回の変更に起因する場合は修正してください。

      pr-reviewer の review を current PR head に対して実行し、REQUEST_CHANGES / blockers があれば implementation-worker に fix_delta として戻し、修正 → verification → current-head re-review を繰り返してください。

      base branch drift / BEHIND は canonical update_branch route で処理し、その後 verification と review を再実行してください。
      stale review は current head で再reviewしてください。
      mere human_review_required: true self-report、advisory artifact不足、label状態、stale advisory evidenceだけを理由に停止しないでください。current skill の live-state routingを使ってください。

    人間承認を求めない範囲

    Issue #2610 の既存 scope 内で解決可能な実装方式選択、テスト方式選択、軽微な refactor、PR body修正、レビュー指摘対応、CI修正、branch updateについては自律判断してください。

    複数案がある場合は、
    correctness / regression resistance / repository既存SSOTの再利用 / control-plane最小化 / 保守性
    を優先し、Issue scope 内の最小変更を選択してください。

    refinement の medium/low warning を理由に再度 owner approval を求めないでください。本プロンプトの Owner Decision で解決済みです。

    停止条件

    以下だけは無理に突破しないでください。

    • 実際の merge 操作が必要になった場合
    • destructive / irreversible な操作が必要な場合
    • secret、credential、認証情報の取得・変更・露出が必要な場合
    • Issueの明示的 Allowed Paths / hard scope boundary を越える変更が不可避で、in-scopeな代替策もない場合
    • current canonical skill が hard stop と定義する genuine Git conflict、permission/protected-path/secret gate等が、通常のin-scope recovery後も解消不能な場合
    • repository状態が外部から同時変更され続け、canonical bounded retry / reconciliation budgetを使い切った場合

    通常の REQUEST_CHANGES、CI failure、merge-base drift、review stale、修正可能なtest failureは停止条件ではありません。自律修正してループを継続してください。

    Claude Code自身の permission mode、/permissions、launcher設定、sandbox設定、--dangerously-skip-permissions、global BASH_MAX_TIMEOUT_MS 等を、このタスクの都合で変更しないでください。

    完了条件

    以下をすべて満たした時だけ完了してください。

    Issue #2610 の実装が current contract のACを満たしていること。
    必要なテスト/検証がcurrent headで成功していること。
    PRが作成済みで Closes #2610 のbindingが正しいこと。
    未解決のreview blockerがないこと。
    pr-reviewer が current head をレビュー済みであること。
    route_loop_verdict_v2() が current live mergeability と reviewer result から approved を返す状態であること。
    PR headがreviewed headと一致していること。
    CI / mergeability が merge直前の状態として許容されていること。
    起動したすべてのSubAgentがcompletion済みで、その結果がmain orchestratorへjoin済みであること。

    ここまで到達したら停止し、mergeは行わず最終報告してください。

    最終報告には Issue番号、branch、PR番号/URL、最終HEAD SHA、変更概要、ACごとの達成状況、実行したテスト、CI状態、最終review verdict、live mergeability、残存warnings、AC9 runtime canaryの結果、全SubAgentのcompletion/join状態を含めてください。

    impl-review-loop 自体も Step 1/2/4 を SubAgent に委譲し、APPROVE だけでなく live mergeability と blocker 空を終端条件にしています。 triage-required などのラベルは readiness authority ではないため、今回それが残っていても実装開始を止める根拠にはなりません。

    必要なら、このプロンプトをさらに短くした「Claude Code貼り付け用の圧縮版」にもできます。

  7. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-10T10:02:24Z)

    • PR: fix: root_review_pipeline.produce のouter timeout ownershipをinventoryしbackground+join契約を明記する #2622
    • Worktree: .claude/worktrees/issue-2610-root-review-outer-timeout
    • Branch: worktree-issue-2610-root-review-outer-timeout
    • Verification: 4/4 PASS(typecheck/lint/test/build)+ gemini model routing test PASS + 全対象pytest(AC2/AC3/AC4/AC5/AC8)PASS + AC9 canary SKIP(opt-in未有効、exit 77、Issueの想定通り)
    • fresh 5項目inventoryの結果: repository-owned consumer不在を再確認(regression pin)。Owner決定に従いAC1/AC6/AC7/AC8/AC9を実装し、AC2/AC3のnamed SSOT変更はskip_conditionsに従い対象外とした
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  8. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-09-10T10:54:40Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2622"
      head_sha: "deaceb145da75a39e759985879cda522e12a4d6c"
      issue_number: 2610
      termination_reason: approved
      merge_ready: false
      iteration: 2
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