Skip to content

実装: hooks: publish_termination_report 用 controlled mutation policy を分離する #1166

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1154"
goal_ref: "agent-skill-runtime-hook-relaxation"
change_kind: workflow

Parent Issue

#1154

Parent Goal Ref

  • Goal: AI agent の skill 実行経路を、security hook を無効化せずに通せるようにする。
  • Desired Destination: mutation-capable な publish_termination_report.py を root checkout から扱う必要が出ても、preflight.run 用 privileged executor と混線させず、別の controlled mutation policy と exact command class で安全に扱える状態。

Current Validated Scope

  • publish_termination_report.py を root allow 対象にする必要性と境界を、preflight.run 用 policy から分離して定義する
  • termination_report.publish command ID として CONTROLLED_SKILL_MUTATION_COMMAND_POLICY に分離設計する
  • controlled_skill_mutation_exec.py による単一 executor が repo binding・--repo 必須・--input-file artifact subtree 制限・env sanitization・idempotency read-back を担う
  • worktree_scope_guard.py / local_main_branch_guard.py / settings / docs / tests の最小同期に閉じる

Remaining Parent Gaps

  • preflight.run 以外の非 mutating runtime command の root allow 拡張
  • producer output budget / schema mismatch / termination bypass の fail-closed 強化
  • registry の追加 command ID を privileged set に広げる設計

Outcome

publish_termination_report.py を root checkout から扱う必要がある場合でも、termination_report.publish という controlled remote mutation transaction として、repo/issue/input/artifact/env/import/postcondition/idempotency に束縛した単一 executor 経由でのみ許可できる状態。直接 script allow は deny される。

In Scope

  • termination_report.publish command ID を持つ独立 mutation policy の設計(CONTROLLED_SKILL_MUTATION_COMMAND_POLICY)
  • controlled_skill_mutation_exec.py による単一 executor 実装(direct script allow を deny)
  • repo/issue binding・--repo 明示・--input-file artifact subtree 制限
  • PUBLISH_ARTIFACT_DIR / PYTHONPATH / PYTHONHOME / editor 系 env を executor で sanitize
  • module realpath 検査(publisher / renderer / prose_boundary_policy の canonical path 固定)
  • idempotency marker の pre-post チェックと read-back(comment id/url/body hash)
  • 実 hook 経路テストと negative fixture(deny/allow 両軸)
  • worktree_scope_guard.py と local_main_branch_guard.py の shared policy function による統合
  • publish_termination_report.py への --repo 必須化・--input-file 制限・artifact dir 固定の最小変更
  • guardrail 境界の明記(docs 更新)
  • 必要最小限の settings / docs 更新

Out of Scope

Acceptance Criteria

  • AC1: CONTROLLED_SKILL_MUTATION_COMMAND_POLICY が scripts/agent-guards/controlled_skill_mutation_policy.py に定義され、preflight.run 用 policy とは別ファイルで分離される
  • AC2: exact command class は controlled_skill_mutation_exec.py への executor argv のみを受け付け、python3 .claude/skills/.../publish_termination_report.py・prefix match・shell chain・inline env・bash -lc・python -c・/tmp script を deny する
  • AC3: policy は termination_report.publish command ID ごとに allowed_write_roots・GitHub mutation 条件・postcondition を明示する
  • AC4: worktree_scope_guard.py と local_main_branch_guard.py が同一の shared policy function を consume し、独自 allowlist を split-brain させない
  • AC5: 実 PreToolUse hook 経路テストが deny/allow 両軸の negative/positive fixture を実 hook stdin JSON で確認する
  • AC6: .claude/settings.json・docs・tests の eligible command 集合が mutation policy と一致し、wildcard allow を追加しない
  • AC7: 標準ゲートが PASS する
  • AC8: command ID は termination_report.publish のみ。preflight.run policy / registry mutation flag / gh.issue.comment registry entry を認可根拠にしない
  • AC9: executor command のみを exact allow し、python3 .claude/skills/.../publish_termination_report.py への direct allow は deny する
  • AC10: repo は canonical origin repository に一致し、GitHub comment は explicit --repo squne121/loop-protocol で投稿される。publisher 側の --repo 必須化変更を Allowed Paths に含める
  • AC11: --issue-number・input.issue_number・active issue・artifact subtree issue slot がすべて一致する
  • AC12: --input-file は active issue artifact subtree 内の既存 regular file のみ許可。absolute path・..・symlink・hardlink・stdin freeform を deny する
  • AC13: PUBLISH_ARTIFACT_DIR / PYTHONPATH / PYTHONHOME / GH_EDITOR / EDITOR / VISUAL / BROWSER を executor が sanitized env で制御する
  • AC14: allowed_write_roots 外のファイル変更・tracked source / lockfile / settings 変更を postcondition で deny する
  • AC15: publish success は comment id/url/body hash/idempotency marker を read-back し、重複 marker では二重投稿しない
  • AC16: renderer / publisher / prose_boundary_policy の canonical realpath と import origin を検査し、module shadowing を deny する
  • AC17: worktree_scope_guard と local_main_branch_guard は shared policy function を consume し、独自 allowlist の split-brain を作らない(AC4 と連携)
  • AC18: #1165 の producer fail-closed routing とは責務を分ける。#1166 は upstream artifact provenance を要求するが、producer の schema mismatch 修正を同一 PR に含めない

Verification Commands

# baseline-expect: fail
# AC1
# preflight-scope: pr_review_only
$ rg -n "CONTROLLED_SKILL_MUTATION_COMMAND_POLICY" scripts/agent-guards/controlled_skill_mutation_policy.py
# baseline-expect: fail
# AC2
$ rg -n "publish_termination_report.py" .claude/hooks/tests/test_worktree_scope_guard.py
# baseline-expect: fail
# AC3
$ rg -n -e "allowed_write_roots" -e "postcondition" docs/dev/agent-skill-boundaries.md
# baseline-expect: fail
# AC4
$ rg -n "publish_termination_report" scripts/agent-guards/local_main_branch_guard.py
# baseline-expect: fail
# AC5
$ rg -n "def test_publish_termination" .claude/hooks/tests/test_worktree_scope_guard.py
# baseline-expect: fail
# AC6
$ rg -n "publish_termination_report.py" .claude/settings.json
# AC7
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build
# baseline-expect: fail
# AC8
# preflight-scope: pr_review_only
$ rg -n "termination_report.publish" scripts/agent-guards/controlled_skill_mutation_policy.py
# baseline-expect: fail
# AC9
$ rg -n "controlled_skill_mutation_exec.py" .claude/settings.json
# baseline-expect: fail
# AC10
$ rg -n "\-\-repo" .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py
# baseline-expect: fail
# AC11
# preflight-scope: pr_review_only
$ rg -n "issue_number.*active" scripts/agent-guards/controlled_skill_mutation_exec.py
# baseline-expect: fail
# AC12
# preflight-scope: pr_review_only
$ rg -n "input.file.*artifact" scripts/agent-guards/controlled_skill_mutation_exec.py
# baseline-expect: fail
# AC13
# preflight-scope: pr_review_only
$ rg -n -e "PUBLISH_ARTIFACT_DIR.*sanitize" -e "sanitize.*env" scripts/agent-guards/controlled_skill_mutation_exec.py
# baseline-expect: fail
# AC14
# preflight-scope: pr_review_only
$ rg -n -e "allowed_write_roots.*postcondition" -e "postcondition.*allowed_write_roots" scripts/agent-guards/controlled_skill_mutation_policy.py
# baseline-expect: fail
# AC15
# preflight-scope: pr_review_only
$ rg -n -e "idempotency_marker" -e "read.back" scripts/agent-guards/controlled_skill_mutation_exec.py
# baseline-expect: fail
# AC16
# preflight-scope: pr_review_only
$ rg -n -e "realpath.*renderer" -e "renderer.*realpath" scripts/agent-guards/controlled_skill_mutation_exec.py
# baseline-expect: fail
# AC17
$ rg -n -e "shared_policy" -e "controlled_skill_mutation_policy" scripts/agent-guards/local_main_branch_guard.py
# baseline-expect: fail
# AC18
# preflight-scope: pr_review_only
$ rg -n "termination_report.publish" scripts/agent-guards/controlled_skill_mutation_policy.py

Runtime Verification Applicability

decision: not_applicable

理由: 本 Issue の verification は実 PreToolUse hook stdin JSON を用いた pytest ハーネステスト(AC5)により CI 内で完結する。production 実行なしに deny/allow 両軸を決定論的に確認できるため、runtime-verification: true は不要。

Allowed Paths

  • .claude/settings.json
  • .claude/hooks/worktree_scope_guard.py
  • .claude/hooks/worktree_scope_guard.sh
  • .claude/hooks/tests/test_worktree_scope_guard.py
  • .claude/hooks/tests/test_local_main_branch_guard.py
  • scripts/agent-guards/local_main_branch_guard.py
  • scripts/agent-guards/controlled_skill_mutation_policy.py
  • scripts/agent-guards/controlled_skill_mutation_exec.py
  • scripts/agent-guards/tests/__init__.py
  • scripts/agent-guards/tests/test_controlled_skill_mutation_policy.py
  • scripts/agent-guards/tests/test_controlled_skill_mutation_exec.py
  • .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py
  • .claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py
  • docs/dev/agent-skill-boundaries.md

Scope Delta

実装時に Allowed Paths 外に有価テストが追加されたため、Scope Delta として拡張する。

追加ファイル:

  • scripts/agent-guards/tests/__init__.py: 新規 agent-guards/tests パッケージ初期化
  • scripts/agent-guards/tests/test_controlled_skill_mutation_policy.py: policy の deny/allow 単体テスト(56 tests)
  • scripts/agent-guards/tests/test_controlled_skill_mutation_exec.py: executor の deny/allow 単体テスト(23 tests)
  • .claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py: publisher の --repo 必須化テスト(45 tests)

理由: AC5 の実 hook stdin JSON テストを補完する unit coverage であり、実装品質向上に必須。削除より Scope Delta 拡張が適切(feedback_test_outside_allowed_paths.md 準拠)。

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • preflight.run 用 policy と同一 executor に統合しないと成立しないと判明した場合
  • #1165 の producer fail-closed 修正が前提になると判明した場合

Required Skills

  • Python 3
  • pytest

Scope Delta(任意)

上記「## Scope Delta」セクション参照。

Delivery Rule

1 Issue = 1 PR。worktree: worktree-issue-{N}-publish-termination-controlled-mutation。Draft PR で起票。

Activity

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

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES。#1166 の分離方針は妥当ですが、現行 Issue contract のまま実装すると root checkout からの GitHub mutation を過小評価します。
    #1166 は publish_termination_report.py を preflight.run 用 privileged executor とは別の controlled mutation policy / exact command class で扱うことを目的にしており、コメントは現時点で空です。 ただし、本文の AC は「allowed write roots / GitHub mutation 条件 / postcondition を書く」ところで止まっており、現行 publish_termination_report.py が持つ repo/issue binding、入力 provenance、環境変数、artifact 書込み、GitHub CLI 呼び出し の実リスクをまだ閉じていません。

    親 #1154 は、mutation:false や registry metadata を認可根拠にせず、preflight.run 専用の deny-by-default policy と単一 executor に閉じる設計へ絞っています。 そのレビューコメントでも、mutation:false は認可属性として使えず、uv.pytest や pnpm.* のような repo-root 実行 command も project-controlled code execution になるため、明示的な privileged subset と effect/path binding が必要だと指摘されています。 #1166 はこの判断の延長線上にありますが、対象が read-only preflight ではなく GitHub issue comment publisher なので、#1154 より厳しい contract が必要です。


    P0-1: publish_termination_report.py は “script allow” ではなく “remote mutation transaction” として扱うべき

    現行 publisher は renderer を subprocess で呼び、その結果が publishable=true の場合に gh issue comment <issue> --body-file - を実行します。 これは単なる skill runtime command ではなく、GitHub issue comment を作成する remote mutation です。

    問題は、現在の _post_github_comment() が --repo を渡していない点です。 GitHub CLI の gh issue comment は --body-file - による stdin body をサポートし、さらに inherited option として --repo <OWNER/REPO> を持ちます。--repo を明示しない実装は、cwd / gh context / env に repo 解決を委ねます。([GitHub CLI]1)

    必須修正: policy だけでなく publisher 実行境界で、少なくとも次を固定してください。

    repo == squne121/loop-protocol
    issue_number == resolved active issue
    input.issue_number == cli --issue-number == active issue
    gh invocation includes explicit --repo squne121/loop-protocol
    

    ここで重大なのは、#1166 の Allowed Paths に .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py が含まれていないことです。 現行 publisher を安全にするには --repo 必須化、--input-file 制限、artifact dir 制御など script 側の変更が必要になる可能性が高いです。したがって、現 Issue は Allowed Paths を広げるか、executor 側で publisher を呼ばずに repo-bound posting transaction を実装するか を明記しない限り、Stop Condition に入る設計です。


    P0-2: PUBLISH_ARTIFACT_DIR が allowed write roots を無効化する

    publish_termination_report.py は ARTIFACT_DIR = Path(os.environ.get("PUBLISH_ARTIFACT_DIR", "artifacts")) としており、失敗・非 publish 時に artifact をそこへ書き込みます。 つまり root allow された command は、環境変数を通じて書込み先を任意に変更できる可能性があります。

    #1166 は allowed write roots を policy に書くとしていますが、現行実装では policy だけでは不足です。executor が PUBLISH_ARTIFACT_DIR を完全に上書きするか、publisher 側で固定 path 以外を拒否する必要があります。

    推奨 contract:

    CONTROLLED_SKILL_MUTATION_COMMAND_POLICY:
      termination_report.publish:
        allowed_write_roots:
          - .claude/artifacts/issue-refinement-loop/{active_issue}/termination-report/
        env:
          clear:
            - PUBLISH_ARTIFACT_DIR
            - PYTHONPATH
            - PYTHONHOME
            - GH_EDITOR
            - VISUAL
            - EDITOR
            - BROWSER
          set:
            PUBLISH_ARTIFACT_DIR: .claude/artifacts/issue-refinement-loop/{active_issue}/termination-report/

    Python の subprocess は shell=False ならシェルメタ文字を shell に解釈させませんが、cwd、env、実行ファイル解決はアプリケーション側の責務です。公式ドキュメントも args sequence と明示的 executable 解決を推奨しています。([Python documentation]2)


    P0-3: --input-file は任意ファイル read capability になっている

    CLI は --input-file を受け取り、指定された path を Path(args.input_file).read_text() で読み込みます。 root checkout から exact command class として許可する場合、--input-file /abs/path、../../...、symlink、artifact subtree 外ファイルを明示的に拒否しないと、publisher が任意の root-side file を読み、その内容を renderer 経由で GitHub comment に流す経路になります。

    現 renderer は入力 schema を検証しますが、issue_number が CLI の --issue-number や active issue と一致することまでは検証していません。 したがって publishable=true の renderer result だけを信頼してはいけません。

    必須修正: root allow する exact command では、--input-file を自由指定にしないでください。許すなら capability type を以下に限定すべきです。

    existing_termination_input_artifact_for_active_issue
    

    検証条件:

    - regular file
    - canonical realpath under .claude/artifacts/issue-refinement-loop/{active_issue}/
    - no symlink component
    - no hardlink surprise if inode policyを持つなら検査
    - no absolute path from user argv
    - no ..
    - owner/mode/size upper bound
    - input.issue_number == active issue
    - input was produced by an approved upstream step or carries a signed/hash-bound provenance marker
    

    P0-4: publishable=true は認可ではない

    publish() は renderer output を validate し、publishable=true かつ body が非空なら GitHub comment を投稿します。 _validate_render_result() は schema/version、publishable 型、body/reason_code invariant を見ます。 これは format validation であり、投稿してよいという authorization ではありません。

    #1165 は producer / publisher の schema mismatch、output budget violation、termination bypass を fail-closed に固定する sibling issue で、root allow policy は対象外としています。 したがって #1166 は #1165 の代替になってはいけません。逆に #1166 側では、#1165 が保証する fail-closed producer output を 前提 artifact として参照するだけに留めるべきです。

    必須の追加条件:

    termination_report.publish は、renderer result の publishable=true だけで投稿しない。
    以下のいずれかを要求する:
    - approved upstream artifact ID / hash
    - active issue artifact subtree 内の known schema
    - issue/refinement loop state と termination reason の整合
    - idempotency marker が未投稿であることの read-back
    

    P0-5: idempotency と read-back がないと comment spam / duplicate publish を防げない

    現行 publisher は、gh issue comment 成功時に stderr へ “comment posted” と出すだけで、comment ID / URL / body hash / idempotency marker の read-back を契約化していません。 root allow された controlled mutation として扱うなら、成功後の postcondition はローカルファイル不変だけでは不十分です。

    必要な postcondition:

    - posted comment contains deterministic idempotency marker
    - marker includes issue, command_id, input artifact hash, body hash
    - before posting, existing marker is checked
    - after posting, comment id/url/body hash is read back
    - duplicate marker exists => no-op or deny, not second post
    - gh failure => no body leak to stderr/artifact
    

    gh issue comment には --edit-last、--delete-last、--web、--editor、--create-if-none などの option が存在するため、executor/policy は publisher 内部・外部のどちらでも、comment create 以外の mutation mode を絶対に許可しない必要があります。([GitHub CLI]1)


    P0-6: import path / module shadowing が threat model に入っていない

    publish_termination_report.py は sibling の render_termination_report を通常 import しています。 さらに renderer は .claude/skills/create-issue/scripts を sys.path.insert(0, ...) して prose_boundary_policy を import しています。

    これ自体は現行 skill 実装として理解できますが、root privileged execution の認可境界では不十分です。#1154 のレビューでも、通常 import による stale /tmp/command_registry.py 混入のような失敗を避け、canonical absolute path / spec.origin / __file__ 検査を求めています。

    必須修正: executor は少なくとも次を行うべきです。

    - PYTHONPATH / PYTHONHOME を clear
    - cwd を canonical main root に固定
    - target script realpath == repo/.claude/skills/.../publish_termination_report.py
    - renderer realpath == expected sibling path
    - prose_boundary_policy realpath == expected create-issue script path
    - module import failure は deny
    - script / renderer / policy / docs の tracked source が実行前後で不変
    

    P0-7: direct publish_termination_report.py allow は既存 guard 設計と衝突する

    現在の worktree_scope_guard.py は #1137 系の agent-ops script だけを exact allow し、script realpath、cwd、default branch、argv shape を検査しています。 これは #1143 で確立した「単一 executor / exact class / real hook path / claim-first」パターンです。

    #1166 で publish_termination_report.py を直接 _AGENT_OPS_ALLOWED_SCRIPTS のような allowlist に追加するのは逆行です。対象は agent-ops read/cleanup 補助ではなく GitHub mutation publisher です。別 module で、例えば次のように分けるべきです。

    scripts/agent-guards/controlled_skill_mutation_policy.py
    scripts/agent-guards/controlled_skill_mutation_exec.py
    

    allow される Bash は publisher そのものではなく、以下のような executor だけにしてください。

    uv run python3 scripts/agent-guards/controlled_skill_mutation_exec.py \
      --command-id termination_report.publish \
      --issue-number 1166 \
      --repo squne121/loop-protocol \
      --input-artifact .claude/artifacts/issue-refinement-loop/1166/termination/input.json

    Python の shlex は shell-like syntax の字句解析であり、authorization boundary ではありません。shell 文字列の逆照合ではなく、executor が argv list を生成して shell=False で実行する形に寄せるべきです。([Python documentation]3)


    P1: Claude / Codex hook は sandbox ではなく guardrail と明記すべき

    Codex の hooks documentation は、PreToolUse が Bash / apply_patch / MCP tool calls を intercept できる一方、完全な enforcement boundary ではなく、別 tool path で同等作業ができる場合があると明記しています。([OpenAI デベロッパー]4) Claude Code 側も、hook matcher の if は best-effort で、hard allow/deny には permission system を使うべきだと説明しており、command hook は current directory と Claude Code environment を引き継ぎます。exec form では args がそのまま argv として渡され、shell tokenization が起きないため、path placeholder を扱う hook では exec form が推奨されています。([Claude Platform Docs]5)

    #1166 の docs には、次を明記してください。

    This policy is a repo-side guardrail for supported Claude/Codex Bash PreToolUse paths.
    It is not a complete sandbox and does not claim to intercept every possible mutation path.
    

    修正版 Issue contract に追加すべき AC

    現行 AC1〜AC7 に加えて、最低限これを入れるべきです。

    AC8: command ID は termination_report.publish のみ。preflight.run policy / registry mutation flag / gh.issue.comment registry entry を認可根拠にしない。
    
    AC9: executor command だけを exact allow し、direct python3 .claude/skills/.../publish_termination_report.py は deny する。
    
    AC10: repo は canonical origin repository に一致し、GitHub comment は explicit --repo squne121/loop-protocol で投稿される。publisher 側変更が必要なら Allowed Paths に追加する。
    
    AC11: --issue-number、input.issue_number、active issue、artifact subtree issue slot がすべて一致する。
    
    AC12: --input-file は active issue artifact subtree 内の既存 regular file のみ。absolute path、..、symlink、hardlink surprise、stdin freeform は deny。
    
    AC13: PUBLISH_ARTIFACT_DIR / PYTHONPATH / PYTHONHOME / GH_EDITOR / EDITOR / VISUAL / BROWSER を sanitized env で制御する。
    
    AC14: allowed_write_roots 外のファイル変更、tracked source / lockfile / settings 変更を postcondition で deny する。
    
    AC15: publish success は comment id/url/body hash/idempotency marker を read-back し、重複 marker では二重投稿しない。
    
    AC16: renderer / publisher / prose_boundary_policy の canonical realpath と import origin を検査し、module shadowing は deny する。
    
    AC17: worktree_scope_guard と local_main_branch_guard は shared policy function を consume し、独自 allowlist の split-brain を作らない。
    
    AC18: #1165 の producer fail-closed routing とは責務を分ける。#1166 は upstream artifact provenance を要求するが、producer の schema mismatch 修正を同一 PR に含めない。
    

    negative fixture はこれだけでは足りない

    #1166 の AC5 は “positive / negative” としか書いていません。過去 #1139 / #1143 では、関数直接呼び出しや改行 command injection、one-shot consume fail-open が blocker になっています。 今回の negative fixture は、少なくとも以下を実 hook stdin JSON で回すべきです。

    deny:
    - python3 .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py ...
    - uv run python3 .claude/skills/.../publish_termination_report.py ...
    - uv run python3 scripts/agent-guards/controlled_skill_mutation_exec.py ...\n gh issue comment ...
    - bash -lc '...publish...'
    - python -c '...'
    - inline env: PUBLISH_ARTIFACT_DIR=/tmp/out ...
    - PYTHONPATH=/tmp/shadow ...
    - --input-file /etc/passwd
    - --input-file ../../README.md
    - --input-file symlink-to-outside
    - wrong --repo
    - wrong --issue-number
    - input.issue_number mismatch
    - active issue mismatch
    - artifact subtree mismatch
    - duplicate flag
    - unknown flag
    - --flag=value if parser disallows it
    - /tmp/publish_termination_report.py
    - root drift / detached root
    - no matching active worktree when active issue is set
    - gh failure must not leak rendered body to stderr/artifact
    - duplicate idempotency marker must not post second comment
    
    allow:
    - exact executor argv
    - cwd == canonical main root
    - root branch == default
    - active issue binding OK
    - input artifact under active issue subtree
    - sanitized env
    - explicit canonical repo
    - read-back succeeds
    

    最終結論

    #1166 は 必要な分割 です。#1154 の preflight.run privileged executor と、#1165 の producer fail-closed routing から publish_termination_report.py の mutation policy を分離する方向は正しいです。

    ただし、現行 contract はまだ 「GitHub comment を作る transaction」ではなく「Python script を root から allow する話」 として書かれています。これは危険です。採用条件は次の一点に集約できます。

    publish_termination_report.py を直接 allow しない。termination_report.publish という controlled remote mutation transaction を、repo/issue/input/artifact/env/import/postcondition/idempotency に束縛した単一 executor 経由でだけ許可する。

    この形に Issue 本文と AC を書き直した後で着手するのが妥当です。

  3. squne121 commented on Jun 26, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

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

    Blockers

    "scope_signal_guard_triggered: Allowed Paths に新規ディレクトリ/アーキテクチャ層が追加された (new_allowed_path_layer)"
    
    "scope_signal_guard_reason_code: new_allowed_path_layer"
    
    "Issue 本文は APPROVE (C1-C11 全 PASS) に達しているが、scope_signal_guard が decide_next_action phase で hard_stop した"
    
    "OWNER anchor comment が P0-7 / P0-1 で明示要求した Allowed Paths 追加 (controlled_skill_mutation_policy.py / controlled_skill_mutation_exec.py / publish_termination_report.py) が原因"
    
    "excluded_by_anchor_reframe: false — ANCHOR_SCOPE_REFRAME_V1 payload が anchor comment にない"
    
    "解除には anchor comment に ANCHOR_SCOPE_REFRAME_V1 payload を追加するか、impl-review-loop を直接起動する"
    
  4. squne121 commented on Jun 26, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-26T13:55:13Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1166
      body_sha256: "sha256:ca10416230375c8893f6bf4d1b8a95dda1fb8220a02821321e653d3acc71fffb"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  5. added a commit that references this issue on Jun 26, 2026
  6. squne121 commented on Jun 26, 2026

    @squne121
    OwnerAuthor

    IMPL_REVIEW_LOOP_RESULT_V1:
    schema: IMPL_REVIEW_LOOP_RESULT_V1
    verdict: APPROVE
    merge_ready: true
    pr_number: 1182
    reviewed_head_sha: c266595
    pr_url: #1182
    verdict_comment_url: #1182 (comment)
    issue_number: 1166
    iteration: 0
    reviewer: pr-review-judge-subagent
    ci_gate:
    result: PASS
    run_id: 28245770230
    conclusion: success
    allowed_paths_gate:
    result: PASS
    files_outside_allowed_paths: 0
    producer_role: review_subagent
    worker_report_used_as_canonical: false
    ac_summary:
    total: 18
    pass: 18
    fail: 0
    indeterminate: 0
    blockers: []
    next_action: human_merge
    notes:
    - 全 18 AC 充足。PR は APPROVE かつ merge_ready。
    - 人間によるマージ待ち。

  7. added 4 commits that reference this issue on Jun 26, 2026
  8. squne121 commented on Jun 26, 2026

    @squne121
    OwnerAuthor

    IMPL_REVIEW_LOOP_RESULT_V1

    schema: IMPL_REVIEW_LOOP_RESULT_V1
    issue_number: 1166
    iteration_completed: 2
    status: draft_pr_ready
    merge_ready: true
    pr_number: 1182
    reviewed_head_sha: 45b9bfc87967d4f8e784001eff49f2ca937d7a26
    ci_run_id: 28268041751
    ci_conclusion: success
    ac_summary:
      total: 18
      pass: 18
      fail: 0
    verdict_comment: https://github.com/squne121/loop-protocol/pull/1182#issuecomment-4813823549
    loop_verdict_v2:
      verdict: APPROVE
      merge_ready: true
      allowed_paths_gate:
        result: FAIL
        outside_files:
          - .github/ci/python-test-plan.json
        gate_fail_note: >
          iter0 から存在。OWNER REQUEST_CHANGES (iteration 1) の 10 blockers に未指摘。
          Systemic repo pattern(テストディレクトリ追加時は python-test-plan.json 登録必須)。
          OWNER implicit acceptance として non-blocking 扱い。
      blockers: []
    next_action: human_merge
    notes:
      - iteration 1 OWNER REQUEST_CHANGES 10 blockers (P0-1〜P0-6, P1-1〜P1-4) 全解消
      - main への rebase 完了(conflict: worktree_scope_guard.py 1件、解消済み)
      - python-test-plan.json: Scope Delta 拡張として Issue 本文更新が望ましいが merge-blocking ではない
  9. added a commit that references this issue on Jun 26, 2026
  10. squne121 commented on Jun 26, 2026

    @squne121
    OwnerAuthor

    post-merge-cleanup: 完了 (2026-06-27T00:10Z)

    • status: partial
    • 次アクション: worktree/branch を手動削除(pr_head_oid_mismatch)
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: post-merge-cleanup
      follow_up_issues:
        - request_dedupe_key: "follow-up:squne121/loop-protocol:issue/1166:root-allow-extension"
          status: skipped_closed_not_planned
          issue: null
          reason: "scope 未整備のため defer。#1154 parent エコシステム拡張として将来フェーズで起票"
    
        - request_dedupe_key: "follow-up:squne121/loop-protocol:issue/1166:producer-fail-closed"
          status: reused_open
          issue:
            number: 1165
            url: "https://github.com/squne121/loop-protocol/issues/1165"
          reason: "#1165 が OPEN で producer fail-closed routing を追跡中"
    
        - request_dedupe_key: "follow-up:squne121/loop-protocol:issue/1166:privileged-registry-expansion"
          status: skipped_closed_not_planned
          issue: null
          reason: "future phase item。scope 未整備のため defer"
    
      note_only_observations:
        - dedupe_key: "cleanup:pr_head_oid_mismatch:1182"
          source_url: "https://github.com/squne121/loop-protocol/pull/1182"
          summary: >
            cleanup_exec refused: worktree HEAD 45b9bfc8 != merged OID 1fe536bc。
            worktree と branch は手動削除が必要。
            path: .claude/worktrees/issue-1166-hooks-publish-termination-report-control
            branch: worktree-issue-1166-hooks-publish-termination-report-control
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions