Skip to content

実装: GitHub remote ops を read-only から分離し AI workflow 必須コマンドとして分類する #1124

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "GitHub CLI コマンドを display-readonly / readonly-artifact-export / github-issue-mutation / github-pr-metadata / destructive の 5 分類に再編し、AI workflow 必須の gh issue create/edit/comment/close/reopen を github_issue_mutation_command として許可し、gh issue view の tmp/ への redirect を readonly_artifact_export_command として許可する。docs / rules / hooks / skills の分類語彙を統一する"
change_kind: code

Parent Issue

none(単独改善)

Parent Goal Ref

Current Validated Scope

  • scripts/agent-guards/local_main_branch_guard.py:
    • github_issue_mutation_command reason_code 追加
    • gh issue create(非対話・repo 限定・body-file 付き)を allow
    • gh issue edit(非対話・repo 限定・body-file 付き)を allow
    • gh issue view > tmp/*.md(readonly_artifact_export_command として allow)
    • gh pr merge / gh pr checkout / gh pr update-branch は block 維持
    • bare / interactive / wrong-repo / unsafe-redirect は block
  • tests/codex/test_local_main_branch_guard.py: AC1〜AC15 の境界テスト追加
  • .claude/hooks/tests/test_local_main_branch_guard.py: AC1〜AC15 の境界テスト追加
  • docs/dev/hook-boundaries.md: 5 分類の判断基準セクション追加
  • docs/dev/agent-skill-boundaries.md: gh CLI 分類語彙を hook-boundaries.md に揃える
  • AGENTS.md: 「direct gh issue create/edit は禁止」記述を「managed skill 経由は許可」に更新
  • .codex/rules/default.rules: gh issue create/edit/close/reopen の approval mode を auto に更新

Remaining Parent Gaps

なし(このフォローアップが完了すれば PR #1120 の関連 tech debt と #1089 の分類未整理 gap は解消)

Outcome

scripts/agent-guards/local_main_branch_guard.py が 5 分類(display-readonly / readonly-artifact-export / github-issue-mutation / github-pr-metadata / destructive)を実装し、tests/codex/test_local_main_branch_guard.py および .claude/hooks/tests/test_local_main_branch_guard.py の境界テストが PASS しており、docs/dev/hook-boundaries.md に 5 分類の判断基準が記録され、関連ドキュメント(AGENTS.md、.codex/rules/default.rules、docs/dev/agent-skill-boundaries.md)が同じ分類語彙を使っている状態。

Background

PR #1120(2026-06-21 マージ済み)は gh issue/pr 系コマンドを allowlist-closed から除外し、post-merge-cleanup で必須の gh issue close / gh issue comment 等を github_remote_ops_command reason_code で記録するよう修正した。

しかし以下の問題が残存する:

  1. 分類が 2 つ(display-readonly / github_remote_ops_command)しかなく不十分: gh issue view > tmp/foo.md(ローカルファイル出力)は pure display-readonly とは異なる。gh issue edit・gh issue create は mutation だが AI workflow に必須であり、display-readonly でも github_remote_ops_command でもない。

  2. AI workflow 必須コマンドが阻害されている: gh issue edit(edit-issue skill が使用)・gh issue create(create-issue skill が使用)は is_gh_mutation_command() に分類されブロックされている。これらは github_issue_mutation_command として first-class 化が必要。

  3. ドキュメント間の語彙不統一: AGENTS.md は "direct gh issue create/edit は forbidden" と書いており、agent-skill-boundaries.md の skill 経由許可と矛盾する。.codex/rules/default.rules は gh issue create/edit/close/reopen を prompt 扱いにしており、hook 設計と乖離している。

新 5 分類語彙(このIssueの中核成果):

分類 reason_code 代表コマンド
display_readonly_command readonly_command gh issue view, gh pr view, stdout のみ
readonly_artifact_export_command readonly_command gh issue view ... > tmp/*.md
github_issue_mutation_command github_remote_ops_command gh issue create/edit/comment/close/reopen
github_pr_metadata_command github_remote_ops_command gh pr comment/review
github_destructive_command gh_mutation_denied gh pr merge, gh pr checkout

Source

dedupe_key: "follow-up:squne121/loop-protocol:pr/1120:github-remote-ops-classification"
pr_source: "https://github.com/squne121/loop-protocol/pull/1120"
materialization_phase: post-merge-cleanup
anchor_comment: "https://github.com/squne121/loop-protocol/issues/1124#issuecomment-4762317985"

In Scope

  • local_main_branch_guard.py の 5 分類ロジック実装(github_issue_mutation_command 追加)
  • gh issue create(非対話・--repo squne121/loop-protocol 必須・--body-file tmp/*.md 必須)を allow
  • gh issue edit <N>(非対話・--repo squne121/loop-protocol 必須・--body-file tmp/*.md 必須)を allow
  • bare / interactive(--editor/--web/-e/-w)/ --repo 不一致 / --body-file - は block
  • gh issue view ... > tmp/*.md(readonly_artifact_export_command)を allow
  • gh issue view ... > src/... / > docs/... / > .env / >> ... は block
  • display_readonly_command と readonly_artifact_export_command の分離
  • gh pr merge / gh pr checkout / gh pr update-branch / gh pr create は block 維持
  • 境界テストを tests/codex/test_local_main_branch_guard.py と .claude/hooks/tests/test_local_main_branch_guard.py に追加
  • docs/dev/hook-boundaries.md への 5 分類判断基準セクション追記
  • docs/dev/agent-skill-boundaries.md の gh CLI 語彙更新
  • AGENTS.md の "direct gh issue create/edit は forbidden" → "managed skill 経由は許可" に修正
  • .codex/rules/default.rules の gh issue create/edit/close/reopen の approval mode 更新

Out of Scope

Acceptance Criteria

  • AC1: local_main_branch_guard.py に github_issue_mutation_command を分類する関数または判定ロジックが実装されている
  • AC2: gh issue view / gh pr view / gh issue list 等の display-readonly コマンドが guard で readonly_command として扱われ、github_issue_mutation_command でブロックされない
  • AC3: gh issue close / gh issue comment <N> --body <text> / gh issue reopen 等が github_remote_ops_command reason_code として allow される
  • AC4: tests/codex/test_local_main_branch_guard.py に AC1〜AC3 の境界テストが追加され PASS する
  • AC5: .claude/hooks/tests/test_local_main_branch_guard.py に AC1〜AC3 の境界テストが追加され PASS する
  • AC6: docs/dev/hook-boundaries.md に 5 分類(display-readonly / readonly-artifact-export / github-issue-mutation / github-pr-metadata / destructive)の判断基準セクションが追加されている
  • AC7: 既存テストが退行していない
  • AC8: gh issue edit <N> --repo squne121/loop-protocol --body-file tmp/foo.md が guard で allow される
  • AC9: gh issue create --repo squne121/loop-protocol --title "タイトル" --body-file tmp/foo.md --label enhancement が guard で allow される
  • AC10: bare gh issue create(--body-file なし)と bare gh issue edit 123(--body-file なし)は block される
  • AC11: gh issue view 123 --repo squne121/loop-protocol --json body --jq .body > tmp/issue_123.md が guard で allow される(readonly_artifact_export_command)
  • AC12: gh issue view 123 > src/foo.md / > docs/foo.md / > .env / >> tmp/foo.md は block される
  • AC13: gh issue create/edit/comment/close/reopen は readonly_command でないことを両 flavor テストで確認する
  • AC14: gh pr merge 123 / gh pr checkout 123 / gh pr update-branch は block される
  • AC15: AGENTS.md、.codex/rules/default.rules、docs/dev/hook-boundaries.md、docs/dev/agent-skill-boundaries.md の policy 語彙が 5 分類に統一されている

Verification Commands

# AC1
$ rg -n "github_issue_mutation" scripts/agent-guards/local_main_branch_guard.py

# AC2
$ uv run pytest tests/codex/test_local_main_branch_guard.py -v -k "display_readonly or gh_readonly"

# AC3
$ uv run pytest tests/codex/test_local_main_branch_guard.py -v -k "gh_issue_close or gh_issue_comment or gh_issue_reopen"

# AC4
$ uv run pytest tests/codex/test_local_main_branch_guard.py -v

# AC5
$ uv run pytest .claude/hooks/tests/test_local_main_branch_guard.py -v

# AC6
$ rg -n "readonly_artifact_export" docs/dev/hook-boundaries.md
$ rg -n "github_issue_mutation" docs/dev/hook-boundaries.md
$ rg -n "github_destructive" docs/dev/hook-boundaries.md

# AC7
$ uv run pytest tests/codex/test_local_main_branch_guard.py .claude/hooks/tests/test_local_main_branch_guard.py -q

# AC8
$ rg -n "gh_issue_edit" tests/codex/test_local_main_branch_guard.py

# AC9
$ rg -n "gh_issue_create" tests/codex/test_local_main_branch_guard.py

# AC10
$ rg -n "bare_gh_issue" tests/codex/test_local_main_branch_guard.py

# AC11
$ rg -n "artifact_export_allow" tests/codex/test_local_main_branch_guard.py

# AC12
$ rg -n "artifact_export_block" tests/codex/test_local_main_branch_guard.py

# AC13
$ rg -n "gh_mutation_not_readonly" tests/codex/test_local_main_branch_guard.py

# AC14
$ rg -n "gh_pr_merge" tests/codex/test_local_main_branch_guard.py

# AC15
$ rg -n "readonly_artifact_export" docs/dev/hook-boundaries.md
$ rg -n "github_issue_mutation" docs/dev/hook-boundaries.md
$ rg -n "github_destructive" docs/dev/hook-boundaries.md
$ rg -n "github_issue_mutation" docs/dev/agent-skill-boundaries.md
$ rg -n "github_issue_mutation" AGENTS.md
$ rg -n "github_issue_mutation" .codex/rules/default.rules

# 全体品質ゲート
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

Allowed Paths

  • scripts/agent-guards/local_main_branch_guard.py
  • tests/codex/test_local_main_branch_guard.py
  • .claude/hooks/tests/test_local_main_branch_guard.py
  • docs/dev/hook-boundaries.md
  • docs/dev/agent-skill-boundaries.md
  • AGENTS.md
  • .codex/rules/default.rules

Stop Conditions

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

Runtime Verification Applicability

decision: deferred
deferred_destination: 本 Issue の実装完了後(AC8〜AC13 の境界テストが tests/codex/test_local_main_branch_guard.py に追加された時点)
deferred_verification_condition: uv run pytest tests/codex/test_local_main_branch_guard.py .claude/hooks/tests/test_local_main_branch_guard.py -v が全 PASS

Required Skills

  • Python(guard スクリプト実装・pytest)
  • GitHub CLI コマンド分類設計(5 分類境界)
  • hook boundary design(display-readonly / artifact-export / mutation / destructive 分類)

Scope Delta(任意)

Scope Delta 適用: anchor comment(issuecomment-4762317985)の人間フィードバックに基づき、以下を拡張。

  • gh issue create / gh issue edit を許可対象に追加(github_issue_mutation_command 新設)
  • gh issue view > tmp/*.md を readonly_artifact_export_command として許可
  • Allowed Paths に AGENTS.md、.codex/rules/default.rules、docs/dev/agent-skill-boundaries.md を追加
  • AC8〜AC15 追加(anchor comment 修正提案)
  • 5 分類語彙を In Scope・Outcome・Background に明示

Delivery Rule

1 Issue = 1 PR。worktree issue-1124-github-remote-ops-classification で作業する。Draft PR から開始する。

Activity

  1. added
    enhancement
    phase/implementation
    on Jun 21, 2026
  2. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    you asked

    message time: 2026-06-21 23:25:03

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


    chatgpt response

    対象 Issue と関連する Issue/PR/コメントをまず取得し、実装・配布物に関わる主張は外部ドキュメントで裏取りします。その上で、採用可否・欠陥・追加すべき受け入れ条件まで絞ってレビューします。

    ここまでで、#1124 自体にコメントはなく、実質的な参照元はマージ済み PR #1120 と、その元 Issue #1108 です。既に #1120 の本文と差分上に「許可対象の過大化→最小集合へ戻す」文脈が見えています。

    関連元の Issue/PR は確認済みですが、#1124 を直接参照する実装 PR が既に出ていないかだけ追加で確認します。これでレビュー対象の漏れを潰します。

    判定

    REQUEST_CHANGES。
    #1124 の方向性、つまり display-readonly と github_remote_ops_command を分離すること自体は正しいです。ただし、Issue 本文の分類対象が現行実装・#1089 の既存 contract・PR #1120 の実装後状態と一部衝突しています。このまま実装すると、単なる境界明確化ではなく false allow の再導入 になります。#1124 自体に追加コメントはありません。

    前提整理

    #1089 / PR #1100 の元 contract はかなり明確です。gh issue view/list と gh pr view/list/status は display_readonly_command、それ以外の gh issue/pr mutation は fail-closed でした。特に #1089 の AC11 は gh issue edit/comment/close、gh pr checkout/merge/update-branch を fail-closed とする設計です。

    #1108 は、その fail-closed 化で post-merge-cleanup に必要な gh issue close/comment まで止まったことへの regression fix でした。ただし #1108 初期案は gh issue create/edit/comment や gh pr create/edit/comment を regex で広く allow する案で、レビューコメントでは「read-only / remote mutation / interactive / branch-dependent を混同する」と強く指摘されています。

    PR #1120 はその後、REASON_GITHUB_REMOTE_OPS = "github_remote_ops_command" と token-based classifier を追加し、gh issue close/comment/reopen、gh pr comment/edit の一部を allow する実装へ寄せています。現行 main でも display-readonly は DISPLAY_READONLY_PATTERNS、remote ops は is_github_remote_ops_command()、その他 gh issue/pr は is_gh_mutation_command() で block という構造です。

    重大ブロッカー

    B1. #1124 は gh issue edit と gh pr merge を “AI workflow 必須” として混ぜており、現行実装と衝突している

    #1124 の本文は gh issue close / gh issue comment に加えて、gh issue edit、gh pr merge、gh pr comment などを github_remote_ops_command として明示分類するよう読めます。特に検索結果上の #1124 本文では、AI workflow 必須コマンドの例に gh issue edit と gh pr merge が含まれています。

    これは危険です。現行実装は gh issue edit を明示的に除外し、テストでも block しています。

    gh pr merge はさらに危険です。GitHub CLI の公式 manual では gh pr merge --delete-branch が local / remote branch の削除を含み得ます。これは local root branch guard の目的に直接関わるため、github_remote_ops_command ではなく fail-closed 維持が妥当です。(GitHub CLI)

    修正: #1124 の scope / AC から gh pr merge を削除してください。gh issue edit も初回では block 維持、必要なら別 Issue で「許可 flag matrix」を定義すべきです。

    B2. --body-file の扱いが粗く、ファイル読込経由の情報漏えいを許容している

    現行実装は gh issue comment <N> --body-file <path> と gh pr comment <N> --body-file <path> を allow しています。テストにも /tmp/body.txt を allow するケースがあります。

    GitHub CLI 公式 manual では --body-file はファイルから本文を読み込み、- なら stdin から読むオプションです。これは「コメント追加」ではなく「ローカルファイル内容を remote に送信する」操作です。(GitHub CLI) (GitHub CLI)

    修正: 初回の #1124 では --body-file / -F を block に寄せるべきです。どうしても許可するなら、少なくとも --body-file - のみ許可、または repo-relative な安全な一時ファイルパスだけに限定してください。/tmp, absolute path, .., home path, /proc, /etc は block です。

    B3. comment 系の destructive / interactive flag block が不足している

    現行実装で明示 block しているのは --delete-last, --editor, --web だけです。

    しかし公式 manual 上、gh issue comment / gh pr comment には --edit-last、--create-if-none、--yes、短縮形 -e / -w、-F などもあります。--edit-last は既存コメント編集、--delete-last は削除、--editor / --web は外部 UI / 対話系です。(GitHub CLI) (GitHub CLI)

    修正: block list は最低限次を含めるべきです。

    --delete-last
    --edit-last
    --create-if-none
    --yes
    --editor
    -e
    --web
    -w
    --body-file
    -F
    

    --body-file を許可する場合でも、別の path policy を必須にしてください。

    B4. has_body 判定が flag の存在だけで、値の存在を検証していない

    現行実装は --body, -b, --body-file の token が含まれていれば has_body = True になります。つまり gh issue comment 123 --body のような「値なし flag」を guard が allow し得ます。

    修正: --body text, --body=text, -b text の値あり形式だけを allow してください。値なし、次 token が別 flag、空文字相当は block です。--body-file は B2 の通り初回 block が安全です。

    B5. gh pr edit <N> が広すぎる

    現行実装は gh pr edit について、PR 番号が数字ならその後の flag matrix を見ずに allow します。

    公式 manual では gh pr edit は base branch、body file、labels、projects、reviewers、assignees など多くの PR metadata を変更できます。また引数なしの場合は current branch の PR を選択します。(GitHub CLI)

    修正: gh pr edit は初回 #1124 では block 維持が妥当です。必要なら次のような極小許可に限定してください。

    allow:
      gh pr edit <number|url> --title <text>
      gh pr edit <number|url> --body <text>
    
    block:
      gh pr edit
      gh pr edit <branch>
      gh pr edit <N> --base ...
      gh pr edit <N> --body-file ...
      gh pr edit <N> --add-reviewer ...
      gh pr edit <N> --add-project ...
      gh pr edit <N> --add-label ...
    

    B6. --repo / -R の repo 境界が未定義

    gh issue/pr には inherited --repo があり、別 repo を対象にできます。公式 manual でも --repo <[HOST/]OWNER/REPO> が共通 option として示されています。(GitHub CLI) (GitHub CLI)

    現行 classifier は --repo を見ません。local root context で実行される前提でも、AI workflow の guard としては「この repo に対する remote mutation だけを許す」ことを明示した方が安全です。

    修正: どちらかを AC に入れてください。

    方針 A: remote ops は --repo squne121/loop-protocol を必須にする
    方針 B: --repo / -R がある場合、squne121/loop-protocol 以外は block。省略時のみ current repo とみなす
    

    実装上は B の方が既存運用への影響が少ないです。

    B7. docs が現行実装と矛盾している

    docs/dev/hook-boundaries.md はまだ reason_code 一覧に github_remote_ops_command を含めておらず、gh mutation コマンド(edit/close/merge 等)は fail-closed と記載しています。これは PR #1120 後の現行実装と矛盾します。

    修正: #1124 の中心成果物は code より doc の正本化です。hook-boundaries.md に次を明記してください。

    display_readonly_command:
      gh issue view/list
      gh pr view/list/status
      pipeline 起点として許可
    
    github_remote_ops_command:
      GitHub remote metadata mutation
      local checkout / branch state は変更しない
      display-readonly ではない
      reason_code は github_remote_ops_command
      pipeline / wrapper / redirect は不可
      token + flag matrix に合致するものだけ allow
    
    blocked gh mutation:
      gh pr merge
      gh pr checkout
      gh pr update-branch
      gh pr create
      gh issue create
      gh issue edit
      gh api
      上記以外の未分類 gh issue/pr は fail-closed
    

    B8. 評価順により drifted / detached root でも remote ops が通るが、#1124 の AC に明記されていない

    現行 evaluate() は is_github_remote_ops_command() を root state 判定より前に置いています。そのため github_remote_ops_command は drifted / detached root でも allow されます。

    これは設計としてはあり得ます。GitHub Issue コメントや close は local checkout を壊さないためです。ただし、guard policy としては重大な判断です。#1124 の docs / tests に明記されていないと、後続レビューで「なぜ drifted root でも allow なのか」が再びブレます。

    修正: AC に次を追加してください。

    AC追加:
    - default / drifted / detached_or_unknown の各 root state で、
      display-readonly と github_remote_ops_command の扱いを明示する。
    - github_remote_ops_command を drifted/detached でも allow する場合、
      その根拠を docs/dev/hook-boundaries.md に記載し、両 flavor で regression test を追加する。
    

    推奨する allow / block matrix

    初回 #1124 ではこの程度まで絞るのが妥当です。

    コマンド 判定 reason_code
    gh issue view <N> allow readonly_command
    gh issue list allow readonly_command
    gh pr view <N> allow readonly_command
    gh pr list allow readonly_command
    gh pr status allow readonly_command
    gh issue close <N> [--reason ...] [--comment ...] allow github_remote_ops_command
    gh issue reopen <N> [--comment ...] allow github_remote_ops_command
    gh issue comment <N> --body <text> allow github_remote_ops_command
    gh pr comment <N> --body <text> allow github_remote_ops_command
    gh issue edit ... block unparseable_branch_mutation
    gh issue create ... block unparseable_branch_mutation
    gh pr create ... block unparseable_branch_mutation
    gh pr edit ... block 初期推奨 unparseable_branch_mutation
    gh pr merge ... block unparseable_branch_mutation
    gh pr checkout ... block branch mutation
    gh api ... block / out of scope unparseable_branch_mutation

    gh pr create は current branch が fully pushed でない場合に push 先を尋ねたり fork / push に関与し得るため、remote metadata 操作として扱うべきではありません。(GitHub CLI)
    gh pr checkout は local git checkout を行うコマンドなので、local root branch guard の対象そのものです。(GitHub CLI)
    gh issue create も bare 実行では対話入力や --web、--editor、--body-file などを含むため、#1124 の初回対象から外すのが安全です。(GitHub CLI)

    追加すべき AC

    #1124 の AC は現状だと「境界を明示する」には弱いです。以下を追加してください。

    - [ ] AC8: `gh issue view/list` と `gh pr view/list/status` は `readonly_command` として扱われ、`github_remote_ops_command` にならない
    - [ ] AC9: `github_remote_ops_command` は `readonly_command` ではないことを両 flavor のテストで検証する
    - [ ] AC10: `gh issue close 123 | head`、`gh issue close 123 && git switch issue-x`、`bash -lc 'gh issue close 123'` は block される
    - [ ] AC11: `--delete-last`、`--edit-last`、`--editor/-e`、`--web/-w`、`--create-if-none`、`--yes`、`--body-file/-F` は block される
    - [ ] AC12: `--body` / `-b` は値あり形式のみ allow され、値なしは block される
    - [ ] AC13: `--repo` / `-R` が他 repo を指す場合は block される
    - [ ] AC14: `gh pr merge`、`gh pr checkout`、`gh pr create`、`gh issue create`、`gh issue edit` は block 維持される
    - [ ] AC15: drifted / detached root における `github_remote_ops_command` の allow/block 方針が docs と tests で一致している
    - [ ] AC16: `uv run python3 scripts/check_hook_boundaries.py` が PASS する

    検証コマンドの差し替え

    #1124 の rg -c "github_remote_ops_command" のような検証は弱いです。分類境界の品質保証になりません。次を canonical gate にしてください。

    uv run pytest tests/codex/test_local_main_branch_guard.py -v -k "gh_ops or gh_readonly or gh_mutation"
    uv run pytest .claude/hooks/tests/test_local_main_branch_guard.py -v -k "gh_ops or gh_readonly or gh_mutation"
    uv run pytest tests/codex/test_local_main_branch_guard.py .claude/hooks/tests/test_local_main_branch_guard.py -q
    uv run python3 scripts/check_hook_boundaries.py
    pnpm typecheck
    pnpm lint
    pnpm test
    pnpm build

    最終提案

    #1124 は 実装 Issue としては採用可 ですが、着手前に Issue 本文を修正すべきです。特に gh issue edit と gh pr merge を github_remote_ops_command に含める表現は削除してください。#1124 の目的は「GitHub remote ops を read-only に誤分類しないこと」であって、「GitHub CLI mutation を広く許可すること」ではありません。

    実テストはこの場では実行していません。上記は GitHub 上の Issue / PR / コメント / 現行ファイルと、GitHub CLI 公式 manual に基づく静的レビューです。


    you asked

    message time: 2026-06-21 23:34:42

    「gh issue edit」は許容でしょ。あとview をリダイレクトでmdファイルへ出力とかも許可。
    「gh issue create」は許可じゃないの?そうじゃななかったらどういう手段で実行スべきなのかエージェントフレンドリーに出力して。
    AI運用設計を網羅的に確認して。hook、スキルなど。


    chatgpt response

    方針を修正します。あなたの運用前提では gh issue edit と gh issue create は禁止ではなく、非対話・repo限定・本文/ラベル/readback付きの管理された mutation として許可対象に寄せるべきです。今から repo の hook/skill/rules/docs 側の整合を確認します。

    訂正結論

    あなたの指摘どおり、gh issue edit は許容対象にすべきです。前回の「初回 #1124 では block 維持」は、この repo の実運用に合っていません。

    ただし分類名は重要です。gh issue edit / gh issue create は read-only ではない。分類は github_issue_mutation_command か github_remote_ops_command。条件は 非対話・repo限定・body-file/validator/readback付き です。

    gh issue view ... > tmp/foo.md も許容でよいです。ただしこれも純粋な display_readonly_command ではなく、read-only remote fetch + local artifact write です。現在の guard は > を shell metachar として一律 block する構造なので、#1124 はここも明示的に直す必要があります。

    gh issue create は許可でよい

    gh issue create は許可対象です。GitHub CLI 公式でも、--body を省略すると prompt、--title を省略すると prompt、--body-file はファイルから本文を読む、と定義されています。つまり bare gh issue create は不可、非対話フラグ付きは可 です。(GitHub CLI)

    この repo にはすでに create-issue skill があり、説明文で「人間承認なしで create_issue_txn.py を実行する」と定義されています。 また、validator 通過後に create_issue_txn.py を実行し、helper が --title / --body-file / --label / --parent-issue / --dependency を受けて read-back まで行う設計です。

    したがって、agent-friendly な実行経路はこれです。

    # 1. 本文を repo-local artifact に作る
    mkdir -p tmp
    NEW_BODY="tmp/issue_body_1124_followup.md"
    
    # 2. 事前検証
    uv run python3 .claude/skills/create-issue/scripts/validate_issue_body.py \
      --body-file "$NEW_BODY" \
      --kind implementation \
      --title "$TITLE"
    
    # 3. 起票 transaction
    uv run python3 .claude/skills/create-issue/scripts/create_issue_txn.py \
      --repo squne121/loop-protocol \
      --title "$TITLE" \
      --body-file "$NEW_BODY" \
      --label phase/implementation \
      --label enhancement
    
    # 4. read-back
    gh issue view "$CREATED_ISSUE_NUMBER" \
      --repo squne121/loop-protocol \
      --json title,labels,body > "tmp/issue_${CREATED_ISSUE_NUMBER}_readback.json"

    gh issue edit の扱い

    gh issue edit も許可対象です。公式 manual では issue 番号または URL を指定して issue を編集し、--body-file、--title、--add-label、--parent、--repo 等を持ちます。(GitHub CLI)

    この repo の edit-issue skill も gh issue edit を前提にしています。バックアップ取得、guard-issue-body.py、contract_readiness_check.py、gh issue edit --repo --body-file、read-back、ready tuple 検証、変更コメントまで手順化されています。

    許可形はこうです。

    gh issue edit "$ISSUE_NUMBER" \
      --repo squne121/loop-protocol \
      --body-file "tmp/issue_${ISSUE_NUMBER}_new.md"
    
    gh issue edit "$ISSUE_NUMBER" \
      --repo squne121/loop-protocol \
      --title "$PROPOSED_TITLE" \
      --body-file "tmp/issue_${ISSUE_NUMBER}_new.md"

    禁止すべきなのは gh issue edit 123 のような 変更内容なし / 対話・曖昧・repo不明 の形です。

    gh issue view > md の扱い

    許可でよいです。gh issue view は title/body 等を表示する read operation で、--json と --jq も公式に用意されています。(GitHub CLI)

    ただし、shell 的には > はローカルファイル write なので、既存の display_readonly_command とは分けるべきです。

    分類案:

    display_readonly_command:
      gh issue view/list
      gh pr view/list/status/checks/diff
      stdout 表示のみ
    
    readonly_artifact_export_command:
      gh issue view <N> --repo squne121/loop-protocol --json body,title,labels > tmp/issue_<N>.json
      gh issue view <N> --repo squne121/loop-protocol --json body --jq .body > tmp/issue_<N>.md
      gh pr view <N> --repo squne121/loop-protocol --json body,title > tmp/pr_<N>.json
    
    禁止:
      > src/...
      > docs/...
      > .github/...
      > .claude/settings.json
      > .env
      > /tmp/...
      >> 任意ファイル
    

    repo-tracked .md へ直接 Bash redirect するのは避け、tmp/ や .claude/artifacts/ に限定するのがよいです。repo-tracked docs を更新する場合は Write/Edit/MultiEdit の Allowed Paths 管理に載せるべきです。

    いまの設計上の不整合

    大きい不整合は 4 つあります。

    1つ目。.claude/settings.json は gh issue edit/create/close/comment/view、gh pr merge/create/review/comment/view、gh api まで広く allow しています。 一方、local_main_branch_guard.py は gh issue create と gh issue edit を現状の remote ops allowlist から外しており、gh issue close/comment/reopen と gh pr comment/edit だけを許可しています。

    2つ目。.codex/rules/default.rules は rtk gh issue create/edit/close/reopen/delete を prompt、つまり明示レビュー要求扱いにしています。 これは「Issue/PR 投稿に人間承認不要」という現行運用と衝突します。

    3つ目。AGENTS.md は direct gh issue create/edit を forbidden と書いています。 ただし agent-skill-boundaries.md では issue-author が create-issue / edit-issue を使い、Issue を起票・修正する役割と定義されています。 ここは「raw directは禁止、managed skill経由は許可」と明文化すべきです。

    4つ目。docs/dev/hook-boundaries.md はまだ github_remote_ops_command を reason_code 一覧に含めず、gh mutation コマンド(edit/close/merge 等)は fail-closed と書いています。 PR #1120 後の実装と docs が drift しています。

    #1124 のあるべき修正方針

    #1124 は「read-only と mutation を分ける」Issue ではなく、より正確には AI workflow 用 GitHub mutation を first-class に分類する Issue に変えるべきです。

    分類はこうです。

    display_readonly_command:
      gh issue view/list
      gh pr view/list/status/checks/diff
      パイプは head/tail/wc 等の表示整形のみ可
    
    readonly_artifact_export_command:
      gh issue view / gh pr view の JSON/body を tmp/ または .claude/artifacts/ に保存
      local file write を伴うので readonly_command とは別 reason_code
    
    github_issue_mutation_command:
      gh issue create/edit/comment/close/reopen
      非対話・repo限定・body-file/validator/readback 付きのみ可
    
    github_pr_metadata_command:
      gh pr create/edit/comment/review/ready
      非対話・base/head/title/body 明示・repo限定・Draft PR 既定のみ可
    
    github_destructive_or_branch_command:
      gh pr merge
      gh pr checkout
      gh pr update-branch
      git checkout/switch/reset/clean
      原則 block または cleanup/default permission
    
    github_api_command:
      gh api GET は read-only として route allow
      PATCH/POST/DELETE は endpoint + payload schema 単位で別 classifier
    

    gh pr merge は github_remote_ops_command に入れない方がよいです。post-merge-cleanup-worker は cleanup カテゴリで、branch 削除や PR merge のような取り消し困難な操作を含むため permissionMode: default を維持すると設計されています。

    #1124 に追加すべき AC

    - [ ] AC8: `gh issue edit <N> --repo squne121/loop-protocol --body-file tmp/*.md` は `github_issue_mutation_command` として allow される
    - [ ] AC9: `gh issue create --repo squne121/loop-protocol --title <title> --body-file tmp/*.md --label ...` は `github_issue_mutation_command` として allow される
    - [ ] AC10: bare `gh issue create` / bare `gh issue edit` は block される
    - [ ] AC11: `gh issue view <N> --repo squne121/loop-protocol --json body --jq .body > tmp/issue_<N>.md` は `readonly_artifact_export_command` として allow される
    - [ ] AC12: `gh issue view ... > src/...` / `> docs/...` / `> .env` / `>> ...` は block される
    - [ ] AC13: `gh issue create/edit/comment/close/reopen` は `readonly_command` ではないことを両 flavor テストで確認する
    - [ ] AC14: `gh pr merge` / `gh pr checkout` / `gh pr update-branch` は `github_issue_mutation_command` に分類されず block または cleanup policy に残る
    - [ ] AC15: `.claude/settings.json`、`.codex/rules/default.rules`、`AGENTS.md`、`docs/dev/hook-boundaries.md`、`docs/dev/agent-skill-boundaries.md` の policy が同じ分類語彙に揃っている

    そのまま渡せる修正プロンプト

    **Standard Title: **

    Issue #1124 修正指示

    対象: squne121/loop-protocol Issue #1124
    目的: GitHub CLI の read-only / artifact export / issue mutation / destructive operation を AI workflow 向けに再分類し、Claude Code / Codex / hooks / skills / docs の不整合を解消する。

    方針

    gh issue edit と gh issue create は禁止ではない。
    ただし readonly_command ではなく、github_issue_mutation_command として分類する。

    許可するのは以下の非対話・repo限定・validated な形のみ。

    • gh issue create --repo squne121/loop-protocol --title <title> --body-file tmp/<file>.md --label <label>...
    • gh issue edit <N> --repo squne121/loop-protocol --body-file tmp/<file>.md
    • gh issue edit <N> --repo squne121/loop-protocol --title <title> --body-file tmp/<file>.md
    • gh issue comment <N> --repo squne121/loop-protocol --body-file tmp/<file>.md
    • gh issue close <N> --repo squne121/loop-protocol --reason completed
    • gh issue reopen <N> --repo squne121/loop-protocol

    bare / interactive / repo不明の形は block する。

    • gh issue create
    • gh issue edit 123
    • gh issue create --web
    • gh issue create --editor
    • gh issue edit 123 --body-file -
    • gh issue edit 123 --repo other/repo ...

    gh issue view のファイル出力は許可する。ただし display_readonly_command ではなく、readonly_artifact_export_command として分類する。

    許可例:

    • gh issue view <N> --repo squne121/loop-protocol --json body --jq .body > tmp/issue_<N>.md
    • gh issue view <N> --repo squne121/loop-protocol --json title,labels,body > tmp/issue_<N>_readback.json

    禁止例:

    • gh issue view <N> > src/foo.md
    • gh issue view <N> > docs/foo.md
    • gh issue view <N> >> tmp/foo.md
    • gh issue view <N> > .env

    変更対象

    • scripts/agent-guards/local_main_branch_guard.py
    • tests/codex/test_local_main_branch_guard.py
    • .claude/hooks/tests/test_local_main_branch_guard.py
    • docs/dev/hook-boundaries.md
    • docs/dev/agent-skill-boundaries.md
    • AGENTS.md
    • .codex/rules/default.rules
    • 必要に応じて .claude/skills/create-issue/SKILL.md
    • 必要に応じて .claude/skills/edit-issue/SKILL.md

    実装要件

    1. github_issue_mutation_command reason_code を追加する。
    2. 既存の github_remote_ops_command は残すか、github_issue_mutation_command に統合する。統合する場合は docs と tests も同時更新する。
    3. display_readonly_command と readonly_artifact_export_command を分離する。
    4. gh issue create/edit/comment/close/reopen は token-based classifier で判定する。
    5. --repo / -R が指定された場合は squne121/loop-protocol のみ許可する。
    6. --repo 省略を許す場合は current repo が squne121/loop-protocol であることを別途解決する。解決不能なら block。
    7. --body-file は repo-local tmp/ または .claude/artifacts/ 配下だけ許可する。
    8. --body-file - は block。
    9. --web / --editor / -w / -e は block。
    10. gh pr merge / gh pr checkout / gh pr update-branch はこの Issue では allow しない。cleanup/destructive policy に残す。
    11. gh api は blanket allow しない。GET read-only と mutation endpoint を分ける follow-up を残す。

    検証

    以下を実行して PASS させる。

    uv run pytest tests/codex/test_local_main_branch_guard.py -v -k "gh_issue or artifact_export or gh_mutation"
    uv run pytest .claude/hooks/tests/test_local_main_branch_guard.py -v -k "gh_issue or artifact_export or gh_mutation"
    uv run pytest tests/codex/test_local_main_branch_guard.py .claude/hooks/tests/test_local_main_branch_guard.py -q
    uv run python3 scripts/check_hook_boundaries.py
    node scripts/session-recording/validate-codex-hooks.mjs .codex/hooks.json
    pnpm typecheck
    pnpm lint
    pnpm test
    pnpm build

    完了条件

    • Claude Code と Codex の policy が同じ分類語彙を使う
    • gh issue create/edit が managed mutation として通る
    • bare / interactive / wrong-repo / unsafe body-file は block される
    • gh issue view > tmp/*.md が通る
    • hook-boundaries と agent-skill-boundaries が実装と一致する
    • create-issue / edit-issue skill の既存フローが hook に阻害されない

    最終レビュー判定

    #1124 は REQUEST_CHANGES だが、方向性は拡張するべきです。
    前回のように gh issue edit/create を禁止寄りにするのではなく、AI workflow の中核 mutation として first-class 化するのが正しいです。当前の敵は gh issue edit/create 自体ではなく、bare 実行・対話実行・wrong repo・unsafe redirection・blanket gh api・docs/rules/hook/skill の drift です。

  3. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor
    schema: LOOP_HANDOFF_RESULT_V1
    issue_number: 1124
    termination_reason: approved
    iteration: 1
    body_sha256: "sha256:1e40507f54b14aae4b14367120853c58f6bff09824d3042f3d21d9c04823b80a"
    anchor_comment: "https://github.com/squne121/loop-protocol/issues/1124#issuecomment-4762317985"
    
    changes_applied:
      - section: goal_ref
        summary: "GitHub CLI 5 分類体系への再編を明示(display-readonly / readonly-artifact-export / github-issue-mutation / github-pr-metadata / destructive)"
      - section: in_scope
        summary: "gh issue create / gh issue edit(非対話・repo 限定・body-file 付き)を許可対象に追加。gh issue view > tmp/*.md を readonly_artifact_export_command として追加"
      - section: acceptance_criteria
        summary: "AC8〜AC15 追加(anchor comment の人間フィードバックを AC として明文化)"
      - section: allowed_paths
        summary: "AGENTS.md、.codex/rules/default.rules、docs/dev/agent-skill-boundaries.md を追加(7 ファイルに拡張)"
      - section: verification_commands
        summary: "pytest -k フィルタを rg ベース(baseline-fail: exit 1)に変更。全 AC1〜AC15 に対応する VC を追加"
      - section: runtime_verification_applicability
        summary: "decision: deferred(AC8〜AC13 テストは実装で新規追加)を追加"
    
    anchor_comment_requirements_satisfied:
      - "gh issue edit は許可(AC8 に明示)"
      - "gh issue create は許可(AC9 に明示)"
      - "gh issue view > tmp/*.md は readonly_artifact_export_command として許可(AC11 に明示)"
      - "AI 運用設計を網羅的に確認(AGENTS.md / .codex/rules/default.rules / agent-skill-boundaries.md を Allowed Paths に追加し AC15 に語彙統一確認を追加)"
    
    contract_readiness: go
    next_action: issue_contract_review または implement_issue
  4. added 5 commits that reference this issue on Jun 22, 2026
  5. squne121 commented on Jun 22, 2026

    @squne121
    OwnerAuthor

    review subagent verdict: iteration 2 APPROVE. RB1/RB2 resolved. LOOP_VERDICT_V2 posted on PR #1126.

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

    enhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions