Repository navigation
feat: preflight.run.with_anchor sibling exact profile を追加する - #1500
Conversation
anchor comment を指定した issue-refinement-loop preflight 実行が、正規の privileged executor 経路(skill_runtime_exec.py)と root checkout の PreToolUse hook(worktree_scope_guard.py / local_main_branch_guard.py)を 通じて fail-closed に検証されながら実行できるようにする。 preflight.run 本体の argv / placeholders / execution_class / timeout は 一切変更していない。新設した github_issue_comment_url placeholder type と parse_exact_skill_runtime_anchor_command() の12トークン厳密一致により、 URL の canonical shape・context-binding(owner/repo/issue番号の一致)・ duplicate flag・flag順序・shell metacharacter を fail-closed で拒否する。 副次的に、既存の10トークン parser(parse_exact_skill_runtime_command)が eligible_command_ids のメンバーシップのみで command_id を判定しており、 preflight.run.with_anchor / preflight.run.fixture の command-id を騙った 不完全な10トークンコマンドを誤って通過させる latent gap を発見したため、 execution_class の一致も要求するように締めた(preflight.run 自体の挙動は 不変)。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1500 closed). |
pr-review-judge REQUEST_CHANGES対応。未使用import(is_exact_skill_runtime_executor_command, pytest)を削除し、 不要なf-stringプレフィックスを除去。テストロジック・カバレッジは無変更。
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2 (pr-review-judge)
verdict: REQUEST_CHANGES
reviewed_head_sha: 753b609
merge_ready: false
Blockers
- CI required check 'python-test' FAILURE (ruff check): scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py:28 (F401 unused import
is_exact_skill_runtime_executor_command), :253 (F541 f-string without placeholder), scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py:19 (F401 unused importpytest) - CI required check 'PR Body Japanese Check' FAILURE: per-block Japanese ratio判定でfailed_blocks=2(block[1] jp=0/total=20, block[2] jp=0/total=24)
- PR本文の検証コマンド結果にruff checkの実行結果が記載されておらず自己申告と実CI結果が不整合
Allowed Paths Gate
status: ok(全15変更ファイルがAllowed Paths内)
Follow-up
Issue #1498 のAC5/AC6 Verification Commands記載ファイル名がAllowed Pathsと矛盾するcontract drift(別途Issue側で是正、merge非blocking)
PR #1500 の PR Body Japanese Check (Check changed Markdown files) が issue-refinement-loop/SKILL.md 内の policy-example マーカーコメント (全て英語)で失敗していたため、日本語説明を併記して修正する。
前コミットで policy-example コメント内に日本語テキストを挿入したため、 governed Python invocation policy checker の exact regex match が崩れ python-test が回帰した。マーカー本体は元の exact 文字列に戻し、 別の HTML コメントとして日本語説明を並記することで両チェックを両立する。
squne121
left a comment
There was a problem hiding this comment.
test-body-please-ignore-scratch
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
(前のコメント "test-body-please-ignore-scratch" は投稿手順確認中の誤操作です。無視してください。本コメントが正式なverdictです。)
verdict: REQUEST_CHANGES
reviewed_head_sha: "88d8e151396496407576d23d8e052476501b5a39"
merge_ready: false
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
前回3blockerの解消確認(実ファイル・実CI証跡での再検証)
- ruff F401/F541: 解消。テストファイルから未使用importと未使用placeholderのf-stringを削除済みであることをworktree実ファイルで確認。CI python-test/lint = SUCCESS(head一致)。
- PR Body Japanese Check: 現head SUCCESS。SKILL.mdのpolicy-exampleコメント行に日本語説明併記を確認。
- 検証コマンド結果とCIの不整合: CI全green化により解消。
新規に検出したblocker(前回レビューが見落とし)
- Safety Claim Matrix セクション欠落(mechanical: false)。本PRは.claude/skills配下、.claude/hooks配下の許可判定ロジック、.claude/settings.jsonのpermission entry追加、権限判定スクリプト等のpermission/hook境界を変更しておりsafety-sensitive判定に該当するが、PR本文にSafety Claim Matrix(Claim/Implemented/Not controlled/Evidence/Follow-up)セクションが存在しない。類似のhook/permission変更PR(例: #1489)では本セクションが必須運用されている。
- 受け入れ条件の達成状況セクション欠落(mechanical: true, update_pr_body_hygiene対象)。Issue #1498のAC1からAC11に対するチェック印プラス根拠形式のAC coverage checklistがPR本文に存在しない。Positive/Negative Test Matrixカバレッジ表はMatrix項目1-24のマッピングでありIssue AC1-AC11との対応checklistの代替にならない。
Allowed Paths Gate(review_subagent 再計算)
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files_source: manual_diff_against_issue_1498_allowed_paths(fingerprint-bound判定scriptはcontract fingerprint入力取得が本セッションのAPI制約で完了できず未実行。フォールバックとして変更ファイル15件をIssue #1498のAllowed Paths列挙と手動突合しexact一致を確認)
changed_files_count: 15(全件Allowed Paths内。前回レビュー時からの差分3ファイルも全てAllowed Paths内の既存ファイル修正のみ)
violations: []
CI証拠(head一致)
status: all_pass。python-test, test, typecheck, lint, build, e2e, actionlint, check-hook-integrity, ci-verdict-summary, deploy-pr, node-backed-hook-tests, validate-generated-artifact, PR Body Japanese Check 全てSUCCESS。stale/pending/failed 0件。
blockers
- Safety Claim Matrix セクション欠落
- 受け入れ条件の達成状況(AC coverage checklist)セクション欠落
required_auto_actions:
- kind: update_pr_body_hygiene
executor: implementation-worker
skill: open-pr.update_pr
blocking_merge_ready: true
mechanical: true
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
changed_files_source: manual_diff_against_issue_1498_allowed_paths
changed_files_count: 15
allowed_paths_gate_source: review_subagent
対応方法
Safety Claim MatrixとAC coverage checklistをPR本文に追加してください。実装ロジックの再変更は不要でPR本文hygieneのみです。追加後は速やかにAPPROVE見込みです。
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
前回2回のREQUEST_CHANGESで指摘した2blocker(Safety Claim Matrix欠落/AC coverage checklist欠落)の解消をコード無変更・本文のみ更新で再検証しました。
前回blockerの解消確認
## 受け入れ条件の達成状況: Issue #1498 AC1〜AC11 全項目が[x]+ テストファイルパス・関数名・実行結果の根拠付きで記載されている。プレースホルダーなし。AC5/AC6のファイル名がAllowed Pathsと矛盾する既知のcontract drift(Issue側follow-up事項)についても「Allowed Paths Compliance」節で明示的に説明されており、実際に既存exactファイルへテスト追加した旨と対応が取れている。Safety Claim Matrix: 5 claim全てEvidence付きで記載。「10トークンparserのexecution_class未検証gapを締めた」の主張はdiffで直接確認済み(scripts/agent-guards/skill_runtime_command_policy.pyのparse_exact_skill_runtime_command()にpolicy.get("execution_class") != SKILL_RUNTIME_EXECUTION_CLASSチェックを追加)。fixture側は元々command_id != "preflight.run.fixture"の明示チェックがmain上に存在済み(対象外の旨)であることも確認した。Not controlled列は全行-で空、未解決follow-upなし(禁止条件に抵触しない)。
CI証拠(head一致・独立検証)
ci_verdict_summary.py は exit 10(status: failed)を返したが、failed_checks は "PR Body Japanese Check" の1件のみで、その実体は head_sha: null の重複エントリ(別run 29269355775、event: pull_request_review)である。.github/workflows/check-japanese.yml の check-pr-body ジョブは if: github.event_name == 'pull_request' でガードされており、review submit(pull_request_reviewイベント)でworkflow全体が再起動されるとこのジョブは構造上 skipped になる(コードの欠陥ではない)。現head 88d8e151... に紐づく pull_request イベントのrun(29269849542)では同チェックが SUCCESS であることを確認した。それ以外の13チェック(python-test, test, typecheck, lint, build, e2e, actionlint, check-hook-integrity, ci-verdict-summary, deploy-pr, node-backed-hook-tests, validate-generated-artifact, PR Body Japanese Check)は全てhead一致でSUCCESS、stale/pending 0件。ci_verdict_summary.py の HEAD_SHA_NULL_SKIPPED_EXCLUDE_RULES allowlistが ("Check Japanese Content", "PR Body Japanese Check") を含んでいないための script側false positiveと判断する(既存の "(retrospective)" ジョブ群と同型のnoise)。これはPR #1500のコードに起因しないため本PRのblockerとしないが、script自体の改善余地としてfollow-up候補にする(merge非blocking)。
Allowed Paths Gate(review_subagent 再計算)
fingerprint-bound allowed_paths_review_gate.py は Issue #1498 の contract-snapshotコメント(CONTRACT_REVIEW_RESULT_V1)が base_sha_at_snapshot / expected_contract_fingerprint を含まないスキーマのため実行不可(前回レビューと同じ制約)。fallbackとして gh pr diff --name-only で取得した変更ファイル15件を Issue #1498 の Allowed Paths 列挙と手動突合し、全件が exact one-to-one で Allowed Paths 内(.claude/skills/issue-refinement-loop/tests/** / scripts/agent-guards/tests/** のワイルドカード配下を含む)であることを確認した。逸脱なし。
verdict
verdict: APPROVE
reviewed_head_sha: "88d8e151396496407576d23d8e052476501b5a39"
merge_ready: true
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests:
- kind: mechanical_gap
title: "ci_verdict_summary.py の HEAD_SHA_NULL_SKIPPED_EXCLUDE_RULES に Check Japanese Content ワークフローの非retrospectiveジョブ名を追加する"
reason: "pull_request_review イベントでworkflow全体が再起動されると check-pr-body ジョブが head_sha=null の skipped エントリとして重複計上され、全チェックSUCCESS時でもexit 10のfalse positiveを生む"
blocking_merge_ready: false
allowed_paths_gate:
status: ok
changed_files_source: manual_diff_against_issue_1498_allowed_paths(fingerprint-bound script は Issue #1498 の contract-snapshot コメントが base_sha_at_snapshot / expected_contract_fingerprint を含まないため実行不可)
changed_files: 15件、全件Allowed Paths内
violations: []
allowed_paths_gate_source: review_subagent
producer_role: review_subagent
worker_report_used_as_canonical: false
Draft PR のため merge_ready は次工程判断用です。人間マージをお願いします。
概要
preflight.runの production 契約を一切変更せず、anchor comment を指定した issue-refinement-loop preflight 実行を、command registry / exact command policy / privileged executor の正規経路で行えるようにする新しい sibling exact profilepreflight.run.with_anchorを追加する。Closes #1498(この Issue #1498 をクローズする)
Refs #1492(関連する Issue #1492 への参照)
Summary
preflight.runの production 契約を一切変更せず、anchor comment を指定した issue-refinement-loop preflight 実行を、command registry / exact command policy / privileged executor の正規経路で行えるようにする新しい sibling exact profilepreflight.run.with_anchorを追加します(詳細は上記「概要」節を参照)。変更内容
.claude/skills/issue-refinement-loop/scripts/command_registry.py:preflight.run.with_anchorエントリ追加。preflight.runの argv/placeholders/execution_class は不変。新設 placeholder typegithub_issue_comment_urlを追加(canonical shape のみ許可、percent-encoding は文字クラス構成上そもそも一致しない)。scripts/agent-guards/skill_runtime_command_policy.py:parse_exact_skill_runtime_anchor_command()(12トークン厳密一致)、is_exact_skill_runtime_anchor_executor_command()を新設。SKILL_RUNTIME_COMMAND_POLICY_V2/ROOT_NO_WORKTREE_ALLOWED_COMMAND_IDS/_EXPECTED_ARGV_BY_COMMAND/_EXPECTED_PLACEHOLDERS_BY_COMMANDにエントリ追加。scripts/agent-guards/skill_runtime_exec.py:--anchor-comment-urlargparse 引数追加、command-id 分岐拡張(preflight.run.with_anchorのみ許可、他は拒否)。allow_abbrev=Falseを明示。.claude/hooks/worktree_scope_guard.py/scripts/agent-guards/local_main_branch_guard.py:preflight.run.with_anchorの exact executor 判定を追加(looks_like_skill_runtime_executor_commandの広域ブロックより前に判定する)。.claude/settings.json:preflight.run.with_anchor用の最小 exact permission entry を1件追加(wildcard なし)。.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py:--anchor-comment-urlの help text を実際の 0..1 件契約に修正。allow_abbrev=Falseを明示。既存の_validate_anchor_comments_batch()ロジックは無改変。.claude/skills/issue-refinement-loop/SKILL.md/docs/dev/agent-skill-boundaries.md:preflight.run.with_anchorの呼び出し例・境界定義を追記。副次的な修正(latent gap の発見)
scripts/agent-guards/skill_runtime_command_policy.pyの既存 10-token parser(parse_exact_skill_runtime_command)がeligible_command_idsのメンバーシップのみで command_id を判定していたため、preflight.run.with_anchorを新規追加した結果、anchor flag を欠いた 10-token の--command-id preflight.run.with_anchorコマンドが誤って許可されてしまう split-brain(AC5 の real hook テストで検出)が判明した。10-token parser はexecution_class == exact_skill_runtime(=preflight.runのみ)の command_id にのみマッチするよう締めた。preflight.run自体の挙動・契約は不変(この修正がなければ既存preflight.run.fixtureにも同種の latent gap があったが、これは Out of Scope として変更していない — fixture 側は元々parse_exact_skill_runtime_fixture_command側でcommand_id != "preflight.run.fixture"を明示チェックしており、この 10-token parser の gap は fixture の exact-executor 判定 (is_exact_skill_runtime_fixture_executor_command) 経路には影響しない)。Allowed Paths Compliance(許可パス遵守状況の確認)
Issue #1498 の Allowed Paths 内でのみ変更した。ただし AC5 / AC6 の Verification Commands が示すテストファイルパス(
.claude/hooks/tests/test_worktree_scope_guard_anchor.py/tests/codex/test_local_main_branch_guard_anchor.py)は Allowed Paths に含まれていなかった(.claude/hooks/tests/とtests/codex/は exact ファイルのみ許可、wildcard なし)ため、代わりに Allowed Paths に列挙されている既存の exact ファイル(.claude/hooks/tests/test_worktree_scope_guard.py、.claude/hooks/tests/test_local_main_branch_guard.py、tests/codex/test_local_main_branch_guard.py)へテスト関数を追加する形で AC5/AC6 の要求内容を満たした。Positive/Negative Test Matrix カバレッジ(全24項目)
preflight.runtest_preflight_run_unaffected_without_anchor等scripts/agent-guards/tests/test_skill_runtime_exec_anchor.pypreflight.run.with_anchortest_registry_sibling_profile_renders_argv,test_matrix_2_valid_anchor_parses,test_worktree_scope_guard_allows_anchor_profile_matrix_2,test_exact_allowlist_anchor_profile*test_matrix_3_missing_anchor_via_plain_parser_is_not_accepted,test_worktree_scope_guard_denies_anchor_profile_negative_matrix[missing_anchor_flag]test_skill_runtime_command_policy_anchor.py,test_worktree_scope_guard.pypreflight.runに追加test_executor_reaches_subprocess_and_rejects_anchor_on_preflight_run,test_matrix_4_anchor_on_preflight_run_rejected_by_plain_parsertest_skill_runtime_exec_anchor.py,test_skill_runtime_command_policy_anchor.pytest_matrix_5_duplicate_distinct_anchor_flags_rejected等test_skill_runtime_command_policy_anchor.pytest_matrix_6_duplicate_identical_anchor_flags_rejected等test_skill_runtime_command_policy_anchor.pytest_matrix_22_repo_context_mismatch_rejected,test_executor_rejects_context_mismatched_anchor_urltest_matrix_22_issue_context_mismatch_rejectedtest_skill_runtime_command_policy_anchor.pytest_matrix_9_to_14_url_shape_rejected[pull_request_review_comment]等test_matrix_9_to_14_url_shape_rejected[discussion_r_fragment]等test_matrix_9_to_14_url_shape_rejected[query_string]等test_matrix_9_to_14_url_shape_rejected[trailing_slash]等test_matrix_9_to_14_url_shape_rejected[userinfo/port等]等test_matrix_9_to_14_url_shape_rejected[percent_encoded]等--anchor-comment-url=URLtest_matrix_15_eq_form_rejected等test_matrix_16_abbreviation_rejected等test_matrix_17_flag_no_value_rejected等test_matrix_18_unknown_extra_flag_rejected等test_matrix_19_duplicate_flag_rejected等test_matrix_20_flag_order_changed_rejected等test_matrix_21_shell_metachar_rejected等test_matrix_22_repo_context_mismatch_rejected,test_matrix_22_issue_context_mismatch_rejectedtest_worktree_scope_guard_anchor_matrix_no_split_brain_with_policy_parser,test_anchor_profile_no_split_brain_with_worktree_scope_guardtest_worktree_scope_guard.py,test_local_main_branch_guard.pytest_claude_codex_parity_anchor_profiletests/codex/test_local_main_branch_guard.pyRuntime Verification Applicability
decision: immediate。real executor / real preflight chain を一時 git repository 上で実行し(AC4, AC9)、実 PreToolUse hook 経路(stdin JSON、実 git worktree)で AC5 の allow/deny matrix を検証した。artifact_requirements(pytest -rA --show-capture=all)は下記「検証コマンド結果」に記録する。検証コマンド結果
Allowed Paths / preflight.run 不変性の確認
git diffでpreflight.runエントリ(command_registry.py/skill_runtime_command_policy.py双方)が一切変更されていないことを確認済み(新規追加ブロックのみの diff)。受け入れ条件の達成状況
Issue #1498 の AC1〜AC11 それぞれについて、達成状況と証跡(テストファイルパス・関数名・実行結果)です。
.claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py::test_registry_sibling_profile_preserves_preflight_run(21 passed)。.claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py::test_github_issue_comment_url_type_rejects_negative_matrix(同上 21 passed に含まれる)。scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py::test_parse_exact_anchor_command_rejects_negative_matrix(33 passed)。scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_executor_reaches_subprocess_and_rejects_anchor_on_preflight_run(4 passed)。.claude/hooks/tests/test_worktree_scope_guard.py::test_worktree_scope_guard_anchor_matrix_no_split_brain_with_policy_parser(230 passed)、.claude/hooks/tests/test_local_main_branch_guard.py::TestAnchorProfile::test_anchor_profile_no_split_brain_with_worktree_scope_guard(324 passed)。tests/codex/test_local_main_branch_guard.py::test_claude_codex_parity_anchor_profile(298 passed)。.claude/skills/issue-refinement-loop/tests/test_anchor_comment_multiple_urls.py(1 passed、無改変で PASS)。Safety Claim Matrix
このPRは safety-sensitive gate を変更するため、以下に安全境界への影響を記載します。
Checks
検証結果はいずれも PASS です(詳細コマンドと出力は上記「検証コマンド結果」節参照)。
pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -q(21 passed)pytest scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py -q(33 passed)pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q(4 passed)pytest .claude/hooks/tests/test_worktree_scope_guard.py -q(230 passed)pytest .claude/hooks/tests/test_local_main_branch_guard.py -q(324 passed)pytest tests/codex/test_local_main_branch_guard.py -q(298 passed)pytest .claude/skills/issue-refinement-loop/tests/test_anchor_comment_multiple_urls.py -q(1 passed)pnpm typecheck/pnpm lint/pnpm test/pnpm build(すべて PASS)Schema Change Applicability
not_schema_changepreflight.runの既存 argv/placeholders/execution_class は不変です。Schema Consumer Inventory
該当なし(
decision: not_schema_changeのため、既存 schema の consumer 一覧・before/after 差分はありません)。Notes