Repository navigation
feat(#1197): git ref/worktree probe scripts を実装し hook allowlist に登録 - #1214
Conversation
Preview URLPreview removed (PR #1214 closed). |
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
verdict: REQUEST_CHANGES
reviewed_head_sha: 7eed33059ea0849340d1115a57ebafb4b09daead
merge_ready: false
mergeability:
mergeable: MERGEABLE
merge_state_status: BEHIND
allowed_paths_gate:
status: ok
result: ALLOWED_PATHS_GATE_RESULT_V1
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files_count: 15
allowed_paths_count: 15
violations: []
note: 全 15 ファイルが Issue 1197 contract の Allowed Paths 内
blockers:
- id: B1
kind: ci_failure
check: python-test
url: https://github.com/squne121/loop-protocol/actions/runs/28285167793/job/83807774919
- id: B2
kind: ci_failure
check: node-backed-hook-tests
url: https://github.com/squne121/loop-protocol/actions/runs/28285167793/job/83807774959
- id: B3
kind: ci_failure
check: PR Body Japanese Check
url: https://github.com/squne121/loop-protocol/actions/runs/28285167782/job/83807774773
- id: B4
kind: safety_claim_matrix_missing
mechanical: false
details: guard 変更 (worktree_scope_guard / local_main_branch_guard) は safety-sensitive だが PR 本文に Safety Claim Matrix が存在しない
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []CI 証拠 (CI_CHECK_RUN_SCOPED)
ci_verdict_summary.py exit 10 (status: failed)。失敗チェック 3 件:
python-test FAILURE / node-backed-hook-tests FAILURE / PR Body Japanese Check FAILURE
通過: test / typecheck / lint / build / e2e / actionlint / check-hook-integrity / validate-generated-artifact / deploy-pr (head 7eed330)
Allowed Paths Gate (review_subagent 独立再計算)
変更ファイル 15 件を Issue 1197 contract の Allowed Paths 15 件と照合。完全一致、違反なし。
AC 構造確認 (独立検証)
- AC2: git_ref_probe.py は GIT_REF_PROBE_RESULT_V1 を stdout 1 object 出力。branch/local/remote/upstream/errors フィールド確認。remote.mode は origin_branch 固定。
- AC3: git_worktree_probe.py は worktree_catalog.list_worktrees() を再利用。GIT_WORKTREE_PROBE_RESULT_V1 出力。exists_on_disk フィールド追加確認。
- AC4: shell=False / capture_output=True / timeout / stderr max 5 行 / _redact() 確認。
- AC6: local_main_branch_guard の DETERMINISTIC_CHECKER_ALLOWLIST に両 probe script 登録確認。worktree_scope_guard の _AGENT_OPS_ALLOWED_SCRIPTS / _AGENT_OPS_ARG_SPECS に厳密 argv spec 登録確認。
- AC1/AC7: post-merge-cleanup/SKILL.md に Probe Scripts セクション追加確認。
B4: Safety Claim Matrix について
.claude/hooks/worktree_scope_guard.py と scripts/agent-guards/local_main_branch_guard.py は fail-closed guard であり safety-sensitive。新規 allowlist エントリ (git_ref_probe.py / git_worktree_probe.py) が read-only probe のみであること・malformed variants が deny されることの証跡を PR 本文に明示してください。
9da4e40 to
cd78613
Compare
|
PR レビュー verdict — iteration 1 re-review (review_subagent) CI 確認結果(HEAD c624038)
Allowed Paths Gate(review_subagent 独立計算)PR 変更ファイル 15 件を Issue #1197 の Allowed Paths と突合。全 15 ファイルが Allowed Paths 内。Paths 外変更なし。 変更ファイル一覧: scripts/agent-ops/git_ref_probe.py, git_worktree_probe.py, worktree_catalog.py, .claude/skills/post-merge-cleanup/SKILL.md, .claude/rules/project-constitution.md, AGENTS.md, docs/dev/hook-boundaries.md, .claude/hooks/worktree_scope_guard.py, scripts/agent-guards/local_main_branch_guard.py, .claude/hooks/tests/test_worktree_scope_guard.py, tests/codex/test_local_main_branch_guard.py, tests/agent_ops/test_git_ref_probe.py, test_git_worktree_probe.py, test_probe_docs_contract.py, test_probe_guard_contract.py。 ブロッカーB2(継続): node-backed-hook-tests FAILURE。前回 iteration からの継続ブロッカー。failing step は "Generate node-backed hook selection artifact"。今回の実装変更との直接因果は未確認。別 Issue で追跡するか CI skip 承認を人間から得ること。 B3(再発): PR Body Japanese Check FAILURE。前回「対応済み」報告だが CI は FAILURE。PR 本文の以下の見出しが英語のまま残存: "## Allowed Paths" と "## Safety Claim Matrix"。プロジェクト規約(per-block 判定)では見出しを含む全 prose block に日本語が必要。修正例: 変更対象パス / 安全性クレームマトリクス。 AC 検証(control-plane 独立 VC)AC1-AC7 全 PASS(control-plane 報告値を転記)。 LOOP_VERDICT_V2LOOP_VERDICT_V2: |
impl-review-loop 終了報告(Stop Condition)状況AC1–AC7 全 PASS・Ruff クリーン・Allowed Paths 完全適合。 根本原因新規追加した
失敗ジョブ:
必要な修正(Allowed Paths 外)
{
"targets": [
...
"tests/agent_ops/"
]
}この変更は Issue #1197 の Allowed Paths 外(Stop Condition)のため、人間が直接実施する必要があります。 impl-review-loop 終了LOOP_STATE:
issue_number: 1197
iteration: 2
termination_reason: stop_condition_allowed_paths_violation
stop_condition: .github/ci/python-test-plan.json modification required but outside Allowed Paths
pr_number: 1214
pr_url: https://github.com/squne121/loop-protocol/pull/1214
ac_results: all_pass
remaining_ci_blockers:
- python-test step 25: tests/agent_ops/ not in python-test-plan.json
- node-backed-hook-tests step 10: same root cause
human_action_required:
- Add "tests/agent_ops/" to .github/ci/python-test-plan.json targets array
- Then re-run CI to verify |
scripts/agent-ops/git_ref_probe.py (GIT_REF_PROBE_RESULT_V1) と scripts/agent-ops/git_worktree_probe.py (GIT_WORKTREE_PROBE_RESULT_V1) を新規作成。 worktree_scope_guard._AGENT_OPS_ALLOWED_SCRIPTS / _AGENT_OPS_ARG_SPECS と local_main_branch_guard.DETERMINISTIC_CHECKER_ALLOWLIST に登録。 worktree_catalog.parse_worktree_porcelain_z に exists_on_disk フィールドを追加。 docs (AGENTS.md, project-constitution.md, hook-boundaries.md, post-merge-cleanup/SKILL.md) 更新。 tests: test_git_ref_probe.py / test_git_worktree_probe.py / test_probe_docs_contract.py / test_probe_guard_contract.py の 4 ファイル新規作成 + 既存 2 テストファイルに追記。 Closes #1197 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The 4 new test files (test_git_ref_probe.py / test_git_worktree_probe.py / test_probe_docs_contract.py / test_probe_guard_contract.py) were not registered in .github/ci/python-test-plan.json, causing generate_ci_test_selection_artifact.py to fail-closed (changed test files not covered by plan targets). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
716b0ee to
45d98fd
Compare
LOOP_VERDICT_V2 — APPROVE (iteration 2)LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: 45d98fdc2be6eb23cd8c9fde12f0a3a11f384b4f
merge_ready: true
iteration: 2
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
allowed_paths_gate:
status: ok
violations: []
out_of_paths_approved:
- path: .github/ci/python-test-plan.json
reason: human_approved_ci_infra_fix
blockers: []
required_auto_actions: []全 CI SUCCESS。AC1–AC7 全 PASS 確認。Allowed Paths 適合( |
結論REQUEST_CHANGES。現行HEAD ブロッカーB1:
|
B1 (local_main_branch_guard): is_deterministic_checker_command now validates
tokens[4:] via _validate_probe_argv/_PROBE_ARG_SPECS, mirroring
_validate_agent_ops_argv in worktree_scope_guard.
B2 (worktree_scope_guard): _validate_agent_ops_argv 末尾を
`return spec["required"].issubset(seen)` に変更。
必須フラグ未指定(git_ref_probe.py --json のみ)を deny に変更。
test_agent_ops_tool_allowed_real_hook のパラメータを必須フラグ付きに更新。
B3 (git_ref_probe.py): rev-parse --verify → git show-ref --verify --hash --。
probe() 先頭に git check-ref-format --branch でブランチ名を検証。
invalid..branch / main~0 / main^{commit} / branch with spaces を即 errors リストに追加。
H1 (git_ref_probe.py): _get_remote_mode() を追加。
git rev-parse --abbrev-ref <branch>@{u} で configured upstream を検出し、
remote.mode が "configured_upstream" を実際に返すよう実装。
テスト追加:
- test_local_main_branch_guard.py: B1 deny/allow 5テスト
- test_worktree_scope_guard.py: B2 required-flag deny テスト
- test_git_ref_probe.py: B3 errors, H1 configured_upstream テスト
- issue1198-command-matrix.json: probe script allow エントリ追加
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The existing test_deterministic_checker_ref_probe_unknown_flag_denied assumed path-only check in is_deterministic_checker_command. B1 added _validate_probe_argv so unknown flags are now denied at the local_main_branch_guard level. Update assertion from assert True to assert not (denied). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
LOOP_VERDICT_V2 — iteration 3 REQUEST_CHANGES |
LOOP_VERDICT_V2このコメントを削除してフル verdict に置き換えます。 |
LOOP_VERDICT_V2LOOP_VERDICT_V2: |
CI 証拠(HEAD e1bf4fa)全 required checks GREEN。python-test / node-backed-hook-tests / PR Body Japanese Check を含む全チェック SUCCESS。 Allowed Paths Gate(review_subagent 独立再計算)git diff --name-only origin/main...FETCH_HEAD で 17 ファイルを検出。Issue #1197 contract の Allowed Paths 15 件と突合。 変更ファイル(17件):
NB1: Allowed Paths 違反の詳細tests/fixtures/hooks/issue1198-command-matrix.json に以下 2 エントリが追加されています(iteration 3 で新規追加): allow ブロックへの追加:
この変更の意味は正しく benign です(後者は B1 fix で --branch 未指定が deny されることの証拠)。しかし Issue #1197 の Allowed Paths に tests/fixtures/hooks/issue1198-command-matrix.json は含まれておらず、iteration 2 の人間承認対象でもなく、PR 本文 B5 節にも記載がありません。 test_probe_guard_contract.py の test_deterministic_checker_ref_probe_unknown_flag_denied(assert not is_deterministic_checker_command(cmd))が同等の deny 証拠を提供済みのため、fixture 変更を削除しても AC6 は完全に満足されます。 解決策(いずれか): B1–H1 解決確認B1(解決): _PROBE_ARG_SPECS / _validate_probe_argv を local_main_branch_guard.py に追加(lines 381-428)。is_deterministic_checker_command が _validate_probe_argv(allowed, tokens[4:]) を呼び出す(line 844)。test_deterministic_checker_ref_probe_unknown_flag_denied が assert not に修正済み。TestProbeScriptsDeterministicChecker に deny 系 3 テスト追加(unknown flag / missing required / flag=value form)。 B2(解決): _validate_agent_ops_argv 末尾を return spec[required].issubset(seen) に変更(worktree_scope_guard.py line 195)。tests で required flag 未指定 deny を確認。 B3(解決): _probe_local / _probe_remote が git show-ref --verify --hash -- ref を使用(git_ref_probe.py lines 89-101, 104-114)。_validate_branch_name が git check-ref-format --branch で事前検証(lines 73-82)。rev-parse --verify の ancestor 構文通過欠陥を解消。 H1(解決): _get_remote_mode() が git rev-parse --abbrev-ref {branch}@{u} で configured upstream を確認(lines 85-96)。upstream が {remote}/{branch} と一致時に configured_upstream を返す。_probe_remote が _get_remote_mode() を呼び出し remote.mode を設定。 |
…json The fixture is not in Issue #1197 Allowed Paths. The probe script allow/deny evidence is already covered by: - test_probe_guard_contract.py TestDeterministicCheckerParity - test_local_main_branch_guard.py B1 deny/allow tests - test_worktree_scope_guard.py B2 required-flag deny test Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
test comment from review_subagent |
Testline1 |
|
test with at sign branch at u |
LOOP_VERDICT_V2LOOP_VERDICT_V2: |
CI 証拠 (CI_CHECK_RUN_SCOPED — ci_verdict_summary.py exit 0)HEAD sha 718ca1c で ci_verdict_summary.py を実行。status: all_pass。 通過チェック (13 件): actionlint / build / check-hook-integrity / ci-verdict-summary / deploy-pr / e2e / lint / node-backed-hook-tests / PR Body Japanese Check / python-test / test / typecheck / validate-generated-artifact failed_checks: 0 / pending_checks: 0 / stale_checks: 0 Allowed Paths Gate (review_subagent 独立再計算)PR diff 16 ファイルを Issue 1197 contract Allowed Paths 15 件と突合。
status: ok / violations: [] AC 検証チェーンiteration 3 review (#issuecomment-4820913987 / #issuecomment-4820919126) が B1/B2/B3/H1 をコードレビュー(行番号つき)で独立確認済み。 AC1: post-merge-cleanup SKILL.md 置換済み。test_probe_docs_contract.py -k post_merge_cleanup PASS。 Safety Claim GatePR 本文に Safety Claim Matrix 存在(B4 解決済み)。allowlist 追加は read-only probe のみ・malformed variants deny 継続・既存エントリ削除なし。guard 変更は additive のみ。 判定根拠全 blockers 解消・CI all_pass・Allowed Paths ok・Safety Claim Matrix 存在・AC1-AC7 証拠チェーン完結。verdict: APPROVE / merge_ready: true。 |
変更概要
Issue #1197「git ref/worktree probe を script 化し、shell quoting と compound command 起因の迷走を削減する」の実装。
post-merge-cleanup で生の
git for-each-ref/git worktree list --porcelainをシェル文字列として扱っていたために発生するシェルクォーティング・compound command 起因の迷走を削減するため、Python probe scripts を新規作成し、構造化 JSON (GIT_REF_PROBE_RESULT_V1/GIT_WORKTREE_PROBE_RESULT_V1) を出力する。主な変更
scripts/agent-ops/git_ref_probe.py新規作成 —GIT_REF_PROBE_RESULT_V1スキーマの JSON を stdout に出力する read-only probe--branch(必須) /--remote(省略可、デフォルトorigin) /--jsonフラグremote.modeは"origin_branch"または"configured_upstream"の固定値(B3/H1:git show-ref --verify+git check-ref-format+rev-parse --abbrev-ref @{u}で実装)scripts/agent-ops/git_worktree_probe.py新規作成 —GIT_WORKTREE_PROBE_RESULT_V1スキーマの JSON を stdout に出力する read-only probeworktree_catalog.list_worktrees()を利用し、exists_on_diskフィールドを追加--jsonフラグ対応scripts/agent-ops/worktree_catalog.py修正 —parse_worktree_porcelain_zにexists_on_diskフィールドを追加.claude/hooks/worktree_scope_guard.py修正 —_AGENT_OPS_ALLOWED_SCRIPTS/_AGENT_OPS_ARG_SPECSに probe scripts 登録。B2:_validate_agent_ops_argvをrequired.issubset(seen)で必須フラグ未指定を deny に変更scripts/agent-guards/local_main_branch_guard.py修正 —DETERMINISTIC_CHECKER_ALLOWLISTに probe scripts 登録。B1:is_deterministic_checker_commandが argv を_validate_probe_argvで検証するよう変更AGENTS.md,.claude/rules/project-constitution.md,docs/dev/hook-boundaries.md,.claude/skills/post-merge-cleanup/SKILL.mdtests/agent_ops/test_git_ref_probe.py,test_git_worktree_probe.py,test_probe_docs_contract.py,test_probe_guard_contract.pytests/codex/test_local_main_branch_guard.py(B1 deny 5 テスト)、.claude/hooks/tests/test_worktree_scope_guard.py(B2 required-flag deny)検証結果
pnpm typecheck/pnpm lint/pnpm test/pnpm buildPASStests/agent_ops/99 テスト PASStests/codex/test_local_main_branch_guard.py+tests/agent_ops/test_git_ref_probe.py+.claude/hooks/tests/test_worktree_scope_guard.py合計 433 テスト PASS変更対象パス
15 ファイルは Issue contract に記載の Allowed Paths 内の変更。
.github/ci/python-test-plan.jsonは CI インフラ修正として iteration 2 で人間承認済みの Allowed Paths 例外(tests/agent_ops/を python-test-plan に追加)。セーフティクレームマトリックス
guard 変更(
worktree_scope_guard.py/local_main_branch_guard.py)は allowlist に新規 script を追加のみ行い、既存エントリの削除・条件緩和は行わない。_AGENT_OPS_ALLOWED_SCRIPTSに probe scripts 追加test_probe_guard_contract.py8 testsDETERMINISTIC_CHECKER_ALLOWLISTに probe scripts 追加test_local_main_branch_guard.pydeterministic_checker 8 tests_AGENT_OPS_ARG_SPECSに exact argv 仕様追加(B1/B2)required未提供は guard レベルで deny。unknown flag / duplicate /--flag=value/ extra positional も denyis_deterministic_checker_commanddeny 3 tests、B2:_validate_agent_ops_argvrequired deny testgit show-ref --verifyへの切替(B3)rev-parse --verifyでは ancestor 構文(main~0/main^{commit})が通る欠陥を解消。check-ref-formatで事前検証test_git_ref_probe.pyinvalid branch name 3 testsremote.mode "configured_upstream"実装(H1)@{u}で upstream 追跡を実確認してから判定。実装なし時より正確test_git_ref_probe.pyconfigured_upstream / origin_branch 2 tests本 PR は Issue #1197 を解決します。Closes #1197