Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "canonical VC plan に command-level timeout budget を追加し、baseline_vc_preflight / contract_readiness_check / run_contract_review_once / run_root_review_pipeline が同一 budget を消費する契約へ配線することで、成長し続ける既存 test suite の実測実行時間に追従できず単発実行のみで誤って Command exceeded timeout blocker を出す構造的欠陥を解消する"
change_kind: codeParent Issue
none
Parent Goal Ref
- Goal: なし(単独改善)
- Desired Destination: なし(単独改善)
Current Validated Scope
- command-level timeout budget(
timeout_seconds/cleanup_tail_seconds/source/estimator_version/estimator_input_digest等の provenance を含む)を canonical VC plan の一部として生成・伝播するロジックの追加 baseline_vc_preflight.py/contract_readiness_check.py/run_contract_review_once.py/run_root_review_pipeline.pyが、同一の command-level budget を独立 scalar の再指定なしに消費するよう配線変更- 上記ロジックに対する pytest(新規テストファイルおよび既存テストファイルへの追加)
Remaining Parent Gaps
なし
Outcome
command-level timeout budget が canonical VC plan(body_sha256、parser_contract_version、command occurrences 等と並ぶ一級のデータ)として生成され、baseline_vc_preflight.py / contract_readiness_check.py / run_contract_review_once.py / run_root_review_pipeline.py の 4 箇所が、それぞれ独立に DEFAULT_TIMEOUT_SECONDS = 150 相当の scalar を再定義・再解釈するのではなく、同一の plan-derived budget を消費する状態になる。budget は最低限、決定論的な static_fallback source を持つ deterministic fallback を実装し、hard maximum を超える推定値は無制限に伸ばさず typed non-retryable failure(command_timeout_exceeds_policy 等)として扱う。history-based(過去実測 P50/P95 等)の calibration は本 Issue の必須スコープに含めず、将来の別 Issue に分離する前提で設計する。
Runtime Verification Applicability
- decision: not_applicable
- reason: command-level budget の plumbing と deterministic fallback は静的検証(pytest によるユニットテスト、typed failure の unit-level 検証)のみで完結する。process-group cancellation や実際の timeout 発火の scaled runtime 検証(OWNER コメントの AC7/AC8 相当)は本 Issue のスコープに含めないため、immediate runtime verification は不要と判断する。scope 拡張が発生した場合は本セクションを再検討する。
In Scope
- 単一の root-owned estimator/producer(pinned body / command plan →
CommandBudget生成 → hard policy ceiling 検査 → immutable plan digest)の追加 - canonical VC plan(body_sha256, parser_contract_version, command occurrences, execution_key_hash 等)への
command_budgets[]/ aggregate budget / estimator evidence digest フィールドの追加 contract_readiness_check.pyが同じ plan を検証し outer budget を導出するよう変更baseline_vc_preflight.pyが plan 由来の per-command budget を適用し、override precedence(既存--timeout-secondsを hard global override として扱う)に従い、実効 timeout の provenance(timeout_seconds/cleanup_tail_seconds/source: explicit_override|static_fallback/estimator_version/estimator_input_digest)を result item に出力するよう変更run_contract_review_once.py/run_root_review_pipeline.pyが独立の scalar を再導出せず、同じ plan を消費するよう配線変更- per-command / aggregate の hard maximum(
DEFAULT_PER_COMMAND_TIMEOUT_SECONDS/MIN_PER_COMMAND_TIMEOUT_SECONDS/MAX_PER_COMMAND_TIMEOUT_SECONDS/MAX_TOTAL_VERIFICATION_BUDGET_SECONDS)を固定し、超過時は subprocess 起動前に typed non-retryable failure とする - dynamic timeout 発火時に direct child/grandchild process が bounded time 内に確実に終了することを確認する process-group cancellation テスト
- 上記変更に対応する pytest の追加(
.claude/skills/issue-contract-review/scripts/tests/および.claude/skills/issue-contract-review/tests/配下) .claude/skills/issue-contract-review/references/vc-preflight.mdへの新しい budget 契約の記載
Out of Scope
- history-based(過去実測 P50/P95 等)estimator の完全実装(command identity・環境 fingerprint・minimum samples・TTL・poisoning 防止を含む calibration 基盤は別 Issue に分離する)
- 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2207/PR 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2221 が導入した aggregate timeout budget の計算式(
N * (150 + 15) + 20系)自体の再変更(本 Issue はこの計算式を command-level budget の集約先として消費する側に回り、計算式自体は変更しない) - 既存ファイル
.claude/skills/issue-contract-review/scripts/tests/test_review_budget_formula.py(実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2207/PR 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2221 由来、既存 aggregate budget formula の契約テスト)および.claude/skills/issue-contract-review/scripts/tests/test_review_budget_planner.py(同由来)自体の変更(本 Issue の AC3/AC4 は新規専用テストファイルで検証し、既存2ファイルには触れない) - 実装: baseline_vc_preflight/v1 に重複 non-pure VC コマンド検出の diagnostics フィールドを追加する #2232(重複 non-pure VC コマンド検出の diagnostics フィールド追加)の責務(別軸の diagnostics であり、本 Issue の budget plumbing とは独立)
docs/dev/ci-performance.mdのci_runtime_baseline_v1(CI job/step の elapsed_ms 記録用スキーマ)自体の再設計(既存資産として参照はするが、本 Issue の per-command VC timeout budget と責務境界を共有しない)
Acceptance Criteria
- AC1: command-level timeout budget を表す新規データ型(
command_timeout_budget/v1相当。command_hash/execution_key_hash/timeout_seconds/cleanup_tail_seconds/source/estimator_version/estimator_input_digest/sample_count/observed_p95_ms/policy_clampedを含む)が実装されている - AC2:
baseline_vc_preflight.py/contract_readiness_check.py/run_contract_review_once.py/run_root_review_pipeline.pyが同一の canonical plan-derived budget を消費し、独立のDEFAULT_TIMEOUT_SECONDS = 150相当の scalar を各ファイルで再指定していないことがテストで固定されている - AC3: aggregate invariant(outer budget が command-level budget の合計 + cleanup tail を常に上回ること)が、異なる timeout を持つ 2 本の non-pure VC を negative control に含めたテストで検証されている
- AC4: 既存の
--timeout-secondsオプションが hard global override として command-level budget より優先されることがテストで検証されている - AC5: 推定値が per-command / aggregate の hard maximum を超えた場合、subprocess を起動せず typed non-retryable failure(
command_timeout_exceeds_policy等)を返すことがテストで検証されている - AC6: result item に実効 timeout の provenance(
timeout_seconds/cleanup_tail_seconds/source/estimator_version/estimator_input_digest)が出力されることがテストで検証されている - AC7: dynamic timeout 発火時に、direct child および grandchild process が bounded time 内に確実に終了する(process-group cancellation)ことがテストで検証されている
- AC8: history evidence がない場合に明示的な
static_fallbacksource が使われ、DEFAULT_TIMEOUT_SECONDS相当の後方互換フォールバック値が引き続き 90 秒以上であることがテストで検証されている - AC9:
uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -vが PASS する(標準 gate)
Verification Commands
# AC1
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_command_timeout_budget.py -v# AC2
$ uv run --locked pytest .claude/skills/issue-contract-review/tests/test_run_contract_review_once_wrapper_wiring.py -v# AC3
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_command_timeout_budget_aggregate_invariant.py -v# AC4
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_command_timeout_budget_override_precedence.py -v# AC5
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_command_timeout_budget.py -v -k policy_ceiling# AC6
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_command_timeout_budget.py -v -k provenance# AC7
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py -v# AC8
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_default_seconds.py -v# AC9
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -v$ pnpm typecheck$ pnpm lint$ pnpm test$ pnpm buildAllowed Paths
- .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
- .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_default_seconds.py
- .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_timeout_classification.py
- .claude/skills/issue-contract-review/scripts/contract_readiness_check.py
- .claude/skills/issue-contract-review/scripts/run_contract_review_once.py
- .claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py
- .claude/skills/issue-contract-review/scripts/tests/test_command_timeout_budget_aggregate_invariant.py
- .claude/skills/issue-contract-review/scripts/tests/test_command_timeout_budget_override_precedence.py
- .claude/skills/issue-contract-review/tests/test_run_contract_review_once_wrapper_wiring.py
- .claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py
- .claude/skills/issue-contract-review/scripts/tests/test_command_timeout_budget.py
- .claude/skills/issue-contract-review/references/vc-preflight.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- history-based estimator(P50/P95 収集・TTL・poisoning 防止基盤)の実装が必須になったと判明した場合(別 Issue に分離すること)
- 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2207/PR 実装: review pipeline の timeout budget を動的 VC 本数ベースに再設計する #2221 の aggregate 計算式自体の変更が必要になったと判明した場合
Required Skills
なし
Required Design References
- .claude/skills/issue-contract-review/references/vc-preflight.md
Scope Delta(任意)
N/A
Background
.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py の DEFAULT_TIMEOUT_SECONDS = 150 は同ファイル内(baseline_vc_preflight.py:61 付近)の単一定義であり、contract_readiness_check.py と run_contract_review_once.py はこの定数を import して再利用しているだけである(「150 秒が 4 ファイルに散在」という記述は不正確であり、正しくは「単一定義 + 複数箇所からの import 依存」)。run_root_review_pipeline.py はこの DEFAULT_TIMEOUT_SECONDS を直接使わず、contract_readiness_check.py 側の派生 aggregate 定数(CONTRACT_READINESS_CHECK_TIMEOUT_SECONDS = VALIDATE_ISSUE_BODY_TIMEOUT_SECONDS + BASELINE_VC_PREFLIGHT_AGGREGATE_TIMEOUT_SECONDS + 20、こちらは #2207/PR #2221 で aggregate budget 側として動的化済み)を使っている。
Issue #2195 の contract に含まれる uv run --locked pytest .claude/skills/issue-refinement-loop/tests -v を control-plane が実測したところ、1556 passed in 271.31s(271 秒、real 4m32s)であり、単一回の実行だけで固定 150 秒キャップを大幅に超過することを確認した。この VC は #2195 が新規追加したものではなく、.claude/skills/issue-refinement-loop/tests/ 配下の既存 test suite 全体を対象とする、この skill を触る多数の Issue で使われる一般的な VC パターンである。review pipeline(run_root_review_pipeline.py produce → contract_readiness_check.py → baseline_vc_preflight.py)は、VC の重複を排除して VC occurrence が 1 件のみになっても、この単一コマンドの実行だけで Command exceeded timeout blocker を返し、Issue 本文の contract readiness を needs-fix / contract_readiness_human_judgment にしてしまう。これは Issue 本文の品質問題ではなく、review pipeline 側の per-command timeout 定数が、成長した既存 test suite の実測実行時間に追従していない構造的な問題である。
当初案(固定値の再引き上げ、または pytest 収集数を単独 authority とする estimator)は OWNER コメント(https://github.com/squne121/loop-protocol/issues/2233#issuecomment-5316918144)で reframe_in_place を要求された。主な指摘は以下の通り。
- pytest の収集数(
--collect-only)は実行時間 estimator の単独 authority にできない。fixture setup/teardown、parametrization、plugin、I/O、uv runの環境同期コストが実時間に影響するため、収集数は補助 feature に留めるべき。 - 過去の実測時間ベースの history estimator を使うなら、command normalization/hash、cwd/env delta、uv.lock digest、Python/uv/pytest version、runner class、tested head SHA、sample count、P50/P95、TTL、cold-start fallback、timeout/cancelled sample の扱い、atomic write、poisoning 防止を定義する必要がある。既存の
ci_runtime_baseline_v1(docs/dev/ci-performance.md)と bootstrap 3 runs / decision baseline 20 runs 方針を無視して独自 policy を追加すると二重 SSOT になる。 - per-command の hard ceiling を固定し、推定値が hard maximum を超えたら無制限に伸ばさず typed non-retryable failure にすべき。
- 実効 timeout の provenance(timeout_seconds / cleanup_tail_seconds / source / estimator_version / estimator_input_digest)を result item に出力すべき。これは
baseline_vc_preflight/v1の schema change になり得るため、同じ schema/producer file を触る 実装: baseline_vc_preflight/v1 に重複 non-pure VC コマンド検出の diagnostics フィールドを追加する #2232(重複 non-pure VC diagnostics、OPEN)との順序・rebase・consumer compatibility も明示すべき。
codebase-investigator による事実確認の結果、「per-command budget/provenance concept が全く存在しない」という前提も一部不正確であることが判明した。baseline_vc_preflight.py には compute_execution_key_hash()(560行目付近)と duration_ms(1177行目付近で計測)が既に存在する。ただし estimator_version / source 等の provenance field は存在せず、この点は OWNER 指摘通り正しい。
本 Issue は OWNER の推奨に従い、責務配置を「root-owned estimator producer(pinned body/command plan → trusted telemetry → CommandBudget 生成 → hard policy ceiling 検査 → immutable plan digest)→ canonical VC plan(command_budgets[] 等を追加)→ contract_readiness_check(同じ plan を検証し outer budget を導出)→ baseline_vc_preflight(budget 適用、override precedence、provenance 出力、process group 回収)→ run_root_review_pipeline/run_contract_review_once(独立 scalar を再導出せず同じ plan を消費)」へ reframe する。history-based estimator まで本 Issue 内で実装するとスコープが際限なく広がるため、command-level budget の plumbing と deterministic fallback(static_fallback)までに限定し、historical calibration(P50/P95 収集等)は Out of Scope として明示的に別 Issue へ分離する。
#2232(実装: baseline_vc_preflight/v1 に重複 non-pure VC コマンド検出の diagnostics フィールドを追加する、OPEN)は同じ baseline_vc_preflight.py の result item schema を触るが、focus は重複検出 diagnostics であり本 Issue の budget provenance フィールドとは別軸である。両 Issue が同じ producer schema/ファイルに触れる可能性があるため、実装順序としては本 Issue(budget provenance フィールド追加)を先に進めるか、#2232 の diagnostics フィールドと衝突しないキー名を選び、マージ順序が入れ替わった場合は rebase 時に result item のキー集合を両方満たすよう明示的に確認すること。いずれの順でマージされても、後発 PR は先行 PR がマージ済みの schema を前提に rebase し、consumer(contract_readiness_check.py 等)が両方の新フィールドを読み取れることを確認する。
Refs #2195, Refs #2207, Refs #1333, Refs #2232, Refs OWNER comment #2233 (comment)
Delivery Rule
1 Issue = 1 PR とする。worktree を作成して作業し、PR は Draft で作成する。
Notes for Reviewer
- 本 reframe は OWNER コメント(https://github.com/squne121/loop-protocol/issues/2233#issuecomment-5316918144)への対応であり、当初の「pytest 収集数ベースの単純な動的化」案を破棄し、command-level timeout budget を canonical VC plan の一部に格上げする設計へ全面改訂したものである。
- history-based(過去実測 P50/P95)estimator の完全実装は意図的に本 Issue のスコープから除外し、command-level budget の plumbing と deterministic fallback(
static_fallback)までに限定した。history estimator は別 Issue で扱うこと。 - 実装: baseline_vc_preflight/v1 に重複 non-pure VC コマンド検出の diagnostics フィールドを追加する #2232 との schema/producer file 競合は Background に記載した通り、マージ順序に応じて rebase 時に result item のキー集合の両立を確認すること。
- Scope Collision (C1, advisory): overlap preflight(
check_issue_overlap.py)により.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py/ 関連テストへのallowed_paths重複を検出(related_issue=実装: baseline_vc_preflight/v1 に重複 non-pure VC コマンド検出の diagnostics フィールドを追加する #2232, 実装: guard-issue-body.py の AC/VC alignment を共有パーサーへ統合し VC grammar parity/LP010/authoring reference を同期する #1719, 実装: overlap pagination の read-only runtime smoke を controlled VC として追加する #1610, 実装: Issue MRC 追加 key の検証ロスを塞ぐ #1396, 実装: issue-contract-review scripts の CLI alias compatibility を追加する #1053, feat(agent-ops): broad regex VC を検出する vc_text_assert.py を追加し、positive assertion の unexpected_pass を事前に潰す #996, 実装: issue-refinement-loop の rewrite routing が既存 blocker contract を consume して non-body-author-fixable blocker を早期停止できるようにする #944, 実装: check_blockers.sh の条件付き依存記述による false positive を改善する #265)。実装: baseline_vc_preflight/v1 に重複 non-pure VC コマンド検出の diagnostics フィールドを追加する #2232 は重複 VC コマンド検出 diagnostics(別軸、Out of Scope に明記済み、Background にも順序調整方針を明記)。他は関連 skill の別 concern(CLI alias, MRC 検証, blocker check 等)であり、edit_intent(本 Issue = command-level timeout budget の plumbing)は non-conflicting と判断し起票を継続する。
Activity
squne121 commentedon Aug 17, 2026
[create-issue] post-create ready tuple validation FAILED: title prefix or phase/implementation label missing. Manual fix required.
squne121 commentedon Aug 17, 2026
[create-issue] Recovery applied: label-readback stage mismatch resolved via
create_issue_txn.py reconcile(canonical/agent/implementer labels restored). Post-create ready tuple validation now PASSES (title prefix ✓, phase/implementation label ✓).squne121 commentedon Aug 17, 2026
判定
REQUEST_CHANGES。推奨 disposition はreframe_in_placeです。レビュー対象は、2026年8月17日時点の
main2b20de74683cc01d0a7e466f63268fb880f4280a、Issue #2233 本文、関連 Issue / PR、現行実装、既存テスト、設計資料です。Issue コメント2件は ready-tuple のラベル復旧記録だけであり、以下の技術的な曖昧性を解消する判断は含んでいません。Issue の問題認識自体は妥当です。#2207 / PR #2221 は aggregate / outer deadline を VC 本数に応じて動的化しましたが、単一 VC の上限150秒は残余リスクとして明示的に残していました。#2233 が示す
issue-refinement-loop/tests全体の実測271.31秒は、固定150秒では正当な regression gate を誤って timeout にする実例になっています。しかし、現契約は「per-command timeout を動的化する」としながら、その値を必要とする上位 budget・production entrypoint・共有 planner を Out of Scope / Allowed Paths 外に置いています。このままでは、実装しても目的を達成しないか、#2207 で確立した timeout 階層を破壊します。
実装着手を止める Blocker
P0-1. 動的な inner timeout を outer budget が表現できない
現在の
contract_readiness_check.pyは、DEFAULT_TIMEOUT_SECONDSを単一 scalar として import し、次の式で aggregate budget を算出しています。derive_review_budget()に渡される入力もcommand_occurrence_countだけであり、各コマンドの timeout 値は渡りません。例えば、正当に300秒を必要とする non-pure pytest VC が2本ある場合、保守的な直列予算は少なくとも次の値です。
しかし現行式の
N=2は350秒です。inner command に300秒を認めても、outerbaseline_aggregateが350秒で process tree を終了させます。ところが #2233 は aggregate budget の変更と
contract_readiness_check.py/run_root_review_pipeline.pyのインターフェース変更を Out of Scope にし、aggregate 側を変更しなければ導出不能と判明した場合を Stop Condition にしています。つまり、現行実装を正しく調査した時点で、その Stop Condition に到達します。必要な修正: budget の入力を
Nだけではなく、canonical plan が持つ command-level budget 列へ変更する必要があります。少なくとも初期実装では、実行 occurrence をすべて合算する保守式にすべきです。将来 parallel batch を厳密にモデル化する場合だけ、canonical planner が生成した batch graph の critical path を使えます。
P0-2.
run_contract_review_once.pyは150秒を明示指定するため、default の動的化では直らないrun_contract_review_once.pyはDEFAULT_TIMEOUT_SECONDSを_VC_PREFLIGHT_PER_COMMAND_TIMEOUTとして importしています。さらにbaseline_vc_preflight.pyの起動時に、を明示的に渡しています。
このため、
baseline_vc_preflight.pyの argparse default を動的化しても、この production entrypoint では引き続き150秒です。逆に、明示された--timeout-secondsを estimator が無視する実装にすると、現在の CLI 契約を無断で「hard override」から別の意味へ変更することになります。既存 wrapper テストも、scalar constant の import、outer timeout の scalar 関係式、明示的な
--timeout-secondsargv を固定しています。ところがrun_contract_review_once.pyとその wiring test は #2233 の Allowed Paths 外です。必要な修正: CLI precedence を契約で固定し、全 entrypoint を更新してください。後方互換性を優先するなら次が自然です。
--timeout-secondsが明示された場合は global hard override。run_contract_review_once.pyは単なる default 値を明示指定しない。P0-3. AC1 が相互に異なる3方式を許容し、無変更実装すら合格し得る
AC1 / Outcome は、次を
orで許しています。これらは入力、信頼境界、失敗モード、必要な I/O がまったく異なる設計です。さらに3番目は、「150秒を維持する」実装も #2207 の
150 + 15式と一貫していると主張できます。したがって AC1 は falsifiable ではありません。仮に aggregate を VC 本数で均等割りするだけでも、
となり、
N >= 2では結局150秒です。N=1の低本数 floor だけで315秒になりますが、2本以上の長時間 VC や異質なコマンド構成を解決しません。必要な修正: AC に次を固定してください。
P0-4. 現行 canonical planner と提案された estimator の責務が両立しない
現在の
compute_canonical_vc_plan()は、pinned Issue body の in-memory bytesだけを入力とする side-effect-free planner です。I/O や subprocess を実行せず、per_command_timeout_secondsも単一 scalar として返します。一方、Issue が候補に挙げる方式は次の追加責務を必要とします。
pytest --collect-only: subprocess 起動、pytest collection、plugin / hook 実行pytest の
--collect-onlyは収集された node list を取得できますが、collection ではpytest_collection_modifyitems等の hook が実行され、pytest_generate_testsは collection 中に parametrization を生成します。単なるファイル数・関数数カウンターではありません。([pytest ドキュメント]1)したがって estimator が別 subprocess で collection を行うなら、planner はもはや side-effect-free ではありません。planner の外で行うなら、root pipeline と executor が同じ estimator snapshot を消費する binding が必要です。現契約には、その snapshot、digest、I/O ownership、TOCTOU 防止策がありません。
必要な修正: planner の入力を、あらかじめ trusted/root-owned producer が確定した immutable estimator evidence に拡張するか、history-based estimator を別 Issue に分離してください。
P0-5.
Runtime Verification Applicability: not_applicableは誤り#2233 が変更するのは、実時間、subprocess lifetime、inner / outer deadline の順序、timeout 時の process-group cleanup です。静的な constant relationship だけを変えた #1333 と異なり、今回の主張は実際の時間経過なしには証明できません。Issue 本文が
not_applicableとする根拠は、問題の性質と一致していません。PR #2221 では runtime fault injection によって、outer wrapper が cooperative SIGTERM handler を通らない問題、signal handler の lock deadlock、SIGTERM を無視する grandchild の残留、kill 後に reap されない zombie などが実際に発見・修正されています。unit test だけでは検出できなかった不具合です。
Python の公式仕様でも、
subprocess.run(timeout=...)は timeout 時に child を kill して wait しますが、Popen.communicate(timeout=...)は自動的には child を終了しません。またstart_new_session=Trueは POSIX でsetsid()を実行します。どの API と process-group policy を使うかが correctness に直接影響します。([Python documentation]2)必要な修正: Runtime Verification は
immediateとし、production と同じ subprocess 階層を通す scaled integration test を必須にしてください。P0-6. Allowed Paths と Verification Commands が実装責務を検証できない
許可されているテストファイルは次の2件だけです。
test_baseline_vc_preflight_default_seconds.pytest_baseline_vc_preflight_timeout_classification.py前者は
DEFAULT_TIMEOUT_SECONDS >= 90、argparse default、ソース文字列のdefault=DEFAULT_TIMEOUT_SECONDSを確認する静的テストです。後者は stderr に"timeout"という語が含まれる高速失敗を genuine timeout と誤分類しないためのテストであり、dynamic estimator、outer budget、wrapper wiring は検証していません。一方で、実際に更新が必要な次のテストは Allowed Paths 外です。
run_contract_review_oncewiring-k timeoutで scripts/tests 全体を実行する AC2 も、今回追加されるべき estimator の正負ケースを特定していません。無関係な timeout classification test が通るだけでも AC2 を満たせます。High findings
P1-1. pytest の収集数は実行時間 estimator の authority にならない
pytest の実時間には test body だけでなく fixture の setup / teardown、parametrization による実行数の増加、plugin、test selection、外部プロセス、I/O が含まれます。pytest 公式にも、parametrized fixture によって収集・実行件数が増え、各 fixture の setup / teardown が実行されることが示されています。実時間の観測には
--durationsが用意されています。([pytest ドキュメント]1)さらに対象コマンドは
uv run --locked pytest ...です。uv はuv runの前に project environment を同期し、--lockedは lockfile 更新を禁止するだけです。環境同期自体を止めるのは--no-syncです。したがって cold / warm environment による差も command timeout に含まれます。([Astral Docs]3)収集数は補助 feature にはなっても、timeout の単独 authority にはできません。
P1-2. 「過去の実測時間」の lifecycle が未定義
history-based estimator を採用する場合、少なくとも次が必要です。
リポジトリには既に
ci_runtime_baseline_v1と CI performance policy があり、1回の測定だけで性能判断せず、bootstrap 3 runs と decision baseline 20 runsを分離し、P50 / P95 で評価する方針が定義されています。#2233 はRequired Skills: なしとしていますが、この既存資産を無視して独自の測定 policy を追加すると二重の performance SSOT になります。271.31秒という1回の観測は「150秒が不足した」という反証には十分ですが、全環境に適用する dynamic policy の決定根拠には不十分です。
P1-3. per-command の hard ceiling がなく、Issue body から deadline を無制限に拡張できる
#2207 は command occurrence 数を40件に制限しています。しかし per-command timeout が無制限に伸びるなら、件数 cap だけでは total deadline を制限できません。現行 planner の policy cap と formula は150秒固定を前提に、最大約110分になることを根拠としていました。
次を別々に固定すべきです。
DEFAULT_PER_COMMAND_TIMEOUT_SECONDSMIN_PER_COMMAND_TIMEOUT_SECONDSMAX_PER_COMMAND_TIMEOUT_SECONDSMAX_TOTAL_VERIFICATION_BUDGET_SECONDS推定値が hard maximum を超える場合は、無制限に deadline を伸ばさず、
command_timeout_exceeds_policy等の typed non-retryable failure にすべきです。P1-4. 実効 timeout の provenance が出力されない
現行 result item は
duration_ms、command_hash、execution_key_hashを出力しますが、「そのコマンドに何秒の timeout が適用されたか」「なぜその値になったか」を出力しません。dynamic 化後にVCP_TIMEOUTが起きても、policy の誤推定か command hang かを判別できません。最低限、各実行結果に次を持たせる必要があります。
これは
baseline_vc_preflight/v1の schema change になり得るため、同じ producer schema と同じbaseline_vc_preflight.pyを変更する #2232 との順序・rebase・consumer compatibility も明示すべきです。推奨するリフレーム
推奨タイトル
実装: canonical VC plan に command-level timeout budget を追加し、全 review wrapper に同一 budget を配線する
「pytest件数から timeout を推定する」ことを主目的にせず、まず command-level budget を end-to-end で表現・伝播できる設計を完成させるべきです。
推奨責務配置
推奨データ契約
history evidence が存在しない場合は、明示的な
static_fallbackを使います。pytest --collect-onlyの件数は、history がない場合の補助 feature としてのみ利用し、単独の authority にしない方が安全です。改訂すべき Acceptance Criteria
Canonical command budget: pinned body と同じ command sequence に対して、各 occurrence の
timeout_seconds、source、estimator version、evidence digest を生成する。Single-plan wiring:
baseline_vc_preflight.py、contract_readiness_check.py、run_root_review_pipeline.py、run_contract_review_once.pyが同じ plan に束縛され、独立した150秒 scalar を再指定しない。Aggregate invariant: outer budget は command-level budget と cleanup tail の保守的合計を常に上回る。異なる timeout を持つ2本の non-pure VC を negative control に含める。
Override precedence: 既存
--timeout-secondsの意味を hard global override、maximum、minimum、fallback のいずれかに固定する。推奨は hard global override。Bounded policy: per-command / aggregate の hard maximum を持ち、超過時は subprocess 起動前に typed non-retryable failure になる。
Provenance: producer result が実効 timeout、source、estimator version、input digest を出力する。
Scaled runtime verification: legacy cap では timeout するが新 budget では完走する command を、production wrapper 階層から実行する。
Cancellation: dynamic timeout 発火時も direct child と grandchild が bounded time 内に消滅する。
Historical policy: history を採用する場合、command identity、環境 fingerprint、minimum samples、P95、TTL、fallback、atomicity、poisoning boundary を固定する。
実装: baseline_vc_preflight/v1 に重複 non-pure VC コマンド検出の diagnostics フィールドを追加する #2232 coordination: schema / producer file の競合順序、consumer inventory、merge sequencing を明記する。
必要な Allowed Paths
最低限、次まで拡張しないと end-to-end の修正になりません。
history-based estimator を #2233 内で実装するなら、さらに
ci-test-performanceの schema、artifact producer / consumer、performance policy 文書を Scope に含める必要があります。そこまで広げない場合は、#2233 を command-level budget の plumbing と deterministic fallback までに限定し、historical calibration を別 Issue に分離するのが妥当です。最終結論
#2233 は必要な follow-up ですが、現在の本文は次の状態です。
not_applicableとしている実装着手前に
reframe_in_placeし、command-level budget を canonical plan の一部に格上げし、すべての wrapper が同じ budget を消費する契約へ変更すべきです。[-]実装: baseline_vc_preflight の per-command timeout を実測実行時間に応じて動的化する[/-][+]実装: canonical VC plan に command-level timeout budget を追加し、全 review wrapper に同一 budget を配線する[/+]squne121 commentedon Aug 17, 2026
Contract Review Result
squne121 commentedon Aug 17, 2026
issue-refinement-loop 終了報告
OWNER コメント(issuecomment-5316918144)が要求した
reframe_in_placeを反映し、Issue #2233 本文を全面改訂しました。実施内容
codebase-investigatorにより、コメントの主張(DEFAULT_TIMEOUT_SECONDSが4ファイルに散在/per-command provenance が皆無)を実コードと突き合わせ、正確な現状(単一定義+複数 import、duration_ms/execution_key_hashは既存だが provenance field は未実装)を確認。run_root_review_pipeline.pyのVERDICT: needs-fix(VCP_UNEXPECTED_PASS)を受け、issue-editorに委譲してタイトル・Outcome・AC(9項目、history-based estimator は Out of Scope に分離)・Allowed Paths(9ファイル追加)・Background(実装: baseline_vc_preflight/v1 に重複 non-pure VC コマンド検出の diagnostics フィールドを追加する #2232 との調整方針)を全面改訂。-kフィルタで 0 件マッチ(exit 5, hard block)していたため、専用の新規テストファイル参照へ再修正。VERDICT: approve、BLOCKERS: 0(body_sha256:sha256:b34f4969270bd439c9d85a1a84c9adc861248908abf440add0324a978692b70f)。Final Gate
issue-contract-review(run_contract_review_once.py --mode execute)を実行し、status: go(readiness/vc_preflight/product_spec 全 pass, blockers 0)を確認。Contract Snapshot を issuecomment-5317056458 に公開済み。次のアクション
impl-review-loopへ handoff 可能(status: impl_ready)。squne121 commentedon Aug 17, 2026
implement-issue: 実装完了 (2026-08-17T14:57:30Z)
.claude/worktrees/issue-2233-vc-timeout-budgetworktree-issue-2233-vc-timeout-budgetsqune121 commentedon Aug 17, 2026
impl-review-loop: 完了 (2026-08-18T00:00:00Z)
fix: canonical VC plan の command-level timeout budget を実際に4箇所で共有・271秒…
squne121 commentedon Aug 18, 2026
impl-review-loop: 完了 (2026-08-18T13:40:00Z)
feat: canonical VC plan に command-level timeout budget を追加する (#2233) (#…
feat: command_timeout_budget/v1 に history-based (nearest_rank_v1) tim…