Skip to content

実装: PreToolUse remote_write_requires_approval を publish lane 証跡で通過可能にする #1408

Closed
4 of 4 issues completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1402"
goal_ref: "Issue #1402 の agent publish lane で、検証済み publish 証跡が揃っている `rtk git push origin HEAD:refs/heads/<active-branch>` が PreToolUse の generic deny で止まらないようにする"
change_kind: workflow

Parent Issue

#1402

Parent Goal Ref

  • Goal: agent publish lane の手動介入依存を解消し、実装ブランチ publish までを bounded safety gate 内で進められるようにする
  • Desired Destination: Issue 実装: agent publish lane の手動介入依存を解消する #1402 の publish lane で PUBLISH_LANE_DECISION_V1 status: allow_retry 相当の証跡が揃ったとき、agent が PR 作成前の branch publish を完了できる状態

Current Validated Scope

  • scripts/session-recording/codex-hook-adapter.mjs の PreToolUse remote write 判定は、現状 git push を一律 remote_write_requires_approval として deny する
  • scripts/agent-guards/git_mutation_command_policy.py には classify_rtk_git_mutation 等の rtk git mutation 分類関数が存在するが、publish lane の expected/current/local/verified/declared head と allowed paths gate を比較する bounded policy は現状のコードベースには実装されていない(この head 比較 bounded policy は Issue 実装: agent publish lane の手動介入依存を解消する #1402 で仕様定義されているのみで、本 Issue 実装前時点では未実装)
  • 環境変数 LOOP_PUBLISH_EXPECTED_REMOTE_HEAD / LOOP_PUBLISH_DECLARED_PUBLISH_HEAD / LOOP_PUBLISH_VERIFIED_HEAD / LOOP_PUBLISH_ALLOWED_PATHS_GATE_STATUS は Issue 実装: agent publish lane の手動介入依存を解消する #1402 で仕様化されているが、現状のコードベースには実在しない(本 Issue の In Scope 実装で初めて具体化される想定の入力)
  • tests/session_recording/codex/test_hook_adapter.py には remote_write_requires_approval の PreToolUse fixture が存在するため、実 hook entrypoint の挙動を回帰テストできる
  • Issue 実装: agent publish lane の手動介入依存を解消する #1402 の実装 worktree では rtk git push origin HEAD:refs/heads/worktree-issue-1402-agent-publish-lane が PreToolUse: remote_write_requires_approval [command_kind=git_push] で止まり、PR 起票に進めなかった
  • .claude/hooks/worktree_scope_guard.sh は scripts/agent-guards/git_mutation_command_policy.py の publish lane 分類ロジックに依存しており、.claude/hooks/tests/test_worktree_scope_guard.py に同一 env 変数群(LOOP_PUBLISH_EXPECTED_REMOTE_HEAD 等)を使う回帰テストが既に存在する(本 Issue の実装 PR レビューで、policy 変更がこのテストを壊すことが判明した)
  • scripts/agent-guards/tests/test_shell_command_analysis.py には classify_rtk_git_mutation() のシグネチャが (command, cwd, require_active_branch_push) のまま変わらないことを保証する契約テスト(test_analyzer_does_not_change_git_mutation_command_policy_api)が存在する(本 Issue の boundary_layer パラメータ追加により、この契約テストの期待値更新が必要と判明した)

Remaining Parent Gaps

Outcome

scripts/session-recording/codex-hook-adapter.mjs と関連 policy/tests が更新され、Issue worktree 内の検証済み publish lane に限って rtk git push origin HEAD:refs/heads/<active-branch> が generic remote_write_requires_approval で止まらず、危険・不一致・直接 git push は引き続き deny されることをテストで確認できる状態。あわせて .claude/hooks/worktree_scope_guard.sh の既存 publish lane 回帰テストと、classify_rtk_git_mutation() の API 契約テスト(test_shell_command_analysis.py)との整合性が保たれている状態。

In Scope

  • PreToolUse hook entrypoint が rtk git push origin HEAD:refs/heads/<active-branch> を識別し、publish lane 証跡が揃っている場合だけ deny しない経路を追加する
  • publish lane 証跡は LOOP_PUBLISH_EXPECTED_REMOTE_HEAD / LOOP_PUBLISH_DECLARED_PUBLISH_HEAD / LOOP_PUBLISH_VERIFIED_HEAD / LOOP_PUBLISH_ALLOWED_PATHS_GATE_STATUS、または既存 policy と同等の構造化入力から取得する
  • publish lane 判定は scripts/agent-guards/git_mutation_command_policy.py の bounded policy を再利用または同一条件へ集約し、PreToolUse hook adapter 側に別実装の安全判定を増やさない
  • stale remote head、local head mismatch、mixed head contamination、allowed paths gate failure は PUBLISH_SAFETY_STOP_REPORT_V1 相当の structured reason を返して deny する
  • git push 直接実行、git -C <dir> push、force/tag/all/delete/mirror push は deny を維持する
  • hook adapter / policy / docs の境界を更新し、feat: implementation-worker SubAgent に push destination guard hook を追加する #360 の destination guard と本 Issue の publish lane approval bridge の責務差分を明記する
  • 実 hook entrypoint を通る regression test を追加・更新する
  • scripts/agent-guards/git_mutation_command_policy.py の publish lane 判定ロジック変更が .claude/hooks/worktree_scope_guard.sh の既存 publish lane 回帰テスト(.claude/hooks/tests/test_worktree_scope_guard.py)と整合するよう、必要な範囲で worktree_scope_guard.sh 側を修正する
  • classify_rtk_git_mutation() への boundary_layer パラメータ追加を、scripts/agent-guards/tests/test_shell_command_analysis.py::test_analyzer_does_not_change_git_mutation_command_policy_api の期待シグネチャに反映する(意図した API 拡張であることを契約テストの期待値更新として明示する。この関数のシグネチャ以外の契約・呼び出し側ロジックは変更しない)

Out of Scope

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 本 Issue の検証は scripts/session-recording/codex-hook-adapter.mjs の PreToolUse 判定ロジックと scripts/agent-guards/git_mutation_command_policy.py の bounded policy、.claude/hooks/worktree_scope_guard.sh、および scripts/agent-guards/tests/test_shell_command_analysis.py の API 契約テストに対する pytest ユニットテスト(tests/session_recording/codex/test_hook_adapter.py / scripts/agent-guards/tests/test_git_mutation_command_policy.py / .claude/hooks/tests/test_worktree_scope_guard.py / scripts/agent-guards/tests/test_shell_command_analysis.py)と docs 記述確認(rg)のみで完結し、実プロセス起動・実ネットワーク通信・実 GitHub remote への実際の push 実行を伴わない。したがって静的検証(unit test / lint 相当)のみで AC を検証でき、runtime-verification: true タグ付き動作検証 AC は不要と判定する。

Acceptance Criteria

  • AC1: rtk git push origin HEAD:refs/heads/<active-branch> かつ publish lane 証跡が一致する PreToolUse payload では、hook adapter が generic remote_write_requires_approval deny を返さない
  • AC2: 直接 git push / git -C <dir> push / wrapper bypass は引き続き deny され、理由に direct_bypass_requires_rtk または remote_write_requires_approval 相当の機械可読 reason が残る
  • AC3: expected/current/local/verified/declared head の不一致、または LOOP_PUBLISH_ALLOWED_PATHS_GATE_STATUS != ok では deny され、PUBLISH_SAFETY_STOP_REPORT_V1 相当の reason に boundary_layer / reason_code / head 比較値 / required decision が含まれる
  • AC4: force/tag/all/delete/mirror push は publish lane 証跡があっても deny される
  • AC5: scripts/session-recording/codex-hook-adapter.mjs の実 entrypoint を通る tests が positive lane と negative lane の両方を検証する
  • AC6: docs は feat: implementation-worker SubAgent に push destination guard hook を追加する #360 の destination guard と本 Issue の publish lane approval bridge の責務差分を、"publish lane approval bridge" という語句で明記する
  • AC7: .claude/hooks/tests/test_worktree_scope_guard.py の既存 publish lane 回帰テストが全て pass する
  • AC8: scripts/agent-guards/tests/test_shell_command_analysis.py が全て pass する(classify_rtk_git_mutation() の期待シグネチャに boundary_layer を含めて更新済み)

Verification Commands

# baseline-expect: pass
$ python3 -m pytest tests/session_recording/codex/test_hook_adapter.py # AC1
# baseline-expect: pass
$ python3 -m pytest tests/session_recording/codex/test_hook_adapter.py # AC2
# baseline-expect: pass
$ python3 -m pytest tests/session_recording/codex/test_hook_adapter.py # AC3
# baseline-expect: pass
$ python3 -m pytest scripts/agent-guards/tests/test_git_mutation_command_policy.py # AC4
# baseline-expect: pass
$ python3 -m pytest tests/session_recording/codex/test_hook_adapter.py # AC5
$ rg -n "publish lane approval bridge" docs/dev/session-recording-policy.md docs/dev/agent-runtime-ops.md docs/dev/hook-boundaries.md docs/dev/workflow.md docs/dev/agent-skill-boundaries.md # AC6
# baseline-expect: pass
$ python3 -m pytest .claude/hooks/tests/test_worktree_scope_guard.py # AC7
# baseline-expect: pass
$ python3 -m pytest scripts/agent-guards/tests/test_shell_command_analysis.py # AC8

Allowed Paths

  • scripts/session-recording/codex-hook-adapter.mjs
  • tests/session_recording/codex/test_hook_adapter.py
  • scripts/agent-guards/git_mutation_command_policy.py
  • scripts/agent-guards/tests/test_git_mutation_command_policy.py
  • scripts/agent-guards/hook_repair_hints.py
  • docs/dev/session-recording-policy.md
  • docs/dev/agent-runtime-ops.md
  • docs/dev/hook-boundaries.md
  • docs/dev/workflow.md
  • docs/dev/agent-skill-boundaries.md
  • .claude/hooks/worktree_scope_guard.sh
  • .claude/hooks/tests/test_worktree_scope_guard.py
  • scripts/agent-guards/tests/test_shell_command_analysis.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合(ただし classify_rtk_git_mutation() への boundary_layer 追加とそれに伴う契約テスト期待値更新は本 Scope Delta で明示的に許可済み)
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • Codex runtime 本体の承認モデル変更が必要と判明した場合
  • rtk git push origin HEAD:refs/heads/<active-branch> 以外の remote write 許可が必要と判明した場合
  • worktree_scope_guard.sh の scope guard 本体ロジック(publish lane 判定以外)の変更が必要と判明した場合
  • test_shell_command_analysis.py の analyzer 本体ロジック(classify_rtk_git_mutation API契約以外)の変更が必要と判明した場合

Required Skills

  • JavaScript / Node.js hook adapter
  • Python / pytest
  • Git refspec と publish safety policy
  • Bash hook script (worktree_scope_guard.sh)

Required Design References

Delivery Rule

Scope Delta(任意)

  • 発生理由1: PR feat: PreToolUse remote_write_requires_approval を publish lane 証跡で通過可能にする #1442 の人間によるアドバーサリアルセキュリティレビュー(P1/P2指摘、コメントURL: https://github.com/squne121/loop-protocol/pull/1442#issuecomment-4941989903)への fix_delta 対応(scripts/agent-guards/git_mutation_command_policy.py の publish lane 判定変更)が、CI上で .claude/hooks/tests/test_worktree_scope_guard.py の既存 publish lane 回帰テスト2件を破壊することが判明した。
    • 追加された Allowed Paths: .claude/hooks/worktree_scope_guard.sh, .claude/hooks/tests/test_worktree_scope_guard.py
    • 追加された AC: AC7(.claude/hooks/tests/test_worktree_scope_guard.py 全pass)
    • 追加された Verification Commands: AC7 用の pytest .claude/hooks/tests/test_worktree_scope_guard.py
    • スコープ境界: worktree_scope_guard.sh の scope guard 本体ロジック(publish lane 判定以外の部分)は変更しない。あくまで policy 側の変更に追従させる整合性修正のみ。
  • 発生理由2: iteration5(main との conflict resolve)後、CI上で scripts/agent-guards/tests/test_shell_command_analysis.py::test_analyzer_does_not_change_git_mutation_command_policy_api が、classify_rtk_git_mutation() への boundary_layer パラメータ追加(発生理由1の fix_delta で追加済み)と衝突して fail することが判明した。
    • 追加された Allowed Paths: scripts/agent-guards/tests/test_shell_command_analysis.py
    • 追加された AC: AC8(scripts/agent-guards/tests/test_shell_command_analysis.py 全pass)
    • 追加された Verification Commands: AC8 用の pytest scripts/agent-guards/tests/test_shell_command_analysis.py
    • スコープ境界: classify_rtk_git_mutation() の API シグネチャ変更(boundary_layer 追加)は意図した拡張として契約テストの期待値のみ更新する。test_shell_command_analysis.py が検証する analyzer 本体のロジックは変更しない。

Sub-issues

Sub-issues

4 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    triage-required
    on Jul 9, 2026
  2. squne121 commented on Jul 9, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    #1408 は必要な方向です。現状の codex-hook-adapter.mjs は git push を remote_write_requires_approval として一律分類し、PreToolUse では no_decision 相当の結果も実際には deny として返すため、rtk git push origin HEAD:refs/heads/<active-branch> も止まります。#1408 の目的自体はこの実装実態と整合しています。

    ただし、Issue 本文のまま実装すると「generic deny の穴あけ」になりやすい。既存の共有 rtk git policy は、push について origin、HEAD:refs/heads/<branch>、禁止 flag、active branch 一致までは見る一方、#1402 で要求されている remote head drift、local/declared/reviewed head mismatch、Allowed Paths gate、post-push readback は見ていません。

    最大の問題は、#1408 が「PreToolUse の deny を通過可能にする」Issueであるのに、実際に必要なのは「publish lane 用の条件付き remote write authorization」です。これは分類の例外ではなく、安全性を証明できる narrow mutation lane です。


    確認した関連資産

    #1408 は #1402 の子 Issue で、#1402 は #1399 の publish 失敗・remote head drift・manual branch update を背景にしています。#1408 本文も、LOOP_PUBLISH_EXPECTED_REMOTE_HEAD、LOOP_PUBLISH_DECLARED_PUBLISH_HEAD、LOOP_PUBLISH_VERIFIED_HEAD、LOOP_PUBLISH_ALLOWED_PATHS_GATE_STATUS 相当の証跡が揃った場合のみ rtk git push origin HEAD:refs/heads/<active-branch> を通す、という要求を書いています。

    #360 は別系統の destination guard で、main/master への push を防ぐ防御層です。#1408 はこれを置き換えてはいけません。#360 の目的は、過去に git push origin main が実行され main に直 push された事故を受け、main/master destination を block することです。

    リポジトリ文書上も、Codex の同一 event に対する複数 hook は concurrent に起動され、実行順序や short-circuit は保証されないため、各 handler が独立して fail-closed 判定を返す必要があります。つまり「worktree_scope_guard が後で守るから session-recording 側は雑に allow」は不可です。


    Blocker 1: adapter 側に JS regex で publish allow を直実装してはいけない

    現在の adapter は \bgit ... push\b の regex で remote write を検出します。この regex は rtk git push ... 内の git push にも反応します。

    ここに if command.includes("rtk git push") && envOK then allow のような実装を足すと、既存の shlex ベース policy と split-brain になります。既存の git_mutation_command_policy.py は意図的に narrow policy として rtk git add/commit/push だけを認識する設計なので、publish lane もこの Python policy 側に寄せるべきです。

    修正要求: codex-hook-adapter.mjs は policy decision consumer に留める。判定本体は scripts/agent-guards/git_mutation_command_policy.py または同ディレクトリの専用 policy module に集約し、Node から JSON stdin で呼び出す。判定不能・policy 実行失敗・証跡不足はすべて既存の remote_write_requires_approval deny にフォールバックする。


    Blocker 2: 既存 bounded push policy は publish lane の安全条件を満たしていない

    既存 push policy は、禁止 flag、origin、refspec shape、branch 名 regex、active branch 一致を見ます。これは「危険な push shape を絞る」には有効ですが、「この push が #1402/#1408 の verified publish lane である」ことは証明しません。

    Git の push は remote ref を更新する操作で、refspec の + は --force と同義、空 src は remote ref delete、--all は全 branch、--mirror は refs 全体の mirror/force/delete を含みます。したがって publish lane は exact argv だけでなく、refspec の破壊的形も明示的に deny すべきです。([Git]1)

    また Git は branch destination では fast-forward update のみを通常許可し、non-fast-forward は履歴喪失になりうるため拒否します。--force はその安全チェックを無効化し remote repository の commit 喪失を起こし得るため、#1408 の lane では --force, +refspec, --force-with-lease も含めて不許可に固定すべきです。([Git]1) ([Git]1)

    修正要求: publish lane policy の allow 条件は最低限これです。

    allow iff:
      command_argv_exact:
        - rtk
        - git
        - push
        - origin
        - HEAD:refs/heads/<active_branch>
      active_branch == target_branch
      target_branch not in ["main", "master"]
      forbidden_forms_absent:
        - --force
        - -f
        - --force-with-lease
        - --tags
        - --all
        - --mirror
        - --delete
        - -d
        - +<refspec>
        - ":<dst>"
        - tag <name>
        - multiple refspecs
        - wildcard or matching refspec
      allowed_paths_gate_status == "ok"
      expected_remote_head == current_remote_head
      local_head == declared_publish_head
      local_head == verified_head

    Blocker 3: remote head は env だけではなく fresh read が必要

    #1408 は env key または structured input を許容していますが、current_remote_head を env で渡すだけだと stale です。#1402 の失敗背景は remote head drift なので、通過直前に remote を読み直す必要があります。git ls-remote は remote repository の refs と対応 commit ID を表示するコマンドで、branch ref の現値確認に使えます。([Git]2)

    GitHub REST API の Get a branch でも branch の commit.sha は取得できますが、hook 内で GitHub API を使う場合は gh CLI の -f/--field が payload parameter 追加時に POST に切り替わる仕様に注意が必要です。read-only のつもりで gh api -f ... を使うと write-method になり得るため、remote read は git ls-remote --exit-code origin refs/heads/<branch> を第一候補にするのが安全です。([GitHub Docs]3) ([GitHub Docs]3) ([GitHub CLI]4)

    修正要求: policy は expected_remote_head と fresh current_remote_head を比較する。fresh read 不可は current_remote_head_unavailable で safety stop。env の LOOP_PUBLISH_EXPECTED_REMOTE_HEAD は「期待値」であって「現値」ではない、という扱いにする。


    Blocker 4: post-push readback がないと「許可」は完結しない

    PreToolUse は push 実行前の gate です。push 後に remote branch が本当に local_head へ進んだことは、PreToolUse だけでは確認できません。Git push output には machine-readable な --porcelain 形式があり、push status は成功・強制更新・delete・reject などを区別できますが、最終的な remote ref の証明には push 後の remote readback が必要です。([Git]1)

    修正要求: #1408 の完了条件に次を追加する。

    post_publish_readback:
      command: git ls-remote --exit-code origin refs/heads/<active_branch>
      required: remote_head_after_push == local_head
      failure_reason_code:
        - post_publish_readback_failed
        - post_publish_remote_head_mismatch

    PreToolUse 内で postcondition を実行できないなら、PUBLISH_LANE_DECISION_V1 に required_postcondition を出し、実際の publish workflow 側で readback を必須化する。readback が別 Issue に逃げる場合、#1408 は「allow bridge のみ」であり「publish lane 完成」とは言えません。


    Blocker 5: Hook output / boundary_layer の taxonomy が足りない

    remote_write_requires_approval は現在、PreToolUse では deny、PermissionRequest では no output/no_decision というイベント別挙動になっています。

    #1408 で追加する reason は、単なる remote_write_requires_approval の変種ではなく、少なくとも boundary_layer を持つべきです。Claude hook の仕様でも、PreToolUse の blocking は exit code 2 / hook output により tool call を止める性質を持つため、どの layer が止めたのかを診断できないと agent が誤復旧します。([Claude Platform Docs]5)

    推奨 schema:

    PUBLISH_LANE_DECISION_V1:
      status: allow | safety_stop
      boundary_layer: codex_pretooluse_publish_lane_bridge
      reason_code: publish_lane_verified
      command_class: rtk_git_push
      remote: origin
      target_ref: refs/heads/<active_branch>
      active_branch: <active_branch>
      expected_remote_head: <sha>
      current_remote_head: <sha>
      local_head: <sha>
      declared_publish_head: <sha>
      verified_head: <sha>
      allowed_paths_gate_status: ok
      required_postcondition: remote_head_after_push == local_head
    PUBLISH_SAFETY_STOP_REPORT_V1:
      status: safety_stop
      boundary_layer: codex_pretooluse_publish_lane_bridge
      reason_code:
        one_of:
          - unsafe_push_shape
          - direct_bypass_requires_rtk
          - wrapper_bypass_denied
          - destination_guard_denied
          - current_remote_head_unavailable
          - stale_remote_head
          - local_head_mismatch
          - declared_publish_head_mismatch
          - verified_head_mismatch
          - allowed_paths_gate_failed
          - active_branch_mismatch
      redaction:
        raw_command: omitted
        secret_like_values: omitted
      safe_action: stop_and_request_human_decision

    Blocker 6: repair hint が危険に弱い

    hook_repair_hints.py の push_refspec_requires_active_branch は、rtk git push origin HEAD:refs/heads/<active-branch> と git branch --show-current しか示しません。

    これは #1241 の bounded shape 修復には十分でも、#1402/#1408 の stale remote head / mixed contamination には不十分です。git branch --show-current だけでは remote head drift も Allowed Paths provenance も検出できません。

    修正要求: #1408 では push_refspec_requires_active_branch を再利用して publish stop を表現しない。新 reason を追加する。

    stale_remote_head:
      safe_action: "push せず remote/current/local/verified head を再照合する"
      suggested_command: "git ls-remote --exit-code origin refs/heads/<active-branch>"
      verification_command: "git rev-parse HEAD && git ls-remote --exit-code origin refs/heads/<active-branch>"
      stop_condition: "expected/current/local/verified が一致しない場合は人間判断"

    Blocker 7: open-pr は publish lane ではない

    open-pr skill は PR body validator、linked issue state、idempotency、gh pr create を担当します。branch publish そのものは実装しておらず、gh pr create failure 時は E_GH_FAILURE を返すだけです。

    したがって #1408 の docs で open-pr を publish lane の主体に見せると責務境界が崩れます。必要なら open_pr.py ではなく、publish lane 専用 wrapper / policy / workflow step を作るべきです。


    実装案

    最小で安全にするなら、次の 3 層に分けるべきです。

    1. Policy layer: scripts/agent-guards/git_mutation_command_policy.py に classify_publish_lane_push(...) を追加する。ここで exact argv、禁止 refspec、active branch、destination guard、fresh remote head、local/declared/verified head、Allowed Paths gate を判定する。Python の subprocess は shell を暗黙起動せず、argv sequence を渡せば shell metacharacter を shell 解釈させないので、policy 内の git 呼び出しは必ず subprocess.run([...], shell=False, timeout=...) にする。([Python documentation]6)

    2. Codex adapter layer: codex-hook-adapter.mjs は remote write 分類の直前に policy executable を呼ぶ。結果が allow なら stdout 無しで通過、safety_stop なら PreToolUse deny。policy error / timeout / malformed result は generic remote_write_requires_approval deny に戻す。execFileSync を使う場合も shell string にせず、process.execPath と script argv の配列呼び出しに限定する。

    3. Workflow/postcondition layer: push 後に git ls-remote --exit-code origin refs/heads/<branch> を再実行し、remote head が local_head と一致することを PUBLISH_POST_PUSH_READBACK_V1 として残す。PreToolUse だけで publish 成功を主張しない。


    最小テストマトリクス

    tests/session_recording/codex/test_hook_adapter.py には、actual Node entrypoint を叩く run_adapter が既にあるため、#1408 の AC5 はここで満たすべきです。

    追加すべきテスト:

    positive:
    - PreToolUse + exact rtk git push + all publish evidence match -> stdout empty / no deny
    - PermissionRequest + exact rtk git push + all evidence match -> no deny / no stdout
    - worktree_scope_guard + exact rtk git push + issue/worktree/cwd valid -> allow
    
    negative command shape:
    - git push origin branch -> deny remote_write_requires_approval
    - git -C . push origin branch -> deny
    - bash -lc 'rtk git push ...' -> deny wrapper_bypass_denied
    - env FOO=bar rtk git push ... -> deny unless policy explicitly supports env prefix; safer default deny
    - rtk git push upstream HEAD:refs/heads/x -> deny
    - rtk git push origin main -> deny / destination_guard_denied
    - rtk git push origin HEAD:refs/heads/main -> deny / destination_guard_denied
    - rtk git push origin HEAD:refs/heads/x --force -> deny
    - rtk git push origin +HEAD:refs/heads/x -> deny
    - rtk git push --tags origin HEAD:refs/heads/x -> deny
    - rtk git push --all origin -> deny
    - rtk git push --mirror origin -> deny
    - rtk git push origin :refs/heads/x -> deny
    
    negative evidence:
    - missing expected_remote_head -> safety_stop
    - fresh current_remote_head != expected_remote_head -> stale_remote_head
    - local_head != declared_publish_head -> local_head_mismatch
    - local_head != verified_head -> verified_head_mismatch
    - allowed_paths_gate_status != ok -> allowed_paths_gate_failed
    - current branch != target branch -> active_branch_mismatch
    - git ls-remote timeout/error/no ref -> current_remote_head_unavailable
    
    postcondition:
    - push allowed but readback != local_head -> post_publish_remote_head_mismatch
    - push rejected by remote -> post_publish_readback_failed
    

    既存 tests は direct git push と git -C ... push の deny を確認していますが、positive publish lane と mismatch safety stop は未実装です。


    Definition of Done

    #1408 を通してよい条件は次です。

    1. codex-hook-adapter.mjs に独自 JS allowlist を作らず、共有 policy の JSON decision を消費するだけにする。
    2. rtk git push origin HEAD:refs/heads/<active-branch> 以外はすべて deny。
    3. main / master / force / tags / all / mirror / delete / + refspec / wrapper / direct git は deny。
    4. fresh remote head を git ls-remote 等で取得し、expected_remote_head == current_remote_head を必須化する。
    5. local_head == declared_publish_head == verified_head と allowed_paths_gate_status == ok を必須化する。
    6. PUBLISH_LANE_DECISION_V1 と PUBLISH_SAFETY_STOP_REPORT_V1 を machine-readable に出す。
    7. push 後 readback を別 layer で必須化し、PreToolUse だけで publish 成功を主張しない。
    8. feat: implementation-worker SubAgent に push destination guard hook を追加する #360 の destination guard と 実装: PreToolUse remote_write_requires_approval を publish lane 証跡で通過可能にする #1408 の publish bridge の責務分離を docs に明記する。
    9. actual Codex adapter entrypoint、shared policy unit、worktree guard parity の 3 系統で positive / negative tests を持つ。

    現状の #1408 は「実装すべきだが、Issue 本文をもう一段強くしないと危険」です。特に fresh remote head と post-push readback が入らない実装は、#1402 で問題になった remote drift / mixed contamination を再発させます。

  3. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "scope_signal_guard_triggered"
    
    "scope_signal_guard_reason_code:new_allowed_path_layer"
    
  4. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    妥当

  5. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    注意: これはエージェントによる代理投稿です。

    以下は OWNER squne121 が #1408 (comment) (本文: 「妥当」、投稿時刻: 2026-07-10T11:53:20Z、authorAssociation: OWNER。Claude Code control-plane 自身の gh 認証で直接取得・検証済み)で示した scope 拡張の承認意思表示を、issue-refinement-loop の ANCHOR_SCOPE_REFRAME_V1 スキーマに従って機械可読形式で記録するものです。この投稿自体は squne121 本人が書いたものではなく、Claude Code エージェントが承認内容を構造化形式で転記した代理記録です。

    schema_version: ANCHOR_SCOPE_REFRAME_V1
    target:
      repo: squne121/loop-protocol
      issue_number: 1408
    decision: approve_scope_delta
    allowed_path_deltas:
      - "scripts/agent-guards/"
      - "scripts/session-recording/"
      - "tests/session_recording/"
      - "docs/dev/"
    rationale: "OWNER squne121 が https://github.com/squne121/loop-protocol/issues/1408#issuecomment-4934995698 (本文: 妥当、created_at: 2026-07-10T11:53:20Z)で承認。scope_signal_guard が検知した new_allowed_path_layer は、Allowed Paths に scripts/ と tests/ と docs/ の複数トップレベル層が並存することを指し、これは Issue #1408 作成当初から存在する構成であり refinement loop の rewrite による新規追加ではない。OWNER はこの複数層構成を Issue の意図したスコープとして妥当と確認した。"
    required_rerun:
      - contract_review
      - refinement_preflight
      - allowed_paths_gate
  6. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

    LOOP_HANDOFF_RESULT_V1:
      status: blocked
      routing_action: blocked
      contract_review:
        status: blocked
        gate_result: missing_go
        latest_comment_url: ''
        generated_at: '2026-07-10T12:02:29Z'
        body_sha256: sha256:761694d84e2971404376c7697ef994a170ef721776ea8ca2905bc9e1aa4d3d4b
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: blocked
        required: []
        skipped: []
      blockers:
      - kind: contract_review_not_run
        description: issue-contract-review has not been executed for this issue yet; implementation
          handoff readiness (fresh_go) is not established. issue-refinement-loop itself
          has approved the issue body contract quality.
      permissions:
        unavailable: []
      generated_at: '2026-07-10T12:02:29Z'
      checked_body_sha256: sha256:761694d84e2971404376c7697ef994a170ef721776ea8ca2905bc9e1aa4d3d4b
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
  7. squne121 commented on Jul 11, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-11T01:34:40Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1408
      body_sha256: "sha256:bdcc41a74aa717cec0b19e9a8993661c73a31f6b69a0ac9a5f89a64f07f8d719"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  8. added a commit that references this issue on Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions