Skip to content

実装: run_contract_review_once.py の readiness_check ステップに timeout 引数を追加し30秒固定 timeout を解消する #1631

Closed

Description

@squne121

Parent Issue

なし(単独改善)

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "run_contract_review_once.py の execute モードで readiness_check ステップが固定30秒 timeout により runtime_error になる問題を解消する"
change_kind: code

Parent Goal Ref

  • Goal: なし(単独 Issue)
  • Desired Destination: なし

Current Validated Scope

  • run_contract_review_once.py の readiness_check ステップ(_run_script(readiness_cmd) 呼び出し)の timeout 値のみを対象とする

Remaining Parent Gaps

  • なし

Outcome

run_contract_review_once.py(.claude/skills/issue-contract-review/scripts/run_contract_review_once.py)の readiness_check ステップ(contract_readiness_check.py --mode <mode> の subprocess 呼び出し)が、CLI 引数で timeout 秒数を上書き可能になり、かつ既定値が現状の30秒より引き上げられる。これにより、VC スイートの総実行時間が伸びた Issue(AC/VC 件数が多い、または個々の test 実行が数秒〜十数秒かかる)でも readiness_check_error: timeout による status: runtime_error に到達しにくくなる。

Background

Issue #1621(squne121/loop-protocol)の issue-contract-review 実行時、run_contract_review_once.py --mode execute を4回連続で実行したが、いずれも以下の runtime_error で失敗した。

{"schema": "CONTRACT_REVIEW_ONCE_RESULT_V1", "status": "runtime_error", "errors": ["readiness_check_error: timeout"]}

同一 Issue に対して --mode static を実行した場合は正常に完了し、11件の AC すべての VC(uv run pytest による実 test 実行)が pass した(vc_preflight_status: pass、readiness_status: go)。VC の実行時間の内訳は、個々の pytest 実行が 0.02〜8.1秒、--mode static 全体で約40秒程度だった。

run_contract_review_once.py の readiness_check ステップ(_run_script(readiness_cmd))は _DEFAULT_TIMEOUT = 30(run_contract_review_once.py:83)を timeout として使用しており、--mode execute を指定した場合は内部で contract_readiness_check.py --mode execute を呼び出す(run_contract_review_once.py:406-417)。--mode execute の contract_readiness_check.py 側の実処理内容次第では、上記の実 VC 実行時間の合計が容易に30秒を超えうる。

--mode static では readiness_check ステップ自体は timeout に到達しなかったため、本 Issue は「readiness_check ステップの timeout が短すぎる」という一般的な問題として起票する(--mode execute 固有の処理内容の是非は対象外とする)。

In Scope

  • run_contract_review_once.py の readiness_check ステップ(_run_script(readiness_cmd) 呼び出し、run_contract_review_once.py:417 付近)に、timeout 秒数を指定できる CLI 引数(例: --readiness-timeout-seconds)を追加する
  • 上記引数を省略した場合の既定値を、現状の _DEFAULT_TIMEOUT = 30 より大きい値に引き上げる(具体的な秒数は実装時に既存 VC 実行時間の実測値を踏まえて決定する)
  • timeout到達時の readiness_check_error: timeout エラーメッセージに、実際に使用された timeout 秒数を含める(診断性向上)
  • 既存のテスト(test_run_contract_review_once.py / test_run_contract_review_once_wrapper_wiring.py)に、timeout 引数の受け渡しと既定値引き上げを確認する回帰テストを追加する

Out of Scope

  • contract_readiness_check.py --mode execute 自体の実行時間短縮・処理内容の変更
  • baseline_vc_preflight.py 側の _VC_PREFLIGHT_TIMEOUT / _VC_PREFLIGHT_PER_COMMAND_TIMEOUT の変更
  • check_blockers.sh / check_product_spec_contract.py 呼び出しの timeout 調整(同じ _DEFAULT_TIMEOUT を使うが、本 Issue の再現手順ではこれらの timeout は問題になっていない)

Acceptance Criteria

  • AC1: run_contract_review_once.py に readiness_check ステップの timeout を指定できる CLI 引数が追加されている
  • AC2: timeout 引数を省略した場合の既定値が、現状の _DEFAULT_TIMEOUT = 30(run_contract_review_once.py:83)より大きい値になっている
  • AC3: timeout到達時のエラーメッセージに実際に使用された timeout 秒数が含まれている
  • AC4: 既存のテストスイート(.claude/skills/issue-contract-review/tests/)が全て pass する

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 本変更は CLI 引数の追加と既定値変更、エラーメッセージの文言変更であり、subprocess timeout 値の受け渡しは unit test(fake subprocess / 短い timeout を意図的に設定したテスト)で決定論的に検証できる。GitHub API access や実ネットワーク I/O を必須とする要素はない

Verification Commands

# AC1
$ uv run pytest .claude/skills/issue-contract-review/tests/test_run_contract_review_once.py -q
# AC2
$ uv run pytest .claude/skills/issue-contract-review/tests/test_run_contract_review_once.py -q
# AC3
$ uv run pytest .claude/skills/issue-contract-review/tests/test_run_contract_review_once.py -q
# AC4
$ uv run pytest .claude/skills/issue-contract-review/tests/ -q

Allowed Paths

  • .claude/skills/issue-contract-review/scripts/run_contract_review_once.py
  • .claude/skills/issue-contract-review/tests/test_run_contract_review_once.py
  • .claude/skills/issue-contract-review/tests/test_run_contract_review_once_wrapper_wiring.py

Stop Conditions

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

Required Skills

  • Python 3

Required Design References

  • .claude/skills/issue-contract-review/scripts/run_contract_review_once.py
  • .claude/skills/issue-contract-review/SKILL.md

Delivery Rule

  • 1 Issue = 1 PR で完結する
  • worktree: .claude/worktrees/issue-<番号>-contract-review-timeout
  • Draft PR を既定とする

Notes for Reviewer

  • 再現手順: Issue 実装: check_implementation_overlap.py の候補に native dependency を前段取得し successor 判定を live route まで反映する #1621(squne121/loop-protocol)に対して uv run --locked python3 .claude/skills/issue-contract-review/scripts/run_contract_review_once.py --issue-number 1621 --repo squne121/loop-protocol --mode execute を実行すると readiness_check_error: timeout で runtime_error になる(本 Issue 起票時点で4回連続再現)。同一 Issue で --mode static は正常完了する
  • 既定 timeout の具体的な引き上げ幅は、実装時に contract_readiness_check.py --mode execute の実測実行時間を計測してから決定することを推奨する

Activity

  1. added
    enhancement
    phase/implementation
    agent/implementer
    on Jul 19, 2026
  2. squne121 commented on Aug 11, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-08-11T10:30:16Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1631
      body_sha256: "sha256:2f95aa5bdb3677fcd28abb8f8182fa6173643e8efabe693449f6cc327f9ff142"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:2f95aa5bdb3677fcd28abb8f8182fa6173643e8efabe693449f6cc327f9ff142","source_provenance":{"source_type":"body_file","body_file":"/tmp/contract_review_once_body_qewut5ab.md"}}
        vc_preflight:
          decision: pass
          classifications: '[{"ac":"AC1","line":2,"raw_command":"uv run pytest .claude/skills/issue-contract-review/tests/test_run_contract_review_once.py -q","command_hash":"sha256:84f622f013f57e54bf2eea916bfe6860e05d5a89e29e64b7418f23e3b89eaefc","execution_key_hash":"sha256:27c10ac12f75c7ef151cb4376100cdf1fd457e1ae0fd0f156240be8997f499f5","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["......................................                                   [100%]","38 passed in 0.08s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":251,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC2","line":2,"raw_command":"uv run pytest .claude/skills/issue-contract-review/tests/test_run_contract_review_once.py -q","command_hash":"sha256:84f622f013f57e54bf2eea916bfe6860e05d5a89e29e64b7418f23e3b89eaefc","execution_key_hash":"sha256:35173b1b636a7685541560139fd2778860ef2fe1f14c99c3c0a9749ac9e17d5a","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["......................................                                   [100%]","38 passed in 0.08s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":274,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC3","line":2,"raw_command":"uv run pytest .claude/skills/issue-contract-review/tests/test_run_contract_review_once.py -q","command_hash":"sha256:84f622f013f57e54bf2eea916bfe6860e05d5a89e29e64b7418f23e3b89eaefc","execution_key_hash":"sha256:018908d682d06d958876328d58a51fe175734f35bc4946d9aa5ce82294aa066e","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["......................................                                   [100%]","38 passed in 0.08s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":257,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC4","line":2,"raw_command":"uv run pytest .claude/skills/issue-contract-review/tests/ -q","command_hash":"sha256:1fda194552a41e7fb936c67d28e21442c46790adc1b37ba4356beeb6c17168c8","execution_key_hash":"sha256:dc7a17a3aec82f2d3e2090fc9bace1ef25c3d5e7b469869c6fa9c0ad1ec55b27","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["........................................................................ [ 14%]","........................................................................ [ 29%]","........................................................................ [ 43%]","........................................................................ [ 58%]","........................................................................ [ 72%]","........................................................................ [ 87%]","..............................................................           [100%]","494 passed in 13.27s"],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":14147,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null}]'
          classifications_transport: {"schema":"vc_preflight_classifications_transport/v1","classification_count":4,"original_payload_sha256":"sha256:f8393c3243b4362eeb66f4f7ffed92e5894969a40ba07c628b8b5172d1dc919e","compact":false,"truncated":false}
        declared_path_overlap: '{"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"6584062cc47a6f85028ae16635a4164a4a3b35cf","draft_policy":"include_drafts","prs":[{"number":1528,"title":"feat(cleanup): 同一実行内の branch-only fallback を追加","base_ref_name":"main","head_ref_name":"worktree-issue-1403-post-merge-cleanup-dedicated-branch-forc","head_ref_oid":"b29007580ae225eb9676c7f32c878ee2bb9ccaa9","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1528","changed_files_count_graphql":4},{"number":2068,"title":"fix(issue-refinement-loop): bind freeform OWNER scope authority end-to-end and expose routing telemetry","base_ref_name":"main","head_ref_name":"worktree-issue-2053-bind-freeform-authority-transport","head_ref_oid":"d623bf60758b2e145b454bb39b20f6acbf267480","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2068","changed_files_count_graphql":16},{"number":2070,"title":"fix(contract-review): RVA 欠落を fail-closed に統一","base_ref_name":"main","head_ref_name":"worktree-issue-2040-implementation-issue-runtime-verificatio","head_ref_oid":"9d5c639de9e3d01c6260939c3b790f40616b911e","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2070","changed_files_count_graphql":32},{"number":2072,"title":"fix: test_issue_1952回帰テストのrepo_root誤指定による.claude/.claude迷子ディレクトリ生成を修正する","base_ref_name":"main","head_ref_name":"worktree-issue-2071-repo-root-fix","head_ref_oid":"488bc8554a6f2d6e5187d0ea374034d19954a14f","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2072","changed_files_count_graphql":1},{"number":2083,"title":"fix(issue-refinement-loop): trusted scope directive を planner に束縛する","base_ref_name":"main","head_ref_name":"worktree-issue-2055-planner-binding","head_ref_oid":"f6aef52ca3722a79205a344cdf1222042be9148d","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2083","changed_files_count_graphql":4},{"number":2089,"title":"fix: CI verdict status checks をページネーションする","base_ref_name":"main","head_ref_name":"worktree-issue-2088-ci-status-check-pagination","head_ref_oid":"0334f3ebf5aaff94c7b7130d97194ae2b88542fa","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2089","changed_files_count_graphql":2},{"number":2092,"title":"実装: GitHub Issue labels を presentation-only metadata として SSOT 化する","base_ref_name":"main","head_ref_name":"worktree-issue-2084-label-authority","head_ref_oid":"68b2cec624b05c33e95041918784913469e96d1c","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2092","changed_files_count_graphql":12},{"number":2094,"title":"fix: visual-impact-policy-trusted の trusted-side re-derivation で forged-self-consistent artifact bypass を fail-closed に修正する","base_ref_name":"main","head_ref_name":"worktree-issue-2091-trusted-side-rederivation","head_ref_oid":"99a06eba9784b40c0bd2f922ea4ebfac42367dcb","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2094","changed_files_count_graphql":3}],"fetched_count":8,"totalCount":8,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:d0ff9ac2fe973deb2c090e774867cc6c3bd7c53c445985525ef577de2bfdc3a9","errors":[]},"inventory_digest_extended":"sha256:abf70699a6c040a6225a92a09a6904e859a92e8ab2ca330eddb3cd125c398427","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}'
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: {"issue_number":1631,"contract_source_kind":"issue_comment","contract_source_id":"5251979940","contract_body_sha256":"sha256:2f95aa5bdb3677fcd28abb8f8182fa6173643e8efabe693449f6cc327f9ff142","allowed_paths_normalized_sha256":"8bdb2e9f352cb7ae86ab41adfff39ae979e1a916f4fb4ef57f0c640cb78e3833","base_ref":"main","base_sha_at_snapshot":"6584062cc47a6f85028ae16635a4164a4a3b35cf"}
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