Skip to content

実装: issue-refinement-loop の controlled metadata mutation lane を root guard と整合させる #1383

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1047"
goal_ref: "issue-refinement-loop の root main guard / controlled GitHub metadata mutation / validator 実行経路を決定論的に整備し、手動 helper script や hook 回避の試行錯誤を不要にする"
change_kind: workflow

Parent Issue

#1047

Parent Goal Ref

  • Goal: impl-review-loop / post-merge-cleanup の周辺制御(preflight / hook / PR body / worktree)で発生するトークン浪費とノイズを根絶し、決定論的整備を行う。
  • Desired Destination: preflight / hook / PR body / worktree 周辺制御が deterministic script に集約され、agent が不要な往復なしで安全に作業できる。

Current Validated Scope

  • 実装: Playwright + Vitest Browser Mode 段階導入で #1370 battle-stage DOM overlay を VRT 保護 #1380 issue-refinement-loop 実行中に、root checkout 上の local_main_branch_guard が以下を拒否し、agent が手動 helper script を作って迂回した。
  • run_refinement_preflight.py が root main 上で issue_refinement_runtime_block として拒否された。
  • rtk run uv ...check_issue_contract.py と rtk run uv ...contract_readiness_check.py が rtk_unknown_inner として拒否され、bare uv run python3 ... へ手動で切り替えた。
  • rtk gh issue edit が github_mutation_denied として拒否され、controlled_skill_mutation_exec.py の issue_body.update / issue_comment.publish input JSON を手作業で生成した。
  • git worktree add / rtk git worktree add が root main guard に拒否され、linked issue worktree を作れないまま root 上で作業した。
  • 本 Issue では、上記の issue-refinement-loop / issue metadata mutation lane に限定して、command registry・guard allow・input builder・skill 手順を整備する。

Remaining Parent Gaps

Outcome

issue-refinement-loop が root main checkout から開始されても、preflight / draft validation / controlled issue body update / controlled issue comment publish が、登録済みの exact command と generated input JSON だけで完了できる。agent は python -c や一時 helper script を作成せず、guard の recovery hint に従うだけで #1380 と同種の comment-first refinement を再現できる。

In Scope

  • .claude/skills/issue-refinement-loop/scripts/command_registry.py に、preflight / draft body validation / readiness validation / controlled issue body update / controlled issue comment publish の canonical command spec を追加または更新する。
  • scripts/agent-guards/local_main_branch_guard.py と関連 test に、issue-refinement-loop の read-only validator 実行と controlled metadata mutation executor を exact command class として許可する narrow rule を追加する。
  • scripts/agent-guards/controlled_skill_mutation_exec.py または隣接 helper に、ISSUE_BODY_UPDATE_INPUT_V1 と ISSUE_COMMENT_PUBLISH_INPUT_V1 を live GitHub readback から生成する deterministic helper を追加する。
  • helper は previous_body_sha256 / previous_updated_at / new_body_sha256 / marker embedding を検証し、既存 executor の stale-write precondition と readback postcondition を維持する。
  • .claude/skills/issue-refinement-loop/SKILL.md または reference に、root main からの GitHub metadata mutation は controlled executor lane を使う手順を明記する。
  • 実装: Playwright + Vitest Browser Mode 段階導入で #1370 battle-stage DOM overlay を VRT 保護 #1380 の実観測を regression fixture として、hook block の false-positive 再発を pytest で検証する。

Out of Scope

  • local_main_branch_guard の root mutation 防止方針を緩めること。
  • bare gh issue edit / gh issue comment を許可すること。
  • --dangerously-skip-permissions / hook bypass / permission mode 変更。
  • post-merge-cleanup の worktree remove / branch delete 経路。
  • cleanup executor / cleanup contract V3 の再実装。
  • issue-refinement-loop の reviewer / author 判定ロジック変更。
  • GitHub issue template の大規模再設計。

Acceptance Criteria

  • AC1: issue-refinement-loop の command registry に、preflight / review checker / readiness checker / body update input build / comment publish input build / controlled executor dry-run / controlled executor publish の canonical command spec が存在する。
  • AC2: local_main_branch_guard が、root main checkout で uv run python3 .claude/skills/review-issue/scripts/check_issue_contract.py --file <draft> --json と uv run python3 .claude/skills/issue-contract-review/scripts/contract_readiness_check.py --mode preflight-static --body-file <draft> を read-only validator として許可する。
  • AC3: local_main_branch_guard が、controlled_skill_mutation_exec.py --command-id issue_body.update|issue_comment.publish ... --dry-run と本実行を、input namespace / repo / issue number が一致する場合のみ許可する。
  • AC4: ISSUE_BODY_UPDATE_INPUT_V1 を生成する helper が、live GitHub body / updatedAt を readback し、previous_body_sha256 / previous_updated_at / new_body_sha256 を executor schema と一致する JSON として artifacts/<issue>/issue-metadata/issue_body.update/input.json に出力する。
  • AC5: ISSUE_COMMENT_PUBLISH_INPUT_V1 を生成する helper が、comment body 内の marker embedding を検証し、artifacts/<issue>/issue-metadata/issue_comment.publish/input.json に出力する。
  • AC6: inline python -c / heredoc / one-off tmp/build_issue_*_input.py を使わず、helper と registry command だけで 実装: Playwright + Vitest Browser Mode 段階導入で #1370 battle-stage DOM overlay を VRT 保護 #1380 と同種の body update + handoff comment publish が実行できる。
  • AC7: run_refinement_preflight.py が root main で拒否される場合の recovery hint が、linked worktree 作成だけでなく controlled metadata mutation lane / validator lane の next command を示す。
  • AC8: .claude/skills/issue-refinement-loop/SKILL.md または reference が、root main guard 下での controlled issue metadata mutation flow を案内している。
  • AC9: pytest に 実装: Playwright + Vitest Browser Mode 段階導入で #1370 battle-stage DOM overlay を VRT 保護 #1380 regression fixture が追加され、rtk run uv ... のような unknown wrapper は引き続き拒否し、canonical uv run python3 ... と controlled executor lane だけを許可することを検証する。

Verification Commands

# AC1
$ rg -n "issue_body.update" .claude/skills/issue-refinement-loop/scripts/command_registry.py
# AC2
$ rg -n "check_issue_contract.py" scripts/agent-guards/local_main_branch_guard.py
# AC3
$ rg -n "controlled_skill_mutation_exec" scripts/agent-guards/local_main_branch_guard.py
# AC4
$ rg -n "ISSUE_BODY_UPDATE_INPUT_V1" scripts/agent-guards
# AC5
$ rg -n "ISSUE_COMMENT_PUBLISH_INPUT_V1" scripts/agent-guards
# AC6
$ rg -n "build_issue_metadata_input" scripts/agent-guards
# AC7
$ rg -n "validator lane" scripts/agent-guards/local_main_branch_guard.py
# AC8
$ rg -n "controlled executor" .claude/skills/issue-refinement-loop/SKILL.md
# AC9
$ uv run python3 -m pytest tests/codex/test_local_main_branch_guard.py .claude/hooks/tests/test_worktree_scope_guard.py

Allowed Paths

  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/references/**
  • .claude/skills/issue-refinement-loop/scripts/command_registry.py
  • .claude/skills/issue-refinement-loop/tests/**
  • scripts/agent-guards/local_main_branch_guard.py
  • scripts/agent-guards/controlled_skill_mutation_exec.py
  • scripts/agent-guards/controlled_skill_mutation_policy.py
  • scripts/agent-guards/**issue*metadata*.py
  • tests/codex/test_local_main_branch_guard.py
  • .claude/hooks/tests/test_worktree_scope_guard.py
  • artifacts/**

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • root main guard の mutation 防止方針を弱める必要が出た場合
  • bare gh issue edit / gh issue comment を許可しないと成立しない場合

Required Skills

  • Python
  • GitHub CLI
  • GitHub issue metadata mutation
  • pytest

Required Design References

  • docs/dev/workflow.md
  • docs/dev/agent-skill-boundaries.md
  • .claude/skills/issue-refinement-loop/SKILL.md
  • scripts/agent-guards/controlled_skill_mutation_policy.py
  • scripts/agent-guards/controlled_skill_mutation_exec.py

Runtime Verification Applicability

decision: not_applicable
reason: guard / skill / command registry / controlled executor input generation の静的・CLI contract 改善であり、pytest と rg による決定論的検証で完結する。ゲーム runtime や browser runtime の動作検証は不要。
if immediate: N/A
if deferred: N/A

Scope Delta(任意)

N/A

Delivery Rule

1 Issue = 1 PR。#1047 の child issue として扱い、root checkout へ直接 commit せず専用 worktree で実装する。PR では #1380 実行時の観測ログと、本 Issue の pytest regression 結果を evidence として添付する。

Activity

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

    @squne121
    OwnerAuthor

    scope 統合: #1395 に統合

    #1395 の impl-review-loop 着手時に Allowed Paths overlap が検出されたため、人間判断により scope 統合します。

    この Issue は #1395 に supersede されるため close します。

  3. squne121 commented on Jul 8, 2026

    @squne121
    OwnerAuthor

    #1395 に scope 統合されたため close します。統合メモ: #1383 (comment)

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