Repository navigation
fix(guards): split branch-safe maintenance telemetry (#1075) - #1079
Conversation
local_main_branch_guard の readonly classifier と branch-safe maintenance telemetry を分離し、git fetch / git worktree prune が readonly_command に畳み込まれないようにする。\n\n合わせて hook_flavor parity、pipeline fail-closed、result schema compatibility の targeted regression を追加する。
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-1079/ The preview will be removed when this PR is closed. |
判定結論: Issue #1075 の契約上は APPROVE 寄り。ただし、merge 前に 2 点だけ追補すると品質が上がります。 CI は head SHA 良い点PR は anchor comment の主要求をかなり正確に満たしています。 実装後の 評価順も妥当です。readonly allow の後に branch-safe maintenance allow を置き、 テストも契約の中心は押さえています。 非ブロッカーだが直したい点1.
|
…ormalize-branch-safe-classifier-telemet
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: "92be8a3b2a8a14ab9119ce58b16a3f87673ae934"
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
expected_contract_fingerprint: "sha256:2536dc1e713913bd6da0c18f0a28ee1ebb0474b01175f84efcf3ae84d9e64f19"
contract_source_kind: issue_comment_snapshot
contract_source_id: "issuecomment-4761002290"
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files:
- .claude/hooks/tests/test_local_main_branch_guard.py
- scripts/agent-guards/local_main_branch_guard.py
allowed_paths_gate_source: review_subagent判定根拠:
Closes #1075があり、linked issue contract の AC/Allowed Paths/VC と整合しています。- changed files は issue contract の Allowed Paths 2件に一致し、Allowed Paths gate は
okです。 DISPLAY_READONLY_PATTERNSとBRANCH_SAFE_MAINTENANCE_PATTERNSの分離、readonly_commandからの telemetry 分離、readonly pipeline fail-closed 回帰、schema key/value type 不変回帰が diff と PR本文で確認できました。ci_verdict_summary.py --pr 1079 --expected-head-sha 92be8a3b2a8a14ab9119ce58b16a3f87673ae934はstatus: all_pass、stale/pending/failed checks はありません。- PR本文には
Schema Change Applicability/Schema Consumer Inventory/Safety Claim Matrixがあり、schema additive change と safety claim の記述も contract と矛盾しません。
Summary
local_main_branch_guard.pyで display read-only と branch-safe maintenance を別 classifier に分離し、git fetch/git worktree pruneがreadonly_commandではなくbranch_safe_maintenance_commandを返すようにしました。git fetch | head -n 1とgit worktree prune | head -n 1が fail-closed のままになる回帰を追加しました。.claude/hooks側に hook flavor parity、readonly parity、schema compatibility に加えて fetch variants 意図固定と drifted root telemetry の named regression test を追加し、既存 Codex parity test も追加変更なしで通ることを確認しました。受け入れ条件の達成状況
scripts/agent-guards/local_main_branch_guard.pyに distinct reason code としてbranch_safe_maintenance_commandを追加しました。git fetchとgit worktree pruneは allow のままbranch_safe_maintenance_commandを返します。git status、git diff --stat、git log、git worktree listは引き続きreadonly_commandを返します。git fetch | head -n 1とgit worktree prune | head -n 1は readonly pipeline に分類されず fail-closed のままです。.claude側 full pytest も PASS しました。検証コマンド結果
以下のコマンドで issue contract の VC と追加回帰確認を実施し、すべて成功しました。
rg -n 'branch_safe_maintenance' scripts/agent-guards/local_main_branch_guard.pyrg -n 'branch_safe_maintenance' .claude/hooks/tests/test_local_main_branch_guard.pyrg -n 'readonly_parity' .claude/hooks/tests/test_local_main_branch_guard.pyrg -n 'pipeline_fail_closed' .claude/hooks/tests/test_local_main_branch_guard.pyuv run pytest .claude/hooks/tests/test_local_main_branch_guard.py -q -k "branch_safe_maintenance or readonly_parity or pipeline_fail_closed or hook_flavor_parity or result_schema_compatibility"結果:
24 passed, 113 deselectedrg -n 'result_schema_compatibility' .claude/hooks/tests/test_local_main_branch_guard.pyuv run pytest .claude/hooks/tests/test_local_main_branch_guard.py -q結果:
137 passeduv run pytest tests/codex/test_local_main_branch_guard.py -q結果:
22 passed in 0.44spython3 -m py_compile scripts/agent-guards/local_main_branch_guard.pyAllowed Paths 遵守
scripts/agent-guards/local_main_branch_guard.pyと.claude/hooks/tests/test_local_main_branch_guard.pyの 2 件のみです。tests/codex/test_local_main_branch_guard.pyは read-only 確認対象として参照しましたが、変更していません。Checks
以下は PR テンプレ必須の checks 要約で、実行済みコマンドをそのまま再掲しています。
rg -n 'branch_safe_maintenance' scripts/agent-guards/local_main_branch_guard.pyrg -n 'branch_safe_maintenance' .claude/hooks/tests/test_local_main_branch_guard.pyrg -n 'readonly_parity' .claude/hooks/tests/test_local_main_branch_guard.pyrg -n 'pipeline_fail_closed' .claude/hooks/tests/test_local_main_branch_guard.pyuv run pytest .claude/hooks/tests/test_local_main_branch_guard.py -q -k "branch_safe_maintenance or readonly_parity or pipeline_fail_closed or hook_flavor_parity or result_schema_compatibility"rg -n 'result_schema_compatibility' .claude/hooks/tests/test_local_main_branch_guard.pyuv run pytest .claude/hooks/tests/test_local_main_branch_guard.py -quv run pytest tests/codex/test_local_main_branch_guard.py -qpython3 -m py_compile scripts/agent-guards/local_main_branch_guard.pySchema Change Applicability
この PR は shared guard の telemetry enum を additive に拡張するため、schema change として扱います。
schema_changeLOCAL_MAIN_BRANCH_GUARD_RESULT_V1.reason_codeにbranch_safe_maintenance_commandを追加し、shared guard の machine-readable telemetry enum を拡張したためです。Schema Consumer Inventory
この PR は key set や value type を変えず、
reason_codeenum に additive な値を 1 つ追加します。既存 consumer がreadonly_commandと混同しないことを regression で固定し、未変更 consumer については影響有無を確認しました。変更対象 schema:
LOCAL_MAIN_BRANCH_GUARD_RESULT_V1.reason_codebefore/after 差分:
Consumer 列挙(hidden path を含む rg コマンド例と結果):
Consumer 更新状況:
scripts/agent-guards/local_main_branch_guard.py.claude/hooks/tests/test_local_main_branch_guard.pytests/codex/test_local_main_branch_guard.pygit fetch/git worktree pruneの reason_code を固定しておらず、既存 parity test は変更なしで PASSCompatibility Decision / 互換性判断
互換性判断は次のとおりで、既存 consumer を壊さない additive change に限定しています。
additive(enum 値の追加のみ)backward_compatible(既存 key set / value type は不変)no(移行作業は不要)N/A(追加の migration issue は不要)reason_codeenum の追加のみで、LOCAL_MAIN_BRANCH_GUARD_RESULT_V1の key set / value type は不変です。既存readonly_commandconsumer を誤って壊さないことは.claude/hooks/tests/test_local_main_branch_guard.pyの schema compatibility 回帰で確認しています。Safety Claim Matrix
この PR は安全境界の設定変更ではなく telemetry 分類の修正に限定されるため、主張は 1 行に絞って記載します。
uv run pytest .claude/hooks/tests/test_local_main_branch_guard.py -q、uv run pytest tests/codex/test_local_main_branch_guard.py -qNotes
Closes #1075として、この follow-up を自動 close 対象にします。