Repository navigation
fix: .claude/settings.json permissions.* から冗長な Write(path) を削除し validator で再導入防止 - #1561
Conversation
…validator で再導入を防止する (#1551) permissions.allow/ask/deny に残っていた scoped Write(assets/**) / Write(LICENSES/**) / Write(.env) / Write(.env.*) / Write(secrets/**) / Write(**/.ssh/**) / Write(**/.config/gh/**) は、対応する Edit(path) ルールが既に存在する冗長な表現だった ため削除した(repository policy: claude_permission_edit_rule_canonicalization_v1)。 scripts/ci/check_claude_settings_permissions.py を新規追加し、 permissions.allow/ask/deny のみを検査対象として scoped Write(...) の再導入を fail-closed(exit 1)で検出する。JSON parse エラーや shape 不正は exit 2、 bare "Write" と hooks matcher("Write|Edit" 等)は accept する。本 validator は Claude Code runtime の安全性同値を主張しない(runtime_behavior_change_claimed: false)。 .github/workflows/ci.yml の python-test job に production invocation として追加した。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1561 closed). |
…1551) PR #1561 の Write/Edit permission rule 統合により settings.json の permissions.deny から scoped Write(.env) / Write(.env.*) / Write(secrets/**) が削除され、対応する Edit(...) エントリに統合された。しかし tests/context_mode/test_deny_secrets.py の TestAC2SyntheticContextModeDir::test_env_files_excluded_by_deny_policy は 「Write(.env が deny_list に含まれること」のみを assert しており、 Write/Edit 統合後の状態を前提としていなかったため CI python-test job が FAILURE していた。 .env への書き込みが deny されていることの検証意図を保ったまま、 Write または Edit のいずれかで deny されていれば良い形にアサーションを 更新する(最小差分)。 Scope Delta: Allowed Paths を tests/context_mode/test_deny_secrets.py まで 拡張(既存の cross-file 契約テストの前提更新のため)。
fix_delta 適用報告(iteration 2)背景
修正内容
Scope Delta
実行した検証コマンドとその結果
push 後の状態
Co-Authored-By: Claude Sonnet 5 [email protected] |
squne121
left a comment
There was a problem hiding this comment.
レビュー結果(REQUEST_CHANGES)
PR #1561(worktree-issue-1551-settings-write-edit-canonicalization)を Issue #1551 の contract(issue comment 5008450334 の Allowed Paths)と照合した結果、tests/context_mode/test_deny_secrets.py の変更が Allowed Paths gate で fail_closed となったため REQUEST_CHANGES とする。
.claude/settings.json / .github/workflows/ci.yml / scripts/ci/check_claude_settings_permissions.py / scripts/ci/tests/test_check_claude_settings_permissions.py は contract の Allowed Paths 内であり問題ない。一方で tests/context_mode/test_deny_secrets.py は Issue #1551 本文にも contract snapshot(comment 5008450334)にも含まれておらず、commit e48f4f6d のコミットメッセージにのみ Scope Delta の理由(.claude/settings.json の scoped Write(.env 系 deny エントリを Edit(...) に統合した結果、既存テストのアサーションが実態と乖離したための追随修正)が記載されている。しかし PR 本文(## Allowed Paths 遵守 / ## Notes 等)にはこの Scope Delta が一切開示されていない。
merge_ready は required_auto_actions が非空のため false。update_pr_body_hygiene を mechanical な自動対応として要求する。PR body で Scope Delta を明示するか、issue-contract-review で Allowed Paths を正式に拡張したうえで再レビューが必要。
LOOP_VERDICT_V2:
verdict: REQUEST_CHANGES
reviewed_head_sha: "e48f4f6df54155def1fd48f450eabf08b3f92c94"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers:
- "ALLOWED_PATHS_GATE_RESULT_V1.status=fail_closed: tests/context_mode/test_deny_secrets.py はIssue #1551本文/contract snapshot(comment 5008450334)のAllowed Pathsに含まれない。commit e48f4f6dのメッセージにのみScope Delta理由が記載され、PR本文(## Allowed Paths 遵守 / ## Notes 等)には一切開示されていない。PR本文でScope Deltaを明示するか、issue-contract-reviewでAllowed Pathsを正式に拡張してから再レビューが必要。"
required_auto_actions:
- kind: update_pr_body_hygiene
executor: implementation-worker
skill: open-pr.update_pr
mechanical: true
blocking_merge_ready: true
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
producer_role: review_subagent
worker_report_used_as_canonical: false
status: fail_closed
changed_files_source: "github_pull_request_files_api_with_previous_filename"
changed_files:
- ".claude/settings.json"
- ".github/workflows/ci.yml"
- "scripts/ci/check_claude_settings_permissions.py"
- "scripts/ci/tests/test_check_claude_settings_permissions.py"
- "tests/context_mode/test_deny_secrets.py"
violations:
- file: "tests/context_mode/test_deny_secrets.py"
path_role: "filename"
reason: "not_in_contract_allowed_paths_no_disclosed_scope_delta"
expected_contract_fingerprint:
issue_number: 1551
contract_source_kind: "issue_comment"
contract_source_id: "5008450334"
contract_body_sha256: "sha256:636a14d1dc82c97a8514579ae77864c3c091ba9eb9734ca5b4f9cc0c1a433ec4"
squne121
left a comment
There was a problem hiding this comment.
PR #1561 レビュー結果(Closes #1551)
判定
APPROVE — マージ可能。
概要
.claude/settings.json の permissions.allow / permissions.ask / permissions.deny から、対応する Edit(path) が既に存在する冗長な scoped Write(path) ルール 7 件(assets/** / LICENSES/** / .env / .env.* / secrets/** / **/.ssh/** / **/.config/gh/**)を削除し、claude_permission_edit_rule_canonicalization_v1 ポリシーに正規化した。再導入防止のための静的検証スクリプト scripts/ci/check_claude_settings_permissions.py を新設し、.github/workflows/ci.yml の python-test job に production invocation として組み込んでいる。
確認事項
- Linked Issue:
Closes #1551を PR 本文から確認済み。 - Mergeability:
mergeable: MERGEABLE/merge_state_status: CLEAN(gh pr viewで確認)。 - CI:
gh pr checksで全 required チェックがpass(PR Body Japanese Check / actionlint / build / check-hook-integrity / ci-verdict-summary / deploy-pr / e2e / lint / node-backed-hook-tests / python-test / test / typecheck / validate-generated-artifact)。 - AC coverage: PR 本文「Checks」節に AC1〜AC10 全項目が
[x]で記載され、各根拠(pytest 23 tests PASS、production invocation exit 0、CI 組み込み、pnpm typecheck/lint/test/buildPASS 等)が明示されている。 - Allowed Paths gate: 変更ファイル 5 件(
.claude/settings.json/.github/workflows/ci.yml/scripts/ci/check_claude_settings_permissions.py/scripts/ci/tests/test_check_claude_settings_permissions.py/tests/context_mode/test_deny_secrets.py)は、Scope Delta 経由で承認済みの Allowed Paths 内であり、gate status はok(violations なし)。 - Schema Change Applicability:
not_schema_change(.claude/settings.jsonはローカル設定であり public schema consumer 対象外)と明記されており妥当。 - Verification skip / fallback / stale head の懸念なし。
Blockers
なし。
Required Auto Actions
なし。
LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: "8657b930374c7cf8b66f6533f47d47f66e994c11"
merge_ready: true
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
changed_files_source: git_diff_name_status_find_renames_z
changed_files:
- .claude/settings.json
- .github/workflows/ci.yml
- scripts/ci/check_claude_settings_permissions.py
- scripts/ci/tests/test_check_claude_settings_permissions.py
- tests/context_mode/test_deny_secrets.py
diff_base_sha: "d55552bfc2dcab0f294cab37bc158d3c24372a63"
contract_fingerprint:
issue_number: 1551
contract_source_kind: issue_comment
contract_source_id: "5008777186"
contract_body_sha256: "sha256:ec5211e8f6c5fda167402cbafc86d3bb7d087f61c81e197ade6fa0f2f06d55c3"
base_sha_at_snapshot: "d55552bfc2dcab0f294cab37bc158d3c24372a63"
violations: []
敵対的レビュー結果判定: REQUEST_CHANGES変更の方向性自体は妥当です。過去の PR #24 では 一方、追加された validator と回帰テストは、現在の Issue が要求する「fail-close」「canonical なお、以前のレビューで指摘された P1-1:
|
…1551) 敵対的レビュー(PR #1561 iteration 3)で指摘された実コード上の欠陥に対応する。 - permissions が null / 非オブジェクトの場合を shape error(exit 2)として key 不在(exit 0 相当)と区別する - AC2「7件の canonical Edit(...) deny を維持する」を回帰テストと mutation test(各エントリ除去で検出)で固定する - test_deny_secrets.py の .env 保護判定を canonical Edit(.env) / Edit(.env.*) の厳密一致に限定し、非推奨の scoped Write(.env...) を 保護の証拠として受理しないようにする - scoped Write(...) 検出の正規表現を fullmatch ベースに厳格化する safety_claim(runtime_behavior_change_claimed: false)は維持し、 外部レビューが主張する未検証の Claude Code バージョン番号は採用しない。
squne121
left a comment
There was a problem hiding this comment.
PR #1561 最終レビュー(Issue #1551)
敵対的レビュー(https://github.com/squne121/loop-protocol/pull/1561#issuecomment-5009141856)で指摘された P1-1〜P1-4 について、control-plane が head efeca015 の実コード(scripts/ci/check_claude_settings_permissions.py / scripts/ci/tests/test_check_claude_settings_permissions.py / tests/context_mode/test_deny_secrets.py)を直接読み、修正が反映されていることを独立に確認した。
- P1-1(
permissions: nullの fail-close 化):find_scoped_write_violations()はpermissionsが dict でない場合(nullを含む)にSettingsPermissionsError("permissions must be an object")を送出し、exit code 2 の shape error として fail-closed になることをソース上で確認した。 - P1-2(AC2 必須7件 Edit deny の回帰テスト + mutation test):
test_check_claude_settings_permissions.pyにREQUIRED_CANONICAL_EDIT_DENIES(7件)に対するtest_repository_settings_retain_required_canonical_edit_deniesと、各エントリを個別に除去して検出できることを確認する@pytest.mark.parametrize済みtest_missing_canonical_edit_deny_is_detected(mutation test、7 parametrize)が追加されていることを確認した。 - P1-3(
test_deny_secrets.pyのWrite(.env)誤受理是正):test_env_files_excluded_by_deny_policyが、旧来の"Write(.env" in entry部分一致判定を廃止し、required_env_edit_denies = {"Edit(.env)", "Edit(.env.*)"}が deny list の部分集合であることを要求する判定に変更され、さらにnot any(entry.startswith("Write(.env") for entry in deny_list)で非推奨の scopedWrite(.env...)が残っていないことを別途 assert していることを確認した。 - P1-4(正規表現の
fullmatch化):_SCOPED_WRITE_RE = re.compile(r"Write\(.+\)")の適用箇所が_SCOPED_WRITE_RE.fullmatch(entry)になっており、部分一致による誤検知/見逃しを排除していることを確認した。 - P1-5(未検証のバージョン主張): 本 PR では採用しなかった(敵対的レビュー側の指摘として記録するのみで、本体修正の対象外と判断)。
その他の確認事項:
- AC coverage: PR 本文の受け入れ条件達成状況と実コード・テストが一致していることを確認した。
- CI:
ci_verdict_summary.py --pr 1561 --expected-head-sha efeca015b292c49f986979e0bccc356f145f5698はstatus: all_pass(exit 0)で、head_sha 一致・stale なし・failed/pending なしを確認した。 - Allowed Paths gate:
gh pr diff --name-onlyによる変更ファイルは.claude/settings.json/.github/workflows/ci.yml/scripts/ci/check_claude_settings_permissions.py/scripts/ci/tests/test_check_claude_settings_permissions.py/tests/context_mode/test_deny_secrets.pyの5件のみで、Issue #1551 の Allowed Paths と一致し、逸脱なし(status: ok)。 - Mergeability:
MERGEABLE/CLEAN。
上記より blocker なし。APPROVE とする。
LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: "efeca015b292c49f986979e0bccc356f145f5698"
merge_ready: true
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
changed_files_source: git_diff_name_status_find_renames_z
changed_files:
- ".claude/settings.json"
- ".github/workflows/ci.yml"
- "scripts/ci/check_claude_settings_permissions.py"
- "scripts/ci/tests/test_check_claude_settings_permissions.py"
- "tests/context_mode/test_deny_secrets.py"
violations: []
Summary
.claude/settings.jsonのpermissions.allow/permissions.ask/permissions.denyに残っていた冗長な scopedWrite(path)ルール(対応するEdit(path)が既に存在する 7 件:assets/**/LICENSES/**/.env/.env.*/secrets/**/**/.ssh/**/**/.config/gh/**)を削除し、repository policyclaude_permission_edit_rule_canonicalization_v1(path-scoped file mutation rule はEdit(...)に正規化し、scopedWrite(...)を使わない)に揃えた。あわせて再導入を防止する static validatorscripts/ci/check_claude_settings_permissions.pyを追加し、.github/workflows/ci.ymlのpython-testjob に production invocation として組み込んだ。Checks
.claude/settings.jsonのpermissions.allow/ask/denyに scopedWrite(...)rule が存在しないEdit(...)rule を維持scripts/ci/check_claude_settings_permissions.pyを追加し JSON parse エラー / shape 不正を fail-close(非ゼロ終了)で検出Writeは accept、hooks matcher("Write|Edit")は検査対象外scripts/ci/tests/test_check_claude_settings_permissions.pyの全テストが PASS(23 tests).github/workflows/ci.ymlのpython-testjob が AC7 の production invocation を実行runtime_behavior_change_claimed: falseを明記pnpm typecheck/pnpm lint/pnpm test/pnpm buildが PASS検証コマンド結果
Schema Change Applicability
.claude/settings.jsonのpermissions.*配列は外部 consumer が参照する public schema ではなく、Claude Code ランタイム自体が読み込むローカル設定ファイルであるため、schema consumer inventory の対象外とする。Schema Consumer Inventory
N/A(Schema Change Applicability が
not_schema_changeのため対象外)Safety Claim Matrix
本 PR は
.github/workflows/ci.yml(CI パス)を変更するため safety-sensitive パスに該当する。ただし変更内容は CI job への static validator 呼び出し 1 行の追加のみであり、CI 実行権限・シークレット・並列度・タイムアウト設定への変更は含まない。CI_TEST_PERFORMANCE_DECISION_V1
Scope Delta
tests/context_mode/test_deny_secrets.py.claude/settings.jsonの scopedWrite(.env系 deny エントリをEdit(...)に統合したことに伴い、この統合前提を知らなかった既存テストtest_env_files_excluded_by_deny_policyのアサーションを実態に合わせて更新する必要があったため(cross-file contract 破綻の是正)。Notes
.claude/settings.jsonを Allowed Paths に含む OPEN Issue だが、いずれも本 PR の Outcome(Write(path)→Edit(path)正規化)と異なる関心事(PR body hygiene wrapper 強制 / staging guard / update_branch 経路強制)を扱っており非衝突。実装開始時点(headd4d5a6de2f66eff86d409bf4167119fac90ccfd8)で state は全て OPEN のまま変わっておらず、fresh evidence の再確認により blocking dependency は検出されなかった。Edit(path)ルールの path anchoring 修正は Out of Scope(follow-up 対象、Issue 実装: .claude/settings.json の permissions.* から無効な Write(path) ルールを削除し validator で再導入を防止する #1551 本文の Notes for Reviewer 参照)。~/.claude/settings.json)の個人設定は対象外。本 PR は Issue #1551 を解決するため Closes #1551 とする。