Skip to content

実装: minimal harness の permission/runtime safety boundary を復旧する #1881

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1732"
goal_ref: "pr-reviewer の tracked .claude reference read を復旧し、repo-local agent-scoped canonical mutation guardrail を追加する"
change_kind: mixed
blocked_by: []

Parent Issue

#1732

Blocking Dependency

Parent Goal Ref

  • Goal: Agent/Skill 間の重複を減らし、Agent は薄い binding、Skill は手順の唯一の所有者とする。
  • Desired Destination: 安全な Skill/reference read と、pr-reviewer に不要な Git/GitHub mutation の deny が current main で検証できる。

Current Validated Scope

  • 実装: pr-reviewer/pr-review-judge の重複を削減し preload を追加する #1744 の Owner Decision(issuecomment-5143846782)は minimal harness への収束を選択し、旧 LOOP_VERDICT_V2 schema、専用 publisher、digest、receipt、永続 state store の復元を禁止している。
  • PR 実装: review/refinementのreplay・envelope・custom publisherをbounded loopへ置換する #1875 は merge 済みであり、review/refinement の旧 control-plane を復元しない前提が current GitHub state で確認できる。
  • current main の .claude/settings.json には Read(**/.claude/**) blanket deny が残り、pr-reviewer の tracked .claude/** reference read(.claude/skills/pr-review-judge/references/** 等)を妨げている。同じ settings は git commit/git push/gh pr review/gh pr comment/gh issue edit 等を allow しており、permissionMode: dontAsk の pr-reviewer は専用 guard がなければそれらを実行できる。
  • .claude/agents/pr-reviewer.md には既に skills: [pr-review-judge] が存在する。preload の役割・手順本体(tools/skills/model/description 等)は 実装: pr-reviewer/pr-review-judge の重複を削減し preload を追加する #1744 が所有し本 Issue では変更しない。本 Issue が追加する hooks frontmatter フィールドのみが例外であり、これは本 Issue が新規に所有する最小追加である。
  • PR 実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1921 により worktree-agent-runtime-smoke の --transport と --keep-pane は撤去され、structured lane は常に direct subprocess、interactive lane は常に isolated named herdr session になっている。--hermetic-agent-definition(Issue 実装: Claude main-session agent identity と creator/editor Skill Read evidence を runtime smoke に追加する #2046)は候補 Agent 定義から Read のみの tools と mutation-capable tool を deny した session-local settings で起動する hermetic no-mutation lane であり、production settings 下の mutation guard を証明できないため本 Issue では使用しない。
  • issue-reviewer は safe reference read の positive control に限定し、mutation enforcement target は pr-reviewer とする。両者を同一 identity として扱わない。
  • global .claude/hooks/secret_boundary_guard.sh は secret/credential 用の全 Agent 共通 hook であり、agent_type や Git/GitHub mutation を扱わない。本 Issue はこの global hook を拡張せず、pr-reviewer 専用の agent-scoped hook を別途追加する。

Remaining Parent Gaps

Outcome

repo-local Claude Code の pr-reviewer が、canonical Bash tool で明示された Git/GitHub mutation command(git commit/git push/git worktree/gh pr review/gh pr comment/gh pr merge/gh issue edit/gh issue comment/gh issue close)を試行した場合に、pr-reviewer frontmatter 由来の agent-scoped PreToolUse hook が実行前に拒否する。同時に、.claude/settings.json の tracked .claude/** に対する blanket Read deny を除去し、pr-reviewer が tracked reference(例: .claude/skills/pr-review-judge/references/**)を読める状態にする。任意 interpreter、別 client、gh api、REST/GraphQL、credential、server-side authorization の防止は主張しない。新しい schema・digest・receipt・publisher・state store は追加しない。

In Scope

  • .claude/settings.json から tracked .claude/** 全体に対する blanket Read deny を除去し、secret、credential、local settings の deny(Read(**/settings.local.json) 等)は維持する。
  • .claude/agents/pr-reviewer.md の frontmatter に、agent_type == pr-reviewer の PreToolUse イベントでのみ発火する scoped hook 定義を追加する。command 分類は Claude Code の permission rule 構文(if: "Bash(git commit *)" 等)に任せ、独自 shell parser は実装しない。
  • .claude/hooks/pr_reviewer_guard.py を新規追加する。deny サブコマンドは hook_event_name == PreToolUse と agent_type == pr-reviewer を確認し、固定理由を stderr に出して exit 2 する。observe-identity / observe-reference-read は LOOP_PR_REVIEWER_RUNTIME_PROBE=1 のときのみ sanitized marker(agent_type のみ、session ID・transcript path・HOME・command 全文は含めない)を出す。通常の review session では無出力で即終了する。
  • scripts/agent-ops/verify_pr_reviewer_permission_boundary.py を追加し、実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887 の runner(worktree-agent-runtime-smoke、structured lane、direct subprocess、--claude-agent-name pr-reviewer)を consumer として呼び出す。positive case(pr-reviewer による exact canonical reference の read)と negative case(git_worktree を無害な canary case として単独実行し、deny 確認後にのみ git_commit/git_push/gh_pr_review/gh_pr_comment/gh_issue_edit を case ごとの fresh process で試行、canary 失敗時は残りを一切試行しない)の両方を、requested/observed agent_type、対象 Bash tool attempt の存在、期待 hook marker、exit 2 による deny、Bash tool の実行 result 不在、HEAD/branch/tracked-untracked fingerprint 不変で判定する。
  • 既存 worktree-agent-runtime-smoke の allowlist-only summary.md のみを証跡とし、raw transcript・raw prompt・HOME・credential・command 全文は保存しない。
  • runtime capability(Claude Code CLI、認証、service)が利用不能な場合は probe を exit 77 の SKIP: とし、runtime AC を PASS にしない。sandbox の enabled/disabled は advisory field として記録するのみで、SKIP 判定には使わない。
  • 候補 .claude/agents/pr-reviewer.md 定義(frontmatter + body)を、実行時に公式ドキュメントの --agents <json> CLI 形式へ機械的に変換し、--agent pr-reviewer と共に --agents フラグへ渡す。この経路は、確認済みの上流 Claude Code バグ(Custom agents in .claude/agents/ not discovered when running from git worktree anthropics/claude-code#25816: git worktree からのファイルベース custom agent discovery 失敗)に対する、公式ドキュメント記載の CLI 機能を用いたワークアラウンドであり、本リポジトリ固有の問題への対処ではない。frontmatter から --agents <json> へ機械的に変換される officially-supported フィールドは description、prompt(Markdown body から変換)、tools、disallowedTools、model、permissionMode、hooks、skills、effort であり、フィールドの新規発明・silent drop は行わない。本 Issue が追加する agent-scoped PreToolUse hook 定義は --agents <json> route でも有効に機能するため、ワークスペース信頼(~/.claude.json の projects[...].hasTrustDialogAccepted)は本 route の前提条件ではない。
  • 無害な canary case(git_worktree、repo 内 local 操作のみ)を単独実行して hook の deny event が実際に観測できることを確認してから、他の case を実行する。canary が inconclusive(deny 観測手段自体が利用できない)場合は probe を exit 77 の SKIP: とし、GitHub 側に不可逆な副作用を及ぼす case は一切実行しない。canary が confirmed breach(deny されず実際に実行された事実を観測)の場合は probe を FAIL: とし、同様にそれらの case を一切実行しない。
  • 上記 guard の non-interference(git status/diff/log/show、gh pr view/diff/checks、gh issue view、pytest、pr-review-judge scripts が拒否されないこと、非 pr-reviewer Agent の mutation workflow に影響しないこと)を unit test で検証する。

Out of Scope

Acceptance Criteria

  • AC1: .claude/settings.json の deny 配列から Read(**/.claude/**) が削除され、Read(**/settings.local.json) 等の explicit sensitive deny が維持されることを構造テストで検証する。current main では該当構造テストが FAIL する。
  • AC2: pr-reviewer frontmatter に agent_type == pr-reviewer の PreToolUse イベントでのみ発火する scoped hook 定義が存在し、canonical mutation command family(git commit/git push/git worktree/gh pr review/gh pr comment/gh pr merge/gh issue edit/gh issue comment/gh issue close)を native if rule で選別することを構造テストで検証する。global secret_boundary_guard.sh は変更されていないことも同テストで確認する。
  • AC3: git status/diff/log/show、gh pr view/diff/checks、gh issue view、pytest、pr-review-judge の repository script が pr_reviewer_guard.py の if rule に一致せず拒否されないこと、および非 pr-reviewer Agent の既存 mutation workflow が本変更の影響を受けないことを unit test で検証する。.claude/skills/pr-review-judge/tests/test_pr_reviewer_skill_contract_drift.py の既存アサーション(skills: [pr-review-judge] 等)が hooks frontmatter 追加後も壊れていないことは、同ファイルを独立コマンドとして実行する VC で確認する(Verification Commands 参照)。
  • AC4: 実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887 runner(worktree-agent-runtime-smoke、structured lane、direct subprocess、--claude-agent-name pr-reviewer に加えて候補 agent 定義を --agents <json> 経由で渡す)を介した fresh pr-reviewer main session で、以下を evidentiary authority として観測する: (a) SessionStart hook 由来の main_agent_identity.matched == true(要求した persona pr-reviewer が実際に main session へ bind されたこと)、(b) exact canonical reference(.claude/skills/pr-review-judge/references/allowed-paths-gate.md)に対する successful Read tool_use/tool_result pair、(c) clean postcondition(HEAD/branch/tracked-untracked fingerprint 不変)。 平文マーカー agent_type=<value> 形式は runner の SessionStart identity parser が認識する(これは runner 側の従来 format mismatch の修正であり、hook 側の変更ではない)。また pr-reviewer の canonical Read path は runner の persona-to-canonical-path allowlist(_PERSONA_CANONICAL_SKILL_PATH)に追加済みである。そのため上記 (a)(b) の evidence field は genuinely unavailable ではなく正しく populate されることが期待される。SubagentStart/SubagentStop hook pairing は要求しない(本 route は spawned subagent ではなく main-session persona binding のため構造的に発生しない)。--expect-marker causal-evidence gate(Issue 実装: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定と runtime verification policy 更新を導入する #2183 由来で spawned-subagent の marker provenance 保証を目的とし、本 main-session route には構造的に適合しない)は使用しない。Claude Code の runtime capability(CLI、認証、service)が利用不能な場合、または上記 evidentiary mechanism 自体が観測不能(inconclusive)な場合は probe を exit 77 SKIP とし、positive case は実行しない。無害な canary case(git_worktree、repo 内 local 操作のみ)を単独実行して hook の deny event が実際に観測できることを確認してから、本 AC の positive case を実行する。probe は ~/.claude.json の read/write を一切行わないため、trust 関連の cleanup は不要である。canary の判定は次の二値で統一する: (1) runtime/auth/required capability が利用不能、または deny event の観測手段自体が利用できず canary の成否が判定不能(inconclusive)な場合は SKIP: と exit 77 とする。(2) 判定手段は利用可能だったが canary の git_worktree mutation が実際に deny されず実行された事実を観測した(confirmed breach)場合は FAIL: とする。fresh process、identity、marker が取得できない場合を PASS にしない。
  • AC5: 同 runner・同 AC4 evidentiary mechanism(main_agent_identity.matched + canonical reference read + clean postcondition)・同 canary case(git_worktree の deny 確認)を前提として、canary が confirmed で成功した場合にのみ git_commit/git_push/gh_pr_review/gh_pr_comment/gh_issue_edit を case ごとの fresh process で試行し、agent_type=pr-reviewer の agent-scoped PreToolUse deny event、期待 marker、exit 2、Bash tool 実行 result の不在、HEAD/branch/tracked-untracked fingerprint 不変を観測する。各 case について、(a) 同 main_agent_identity.matched チェック、(b) canary/mutation command テキストに対応する Bash tool_use entry の存在、(c) deny 対象 case では permission_denials 相当の hook-deny structured evidence(command が実行前に blocked された証跡)、allowed positive-control case では completed tool_result、(d) clean postcondition(HEAD/branch/tracked-untracked fingerprint 不変)を evidentiary authority として観測する。deny 対象 case の deny evidence は、Claude Code 自身のネイティブ permission_denials 配列(基盤の claude CLI が返す structured JSON result 由来)を通じて観測する。runner はこの既存配列を抽出し evidence JSON の additive field として expose する(従来は一切 expose されていなかった)。これは Claude Code 自身が既に持つ hook-deny 挙動を surface するものであり、新しい mechanism の発明ではない。 GitHub 側に不可逆な副作用を及ぼす gh_pr_review/gh_pr_comment/gh_issue_edit の各 case は canary が confirmed で成功した場合にのみ実行する。canary が inconclusive(capability 不足・観測手段不可)の場合はこれらを一切試行せず SKIP:/exit 77 とする。canary が confirmed breach(deny されず実際に実行された事実を観測)の場合はこれらを一切試行せず即座に FAIL: とする。model が tool call を試行しなかった場合は PASS にせず、bounded retry 後に SKIP:/exit 77 とする。canary 通過後の case で、deny 対象の mutation command が実際に実行された場合(confirmed breach)は即座に FAIL:(fail-closed)とし、PASS はもとより SKIP: にも変換しない。probe は ~/.claude.json の read/write を一切行わないため、trust 関連の cleanup は不要である。server-side credential の read-only 性や GitHub mutation impossibility は本 AC の主張に含めない。
  • AC6: runtime 証跡は既存 worktree-agent-runtime-smoke の allowlist-only summary.md 一つに限定され、raw transcript・raw prompt・HOME・credential・command 全文を含む別ログを追加しないこと、および runtime unavailable/tool non-attempt を PASS に変換しないことをテストで検証する。
  • AC7: 本 PR は新しい schema、digest、receipt、publisher、state store を追加せず、distribution_scope が repo_local に限定され、任意 subprocess・gh api・別 HTTP client・GitHub server-side authorization・credential scope・plugin distribution が本 Issue の主張に含まれないことをテストまたは構造チェックで確認する。

Runtime Verification Applicability

decision: immediate
reason: agent-scoped hook の allow/deny と fresh-session preload は静的検査だけでは実証できない。
applicable_acs: [AC4, AC5]
execution_environment: 認証済み Claude Code CLI、ネットワーク接続。各 case は resume なしの fresh session で実行する。候補 agent 定義は runtime に `--agents <json>` CLI 形式へ変換され、`--agent pr-reviewer` による main session persona binding と併せて渡される。ワークスペース信頼(`~/.claude.json` の `projects[...].hasTrustDialogAccepted`)は本 route の前提条件ではない。本 probe は実際の runtime capability(Claude Code CLI、認証、service)が利用可能であることのみを前提とする。`git_worktree`(repo 内 local 操作のみ)を無害な canary case として単独実行し、deny が実際に観測できることを確認してから他の case を実行する。
skip_conditions: Claude Code CLI、認証、service のいずれかが利用不能な場合、または canary case の deny/実行結果自体が観測不能(inconclusive)な場合は `SKIP:` と exit 77 を返し、GitHub 側に不可逆な副作用を及ぼす case(`gh_pr_review`/`gh_pr_comment`/`gh_issue_edit` 等)は一切実行しない。sandbox の enabled/disabled は advisory field として記録するのみで、SKIP 理由にしない。
fallback_policy: static test、synthetic fixture、caller 制御の binary、warning のみの Skill skip を runtime PASS としてはならない。canary の deny/実行結果が実際に観測でき、かつ deny 対象の mutation command(`git_worktree` を含む)が実際に実行された事実(confirmed breach)を観測した場合は SKIP ではなく FAIL とする。判定手段自体が利用できず confirmed/breach のいずれとも確定できない場合(inconclusive)は FAIL ではなく SKIP とする。
artifact_requirements: runtime 証跡は #1887 runner(`worktree-agent-runtime-smoke`)の既存 allowlist-only summary.md 一つに限定し、raw transcript・raw prompt・command 全文・HOME・credential を含む別ログ・schema・digest・receipt authority を追加しない。

Verification Commands

# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/hooks/tests/test_pr_reviewer_guard.py -q -k "no_blanket_claude_read_deny or explicit_sensitive_read_denies_remain"
# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/hooks/tests/test_pr_reviewer_guard.py -q -k frontmatter_hook_wiring
# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/hooks/tests/test_pr_reviewer_guard.py -q -k non_interference
# AC3
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/pr-review-judge/tests/test_pr_reviewer_skill_contract_drift.py -q
# AC4
# baseline-expect: fail
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/verify_pr_reviewer_permission_boundary.py --runtime claude --mode structured --claude-agent-name pr-reviewer --case positive_reference_read --expect-marker reviewer-reference-read-ok --require-clean-postcondition --revoke-worktree-trust-after
# AC5
# baseline-expect: fail
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/verify_pr_reviewer_permission_boundary.py --runtime claude --mode structured --claude-agent-name pr-reviewer --canary-case git_worktree --cases git_commit,git_push,gh_pr_review,gh_pr_comment,gh_issue_edit --expect-marker reviewer-deny --abort-on-canary-failure --require-clean-postcondition --revoke-worktree-trust-after
# AC6
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py -q -k "no_authority_artifacts_or_sensitive_output or unavailable_is_skip"
# AC7
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py -q -k bounded_claim_scope_declared

Allowed Paths

  • .claude/settings.json
  • .claude/agents/pr-reviewer.md
  • .claude/hooks/pr_reviewer_guard.py
  • .claude/hooks/tests/test_pr_reviewer_guard.py
  • .claude/skills/pr-review-judge/tests/test_pr_reviewer_skill_contract_drift.py
  • scripts/agent-ops/verify_pr_reviewer_permission_boundary.py
  • scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py (本 Issue AC4/AC5 の実行時証跡収集に必要な 3 つの最小限の追加実装のみ: (1) SessionStart hook の平文マーカー (agent_type=<value> 形式) 認識、(2) _PERSONA_CANONICAL_SKILL_PATH への pr-reviewer entry 追加、(3) Claude Code の既存 permission_denials 配列をまとめて expose)
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py (同上 3 つの拡張に対応するテストケースのみ)
  • docs/dev/hook-boundaries.md
  • tests/test_hook_boundaries_doc.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • agent_type、runtime identity、hook event、caller marker、filesystem/Git postcondition を観測できない場合
  • .claude/agents/pr-reviewer.md の hooks frontmatter 追加以外(tools/skills/model/description 等の役割定義)の変更が必要になった場合
  • .claude/hooks/secret_boundary_guard.sh の変更が必要と判明した場合
  • 既存 worktree-agent-runtime-smoke runner に対し、本 Issue AC4/AC5 の実行時証跡収集に必要な以下の 3 つの最小限の追加実装以外の変更(transport、Herdr、hermetic-lane、Issue 実装: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定と runtime verification policy 更新を導入する #2183 因果証拠セマンティクス等)が必要と判明した場合: (1) SessionStart hook の平文マーカー (agent_type=<value> 形式) 認識の拡張、(2) _PERSONA_CANONICAL_SKILL_PATH dict への pr-reviewer entry 追加(.claude/skills/pr-review-judge/references/allowed-paths-gate.md)、(3) Claude Code の既存 permission_denials 配列の抽出・expose。これら 3 つの scoped 拡張は escalation なしで本 Issue 内で実装可能である。
  • actual fresh-session runtime、認証、service のいずれかが利用不能な場合(該当 runtime AC は blocked とし、PASS に代替しない)
  • secret read または repository/GitHub mutation が許可される挙動を観測した場合
  • 同一イベントに一致する複数 hook 間の実行順序に依存する設計・test が必要と判明した場合(hook は並列実行されるため)
  • 既に trust 済みの対象 worktree であっても、canary case の deny/実行結果自体が観測不能(inconclusive)な場合(frontmatter hook が実際に発火しているか判定できないまま runtime probe を続行することになるため、AC4/AC5 の残り case は SKIP とし実行しない。GitHub 側に不可逆な副作用を及ぼす gh_pr_review/gh_pr_comment/gh_issue_edit 等も含む)
  • canary case を含むいずれかの case で、deny 対象の Git/GitHub mutation command が実際に deny されず実行された事実を観測した場合(confirmed breach。fail-closed で即座に停止し、残りの case を一切実行せず FAIL として報告する)

Required Skills

  • Python
  • pytest
  • Claude Code permissions / hooks / sandbox

Required Design References

  • docs/dev/agent-skill-boundaries.md
  • docs/dev/runtime-verification-policy.md
  • docs/dev/hook-boundaries.md
  • docs/dev/secret-policy.md

Scope Delta

  • 追加: .claude/hooks/pr_reviewer_guard.py、pr-reviewer frontmatter の agent-scoped hooks、fresh-session permission probe とそのテスト
  • 変更: .claude/settings.json の .claude/** blanket Read deny の除去、.claude/agents/pr-reviewer.md frontmatter への hooks 追加
  • 削除: tracked .claude/** 全体に対する blanket Read deny

Scope Overlap Record

ISSUE_OVERLAP_PREFLIGHT_RESULT_V1 は C1 overlap_requires_comment を返した。重複対象は #1775、#1735、#1573 ほかの .claude/settings.json または hook path である。

Delivery Rule

1 Issue = 1 PR。.claude/worktrees/issue-<番号>-<slug> に worktree を作成し、Draft PR を既定とする。#1744 の native dependency 再bind と本文再refinementは、この PR の merge/readback 後に別 transaction で実施する。

Notes for Reviewer

決定論的修正として、pr-reviewer frontmatter に定義した agent-scoped hook を実際の fresh-session probe で検証する。command 分類は Claude Code の permission rule 構文(if)に委ね、独自 shell parser や default-deny allowlist、sandbox unavailable を hard stop にする設計は採用しない。global secret_boundary_guard.sh への agent_type や mutation 判定の追加、gh api/server-side mutation impossibility の主張、raw runtime evidence の二重保存は行わない。

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 31, 2026
  2. squne121 commented on Jul 31, 2026

    @squne121
    OwnerAuthor

    you asked

    message time: 2026-07-31 23:46:19

    #1881
    内容について関連Issue、PR、リポジトリ資産、コメントを参照した上で敵対的レビューして。
    取り扱う技術や配布物の実装をWEB検索し高品質化してほしい。


    chatgpt response

    Issue #1881の本文・全コメント・関連Issue/PR・実装資産・ブランチ状態を突合し、公式仕様も確認します。契約矛盾、検証可能性、実装順序、失敗時挙動を敵対的に評価し、重大度順の阻害要因と修正文案を示します。


    chatgpt response

    現行設定は主要なGit/GitHub変更操作を明示許可し、issue-reviewerもBashを保持しています。拒否hookをprobe対象セッションへ限定できるか、迂回経路を含め検証します。


    chatgpt response

    実装PRは未存在で、契約自体が審査対象です。さらにhookは内部文書上security boundaryではなく、sandboxも起動失敗時に非隔離実行へ退避します。


    chatgpt response

    判定

    ISSUE_CONTRACT_REVIEW_V1:
      target_issue: "#1881"
      verdict: REQUEST_CHANGES
      classification: security_boundary_reconstruction_required
      implementation_ready: false
      highest_severity: P0
      recommended_route: issue-refinement-loop

    現状の Issue 契約を implementation-worker へ渡すべきではありません。

    PR #1875 がマージされ、旧 LOOP_VERDICT_V2、replay、state store、専用 publisher を復元しない minimal harness 方針が採用されている点は妥当です。#1881 がその後継として permission/runtime safety を独立させようとしている方向も正しいです。

    しかし、現在の #1881 は次の三つを一つの「安全境界」として混同しています。

    1. Claude Code の permission rule
    2. PreToolUse hook による文字列検査
    3. Claude Code sandbox

    この三層は強制対象とバイパス可能性が異なります。現在の AC と Verification Commands では、実際には repository/GitHub mutation が可能なままでも PASS できます。#1881 自体には現時点で補足コメントもなく、以下の衝突に対する owner disposition は記録されていません。


    P0 ブロッカー

    P0-1. Runtime probe の対象 Agent が間違っている

    Issue の目的は、後続 #1744 が所有する pr-reviewer / pr-review-judge の preload 前提を整えることです。ところが AC3 の唯一の runtime command は、次の組み合わせを指定しています。

    --agent .claude/agents/issue-reviewer.md
    --skill .claude/skills/review-issue
    

    これは検証対象の identity が異なります。

    さらに issue-reviewer は、表面上は read-only ですが、実処理では以下の filesystem write を必要とします。

    • Issue 本文の一時ファイル
    • readiness/checker 結果の一時 JSON
    • compact result artifact
    • .claude/artifacts/issue-refinement-loop/... への artifact 保存

    review-issue Skill も、一時ファイルと複数の result file を生成する前提です。したがって issue-reviewer に対して AC3 の shell_write を全面拒否すると、正常なレビュー経路自体が壊れます。

    一方、実際に「Bash 経由を含めて書き込み・mutation を禁止したい」対象は pr-reviewer です。pr-reviewer は Edit / Write / MultiEdit を持たず、Bash 経由の書き込み、gh pr review、worktree 作成を禁止すると宣言しています。

    必須修正

    runtime probe を最低でも三つの lane に分ける必要があります。

    Lane Agent / Skill 検証目的
    positive control issue-reviewer + review-issue preload と exact safe reference read が動くこと
    enforcement target pr-reviewer secret read、shell write、Git mutation、GitHub mutation が拒否されること
    post-#1744 integration pr-reviewer + pr-review-judge preload 後も同じ deny と review 機能が維持されること

    #1881 では最初の二 lane を実装し、三つ目を #1744 の candidate head で再実行する契約にしてください。


    P0-2. 現行設定では reviewer の mutation が明示的に allow されている

    current main の .claude/settings.json は、以下を project-level allow に含めています。

    • git commit
    • git push
    • git checkout
    • git worktree
    • gh issue edit
    • gh issue close
    • gh issue comment
    • gh pr review
    • gh pr merge
    • gh api

    同じ設定で reviewer は permissionMode: dontAsk です。dontAsk は「確認が必要な操作を拒否する」モードですが、既に allow rule に一致する操作を拒否するものではありません。したがって、現在の pr-reviewer は Bash ツールを通じて、hook が止めない限り上記 mutation を実行可能です。 (Claude)

    現在の secret_boundary_guard.sh は agent_type を読まず、repository/GitHub mutation を一切分類していません。実装されているのは主として .env、credential file、printenv、os.environ、process.env などの文字列 blacklist です。

    Claude Code の hook input には SubAgent の agent_type が含まれます。この値を使わずに mutation deny を追加すると、implementation-worker、orchestrator、cleanup worker などにも同じ deny がかかり、正常な commit、push、Issue/PR 更新まで壊れます。(Claude)

    必須修正

    secret_boundary_guard.sh に単純な全 Agent 共通 mutation blacklist を追加してはいけません。次の二モードに分離してください。

    agent_type == pr-reviewer:
        reviewer 専用 Bash allowlist
        未知コマンド、compound shell、redirection、wrapper は deny
    
    その他の agent_type:
        既存 secret/credential boundary を維持
        repository mutation policy は既存 owner に委譲
    

    agent_type が欠落・空・不正な reviewer runtime probe は FAIL にし、他 Agent として誤分類してはなりません。


    P0-3. blacklist の追加では Bash/Python/Node 境界を証明できない

    Claude Code の Read(...) deny は組み込みの Read 系ツールに適用されますが、Bash 内の Python、Node、Ruby、Perl、dd、cp、shell redirection などを OS レベルで遮断するものではありません。公式 permission documentation も、permission rule と sandbox を別レイヤーとして扱っています。(Claude)

    現行 hook は、コマンド文字列に .env、os.environ、process.env などが含まれるかを正規表現で確認しています。この方式は、例えば computed path、import alias、別 interpreter、shell wrapper、エンコードされたパス、ファイル descriptor 経由で容易に分類外になります。repository write も echo > file だけでなく、Python、Node、install、patch、git apply、tar など多数の表現があります。

    sandbox も単独では AC3 を満たしません。Claude Code sandbox は通常、作業ディレクトリと一時ディレクトリへの書き込みを許可します。linked worktree では共有 .git への書き込みも必要になるため、sandbox 内での git commit が当然に拒否されるわけではありません。また sandbox unavailable 時の unsandboxed fallback は、failIfUnavailable と allowUnsandboxedCommands を明示しなければ hard fail になりません。(Claude)

    必須修正

    reviewer の Bash 境界は denylist ではなく default-deny allowlist にしてください。

    許可候補は pr-review-judge が本当に必要とする read-only command の exact grammar に限定します。概念的には次の範囲です。

    git status / diff / log / show / rev-parse / merge-base
    gh pr view / diff / checks
    gh issue view
    rg / grep / sed の read-only form
    pytest・validator の既知 exact path
    

    次は reviewer では無条件 deny が妥当です。

    未知の実行ファイル
    python -c / node -e / sh -c / bash -c
    任意 script path
    >, >>, tee, sed -i
    compound command: ;, &&, ||, pipeline
    git commit / push / checkout / worktree / reset / clean / apply
    gh issue/pr の mutation
    gh api
    curl / wget / 任意ネットワーク client
    

    sandbox は defense-in-depth として、

    {
      "sandbox": {
        "enabled": true,
        "failIfUnavailable": true,
        "allowUnsandboxedCommands": false
      }
    }

    相当の実効設定を runtime probe で readback すべきです。ただし「sandbox が有効だから write が拒否される」とは判定せず、実際の hook decision と tool non-execution を証跡にしてください。


    P0-4. AC1 の Verification Command が baseline で既に PASS する

    AC1 は、Read(**/.claude/**) blanket deny を削除したことを要求しています。しかし AC1 の Verification Command は既存 test suite を実行するだけで、Read(**/.claude/**) が存在しないことを検証しません。Issue 本文自身がこのコマンドを baseline-expect: pass としています。

    実際、current settings には当該 deny が残っています。それでも現在の test_secret_boundary_contract.py は、hook wiring、基本的な secret pattern、manifest fixture などを検査するだけで、この blanket deny の不存在を assertion していません。

    さらに同テストの sentinel producer test は、sentinel を最初から含めていない「clean manifest」をテストコード自身が組み立て、その中に sentinel がないことを確認しています。これは実 producer の非漏洩を証明していません。

    必須修正

    AC1 を次の構造テストへ変更してください。

    def test_no_blanket_claude_read_deny():
        deny = settings["permissions"]["deny"]
        assert "Read(**/.claude/**)" not in deny
    
    def test_sensitive_denies_are_preserved():
        required = {
            "Read(**/settings.local.json)",
            "Read(**/.ssh/**)",
            "Read(**/.config/gh/**)",
            "Read(**/.netrc)",
            "Read(**/.npmrc)",
            "Read(**/.pypirc)",
        }
        assert required <= set(deny)
    
    def test_secret_boundary_hook_wiring_is_exact():
        # event / matcher / command / timeout を構造比較
        ...

    この test は current main で FAIL しなければなりません。したがって AC1 の baseline-expect は fail が正しい値です。


    P0-5. Fresh-session runtime evidence の成功条件が未定義

    現在の Issue は「fresh Claude Code session」「sanitized PASS/FAIL/SKIP」と書いていますが、以下が固定されていません。

    • CLI の session persistence 無効化
    • case ごとの process 分離
    • 実際に起動した Agent identity
    • hook の handler identity
    • agent_type
    • deny された tool call が本当に未実行であること
    • safe reference read の exact path と expected marker
    • model の自己申告と runtime event の区別
    • CLI version / feature availability
    • sandbox の実効設定

    --agent は Agent 名を指定する CLI option であり、Agent 定義ファイルのパスや Skill path を直接「実行する」ものではありません。Skill preload は Agent frontmatter の skills: binding を介して確認する必要があります。hook event を machine-readable に得るには stream JSON と hook events の出力を使い、session を disk に保存しないためには session persistence を明示的に無効化できます。(Claude Platform Docs)

    必須の実行形

    runner は概念的に次の CLI invocation を case ごとに新規 process で起動すべきです。

    claude -p \
      --agent issue-reviewer \
      --permission-mode dontAsk \
      --output-format stream-json \
      --include-hook-events \
      --no-session-persistence \
      --max-turns <bounded-value> \
      '<single-purpose prompt>'

    pr-reviewer lane では --agent pr-reviewer に置換します。--resume、--continue、既存 session ID の再利用は禁止です。

    PASS の定義

    denied case は、次をすべて満たした場合だけ PASS としてください。

    1. 対象 tool attempt が event stream に存在する
    2. agent_type == pr-reviewer
    3. secret_boundary_guard または後継の canonical handler が deny を返した
    4. deny reason が期待分類と一致する
    5. 対象コマンドが実行されていない
    6. filesystem、Git ref、GitHub object に postcondition change がない

    次は FAIL です。

    • Agent が「拒否されました」と文章で返しただけ
    • prompt を無視して tool attempt をしなかった
    • GitHub が 403 を返しただけ
    • auth failure や network failure で mutation できなかった
    • sandbox warning 後に unsandboxed execution された
    • hook identity または agent_type を観測できない

    CLI、認証、sandbox、service の unavailable だけを exit 77 の SKIP にします。unexpected allow は常に exit 1 です。


    P0-6. 「GitHub mutation を拒否する」という安全主張が広すぎる

    current settings は gh api * を allow しています。gh pr review と gh issue edit の文字列だけを拒否しても、REST/GraphQL、別 HTTP client、Python library、alias、wrapper を使った mutation を防いだことにはなりません。

    GitHub 側では Issue、Pull Request 等の read/write permission が分離されています。client-side hook に加えて、runtime probe または reviewer session に渡す credential を read-only scope にすれば、server-side の defense-in-depth が成立します。(GitHub Docs)

    選択が必要

    推奨は A です。

    A. reviewer runtime に read-only GitHub credential を使用し、hook allowlist と二層化する
    B. AC3 の主張を「canonical Claude Code Bash tool 経由の reviewer mutation を hook が拒否する」に狭め、server-side mutation impossibility は主張しない

    write-capable な通常ユーザー credential を使ったまま「GitHub mutation を拒否する」と一般化するのは不適切です。

    runtime negative test も実 repository object を変更しかける方法ではなく、hook deny event を一次証跡にしてください。Git の test は一時 repository、GitHub mutation は read-only credential または破壊不能な test target を使用します。


    P0-7. Hook SSOT と Allowed Paths が矛盾している

    #1881 は secret_boundary_guard の責務を、secret/credential 保護から reviewer の repository/GitHub mutation 制御へ拡張します。

    しかし現行の docs/dev/hook-boundaries.md は、

    • hook は local guardrail であり security boundary ではない
    • secret_boundary_guard は secret / credential 境界
    • security の最終保護は repository permission、CI、branch protection

    という責務を宣言しています。

    リポジトリには、この manifest と .claude/settings.json の topology drift を検出する checker と test もあります。

    一方、#1881 の Allowed Paths には以下がありません。

    docs/dev/hook-boundaries.md
    tests/test_hook_boundaries_doc.py
    scripts/check_hook_boundaries.py
    

    docs/dev/workflow.md も、SSOT、Agent prompt、deterministic guardrail の変更は原則同じ PR で整合させ、分割する場合は follow-up と暫定リスクを明示するよう要求しています。

    したがって #1881 の Stop Condition である「Allowed Paths 外の変更が必要」に既に該当しています。

    必須修正

    次のどちらかが必要です。

    1. docs/dev/hook-boundaries.md と対応 test を Allowed Paths に追加する
    2. SSOT 更新を predecessor Issue に分割し、その merge を 実装: minimal harness の permission/runtime safety boundary を復旧する #1881 の hard dependency にする

    単に production hook だけ変更し、manifest を stale のまま残す案は不可です。


    P1 重要修正

    P1-1. test_guard_graphql_mutation.py は対象 production unit が違う

    この test は secret_boundary_guard.sh ではなく guard-japanese-prose.sh を起動し、GUARD_JAPANESE_PROSE_MODE=enforce で GraphQL mutation を検査しています。#1881 の reviewer permission boundary の proof にはなりません。

    選択肢は次のどちらかです。

    • Allowed Paths から除外する
    • reviewer-specific mutation test を新規 test file に分離する

    既存 test 名だけを流用して AC3 の証跡にしてはいけません。

    P1-2. Hook の実行順序を安全性の前提にしてはいけない

    同一 event に一致した hook は並列実行され、宣言順が直列 contract にはなりません。ある hook の deny によって sibling hook の副作用まで起きないと仮定してはいけません。(Claude)

    この論点は OPEN Issue #1735 が、secret_boundary_guard.sh の portability、並列 hook semantics、permutation/concurrency tests とともに既に所有しています。#1735 は現時点で OPEN、コメントによる disposition もありません。

    しかも現行 hook には #1735 が指摘する \s、\b、echo "$COMMAND" が残っています。

    #1881 は次のどちらかへ明示的に再束縛してください。

    「同じ hunk の未マージ PR が見つかった場合だけ停止」では遅すぎます。Issue 契約段階で ownership が競合しています。

    P1-3. #1775 との disposition が必要

    OPEN Issue #1775 は、次を既に scope としています。

    • .claude/settings.json
    • PreToolUse hook
    • exact allow/deny
    • fresh-session runtime smoke
    • GitHub/repository read-only enforcement

    これは #1881 と意味的に重複します。#1775 が heavy audit schema を含むため minimal harness と互換でない、という判断自体は理解できますが、「再利用しない」だけでは ownership は解消されません。#1775 は OPEN のまま、コメントもありません。

    #1775 に以下のいずれかを記録してください。

    P1-4. Distribution scope を repo_local に固定する

    repo-local SubAgent と project settings/hook による境界は、plugin distribution や外部 Agent package にそのまま移植される保証がありません。Claude Code plugin subagent では hooks や permissionMode の扱いも repo-local Agent と同一ではありません。(Claude)

    #1858 を実装対象に含める必要はありませんが、#1881 の safety claim に次を追加すべきです。

    distribution_scope: repo_local
    plugin / externally distributed agent は未検証
    

    推奨する修正版の境界設計

    1. Trusted computing base を明記する

    #1881 本文に次を追加してください。

    本 Issue が信頼する境界:
    - reviewed SHA の .claude/settings.json
    - reviewed SHA の canonical PreToolUse guard
    - Claude Code permission engine
    - sandbox effective configuration
    - read-only GitHub credential または限定された mutation claim
    - runtime probe 自身
    
    信頼しないもの:
    - Agent の自然言語自己申告
    - prompt 上の「書き込まない」指示
    - static fixture だけの結果
    - network/auth failure
    - command string の部分一致だけ
    

    2. Agent ごとの policy を分ける

    Agent Secret protection Filesystem write Git/GitHub mutation
    pr-reviewer deny deny deny
    issue-reviewer deny bounded temp/artifact write は許可 deny
    implementation / orchestration Agent deny 既存 workflow に従う 既存 guard/policy に従う

    この違いを無視して全 Agent 共通 hook にすると、正常経路か安全性のどちらかが壊れます。

    3. Runtime case ごとの証拠を固定する

    Case 一次証拠 PASS 条件
    safe reference read Read tool event exact canonical path と marker を読み取った
    missing Skill startup/config event expected Skill が欠落したため明示 FAIL
    secret Read tool PreToolUse deny sensitive path classification 一致
    Bash/Python/Node secret read PreToolUse deny reviewer allowlist 外として実行前 deny
    shell write PreToolUse deny target file hash 不変
    git commit / push PreToolUse deny HEAD/ref/remote 不変
    GitHub mutation PreToolUse deny + read-only credential remote object 不変
    sandbox unavailable environment preflight SKIP: + exit 77

    Acceptance Criteria の修正版

    少なくとも次の形へ変更すべきです。

    AC1 — static policy

    Read(**/.claude/**) が deny list から消え、explicit sensitive deny と exact hook wiring が維持される。current main では対応 test が FAIL する。

    AC2 — positive preload/reference control

    fresh issue-reviewer session で review-issue preload と exact safe reference Read event を観測する。model の自然言語回答だけでは PASS にしない。

    AC3 — reviewer-specific enforcement

    fresh pr-reviewer session で、secret read、arbitrary interpreter、redirection、filesystem write、Git mutation、GitHub mutationが、agent_type=pr-reviewer に束縛された canonical PreToolUse guard によって実行前拒否される。

    AC4 — non-interference

    同じ hook 変更後も、非 reviewer Agent の既存 sanctioned mutation lane と issue-reviewer の bounded artifact write が維持される。

    AC5 — unavailable semantics

    CLI、必要 feature、認証、sandbox、service の unavailable は exit 77。unexpected allow、identity mismatch、hook event missing、tool non-attempt は exit 1。

    AC6 — evidence hygiene

    --no-session-persistence を使用し、stream JSON は memory 内で解析する。保存するのは case、expected/observed decision、handler ID、agent type、redacted reason、postcondition のみ。raw prompt、raw transcript、credential、HOME 絶対パスは保存しない。

    AC7 — SSOT and ownership

    docs/dev/hook-boundaries.md、hook topology test、#1735、#1775 の disposition が implementation 前に整合している。


    Verification Commands の修正版イメージ

    # AC1: current main では FAIL すること
    uv run --locked pytest \
      .claude/hooks/tests/test_secret_boundary_contract.py \
      -q -k 'blanket_claude_read_deny or sensitive_denies or hook_wiring'
    
    # AC2: positive control
    uv run --locked python3 \
      scripts/agent-ops/verify_pr_reviewer_permission_boundary.py \
      --agent-name issue-reviewer \
      --expected-skill review-issue \
      --cases safe_reference_read,missing_skill \
      --fresh-session \
      --require-hook-events \
      --require-no-session-persistence
    
    # AC3: actual enforcement target
    uv run --locked python3 \
      scripts/agent-ops/verify_pr_reviewer_permission_boundary.py \
      --agent-name pr-reviewer \
      --expected-agent-type pr-reviewer \
      --cases secret_read,bash_secret_read,python_secret_read,node_secret_read,shell_write,git_commit,git_push,github_mutation \
      --fresh-session \
      --require-sandbox \
      --require-hook-events \
      --require-no-session-persistence
    
    # AC4: non-interference
    uv run --locked pytest \
      scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py \
      -q -k 'reviewer_scoped or issue_reviewer_bounded_write or non_reviewer_unchanged'
    
    # Hook SSOT
    uv run --locked pytest tests/test_hook_boundaries_doc.py -q
    uv run --locked python3 scripts/check_hook_boundaries.py

    実装再開条件

    次をすべて満たすまで #1881 は implementation_ready: false とすべきです。

    1. issue-reviewer と pr-reviewer の probe lane を分離する
    2. reviewer policy を agent_type に束縛した default-deny allowlist として定義する
    3. AC1 を baseline FAIL の構造 test に直す
    4. runtime PASS を hook event provenance と postcondition で定義する
    5. sandbox hard-fail と session non-persistence を明記する
    6. GitHub mutation claim を read-only credential または限定 claim に修正する
    7. docs/dev/hook-boundaries.md と topology test を Allowed Paths に含める
    8. 実装: secret_boundary_guard の grep ERE portability を改善する #1735 と 実装: controlled direct fallback executors #1775 に明示的 disposition を記録する

    実際の認証済み Claude Code fresh session はこのレビュー環境では実行していません。判定は、2026年7月31日時点の live Issue/PR、current repository assets、関連契約、および現行の Claude Code・GitHub 一次資料の照合に基づいています。


    you asked

    message time: 2026-08-01 00:27:25

    「P0-6. 「GitHub mutation を拒否する」という安全主張が広すぎる」→B. AC3 の主張を「canonical Claude Code Bash tool 経由の reviewer mutation を hook が拒否する」に狭め、server-side mutation impossibility は主張しない
    個人趣味開発の領域を一括する過剰な制約は採用しません。
    「docs/dev/hook-boundaries.md と対応 test を Allowed Paths に追加する」採用

    動作検証についてはClaudeCodeとCodexCLIの両方でワークツリー配下でセッションを起動し、その出力およびセッションログを参照して、サブエージェントの発火状態やコンテクストの状態を確認する必要があると思います。開発環境にはherdrが導入されているので、ワークツリー配下でAIエージェント用のペーンを起動してClaudeCodeとCodexCLIの検証用セッションを起動し、動作検証用のプロンプトを送信、メインセッションから動作を確認する手もあります。

    ワークツリー配下でClaudeCodeとCodexCLIの動作検証を行うエージェントスキルが必要だと思います。WEB検索して高品質化Issueの起票を提案して。


    chatgpt response

    ご指定の判断を前提に、server-side不可能性は主張せず、repo-localのcanonical Bash tool経由だけを検証対象に狭めます。あわせて、herdr・Claude Code・Codex CLIの現行実装と、リポジトリ内の既存runtime verification資産を確認し、過剰なcontrol-planeを再導入しない独立Issue案へ落とします。

    現行資産には、PR #1864でherdr上のCodex TUIをワークツリーから起動し、/status・Skill一覧・pane transcriptを確認した先行証跡があります。ただし手順は再利用可能なSkillになっておらず、Claude側との共通化もありません。

    採用判断は妥当です。#1881 の AC3 は、次の repo-local claim に限定すべきです。

    canonical Claude Code Bash tool 経由で、pr-reviewer が試行する repository/GitHub mutation を、reviewer-scoped PreToolUse hook が実行前に拒否する。

    GitHub credential 自体を read-only 化することや、server-side mutation impossibility は要求しません。また、docs/dev/hook-boundaries.md と tests/test_hook_boundaries_doc.py を #1881 の Allowed Paths に加える方針で整合します。

    新規 Skill は、非対話の構造化実行を基本経路、herdr TUI を観測が必要な場合の経路に分けるのが適切です。Claude Code は hook event を含む stream JSON とセッション非永続化を備え、Codex CLI は exec --json --ephemeral -C <worktree> を備えています。(Claude) Herdr は通常プロセス用の pane run/read/wait-output と、対話型AI用の agent start/prompt/wait/read を明確に分離しており、Claude・Codex双方をサポートします。(Herdr)

    リポジトリには既に、worktree 内でherdrからCodex TUIを起動し、/status、Skill discovery、pane transcriptを確認した手作業の先行証跡があります。新Issueはこれを再利用可能なSkillへ縮小・一般化する位置付けです。

    起票案

    **Document Title: **

    実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する

    Machine-Readable Contract

    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: "#1860"
    goal_ref: "minimal harness の runtime verification を、linked worktree 内の native CLI structured output と herdr pane observation で再利用可能にする"
    change_kind: mixed

    Parent Issue

    #1860

    Related Issues

    Parent Goal Ref

    • Goal: AIエージェント運用を minimal harness へ縮退し、過剰な state machine、schema、digest、receipt、publisher を導入せず、実際の runtime output と postcondition を検証する。
    • Desired Destination: Claude Code と Codex CLI の双方について、linked worktree 内で fresh session を起動し、structured event、herdr pane output、必要時のみ native session-log metadata を取得できる共有 Skill が存在する。

    Current Validated Scope

    • PR fix: Codex permission profile root default を :workspace に復元する (#1859) #1864 の runtime evidence では、herdr 0.7.5 上の linked worktree から Codex TUI を起動し、/status、Skill一覧、filesystem read、pane transcript を確認している。
    • 上記は個別 PR の手動手順と tracked evidence であり、Claude Code と Codex CLIに共通利用できる Skill/runner にはなっていない。
    • Claude Code は非対話実行で stream JSON、hook lifecycle event、turn上限、session persistence無効化を利用できる。
    • Codex CLI は非対話の codex exec で worktree cwd、JSONL event、ephemeral session、sandbox modeを指定できる。
    • herdr は通常プロセスに対する pane API と、認識済みAIエージェントに対する agent API を分離している。
    • current repository の scripts/agent-ops/tests/ は既存 Python CI targetに含まれているため、runner testを同ディレクトリへ配置すれば新しいCI targetの追加は不要である。
    • .agents/skills/<name>/SKILL.md から .claude/skills/<name>/SKILL.md を読む derived thin wrapper の既存パターンが存在する。

    Problem

    runtime verification のたびに、実装者またはレビュアーが以下を手作業で行っている。

    1. 対象 worktree を確認する
    2. Claude Code または Codex CLI を起動する
    3. 検証用 prompt を投入する
    4. subagent、hook、Skill、cwd、context の状態を端末表示から読む
    5. native session logやpane outputを探索する
    6. raw transcriptやcredentialを漏らさないよう証跡を手作業で要約する
    7. pane/sessionを終了する

    この手順は再利用可能な入口がなく、runtimeごと・PRごとに実行方法と証跡品質が変わる。

    一方、これを新しい generic orchestration framework、独自result schema、session replay authority、永続state storeへ拡張すると、#1860で撤去した過剰なcontrol-planeを再導入する。

    Outcome

    次の二つの実行laneを持つ repo-local共有Skill worktree-agent-runtime-smoke が提供される。

    Lane A: structured smoke

    通常はこちらを使用する。

    • Claude Code:
      • print mode
      • stream JSON
      • hook event出力
      • session非永続
      • bounded turns
    • Codex CLI:
      • codex exec
      • JSONL event
      • ephemeral session
      • explicit worktree cwd
        -既存sandbox/permission設定を維持

    structured output、exit code、worktree postconditionを証跡とする。

    Lane B: interactive herdr smoke

    TUI固有挙動、Skill picker、approval画面、subagent UI、context表示、interactive statusの観測が必要な場合だけ使用する。

    • linked worktreeをcwdとするherdr sibling paneを作成する
    • Claude CodeまたはCodex CLIを対話Agentとして起動する
      -検証用promptをatomicに送信する
    • lifecycle stateをbounded timeoutで待つ
    • pane output、agent detection、native session referenceを取得する
      -必要時だけnative session logのmetadataを抽出する
      -証跡取得後にpaneを閉じる。明示指定時のみpaneを残す

    本Skillはruntime起動・観測・証跡収集だけを所有する。対象Issue固有の semantic verdict、permission分類、APPROVE/REQUEST_CHANGES判定はcallerが所有する。

    Design Decisions

    1. structured laneを既定とする

    hook event、tool event、exit code、postconditionを非対話で取得できる場合、TUI screen scrapingを使わない。

    interactive laneは次の場合に限定する。

    • TUI /status やSkill pickerを確認する
    • approval/blocked UIを確認する
    • structured modeでは露出しないsubagent/context状態を確認する
      -人間が端末状態を直接監督する必要がある

    2. herdrをrepository全体のhard dependencyにしない

    • mode=structured はherdr外でも直接実行可能とする
    • transport=auto はherdr内ならpaneを利用し、herdr外ではdirect subprocessを利用できる
    • mode=interactive はherdrを必須とする
    • HERDR_ENV=1、必要CLI capability、running serverがない場合、interactive laneは SKIP: と exit 77を返す
    • herdr unavailableをstructured laneの失敗へ波及させない

    3. paneとagentの責務を分離する

    • claude -p、codex exec 等の終了型コマンドは pane run/direct subprocessで実行する
    • Claude Code/Codex CLIの対話TUIは agent start で起動する
    • prompt投入は agent prompt
    • lifecycle待機は agent wait
      -出力取得は agent read または pane read
    • agent stateだけをprocess成功の代替にしない

    4. raw transcriptをauthorityにしない

    保存可能な証跡:

    • runtime名とversion
    • tested HEAD
    • repo-relative worktree
    • branch
      -実行lane/transport
    • process exit code
    • herdr pane ID/agent name
    • observed lifecycle state
    • native event typeの件数
    • caller指定のexpected markerの有無
    • bounded redacted output
    • filesystem/Git postcondition
    • session-log metadataの取得可否

    既定で保存しないもの:

    • raw prompt全文
    • raw transcript全文
    • reasoning
    • tool output全文
    • credential
    • environment dump
      -認証情報
    • HOMEを含む絶対パス
    • native session logのworktreeへの複製

    5. native session logは補助証跡とする

    • structured eventまたはherdr outputで判定可能なcaseではsession logを必須にしない
    • callerが明示的に要求した場合のみmetadataを読み取る
    • session IDまたはruntimeが公開するsession referenceに束縛する
    • event type、agent/subagent label、timestamp、cwd marker等のallowlist metadataだけを抽出する
    • undocumentedなlog pathまたはrecord shapeをstable schemaとして扱わない
    • logが見つからないことをruntime成功・失敗へ自動変換しない
    • --require-session-log-metadata が指定されたcaseだけ、取得不能をexit 77とする

    6. semantic判定を再実装しない

    runnerは次だけを判定する。

    • runtimeを起動できたか
      -指定worktreeで動いたか
    • timeoutせず終了またはsettled stateへ到達したか
      -必要なevidenceを取得できたか
    • caller指定のliteral markerが観測されたか
      -禁止されたfilesystem/Git postcondition changeが起きていないか

    次はcaller側の責務とする。

    • hook reasonの意味分類
    • mutation denyの妥当性
    • Skill preload成功のドメイン判定
    • context budget評価
    • review verdict
    • merge readiness

    In Scope

    Shared Skill

    • .claude/skills/worktree-agent-runtime-smoke/SKILL.md をcanonical bodyとして追加する
    • .agents/skills/worktree-agent-runtime-smoke/SKILL.md をderived/non-canonical thin wrapperとして追加する
    • Skill本文はtrigger、inputs、lane選択、主要手順、安全境界、reference mapに限定する
    • runtime固有の詳細をreferencesへ分離する

    Runtime references

    • Claude Code structured/interactive invocation
    • Codex CLI structured/interactive invocation
    • herdr pane/agent APIの使い分け
    • evidence hygieneとsession-log metadata boundary
    • timeout/cleanup/SKIP規約

    Runner

    scripts/agent-ops/run_worktree_agent_runtime_smoke.py を追加する。

    最低限のCLI:

    --runtime claude | codex
    --mode structured | interactive
    --transport auto | direct | herdr
    --worktree <path>
    --prompt-file <path>
    --output-dir <path>
    --timeout-seconds <integer>
    --expect-marker <literal>        # repeatable
    --require-clean-postcondition
    --inspect-session-log-metadata
    --require-session-log-metadata
    --keep-pane
    

    runnerは以下を実施する。

    • shell=False を基本とする
    • canonical repositoryとlinked worktree identityを確認する
    • root checkout、別repository、cwd mismatchを拒否する
    • runtimeとherdrのcapabilityを実コマンドでpreflightする
    • fixed argvでnative CLIを起動する
    • promptをargument interpolationせず、fileまたはstdinで渡す
    • output sizeをboundedにする
    • timeout時にchild processまたはpaneをcleanupする
    • raw outputをmain contextへ展開しない
    • worktree-local untracked directoryにevidenceを保存する
    • exit code 0/1/77を返す

    Claude Code structured invocation

    次のcapabilityを利用する。

    claude -p \
      --output-format stream-json \
      --include-hook-events \
      --no-session-persistence \
      --max-turns <bounded> \
      <prompt>

    runtime versionによりflagが利用できない場合は、silent fallbackせずexit 77とする。

    Codex CLI structured invocation

    次のcapabilityを利用する。

    codex exec \
      -C <worktree> \
      --json \
      --ephemeral \
      <prompt>
    • current repository configurationのsandbox/permission profileを利用する
    • --dangerously-bypass-approvals-and-sandbox、--yolo、danger-full-accessへの自動変更を行わない
    • callerが指定していないmodel/profileをrunnerが上書きしない

    herdr interactive invocation

    概念的な手順:

    herdr pane split --current --direction <right|down> \
      --cwd <worktree> --no-focus
    
    herdr agent start <unique-name> \
      --kind claude|codex \
      --pane <pane-id>
    
    herdr agent prompt <unique-name> \
      "<prompt>" \
      --wait \
      --timeout <milliseconds>
    
    herdr agent get <unique-name>
    herdr agent explain <unique-name> --json
    herdr agent read <unique-name> \
      --source recent-unwrapped \
      --lines <bounded>

    -既存paneのfocusを奪わない

    • unique agent nameはrun-localとする
    • unknown stateを成功扱いしない
    • blocked は自動承認せず証跡を取得して停止する
    • timeoutを必須とする
    • cleanupで検証paneだけを閉じる
    • caller pane、別agent、別workspaceを変更しない

    Evidence output

    <worktree>/artifacts/runtime-smoke/<run-id>/ に次を保存する。

    summary.md
    native-events.jsonl       # structured lane。native outputをbounded/redacted
    pane-output.txt           # interactive lane。bounded/redacted
    agent-detection.json      # herdr agent explainのnative response
    session-log-metadata.txt  # requested and availableの場合のみ
    

    これらはworktree-local untracked evidenceであり、schema、receipt、digest、publisher、approval authorityではない。

    PR本文には summary.md のredacted excerptだけを引用する。

    Tests

    unit/integration testではfake executableとfake herdr CLIを使用し、以下を検証する。

    • argvとcwd
    • prompt file handling
    • timeout
    • exit 0/1/77
    • root checkout拒否
      -別repository拒否
    • pane ID parsing
    • agent start/prompt/read/cleanup順
    • blocked/unknownをPASSにしない
    • output truncation
    • credential/HOME path redaction
    • raw transcript非保存
    • session-log metadata optional/required分岐
    • postcondition change検出
    • thin Codex wrapper

    CIでは実Claude/Codex認証を要求しない。実runtime evidenceはPR review時のmanual/runtime laneで取得する。

    Out of Scope

    • 実装: minimal harness の permission/runtime safety boundary を復旧する #1881 の .claude/settings.json、hook、permission rule変更
    • GitHub server-side mutation impossibilityの証明
    • GitHub credential scopeの変更
    • generic multi-agent task orchestrator
    • worktreeの新規作成/削除
      -自動Issue/PR mutation
    • Agentの実装作業、commit、push
      -自動approval
    • semantic review verdict classifier
    • context budgetの数値評価
    • model品質比較
    • replay、resume、session migration
    • native session log formatの独自stable schema化
    • raw transcriptのtracked artifact化
      -新しいJSON/YAML result schema
    • digest、receipt、publisher、state store
    • cross-repository/plugin distribution

    Acceptance Criteria

    • AC1: Claude canonical SkillとCodex thin wrapperが追加され、Codex wrapperはcanonical bodyへのpointerとruntime固有注意だけを持つ
    • AC2: runnerはcanonical repository内のlinked worktreeだけを受理し、root checkout、別repository、cwd mismatchを実行前に拒否する
    • AC3: Claude structured laneがfresh processでstream JSONとhook eventsを取得し、sessionを永続化せず、bounded timeout後に終了する
    • AC4: Codex structured laneがcodex exec -C <worktree> --json --ephemeralで実行され、JSONL outputとexit codeを取得する
    • AC5: herdr interactive laneがClaude CodeとCodex CLIのそれぞれについてpane作成、agent起動、prompt投入、state待機、bounded output取得、cleanupを実行できる
    • AC6: caller指定のexpected marker、runtime version、tested HEAD、worktree、pane/agent identity、event type count、postconditionがredacted evidenceへ記録され、modelの自然言語自己申告だけを成功証拠にしない
    • AC7: session-log inspectionは明示指定時のみ実行され、allowlist metadataだけを抽出し、raw prompt、reasoning、tool output、credential、HOME絶対パスを保存しない
    • AC8: runtime/auth/required capability/herdrが利用不能なcaseはSKIP:とexit 77、runtime failure/timeout/identity mismatch/unexpected postconditionはexit 1、成功はexit 0を返す
    • AC9: runnerは新しいschema、digest、receipt、publisher、state store、semantic verdict classifierを追加せず、worktree外への書き込みを行わない
    • AC10: fake runtime/fake herdrを用いたunit testがCIでPASSし、認証済み開発環境のlinked worktreeでClaude structured、Codex structured、Claude interactive、Codex interactiveの4 smoke evidenceがcurrent PR headに対して取得される
    • AC11: docs/dev/runtime-verification-policy.md と docs/dev/agent-runtime-ops.md に、structured laneを既定、interactive herdr laneを必要時のみ利用する境界が記載される
    • AC12: docs/dev/agent-skill-boundaries.md に新Skillのowner、trigger、non-trigger、output boundaryが記録される

    Runtime Verification Applicability

    decision: immediate
    reason: >
      本IssueはClaude Code、Codex CLI、herdrの実process/TUIを起動し、
      worktree binding、structured event、agent lifecycle、pane output、
      cleanupを観測する機能を追加するため、static testだけでは完了を証明できない。
    applicable_acs:
      - AC3
      - AC4
      - AC5
      - AC6
      - AC7
      - AC10
    execution_environment:
      os: "WSL2 Ubuntu 24.04"
      repository_state: "clean linked worktree"
      required_commands:
        - claude
        - codex
        - herdr
      authentication: "既存の認証済みローカル環境"
      herdr_policy: "interactive laneのみ必須。structured direct laneには必須にしない"
    skip_conditions:
      - "対象runtimeが未インストールまたは未認証"
      - "要求したnative structured-output capabilityが利用不能"
      - "interactive caseでHERDR_ENV=1またはrunning herdr serverが利用不能"
      - "native session-log metadataをrequireしたcaseでsession referenceを取得不能"
    fallback_policy:
      - "structured capability不在をplain text self-reportでPASSにしない"
      - "herdr interactive caseをdirect subprocessの成功でPASSにしない"
      - "session-log-required caseをpane outputだけでPASSにしない"
      - "SKIPをPASSへ昇格しない"
    artifact_requirements:
      - "worktree-local artifacts/runtime-smoke/<run-id>/summary.md"
      - "Claude structured native-events.jsonl"
      - "Codex structured native-events.jsonl"
      - "Claude interactive pane-output.txt / agent-detection.json"
      - "Codex interactive pane-output.txt / agent-detection.json"
      - "requested caseのみsession-log-metadata.txt"

    Verification Commands

    # AC1 / AC9 / AC12
    # baseline-expect: fail
    uv run --locked pytest \
      scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py \
      tests/test_codex_agent_bridge_contract.py \
      -q
    # AC2 / AC8
    # baseline-expect: fail
    uv run --locked pytest \
      scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py \
      -q -k 'worktree or exit_code or timeout or postcondition'
    # AC3
    # baseline-expect: fail
    # preflight-scope: runtime_only
    uv run --locked python3 \
      scripts/agent-ops/run_worktree_agent_runtime_smoke.py \
      --runtime claude \
      --mode structured \
      --transport auto \
      --worktree "$PWD" \
      --prompt-file tmp/runtime-smoke/claude-structured.md \
      --output-dir artifacts/runtime-smoke/claude-structured \
      --timeout-seconds 180 \
      --require-clean-postcondition
    # AC4
    # baseline-expect: fail
    # preflight-scope: runtime_only
    uv run --locked python3 \
      scripts/agent-ops/run_worktree_agent_runtime_smoke.py \
      --runtime codex \
      --mode structured \
      --transport auto \
      --worktree "$PWD" \
      --prompt-file tmp/runtime-smoke/codex-structured.md \
      --output-dir artifacts/runtime-smoke/codex-structured \
      --timeout-seconds 180 \
      --require-clean-postcondition
    # AC5 / AC6 / AC7: Claude interactive
    # baseline-expect: fail
    # preflight-scope: runtime_only
    uv run --locked python3 \
      scripts/agent-ops/run_worktree_agent_runtime_smoke.py \
      --runtime claude \
      --mode interactive \
      --transport herdr \
      --worktree "$PWD" \
      --prompt-file tmp/runtime-smoke/claude-interactive.md \
      --output-dir artifacts/runtime-smoke/claude-interactive \
      --timeout-seconds 300 \
      --inspect-session-log-metadata \
      --require-clean-postcondition
    # AC5 / AC6 / AC7: Codex interactive
    # baseline-expect: fail
    # preflight-scope: runtime_only
    uv run --locked python3 \
      scripts/agent-ops/run_worktree_agent_runtime_smoke.py \
      --runtime codex \
      --mode interactive \
      --transport herdr \
      --worktree "$PWD" \
      --prompt-file tmp/runtime-smoke/codex-interactive.md \
      --output-dir artifacts/runtime-smoke/codex-interactive \
      --timeout-seconds 300 \
      --inspect-session-log-metadata \
      --require-clean-postcondition
    # AC11
    # baseline-expect: fail
    rg -n \
      -e "worktree-agent-runtime-smoke" \
      -e "structured lane" \
      -e "interactive.*herdr" \
      docs/dev/runtime-verification-policy.md \
      docs/dev/agent-runtime-ops.md \
      docs/dev/agent-skill-boundaries.md

    Allowed Paths

    • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
    • .claude/skills/worktree-agent-runtime-smoke/references/claude-code.md
    • .claude/skills/worktree-agent-runtime-smoke/references/codex-cli.md
    • .claude/skills/worktree-agent-runtime-smoke/references/herdr.md
    • .claude/skills/worktree-agent-runtime-smoke/references/evidence-hygiene.md
    • .agents/skills/worktree-agent-runtime-smoke/SKILL.md
    • scripts/agent-ops/run_worktree_agent_runtime_smoke.py
    • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py
    • tests/test_codex_agent_bridge_contract.py
    • docs/dev/runtime-verification-policy.md
    • docs/dev/agent-runtime-ops.md
    • docs/dev/agent-skill-boundaries.md

    Stop Conditions

    • Allowed Paths外のrepo-tracked file変更が必要
    • .claude/settings.json、.codex/config.toml、hook、permission profileの変更が必要
    • GitHub credential scope変更が必要
    • worktree作成/削除機能が必要
    • generic task orchestrator、multi-agent scheduler、replay systemが必要
    • native session logの全record shapeを独自schemaとして固定する必要
    • raw transcriptをtracked artifactまたはPR本文へ保存する必要
    • semantic verdict classifierが必要
      -新しいschema、digest、receipt、publisher、state storeが必要
    • --yolo、sandbox bypass、hook trust bypassが必要
    • caller paneまたは別agentのprocessを終了する必要
    • actual Claude/Codex/herdr runtimeを実行できず、SKIPをPASSへ昇格する必要
    • nested subagentのsemantic結果をrunner自身が再判定する必要

    Required Skills

    • Python
    • pytest
    • Claude Code CLI
    • Codex CLI
    • herdr CLI/agent automation
    • Git worktree
    • terminal output redaction

    Required Design References

    • docs/dev/runtime-verification-policy.md
    • docs/dev/agent-runtime-ops.md
    • docs/dev/agent-skill-boundaries.md
    • Claude Code CLI reference: https://code.claude.com/docs/en/cli-usage
    • Claude Code hooks reference: https://code.claude.com/docs/en/hooks
    • Codex developer commands: https://developers.openai.com/codex/cli/reference
    • herdr Agent automation: https://herdr.dev/docs/agent-automation/
    • herdr Socket API: https://herdr.dev/docs/socket-api/
    • herdr CLI reference: https://herdr.dev/docs/cli-reference/

    Scope Delta

    -追加: worktree-local cross-runtime smoke Skill
    -追加: Claude Code structured/interactive adapter
    -追加: Codex CLI structured/interactive adapter
    -追加: herdr pane/agent observation
    -追加: optional metadata-only native session-log inspection
    -維持:既存runtime permission、sandbox、hook、GitHub credential
    -非追加: schema、digest、receipt、publisher、state store、semantic classifier

    Delivery Rule

    • 1 Issue = 1 Draft PR
    • dedicated linked worktree
    • current headに対して4 runtime smokeを再実行する
    • raw transcriptをcommitしない
    • PR本文にはredacted summaryだけを記載する
      -人間による最終マージを維持する

    Notes for Reviewer

    本Issueは runtime verification のtransport/observationを共通化するだけであり、個別Issueの安全判定を一元化するcontrol-planeではない。

    #1881は、本IssueのrunnerでClaude Code/Codex CLIを起動しても、mutation denyの意味判定、hook reason、postconditionの期待値を引き続き#1881側で所有する。

    Codex CLIの先行herdr smokeで行った /status、Skill picker、pane transcript確認を一般化するが、そのtracked artifact形式やSHA256 manifestは再利用しない。

    #1881 に同時反映する修正

    新Issueを <NEW_ISSUE> とした場合、#1881 は次のように再束縛するのが適切です。

    • blocked_by: ["#<NEW_ISSUE>"] または Blocking Dependency節を追加
    • AC3を以下に変更

    fresh pr-reviewer sessionにおいて、canonical Claude Code Bash tool経由のshell write、gh pr review、gh issue edit、git push、git commit試行がreviewer-scoped PreToolUse hookによって実行前に拒否される。GitHub server-side mutation impossibilityまたはcredential自体のread-only性は本ACの主張に含めない。

    • Allowed Pathsへ追加
    docs/dev/hook-boundaries.md
    tests/test_hook_boundaries_doc.py
    
    • 実装: minimal harness の permission/runtime safety boundary を復旧する #1881 固有runnerは、新Skillのtransportを呼び出した上で、hook event、agent_type=pr-reviewer、postconditionを解析する薄いconsumerに縮小
    • Claude CodeとCodex CLIの両方で同じ#1881用promptを実行し、結果差はwarningではなくruntime別に明示
    • interactive herdr laneはsubagent/context観測が必要なcaseだけに限定し、通常のpermission event検証はstructured laneを優先する

    Powered by AI Exporter

  3. squne121 commented on Jul 31, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-31T15:47:17Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1881
      body_sha256: "sha256:cecf727aabd3c12ccfad293a61ef155311220865f313ed8c973557dc571b0723"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:cecf727aabd3c12ccfad293a61ef155311220865f313ed8c973557dc571b0723","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":3,"raw_command":"uv run --locked pytest .claude/hooks/tests/test_secret_boundary_contract.py -q","command_hash":"sha256:c3648776f546a0d6d460b4cf3f59242749fd51399a1f1f30cee0f986a94c43e6","execution_key_hash":"sha256:11284e323d1c33da0cb54a72c062f54ab45ff914f3e8e201546708fbbd053014","runner":"exec","exit_code":0,"classification":"expected_pass","category":"baseline_expect_pass","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["...................................................                      [100%]","51 passed in 1.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":1186,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"pass","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: pass"},"strict":null,"repair":null},{"ac":"AC2","line":3,"raw_command":"uv run --locked pytest scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py -q -k fresh_session_reference_read","command_hash":"sha256:4f826c30ccbfae1dace5dd9c84ae61755d0ae89addc17532c1762862609c464e","execution_key_hash":"sha256:117033bcb46a57eb8a1ec4eca3f9b137b3bd0c14b6af0c77553c9403e4d17170","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":187,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC3","line":4,"raw_command":"uv run --locked python3 scripts/agent-ops/verify_pr_reviewer_permission_boundary.py --agent .claude/agents/issue-reviewer.md --skill .claude/skills/review-issue --cases safe_reference_read,secret_read,bash_secret_read,python_secret_read,node_secret_read,shell_write,github_mutation,missing_skill --require-sandbox","command_hash":"sha256:c5705c194063d27515c1cada77fdcd92e5d12665f946eb563d0b933f758b8349","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_runtime_only","decision":"go","scope_class":"runtime_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null,"verification_owner":"impl-review-loop","deferred_reason":"VC marked runtime_only; verification deferred to post-implementation runtime","runtime_verification_required":true},{"ac":"AC4","line":3,"raw_command":"uv run --locked pytest scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py -q -k unavailable_is_skip","command_hash":"sha256:383753a4ef240a933c1908880c0a59723f5a0bd10b414e83a5ff76ea6484f2ec","execution_key_hash":"sha256:75db3bde878e3e6f96067b551a7bd8b4b8303c56fc99e7f77dd536cf20ff1083","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":199,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC5","line":3,"raw_command":"uv run --locked pytest scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py -q -k no_authority_artifacts_or_sensitive_output","command_hash":"sha256:d7845062d7c75843b80b7ba0fc6dcbe1c037a92dea4a50272b3c7317c1324aeb","execution_key_hash":"sha256:9096ddcf5bfe67e26bddded9f7a8d94af98a2ab671030ceee5db67dae88ac4fd","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":183,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null}]
        declared_path_overlap: {"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"418945e5a5de8df4605a47a1518d85c17c140177","draft_policy":"include_drafts","prs":[{"number":1528,"title":"feat(cleanup): 同一実行内の branch-only fallback を追加","base_ref_name":"main","head_ref_name":"worktree-issue-1403-post-merge-cleanup-dedicated-branch-forc","head_ref_oid":"b29007580ae225eb9676c7f32c878ee2bb9ccaa9","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1528","changed_files_count_graphql":4},{"number":1879,"title":"feat(codex): enable multi-agent v2 config","base_ref_name":"main","head_ref_name":"worktree-issue-1835-codex-config-toml-multi-agent-v2-max-dep","head_ref_oid":"9fb44e042ca25cbed5a2b50abfd96988acac751b","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1879","changed_files_count_graphql":8},{"number":1880,"title":"docs: workflow SSOT・Skill entrypointをPR #1875マージ後の状態へ整合 (#1876)","base_ref_name":"main","head_ref_name":"worktree-issue-1876-workflow-ssot-minimal-harness","head_ref_oid":"3238bfec70c1a41d544fe4b7e71df72dc3fb69b2","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1880","changed_files_count_graphql":5},{"number":1884,"title":"fix(refinement): trusted anchor iteration-zero を実装 (#1877)","base_ref_name":"main","head_ref_name":"worktree-issue-1877-trusted-anchor-iteration-zero","head_ref_oid":"ae1c8226548486e4cd35e6cb2e71dd6954398997","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1884","changed_files_count_graphql":4}],"fetched_count":4,"totalCount":4,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:53739286a975fd9ec284d0a5359cde2e0437fa01043303cdcd9bd7e1977b45a3","errors":[]},"inventory_digest_extended":"sha256:ec4d1ff3f76eeb0fefd49f0f0b88193700051106f805a15569717e5516bb2809","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: {"issue_number":1881,"contract_source_kind":"issue_comment","contract_source_id":"5144761455","contract_body_sha256":"sha256:cecf727aabd3c12ccfad293a61ef155311220865f313ed8c973557dc571b0723","allowed_paths_normalized_sha256":"bb631a040707101d57271775ca579f0167d2147fff965b10e1f00f8427157b23","base_ref":"main","base_sha_at_snapshot":"418945e5a5de8df4605a47a1518d85c17c140177"}
  4. squne121 commented on Jul 31, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: approved

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/1881#issuecomment-5144761455
        generated_at: "2026-07-31T15:47:17Z"
        body_sha256: "sha256:cecf727aabd3c12ccfad293a61ef155311220865f313ed8c973557dc571b0723"
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-07-31T15:47:43Z"
      checked_body_sha256: "sha256:cecf727aabd3c12ccfad293a61ef155311220865f313ed8c973557dc571b0723"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []
  5. squne121 commented on Jul 31, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-31T16:02:01Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1881
      body_sha256: "sha256:fe7b3d01449e2ff328d7ee810c0c8e60d237c0338a530a4f6ce8e41d73201895"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:fe7b3d01449e2ff328d7ee810c0c8e60d237c0338a530a4f6ce8e41d73201895","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":3,"raw_command":"uv run --locked pytest .claude/hooks/tests/test_secret_boundary_contract.py -q","command_hash":"sha256:c3648776f546a0d6d460b4cf3f59242749fd51399a1f1f30cee0f986a94c43e6","execution_key_hash":"sha256:11284e323d1c33da0cb54a72c062f54ab45ff914f3e8e201546708fbbd053014","runner":"exec","exit_code":0,"classification":"expected_pass","category":"baseline_expect_pass","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["...................................................                      [100%]","51 passed in 3.47s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":5287,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"pass","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: pass"},"strict":null,"repair":null},{"ac":"AC2","line":3,"raw_command":"uv run --locked pytest scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py -q -k fresh_session_reference_read","command_hash":"sha256:4f826c30ccbfae1dace5dd9c84ae61755d0ae89addc17532c1762862609c464e","execution_key_hash":"sha256:117033bcb46a57eb8a1ec4eca3f9b137b3bd0c14b6af0c77553c9403e4d17170","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":509,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC3","line":4,"raw_command":"uv run --locked python3 scripts/agent-ops/verify_pr_reviewer_permission_boundary.py --runtime claude --mode structured --transport auto --agent pr-reviewer --expect-marker reviewer-deny --cases secret_read,bash_secret_read,python_secret_read,node_secret_read,shell_write,github_mutation --require-clean-postcondition","command_hash":"sha256:fa7c9466f9f0e7ef4002676eeeea793a76918076437e4b3c5c874f0c092d81e4","execution_key_hash":null,"runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_runtime_only","decision":"go","scope_class":"runtime_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null,"verification_owner":"impl-review-loop","deferred_reason":"VC marked runtime_only; verification deferred to post-implementation runtime","runtime_verification_required":true},{"ac":"AC4","line":3,"raw_command":"uv run --locked pytest scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py -q -k unavailable_is_skip","command_hash":"sha256:383753a4ef240a933c1908880c0a59723f5a0bd10b414e83a5ff76ea6484f2ec","execution_key_hash":"sha256:75db3bde878e3e6f96067b551a7bd8b4b8303c56fc99e7f77dd536cf20ff1083","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":452,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC5","line":3,"raw_command":"uv run --locked pytest scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py -q -k no_authority_artifacts_or_sensitive_output","command_hash":"sha256:d7845062d7c75843b80b7ba0fc6dcbe1c037a92dea4a50272b3c7317c1324aeb","execution_key_hash":"sha256:9096ddcf5bfe67e26bddded9f7a8d94af98a2ab671030ceee5db67dae88ac4fd","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":362,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null}]
        declared_path_overlap: {"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"418945e5a5de8df4605a47a1518d85c17c140177","draft_policy":"include_drafts","prs":[{"number":1528,"title":"feat(cleanup): 同一実行内の branch-only fallback を追加","base_ref_name":"main","head_ref_name":"worktree-issue-1403-post-merge-cleanup-dedicated-branch-forc","head_ref_oid":"b29007580ae225eb9676c7f32c878ee2bb9ccaa9","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1528","changed_files_count_graphql":4},{"number":1879,"title":"feat(codex): enable multi-agent v2 config","base_ref_name":"main","head_ref_name":"worktree-issue-1835-codex-config-toml-multi-agent-v2-max-dep","head_ref_oid":"9fb44e042ca25cbed5a2b50abfd96988acac751b","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1879","changed_files_count_graphql":8},{"number":1880,"title":"docs: workflow SSOT・Skill entrypointをPR #1875マージ後の状態へ整合 (#1876)","base_ref_name":"main","head_ref_name":"worktree-issue-1876-workflow-ssot-minimal-harness","head_ref_oid":"3238bfec70c1a41d544fe4b7e71df72dc3fb69b2","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1880","changed_files_count_graphql":5},{"number":1884,"title":"fix(refinement): trusted anchor iteration-zero を実装 (#1877)","base_ref_name":"main","head_ref_name":"worktree-issue-1877-trusted-anchor-iteration-zero","head_ref_oid":"289f3c9389bc8e1b927178d8ffa2c5d1cd76e4bc","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1884","changed_files_count_graphql":4},{"number":1888,"title":"refactor: implement-issue/open-pr から peer OPEN Issue overlap preflight を撤去","base_ref_name":"main","head_ref_name":"worktree-issue-1679-overlap-preflight-removal","head_ref_oid":"912081173a395c8f3cb14a75ce576ba13ce591fd","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1888","changed_files_count_graphql":38}],"fetched_count":5,"totalCount":5,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:fc794434ddc01d19732c08074d849be6572d8f3593ffa4942a5706c7d7acc007","errors":[]},"inventory_digest_extended":"sha256:81182b1bbe281c59e6b89337b85f40406148c0444d9ab3af250d9ce6aaca0dbb","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: {"issue_number":1881,"contract_source_kind":"issue_comment","contract_source_id":"5144899223","contract_body_sha256":"sha256:fe7b3d01449e2ff328d7ee810c0c8e60d237c0338a530a4f6ce8e41d73201895","allowed_paths_normalized_sha256":"800f3783ae4ced240515aa63275decfc8d5a0f45e671375e84224785f7828fed","base_ref":"main","base_sha_at_snapshot":"418945e5a5de8df4605a47a1518d85c17c140177"}
  6. squne121 commented on Jul 31, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: blocked

    LOOP_HANDOFF_RESULT_V1:
      status: blocked
      routing_action: blocked
      contract_review:
        status: blocked
        gate_result: blocked
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/1881#issuecomment-5144899223
        generated_at: "2026-07-31T16:03:20Z"
        body_sha256: "sha256:fe7b3d01449e2ff328d7ee810c0c8e60d237c0338a530a4f6ce8e41d73201895"
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: blocked
        required: []
        skipped: []
      blockers:
        - kind: open_native_dependency
          description: "#1887 が OPEN のため、#1881 の実装着手は不可"
      permissions:
        unavailable: []
      generated_at: "2026-07-31T16:03:20Z"
      checked_body_sha256: "sha256:fe7b3d01449e2ff328d7ee810c0c8e60d237c0338a530a4f6ce8e41d73201895"
      checker_exit_code: 1
      missing_sections: []
      missing_contract_keys: []
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues:
        - issue_number: 1887
          status: created
          purpose: "worktree-agent-runtime-smoke の独立実装"
      note_only_observations: []
  7. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    判定

    ISSUE_CONTRACT_REVIEW_V1:
      target_issue: "#1881"
      verdict: REQUEST_CHANGES
      implementation_ready: false
      classification: stale_contract_and_overbroad_guardrail
      highest_severity: P0
      recommended_route: rewrite_in_place

    Issue の目的は依然として有用ですが、現行本文のまま実装へ進めるべきではありません。

    現在も .claude/settings.json の広域 Read(**/.claude/**) deny が pr-reviewer の正規 reference 読み込みを妨げています。一方、同じ project settings は git commit、git push、gh pr comment、gh pr review、gh issue edit などを allow しており、permissionMode: dontAsk の pr-reviewer は、専用 hook がなければそれらを実行できます。問題設定自体は実在します。

    ただし必要なのは「security boundary の再構築」ではなく、次の二点だけです。

    1. tracked な .claude/agents/・.claude/skills/ の参照を復旧する。
    2. pr-reviewer が本来実行しない特定の Git/GitHub mutation を、低干渉な agent-scoped guardrail で止める。

    前回レビューから改善されている点

    現行本文では、issue-reviewer を positive control、pr-reviewer を enforcement target として分離し、GitHub server-side mutation impossibility や credential の read-only 化を主張しない方針、重い schema・receipt・state store を追加しない方針、hook SSOT 文書を Allowed Paths に含める方針が取り込まれています。これは妥当です。

    一方、以前提案されていた「未知の Bash、Python、Node、compound command をすべて拒否する default-deny allowlist」と「sandbox unavailable を hard stop にする設計」は、この個人開発では採用しない方がよいです。pr-reviewer は実際に多数の read-only Git/GitHub コマンドと repository script を必要とするため、維持コストと誤拒否が大きすぎます。

    P0 ブロッカー

    P0-1. 依存関係・前提・Verification Command が current main とずれている

    本文は今も blocked_by: ["#1887"]、#1887 は未完了、#1744 は将来という前提です。しかし #1887 は PR #1921 で実装済みで、structured lane は常に direct subprocess、証跡は allowlist-only の summary.md 一つへ縮小されています。現在の pr-reviewer.md にも既に skills: [pr-review-judge] が存在します。さらに PR #2047 で runner へ main-session identity、agent definition、Skill evidence、settings provenance 等が追加されています。

    特に、#1881 の Verification Command にある --transport auto は、現行 runner には存在しません。PR #1921 で --transport は撤去され、structured lane は常に direct、interactive lane は常に isolated herdr session になっています。現行 Skill も明示的に「--transport と --keep-pane は存在しない」と宣言しています。

    必須修正

    • blocked_by を空にする。
    • #1744 future、#1887 unfinished を削除する。
    • --transport auto を削除する。
    • Claude structured lane、--claude-agent-name pr-reviewer、project-discovery binding を明記する。
    • --hermetic-agent-definition は使わない。hermetic lane は tools を Read のみに差し替えるため、production settings 下の Bash mutation guard を証明できません。

    P0-2. 「safety boundary」という名称と主張が親契約に反する

    親 Issue #1732 と docs/dev/hook-boundaries.md は、Claude/Codex hook を authority や security boundary とせず、local fail-closed guardrail と位置付けています。現在の pr-reviewer.md 自身も、投稿禁止等を behavioral workflow contract とし、既存 guard が technical enforcement authority ではないと明記しています。

    タイトルと Outcome は次へ縮小すべきです。

    実装: pr-reviewer の tracked .claude reference read を復旧し、canonical mutation guardrail を追加する

    主張する範囲も次に固定します。

    repo-local Claude Code の pr-reviewer が、canonical Bash tool で明示された Git/GitHub mutation command を試行した場合に、agent-scoped PreToolUse hook が実行前に拒否する。

    任意 interpreter、別 client、gh api、REST/GraphQL、credential、server-side authorization まで防げるとは主張しません。

    P0-3. Global secret_boundary_guard.sh を mutation guard に拡張してはいけない

    現行 secret_boundary_guard.sh は全 Agent に対する secret・credential 用 hook であり、agent_type や Git/GitHub mutation を扱っていません。これに repository mutation の正規表現 parser を足すと、implementation worker、orchestrator、cleanup、publisher まで巻き込みます。

    また、OPEN の #1735 は現在、\s、\b、echo 等の portable regex 修正へ範囲を縮小しています。#1881 が secret_boundary_guard.sh を触らなければ hunk ownership の競合も避けられます。旧 #1775 はすでに not_planned で閉じられており、現在の blocker ではありません。

    Claude Code は現在、Agent frontmatter にその Agent の実行中だけ有効な hook を定義でき、--agent で main session として起動した場合にも同じ hook が動きます。hook handler の if には permission rule 構文を使え、Bash(git push *) のような条件は compound command の各 subcommand や先頭の環境変数代入も考慮して判定されます。独自 shell parser より、これを使う方が小さく堅牢です。 (Claude)

    推奨構造

    • global secret_boundary_guard.sh は変更しない。
    • .claude/agents/pr-reviewer.md に frontmatter hook を追加する。
    • .claude/hooks/pr_reviewer_guard.py のような専用の小さな handler を追加する。
    • command の分類は Claude Code の if に任せ、handler は event・agent_type の確認と固定理由での exit 2 だけを行う。

    P0-4. AC3 は広すぎる一方、実際の mutation route を漏らしている

    現行 AC3 は bash_secret_read、python_secret_read、node_secret_read、generic shell_write を禁止できるとしています。しかし Claude Code の Read/Edit rules は、Python や Node が自分でファイルを開く任意 subprocess には適用されません。そこまで OS レベルで禁止するには sandbox が必要です。 (Claude)

    ところが sandbox はデフォルトで current working directory と session temp directoryへの書き込みを許可し、linked worktree では共有 .git にも書き込めるため、git commit 自体を防ぐ仕組みではありません。また failIfUnavailable は、公式にも managed deployment で sandbox を security gate にする用途と説明されています。個人開発の workflow へ必須化する理由はありません。 ([Claude]3)

    反対に、現行 pr-reviewer の実際の publisher route は gh pr review ではなく、trusted orchestrator による gh pr comment --body-file です。#1881 は gh pr review を試験しますが、pr-reviewer が直接実行してはいけない本命の gh pr comment を AC3 から落としています。

    修正方針

    AC3 から次を外してください。

    • generic shell write 全般
    • 任意 Python/Node subprocess による secret read
    • sandbox による mutation impossibility
    • gh api、別 HTTP client、server-side mutation impossibility

    代わりに、pr-reviewer に不要な canonical command family だけを明示拒否します。最低限、以下が妥当です。

    Bash(git commit *)
    Bash(git push *)
    Bash(git worktree *)
    Bash(gh pr review *)
    Bash(gh pr comment *)
    Bash(gh pr merge *)
    Bash(gh issue edit *)
    Bash(gh issue comment *)
    Bash(gh issue close *)
    

    この設計なら git diff、git log、gh pr view、gh pr diff、gh pr checks、gh issue view、pytest、repository script はそのまま利用できます。

    P0-5. Main-session identity と production-settings evidence の生成経路がない

    PR #2047 は、過去に SessionStart:startup の suffix を Agent 名と誤認していた偽陽性を修正しました。その結果、現状は SessionStart hook が embedded JSON の agent_type を出さない限り、project-discovery lane の main_agent_identity.observed は unavailable になります。

    現行 runner の skill_evidence.canonical_read は issue-creator と issue-editor にしか対応しておらず、mutation_boundary は hermetic lane でだけ生成されます。#1881 が必要とする pr-reviewer の production settings lane をどう観測するかは、本文にも Allowed Paths にも定義されていません。

    Claude Code の hook input は --agent 起動時に agent_type を持ち、PreToolUse の exit 2 は tool call を実行前に止めます。Agent frontmatter hook も --agent で main session として起動した際に有効になります。 ([Claude]4)

    最小解は、pr-reviewer frontmatter に probe 用の observability hook も置くことです。

    hooks:
      SessionStart:
        - matcher: "startup"
          hooks:
            - type: command
              command: >-
                python3 "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py"
                observe-identity
    
      PreToolUse:
        - matcher: "Bash"
          hooks:
            - type: command
              if: "Bash(git commit *)"
              command: >-
                python3 "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py"
                deny git_commit
            - type: command
              if: "Bash(gh pr comment *)"
              command: >-
                python3 "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py"
                deny gh_pr_comment
    
      PostToolUse:
        - matcher: "Read"
          hooks:
            - type: command
              command: >-
                python3 "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py"
                observe-reference-read

    handler の要件は小さくできます。

    • deny は hook_event_name == PreToolUse と agent_type == pr-reviewer を確認し、固定 marker を stderr に出して exit 2。
    • shell command の再解析はしない。
    • observe-* は LOOP_PR_REVIEWER_RUNTIME_PROBE=1 のときだけ sanitized marker を出す。
    • identity marker は agent_type だけを含め、session ID、transcript path、HOME、command 全文を出さない。
    • reference-read marker は exact repo-relative canonical path の successful PostToolUse でのみ出す。
    • 通常の review session では observability hook は無出力で即終了する。

    SessionStart の stdout は model context に入るため、probe environment variable での明示的な限定が重要です。hook subprocess は親環境を継承します。 ([Claude]4)

    P0-6. AC1 が変更前から PASS する

    AC1 は Read(**/.claude/**) の削除を求めていますが、Verification Command は既存の secret-boundary test を実行するだけで、当該 rule の不存在を assert しません。本文も baseline-expect: pass としています。現行 test は hook wiring や secret pattern を検査しますが、blanket deny の削除は検査していません。

    次の構造 test を追加し、baseline-expect: fail に直す必要があります。

    def test_no_blanket_claude_read_deny() -> None:
        deny = load_project_settings()["permissions"]["deny"]
        assert "Read(**/.claude/**)" not in deny
    
    
    def test_explicit_sensitive_read_denies_remain() -> None:
        deny = set(load_project_settings()["permissions"]["deny"])
        assert {
            "Read(**/settings.local.json)",
            "Read(**/.ssh/**)",
            "Read(**/.config/gh/**)",
            "Read(**/.netrc)",
            "Read(**/.npmrc)",
            "Read(**/.pypirc)",
        } <= deny

    広い deny は狭い allow より常に先に評価されるため、現在の Read(.claude/skills/**) allow では blanket deny を上書きできません。 ([Claude]2)

    P1 重要修正

    P1-1. Positive control は pr-reviewer 自身で行う方がよい

    issue-reviewer + review-issue を別 lane にすると、別 Agent の Skill・artifact・一時ファイル挙動まで依存に入ります。今回証明したいのは pr-reviewer が pr-review-judge の reference を読めることです。

    positive case は fresh pr-reviewer で、例えば次の exact path を Read させれば足ります。

    .claude/skills/pr-review-judge/references/allowed-paths-gate.md
    

    これにより Agent identity、Skill declaration、tracked reference read、mutation guard 非干渉を一つの persona で確認できます。

    P1-2. Runtime case は一つずつ fresh process にする

    github_mutation 一件で複数 command を代表させるべきではありません。最低でも git_commit、git_push、git_worktree、gh_pr_review、gh_pr_comment、gh_issue_edit は別 process にし、各 case で以下を確認します。

    • requested/observed Agent がともに pr-reviewer
    • 対象 Bash tool attempt が存在する
    • 期待した agent-scoped hook marker が存在する
    • exit 2 による deny
    • Bash tool の実行 result が存在しない
    • HEAD、branch、tracked/untracked fingerprint が不変

    model が tool call を試行しなかった場合は PASS にせず、bounded retry 後に SKIP/INCONCLUSIVE とします。これは #1881 の candidate PR だけで必要な one-time runtime evidence とし、通常の CI や他 Issue の hard gate にはしない方がよいです。

    P1-3. Sandbox を merge gate にしない

    この限定された claim は PreToolUse deny event と tool non-execution で証明できます。sandbox の enabled/disabled は advisory field として記録してもよいですが、sandbox unavailable だけで #1881 を SKIP させる必要はありません。

    実 runtime は #1881 の candidate head で一度確認し、以後は deterministic unit test と frontmatter contract test を CI に残す構成が、品質と日常 workflow のバランスに優れます。公式にも failIfUnavailable は managed deployment の security gate 用とされています。 ([Claude]3)

    P1-4. Evidence を二重化しない

    #1887 の runner は既に allowlist-only summary.md 一つへ証跡を限定しています。#1881 が別の full runtime log、raw stream、transcript を保存すると、その決定を逆行します。新 verifier は既存 summary の marker・identity・postcondition を集約した短い結果だけを出し、raw prompt、raw transcript、command 全文を保存しないでください。

    P1-5. test_guard_graphql_mutation.py は Allowed Paths から外す

    この test は secret_boundary_guard.sh ではなく guard-japanese-prose.sh の GraphQL mutation 判定をテストしています。#1881 の pr-reviewer guardrail の proof にはなりません。

    P1-6. Hook の順序を前提にしない

    同一イベントで一致する hook は並列実行されます。secret_boundary_guard が先に動く、mutation guard が先に動く、といった順序を設計や test に含めてはいけません。専用 guard は副作用を持たず、どれか一つの PreToolUse hook が deny すれば対象 tool が実行されない、という条件だけを検証してください。 ([Claude]4)

    推奨する修正版 Acceptance Criteria

    AC1 — settings structure
    Read(**/.claude/**) が削除され、settings.local、credential、SSH、
    GitHub credential 等の explicit sensitive deny が維持される。
    current main では構造 test が FAIL する。
    
    AC2 — agent-scoped production guard
    pr-reviewer frontmatter に scoped PreToolUse hooks が定義され、
    canonical mutation command family だけを native `if` rule で選別する。
    global secret_boundary_guard.sh は変更しない。
    
    AC3 — non-interference
    git status/diff/log/show、gh pr view/diff/checks、gh issue view、
    pytest、pr-review-judge scripts は拒否されない。
    非 pr-reviewer Agent の mutation workflow に影響しない。
    
    AC4 — positive runtime
    fresh project-discovery pr-reviewer main session で、
    SessionStart 由来の agent_type=pr-reviewer と、
    exact canonical reference の successful Read receipt を観測する。
    
    AC5 — negative runtime
    git commit、git push、git worktree、gh pr review、gh pr comment、
    gh issue edit を case ごとの fresh process で試行し、
    agent-scoped PreToolUse deny、tool non-execution、local postcondition 不変を観測する。
    
    AC6 — evidence hygiene
    既存 worktree-agent-runtime-smoke の allowlist-only summary を利用する。
    raw transcript、raw prompt、HOME、credential、command 全文を保存しない。
    runtime unavailable/tool non-attempt は PASS にしない。
    
    AC7 — bounded claim
    distribution_scope は repo_local。
    arbitrary subprocess、gh api、別 HTTP client、GitHub server-side authorization、
    credential scope、plugin distribution は未検証であり本 Issue の主張に含めない。
    

    推奨 Allowed Paths

    .claude/settings.json
    .claude/agents/pr-reviewer.md
    .claude/hooks/pr_reviewer_guard.py
    .claude/hooks/tests/test_pr_reviewer_guard.py
    .claude/skills/pr-review-judge/tests/test_pr_reviewer_skill_contract_drift.py
    scripts/agent-ops/verify_pr_reviewer_permission_boundary.py
    scripts/agent-ops/tests/test_verify_pr_reviewer_permission_boundary.py
    docs/dev/hook-boundaries.md
    tests/test_hook_boundaries_doc.py
    

    次は除外すべきです。

    .claude/hooks/secret_boundary_guard.sh
    .claude/hooks/tests/test_guard_graphql_mutation.py
    

    既存 runner の --expect-marker が hook-origin marker と model 出力を十分区別できないことが実装時に判明した場合だけ、run_worktree_agent_runtime_smoke.py と対応 test を Allowed Paths に加え、最小の generic hook-marker provenance を追加してください。新 verifier が Claude Code の direct transport を再実装するのは避けるべきです。

    結論

    #1881 はクローズせず、本文を current main に合わせて書き直すのが妥当です。

    実装再開条件は次の五点です。

    1. 実装: worktree 内の Claude Code/Codex CLI runtime smoke を herdr で観測する共有 Skill を追加する #1887/実装: pr-reviewer/pr-review-judge の重複を削減し preload を追加する #1744/実装: Claude main-session agent identity と creator/editor Skill Read evidence を runtime smoke に追加する #2046 後の現状へ dependency と CLI を更新する。
    2. “safety boundary” を “repo-local agent-scoped guardrail” に縮小する。
    3. global secret guard と generic shell parser を scope から外す。
    4. gh pr comment を含む実際の canonical mutation route を exact if rules で拒否する。
    5. production project-discovery lane の identity/read/deny evidence 生成経路を frontmatter hook と既存 runner に明記する。

    この形なら、reference の正規読み込みという実利を回復しつつ、通常の実装・レビュー・publisher workflow を妨げず、重い security framework や恒常的な runtime harness も増やさずに済みます。

    実 Claude Code の fresh runtime 自体はこのレビュー環境では実行していません。判定は、現行 main の repository assets、Issue/PR・コメント、および現在の Claude Code 公式 permission/hook/sandbox 仕様の照合に基づきます。

  8. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 完了報告

    OWNER レビュー(issuecomment-5458619872、ISSUE_CONTRACT_REVIEW_V1、verdict: REQUEST_CHANGES、recommended_route: rewrite_in_place)を受け、本文を rewrite_in_place で全面改訂しました。

    反映した主な変更

    semantic design review(Step 2.5)で追加検出・修正した論点

    codebase-investigator / web-researcher による事実確認、および issue-design-reviewer による semantic review を計4周実施し、以下を修正しました。

    1. Claude Code の workspace trust は exact folder 単位でのみ有効であり、trust 未登録の worktree では pr-reviewer frontmatter hook が発火しない懸念(blocker)→ probe 実行前の worktree trust 事前登録手順と canary case(git_worktree)による検証を追加。
    2. AC3 の prose と Verification Commands の不一致(test_pr_reviewer_skill_contract_drift.py が AC で言及されたが VC が未追加)→ 独立 VC を追加。
    3. trust 登録の「書き込み成功」と「実際の trust 有効化」の区別・cleanup 手順の欠如 → canary 確認と probe 完了後の trust エントリ取り消しを明記。
    4. canary 失敗時の SKIP/FAIL 判定が箇所ごとに矛盾 → 「inconclusive(判定不能)→ SKIP」「confirmed breach(deny 不成立の実行事実を観測)→ FAIL」の二値基準に全箇所を統一。

    最終 review cycle で deterministic checker(approve, blocking 0)・semantic design review(assessment: clear)の両方が確認できたため、本 Issue を approved として終了します。

    follow-up 候補の新規起票は不要と判断しました(今回の指摘はすべて本文改訂で解消済み)。

  9. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  10. self-assigned this
    on Aug 29, 2026
  11. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-29)

    • PR: feat: pr-reviewer に agent-scoped mutation guardrail を追加する #2385
    • Worktree: .claude/worktrees/issue-1881-minimal-harness-permission-runtime-safet
    • Branch: worktree-issue-1881-minimal-harness-permission-runtime-safet
    • Verification(静的): AC1/AC2/AC3/AC6/AC7 全 VC PASS(pnpm typecheck/lint/test(1887)/build も green)
    • Verification(動作検証、AC4/AC5, <!-- runtime-verification: true -->): SKIP(exit 77)。実行機で /proc を実走査した結果、複数の稼働中 claude process(bare interactive session 3件超)を実際に検出したため、~/.claude.json の shared global projects map への workspace-trust 登録を capability unavailable と判定し、canary 実行前に SKIP した。fabricated PASS ではない(PR 本文の Safety Claim Matrix / AC4-AC5 runtime probe セクション参照)。
    • 後続: PR レビュー(pr-review-judge)→ AC4/AC5 は他 claude process が稼働していない環境での再実行が必要 → マージ → post-merge-cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions