Skip to content

実装: issue-refinement-loop Step 0f を parent-owned preflight 運用で明文化し isolation agent の exact executor 実行を契約テストで禁止する #1478

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "1464"
goal_ref: "issue-refinement-loop の Step 0f を parent-owned preflight 方針で明文化し、isolation worktree agent が preflight.run の exact executor / direct wrapper を自ら実行しないことを契約として固定する"
change_kind: docs_and_test

Parent Issue

#1464

Parent Goal Ref

  • Goal: .claude/hooks/worktree_scope_guard.py の issue worktree 判定パターン不一致ではなく、scripts/agent-guards/skill_runtime_command_policy.py が preflight.run に要求する required_cwd: canonical_main_root / required_branch: default_branch invariant と、Agent tool の isolation: "worktree" で生成される汎用 worktree の cwd との衝突が root cause であると確定し、対応方針 (d) parent-owned preflight を採用した。
  • Desired Destination: .claude/skills/issue-refinement-loop/SKILL.md の Step 0f に、isolation worktree agent への委譲時は parent orchestrator が canonical main root / default branch で preflight.run を実行し、bounded な結果のみを isolation agent へ渡す運用を明文化する。

Current Validated Scope

  • .claude/skills/issue-refinement-loop/SKILL.md Step 0f への「parent-owned preflight」セクション追加
  • 既存 Step 0f 直接実行 bash block(run_refinement_preflight.py)の適用範囲注記(isolation worktree agent からは行わない旨)
  • 上記文言の存在を検証する新規契約テストの追加

Remaining Parent Gaps

Outcome

.claude/skills/issue-refinement-loop/SKILL.md の Step 0f に、isolation worktree agent への委譲時は parent(orchestrator 自身、canonical main root・default branch で稼働)が preflight.run を実行し、bounded な結果(NEXT_ACTION / MUST_READ / ARTIFACT 等の canonical stdout フィールド)のみを isolation agent へ渡す「parent-owned preflight」運用を明記し、isolation agent が exact executor(skill_runtime_exec.py)・direct wrapper(run_refinement_preflight.py)のいずれも自ら実行しないこと、および agent-* 等の未保証な isolation worktree 命名パターンを認可根拠として追加しないことを契約として固定する。既存の Step 0f 直接実行 bash block は、orchestrator 自身が canonical main root もしくは canonically-named issue worktree から直接実行する場合に限定されることを注記する。

In Scope

  • .claude/skills/issue-refinement-loop/SKILL.md Step 0f への「parent-owned preflight」セクション追加
  • 既存 Step 0f 直接実行 bash block(run_refinement_preflight.py)の適用範囲注記(isolation worktree agent からは行わない旨)
  • 上記文言の存在を検証する新規契約テストの追加

Out of Scope

  • .claude/hooks/worktree_scope_guard.py 本体の実装変更(issue worktree 判定 regex 拡張を含む)
  • scripts/agent-guards/skill_runtime_command_policy.py の required_cwd / required_branch invariant 緩和
  • Agent tool(isolation worktree 起動基盤)自体の変更
  • isolation agent からの exact executor / direct wrapper 実行を許可する変更
  • agent-* 等の generic worktree 命名パターンを認可根拠として guard 側に追加する変更
  • .claude/skills/issue-refinement-loop/SKILL.md 以外のスキル手順ファイルの変更

Acceptance Criteria

  • AC1: .claude/skills/issue-refinement-loop/SKILL.md の Step 0f に「parent-owned preflight」という文字列を含む新セクションが追加され、isolation worktree agent への委譲時に parent が preflight.run を実行してから bounded な結果のみを isolation agent へ渡す運用が明記されている
  • AC2: 同セクションに、isolation agent が skill_runtime_exec.py(exact executor)も run_refinement_preflight.py(direct wrapper)も自ら実行しないことが明記されている
  • AC3: 同セクションに、agent-* 等の未保証な isolation worktree 命名パターンを preflight.run の認可根拠として追加しないことが明記されている
  • AC4: 既存の Step 0f 直接実行 bash block(run_refinement_preflight.py を直接呼ぶ例)が、orchestrator 自身が canonical main root もしくは canonically-named issue worktree から直接実行する場合に限定されることを示す注記が追加されている
  • AC5: 新規契約テスト .claude/skills/issue-refinement-loop/tests/test_step_0f_parent_owned_preflight.py が追加され、AC1〜AC4 で要求される文言の存在を検証し、pass する
  • AC6: 既存の scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py が本Issueの変更後も regression なく green のままである(direct wrapper 拒否・generic worktree 拒否の既存契約を変更しない)

Verification Commands

# AC1
$ rg -n "parent-owned preflight" .claude/skills/issue-refinement-loop/SKILL.md
# AC2
$ rg -n -e "isolation agent は.*skill_runtime_exec\.py.*自ら実行しない" -e "isolation agent は.*run_refinement_preflight\.py.*自ら実行しない" .claude/skills/issue-refinement-loop/SKILL.md
# AC3
$ rg -n "認可根拠として追加しない" .claude/skills/issue-refinement-loop/SKILL.md
# AC4
$ rg -n "isolation worktree agent からは.*実行しない" .claude/skills/issue-refinement-loop/SKILL.md
# AC5
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_step_0f_parent_owned_preflight.py -q
# AC6
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -q

Allowed Paths

  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/tests/test_step_0f_parent_owned_preflight.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • Outcome / Scope / AC が検索可能な形で記載されていない場合は即停止
  • 権限不足(permission denied)により操作が完了できない場合は即停止

Required Skills

なし

Required Design References

  • .claude/skills/issue-refinement-loop/SKILL.md — Step 0f(### Step 0f: Planner 結果の消費)が本 Issue の変更対象そのものであり、Step 0f に追加される新セクションの記述先
  • docs/dev/agent-skill-boundaries.md — オーケストレータ(control-plane)と isolation worktree agent の責務分離設計原則の参照先
  • .claude/skills/issue-refinement-loop/tests/test_skill_md_wiring.py — SKILL.md 内の文言・参照存在を検証する既存契約テストパターンの参考(AC5 の新規テスト作成時の実装参考)

Runtime Verification Applicability

  • decision: not_applicable
  • 本Issueは SKILL.md のプロース変更と純粋な文字列存在検証テストの追加のみであり、.claude/hooks/* や scripts/agent-guards/* のガードコード自体は変更しない。既存ガード契約への regression は AC6 の pytest 実行で検証する。

Handoff Contract

Delivery Rule

  • 1 Issue = 1 PR。PR は本Issueを Closes し、Refs #1464 を含める。

Activity

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

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-12T01:00:57Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1478
      body_sha256: "sha256:712b4b37446064d3af6eddcfff323adef2fa37f5a64cf979b3967d71360b10d3"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"rg -n \"parent-owned preflight\" .claude/skills/issue-refinement-loop/SKILL.md","command_hash":"sha256:2a6dcc62873a8d2d2f0e76387a3a0132b1fad2e46bc9a09324191fe3fc0bfb10","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":3,"fix_hint":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":"rg -n -e \"isolation agent は.*skill_runtime_exec\\.py.*自ら実行しない\" -e \"isolation agent は.*run_refinement_preflight\\.py.*自ら実行しない\" .claude/skills/issue-refinement-loop/SKILL.md","command_hash":"sha256:bbb3590c3815ef2ba5dadd05a090c830c128f5505eb87b2454382329dedab10d","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":4,"fix_hint":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":"rg -n \"認可根拠として追加しない\" .claude/skills/issue-refinement-loop/SKILL.md","command_hash":"sha256:e3c68286ebc8924ea28bfc6b8505de63ca1fa9d8179a9b4ffe27accb0d911bd6","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":1,"fix_hint":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":"rg -n \"isolation worktree agent からは.*実行しない\" .claude/skills/issue-refinement-loop/SKILL.md","command_hash":"sha256:e4e7b1d6a4e40b679280db2e2fde2632d4b0a52eb98f3c070f90b9773eadacdf","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":2,"fix_hint":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC5","line":2,"raw_command":"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_step_0f_parent_owned_preflight.py -q","command_hash":"sha256:06a42f2704269138619a15dcbdd830f6a377c898f9e2fa1858cadd420311f6ef","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.00s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/issue-refinement-loop/tests/test_step_0f_parent_owned_preflight.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":158,"fix_hint":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC6","line":2,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -q","command_hash":"sha256:3fb31b559a5114a0a5f3e44b634a38c983df1a58bd9771c946a8000f34ed6634","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["....................                                                     [100%]","20 passed in 1.73s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":1874,"fix_hint":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null}]
      source: ensure_contract_snapshot_auto
  3. squne121 commented on Jul 12, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了・PR 起票は overlap-preflight hard gate によりブロック

    • Worktree: .claude/worktrees/issue-1478-parent-owned-preflight
    • Branch: worktree-issue-1478-parent-owned-preflight(push 済み、commit 6bacfa46)
    • Verification:
      • AC1〜AC4(rg パターン一致): 全て確認済み
      • AC5: uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_step_0f_parent_owned_preflight.py -q → 7 passed
      • AC6: uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -q → 20 passed(regression なし)
      • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -q → 1265 passed(既存 wiring テスト含め regression なし)
    • Allowed Paths 準拠: .claude/skills/issue-refinement-loop/SKILL.md(既存変更)と .claude/skills/issue-refinement-loop/tests/test_step_0f_parent_owned_preflight.py(新規)の 2 ファイルのみ変更。

    PR 起票がブロックされている理由(human judgment 待ち)

    open-pr skill の overlap-preflight hard gate(check_implementation_overlap.py、Issue #1458)が route: human_review_required を返すため、gh pr create を呼ばず fail-closed で停止している。

    current_issue.number: 1478 に対する candidates は空配列([])であり、#1478 の Allowed Paths と実際に衝突する OPEN implementation Issue は存在しない。ブロックの原因は、phase/implementation ラベルを持つ他の OPEN Issue(#481 / #666 / #667 / #901)が ## Allowed Paths セクションを持たず、overlap classifier の「候補が一件でも読み取り不完全なら fail-closed(human_review_required)」ルールに抵触しているためである。これは #1478 固有の問題ではなく、この 4 件が未整備のまま残る限り phase/implementation ラベル付きの Issue 全般の PR 起票に影響しうる systemic な preflight fragility と考えられる。

    implement-issue / open-pr の両 skill とも gh pr create を直接呼ぶことを禁止しているため、この fail-closed gate をバイパスせずに停止した。

    Evidence

    route: human_review_required
    current_issue.candidates: []
    validation_errors:
      "481": ["missing_allowed_paths"]
      "666": ["missing_allowed_paths"]
      "667": ["missing_allowed_paths"]
      "901": ["missing_allowed_paths"]
    evidence_sha256: sha256:e8acee3352a0b8d4070c9f8025009b51e9b464c5ccf52f30cca3a69f1eb4fecc
    decision_inputs_sha256: sha256:3e24d5362654cee7b1ff1fe368f3031495aabd0590d938a20c82585b2ba5bc38
    

    人間判断が必要な選択肢

    1. #481 / #666 / #667 / #901 に ## Allowed Paths セクションを追加する(または phase/implementation ラベルを外す)。
    2. 上記解消後に check_implementation_overlap.py を再実行し route: proceed(または proceed_with_collision_evidence)に変わったことを確認してから、open-pr skill 経由で PR を起票する。
    3. または人間が直接 gh pr create(Closes #1478 / Refs #1464)で起票する。

    準備済みの PR タイトル・本文は .claude/worktrees/issue-1478-parent-owned-preflight/tmp_pr_body.md にある。

  4. squne121 commented on Jul 12, 2026

    @squne121
    OwnerAuthor

    PR 起票完了(overlap-preflight gate の false positive を手動で切り分け)

    PR: #1481 (Draft、Closes #1478 / Refs #1464)

    経緯

    open-pr skill の overlap-preflight hard gate は、#1478 自体には実際の衝突候補が存在しない(candidates: [])にもかかわらず、他の phase/implementation ラベル付き OPEN Issue が ## Allowed Paths セクションを欠いているために route: human_review_required を返し続けていた。

    判断

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/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions