Skip to content

実装: guard-japanese-prose の borderline case に Claude Code 自己修正シグナル(repair signal)を追加 #605

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "guard-japanese-prose.sh の borderline case で Claude Code 自己修正シグナルを実装し、ユーザー確認を発生させずに Claude Code が日本語 prose へ修正・再試行できる状態にする"
change_kind: workflow

Parent Issue

none(単独改善)

Parent Goal Ref

  • Goal: guard-japanese-prose hook が borderline prose を二値判定(allow/deny)ではなく Claude Code 自己修正シグナルで扱えるようにする
  • Desired Destination: guard-japanese-prose.sh が borderline human-facing prose を検出した場合、ユーザー確認を要求せず、Claude Code が自己修正できる machine-readable repair signal を返す。Claude Code は既に示された日本語優先方針に従い、本文 prose を日本語へ修正して再試行する。code fence / inline code / identifier / CLI/API 名 / schema enum / URL は英語許容対象とする。

Current Validated Scope

  • .claude/skills/create-issue/scripts/validate_japanese_content.py に machine-readable decision output を追加(allow/ask/deny の構造化判定メタデータ)。既存アルゴリズム・閾値は変更しない。
  • .claude/hooks/guard-japanese-prose.sh に Claude Code 自己修正シグナル経路を追加
  • .claude/hooks/tests/ に borderline repair smoke test を追加

Remaining Parent Gaps

なし(本 Issue は #594 AC9 の follow-up として独立して完結する)

Background

PR #600(#594 実装)では guard-japanese-prose.sh が gh api --input による body mutation を検査対象に追加した。しかし #594 の AC9 「borderline case に structured フローを実装する」は PR #600 の scope 外として除外された。

現在の hook は exit 0(allow)または exit 2(deny/fail-closed)の二値判定のみを実装している。

当初は permissionDecision: "ask" でユーザー確認を実装する方向だったが、人間方針により方針を反転した。「人間への出力は日本語の方が好ましい」という既存方針がある場合、Claude Code はユーザーに確認せず自己修正する。borderline case は「ユーザーが判断する」ではなく「Claude Code が日本語 prose へ修正して再試行する」ための指標として扱う。

本 Issue では Claude Code 自己修正シグナル(repair signal)を実装する。permissionDecision: "ask" は使わない。

Outcome

guard-japanese-prose.sh が更新され、borderline human-facing prose(日本語比率がしきい値近傍・混在 prose 等)で Claude Code 自己修正シグナルを返す状態。具体的には exit 0 + JSON {"hookSpecificOutput": {"permissionDecision": "deny", "permissionDecisionReason": "borderline_japanese_prose_repair_required: ..."}} を返すか、または従来通り exit 2 + stderr reason code を返す(実装者が最小差分で選択する)。対応する smoke test が .claude/hooks/tests/ に追加され PASS する状態。

In Scope

  • .claude/skills/create-issue/scripts/validate_japanese_content.py に machine-readable decision output を追加(hook が ask/deny/allow を安全に判断できるよう判定メタデータの JSON 出力を追加する。既存アルゴリズム・閾値は変更しない)
  • .claude/hooks/guard-japanese-prose.sh に Claude Code 自己修正シグナル経路を追加
  • borderline human-facing prose の判定ロジック(比率範囲 / 不確実性フラグ等)
  • Claude Code hook structured output の JSON schema 準拠(hookSpecificOutput.permissionDecision: "deny" + permissionDecisionReason: borderline_japanese_prose_repair_required など)、またはシンプルに exit 2 + stderr reason code
  • 対応する smoke test の追加(.claude/hooks/tests/test_guard_borderline_repair.py など)

Out of Scope

  • deny / fail-closed 経路の変更(現行維持)
  • allow 閾値の変更
  • permissionDecision: "ask" の実装(採用禁止)
  • ユーザー確認フローの実装(採用禁止)
  • GraphQL mutation 専用の決定ロジック追加(別 Issue で対応)
  • validate_japanese_content.py の既存アルゴリズム・閾値変更

Acceptance Criteria

  • AC1: borderline human-facing prose はユーザー確認ではなく Claude Code 自己修正シグナルになる(ask JSON ではなく deny または exit 2 + repair reason code)
  • AC2: permissionDecision: "ask" が guard-japanese-prose.sh に存在しない
  • AC3: reason には borderline_japanese_prose_repair_required 等の安定した reason code を含める
  • AC4: reason は「ユーザーに確認せず、日本語 prose に修正して再試行する」ことを Claude Code に指示する
  • AC5: code fence / inline code / command / identifier / file path / URL / schema enum / API field name は英語許容対象としてテストされる
  • AC6: 明確な英語 prose は従来どおり block / repair-required になる
  • AC7: smoke test は「ask が返らないこと」と「Claude Code 向け修正指示が返ること」を検証する

Verification Commands

# AC1
$ rg -n "borderline_japanese_prose_repair_required|permissionDecisionReason" .claude/hooks/guard-japanese-prose.sh
# AC2
$ ! rg -qn "permissionDecision.*ask" .claude/hooks/guard-japanese-prose.sh
# AC3
$ rg -n "borderline_japanese_prose_repair_required" .claude/hooks/guard-japanese-prose.sh
# AC4
$ test -f .claude/hooks/tests/test_guard_borderline_repair.py
# AC5
$ uv run pytest .claude/hooks/tests/test_guard_borderline_repair.py -v -k "english_allowlist or code_fence or identifier"
# AC6
$ uv run pytest .claude/hooks/tests/test_guard_borderline_repair.py -v -k "english_prose"
# AC7
$ uv run pytest .claude/hooks/tests/test_guard_borderline_repair.py -v

Allowed Paths

  • .claude/skills/create-issue/scripts/validate_japanese_content.py
  • .claude/hooks/guard-japanese-prose.sh
  • .claude/hooks/tests/test_guard_borderline_repair.py(または同ディレクトリの新テストファイル)

Stop Conditions

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

Required Skills

  • bash(シェルスクリプト)
  • Claude Code PreToolUse hook 構造化 JSON 出力
  • pytest(テストフレームワーク)
  • Python(validate_japanese_content.py 修正)

Scope Delta(任意)

N/A

Runtime Verification Applicability

decision: deferred
reason: "Claude Code PreToolUse hook の end-to-end 動作検証は実 Claude Code 実行環境が必要。fixture / mock で代替する smoke test で境界を確認する。"
deferred_destination:
  destination_type: issue
  destination_ref: "本 Issue の PR に smoke test pass 結果を添付"
deferred_verification_condition: "borderline prose fixture を hook に入力したとき Claude Code 自己修正シグナルが返り(ask は返らない)、明確な deny 対象では exit 2 が返ること"

Delivery Rule

Source(dedupe_key)

follow-up:squne121/loop-protocol:pr/600:B5-ac9-graphql-ask

関連

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    on Jun 2, 2026
  2. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    Issue #605 の方向性は妥当です。#594 の AC9 で求められていた permissionDecision: "ask" が #600 では明示的にスコープ外化され、follow-up として #605 が立っている流れは整合しています。Issue #605 自体も、borderline な日本語 prose を exit 2 の一律拒否ではなく exit 0 + JSON ask にすることを目的にしています。([GitHub]1)

    ただし、現行の Issue 契約のまま実装すると、安全性を落とすか、テスト不能なヒューリスティックを shell 側に増やす可能性が高いです。現 main の guard-japanese-prose.sh には permissionDecision 実装が存在せず、現行 validator の delta check も基本的に DELTA_PASS / DELTA_FAIL と件数だけを返す設計で、borderline 判定に必要な比率・理由・対象ブロック種別を返していません。([GitHub]2)


    Blocker 1: 「borderline」の定義が曖昧で、AC が検証不能

    Issue #605 は “Japanese ratio near threshold, mixed prose, translation-like text” を borderline 例として挙げていますが、どの値なら ask、どの値なら deny、どの値なら allow なのかが未定義です。([GitHub]3)

    この状態で実装すると、実装者は以下のどちらかを選ぶことになります。

    1. shell script 側で雑に文字数・日本語比率を再計算する
    2. validator の失敗結果を grep して “なんとなく borderline” とみなす

    どちらも不可です。日本語 prose policy は #466 で「GitHub の Issue/PR/comment/Markdown deliverables を日本語 prose にする」ための guard であり、fail-closed と bypass 防止が中核です。([GitHub]4)

    修正案: Issue #605 の scope に validator の構造化出力追加を入れるべきです。
    「validator algorithm は変えない」は維持してよいですが、「validator の判定メタデータ出力を追加しない」は無理があります。

    最低限、validator から次を返せるようにするべきです。

    {
      "schema_version": "japanese_prose_guard.v1",
      "decision": "allow|ask|deny",
      "mode": "delta|full",
      "changed_prose_blocks": 2,
      "failed_blocks": 1,
      "borderline_blocks": 1,
      "min_japanese_ratio": 0.083,
      "threshold": 0.1,
      "reason_codes": ["ratio_near_threshold", "mixed_japanese_english_prose"]
    }

    Blocker 2: ask は exit 0 の stdout JSON 専用経路にしないと壊れる

    Claude Code hooks の公式仕様では、JSON decision は exit 0 の stdout JSON として処理され、exit 2 は block として扱われます。また、JSON 出力方式を使う場合は stdout が JSON 専用である必要があります。([Claude Code]5)

    したがって #605 の AC2「exit 2 と structured ask JSON を混ぜない」は正しいですが、不十分です。次まで AC に入れるべきです。

    • ask 時は exit 0
    • stdout は JSON のみ
    • stderr に debug/prose/body 断片を出さない
    • jq 等で JSON を生成し、手書き escape しない
    • permissionDecisionReason に本文全文を入れない
    • deny 時は従来通り exit 2、stdout JSON は出さない

    推奨形はこれです。

    {
      "hookSpecificOutput": {
        "hookEventName": "PreToolUse",
        "permissionDecision": "ask",
        "permissionDecisionReason": "日本語比率が閾値付近です。ratio=0.083 threshold=0.1 reason=ratio_near_threshold"
      }
    }

    Blocker 3: ask の導入で fail-closed 経路を絶対に緩めてはいけない

    Issue #605 は「deny/fail-closed は変更しない」と書いていますが、実装上は明示的な deny 優先順位を設けないと事故ります。現行 guard には GraphQL body mutation の保守的 deny、API input parse failure、body extraction failure などの fail-closed 経路があります。([GitHub]2)

    Claude Code 側でも複数 hook の precedence は deny > ask > allow 系の考え方なので、単一 hook 内でも同じ設計にするべきです。([Claude Code]5)

    AC に追加すべき禁止条件:

    • JSON parse failure は常に exit 2
    • target issue / PR body の取得失敗は常に exit 2
    • GraphQL mutation の未知・危険判定は常に exit 2
    • body mutation で対象本文が抽出できない場合は常に exit 2
    • pure English prose は ask ではなく従来通り exit 2

    ask は「日本語が一部あり、閾値付近で、人間判断に値する」ケースに限定するべきです。


    Blocker 4: #606 との責務境界が弱い

    #606 は gh api による Issue/PR comment body mutation を扱う follow-up で、REST comment edit を guard 対象に入れる計画です。#606 の desired state でも comment body mutation は “deny or ask” とされています。([GitHub]6)

    つまり #605 の ask 実装を Issue/PR body 専用の ad hoc 分岐として書くと、#606 で同じ decision logic を再実装することになります。これは guard の分岐爆発を招きます。

    修正案:


    Blocker 5: translation-like text は初期スコープから外すべき

    “translation-like text” は、人間には直感的でも、deterministic hook の AC としては危険です。形態素解析・言語モデル・textlint rule を入れない限り、安定した判定になりません。

    #466 の guard は日本語比率と prose block 判定を中心にしており、今回の #605 もその延長に置くべきです。([GitHub]4)

    初期実装では次の 2 類型に絞るのが安全です。

    • ratio_near_threshold
    • mixed_japanese_english_prose

    translation-like は別 Issue に分離し、textlint / proofreading / LLM reviewer の責務として扱う方がよいです。


    Blocker 6: テスト設計が smoke test だけでは不足

    #600 では test_guard_api_input.py が追加されたものの、CI 登録漏れが #602 として切り出されています。#605 でも「smoke test 追加」だけだと同じ事故が起きます。([GitHub]7)

    #605 の AC4 は次まで具体化してください。

    必須テスト:

    1. borderline delta prose → exit 0 + stdout JSON parse 成功 + permissionDecision=ask
    2. clear English prose → exit 2 + ask JSON なし
    3. clear Japanese prose → exit 0 + stdout 空、または allow JSON 方針なら schema 準拠
    4. malformed hook stdin → exit 2
    5. target body fetch failure → exit 2
    6. GraphQL unsafe mutation → exit 2
    7. permissionDecisionReason に本文全文が含まれない
    8. 追加 test file が CI で実行される

    Blocker 7: allowed paths が狭すぎる

    Issue #605 の対象パスは .claude/hooks/guard-japanese-prose.sh と .claude/hooks/tests/ に寄っています。([GitHub]3)

    しかし robust な borderline 判定には、少なくとも validator の構造化出力が必要です。#590/#592 で delta mode と changed prose block API が入った流れを考えると、この判定は hook shell ではなく validator 側に寄せるべきです。([GitHub]8)

    Issue 修正案:

    追加対象パス:

    .claude/skills/create-issue/scripts/validate_japanese_content.py
    .claude/hooks/guard-japanese-prose.sh
    .claude/hooks/tests/
    

    scope 文言:

    validator の既存アルゴリズム・閾値は変更しない。
    ただし hook が ask/deny/allow を安全に判断できるよう、判定メタデータの JSON 出力を追加する。
    

    高品質化した Issue #605 の推奨 AC

    現行 AC を次に差し替えるのがよいです。

    AC1: borderline な changed prose block は exit 0 で stdout に Claude Code PreToolUse structured JSON を出す。
         hookSpecificOutput.permissionDecision は "ask"。
         permissionDecisionReason は reason code と metrics のみを含み、本文全文を含めない。
    
    AC2: clear Japanese prose は従来通り allow される。
         allow 時に stdout JSON を出すかどうかは hook 方針として固定し、テストで検証する。
    
    AC3: clear Japanese deficiency / pure English prose は従来通り exit 2 で block される。
         exit 2 と ask JSON は混在しない。
    
    AC4: parse failure, target fetch failure, unknown GraphQL/body mutation classification は常に exit 2。
         ask に降格しない。
    
    AC5: validator は --delta-check-json などの machine-readable output を提供し、
         hook はその decision を Claude Code hook JSON に変換するだけにする。
    
    AC6: ask JSON は jq または Python json.dumps で生成し、stdout は JSON のみにする。
    
    AC7: test_guard_borderline_ask.py を追加し、CI で実行されることを確認する。
    
    AC8: #606 の comment body mutation path からも再利用できる decision helper として実装する。
         #606 自体の route 対応は本 Issue では実装しない。
    

    実装方針

    推奨はこの分割です。

    validate_japanese_content.py
      - prose block 抽出
      - 日本語比率計算
      - allow / ask / deny の構造化判定
      - JSON schema 出力
    
    guard-japanese-prose.sh
      - Claude Code hook stdin の parse
      - gh command / body mutation target の特定
      - validator JSON の受け取り
      - deny -> exit 2
      - ask -> exit 0 + hookSpecificOutput JSON
      - allow -> exit 0
    
    tests
      - validator decision unit tests
      - hook integration smoke tests
      - CI registration test
    

    gh api については、GitHub CLI 公式仕様上、gh api は REST endpoint だけでなく graphql endpoint も扱い、--input は request body をファイル/STDIN から読むため、body mutation guard の対象として扱う設計は妥当です。(GitHub CLI)


    最終コメント案

    #605 の目的は正しいが、現 Issue 契約のままでは実装不可または危険です。
    borderline の定義が曖昧で、現 validator は ask 判定に必要な ratio/reason/block metadata を返していません。hook shell 側で再判定する実装は guard の安全性を落とします。

    permissionDecision: "ask" は Claude Code hook 仕様上 exit 0 + stdout JSON 専用経路にし、exit 2 deny/fail-closed と混在させてはいけません。

    この Issue は .claude/hooks/guard-japanese-prose.sh だけで完結させず、validator の machine-readable decision output を追加する scope に修正してください。allow|ask|deny の判定は validator、Claude Code hook JSON 変換は shell、という責務分離にするべきです。

    また #606 の comment body mutation から同じ decision helper を再利用できるようにし、translation-like text は deterministic 判定不能なので初期スコープから外すべきです。

    この修正なしに実装すると、ask が fail-closed bypass になり得るため、REQUEST_CHANGES です。

    ローカル clone での test 実行はしていません。公開 GitHub 上の Issue/PR/comment/code と Claude Code / GitHub CLI 公式仕様を根拠にしたレビューです。

  3. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    人間からのコメントです。
    「Desired Destination: guard-japanese-prose.sh が borderline case で exit 0 + JSON permissionDecision: "ask" を返し、Claude Code がユーザーに確認できる状態」とあるが、ユーザーに確認して作業を止めたり、認知負荷をかけるのはやめて。人間への出力は日本語の方が好ましいと既に示している。しかし英単語やスクリプト中などの英語の存在は認めている。ユーザーではなくClaudeCodeが修正する指標としてのみ利用して。
    このIssue以外でも、そう。既に人間が示している方針に対して、どのように対応するか人間に確認するのはコンテクストの無駄。
    ADRやドキュメントなどの存在意義がない。

  4. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    #605 (comment)

    結論:#605 は 実装方針を反転すべきです。
    現行の「borderline case で permissionDecision: "ask" にしてユーザー確認させる」は、今回の人間方針と衝突しています。#605 本文は「ユーザーが確認できる中間経路」を Desired Destination にしていますが、Claude Code 仕様上 ask は実際にユーザー確認を出す挙動です。([GitHub]1) 公式 docs でも PreToolUse の permissionDecision: "ask" はユーザー確認を促し、deny はツール実行を止めて理由を Claude 側に返す用途だと説明されています。([Claude Code]2)

    判断

    #605 は 「ask フロー追加」ではなく、「Claude Code 自己修正フィードバック追加」へ修正するべきです。

    望ましい設計はこれです。

    borderline prose を検出
      → ユーザーへ確認しない
      → Claude Code にだけ repair_required reason を返す
      → Claude Code が本文 prose を日本語に修正して再試行する
      → 英単語・識別子・CLI/API 名・スクリプト・コードフェンス・schema enum・URL 等は許容する
    

    #594 でも code fence / machine-readable YAML / grep pattern / URL / identifier-only block は pass する要求があり、明確な英語 prose block は block する要求になっています。つまり、既に「英語の存在」ではなく「人間向け prose の英語化」を制御対象にする設計になっています。([GitHub]3)

    #605 へ貼るコメント案

    この Issue の Desired Destination は修正してください。
    
    現行文には「guard-japanese-prose.sh が borderline case で `exit 0` + JSON `permissionDecision: "ask"` を返し、Claude Code がユーザーに確認できる状態」とありますが、これは採用しないでください。
    
    人間への出力は日本語の方が好ましい、という方針は既に示しています。一方で、英単語、識別子、schema enum、CLI/API 名、スクリプト中の英語、コードフェンス、URL 等の英語は許容しています。したがって borderline case はユーザーに確認するための状態ではなく、Claude Code が自己修正するための指標として扱ってください。
    
    要求する挙動は次です。
    
    - `permissionDecision: "ask"` は使わない。
    - borderline case でユーザー確認を発生させない。
    - Claude Code に対して `borderline_japanese_prose_repair_required` のような reason code と修正指示を返す。
    - Claude Code はユーザーに確認せず、人間向け prose を日本語へ修正して再試行する。
    - 英単語そのものを禁止しない。禁止対象は「人間向け prose が英語中心のまま送信されること」。
    - code fence / inline code / schema enum / command / file path / identifier / URL / quoted API field name は日本語比率判定から除外または許容する。
    
    推奨する Desired Destination は次に差し替えてください。
    
    `guard-japanese-prose.sh が borderline human-facing prose を検出した場合、ユーザー確認を要求せず、Claude Code が自己修正できる machine-readable repair signal を返す。Claude Code は既に示された日本語優先方針に従い、本文 prose を日本語へ修正して再試行する。`
    
    実装方式はどちらかに統一してください。
    
    1. 既存方針を維持するなら `exit 2` + stderr reason code。
    2. structured output を使うなら `exit 0` + JSON `hookSpecificOutput.permissionDecision: "deny"` + `permissionDecisionReason`。
    
    ただし `permissionDecision: "ask"` は使わないでください。これはユーザー確認を発生させるため、今回の目的と逆です。
    
    Acceptance Criteria も差し替えてください。
    
    - AC1: borderline human-facing prose はユーザー確認ではなく Claude Code 自己修正シグナルになる。
    - AC2: `permissionDecision: "ask"` が `guard-japanese-prose.sh` に存在しない。
    - AC3: reason には `borderline_japanese_prose_repair_required` 等の安定した reason code を含める。
    - AC4: reason は「ユーザーに確認せず、日本語 prose に修正して再試行する」ことを Claude Code に指示する。
    - AC5: code fence / inline code / command / identifier / file path / URL / schema enum / API field name は英語許容対象としてテストされる。
    - AC6: 明確な英語 prose は従来どおり block / repair-required になる。
    - AC7: smoke test は「ask が返らないこと」と「Claude Code 向け修正指示が返ること」を検証する。
    
    この方針はこの Issue に限らず、既に人間が示した方針がある場合全般に適用してください。既存方針に対して毎回ユーザー確認を求めるのは、ADR・Issue・運用ドキュメントの存在意義を失わせ、コンテクストを浪費します。確認が必要なのは、既存方針同士が衝突している場合、不可逆な外部副作用がある場合、または方針が未定義の場合に限定してください。

    実装側の推奨

    最小差分なら exit 2 継続で十分です。現在の hook は既に exit 2 を policy block として使っているため、#605 のために ask を増やす必要はありません。#600 でも AC9 の structured ask は de-scope されています。([GitHub]4) ([GitHub]4)

    より整理するなら、次の structured deny に寄せるのがよいです。

    {
      "hookSpecificOutput": {
        "hookEventName": "PreToolUse",
        "permissionDecision": "deny",
        "permissionDecisionReason": "borderline_japanese_prose_repair_required: 人間向け prose は日本語優先。英単語・識別子・CLI/API 名・コードフェンス・schema enum・URL は許容。ユーザーへ確認せず、本文 prose を日本語に修正して再試行する。"
      }
    }

    ただし、この変更は既存の exit 2 方針と混在させない方がよいです。Claude Code docs も、exit 2 と stdout JSON は混ぜず、JSON は exit 0 のときだけ処理されると説明しています。([Claude Code]2)

  5. changed the title [-]実装: guard-japanese-prose の borderline case に structured permissionDecision ask フローを追加[/-] [+]実装: guard-japanese-prose の borderline case に Claude Code 自己修正シグナル(repair signal)を追加[/+] on Jun 3, 2026
  6. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop が完了しました。anchor comment に基づき実装方針を反転し、Issue 本文を更新しました。変更の概要は以下の通りです。

    • 実装方針を permissionDecision ask から Claude Code 自己修正シグナルに反転しました
    • タイトルを Claude Code 自己修正シグナル(repair signal)に変更しました
    • 受け入れ基準を ask 禁止・deny/repair reason code ベースに全面書き換えました
    • 検証コマンドのコメント形式を修正し、全 AC に対応する VC を追加しました
    LOOP_HANDOFF_RESULT_V1:
      schema_version: 1
      issue_number: 605
      verdict: approved
      termination_reason: approved
      iterations_completed: 2
      impl_ready: true
      next_skill: implement-issue
  7. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    契約スナップショット / Contract Snapshot (2026-06-03T16:26:07Z)

    この Issue は全チェックを通過しました。実装を開始できる状態です。

    • Outcome: guard-japanese-prose.sh が更新され、borderline human-facing prose で Claude Code 自己修正シグナルを返す状態(smoke test PASS)。
    • Acceptance Criteria:
      • AC1: borderline prose で Claude Code 自己修正シグナルが返る(ask JSON でなく deny/exit2 + repair reason code)
      • AC2: permissionDecision: "ask" が guard-japanese-prose.sh に存在しない
      • AC3: reason に borderline_japanese_prose_repair_required 等の安定した reason code を含める
      • AC4: reason は「日本語 prose に修正して再試行する」ことを Claude Code に指示する
      • AC5: code fence / inline code / command 等は英語許容対象としてテストされる
      • AC6: 明確な英語 prose は従来どおり block / repair-required になる
      • AC7: smoke test は「ask が返らないこと」と「Claude Code 向け修正指示が返ること」を検証する
    • Verification Commands:
      • AC1: rg -n "borderline_japanese_prose_repair_required|permissionDecisionReason" .claude/hooks/guard-japanese-prose.sh
      • AC2: ! rg -qn "permissionDecision.*ask" .claude/hooks/guard-japanese-prose.sh
      • AC3: rg -n "borderline_japanese_prose_repair_required" .claude/hooks/guard-japanese-prose.sh
      • AC4: test -f .claude/hooks/tests/test_guard_borderline_repair.py
      • AC5: uv run pytest .claude/hooks/tests/test_guard_borderline_repair.py -v -k "english_allowlist or code_fence or identifier"
      • AC6: uv run pytest .claude/hooks/tests/test_guard_borderline_repair.py -v -k "english_prose"
      • AC7: uv run pytest .claude/hooks/tests/test_guard_borderline_repair.py -v
    • Allowed Paths:
      • .claude/skills/create-issue/scripts/validate_japanese_content.py
      • .claude/hooks/guard-japanese-prose.sh
      • .claude/hooks/tests/test_guard_borderline_repair.py(または同ディレクトリの新テストファイル)
    • VC preflight: baseline fail = 7, 想定外 pass = 0, 実行不可 = 0

    実装用のブランチとworktreeは以下の通りです:

    Worktree: .claude/worktrees/issue-605-guard-japanese-prose-borderline-case-cla
    Branch: worktree-issue-605-guard-japanese-prose-borderline-case-cla
    
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-03T16:25:40Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/605
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 7
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 0
          vc_skipped: 0
          status: pass
          classifications:
            - ac: AC1
              command: "rg -n \"borderline_japanese_prose_repair_required|permissionDecisionReason\" .claude/hooks/guard-japanese-prose.sh"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC2
              command: "! rg -qn \"permissionDecision.*ask\" .claude/hooks/guard-japanese-prose.sh"
              exit_code: null
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC3
              command: "rg -n \"borderline_japanese_prose_repair_required\" .claude/hooks/guard-japanese-prose.sh"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC4
              command: "test -f .claude/hooks/tests/test_guard_borderline_repair.py"
              exit_code: 1
              category: file_not_found_expected
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC5
              command: "uv run pytest .claude/hooks/tests/test_guard_borderline_repair.py -v -k \"english_allowlist or code_fence or identifier\""
              exit_code: 4
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: "ERROR: file or directory not found"
                stderr_excerpt: ""
              decision: go
            - ac: AC6
              command: "uv run pytest .claude/hooks/tests/test_guard_borderline_repair.py -v -k \"english_prose\""
              exit_code: 4
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: "ERROR: file or directory not found"
                stderr_excerpt: ""
              decision: go
            - ac: AC7
              command: "uv run pytest .claude/hooks/tests/test_guard_borderline_repair.py -v"
              exit_code: 4
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: "ERROR: file or directory not found"
                stderr_excerpt: ""
              decision: go
        ac_verifiability: pass
        product_spec_check:
          applicability: not_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
          blocked_reasons: []
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []
      source:
        body_sha256: "sha256:cd49b6f49bd4cf1a0e87e219125b4347baa7c4d06adfa5a3a586aa41b4dcc8b2"
  8. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-06-03T16:37:18Z)

  9. added 2 commits that reference this issue on Jun 3, 2026
  10. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    後処理完了レポート / post-merge-cleanup (2026-06-03T22:04:55Z)

    クリーンアップが正常に完了しました。

    • status: ok
    • 次アクション: なし(parent issue なし・follow-up なし)
    • クリーンアップ済み: worktree と branch を削除しました
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: post-merge-cleanup
      follow_up_issues: []
      note_only_observations: []
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/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions