Skip to content

実装: git ref/worktree probe を script 化し、shell quoting と compound command 起因の迷走を削減する #1197

Closed
1 of 1 issue completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "高頻度の git read-only probe を script 化し、shell quoting 事故と guard noise を減らす"
change_kind: workflow

Parent Issue

none

Parent Goal Ref

  • Goal: 高頻度の git read-only probe を script 化し、shell quoting 事故と guard noise を減らす
  • Desired Destination: branch / worktree の read-only probe を shell format 文字列や compound command なしで実行でき、post-merge-cleanup などの手順から raw shell probe が減っている状態

Current Validated Scope

  • scripts/agent-ops/git_ref_probe.py と scripts/agent-ops/git_worktree_probe.py を追加する
  • git_worktree_probe.py は既存 scripts/agent-ops/worktree_catalog.py を SSOT として再利用する
  • post-merge-cleanup skill・rule・guard docs を probe script 前提に更新する
  • deterministic checker allow と probe script 用テストを追加する

Remaining Parent Gaps

  • hook failure transcript noise compaction は別 Issue で扱う
  • instruction surface audit や retro index 集約は別 Issue で扱う

Outcome

branch / remote-tracking ref / worktree catalog の read-only 確認が Python probe script の JSON 出力に置き換わり、shell quoting や compound command に依存した raw git probe を post-merge-cleanup 周辺の正本手順から排除できている状態。

In Scope

  • git_ref_probe.py と git_worktree_probe.py の新規追加
  • git_worktree_probe.py から worktree_catalog.py の parser / schema を再利用する
  • skill / rule / docs から raw git for-each-ref や raw git worktree list --porcelain の shell 例を probe script に置換する
  • guard 側の deterministic checker allow と pytest fixture 追加

Out of Scope

  • git mutation の script 化
  • git branch -d/-D や git worktree remove の executor 化
  • arbitrary shell passthrough の許可
  • hook transcript noise compaction や resume capsule の実装

Acceptance Criteria

  • AC1: post-merge-cleanup skill の read-only probe 手順から raw git for-each-ref / raw git worktree list --porcelain の shell 使用例が削除され、scripts/agent-ops/git_ref_probe.py / scripts/agent-ops/git_worktree_probe.py 呼び出しへ置き換わる
  • AC2: git_ref_probe.py は GIT_REF_PROBE_RESULT_V1 JSON を stdout に 1 object のみ出力し、少なくとも branch, local.exists, local.ref, local.oid, remote.mode, remote.ref, remote.exists, remote.oid, upstream.configured, upstream.track, errors を返す。remote.mode は origin_branch または configured_upstream のどちらかに固定され、実装・docs・tests で同一意味を持つ
  • AC3: git_worktree_probe.py は scripts/agent-ops/worktree_catalog.py の parser / catalog schema を再利用し、GIT_WORKTREE_PROBE_RESULT_V1 JSON を stdout に 1 object のみ出力する。entries は既存 WORKTREE_CATALOG_ENTRY_V1 と互換で、少なくとも worktree_realpath, branch_ref, head, detached, exists_on_disk を扱える
  • AC4: probe scripts は stdout JSON-only、stderr 最大 5 行、raw command / env / secret-like absolute path を stderr に出さない。Git subprocess は shell=False の argv list、capture_output=True、timeout 付きで実行する
  • AC5: pytest fixture / 回帰テストとして少なくとも local branch exists/missing、remote-tracking exists/missing、configured upstream missing or gone、detached worktree、path with whitespace、invalid branch name を追加する
  • AC6: .claude/hooks/worktree_scope_guard.py と scripts/agent-guards/local_main_branch_guard.py が uv run python3 scripts/agent-ops/git_ref_probe.py --branch main --json および uv run python3 scripts/agent-ops/git_worktree_probe.py --json を deterministic checker として許可し、unknown flag / duplicate flag / --flag=value / extra positional / shell metachar / wrapper / newline chain / bare git mutation は引き続き deny する。検証は dedicated contract test で両 guard の parity を確認できる
  • AC7: AGENTS.md / .claude/rules/project-constitution.md / docs/dev/hook-boundaries.md / .claude/skills/post-merge-cleanup/SKILL.md が「複雑な git read-only probe は script 優先」「hook は fail-closed local guardrail であり security boundary ではない」という方針に整合する

Verification Commands

# AC1
$ uv run pytest tests/agent_ops/test_probe_docs_contract.py -k post_merge_cleanup

# AC2
$ uv run pytest tests/agent_ops/test_git_ref_probe.py -k json_contract

# AC3
$ uv run pytest tests/agent_ops/test_git_worktree_probe.py -k json_contract

# AC4
$ uv run pytest tests/agent_ops/test_git_ref_probe.py -k stderr

# AC5
$ uv run pytest tests/agent_ops/test_git_ref_probe.py -k fixtures

# AC6
$ uv run pytest tests/agent_ops/test_probe_guard_contract.py -k deterministic_checker

# AC7
$ uv run pytest tests/agent_ops/test_probe_docs_contract.py -k policy_alignment

Allowed Paths

  • scripts/agent-ops/git_ref_probe.py
  • scripts/agent-ops/git_worktree_probe.py
  • scripts/agent-ops/worktree_catalog.py
  • .claude/skills/post-merge-cleanup/SKILL.md
  • .claude/rules/project-constitution.md
  • AGENTS.md
  • docs/dev/hook-boundaries.md
  • .claude/hooks/worktree_scope_guard.py
  • scripts/agent-guards/local_main_branch_guard.py
  • .claude/hooks/tests/test_worktree_scope_guard.py
  • tests/codex/test_local_main_branch_guard.py
  • tests/agent_ops/test_git_ref_probe.py
  • tests/agent_ops/test_git_worktree_probe.py
  • tests/agent_ops/test_probe_docs_contract.py
  • tests/agent_ops/test_probe_guard_contract.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • Python 3
  • Git

Scope Delta(任意)

  • anchor comment #issuecomment-4815640481 を反映し、Allowed Paths / AC / VC の不整合を修正
  • AC6 の Verification Command を dedicated contract test 前提へ更新し、baseline preflight が vc_no_tests_collected で停止しないよう補強

Runtime Verification Applicability

  • decision: not_applicable
  • reason: read-only probe script・guard・docs・pytest の変更で完結し、動作検証は JSON CLI と pytest で確認できる
  • if immediate: N/A
  • if deferred: N/A

Delivery Rule

1 Issue = 1 PR。git mutation を含めず、read-only probe のみを script 化する。

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jun 26, 2026
  2. squne121 commented on Jun 27, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    Issue #1197 の方向性は正しいです。git ref/worktree の read-only probe を Python script 化し、shell quoting・compound command・hook transcript noise を減らす狙いは、#1047 系の「agent 周辺制御を deterministic script に寄せる」方針と整合します。#1197 本文も、git_ref_probe.py / git_worktree_probe.py 追加、post-merge-cleanup 更新、deterministic checker allow、fixture 追加まで明記しています。

    ただし、現状の Issue 契約のまま実装すると AC を満たせません。特に Allowed Paths と AC6 が矛盾しています。Issue #1197 自体のコメントは 0 件でした。


    P0 ブロッカー

    1. AC6「guard が probe script を deterministic checker として許可」が Allowed Paths 上で実装不能

    #1197 は AC6 で「guard が probe script の exact command class を deterministic checker として許可する」としていますが、Allowed Paths に 実際の guard 本体が入っていません。現行 local_main_branch_guard.py の DETERMINISTIC_CHECKER_ALLOWLIST は空で、is_deterministic_checker_command() は uv run python3 <script> かつ allowlist の exact path に一致する場合だけ許可します。

    さらに worktree_scope_guard.py 側も、main root から active issue worktree 存在時に通せる agent-ops script を _AGENT_OPS_ALLOWED_SCRIPTS で閉じており、現状は cleanup_exec.py / guard_preflight.py / materialize_cleanup_contract.py のみです。git_ref_probe.py と git_worktree_probe.py は含まれていません。

    worktree_scope_guard の exact allow は script realpath・argv shape・cwd main root・default branch をすべて検証する実装なので、テストだけ追加しても実 hook 経路は通りません。

    修正案: Allowed Paths に最低限これを追加してください。

    - `.claude/hooks/worktree_scope_guard.py`
    - `scripts/agent-guards/local_main_branch_guard.py`
    - `.claude/hooks/tests/test_worktree_scope_guard.py`
    - `tests/codex/test_local_main_branch_guard.py`

    または、probe command policy を共有 module に切り出すなら、その module と両 guard の import 更新も Allowed Paths に入れる必要があります。


    2. Verification Commands が参照する test file が Allowed Paths に無い

    #1197 の Verification Commands には tests/agent_ops/test_git_ref_probe.py が出てきますが、Allowed Paths にはそのファイルがありません。

    このままだと、AC4 / AC5 の probe script 回帰テストを追加した瞬間に Allowed Paths 違反になります。

    修正案: Allowed Paths に追加。

    - `tests/agent_ops/test_git_ref_probe.py`
    - `tests/agent_ops/test_git_worktree_probe.py`

    3. git_worktree_probe.py が既存 SSOT と drift する危険が高い

    リポジトリには既に scripts/agent-ops/worktree_catalog.py があり、worktree_scope_guard / guard_preflight / cleanup_exec が同じ worktree catalog parser を使うための SSOT として導入されています。コメント上も、git worktree list --porcelain -z を使って path の newline/quoting ambiguity を避ける設計です。

    既存 parser は WORKTREE_CATALOG_ENTRY_V1 として worktree_realpath / branch_ref / git_common_dir / detached / head を扱っています。

    Git 公式仕様でも、git worktree list --porcelain -z は attribute line を NUL 終端にし、worktree が常に最初の属性になり、detached のような boolean attribute は true のときだけ出る形式です。(Git)

    修正案: git_worktree_probe.py は独自 parser を持たず、原則 worktree_catalog.py を import してください。もし locked / prunable / exists_on_disk などを追加で必要とするなら、scripts/agent-ops/worktree_catalog.py も Allowed Paths に入れて、既存 SSOT を拡張する方が安全です。


    4. remote existence / remote OID の定義が曖昧

    #1197 の AC2 は「branch existence / local OID / remote existence / remote OID」としていますが、ここでいう remote が以下のどれか不明です。

    • refs/remotes/origin/<branch>
    • branch に設定された upstream
    • PR head ref
    • origin/HEAD から見た default branch
    • fetch 前提の live remote state

    Git の for-each-ref は upstream 関連 atom を持ち、%(upstream:track) は upstream が unknown の場合に [gone] を出せます。(Git) ただし、これは「configured upstream」の状態であって、単純な origin/<branch> の存在とは別です。

    修正案: AC2 を以下のように明文化してください。

    AC2: `git_ref_probe.py` は以下を `GIT_REF_PROBE_RESULT_V1` JSON として返す:
    - `branch`: 入力 branch 名
    - `local.exists`: `refs/heads/<branch>` が存在するか
    - `local.oid`: local branch ref の full OID。不存在時は null
    - `remote.mode`: `"tracking"` または `"origin_branch"` のどちらを解決したか
    - `remote.ref`: 解決対象 ref。例: `refs/remotes/origin/<branch>`
    - `remote.exists`: remote-tracking ref が存在するか
    - `remote.oid`: remote-tracking ref の full OID。不存在時は null
    - `upstream.configured`: branch に upstream が設定されているか
    - `upstream.track`: `"present" | "gone" | "not_configured"` などの正規化 status
    - `errors`: bounded diagnostic list

    branch 名は git check-ref-format --branch 相当で検証すべきです。Git 公式 docs は --branch <branchname-shorthand> を branch name 検証用として説明し、不正な refname では non-zero status になるとしています。(Git)


    5. AC1 の検証が hollow

    AC1 は「post-merge-cleanup skill から raw git for-each-ref の shell 使用例を削除」としていますが、Verification Commands は worktree_scope_guard.py -k deterministic_checker だけです。これは docs から raw shell probe が消えたことを検証しません。

    修正案: docs drift を検出する専用 pytest を追加してください。

    例:

    def test_post_merge_cleanup_uses_probe_scripts_not_raw_git_probe():
        text = Path(".claude/skills/post-merge-cleanup/SKILL.md").read_text()
        assert "scripts/agent-ops/git_ref_probe.py" in text
        assert "scripts/agent-ops/git_worktree_probe.py" in text
        assert "git for-each-ref" not in text

    必要なら git worktree list --porcelain の raw shell 例も禁止対象にしてください。ただし、script 実装内の argv-list subprocess は対象外にします。


    6. stderr 5 行制限だけでは不十分

    AC4 は「probe script の stderr は最大 5 行」としていますが、read-only probe script の品質条件としては不足です。必要なのは stdout JSON-only と bounded structured diagnostics です。

    Python の subprocess.run() は args sequence、capture_output=True、timeout= をサポートします。capture_output=True は stdout/stderr を PIPE にし、timeout 超過時は child process を kill/wait したうえで TimeoutExpired を再 raise します。([Python documentation]4) ([Python documentation]4)

    修正案: AC4 をこう強化してください。

    AC4: probe script は stdout に JSON object を 1 個だけ出力し、stderr は最大 5 行、かつ raw command / env / absolute secret-like path を出力しない。Git subprocess は shell=False の argv list、capture_output=True、timeout を使う。

    7. #1196 との接続条件が弱い

    #1197 は post-merge-cleanup 周辺 probe の script 化です。一方、直近の #1196 は branch-only cleanup resume を扱っており、「worktree が存在しない」状態を disk path / worktree catalog / branch catalog / local ref existence に分解しています。

    Git 公式 docs でも、作業ツリーを手動削除した場合は管理情報が残り、後で prune されると説明されています。また worktree remove は clean な worktree だけ削除し、dirty/submodule 付きは force が必要です。([Git]1)

    したがって git_worktree_probe.py が post-merge-cleanup の正本 probe になるなら、最低限以下を JSON に含めるべきです。

    {
      "schema": "GIT_WORKTREE_PROBE_RESULT_V1",
      "entries": [
        {
          "schema": "WORKTREE_CATALOG_ENTRY_V1",
          "worktree_realpath": "...",
          "branch_ref": "refs/heads/...",
          "head": "...",
          "detached": false,
          "exists_on_disk": true,
          "locked": false,
          "prunable": false
        }
      ],
      "queries": {
        "by_branch_ref": {
          "branch_ref": "refs/heads/issue-1197-...",
          "match_count": 1
        },
        "by_path": {
          "worktree_realpath": "...",
          "in_catalog": true,
          "exists_on_disk": true
        }
      }
    }

    現行 worktree_catalog.py は locked / prunable を保持していないので、この情報まで要るなら SSOT 側の拡張を Issue scope に含めるべきです。


    P1 改善

    git_ref_probe.py は show-ref --verify --hash ベースがよい

    git show-ref は local refs を表示し、--verify は exact ref path を要求し、--hash は OID のみを出力できます。不存在は error code で判定できます。([Git]5)

    推奨 probe strategy:

    branch input
      -> git check-ref-format --branch <branch>
      -> local: git show-ref --verify --hash refs/heads/<branch>
      -> remote-tracking: git show-ref --verify --hash refs/remotes/<remote>/<branch>
      -> optional upstream metadata: git for-each-ref --format=... refs/heads/<branch>
    

    ただし git for-each-ref --shell/--python は placeholder を host language literal として quote する option で、eval 前提の例が出る領域です。#1197 の目的が shell quoting 事故削減なら、--shell / eval 系の使い方は採用しない方がよいです。([Git]2)


    hook docs の記述は「security boundary」ではなく「fail-closed local guardrail」に合わせる

    docs/dev/hook-boundaries.md は、hook は fail-closed local guardrail であって security boundary ではなく、hook failure は transcript を汚染し得る、と明記しています。

    #1197 の docs 更新は、probe script を「安全な権限昇格」ではなく、read-only probe の argv grammar 固定・JSON 正規化・stderr 縮小として説明すべきです。


    Issue #1197 への追記案

    ## Contract Fixes
    
    ### Allowed Paths 追加
    
    - `.claude/hooks/worktree_scope_guard.py`
    - `scripts/agent-guards/local_main_branch_guard.py`
    - `tests/agent_ops/test_git_ref_probe.py`
    - `tests/agent_ops/test_git_worktree_probe.py`
    - `scripts/agent-ops/worktree_catalog.py`(locked/prunable など catalog schema 拡張が必要な場合のみ)
    
    ### AC2 revised
    
    `git_ref_probe.py` は `GIT_REF_PROBE_RESULT_V1` JSON を stdout に 1 object のみ出力する。
    
    Required fields:
    
    - `schema`
    - `branch`
    - `local.exists`
    - `local.ref`
    - `local.oid`
    - `remote.mode`
    - `remote.ref`
    - `remote.exists`
    - `remote.oid`
    - `upstream.configured`
    - `upstream.track`
    - `errors`
    
    `remote.mode` は `"origin_branch"` または `"configured_upstream"` のどちらかに固定し、実装・docs・tests で同じ意味にする。
    
    ### AC3 revised
    
    `git_worktree_probe.py` は `worktree_catalog.py` の parser / catalog schema を再利用し、`GIT_WORKTREE_PROBE_RESULT_V1` JSON を stdout に 1 object のみ出力する。少なくとも `worktree_realpath`, `branch_ref`, `head`, `detached`, `exists_on_disk` を含める。`locked` / `prunable` を扱う場合は `worktree_catalog.py` の SSOT schema を拡張する。
    
    ### AC4 revised
    
    probe scripts は stdout JSON-only、stderr 最大 5 行、raw command / env / secret-like absolute path を stderr に出さない。Git subprocess は shell=False の argv list、capture_output=True、timeout 付きで実行する。
    
    ### AC5 revised fixtures
    
    以下を pytest fixture で固定する。
    
    - local branch exists
    - local branch missing
    - remote-tracking branch exists
    - remote-tracking branch gone/missing
    - configured upstream missing
    - detached worktree
    - branch checked out in another worktree
    - deleted-on-disk but catalog remains, if supported
    - path with whitespace
    - invalid branch name
    
    ### AC6 revised
    
    Claude hook / Codex guard parity を含め、以下を process または direct classifier test で検証する。
    
    - `uv run python3 scripts/agent-ops/git_ref_probe.py --branch main --json` is allowed
    - `uv run python3 scripts/agent-ops/git_worktree_probe.py --json` is allowed
    - unknown flag, duplicate flag, `--flag=value`, extra positional, shell metachar, wrapper, newline chain are denied
    - bare git mutation remains denied

    Codex / Claude Code 実行プロンプト

    Issue #1197 を実装前に契約修正込みで再精査してください。
    
    対象:
    https://github.com/squne121/loop-protocol/issues/1197
    
    目的:
    git ref/worktree の high-frequency read-only probe を Python script 化し、shell quoting / compound command / hook transcript noise を削減する。ただし cleanup mutation executor ではない。read-only JSON probe に限定する。
    
    必ず確認する関連文脈:
    - Issue #1197 本文
    - Issue #1196: branch-only cleanup resume lane
    - Issue #1147: post-merge-cleanup-worker が local_main_branch_guard に block された経緯
    - Issue #1050 / PR #1065: worktree_scope_guard の read_only / mutation / cleanup 分類
    - PR #1139 / PR #1143: cleanup_exec, one-shot V3, worktree_catalog,実 hook integration
    - PR #1182: controlled skill mutation policy and no split-brain guard policy
    - Repository assets:
      - scripts/agent-ops/worktree_catalog.py
      - .claude/hooks/worktree_scope_guard.py
      - scripts/agent-guards/local_main_branch_guard.py
      - docs/dev/hook-boundaries.md
      - .claude/skills/post-merge-cleanup/SKILL.md
      - AGENTS.md
      - .claude/rules/project-constitution.md
    
    最初にやること:
    1. Issue #1197 の Allowed Paths と AC6/Verification Commands の矛盾を確認する。
    2. 実装に必要な Allowed Paths 追加が必要なら、Issue 本文を修正するか、修正案をコメントとして出す。
    3. `tests/agent_ops/test_git_ref_probe.py` / `tests/agent_ops/test_git_worktree_probe.py` が Allowed Paths に無い問題を解消する。
    4. `worktree_scope_guard.py` / `local_main_branch_guard.py` への exact allow 追加が必要か確認し、必要なら Allowed Paths に含める。
    5. `git_worktree_probe.py` は `worktree_catalog.py` を SSOT として再利用する。独自 parser を作って drift させない。
    6. `git_ref_probe.py` は shell=True / compound command / eval / --shell format に依存しない。Python subprocess の argv list で実装する。
    7. stdout は JSON 1 object のみ。stderr は最大 5 行。raw command / env / secret-like path を出さない。
    8. mutation は一切実装しない。`git branch -d/-D`, `git worktree remove`, `git worktree prune` executor 化はしない。
    
    実装方針:
    - `scripts/agent-ops/git_ref_probe.py`
      - `--branch <branch>` 必須
      - `--remote origin` は任意、default origin
      - `--json` 必須または default JSON
      - branch name は `git check-ref-format --branch` 相当で検証
      - local ref は `refs/heads/<branch>`
      - remote-tracking ref は `refs/remotes/<remote>/<branch>`
      - configured upstream と origin branch を混同しない
      - JSON schema: `GIT_REF_PROBE_RESULT_V1`
    
    - `scripts/agent-ops/git_worktree_probe.py`
      - `worktree_catalog.py` の parser/list function を利用
      - JSON schema: `GIT_WORKTREE_PROBE_RESULT_V1`
      - `entries` は既存 `WORKTREE_CATALOG_ENTRY_V1` と互換
      - 必要なら `exists_on_disk` を wrapper 側で追加
      - `locked` / `prunable` が必要なら `worktree_catalog.py` の schema 拡張を明示してテストする
    
    - guard allow:
      - `worktree_scope_guard.py` の `_AGENT_OPS_ALLOWED_SCRIPTS` / `_AGENT_OPS_ARG_SPECS` に probe scripts を exact command class として追加する
      - `local_main_branch_guard.py` の deterministic checker allowlist に probe scripts を追加する、または共有 policy 化する
      - unknown flag / duplicate flag / --flag=value / extra positional / shell metachar / wrapper / newline chain は deny のまま
      - bare git mutation は deny のまま
    
    テスト:
    - `tests/agent_ops/test_git_ref_probe.py`
      - local exists/missing
      - remote-tracking exists/missing
      - configured upstream missing/gone
      - invalid branch name
      - stdout JSON-only
      - stderr <= 5 lines
      - timeout/subprocess failure bounded
    
    - `tests/agent_ops/test_git_worktree_probe.py`
      - normal catalog
      - detached HEAD worktree
      - branch ref present
      - path with whitespace
      - missing/deleted worktree if representable
      - stdout JSON-only
      - stderr <= 5 lines
    
    - `.claude/hooks/tests/test_worktree_scope_guard.py`
      - exact `uv run python3 scripts/agent-ops/git_ref_probe.py --branch main --json` allowed
      - exact `uv run python3 scripts/agent-ops/git_worktree_probe.py --json` allowed
      - malformed variants denied
    
    - `tests/codex/test_local_main_branch_guard.py`
      - deterministic checker allow for both probe scripts
      - malformed variants denied
      - branch mutation remains denied
    
    Docs:
    - `.claude/skills/post-merge-cleanup/SKILL.md` から raw `git for-each-ref` 等の shell probe 例を削除し、probe script 呼び出しへ置換する
    - `docs/dev/hook-boundaries.md` は hook を security boundary と誤記せず、fail-closed local guardrail / transcript noise reduction として記述する
    - `AGENTS.md` / `.claude/rules/project-constitution.md` は「複雑な git read-only probe は script 優先」に整合させる
    
    検証:
    - `uv run pytest tests/agent_ops/test_git_ref_probe.py -q`
    - `uv run pytest tests/agent_ops/test_git_worktree_probe.py -q`
    - `uv run pytest .claude/hooks/tests/test_worktree_scope_guard.py -k "agent_ops or deterministic_checker" -q`
    - `uv run pytest tests/codex/test_local_main_branch_guard.py -k deterministic_checker -q`
    - `uv run python3 scripts/agent-ops/git_ref_probe.py --branch main --json`
    - `uv run python3 scripts/agent-ops/git_worktree_probe.py --json`
    
    PR:
    - 1 Issue = 1 PR
    - PR body に `Closes #1197`
    - 実装・テスト・docs 更新後、CI が green になるまで修正する
    - review comment が付いたら unresolved thread を確認し、必要修正・追加テスト・docs 更新まで行う
    - Issue close 条件は全 AC と Verification Commands の達成
    
    停止条件:
    - Allowed Paths 外の変更が必要で Issue 本文を更新できない
    - 破壊的 git mutation が必要になる
    - 秘密情報・外部課金・権限昇格が必要になる
    - `git branch -D` / `git worktree remove` 等の mutation executor 化が必要になる
    - 既存 guard policy の安全境界を緩和しないと通らない
    

    この Issue は「実装着手前に契約修正」が必要です。現状のまま Codex/Claude に投げると、Allowed Paths 違反か、AC6 未達のどちらかになります。

  3. squne121 commented on Jun 27, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-27T06:51:28Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1197
      body_sha256: "sha256:85914120fedccf71ea5ae9fec1a69271ae7e553261cbcf5c4d296944f44ca755"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  4. squne121 commented on Jun 27, 2026

    @squne121
    OwnerAuthor

    AGENT_RUN_REPORT_V1

    schema: AGENT_RUN_REPORT_V1
    issue_number: 1197
    pr_number: 1214
    pr_url: https://github.com/squne121/loop-protocol/pull/1214
    branch: worktree-issue-1197-git-ref-worktree-probe-script-shell-quot
    commit_sha: 7eed3305
    status: draft_pr_ready
    
    ac_results:
      - id: AC1
        description: test_probe_docs_contract.py -k post_merge_cleanup が 2 テスト PASS
        status: PASS
        vc_command: "uv run pytest tests/agent_ops/test_probe_docs_contract.py -k post_merge_cleanup -v"
        exit_code: 0
    
      - id: AC2
        description: test_git_ref_probe.py -k json_contract が PASS(remote.mode 固定値検証含む)
        status: PASS
        vc_command: "uv run pytest tests/agent_ops/test_git_ref_probe.py -k json_contract -v"
        exit_code: 0
        tests_collected: 9
    
      - id: AC3
        description: test_git_worktree_probe.py -k json_contract が PASS(exists_on_disk 含む)
        status: PASS
        vc_command: "uv run pytest tests/agent_ops/test_git_worktree_probe.py -k json_contract -v"
        exit_code: 0
        tests_collected: 7
    
      - id: AC4
        description: test_git_ref_probe.py -k stderr が PASS(最大 5 行・パスマスク)
        status: PASS
        vc_command: "uv run pytest tests/agent_ops/test_git_ref_probe.py -k stderr -v"
        exit_code: 0
        tests_collected: 3
    
      - id: AC5
        description: test_git_ref_probe.py -k fixtures が PASS(8 シナリオ)
        status: PASS
        vc_command: "uv run pytest tests/agent_ops/test_git_ref_probe.py -k fixtures -v"
        exit_code: 0
        tests_collected: 8
    
      - id: AC6
        description: test_probe_guard_contract.py -k deterministic_checker が PASS(allowlist 登録確認)
        status: PASS
        vc_command: "uv run pytest tests/agent_ops/test_probe_guard_contract.py -k deterministic_checker -v"
        exit_code: 0
        tests_collected: 8
    
      - id: AC7
        description: test_probe_docs_contract.py -k policy_alignment が PASS(docs 整合確認)
        status: PASS
        vc_command: "uv run pytest tests/agent_ops/test_probe_docs_contract.py -k policy_alignment -v"
        exit_code: 0
        tests_collected: 4
    
    quality_gates:
      pnpm_typecheck: PASS
      pnpm_lint: PASS
      pnpm_test: PASS
      pnpm_build: PASS
      agent_ops_full_suite: PASS  # 99 tests
      codex_local_main_branch_guard: PASS  # 187 tests
      hook_worktree_scope_guard: PASS  # 206 tests
    
    allowed_paths_compliance: true
    
    new_files:
      - scripts/agent-ops/git_ref_probe.py
      - scripts/agent-ops/git_worktree_probe.py
      - tests/agent_ops/test_git_ref_probe.py
      - tests/agent_ops/test_git_worktree_probe.py
      - tests/agent_ops/test_probe_docs_contract.py
      - tests/agent_ops/test_probe_guard_contract.py
    
    modified_files:
      - scripts/agent-ops/worktree_catalog.py  # exists_on_disk フィールド追加
      - .claude/hooks/worktree_scope_guard.py  # _AGENT_OPS_ALLOWED_SCRIPTS / _AGENT_OPS_ARG_SPECS 追加
      - scripts/agent-guards/local_main_branch_guard.py  # DETERMINISTIC_CHECKER_ALLOWLIST 更新
      - .claude/skills/post-merge-cleanup/SKILL.md  # Probe Scripts セクション追加
      - AGENTS.md  # Git Read-Only Probe Scripts セクション追加
      - .claude/rules/project-constitution.md  # Git Read-Only Probe Script 方針セクション追加
      - docs/dev/hook-boundaries.md  # probe scripts allowlist 登録済み注記追加
      - tests/codex/test_local_main_branch_guard.py  # TestProbeScriptsDeterministicChecker 追記
      - .claude/hooks/tests/test_worktree_scope_guard.py  # TestProbeScriptsExactAllow 追記
  5. added 12 commits that reference this issue on Jun 27, 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/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions