Skip to content

実装(#646): canonical / bilingual heading 除外と heading_policy を checker / guard で共有 #654

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#646"
goal_ref: "canonical / bilingual heading と Machine-Readable Contract / VC command / code fence を prose ratio 判定から除外し、bilingual heading 正規形 heading_policy を checker と guard が共有する"
change_kind: code

Parent Issue

#646

Parent Goal Ref

  • Goal: 正規見出し・機械可読構造を prose ratio 判定から除外し、bilingual heading を checker / guard の双方で同一ルールで認識する
  • Desired Destination: ## Outcome のような英語正規見出しが prose guard で誤検出されず、## 成果物 (Outcome) のような bilingual heading が contract checker の section heading として extract される。純粋な英語説明 prose は引き続き検出される

Current Validated Scope

  • .claude/skills/create-issue/scripts/prose_boundary_policy.py へ heading_policy(canonical_en / canonical_ja / accepted_forms / prose_guard_kind / contract_checker_kind を持つ entry の inventory)を 追加データとして 実装する。既存の公開 API classify_block(block) -> str のシグネチャと既存 block_kind 定数(BLOCK_KIND_CANONICAL_HEADING / BLOCK_KIND_BILINGUAL_HEADING 等)の意味は変更しない
  • heading_policy inventory は現行 implementation テンプレート(.github/ISSUE_TEMPLATE/implementation.yml)が使う canonical heading 群を網羅する
  • GFM/CommonMark の ATX heading 仕様(0–3 spaces indent / 任意 closing # / 半角・全角括弧)に追従する正規化関数で accepted_forms を扱う
  • .claude/skills/create-issue/scripts/validate_japanese_content.py の prose ratio 判定で canonical_heading / bilingual_heading / machine_contract / vc_command / code_fence を除外する。delta mode と full-body mode の挙動差を維持する
  • .claude/skills/review-issue/scripts/check_issue_contract.py の extract_section が bilingual heading を canonical section として認識する
  • 対応する unit test(heading inventory / GFM 正規化 / negative / code fence edge / bilingual 抽出)の追加

Remaining Parent Gaps

  • 公開 mutation route matrix SSOT は child-2 に委譲する
  • 終了レポート dry-run は child-3、shadow / enforce mode は child-4 に委譲する

Outcome

prose_boundary_policy.py に heading_policy inventory が追加され、## Outcome / ## Background などの英語正規見出しが canonical_heading として prose ratio 判定(delta mode)から除外される。## 成果物 (Outcome) のような bilingual heading は accepted_forms(半角・全角括弧)により bilingual_heading として扱われ、check_issue_contract.py の extract_section(body, "Outcome") がそれを Outcome セクションとして抽出できる。Machine-Readable Contract / VC command / code fence も ratio 判定から除外される一方、Summary 以下の純粋な英語説明段落・canonical でない英語見出し(例 ## Outcomes / ## Outcome Risks / ## This is a long English sentence)は引き続き fail する。full-body mode の prose-zero fail policy(#594)は弱めない。classify_block の公開 API と既存 block_kind の意味は不変。これらが unit test で固定される。

Background

#646 の reviewer Blocker 5 は、## 成果物 (Outcome) などの bilingual heading の正規形が未定義で、check_issue_contract.py は通るが guard-japanese-prose が落とす(またはその逆)の deadlock が起きうると指摘している。実際に #646 の refinement では英語正規見出し ## Outcome を contract checker が要求する一方、prose guard が日本語比率不足の prose block として block する deadlock が観測された。

child-0(#653, PR #658)は既にマージ済みで、prose_boundary_policy.py(classify_block 公開 API と BLOCK_KIND_CANONICAL_HEADING / BLOCK_KIND_BILINGUAL_HEADING 等の block_kind 定数)と validate_japanese_content.py からの委譲、guard-japanese-prose.sh の VALIDATOR 経由共有を提供する。ただし現状の heading 判定は「見出しに日本語を含むか」のみで分類するヒューリスティックであり、canonical heading の名前付き inventory も GFM 正規化も bilingual heading の extract_section 認識も未実装である。本 Issue はこの gap を heading_policy inventory の共有で解消する。

In Scope

  • heading_policy inventory の定義(各 entry が canonical_en / canonical_ja / accepted_forms / prose_guard_kind / contract_checker_kind を持つ)。classify_block 公開 API と既存 block_kind の意味は変更せず、同 module の追加データとして実装する
  • heading_policy inventory が現行 implementation テンプレートの canonical heading(Machine-Readable Contract / Parent Issue / Parent Goal Ref / Current Validated Scope / Remaining Parent Gaps / Outcome / Background / In Scope / Out of Scope / Acceptance Criteria / Verification Commands / Allowed Paths / Stop Conditions / Required Skills / Runtime Verification Applicability)を網羅すること
  • GFM ATX heading 正規化(0–3 spaces indent / 任意 closing # / 半角・全角括弧)に追従する accepted_forms 処理と、## Outcomes / ## Outcome Risks / ## Outcome: English prose を Outcome と誤認しない negative test
  • canonical_heading / bilingual_heading / machine_contract / vc_command / code_fence の prose ratio 判定除外(delta mode)。full-body mode の prose-zero fail policy(実装: AI-safe GitHub body mutation lane を追加し guard-japanese-prose の過剰ブロックと gh api workaround 化を解消する #594)は維持する
  • code fence 除外の test corpus(backtick 4 個 fence 内に 3 個 fence / tilde fence / closing fence が opening より短い / 未閉じ fence / code fence 直後に空行なし prose)
  • bilingual heading を check_issue_contract.py の section heading として認識する extract_section ロジック
  • guard 側(guard-japanese-prose.sh)は直接変更せず、heading_policy 適用は validate_japanese_content.py 経由でのみ行う

Out of Scope

Acceptance Criteria

  • AC1: heading_policy が prose_boundary_policy.py に存在し、各 entry が canonical_en / canonical_ja / accepted_forms / prose_guard_kind / contract_checker_kind を持つ。かつ classify_block(block) -> str の公開 API シグネチャと既存 block_kind 定数(BLOCK_KIND_CANONICAL_HEADING / BLOCK_KIND_BILINGUAL_HEADING 等)の意味を変更しない(heading_policy は同 module の追加データ)
  • AC2: heading_policy inventory が現行 implementation テンプレートの canonical heading 群(Machine-Readable Contract / Parent Issue / Parent Goal Ref / Current Validated Scope / Remaining Parent Gaps / Outcome / Background / In Scope / Out of Scope / Acceptance Criteria / Verification Commands / Allowed Paths / Stop Conditions / Required Skills / Runtime Verification Applicability)を網羅する
  • AC3: 英語正規見出し ## Outcome 単独 block が delta mode の prose ratio 判定で fail しない(canonical_heading として除外)一方、full-body mode の prose-zero fail policy(実装: AI-safe GitHub body mutation lane を追加し guard-japanese-prose の過剰ブロックと gh api workaround 化を解消する #594)は弱めない
  • AC4: bilingual heading ## 成果物 (Outcome)(半角・全角括弧の両 accepted_forms)が check_issue_contract.py の extract_section(body, "Outcome") で本文を抽出できる
  • AC5: GFM ATX heading 正規化(0–3 spaces indent / 任意 closing # / 半角・全角括弧)に追従し、## Outcomes / ## Outcome Risks / ## Outcome: English prose を Outcome と誤認しない negative test を持つ
  • AC6: Machine-Readable Contract / VC command / code fence が prose ratio 判定から除外される。code fence は nested backtick(4 個 fence 内 3 個 fence)/ tilde fence / 未閉じ fence / fence 直後 prose の fixture で検証する
  • AC7: Summary 以下の純粋な英語説明段落、および canonical でない英語見出し(例 ## This is a long English sentence)は引き続き prose ratio で fail する
  • AC8: guard-japanese-prose.sh を直接変更しない(heading_policy 適用は validate_japanese_content.py 経由のみ)。shell 側に独自 heading 分岐を追加しない
  • AC9: 既存の validator / checker / hook テストが回帰なく PASS する

Verification Commands

# AC1
$ rg -n "heading_policy|accepted_forms|canonical_en|canonical_ja|prose_guard_kind|contract_checker_kind" .claude/skills/create-issue/scripts/prose_boundary_policy.py

# AC2
$ uv run pytest .claude/skills/create-issue/scripts/tests/test_heading_policy.py -q -k "inventory_covers_template_headings"

# AC3
$ uv run pytest .claude/skills/create-issue/scripts/tests/test_heading_policy.py -q -k "delta_canonical_heading_excluded or full_body_zero_prose_still_fails"

# AC4
$ uv run pytest .claude/skills/review-issue/scripts/tests/test_bilingual_heading.py -q -k "extract_section_bilingual"

# AC5
$ uv run pytest .claude/skills/create-issue/scripts/tests/test_heading_policy.py -q -k "atx_normalization or similar_invalid_heading_negative"

# AC6
$ uv run pytest .claude/skills/create-issue/scripts/tests/test_heading_policy.py -q -k "machine_contract or vc_command or code_fence_edge"

# AC7
$ uv run pytest .claude/skills/create-issue/scripts/tests/test_heading_policy.py -q -k "english_prose_still_fails or non_canonical_english_heading_fails"

# AC8
$ uv run pytest .claude/skills/create-issue/scripts/tests/test_heading_policy.py -q -k "heading_policy_applied_via_validate"

# AC9
$ uv run pytest .claude/skills/create-issue/scripts/tests/ .claude/skills/review-issue/scripts/tests/ .claude/hooks/tests/ -q

Allowed Paths

  • .claude/skills/create-issue/scripts/prose_boundary_policy.py
  • .claude/skills/create-issue/scripts/validate_japanese_content.py
  • .claude/skills/review-issue/scripts/check_issue_contract.py
  • .claude/skills/create-issue/scripts/tests/test_heading_policy.py
  • .claude/skills/review-issue/scripts/tests/test_bilingual_heading.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合(特に guard-japanese-prose.sh の shell 側分岐変更が必要になった場合)
  • In Scope の固定契約(heading_policy フィールド / accepted_forms 正規形 / canonical heading inventory)の変更が必要になった場合
  • prose_boundary_policy.py の classify_block 公開 API または既存 block_kind の意味変更が必要になった場合
  • full-body mode の prose-zero pass 化など 実装: AI-safe GitHub body mutation lane を追加し guard-japanese-prose の過剰ブロックと gh api workaround 化を解消する #594 方針と衝突する変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • Python(pytest / unittest)
  • Markdown heading の正規化と正規表現(GFM/CommonMark ATX heading 仕様)
  • 既存 validator / checker の refactor

Scope Delta(任意)

N/A

Delivery Rule

Source(dedupe_key)

follow-up:squne121/loop-protocol:issue/646:child-1-heading-policy-exclusion

関連

Runtime Verification Applicability

rva_schema_version: v1
applicability: not_applicable
decision: not_applicable
reason: "heading 除外と bilingual heading 認識は decisionistic な block 分類 / 正規表現マッチングであり、unit test と回帰テストで決定論的に検証できる。runtime UI / 実行時挙動の動作検証対象を持たないため not_applicable とする"

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    area/ai-ops
    on Jun 4, 2026
  2. squne121 commented on Jun 4, 2026

    @squne121
    OwnerAuthor

    結論

    #654 は方向性は妥当ですが、このまま実装 Issue として流すと 部分修正で deadlock が残る可能性が高い です。現時点では 実装着手前に Issue 契約を補強すべき です。

    特に危険なのは、AC が Outcome 周辺に偏っており、Machine-Readable Contract / Parent Goal Ref / Current Validated Scope / Verification Commands / Runtime Verification Applicability など、実際の Issue テンプレートに出る canonical heading 全体を固定していない点です。#654 自体は ## Outcome や ## 成果物 (Outcome) を対象にしていますが、親 #646 はより広い正規見出し群を prose guard と contract checker の双方で通すことを目的にしています。([GitHub]1) ([GitHub]2)

    敵対的レビュー

    Blocker 1: #653 依存が実装順序だけでなく API 契約依存になっている

    #654 は prose_boundary_policy.py の heading policy 追加を前提にしていますが、#653 はそのファイル自体の新設と block_kind/classify API の SSOT 化を担当し、heading_policy は明示的に child-1 へ委譲しています。([GitHub]3)

    したがって #654 の PR は、#653 がマージ済みであるだけでなく、以下が確定していないと安全に書けません。

    classify API の戻り値型
    block_kind の列挙名
    canonical_heading / bilingual_heading の責務分界
    validate_japanese_content.py が prose_boundary_policy をどう import するか
    check_issue_contract.py が同じ module をどう参照するか
    

    #654 は「#653 マージ後に直列で着手」と書いていますが、API 互換条件までは AC 化していません。([GitHub]1)

    修正案

    AC に以下を追加してください。

    AC追加: #653 の prose_boundary_policy.classify_markdown_block もしくは同等の公開 classify API を変更せず、heading_policy は同 module の追加データとして実装する。既存 block_kind の意味を変更しない。
    

    Blocker 2: canonical heading の網羅表がない

    #654 の AC は Outcome と Background に寄りすぎです。親 #646 は Machine-Readable Contract / Outcome / In Scope / Allowed Paths / Stop Conditions / Handoff Contract などの正規見出しを prose guard と contract checker の双方で通すことを要求しています。([GitHub]2)

    しかし #654 の In Scope / AC は、どの heading が canonical_en / canonical_ja / accepted_forms に入るのかを列挙していません。これでは実装者が Outcome だけ直して完了扱いにできます。

    修正案

    Issue に heading_policy matrix を明示してください。

    heading_policy:
      - canonical_en: "Machine-Readable Contract"
        canonical_ja: "機械可読契約"
        accepted_forms:
          - "## Machine-Readable Contract"
          - "## 機械可読契約 (Machine-Readable Contract)"
          - "## 機械可読契約(Machine-Readable Contract)"
        prose_guard_kind: canonical_heading
        contract_checker_kind: machine_contract_heading
    
      - canonical_en: "Outcome"
        canonical_ja: "成果物"
        accepted_forms:
          - "## Outcome"
          - "## 成果物 (Outcome)"
          - "## 成果物(Outcome)"

    最低限、現行テンプレートで contract checker が要求する見出しを全部入れるべきです。新規見出し追加は Out of Scope でよいですが、既存見出しの完全な inventory は In Scope です。


    Blocker 3: Markdown 仕様準拠が弱い

    GitHub Flavored Markdown は CommonMark の strict superset です。([GitHub Pages]4) ATX heading は 1〜6 個の #、0〜3 spaces の indent、任意の closing # を許容します。([GitHub Pages]4)

    #654 の AC は ## Outcome と ## 成果物 (Outcome) だけを例示しており、以下の現実的な GitHub Markdown を固定していません。

    ## Outcome ##
      ## Outcome
    ## 成果物(Outcome)##
    ### Outcome

    特に section extractor 側は、heading level と section boundary を誤ると Outcome セクションの本文抽出が壊れます。

    修正案

    accepted_forms は単なる文字列リストではなく、正規化関数で扱うべきです。

    normalize_heading("  ## 成果物(Outcome) ##") == {
        "level": 2,
        "canonical_en": "Outcome",
        "canonical_ja": "成果物",
        "kind": "bilingual_heading",
    }

    加えて、## Outcome Risks や ## Outcomes を Outcome として誤認しない negative test が必要です。


    Blocker 4: code fence 除外は CommonMark とズレやすい

    #654 は code fence を prose ratio から除外するとしていますが、GFM の fenced code block は「3 個以上の backtick または tilde」「同種かつ同数以上の closing fence」「closing がない場合は文書末尾まで code block」などの仕様を持ちます。([GitHub Pages]4)

    単純な正規表現で ```.*?``` だけを抜くと、以下で誤判定します。

    English prose inside nested fence
    
    ```
    
    また、未閉じ fence は仕様上文書末尾まで code block 扱いです。:contentReference[oaicite:8]{index=8}
    
    **修正案**
    
    本 Issue で Markdown parser 導入までは不要ですが、少なくとも test corpus に以下を追加してください。
    
    ```text
    - backtick 4 個 fence 内に 3 個 fence がある
    - tilde fence
    - closing fence が opening より短い
    - 未閉じ fence
    - code fence 直後に空行なしで prose が続く
    ```
    
    ---
    
    ### Blocker 5: 「heading 単独 block が fail しない」の意味が危険
    
    #654 AC2 は `## Outcome` 単独 block が prose ratio 判定で fail を起こさないことを要求しています。:contentReference[oaicite:9]{index=9}
    
    これは delta 検査では妥当です。しかし full-body create/comment 検査で「prose block がゼロでも pass」に変えると、親 #594 の「新規 Issue / PR / comment / review の full-body 検査を弱めない」という方針と衝突します。:contentReference[oaicite:10]{index=10}
    
    **修正案**
    
    AC を分離してください。
    
    ```text
    AC追加:
    - delta mode: canonical heading だけの追加・変更は pass
    - full-body mode: canonical heading / machine block / code fence だけで human_prose が存在しない本文は、既存 policy を維持する。pass に変更する場合は別 Issue。
    ```
    
    ---
    
    ### Blocker 6: guard と checker が本当に同じ policy を使う保証が弱い
    
    #654 は checker / guard 共有を目的にしていますが、Allowed Paths に `.claude/hooks/guard-japanese-prose.sh` がありません。:contentReference[oaicite:11]{index=11}
    
    「guard は `validate_japanese_content.py` 経由でだけ heading_policy を consume する」という前提なら許容できます。しかし、shell 側に独自の分岐や grep 判定が残る場合、#654 の Allowed Paths では目的を満たせません。
    
    **修正案**
    
    Issue に明記してください。
    
    ```text
    Implementation Constraint:
    guard-japanese-prose.sh は直接変更しない。guard 側の heading_policy 適用は validate_japanese_content.py 経由でのみ行う。
    もし shell 側の分岐変更が必要なら Stop Condition として停止し、別 Issue に分割する。
    ```
    
    ---
    
    ## 追加すべきテスト
    
    #654 の現行 AC に加えて、最低限これを入れるべきです。
    
    ```text
    1. canonical headings inventory
       - Machine-Readable Contract
       - Parent Issue
       - Parent Goal Ref
       - Current Validated Scope
       - Remaining Parent Gaps
       - Outcome
       - Background
       - In Scope
       - Out of Scope
       - Acceptance Criteria
       - Verification Commands
       - Allowed Paths
       - Stop Conditions
       - Delivery Rule
       - Runtime Verification Applicability
    
    2. bilingual heading extraction
       - 半角括弧
       - 全角括弧
       - closing # 付き
       - 0〜3 spaces indent
       - similar but invalid heading: Outcomes / Outcome Risks / Outcome: English prose
    
    3. prose guard negative
       - `## Summary` 配下の純英語 prose は fail
       - `## Outcome` 見出しだけは delta pass
       - `## This is a long English sentence` は canonical heading ではないため fail
    
    4. code fence
       - nested backtick
       - tilde fence
       - unclosed fence
       - fence 直後 prose
    
    5. integration
       - validate_japanese_content.py と check_issue_contract.py が同じ heading_policy entry を参照していること
       - 片方だけに hardcoded regex がないこと
    ```
    
    ---
    
    ## PR が来たら見るべき差分ポイント
    
    1. `accepted_forms` を ad-hoc regex にしていないか。  
    2. `Outcome` だけのパッチになっていないか。  
    3. `check_issue_contract.py` 側で `## 成果物 (Outcome)` を抽出できても、`validate_japanese_content.py` 側が別ロジックになっていないか。  
    4. full-body guard を弱めていないか。  
    5. GFM の heading / fence 境界に最低限追従しているか。  
    6. #653 の block_kind を再定義・意味変更していないか。  
    7. `guard-japanese-prose.sh` の直接変更が必要になったのに、Allowed Paths を黙って破っていないか。
    
    ## 推奨する Issue コメント案
    
    ```markdown
    敵対的レビュー: この Issue は方向性は妥当だが、現状のまま実装すると Outcome 周辺だけを直して親 #646 の deadlock が残る可能性が高いです。
    
    Blocker:
    1. canonical heading の完全な inventory がない。Machine-Readable Contract / Parent Goal Ref / Current Validated Scope / Verification Commands / Runtime Verification Applicability など、現行テンプレートで使う heading を heading_policy matrix として列挙してください。
    2. `## Outcome` 単独 block pass の意味を delta mode と full-body mode で分離してください。full-body create/comment の「prose なし pass」化は #594 の full-body guard 維持方針と衝突します。
    3. GFM/CommonMark の ATX heading 仕様に合わせ、0-3 spaces indent / optional closing # / 半角・全角括弧 / invalid similar heading の negative test を追加してください。
    4. code fence 除外は nested fence / tilde fence / unclosed fence の fixture が必要です。
    5. guard 側は `validate_japanese_content.py` 経由でのみ heading_policy を consume するのか明記してください。shell 側変更が必要なら Stop Condition として別 Issue 化してください。
    6. #653 の classify API / block_kind を変更せず、heading_policy 追加だけで実装することを AC に入れてください。
    
    この補強なしで PR が来た場合、`Outcome` だけの局所修正・guard 弱体化・checker/guard の再分岐を Blocker として扱うべきです。
    ```
    
    現時点の判定は **Needs contract hardening before implementation** です。
    
  3. squne121 commented on Jun 4, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot 契約スナップショット (2026-06-04T13:31:00Z)

    着手準備が整いました。スナップショットは以下のとおりです。

    Outcome: prose_boundary_policy.py に heading_policy inventory を追加し、
      canonical / bilingual heading・machine contract・VC command・code fence を
      prose ratio 判定(delta mode)から除外。check_issue_contract.py の extract_section が
      bilingual heading を認識する。full-body mode の prose-zero fail policy(#594)は維持。
    Acceptance Criteria:
      AC1 heading_policy inventory + classify_block API/block_kind 不変
      AC2 template canonical heading 網羅
      AC3 delta 除外 ∧ full-body 非弱体化
      AC4 bilingual extract_section
      AC5 GFM ATX 正規化 + negative
      AC6 machine/vc/code fence edge 除外
      AC7 英語 prose / 非 canonical 英語見出し fail
      AC8 guard.sh 非変更・validate 経由
      AC9 既存テスト回帰なし
    Verification Commands: AC1-AC9 を fenced bash block に # ACN マーカー付きで列挙 (rg 1 + pytest 8)
    Allowed Paths: prose_boundary_policy.py / validate_japanese_content.py /
      check_issue_contract.py / tests/test_heading_policy.py / tests/test_bilingual_heading.py
    Worktree: .claude/worktrees/issue-654-heading-policy-exclusion
    Branch:   worktree-issue-654-heading-policy-exclusion
    VC preflight: baseline fail = 9, 想定外 pass = 0, 実行不可 = 0
    
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: 2026-06-04T13:31:00Z
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/654
      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: 9
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 0
          vc_skipped: 0
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []

    機械可読 handoff marker(自動 routing 用):

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: null
        generated_at: 2026-06-04T13:31:00Z
        body_sha256: sha256:b7fe61c63e6b5864fe6d860d918117a26d1917059ed6118b99fcf21692e50737
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: 2026-06-04T13:31:00Z

    refinement loop 概要

    次アクション: impl-review-loop 654(contract review go・blocker clear)。

  4. squne121 commented on Jun 4, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-06-04T13:53:55Z)

    実装が完了しました。Draft PR を起票しました。

    実装概要

    heading_policy inventory(15 エントリ)を prose_boundary_policy.py に追加データとして実装しました。
    canonical_heading / bilingual_heading が delta mode および full-body mode の prose ratio 判定から除外されます。
    extract_section が bilingual heading(例: ## 成果物 (Outcome))を英語正規名で抽出できます。
    classify_block 公開 API と既存 block_kind 定数の意味は変更していません。
    guard-japanese-prose.sh の直接変更もありません(AC8 準拠)。

  5. squne121 commented on Jun 4, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了(人間判断要請) (2026-06-04T14:20:00Z)

    人間判断が必要な理由

    唯一の失敗 CI は PR Body Japanese Check で、PR 本文の英語主体 prose block 4 件が日本語比率閾値(0.1)を下回ったため(aggregate=0.267, failed_blocks=4)。これは PR 本文の技術記述(Safety Claim Matrix / code identifier 多数)に起因し、本 PR の diff(コード/テスト)の問題ではない。実テストゲートは全 pass:

    • pnpm typecheck / pnpm lint / pnpm test(355) / pnpm build — pass
    • python-test / e2e / actionlint / build / deploy-pr — pass
    • pytest 387 passed, 1 xfailed(test_secret_boundary_contract は着手前からの既存 baseline fail、本 PR 無関係)

    この失敗は child-0 PR #658 マージ時と同一の systemic prose-check 失敗であり、まさに本 child chain(#646)が修正対象としている事象。

    step-5 の merge_ready 要件 テーブルでは UNSTABLE を自動的に merge_ready: true と見なさず人間判断に委ねるため、termination_reason: approved を立てずに停止する。

    人間の次アクション候補

    1. PR Body Japanese Check を feat(#646): prose block 分類 SSOT (prose_boundary_policy.py) を新設し validate_japanese_content.py を委譲 #658 と同じ systemic baseline として許容し、Draft 解除 → マージ
    2. PR 本文を日本語比率が閾値を満たすよう調整してから再評価
    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      draft_pr_ready: true
      github_merge_ready: false
      github_merge_state_status: UNSTABLE
      merge_ready: false
      pr_url: "https://github.com/squne121/loop-protocol/pull/662"
      head_sha: "345422b9d4186e80aedad9bf83bdd5e509f3d6ff"
      issue_number: 654
      termination_reason: human_escalation
      iteration: 0
      required_auto_actions: []
      human_next_action: review_ci_policy_then_mark_ready_or_merge
      blocking_ci_check: "PR Body Japanese Check (PR body Japanese ratio < 0.1, diff-unrelated, same as PR #658)"
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
    
    ISSUE_SCOPE_ROLLUP_DECISION_V2:
      schema_version: 2
      recorded_at: "2026-06-04T14:20:00Z"
      rollup_plan_ref:
        body_sha256: "see /tmp/scope_rollup_result_20260604T133832Z_3453071.json"
        generated_at: "2026-06-04T13:38:00Z"
      decision: skipped
      executed_actions: []
      skipped_reason: "high-confidence 候補は親 #646 の delivery-rollup で意図的に分割済みの child(#655 child-2 / #659)。escalation_required: false のため統合せず related_coordination として PR body に記録。#653 は closed_completed"
      related_coordination: [655, 659]
      candidates_reviewed:
        - kind: "issue"
          number: 655
          confidence: "high"
          suggested_action: "amend_current_issue"
          final_decision: "deferred"
          rejection_reason: "親 rollup で意図的に分離した別 child(child-2)。same_file_disjoint_anchor / escalation_required false"
        - kind: "issue"
          number: 659
          confidence: "high"
          suggested_action: "amend_current_issue"
          final_decision: "deferred"
          rejection_reason: "別 child(split_markdown_blocks 委譲)。same_file_disjoint_anchor / escalation_required false"
        - kind: "issue"
          number: 653
          confidence: "high"
          suggested_action: "amend_current_issue"
          final_decision: "rejected"
          rejection_reason: "closed_completed(child-0, PR #658 マージ済みの前提)"
  6. added a commit that references this issue on Jun 4, 2026
  7. squne121 commented on Jun 4, 2026

    @squne121
    OwnerAuthor

    fix_delta 修正完了

    PR #662 REQUEST_CHANGES 対応が完了しました。プッシュ済み(commit 00d9b34)。

    修正内容: B1_B4(heading_policy SSOT 接続)/ B2(parse_atx_heading_line 実装)/ B3(code fence exact assertion)/ TEST_INVERSION(テスト名・期待値修正)。

    pytest 396 passed, 2 xfailed(既存 baseline fail 1 件は本 PR 無関係)。pnpm 全件 PASS。

  8. squne121 commented on Jun 4, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: #659 先行のため hold(再順序付け) (2026-06-05T07:30:00Z)

    外部レビュー REQUEST_CHANGES を受け iteration 1 を実施。core blocker は解消したが、AC6 の code fence GFM 完全準拠に #659 への確定依存 が判明したため、人間判断により #659 を先に実装する再順序付けを採用する。

    iteration 1 で解消した blocker(独立検証済み)

    • B1/B4: heading_policy を prose 除外 gate の SSOT に接続。_is_heading_block() が lookup_heading_policy を参照し、inventory にない非 canonical 英語見出し(## This is a long English sentence / ## Outcome Risks / ## Outcomes / ## Outcome: English prose)は prose detect に残る(AC7 機能成立を実挙動で確認)
    • B2: parse_atx_heading_line() を新設し GFM ATX 正規化(0–3 spaces indent / closing #)を checker / guard で共有(AC5)
    • TEST_INVERSION: test_non_canonical_english_heading_fails の名前/期待値の逆転を修正

    #659 依存で未達の項目(AC6)

    • nested 4-backtick fence: 現行 split_markdown_blocks() の非貪欲 regex が 4-backtick 内の 3-backtick を誤って closing 扱いし 2 分割。xfail(strict=True) sentinel として記録
    • unclosed fence: GFM では EOF まで code block だが、現状は途中で prose block に戻る非 GFM 挙動(fence 直後内容が日本語比率チェック対象になる)

    これらの正しい実装は split_markdown_blocks の GFM 準拠 state machine を要し、#659(split_markdown_blocks の GFM 準拠セグメンテーションを prose_boundary_policy SSOT へ委譲)の In Scope。#654 へ取り込むと #659 とスコープ重複し親 #646 の rollup 分割方針に反するため取り込まない。

    routing 決定

    scope-rollup の反省

    初回 scope-rollup は #659 を same_file_disjoint_anchor の coordination 候補と扱ったが、実際は #654 AC6 が #659 の未実装挙動に依存する ordering dependency(sequential_required / blocked_by) だった。

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: blocked
      termination_reason: human_escalation
      blocked_by: [659]
      merge_ready: false
      pr_url: "https://github.com/squne121/loop-protocol/pull/662"
      head_sha: "00d9b34d3278d7149c2550907e014f4a3477e931"
      issue_number: 654
      iteration: 1
      resolved_blockers: [B1, B2, B4, test_inversion]
      deferred_to_659: [ac6_nested_4backtick_fence, ac6_unclosed_fence_to_eof]
      human_next_action: implement_659_first_then_resume_662
  9. added 2 commits that reference this issue on Jun 5, 2026
  10. squne121 commented on Jun 5, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了(人間のマージ判断待ち) (2026-06-05T08:40:00Z)

    #659(PR #669)マージ後に #654 を再開し、全 blocker を解消した。

    解消した blocker の経緯

    iteration 内容
    0 初回実装 → 外部レビューで REQUEST_CHANGES(heading_policy 飾り化 / AC7 違反 / ATX 正規化 / テスト逆転 / AC6 fence)
    1 B1/B4(heading_policy を prose 除外 gate の SSOT に接続・AC7)/ B2(parse_atx_heading_line・AC5)/ テスト逆転 を解消。AC6 fence GFM が #659 依存と判明し再順序付け
    2 #659(PR #669)マージ後に main 取り込み。AC6 の test_code_fence_nested_backtick_exact / test_code_fence_unclosed_consumes_to_eof を xfail なしの通常 PASS(exact assertion)に昇格 → 再レビューで extract_section 変更による edit-issue autofix 13 件 regression / CI python-test fail を検出(REQUEST_CHANGES)
    3 extract_section を #659 の iter_markdown_blocks(GFM 準拠 SSOT)で fence 対応にし、境界を level-2(##)に限定。fence 内 # AC1 を見出し境界に誤検出するバグを修正。edit-issue autofix 16 passed・CI python-test pass → 回帰解消

    検証(独立確認済み)

    UNSTABLE の原因

    唯一の失敗 CI は PR Body Japanese Check(PR 本文の英語比率、diff 無関係の systemic baseline、#658/#669 と同一で前例あり)。実ゲートは全 pass。

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      draft_pr_ready: true
      github_merge_ready: false
      github_merge_state_status: UNSTABLE
      merge_ready: false
      pr_url: "https://github.com/squne121/loop-protocol/pull/662"
      head_sha: "9f8f4a1bee70c3a2bb9b0d42a3e25608d2ad8285"
      issue_number: 654
      termination_reason: human_escalation
      iteration: 3
      required_auto_actions: []
      blocking_ci_check: "PR Body Japanese Check (PR body Japanese ratio, diff-unrelated systemic baseline, same as #658/#669)"
      human_next_action: review_ci_policy_then_mark_ready_or_merge
      depends_on_merged: [659]
  11. added a commit that references this issue on Jun 5, 2026
  12. squne121 commented on Jun 5, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: iteration 4 完了(人間のマージ判断待ち) (2026-06-05T09:30:00Z)

    外部レビューの REQUEST_CHANGES(B1/B2 blocker + M1/M2 major)を人間承認のもと iteration 4 で修正。全項目を control-plane が独立検証済み。

    解消(独立検証済み)

    • B1(安全バグ): 先頭 4 スペースの字下げコードブロックが見出しとして誤って除外されていた問題を解消しました。構文判定の前に空白を削っていた処理を取り除き、生の行で判定するよう変更しています。独立検証では字下げ見出しが見出し扱いされず、本文(prose)として正しく検出されることを確認しました。
    • B2(判定が緩い問題): 二言語見出しの許容形をすり抜けて任意の前置きでも一致していた問題を解消しました。許容形の厳密一致のみで判定するよう変更し、想定外の前置きを持つ見出しは拒否されることを確認しています。
    • M1: 閉じ側フェンスが開き側より短い場合にフェンスが継続することを検証する観測例(fixture)を追加し、合格を確認しました。
    • M2: 見出し一覧の網羅検証を、固定の埋め込みからテンプレート定義からの動的抽出に変更し、出所を明示する正本(SSOT)化を行いました。テンプレートに無い見出しは由来を区別して保持しています。

    回帰なし

    既存の受け入れ条件は維持されています。英語正規見出しの除外(AC3)、二言語見出しからの本文抽出(AC4)、非正規の英語見出しを本文として検出する挙動(AC7)はいずれも従来どおりで、別スキルの自動修正テストも全件合格しました。継続的インテグレーションの実ジョブ(型検査・lint・テスト・ビルド・e2e・actionlint・python-test)はすべて成功しています。広域テストは 519 件合格で、唯一の失敗は本件と無関係の既存の secret boundary テストです。

    iteration 履歴(#654 全体)

    UNSTABLE の原因

    唯一の失敗 CI は PR Body Japanese Check(PR 本文の英語比率、diff 無関係の systemic baseline、#658/#669 と同一の前例)。

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      draft_pr_ready: true
      github_merge_ready: false
      github_merge_state_status: UNSTABLE
      merge_ready: false
      pr_url: "https://github.com/squne121/loop-protocol/pull/662"
      head_sha: "9632153e6a7b835a7f595f272e0cd23363b82bc3"
      issue_number: 654
      termination_reason: human_escalation
      iteration: 4
      required_auto_actions: []
      blocking_ci_check: "PR Body Japanese Check (diff-unrelated systemic baseline, same as #658/#669)"
      human_next_action: review_then_mark_ready_or_merge
      resolved_external_review_blockers: [B1, B2, M1, M2]
  13. added 2 commits that reference this issue on Jun 5, 2026
  14. added a commit that references this issue on Jun 5, 2026
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/implementerarea/ai-opsenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions