Repository navigation
refactor: .guard_shadow_log.jsonl の shadow-log 特例を廃止し generic 判定に戻す - #2390
Conversation
…2252) 全 production producer(#2264 の rtk_boundary_shadow_guard.sh、#2265 の guard-japanese-prose.sh persistent shadow logging、および本 Issue の .claude/hooks/shadow_log.py)撤去後、skill_runtime_exec.py の shadow-log typed exact-file special case(_SHADOW_LOG_* 定数・ _shadow_log_stable_observation 等の関数・ShadowLogStreamCapture)を コード・コメントとも完全に削除し、.guard_shadow_log.jsonl を generic repository path として扱う(誤って書き込まれれば通常の unauthorized_write_path で fail-close する)。 - test_guard_shadow_log_write_path_policy.py(special case 専用 regression)を削除 - test_codex_shadow_removal_regression.py から SHADOW_LOG_WRITER 定義・ producer 起動テスト・_SHADOW_LOG_EXACT_REL assertion・旧契約 docstring を削除 - test_skill_runtime_exec_unauthorized_write_path.py に .guard_shadow_log.jsonl 新規作成が generic unauthorized_write_path で fail-close する regression test を追加 - test_skill_runtime_exec_stale_shadow_log_preflight.py(新規)で stale な .guard_shadow_log.jsonl が canonical preflight を妨げない ことを検証 - docs/dev/agent-skill-boundaries.md の shadow-log active operational policy 記述を歴史化 - .claude/hooks/guard-japanese-prose.sh のコメントに残っていた .guard_shadow_log.jsonl への文字参照を削除(AC1 の production 領域 無参照要件を満たすための Scope Delta。コメントのみで挙動変更なし) - .gitignore の .guard_shadow_log.jsonl entry は legacy tombstone として維持(変更しない) Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2390/ The preview will be removed when this PR is closed. |
判定:REQUEST_CHANGES設計方針には賛成です。全 producer の撤去後に、約三千行ある shadow-log 専用ポリシーを削除して既存の generic ただし、現時点では次の 二件をマージブロッカー と判断します。
Findings[BLOCKER 1] PR #2381 マージ後の
|
…hadow-log-removal # Conflicts: # scripts/agent-guards/skill_runtime_exec.py
…ント)を解消する Issue #2252 AC4 が要求する .guard_shadow_log.jsonl への update 経路の regression test を追加し、共通 fixture _make_repo() の .gitignore に .guard_shadow_log.jsonl を追加して本番の legacy tombstone (ignored path) 条件を再現するようにした。あわせて root .gitignore のコメントを active observability を示唆する文言から legacy tombstone であることが 明確な文言へ変更した。
Summary
Issue #2252 の実装です。
.guard_shadow_log.jsonlという repo-local persistent shadow telemetry を廃止し、全 production producer(#2264 のrtk_boundary_shadow_guard.sh、#2265 のguard-japanese-prose.shpersistent shadow logging、本 PR の.claude/hooks/shadow_log.py)撤去後、scripts/agent-guards/skill_runtime_exec.pyの shadow-log 専用 typed exact-file special case を削除して genericunauthorized_write_pathfail-close 判定に戻しました。変更内容
scripts/agent-guards/skill_runtime_exec.py: shadow-log typed exact-file special case(_SHADOW_LOG_*定数群、_shadow_log_stable_observation/_shadow_log_stream_capture/_is_allowed_shadow_log_kind_transition/_is_authorized_shadow_log_content_transition_capture/_is_authorized_shadow_log_cold_start_content_capture/_reject_shadow_log_json_constant/_parse_shadow_log_jsonl/_mode_kind等の関数、ShadowLogStreamCapture/_JsonlLineScannerクラス、関連コメント)を大文字小文字を問わず全削除。_find_unauthorized_repo_changes()から shadow-log 専用の kind/content 遷移チェックと除外条件(path != _SHADOW_LOG_EXACT_REL)を削除し、.guard_shadow_log.jsonlを generic repository path として扱うようにした。未使用になったerrno/hashlib/typing.NamedTupleの import も削除(ruff clean)。.claude/hooks/shadow_log.py: 削除。削除前にrg --hiddenで.claude/hooks/scripts(tests 除く)配下に production caller が存在しないことを確認済み(investigation ログ参照)。scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py: 削除(typed exact-file special case 専用の regression test。special case 削除に伴い意味を失う)。scripts/agent-guards/tests/test_codex_shadow_removal_regression.py:SHADOW_LOG_WRITER定義・test_other_shadow_log_producer_still_writes_successfully()(削除済みshadow_log.pyを実際に起動するテスト)・test_skill_runtime_exec_shadow_log_exact_rel_policy_untouched()(_SHADOW_LOG_EXACT_RELを直接 assert)・旧 docstring 契約文(「OTHER producer は書き続けなければならない」)を削除し、Codex 固有 shadow writer 除去の regression のみを残す形に更新。scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py:.guard_shadow_log.jsonlを test child が新規 create または既存ファイルを update した場合に、いずれも genericunauthorized_write_pathで fail-close することを示す parametrize regression test(test_shadow_log_create_or_update_fails_as_generic_unauthorized_write_path[create|update])を追加。共通 fixture_make_repo()の.gitignoreに.guard_shadow_log.jsonlを追加し、git check-ignore -qで ignored 状態(本番の legacy tombstone 条件)を fixture 構築時に assert するよう修正。既存の非 shadow-log regression 群は無変更。scripts/agent-guards/tests/test_skill_runtime_exec_stale_shadow_log_preflight.py(新規): producer 撤去前から存在する stale.guard_shadow_log.jsonlが無変更のまま canonical preflight(skill_runtime_exec.py経由の実行)が正常完了することを検証。docs/dev/agent-skill-boundaries.md: shadow-log active operational policy 記述(型付き遷移ポリシーの詳細節、directory-root 除外クラス非該当の説明)を歴史化(Issue 実装: .guard_shadow_log.jsonl と privileged executor の shadow-log 特例を廃止する #2252 で廃止済みである旨を明記し、詳細な遷移ロジック説明は削除)。.claude/hooks/guard-japanese-prose.sh(Scope Delta): コメント内に残っていた.guard_shadow_log.jsonlへの具体的ファイル名言及を、挙動を変えずに generic な表現へ書き換え。AC1 の VC が production 領域(.claude/hooks/scripts、tests 除く)に shadow-log 関連の文字列参照が一切ないことを要求しており、実装前の investigation でこの 1 行のコメント残存が該当することを検出したため、Issue 本文の Scope Delta セクションで理由を明記した上で Allowed Paths に追加した。分岐ロジック・exit code は無変更(コメント 1 行のみ)。.gitignore(Scope Delta):.guard_shadow_log.jsonlの entry 自体は削除・変更していません(legacy tombstone として維持)が、レビュー指摘(PR refactor: .guard_shadow_log.jsonl の shadow-log 特例を廃止し generic 判定に戻す #2390 コメント)を受けてコメント文言を「active observability」を示唆する記述から「legacy tombstone」であることを明示する記述へ書き換えました(4 insertions / 1 deletion)。Issue 本文の Scope Delta に追記済みです。fix_delta(iteration 3: main コンフリクト解消 + レビュー指摘対応)
PR #2381(
scripts/agent-guards/skill_runtime_exec.pyを含む remote protocol Git builders 変更)が本 PR 着手後に main へマージされ、一時mergeable: CONFLICTINGになりました。以下を対応しました:origin/main(PR feat: harden remote protocol Git builders #2381 マージ後、head1611e101)を merge。scripts/agent-guards/skill_runtime_exec.pyのコンフリクトを関数単位で解消(PR feat: harden remote protocol Git builders #2381 の remote Git builder / process supervisor コード・import は保持、本 PR が削除する shadow-log special case は削除のまま維持)。マージ後に! rg -n '(?i)shadow[_-]?log' scripts/agent-guards/skill_runtime_exec.pyが exit 1(該当なし)であること、PR feat: harden remote protocol Git builders #2381 由来の focused tests(test_skill_runtime_control_plane_exec.py/test_skill_runtime_control_plane_policy.py)が PASS することを確認。.gitignore不整合、および.gitignoreコメントの LOW 指摘を上記の通り修正。Checks
uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_stale_shadow_log_preflight.py::test_stale_pre_existing_shadow_log_does_not_block_preflight -v(AC3、1 passed)uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py -v(AC4、12 passed、create/update parametrize 含む)uv run --locked pytest scripts/agent-guards/tests/test_codex_shadow_removal_regression.py -v(AC5、2 passed)! rg --files .claude/hooks -g 'shadow_log.py'(AC1、exit 1 = 該当なし)! rg --files scripts/agent-guards/tests -g 'test_guard_shadow_log_write_path_policy.py'(AC1、exit 1 = 該当なし)! rg --hidden -n -e 'guard_shadow_log\.jsonl' -e 'shadow_log\.py' -e 'SHADOW_LOG_PY' -e 'SHADOW_LOG_FILE' -e 'GUARD_JAPANESE_PROSE_SHADOW_LOG' .claude/hooks scripts --glob '!**/tests/**'(AC1、exit 1 = 該当なし)! rg -n '(?i)shadow[_-]?log' scripts/agent-guards/skill_runtime_exec.py(AC2、exit 1 = 該当なし)rg -n "guard_shadow_log" .gitignore(AC6、tombstone entry 存在確認)uv run --directory <worktree> --locked pytest scripts/agent-guards/tests/ -q(回帰確認、14 failed は main 側にも同数存在する pre-existing localuv_version_mismatch環境依存 failure で本 PR 由来ではないことを確認済み、1512 passed)uv run --directory <worktree> --locked pytest .claude/hooks/tests/test_guard_shadow_removal.py .claude/hooks/tests/test_guard_shadow_mode.py -q(guard-japanese-prose.sh コメント変更の無回帰確認、21 passed)pnpm typecheck/pnpm lint/pnpm test(1887 passed)/pnpm builduv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py(24 passed)実行証跡(Runtime Evidence, AC3/AC4/AC5)
Runtime Verification Applicability:
decision: immediate(applicable_acs: [AC3, AC4, AC5])。worktree-local artifact に pytest 実行結果を記録しました(artifacts/は.gitignore対象のため未コミット、実行ログを以下に引用します)。artifacts/runtime-verification-AC3-20260829T044002Z.log(exit_code: 0、1 passed — stale.guard_shadow_log.jsonlが canonical preflight を妨げない)artifacts/runtime-verification-AC4-20260829T044002Z.log(exit_code: 0、fix_delta 後はtest_shadow_log_create_or_update_fails_as_generic_unauthorized_write_path[create|update]を含む 12 passed)artifacts/runtime-verification-AC5-20260829T044002Z.log(exit_code: 0、2 passed — Codex shadow writer 除去 regression)AC3 ログ抜粋:
AC4 ログ抜粋(fix_delta 後、create/update parametrize):
AC5 ログ抜粋:
SKIP / fallback 経由の成功はありません(fail-closed で production パス・real subprocess 実行)。
Schema Change Applicability
skill_runtime_exec.pyの CLI 引数契約・stdout/stderr wire format・reason code 語彙(unauthorized_write_path含む)は変更していません。削除したのは shadow-log 専用の内部 typed exact-file special case(非公開の内部関数・定数)のみで、公開 schema・関数シグネチャ・呼び出し規約の変更はありません。Schema Consumer Inventory
N/A
reason: schema_change ではないため。
Safety Claim Matrix
.guard_shadow_log.jsonlへの新規 create/update は special exception ではなく genericunauthorized_write_pathで fail-close するtest_shadow_log_create_or_update_fails_as_generic_unauthorized_write_path[create|update](実 subprocess 実行、AC4、fixture が.gitignore/git check-ignoreで legacy tombstone 条件を再現).guard_shadow_log.jsonl(無変更)は canonical preflight を妨げないtest_stale_pre_existing_shadow_log_does_not_block_preflight(実 subprocess 実行、AC3).claude/hooks/scripts、tests 除く)に shadow-log 関連ファイル・symbol・参照が case-insensitive で一切残っていないrg --hidden -n -e 'guard_shadow_log\.jsonl' .../rg -n '(?i)shadow[_-]?log' scripts/agent-guards/skill_runtime_exec.py(いずれも exit 1 = 該当なし、AC1/AC2)test_skill_runtime_exec_unauthorized_write_path.py既存 10 test 全 PASS(AC4).gitignoreの.guard_shadow_log.jsonllegacy tombstone entry は削除していない(コメント文言のみ更新)rg -n "guard_shadow_log" .gitignore(AC6)。git diff -- .gitignoreで entry 自体は無変更、コメント 1 行のみ書き換え(4 insertions / 1 deletion)であることを確認Notes
scripts/agent-guards/skill_runtime_exec.pyを含む remote protocol Git builders 変更)と対象ファイルが重複していました。feat: harden remote protocol Git builders #2381 は 2026-08-29 15:53 JST に main へマージされ、本 PR は一時mergeable: CONFLICTINGになりましたが、iteration 3 の fix_delta でorigin/mainを merge し関数単位でコンフリクト解消済みです(現在mergeable: MERGEABLE/mergeStateStatus: CLEAN)。.claude/hooks/guard-japanese-prose.shのコメント 1 行修正、および.gitignoreのコメント文言修正を Allowed Paths に追加しました(詳細は Issue 実装: .guard_shadow_log.jsonl と privileged executor の shadow-log 特例を廃止する #2252 本文の## Scope Deltaセクション参照。いずれも挙動変更なし)。224017e1→ iteration 2 fix_delta(.claude/hooks/tests/test_shadow_log.py削除)後bfa72dbf→ iteration 3 fix_delta(main コンフリクト解消 + AC4 update テスト +.gitignoreコメント修正)後5b6f577e(現行 head)。