Repository navigation
Closed
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#964"
goal_ref: "plan_refinement_loop.py の SyntaxError 報告と loop 停止を再現不能化し、issue-refinement-loop を安全に再開させるための検出・証跡整合を修正する"
change_kind: toolingParent Issue
Parent Goal Ref
#964はplan_refinement_loop.py実行時のSyntaxErrorを契機にissue-refinement-loopがhuman_judgment_requiredで停止したため、再発条件の切り分けと再開手順の安定化が必要。- 仕様は「実装: PR body hygiene 更新は update_pr.py wrapper 経由に限定する #964 本体修正の実装」を止めるのではなく、loop 運用の停止を解くために観測証跡と判定の整合を確認する。
Current Validated Scope
.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py.claude/artifacts/issue-refinement-loop/964/(生成物として扱う。恒久 fixture はtests/fixtures/に置く)
Remaining Parent Gaps
plan_refinement_loop.pyの構文エラーが再現した実行環境(行番号付き traceback)を持つ再現手順。- loop 停止時の再開手順に対する実行環境不整合(ファイル/環境差分)ルール。
Outcome
issue-refinement-loop 実行時の SyntaxError 停止が再現しない前提を明文化し、発生時は「違うファイル/別コミット実行」起因であることを短時間で切り分けできるようにする。#964 の実装作業は再開可能な状態に導く。
In Scope
plan_refinement_loop.pyの実行時実態確認(構文検証: py_compile)およびPY_COMPILE_PROOF_V1の記録run_refinement_preflight.py経由で planner 生成時の error path を確認し、PLANNER_FAILURE_CLASSIFICATION_V1taxonomy に従って停止理由を分類・明文化- live preflight と fixture replay の両方を実行し、
REFINEMENT_PREFLIGHT_REPLAY_PROOF_V1として記録 REFINEMENT_PREFLIGHT_PROVENANCE_V1フィールド(git HEAD / script blob SHA / python executable / cwd / stderr hash 等)を artifact または Issue コメントに残す手順の整備.claude/artifacts/issue-refinement-loop/964/は生成物として扱い、恒久 fixture はtests/fixtures/に配置する区別の明確化
Out of Scope
#964の AC/VC 本体修正(別Issueで確定)。open-prやupdate_pr.py本体の直接改修。- Hook ルール(
gh pr editdeny allowlist)の機能追加自体。 #964の runtime enforcement blocker(gh pr edit --body,--body-file,gh api, GraphQL, shell chaining, Claude Code hook deny semantics)の解消。
Acceptance Criteria
- AC1: 現行
plan_refinement_loop.pyについてPY_COMPILE_PROOF_V1を記録する。記録すべき内容:python3 -m py_compileの成否 /python3 -V/sys.executable/git rev-parse HEAD/git hash-object plan_refinement_loop.py/ cwd / realpath / stderr hash。 - AC2:
#964anchor comment を使った live preflight と、保存済み raw snapshot を使った fixture replay の両方を実行し、結果をREFINEMENT_PREFLIGHT_REPLAY_PROOF_V1として記録する。live run と fixture replay の差分が input drift の有無を示すことを確認する。 - AC3:
PLANNER_INTERNAL_ERRORが現れた場合、syntax_compile_failure/planner_stdout_non_json/planner_runtime_internal_error/wrapper_environment_failure/anchor_or_input_blockedに分類できるPLANNER_FAILURE_CLASSIFICATION_V1taxonomy の手順を Issue コメントまたは artifact として記録する。 - AC4:
SyntaxErrorが再現した場合の traceback 採取手順を固定する。採取すべき情報: command / cwd / interpreter / script realpath / git HEAD / file blob SHA / traceback excerpt / failing line excerpt。 - AC5:
#964への追記先と追記内容を決める。追記は loop 再開可否に限定し、#964の runtime enforcement blocker(hook deny semantics /gh pr edit全バリアント / GraphQL route)は解消扱いにしない。 - AC6:
.claude/artifacts/issue-refinement-loop/964/は生成物として扱い、恒久 fixture が必要な場合は.claude/skills/issue-refinement-loop/tests/fixtures/に置く。generated artifact を通常の source edit として扱わない。
Runtime Verification Applicability
decision: not_applicable
reason: "本Issueは再発原因の再現条件整理と運用手順整備が対象で、実行時の実装変更を前提としない。"
Verification Commands
# AC1
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_1035_provenance.py::test_py_compile_proof_v1 -v
# AC2
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_1035_provenance.py::test_preflight_replay_proof_v1 -v
# AC3
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_1035_provenance.py::test_planner_failure_classification_v1 -v
# AC4
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_1035_provenance.py::test_preflight_provenance_v1 -v
# AC5
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_1035_provenance.py::test_issue_964_enforcement_not_resolved -v
# AC6
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_1035_provenance.py::test_artifacts_not_git_tracked -vAllowed Paths
.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py.claude/skills/issue-refinement-loop/tests/test_1035_provenance.py.claude/skills/issue-refinement-loop/tests/fixtures/(恒久 fixture 配置先)
Stop Conditions
- 再現環境を特定するために別環境要因を切り分ける必要があり、別ファイル(別バージョン)起点の修正が必要になった場合。
- 本Issueの対象範囲外である
#964の core AC 修正が必要と判断された場合。 - 追加の安全対策(command wrapper/validator 変更)が必要と判明した場合。
#964の runtime enforcement blocker(hook deny semantics /gh pr edit全バリアント)の解消が本 Issue の調査結果として要求された場合。- fixture replay と live run の結果が異なり、input drift の特定に本 Issue のスコープを超える別 Issue が必要と判明した場合。
py_compile以外の起因(encoding / BOM / worktree 汚染 / 別 interpreter)が判明し、本 Issue の Allowed Paths 外の修正が必要になった場合。
Required Skills
- review-issue
Metadata
Metadata
Assignees
Labels
No labels
Activity
squne121 commentedon Jun 20, 2026
判定: REQUEST_CHANGES
#1035 は必要ですが、このままでは #964 の
issue-refinement-loop再開可否を安全に判断できません。現状の AC は「現行plan_refinement_loop.pyがpy_compileできる」ことに寄りすぎており、実際に停止した実行の commit / worktree / interpreter / stdin / artifact / stderr の同一性を固定していません。#1035 自体はコメントなしで、親 #964 側には既に強いREQUEST_CHANGESコメントがあり、#964 は runtime enforcement の契約問題も抱えています。最大のリスクは、「現行ファイルは構文エラーにならない」=「停止原因は解消済み」 と誤分類することです。Python の
py_compileは指定されたソースを bytecode にコンパイルし、コマンドラインではコンパイル不能なファイルがあれば非 0 終了します。したがって AC1 の検査自体は妥当です。ただし、それが証明するのは「その interpreter が、その path の、その時点のファイルを parse できる」だけで、停止時に実行された別 worktree・別 ref・別一時ファイル・壊れた artifact まで否定しません。([Python documentation]1)Blocker 1:
SyntaxErrorとPLANNER_INTERNAL_ERRORの分類が粗すぎるSyntaxErrorは Python がファイルを parse/import する前に落ちるため、plan_refinement_loop.py内部のtry/exceptでは捕捉できません。一方、planner 実行中の runtime exception はplanner_internal_errorを含む JSON plan と exit 3 を返す実装になっています。wrapper 側は planner を
subprocess.run([sys.executable, str(PLANNER_SCRIPT)], shell=False, ...)で呼び、stdout を JSON parse できない場合はplan is Noneとして扱います。つまり、構文エラー・stdout 非 JSON・runtime exception・timeout が同じPLANNER_INTERNAL_ERROR周辺に潰れて見える危険があります。#1035 には次の taxonomy を AC として追加すべきです。
Blocker 2: provenance がないため「別ファイル/別コミット実行」を短時間で切れない
#1035 の Outcome は「別ファイル/別コミット実行起因を短時間で切り分ける」ですが、AC に必要な証跡フィールドがありません。最低限、以下を artifact または Issue コメントに残すべきです。
run_refinement_preflight.pyは artifact を.claude/artifacts/issue-refinement-loop/<issue_number>/に書く設計なので、証跡化の受け皿はあります。 ただし #1035 の Allowed Paths にある.claude/artifacts/issue-refinement-loop/964/refinement_preflight_result_v1.jsonは runtime 生成物であり、リポジトリ上の通常ファイルとして扱うと ephemeral artifact を commit する設計になります。ここは 「生成される出力先」なのか「編集対象ファイル」なのかを分ける 必要があります。Blocker 3: fixture replay が AC にない
#1035 は live 実行の verification command だけを要求していますが、GitHub Issue 本文・コメントは時間で変わります。停止時の再現性を扱うなら、live run だけでなく fixture replay が必須です。wrapper には
--fixtureが既にあります。追加すべき検証はこれです。
python3 -V python3 -c 'import sys; print(sys.executable)' git rev-parse HEAD git hash-object .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py python3 -m py_compile .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py uv run python3 .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py \ --issue-number 964 \ --repo squne121/loop-protocol \ --anchor-comment-url https://github.com/squne121/loop-protocol/issues/964#issuecomment-4755261407 uv run python3 .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py \ --issue-number 964 \ --repo squne121/loop-protocol \ --fixture .claude/artifacts/issue-refinement-loop/964/raw_issue_snapshot.jsonlive run が pass/warn/blocked でも、fixture replay が別結果なら「再現不能」ではなく input drift です。
Blocker 4: #964 の未解決 blocker を #1035 で消してはいけない
#964 は現在、
update_pr.pywrapper 経由以外の PR body mutation を PreToolUse で止める Issue です。親は #639 として整理されており、#639 は #631 / PR #638 で docs-level prohibition に留まっていた runtime enforcement の follow-up です。#964 コメントでは、
gh pr edit --body-fileだけでは狭すぎること、--body/-b/-F/ shell chaining /gh api/ GraphQL route をどう扱うか明記すべきことが既に指摘されています。 GitHub CLI 公式でもgh pr editは--bodyと--body-fileの両方で PR 本文更新が可能です。(GitHub CLI)したがって #1035 の AC4 は、次のように制限すべきです。
Blocker 5: Claude Code hook の enforcement 仕様を #964 追記で崩す危険
Claude Code hook は
PreToolUseで tool call 前に実行され、hookSpecificOutput.permissionDecision: "deny"で制御できます。exit code 2 は block、exit code 1 は多くの場合 non-blocking です。([Claude API Docs]3) ([Claude API Docs]3)#964 の本質は runtime enforcement なので、#1035 で「loop は再開可能」とコメントする場合でも、少なくともこの条件を parent blocker として残す必要があります。
Blocker 6: GitHub closing keyword /
Refsの扱いを混同してはいけない#819 は closing keyword 全 variant、
Refs #N、cross-repo reference を preserved token として保持する契約でした。 GitHub 公式でも issue を close する keyword はclose/closes/closed,fix/fixes/fixed,resolve/resolves/resolvedで、PR が default branch に merge される場合に効きます。Refs #Nは close しません。([GitHub Docs]4)#1035 が #964 再開コメントを出す場合、#964 の reference-block repair 論点を「単なる SyntaxError 再現問題」と一緒に解消扱いしてはいけません。これは別 blocker として残すべきです。
Blocker 7: #1013 / PR #1030 の phase gate 変更も関連リスク
#1013 は preflight 直後に
decide_next_loop_action.pyを誤って呼び、scope_signal_guardから prematurehuman_escalationに落ちる問題を直す Issue でした。 PR #1030 は merge 済みですが、レビューコメントではapproveverdict + max_iterations 近傍で誤ってhuman_escalationになる blocker が指摘されています。#1035 は
plan_refinement_loop.pyの SyntaxError だけでなく、「loop 再開を阻害する別の loop-control regression が残っていないか」も確認対象に入れるべきです。少なくとも AC4 の「loop 再開に必要な最小運用要件」には、#1013/#1030 の phase gate regression 状態を含めてください。推奨修正版 AC
結論
#1035 は「やるべき調査」ですが、現行契約では 証跡の同一性が弱く、#964 の本質的 blocker を誤って unblock する危険があります。
進めるなら、実装者への指示は次の方針が安全です。
この修正なしに #1035 を完了扱いにすると、「たまたま現在の main では py_compile が通る」だけで、実際の停止原因が別 worktree・古い生成物・壊れた stdout・phase gate regression だったケースを取り逃がします。
squne121 commentedon Jun 20, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedfix(#1035): レビュー Blocker 1〜6 を解消 — helper を実行経路に接続し sidecar を実生成