Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Description
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: workflowParent Issue
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として拒否され、bareuv run python3 ...へ手動で切り替えた。rtk gh issue editがgithub_mutation_deniedとして拒否され、controlled_skill_mutation_exec.pyのissue_body.update/issue_comment.publishinput 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
- post-merge-cleanup 専用の root checkout block は 改善: post-merge-cleanup-worker が root checkout で local_main_branch_guard にブロックされ機能しない #1147 が扱う。
- cleanup executor / cleanup contract delivery の広域 guard arbitration は 実装: guard arbitration preflight と cleanup contract delivery を機械化する (agent-ops) #1137 が既に closed しており、本 Issue では再実装しない。
- impl-review-loop 全体の capsule-first / context budget / PR review routing は既存 child issue 群の責務とし、本 Issue では扱わない。
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-offtmp/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 は引き続き拒否し、canonicaluv 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.pyAllowed 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.pyscripts/agent-guards/controlled_skill_mutation_exec.pyscripts/agent-guards/controlled_skill_mutation_policy.pyscripts/agent-guards/**issue*metadata*.pytests/codex/test_local_main_branch_guard.py.claude/hooks/tests/test_worktree_scope_guard.pyartifacts/**
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.mddocs/dev/agent-skill-boundaries.md.claude/skills/issue-refinement-loop/SKILL.mdscripts/agent-guards/controlled_skill_mutation_policy.pyscripts/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 として添付する。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Activity
squne121 commentedon Jul 8, 2026
scope 統合: #1395 に統合
#1395 の impl-review-loop 着手時に Allowed Paths overlap が検出されたため、人間判断により scope 統合します。
preflight.runexecutor allow / direct runtime deny / raw mutation deny / hook parity の範囲に集約CONTRACT_REVIEW_RESULT_V1 status: goを取得済み: 実装: issue-refinement-loop canonical runtime の hook allowlist を整備する #1395 (comment)この Issue は #1395 に supersede されるため close します。
squne121 commentedon Jul 8, 2026
#1395 に scope 統合されたため close します。統合メモ: #1383 (comment)