Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: parent
goal_ref: "guard-japanese-prose と issue contract authoring の境界を SSOT 化し、公開副作用を伴う GitHub mutation だけを guard しつつ、機械可読契約・テンプレ見出し・一時下書き・終了レポートが guard と両立した状態で issue-refinement-loop / create-issue / edit-issue が実運用で回ることを、運用証跡(deterministic replay/test artifact)付きで保証する"
change_kind: workflow
parent_mode: delivery-rollup
closure_mode: child-completeGoal
guard-japanese-prose と issue contract authoring の境界を SSOT 化し、公開副作用を伴う GitHub mutation だけを guard しつつ、機械可読契約・テンプレ見出し・一時下書き・終了レポートが guard と両立した状態で issue-refinement-loop / create-issue / edit-issue が実運用で回ることを、運用証跡(deterministic replay/test artifact)付きで保証する。
Summary
guard-japanese-prose.sh は英語 prose 混入の防止には有効だが、現在は template 由来の正規見出しや機械可読契約、tmp/ 下書き、終了レポート投稿まで同じ日本語比率ルールで扱うため、Issue 本文を正しくテンプレ準拠へ寄せるほど guard と衝突する。特に #606 で comment body mutation guard が拡張された結果、authoring 経路全体の境界を整理しないまま個別経路だけを広げると、issue-refinement-loop / create-issue / edit-issue の失敗が再発する。
直近の reviewer 指摘(REQUEST_CHANGES 2 件)は、今回の本質的な失敗が guard の条件式が間違っていたことではなく、本番阻止系 hook を、実際の authoring workflow で Claude Code に使わせて厳しすぎないか・回避路がないか・自己修復できるかを計測する前に enforce で投入したことだと整理している。したがって本 parent は、追加の正規表現ではなく、prose 境界の SSOT 化・公開 mutation route matrix の SSOT 化・shadow/dry-run rollout・Claude Code replay 検証を先行する親契約として固定する。
本 parent は、公開副作用に対しては厳格に guard するが、テンプレ由来の機械可読構造と安全な一時下書きは妨げない境界へ正規化し、その安全性を CI だけでなく実運用証跡で証明する follow-up 群を束ねる。
Outcome
本セクションは Issue authoring 系ワークフロー(issue-refinement-loop / create-issue / edit-issue)が達成すべき成果物を定義する。
以下を同時に満たす状態を、運用証跡付きで達成する。
- prose / code / machine-readable / テンプレ見出し / bilingual heading / 一時下書き / 公開出力の分類が、単一の SSOT(prose boundary policy)から導出され、
guard-japanese-prose.sh/validate_japanese_content.py/check_issue_contract.py/guard-issue-body.py/issue-refinement-loopの dry-run が同じ分類結果を使うこと。 - 公開副作用を伴う GitHub mutation(
gh issue/prwrapper の body 系、gh apiの REST body/comment mutation、gh api graphqlの body/comment mutation)が単一の mutation route matrix SSOT から判定され、--inputだけでなく-f body=/-F body=/-F body=@file経路も検出されること。 - 本番 enforce へ切り替える前に shadow / dry-run mode で would-block 件数・理由・route・failed block count を計測でき、enforce は環境変数または設定で rollback 可能で、初期値は shadow または限定 enforce であること。
- Claude Code replay scenario(R1〜R7)の transcript または structured log が証跡として残り、create-issue / edit-issue / issue-refinement-loop の終了レポートが厳しすぎず・回避路がなく・自己修復できることが確認されていること。
- borderline は人間確認(
ask)に逃がさず、Claude Code が修復できる deterministic な repair signal(exit 2 + repair reasonもしくはexit 0 + permissionDecision: deny)として返すこと。
Desired Destination
Machine-Readable Contract / Outcome / In Scope / Allowed Paths / Stop Conditions / Handoff Contractなどの正規見出しを含む Issue 本文が、contract checker と prose guard を同時に通過する。- bilingual 見出し(例:
## 成果物 (Outcome))が、checker と guard の両方で同一の正規形ルールにより正規見出しとして扱われ、純粋な英語説明 prose は引き続き guard で検出される。 tmp/*.mdや/tmp/*issue*body*.mdへの下書き作成は guard にブロックされず、gh issue edit/comment・gh api ... issues/...・gh api ... comments/...・gh api graphql ...など公開 mutation だけが guard 対象になる。issue-refinement-loopの終了レポート投稿前に dry-run guard を実行し、guard failure 時は本文回避ではなく、上限付きでテンプレート再生成へ戻り、上限超過時は公開投稿せず reason_code を local artifact / stderr に残す。- 上記が CI のユニットテストだけでなく、deterministic shadow-mode replay/test 証跡で運用上も成立していることを確認できる。
Current Validated Scope
.claude/hooks/guard-japanese-prose.shとvalidate_japanese_content.pyの、guard 対象 prose と、テンプレ / 機械可読構造 / tmp 下書きの境界整理、および分類の SSOT 化。check_issue_contract.py/guard-issue-body.py側の正規見出し認識と bilingual heading 正規形の共有。- 公開 mutation route matrix の SSOT 化(
ghwrapper /gh apiREST /gh api graphql/-f・-F・--input経路)。 issue-refinement-loop/edit-issue/create-issueの終了レポート・下書き投稿経路に対する guard 互換テンプレート / dry-run contract / shadow rollout。
Decisions Fixed
- 2026-06-04:
#606を comment body mutation guard の REST endpoint 拡張として継続し、本 parent は authoring boundary 全体の整合を束ねる delivery-rollup tracker とする。 - 2026-06-04: template 由来の英語正規見出しは prose guard の違反 prose ではなく、機械可読構造として除外する方針を採る。
- 2026-06-04:
tmp///tmp/の下書きは公開出力と分離し、guard は公開副作用を伴う mutation に集中させる。 - 2026-06-04: prose / code / machine-readable / heading / 一時下書き / 公開出力の分類は単一の prose boundary policy SSOT に置き、各 hook / validator / checker / loop は分類結果を consume するだけにする。同じような正規表現を各所に書くことは禁止する(reviewer Blocker 1 を親契約化)。
- 2026-06-04:
tmp下書きの Write/Edit/MultiEdit は公開出力として block せず、必要なら advisory lint のみとする。guard はgh issue/prの body 系、gh apiREST、gh api graphqlの公開 mutation 時に body 実体を読んで検査し、stdin / unreadable file / invalid JSON /body:null/ 空 body は fail-closed にする(reviewer Blocker 2 を親契約化)。 - 2026-06-04:
gh apiの comment / body mutation guard は--inputだけでなく-f body=/-F body=/-F body=@fileを検出対象に含める。--inputのみを guard すると-f body=で迂回できるため、これは仕様上の抜け道として必須対象にする(reviewer Blocker 3 を親契約化)。 - 2026-06-04:
gh api graphqlの body / comment mutation(addComment/updateIssueComment/ PR review comment 系を含む)は、専用 parser が実装されるまで conservative deny / repair required を invariant として固定し、GraphQL を理由に public output guard を bypass してはならない(reviewer Blocker 4 を親契約化)。 - 2026-06-04: bilingual heading は正規形ルール(
heading_policy)として、canonical_en / canonical_ja / accepted_forms / prose_guard_kind / contract_checker_kind を定義し、checker と guard が同一ルールを参照する。公開 Issue 本文では bilingual heading を標準とする(reviewer Blocker 5 を親契約化)。 - 2026-06-04: 終了レポートの dry-run guard 失敗時は、deterministic template 生成 → 同一 classifier で dry-run → 失敗時は 1 回だけ template-safe regeneration → なお失敗なら公開投稿しない → reason_code を local artifact / stderr に出す、という上限付き経路にする。無制限 regeneration と人間確認への escape hatch は設けない(reviewer Blocker 6 を親契約化)。
- 2026-06-04: 本番 enforce 前に
GUARD_JAPANESE_PROSE_MODE=shadow|enforce相当の shadow / dry-run mode を設け、shadow では block せず would-block 件数・理由・route・public_mutation・failed_block_count・duration を deterministic replay/test artifact として記録する。enforce 切替は環境変数または設定で rollback 可能とし、初期値は shadow または限定 enforce とする。 - 2026-08-20: OWNER decision により、
.guard_shadow_log.jsonlを repo-local persistent shadow telemetry として恒久運用する設計を廃止する。shadow / dry-run mode 自体(unset/off は non-blocking、enforce は block)は維持するが、would-block 計測・R1〜R7 replay 証跡は persistent production JSONL ではなく deterministic replay/test artifact(CI 実行ログ・PR 添付ファイル等)で保証する。詳細実装は 実装: guard-japanese-prose の persistent shadow logging を廃止し default non-blocking semantics を保持する #2265(guard-japanese-prose の persistent shadow logging 廃止)が所有する。 - 2026-06-04: borderline は
ask(人間確認)に逃がさず、Claude Code が修復できる deterministic repair signal(exit 2 + repair reasonまたはexit 0 + permissionDecision: deny)に統一する。askは原則禁止とする。 - 2026-06-04: parent close 条件を child が merge されたことだけにせず、shadow / replay の運用証跡が PR コメントまたは artifact に残っていることを必須材料に加える。
Quality Decision Record
Status: N/ADecision Date: 2026-06-04Does this prove the parent goal complete?: N/AReason: delivery-rollup parent のため quality-gate 判定は不要Evidence: N/ANext Action: prose boundary policy SSOT(child-0)を先頭に materialize し、guard / checker / loop 終了レポートの整合を順次修正する
Parent Closure Rule
delivery-rollup:#606と本 parent 配下で materialize された child issue が全件マージされ、かつ Desired Destination の各系統(prose 分類 SSOT・公開 mutation route matrix SSOT・tmp 下書き境界・bilingual heading 正規形・終了レポート dry-run・shadow rollout)が満たされ、さらに deterministic replay/test artifact(R1〜R7 相当)が PR コメントまたは artifact に残っている状態を確認してから close するquality-gate: N/Arouting-map: N/Adecision-log: N/A- 非
quality-gateparent のQuality Decision Recordは close 判定の必須材料にしない
Child Issues
- 実装: gh api による comment body PATCH mutation の guard 対象追加 #606 —
gh apiによる comment body mutation guard 対象追加(REST comment mutation 経路の基盤) - 実装(#646): prose / code / machine-readable / heading / tmp draft / public output 分類の prose boundary policy SSOT 化 #653 — child-0: prose / code / machine-readable / heading / tmp draft / public output の分類を単一の prose boundary policy SSOT として追加し、guard / validator / checker / loop dry-run が同じ分類結果を使う(reviewer Blocker 1)
- 実装(#646): canonical / bilingual heading 除外と heading_policy を checker / guard で共有 #654 — child-1: 正規見出し / Machine-Readable Contract / bilingual heading / VC command / code fence を prose ratio 判定から除外し、bilingual heading 正規形(
heading_policy)を checker と guard で共有する(reviewer Blocker 5、blocked-by 実装(#646): prose / code / machine-readable / heading / tmp draft / public output 分類の prose boundary policy SSOT 化 #653) - 実装(#646): 公開 mutation route matrix SSOT 化と tmp 下書き / 公開 mutation の分離(REST -f / -F / --input と GraphQL conservative deny) #655 — child-2:
tmp///tmp/下書きを公開 mutation と分離し、Write/Edit/MultiEdit の下書きは block せず、公開 mutation(REST-f/-F/--inputと GraphQL)時に body 実体を guard する。stdin / unreadable / invalid JSON / 空 body は fail-closed にする(reviewer Blocker 2・Blocker 3・Blocker 4、blocked-by 実装(#646): prose / code / machine-readable / heading / tmp draft / public output 分類の prose boundary policy SSOT 化 #653) - 実装(#646): issue-refinement-loop 終了レポートの guard 互換 renderer ライブラリ新設 #656 — child-3:
issue-refinement-loop終了レポートを guard 互換テンプレートで生成し、投稿前 dry-run guard・上限付き再生成・上限超過時の非投稿 + reason_code 出力を持つ(reviewer Blocker 6、blocked-by 実装(#646): prose / code / machine-readable / heading / tmp draft / public output 分類の prose boundary policy SSOT 化 #653) - 実装(#646): guard-japanese-prose に shadow / enforce mode と replay 証跡(R1〜R7)を追加 #657 — child-4:
GUARD_JAPANESE_PROSE_MODE=shadow|enforceの shadow / dry-run mode と計測、enforce rollback、および Claude Code replay scenario R1〜R7 の証跡収集を行う(reviewer 追加設計要件・運用証跡 AC、blocked-by 実装(#646): prose / code / machine-readable / heading / tmp draft / public output 分類の prose boundary policy SSOT 化 #653。CLOSED・実装済み。計測手段として persistent.guard_shadow_log.jsonlを採用していたが、2026-08-20 OWNER decision によりこの persistent logging 部分は 実装: guard-japanese-prose の persistent shadow logging を廃止し default non-blocking semantics を保持する #2265 で退役する) - 実装: guard-japanese-prose の persistent shadow logging を廃止し default non-blocking semantics を保持する #2265 — child: guard-japanese-prose の persistent shadow logging(
.guard_shadow_log.jsonlへの write)を廃止し、default non-blocking semantics(unset/off は allow、enforce は block)を維持したまま、計測・R1〜R7 証跡を deterministic replay/test artifact へ移行する(2026-08-20 OWNER decision、実装(#646): guard-japanese-prose に shadow / enforce mode と replay 証跡(R1〜R7)を追加 #657 の persistent logging 部分を retirement) - 実装: split_markdown_blocks の GFM 準拠セグメンテーションを prose_boundary_policy SSOT へ委譲 #659 — child-5:
split_markdown_blocks()/extract_code_fences()/validate_text()/classify_borderline()の GFM 準拠 segmentation SSOT をprose_boundary_policy.pyに統合し、validate_japanese_content.pyの独自 fence 抽出 regex を撤去する(blocked-by 実装(#646): prose / code / machine-readable / heading / tmp draft / public output 分類の prose boundary policy SSOT 化 #653/feat(#646): prose block 分類 SSOT (prose_boundary_policy.py) を新設し validate_japanese_content.py を委譲 #658、related 実装(#646): canonical / bilingual heading 除外と heading_policy を checker / guard で共有 #654/feat(#654): heading_policy inventory と bilingual heading 除外を prose_boundary_policy に追加 #662)
Remaining Parent Gaps
- GraphQL comment mutation の完全 parser は本 parent の必須条件ではない。完全 parser が出るまで conservative deny を invariant として固定する(必要なら follow-up)。
- prose / code / machine-readable block の境界ルールを文書化し、複数 skill から再利用できる SSOT へ寄せる(child-0 で着手)。
- bilingual heading を template validator / checker / hook の全レイヤーで同一ルールに揃える(child-1 で着手)。
Runtime Verification Applicability
本セクションは動作検証の適用方針を定義する。
- decision: deferred
- 理由: 本 parent は write-capable scope を持たない delivery-rollup tracker であり、実 runtime 検証(hook 単体判定 /
gh経路ごとの mutation route 検証 / Claude Code 黒箱 replay / shadow 計測)は各 child issue 側で immediate として実施する。 - deferred_destination: 各 child issue(実装(#646): prose / code / machine-readable / heading / tmp draft / public output 分類の prose boundary policy SSOT 化 #653〜実装: split_markdown_blocks の GFM 準拠セグメンテーションを prose_boundary_policy SSOT へ委譲 #659, 実装: guard-japanese-prose の persistent shadow logging を廃止し default non-blocking semantics を保持する #2265 等)の Runtime Verification Applicability セクション
- deferred_verification_condition: child issue が materialize され、AC に対応する Verification Commands が実 subprocess 実行で検証されること
- child 側 runtime 検証要件: child-0〜child-4 は、CI のユニットテストに加えて、deterministic replay/test artifact(shadow-mode 実行ログを含む)を PR に添付することを必須とする(
docs/dev/runtime-verification-policy.mdの SKIP 規約・証跡保存・Stop Condition 連動に従う)。
Phase Handoff Contract
Desired DestinationCurrent Validated ScopeRemaining Parent GapsCurrent ObjectiveBounded Current ContextNormative ReferencesAllowed PathsRequired SkillsValidation CommandsStop ConditionsOpen QuestionsNext ActionArtifact RefsHandoff Prompt DraftLinked PR
Acceptance Criteria
- AC1: prose / code / machine-readable / template heading / bilingual heading / tmp draft / public output の分類 golden corpus が存在し、pass/block 理由が snapshot 化され、guard / validator / checker / loop dry-run が同一 SSOT から検証される child 実装がマージされている
- AC2: bilingual heading(例:
## 成果物 (Outcome))がheading_policyの正規形として checker と guard の両方で認識され、Machine-Readable Contract / VC command / code fence は prose ratio 判定から除外され、純粋な英語説明 prose は引き続き guard で検出される child 実装がマージされている - AC3:
tmp/*.mdおよび/tmp/*issue*body*.mdなどの下書き生成は guard にブロックされず、gh issue/prbody 系・gh apiREST comment/body mutation(--input/-f body=/-F body=/-F body=@file)・gh api graphqlの body/comment mutation が guard 対象になり、stdin / unreadable file / invalid JSON / 空 body は fail-closed になる child 実装がマージされている - AC4:
gh api graphqlの body / comment mutation(addComment/updateIssueComment/ PR review comment 系)は、専用 parser 実装まで conservative deny され、GraphQL を理由に public output guard を bypass できないことが regression test で固定されている child 実装がマージされている - AC5:
issue-refinement-loopのhuman_escalation/needs-fix/max_iterations終了レポートが guard 互換テンプレートから生成され、投稿前 dry-run guard・上限付き再生成・上限超過時の非投稿 + reason_code 出力が実装され、再生成上限と reason_code がテストされている child 実装がマージされている - AC6:
GUARD_JAPANESE_PROSE_MODE=shadow|enforce相当の mode が存在し、unset/off(default)は allow・persistent telemetry を書かず、enforceのみ block する。enforce 切替は環境変数または設定で rollback 可能(初期値は default non-blocking)で、would-block 件数・理由・route・public_mutation・failed_block_count・duration は persistent production JSONL ではなく deterministic replay/test artifact に記録される child 実装がマージされている(2026-08-20 OWNER decision、実装: guard-japanese-prose の persistent shadow logging を廃止し default non-blocking semantics を保持する #2265 が所有) - AC7: Claude Code replay scenario R1〜R7(create-issue の正規テンプレ見出し + Machine-Readable Contract + 日本語 prose 投稿、edit-issue の非 prose 差分通過、新規英語 prose の block と日本語修正での再実行、終了レポート dry-run と失敗時再生成、tmp 下書き非 block と公開 mutation guard、REST comment PATCH 検査、GraphQL comment mutation の conservative deny または記録)の transcript または structured log が deterministic replay/test artifact として child PR に証跡添付されている(persistent production
.guard_shadow_log.jsonlを証跡の正本にしない) - AC8: borderline 判定が
ask(人間確認)を使わず、Claude Code が修復できる deterministic repair signal(exit 2 + repair reasonまたはexit 0 + permissionDecision: deny)として返ることがテストで固定されている child 実装がマージされている
Verification Commands
# AC1
# parent tracker: 検証は child issue の Verification Commands へ委譲する
$ echo "parent tracker: verification delegated to child issues"# AC2
$ echo "parent tracker: verification delegated to child issues"# AC3
$ echo "parent tracker: verification delegated to child issues"# AC4
$ echo "parent tracker: verification delegated to child issues"# AC5
$ echo "parent tracker: verification delegated to child issues"# AC6
$ echo "parent tracker: verification delegated to child issue #2265"# AC7
$ echo "parent tracker: verification delegated to child issue #2265"# AC8
$ echo "parent tracker: verification delegated to child issues"Allowed Paths
N/A — parent tracker のため、write-capable scope は child issue 側で確定する
Notes
#606と同じ.claude/hooks/guard-japanese-prose.shを触る child を並行で open すると Allowed Paths が衝突するため、child-0〜child-4 は materialization 時点で#606の merge 状況を確認して順序制御する。- prose boundary policy SSOT(child-0)は他 child の前提となるため、materialization 順序は child-0 を先頭にする。
- 本 parent 自体は write-capable scope を持たない。各 child の Allowed Paths は materialization 時に narrow する。
- reviewer 指摘の Blocker 1〜6 と追加設計要件(shadow mode / route matrix SSOT / replay / enforce rollout / ask 禁止)を child-0〜child-4 と AC1〜AC8 に割り付け済み。child materialize は本 parent の親契約確定後に行う。
Activity
squne121 commentedon Jun 4, 2026
Claude作業ログ
squne121 commentedon Jun 4, 2026
人間からのコメントです。
今回の件の教訓として、実装した際にしっかり検証を行って、動作確認を行わなかったことが問題かなと感じています。
ClaudeCodeに実際に使わせてみて、厳しすぎないかなど、効果を確認した上で本番運用に変えるべきでした。あるいは動作はするけど、AIの作業に影響を与えないような形で、どれぐらい発火するかなどを確認するべきだったと思います。
squne121 commentedon Jun 4, 2026
#646 (comment)
判定: REQUEST_CHANGES
#646 の方向性は正しいです。ただし、現状のまま実装Issueへ分解すると、前回と同じ失敗を再発します。問題は「guard の条件が間違っていた」だけではなく、「Claude Code に実際の authoring workflow で使わせる前に、本番阻止系 hook として投入した」ことです。#646 は、
guard-japanese-prose.shが英語 prose 混入防止には有効だが、テンプレ見出し、Machine-Readable Contract、tmp/下書き、終了レポートまで同じ比率ルールで扱うため衝突すると整理しています。ここまでは妥当です。(GitHub)しかし #646 の Acceptance Criteria は「child 実装がマージされている」ことに寄りすぎています。Verification Commands も parent では
echo "parent tracker: verification is delegated to child issues"だけです。これでは「CIは通ったが、Claude Code の実運用では厳しすぎた/回避路があった/agent が修復できなかった」を検出できません。(GitHub)人間コメントへの評価
提示コメントの「実装時にしっかり検証・動作確認をしなかったことが問題」という認識は正しいです。ただし、このままだとまだ抽象度が高いです。今回必要なのは単なる
pytestではなく、次の4種類の検証です。hook 単体の判定検証
gh経路ごとの mutation route 検証Claude Code に実際の issue-refinement-loop / create-issue / edit-issue を走らせる黒箱検証
本番ブロック前の shadow / dry-run 計測
#594 でも Runtime Verification は明示的に deferred されており、Claude Code PreToolUse hook の stdin JSON と
ghbody mutation の E2E smoke test が必要だと書かれています。つまり今回の教訓は新発見ではなく、既存Issue内で要求されていた runtime verification を実質的に弱く扱ったことです。(GitHub)敵対的レビュー: #646 の主要欠陥
1. 「child が merge されたら完了」は危険
#646 は delivery-rollup parent として、
#606と child-1〜child-3 が完了すれば close できる構造です。しかし今回の failure mode は「実装が存在するか」ではなく「agent workflow に悪影響なく機能するか」です。したがって完了条件に、Claude Code 実行ログ、guard 発火件数、false positive、修復成功率、再生成ループ有無を入れないと不十分です。(GitHub)2. GraphQL / REST / gh wrapper の route matrix がまだ弱い
#606 は REST の issue comment / PR review comment PATCH を対象にしますが、GraphQL comment mutation は out of scope です。#646 も GraphQL comment mutation の完全解析を必須条件にしていません。これは「本番guard」としては穴です。少なくとも
gh api graphql --inputが mutation かつ body を含む可能性がある場合は、shadow 記録または fail-closed の対象にすべきです。(GitHub)gh apiは REST v3 path だけでなくgraphqlendpoint も公式に扱い、--inputではリクエスト本文をファイルから読み、field flags は query string に追加されます。method の default も条件で変わります。つまり endpoint 文字列と top-levelbodyだけを見る分類では漏れます。(GitHub CLI)3. 過去PRの履歴が「テストだけでは信用できない」ことを証明している
PR #600 は一度 approve 方向に進んだ後、GraphQL bypass、payload 抽出の fail-open、HTTP method 未判定、comment / review route 未整理などが後段レビューで blocker 化しました。その後、GraphQL body mutation deny、環境変数経由の fail-closed、method 判定、scope-out 明記で修正されています。(GitHub)
PR #644 でも、borderline repair signal 追加時に、aggregate 判定を primary gate にしてしまい、英語 prose block が長い日本語 block に埋もれて通る regression が指摘されています。最終的には per-block gate を primary に戻し、混合ブロック bypass regression test を追加して解消しています。(GitHub)
この履歴から見ると、#646 の child も「テストが増えた」「CIが通った」だけでは不十分です。実際の Claude Code hook 入力、実際の
ghcommand pattern、実際の agent retry 挙動を検証条件に入れる必要があります。4.
askは方針と衝突するので使わない設計に寄せるべきClaude Code の PreToolUse hook は
permissionDecisionとしてallow / deny / ask / deferを返せます。askはユーザー確認を促す挙動です。また exit 2 は blocking error として stderr が Claude に返り、JSON は処理されません。(Claude Code)今回の人間コメントの方針は「ユーザーに確認させず、Claude Code が修正する指標として使う」です。したがって #646 系の設計では、borderline を
askに戻すのではなく、exit 2 + repair reasonかexit 0 + permissionDecision: denyに統一し、Claude が次に取る修復行動を stderr / reason に明示するべきです。askは原則禁止にした方がよいです。#646 に追加すべき設計要件
1. shadow / dry-run mode
本番ブロック前に、次の環境変数を入れて運用できるようにしてください。
shadow mode では最低限、次を JSONL に出すべきです。
これにより、「どれぐらい発火するか」「厳しすぎるか」「agent の作業に影響するか」を、本番阻止前に測れます。
2. mutation route matrix を SSOT 化
route | public side effect | validation | action -- | -- | -- | -- gh issue create --body* | yes | full-body prose | enforce gh issue edit --body-file | yes | delta prose | enforce gh issue comment --body* | yes | full-body prose | enforce gh pr create --body* | yes | full-body prose | enforce gh pr edit --body-file | yes | delta prose | enforce gh pr review --body* | yes | full-body prose | enforce gh api repos/.../issues/{n} --method PATCH --input | yes | delta prose | enforce gh api repos/.../issues/comments/{id} --method PATCH --input | yes | delta prose | enforce gh api graphql --input mutation body | yes | conservative deny or parsed delta | shadow → enforce tmp/*.md, /tmp/*issue*body*.md | no | no block / shadow only | pass Machine-Readable Contract / code fence / VC command | no prose | excluded | pass.claude/hooks/guard-japanese-prose.shに分岐を増やすだけでは再発します。次のような matrix を Python 側に持たせ、hook は分類結果を使う構造に寄せるべきです。3. Claude Code replay test を AC に入れる
#646 の child 完了条件には、少なくとも次の replay が必要です。
4. 完了条件を「merge」から「運用証跡」に変更
#646 の AC は次のように書き換えるべきです。
#646 への貼り付けコメント案
結論として、#646 は「境界整理 parent」としては有効ですが、現状では品質ゲートが足りません。今回の教訓を反映するなら、最優先で入れるべきは追加の正規表現ではなく、shadow mode、route matrix SSOT、Claude Code replay、enforce rollout 条件です。
## 判定: REQUEST_CHANGES#646 の方向性は正しいです。ただし、現状のまま実装Issueへ分解すると、前回と同じ失敗を再発します。問題は「guard の条件が間違っていた」だけではなく、「Claude Code に実際の authoring workflow で使わせる前に、本番阻止系 hook として投入した」ことです。#646 は、
guard-japanese-prose.shが英語 prose 混入防止には有効だが、テンプレ見出し、Machine-Readable Contract、tmp/下書き、終了レポートまで同じ比率ルールで扱うため衝突すると整理しています。ここまでは妥当です。([GitHub]1)しかし #646 の Acceptance Criteria は「child 実装がマージされている」ことに寄りすぎています。Verification Commands も parent では
echo "parent tracker: verification is delegated to child issues"だけです。これでは「CIは通ったが、Claude Code の実運用では厳しすぎた/回避路があった/agent が修復できなかった」を検出できません。([GitHub]1)人間コメントへの評価
提示コメントの「実装時にしっかり検証・動作確認をしなかったことが問題」という認識は正しいです。ただし、このままだとまだ抽象度が高いです。今回必要なのは単なる
pytestではなく、次の4種類の検証です。gh経路ごとの mutation route 検証#594 でも Runtime Verification は明示的に deferred されており、Claude Code PreToolUse hook の stdin JSON と
ghbody mutation の E2E smoke test が必要だと書かれています。つまり今回の教訓は新発見ではなく、既存Issue内で要求されていた runtime verification を実質的に弱く扱ったことです。([GitHub]2)敵対的レビュー: #646 の主要欠陥
1. 「child が merge されたら完了」は危険
#646 は delivery-rollup parent として、
#606と child-1〜child-3 が完了すれば close できる構造です。しかし今回の failure mode は「実装が存在するか」ではなく「agent workflow に悪影響なく機能するか」です。したがって完了条件に、Claude Code 実行ログ、guard 発火件数、false positive、修復成功率、再生成ループ有無を入れないと不十分です。([GitHub]1)2. GraphQL / REST / gh wrapper の route matrix がまだ弱い
#606 は REST の issue comment / PR review comment PATCH を対象にしますが、GraphQL comment mutation は out of scope です。#646 も GraphQL comment mutation の完全解析を必須条件にしていません。これは「本番guard」としては穴です。少なくとも
gh api graphql --inputが mutation かつ body を含む可能性がある場合は、shadow 記録または fail-closed の対象にすべきです。([GitHub]3)gh apiは REST v3 path だけでなくgraphqlendpoint も公式に扱い、--inputではリクエスト本文をファイルから読み、field flags は query string に追加されます。method の default も条件で変わります。つまり endpoint 文字列と top-levelbodyだけを見る分類では漏れます。([GitHub CLI]4)3. 過去PRの履歴が「テストだけでは信用できない」ことを証明している
PR #600 は一度 approve 方向に進んだ後、GraphQL bypass、payload 抽出の fail-open、HTTP method 未判定、comment / review route 未整理などが後段レビューで blocker 化しました。その後、GraphQL body mutation deny、環境変数経由の fail-closed、method 判定、scope-out 明記で修正されています。([GitHub]5)
PR #644 でも、borderline repair signal 追加時に、aggregate 判定を primary gate にしてしまい、英語 prose block が長い日本語 block に埋もれて通る regression が指摘されています。最終的には per-block gate を primary に戻し、混合ブロック bypass regression test を追加して解消しています。([GitHub]6)
この履歴から見ると、#646 の child も「テストが増えた」「CIが通った」だけでは不十分です。実際の Claude Code hook 入力、実際の
ghcommand pattern、実際の agent retry 挙動を検証条件に入れる必要があります。4.
askは方針と衝突するので使わない設計に寄せるべきClaude Code の PreToolUse hook は
permissionDecisionとしてallow / deny / ask / deferを返せます。askはユーザー確認を促す挙動です。また exit 2 は blocking error として stderr が Claude に返り、JSON は処理されません。([Claude Code]7)今回の人間コメントの方針は「ユーザーに確認させず、Claude Code が修正する指標として使う」です。したがって #646 系の設計では、borderline を
askに戻すのではなく、exit 2 + repair reasonかexit 0 + permissionDecision: denyに統一し、Claude が次に取る修復行動を stderr / reason に明示するべきです。askは原則禁止にした方がよいです。#646 に追加すべき設計要件
1. shadow / dry-run mode
本番ブロック前に、次の環境変数を入れて運用できるようにしてください。
shadow mode では最低限、次を JSONL に出すべきです。
{ "event": "guard_japanese_prose", "mode": "shadow", "tool": "Bash", "route": "gh_issue_comment", "public_mutation": true, "decision_would_be": "deny", "reason": "english_prose_block_detected", "path_classification": "public_github_mutation", "failed_block_count": 1, "duration_ms": 42 }これにより、「どれぐらい発火するか」「厳しすぎるか」「agent の作業に影響するか」を、本番阻止前に測れます。
2. mutation route matrix を SSOT 化
.claude/hooks/guard-japanese-prose.shに分岐を増やすだけでは再発します。次のような matrix を Python 側に持たせ、hook は分類結果を使う構造に寄せるべきです。gh issue create --body*gh issue edit --body-filegh issue comment --body*gh pr create --body*gh pr edit --body-filegh pr review --body*gh api repos/.../issues/{n} --method PATCH --inputgh api repos/.../issues/comments/{id} --method PATCH --inputgh api graphql --inputmutation bodytmp/*.md,/tmp/*issue*body*.md3. Claude Code replay test を AC に入れる
#646 の child 完了条件には、少なくとも次の replay が必要です。
4. 完了条件を「merge」から「運用証跡」に変更
#646 の AC は次のように書き換えるべきです。
#646 への貼り付けコメント案
結論として、#646 は「境界整理 parent」としては有効ですが、現状では品質ゲートが足りません。今回の教訓を反映するなら、最優先で入れるべきは追加の正規表現ではなく、shadow mode、route matrix SSOT、Claude Code replay、enforce rollout 条件です。
squne121 commentedon Jun 4, 2026
判定: REQUEST CHANGES
#646 の問題設定は妥当です。
guard-japanese-proseがテンプレート見出し、Machine-Readable Contract、tmp draft、終了レポートを同じ日本語比率ルールで扱ってしまうため、issue-refinement-loop / create-issue / edit-issue の実運用と衝突している、という整理は正しいです。#646 自体も「英語の正規見出し・Machine-Readable Contract・VC commands は prose guard から除外」「tmp draft と public output を分離」「終了レポートは dry-run guard 後に投稿」と明記しています。([GitHub]1)ただし、現状の #646 は 親Issueとしての境界契約が弱く、このまま child Issue を切ると再び guard/checker/loop の実装差分が出る 可能性が高いです。特に
gh apiの入力経路、tmp draft の扱い、GraphQL の保守的拒否、bilingual heading の正規化、終了レポート失敗時の挙動が曖昧です。関連Issue/PRから見える前提
#606 は
gh api --inputによる REST comment body mutation を guard 対象に追加する実装Issueで、REST の issue comment / PR review comment endpoint を delta check に載せるのが目的です。一方で GraphQL comment mutation は明示的に scope out されています。([GitHub]2)#594 / PR #600 では、
gh api --inputによる issue / PR body mutation の guard 化、stdin fail-closed、invalid JSON fail-closed、GraphQL mutation の conservative deny などが扱われています。PR #600 では Safety Claim Matrix とテスト結果も示されており、この系列は「実装した」だけではなく、guard bypass がないことをレビュー可能な形で示す必要がある類の変更です。([GitHub]3)#605 / PR #644 では、borderline case は人間へ
askするのではなく、Claude が自己修正するための repair signal として扱う方針に変わっています。PR #644 の実装もpermissionDecision: askではなく、exit2 + reason による修正要求へ寄せています。([GitHub]4)Blocker 1: SSOT なしに boundary を複数実装すると再発する
現行の
validate_japanese_content.pyには、通常検証、delta block 検出、borderline 判定、Markdown block 分類が別々に存在しています。validate_textは code fence を抜いた後に単純な prose block として見る一方、changed_prose_blocksは Markdown block 分類を使っています。つまり、full-body create/comment と delta edit で「何を prose とみなすか」がズレる余地があります。([GitHub]5)#646 では「prose/code/machine-readable boundary の doc と SSOT」が Remaining gap に置かれていますが、これは gap ではなく 先行実装すべき親契約 です。
修正案:
最低限、以下を共有ポリシー化してください。
guard-japanese-prose.sh、validate_japanese_content.py、check_issue_contract.py、guard-issue-body.py、issue-refinement-loop の dry-run が同じ分類結果を使うべきです。「同じような正規表現を各所に書く」は不可です。
Blocker 2: tmp draft の扱いが現行実装と逆方向
#646 は tmp draft を安全に許可し、public mutation を guard 対象にする方針です。ところが現行 hook は Write/Edit/MultiEdit の
tmp/*.md、/tmp/*.md、*_draft.mdなどを draft candidate として検出し、そこでvalidate_bodyを実行します。([GitHub]6)これは #646 の意図と衝突します。tmp draft は「公開物」ではなく中間生成物です。guard すべきなのは、
gh issue create --body-file、gh issue edit --body-file、gh issue comment --body-file、gh api --inputなどで実際に GitHub へ送る瞬間です。GitHub CLI は issue create/edit/comment で--body/--body-fileを正式に持っており、--body-file -による stdin もあります。([GitHub CLI]7)修正案:
これにより、草稿生成の false positive を消しつつ、公開経路の guard は維持できます。
Blocker 3:
gh api --inputだけでは comment mutation guard として不足#606 は
gh api --inputの REST comment mutation を主対象にしていますが、GitHub CLI のgh apiは--input以外にも-f/--raw-field、-F/--fieldを持ちます。公式ドキュメント上も、issue comment 作成例は-f body='...'です。また、field 指定は request method を POST に切り替える挙動があり、--inputと併用した場合は field が query string に回るため、method / payload 判定が単純ではありません。([GitHub CLI]8)したがって、#606 / #646 の guard は最低限これを検出対象に入れるべきです。
--inputだけを guard すると、-f body=で簡単に迂回できます。これは仕様上の抜け道であり、実装漏れでは済みません。Blocker 4: GraphQL scope-out は「保守的拒否」を親契約に固定すべき
#606 は GraphQL comment mutation を scope out しています。しかし
gh api graphqlは GitHub CLI の正式経路であり、GraphQL mutation はサーバー状態を変更します。(GitHub CLI)完全対応を #606 に入れない判断は許容できます。ただし #646 側で、次を invariant として固定すべきです。
特に
addComment、updateIssueComment、PR review comment 系 mutation は regression test に入れるべきです。Blocker 5: bilingual heading の正規形が未定義
#646 は
## 成果物 (Outcome)のような bilingual heading を checker と guard の両方で認識すると書いています。([GitHub]1)しかし、以下の揺れをどう扱うかが未定義です。
ここを曖昧にすると、
check_issue_contract.pyは通るがguard-japanese-proseが落とす、またはその逆が起きます。修正案:
英語のみ見出しを許すのか、bilingual を必須にするのかも明示してください。ユーザー向け可読性を重視するなら、公開Issue本文は bilingual heading を標準にするのが妥当です。
Blocker 6: 終了レポート dry-run の失敗処理が弱い
Claude Code hooks は exit 2 の stderr を blocking reason として扱い、JSON output は exit 0 のときに意味を持ちます。
PreToolUseのpermissionDecisionもallow/deny/askの優先順位を持ちますが、#605 系の方針では人間への ask ではなく repair signal に寄せています。([Claude Code]9)#646 の「dry-run guard before posting termination reports and regenerate on guard failure」は方向性として正しいですが、失敗時の上限がありません。
修正案:
無制限 regeneration や、人間確認への escape hatch は避けるべきです。
追加すべき acceptance criteria
#646 の AC は現在のままだと「child Issue が merged した」ことを確認するだけで、guard 境界の安全性を十分に証明できません。以下を追加してください。
必須テストケース
最低限この golden corpus を入れるべきです。
まとめ
#646 は親Issueとして必要ですが、現状のままだと 「guard を強化するIssue」ではなく「guard と authoring workflow の例外を各所に散らすIssue」になりやすい です。
最優先の修正は次の4点です。
gh apiは--inputだけでなく-f/-F bodyも対象にする。この4点を #646 の親契約に入れてから child Issue を materialize するのが妥当です。
squne121 commentedon Jun 4, 2026
issue-refinement-loop 終了レポート(approved)
対象 anchor comment 2 件(いずれも REQUEST_CHANGES レビュー)を反映し、本 parent の親契約を強化しました。deterministic contract checker は全項目 pass(verdict: approve)です。
反映した reviewer 指摘
Decisions Fixedと child-0 / AC1 に固定。gh apiの comment / body mutation は--inputだけでなく-f body=/-F body=/-F body=@fileを検出対象に含める方針を child-2 / AC3 に固定。gh api graphqlの body / comment mutation は専用 parser 実装まで conservative deny を invariant とする方針を child-2 / AC4 に固定。heading_policy)を checker と guard で共有する方針を child-1 / AC2 に固定。GUARD_JAPANESE_PROSE_MODE=shadow|enforceの shadow rollout(AC6)、mutation route matrix SSOT(Outcome)、Claude Code replay scenario R1〜R7(AC7)、ask禁止と deterministic repair signal(AC8)、parent close 条件を「child merge」から「shadow/replay 運用証跡」へ変更(Parent Closure Rule)。決定論的 contract checker の結果
C3〜C13 すべて pass(C8 Outcome concreteness と C9 Runtime Verification Applicability を含む)。blocking なし。
今回の loop 自体が再現した不具合
本 loop の本文更新中に、checker が要求する英語正規見出し
## Outcome/## Runtime Verification Applicabilityを、prose guard が日本語比率不足の prose block として block する deadlock を実際に踏みました。これは本 parent の Blocker 1 / Blocker 5(正規見出し除外・heading_policy)が解決すべき現象そのものであり、child 実装の必要性を裏付ける運用証跡です。child materialization の判断
child-0〜child-4 は
.claude/hooks/guard-japanese-prose.sh/validate_japanese_content.pyを触るため、同一ファイルを Allowed Paths に含む OPEN な #606(PR 未作成)と衝突します。本 parent の Notes と reviewer 指針に従い、本 iteration では child を materialize せず、#606 の merge 後に child-0(prose boundary policy SSOT)を先頭として順序制御で materialize します。以下に機械可読な handoff marker を出力する。
feat(#646): prose block 分類 SSOT (prose_boundary_policy.py) を新設し valid…
squne121 commentedon Aug 21, 2026
全12子Issue(#653, #654, #655, #656, #657, #659, #671, #678, #682, #685, #692, #2265)がクローズ済みのため、delivery-rollup(closure_mode: child-complete)としてクローズします。post-merge-cleanup(PR #2267マージ後)にて確認。