Skip to content

実装: delivery-rollup child materialization を parser_gap 自動修復付き reconciliation で fail-closed 化する #328

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
goal_ref: "delivery-rollup / child-complete parent の approve フローで body desired state と GitHub Sub-issue actual state を reconcile し、A/B/C/D 形式含む全 child candidate が materialize されるまで approved に移行しない"
change_kind: workflow

Outcome

delivery-rollup / child-complete parent の approve フロー(approve → Step 4.5 → Step 5)が確立され、A/B/C/D 形式を含むすべての child candidate が native GitHub Sub-issue として materialize されるまで termination_reason: approved に移行しない。parser_gap 自動修復(repair_confidence: high の場合は issue-author に委譲)が機能し、修復不能な gap のみ human_escalation になる。

Parent Issue

#244

Parent Goal Ref

#244 の Goal: 「GitHub Issue/PR body authoring をテンプレート・validator・lint で機械検証し、AI が最小コンテキストで修正できる状態にする」

Desired Destination:

  • validate_issue_body.py / validate_pr_body.py / baseline_vc_preflight.py により Issue/PR body が機械検証される
  • AI に渡す修正コンテキストは validator JSON の failing rule + minimal_context に限定される
  • 本 tracker の全 child Issue (A/B/C/D) が完了状態になっている

Summary

issue-refinement-loop を delivery-rollup + child-complete の parent Issue(例: #244)に対して実行したとき、review-issue が approve を返しても child issues(A/B/C/D トラック)が起票されないまま termination_reason: approved になる問題を修正する。

根本原因:

  1. plan_child_materialization.py の child parser が C\d+-\d+ 形式しか認識せず、A/B/C/D 形式の child line を 0 件と誤認識する
  2. on_no_children: pass: true が delivery-rollup parent でも無条件に pass するため materialization が強制されない
  3. issue-refinement-loop Guardrails に「approve で即終了」という記述があり Step 4.5 の必須性と矛盾する
  4. edit-issue の delivery-rollup-parent-update mode が V2 schema(old_line/new_line)ではなく V1 フィールド名(replace/with)を参照している
  5. issue-author に task: materialize_children の入力定義がなく、child materialization の mutation 境界が未定義
  6. create-issue の plan が取得できない場合に fail-closed せず通常フローにフォールバックする(delivery-rollup 文脈では危険)
  7. parser_gap が発生しても即 human_escalation に移行し、repair_confidence: high の gap を自動修復する手段がない

Goal

  • plan_child_materialization.py が body desired state(A/B/C/D 形式含む)と native GitHub Sub-issue actual state を分離して reconcile する
  • ## Child Issues 配下の全 checkbox/bullet candidate を parser 前に inventory 化し、candidate_count / parsed_count / parser_gap_report[] を出力する
  • parser_gap が repair_confidence: high の場合は human_escalation ではなく issue-author の task: materialize_children に修復を委譲し、修復後に plan を再実行する
  • human_escalation は duplicate child_id / multiple issue refs / missing title / cross-owner issue / GitHub API 403・404・410・422 / expected_match_count != 1 など、決定論的修復不能な gap に限定する
  • issue-refinement-loop の approve 経路が approve -> Step 4.5 -> Step 5 に統一され、Guardrails との矛盾が解消される
  • issue-author が task: materialize_children を受け付け、CHILD_MATERIALIZATION_RESULT_V2 を返す
  • edit-issue の delivery-rollup-parent-update が V2 schema(old_line/new_line/expected_match_count)を正しく消費する

Current Validated Scope

  • .claude/skills/create-issue/scripts/plan_child_materialization.py
  • .claude/skills/create-issue/tests/test_plan_child_materialization.py
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/agents/issue-author.md
  • .claude/skills/edit-issue/SKILL.md
  • docs/dev/agent-skill-boundaries.md

In Scope

  • .claude/skills/create-issue/scripts/plan_child_materialization.py
    • _CHILD_LINE_RE を拡張: C\d+-\d+ に加えて [A-Z] 形式(## Child Issues セクション内の checkbox/bullet 先頭に限定)を検出
    • delivery-rollup parent で child candidate がある(## Child Issues セクションに checkbox 行がある)のに parsed children が 0 件の場合: warning ではなく fail(on_unparsed_child_candidates: severity: human_escalation)
    • dedupe_key を delivery-rollup:<parent>:A 形式に安定化
    • body_inventory / parser_gap_report[] / github_subissues_actual フィールドの追加
    • repairable_gap_rules / unsafe_gap_rules の実装(OWNER コメント参照)
    • task: materialize_children への修復委譲ロジック
  • .claude/skills/create-issue/tests/test_plan_child_materialization.py
    • A:/B:/C:/D: 形式検出の回帰テスト追加
    • parser_gap / human_escalation の単体テスト追加
  • .claude/skills/issue-refinement-loop/SKILL.md
    • Step 4.5 を approve 前の mandatory gate として明確化(approve_without_materialization: prohibited の適用範囲を明示)
    • Guardrails の「review-issue から approve を受けた時点で即終了」を delivery-rollup + child-complete 例外付きに修正
    • on_no_children: pass: true を fail-closed 条件付きに変更(Remaining Parent Gaps に child 起票が残っている場合は stop)
    • 終了コメントの FOLLOW_UP_MATERIALIZATION_RESULT_V1 を CHILD_MATERIALIZATION_RESULT_V2 に強化
  • .claude/agents/issue-author.md
    • task: materialize_children を追加
    • CHILD_MATERIALIZATION_PLAN_V2 → create-issue / edit-issue → CHILD_MATERIALIZATION_RESULT_V2 の責務を追加
    • 1 件でも create 失敗したら termination_reason: partial_failure、parent body への #N 反映失敗も approved にしない
  • .claude/skills/edit-issue/SKILL.md
    • delivery-rollup-parent-update の V2 schema 参照を old_line/new_line/expected_match_count に統一
    • replace/with フィールド名の V1 残存を修正
  • docs/dev/agent-skill-boundaries.md
    • CHILD_MATERIALIZATION_RESULT_V2 schema 正本を追加

Remaining Parent Gaps

Out of Scope

Acceptance Criteria

  • AC1: plan_child_materialization.py は C254-3 形式と A: / B: / C: / D: 形式の両方を ## Child Issues 配下で parse できる
  • AC2a: plan_child_materialization.py は ## Child Issues セクション配下の checkbox/bullet candidate を parser 前に全件 inventory 化し、candidate_count, parsed_count, parser_gap_report[] を出力する
  • AC2b: parser_gap_report[] は line_number, raw_line, gap_reason, suggested_repair, repair_confidence, minimal_context を含む
  • AC2c: すべての parser_gap が repair_confidence: high の場合、human_escalation ではなく issue-author task: materialize_children に修復を委譲し、修復後に plan を再実行する
  • AC2d: 修復後の再実行で candidate_count == parsed_count、parser_gap_report == []、required_issue_creations == []、required_subissue_registrations == []、parent_body_updates == [] になるまで termination_reason: approved にしない
  • AC2e: human_escalation は duplicate child_id / multiple issue refs / missing title / cross-owner issue / GitHub API 403・404・410・422 / expected_match_count != 1 など、決定論的修復不能な gap に限定する
  • AC3: plan は body_inventory(desired state: body 解析)と github_subissues_actual(actual state: native Sub-issue read-back)を分離して出力し、actual state は native Sub-issue read-back を優先する
  • AC4: body に #N があるが native Sub-issue parent read-back が一致しない場合、no_op ではなく register_subissue_or_human_escalation になる
  • AC5: issue-refinement-loop の approve 経路は approve -> Step 4.5 -> Step 5 に統一され、Guardrails の approve 即終了記述が削除または delivery-rollup 例外付きになる
  • AC6: issue-author は task: materialize_children を受け取り、CHILD_MATERIALIZATION_PLAN_V2 と parser_gap_report を入力として CHILD_MATERIALIZATION_RESULT_V2(status: ok|partial_failure|failed|human_escalation、created_issues、registered_subissues、parent_body_updates_applied、parser_gaps_resolved、remaining_gaps、replan)を返す
  • AC7: edit-issue の delivery-rollup-parent-update は old_line/new_line/expected_match_count を使い、replace/with フィールドを参照しない
  • AC8: child 起票・sub-issue 登録・parent body update のいずれかが失敗した場合、termination_reason: approved にならない

Verification Commands

# AC1: C254-3 形式と A:/B:/C:/D: 形式の両方を検出
$ uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py -k "abcd or c254" -v

# AC2a-2b: candidate inventory と parser_gap_report が出ること
$ uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py \
  -k "candidate_inventory or parser_gap_report" -v

# AC2c: repairable parser_gap が suggested_repair を返すこと
$ uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py \
  -k "repairable_parser_gap or repair_confidence" -v

# AC2e: unsafe gap のみ human_escalation になること
$ uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py \
  -k "unsafe_parser_gap or duplicate_child_id or multiple_issue_refs" -v

# AC3: body_inventory / github_subissues_actual を分離出力
$ uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py -k "inventory_split or subissues_actual" -v

# AC4: register_subissue_or_human_escalation のロジック
$ uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py -k "register_subissue" -v

# AC5: approve routing が Step 4.5 を必ず通り、approve 即終了の残存がないこと
$ rg "approve.*Step 4\.5|proceed_to: Step 4\.5|Step 4\.5.*mandatory|delivery.rollup.*exception" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: AC5-routing" || echo "FAIL: AC5-routing"
$ ! rg "approve.*即終了|approve → 終了|approve -> 終了" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: AC5-no-immediate-exit" || echo "FAIL: AC5-no-immediate-exit"

# AC6: issue-author が task: materialize_children と result schema を持つこと
$ rg "task: materialize_children|CHILD_MATERIALIZATION_RESULT_V2" .claude/agents/issue-author.md && echo "PASS: AC6" || echo "FAIL: AC6"

# AC7: edit-issue が old_line/new_line を使用し replace/with を使わないこと
$ rg "old_line|new_line|expected_match_count" .claude/skills/edit-issue/SKILL.md && echo "PASS: AC7-schema" || echo "FAIL: AC7-schema"
$ ! rg "parent_body_updates\[\*\]\.(replace|with)" .claude/skills/edit-issue/SKILL.md && echo "PASS: AC7-no-v1-refs" || echo "FAIL: AC7-no-v1-refs"

# AC8: 失敗時に termination_reason: approved にならない
$ rg "partial_failure|materialization_failed|materialization.*human_escalation" .claude/skills/issue-refinement-loop/SKILL.md && echo "PASS: AC8" || echo "FAIL: AC8"

# 全体ビルド
$ pnpm typecheck && pnpm lint && pnpm test && pnpm build

Allowed Paths

  • .claude/skills/create-issue/scripts/plan_child_materialization.py
  • .claude/skills/create-issue/tests/test_plan_child_materialization.py
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/agents/issue-author.md
  • .claude/skills/edit-issue/SKILL.md
  • docs/dev/agent-skill-boundaries.md

Stop Conditions

  • _CHILD_LINE_RE の拡張が既存 C\d+-\d+ 形式の検出に影響する場合 → 既存テストを保護した上で慎重に拡張
  • on_unparsed_child_candidates: human_escalation が既存の正常ケースを誤検知する場合 → 条件を絞り込んでから再実装
  • GitHub Sub-issues API の 422 エラー(spam 判定)が発生する場合 → human_escalation(自動リトライ禁止)
  • native Sub-issue read-back が 0 件かつ parent_mode が delivery-rollup でない場合 → reconciler をスキップ
  • native Sub-issue read-back が外部 org の Issue を参照している場合 → human_escalation(same-owner 制約違反)
  • plan_child_materialization.py の改修が既存の C\d+-\d+ 形式検出を回帰させる場合 → pnpm test で検出後、修正してから再実装

Required Skills

  • plan_child_materialization.py(.claude/skills/create-issue/scripts/)

Runtime Verification Applicability

decision: immediate
reason: "plan_child_materialization.py の parser 動作と issue-refinement-loop Step 4.5 の動作は実装直後にテスト可能"

Related Issues

Source

dedupe_key: refinement-loop-child-materialization-gate-fail-closed
source_issue: 244
source_url: https://github.com/squne121/loop-protocol/issues/244#issuecomment-4526915156
materialized_by: issue-refinement-loop フィードバック対応
rationale: "delivery-rollup parent で A/B/C/D 形式 child が検出されず approved になる仕様穴を修正"

Activity

  1. added
    workflow
    kind/implementation
    area/ai-ops
    on May 24, 2026
  2. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    人間からの指摘です。
    issue作成時やissue編集時のエージェントスキルにおけるchildissue 起票ルールの制御が甘いのでは?
    あるいはissue本文ではなくSub-issueの読み取りから行った方が確実なのでは?

  3. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    ([Gmail]1)([Gmail]2)([Gmail]3)([Gmail]4)([Gmail]5)([Gmail]6)([Gmail]7)([Gmail]8)([Gmail]9)

    判定: REQUEST CHANGES

    #328 は問題の方向性は正しいです。ただし、現状の Issue は 「A/B/C/D 形式を parser に足す」ことに寄りすぎで、人間指摘の本質である child issue materialization の制御面が create/edit/issue-author/refinement にまたがって甘いという問題を十分に閉じていません。#328 の本文自体も、原因として plan_child_materialization.py が C\d+-\d+ 形式しか認識しないこと、on_no_children: pass: true が delivery-rollup parent でも通ってしまうこと、approve 即終了記述と Step 4.5 が矛盾していることを挙げています。 人間コメントの「Issue 作成時・編集時の child issue 起票ルール制御が甘いのでは」「Sub-issue 読み取りから行った方が確実では」という指摘は妥当です。

    #244 はすでに A/B/C/D が #327/#329/#330/#331 として本文上に反映されていますが、これは今回のバグが発生した後に状態が補正された結果であり、再発防止の証明にはなりません。むしろ #244 は、A/B/C/D 形式の child inventory を regression fixture にすべきです。

    重大な問題

    1. #328 のスコープは parser patch だけでは足りない

    #299 と PR #315 で、すでに CHILD_MATERIALIZATION_PLAN_V2 と plan_child_materialization.py が導入され、create-issue / edit-issue / issue-refinement-loop / impl-review-loop / open-pr / post-merge-cleanup へ横断的に伝搬する設計になっています。 PR #315 本文上も、V2 schema、line-oriented patch、dedupe search、closed child 判定、61 tests などを実装済みとしています。

    しかし現在の plan_child_materialization.py の _CHILD_LINE_RE は依然として C\d+-\d+ 形式に固定されており、A/B/C/D 形式は child として parse されません。 さらに parsed_children が 0 件でも warning を追加するだけで、delivery-rollup / child-complete parent に対して fail-closed していません。 これは #328 の直接原因です。

    2. issue-refinement-loop の文書内矛盾がまだ残っている

    issue-refinement-loop の冒頭と Loop Structure は「review-issue が approve を返したら終了」と書いており、Step 2 routing も approve -> Step 5 になっています。 一方で後段の Step 4.5 は approve 後・Step 5 前に child materialization gate を実行し、missing children は approve_without_materialization: prohibited としています。

    これは LLM にとって致命的です。上にある単純な「approve 即終了」の方が先に読まれ、Step 4.5 が運用上スキップされる余地があります。#328 ではこの矛盾を「例外付きに修正」としていますが、実装方針としては Step 2 routing 自体を approve -> Step 4.5 -> Step 5 に書き換える必要があります。

    3. issue-author に materialize_children task が存在しない

    #328 は .claude/agents/issue-author.md に task: materialize_children を追加するとしていますが、現行の issue-author 入力表は「新規起票」「既存修正」「起票 + 即時修正」の 3 種だけです。 つまり Step 4.5 が issue-author task: materialize_children を呼ぶ設計にしても、現状では受け口がありません。

    さらに issue-author の frontmatter では Write が許可されていますが、本文制約には disallowedTools: [Edit, Write, MultiEdit] と書かれており、ツール制約の説明もずれています。 これは child materialization のような mutation-heavy な処理では危険です。

    4. edit-issue の V2 schema 消費が壊れている可能性が高い

    CHILD_MATERIALIZATION_PLAN_V2 の schema 正本では parent_body_updates は old_line / new_line / expected_match_count 形式です。 plan_child_materialization.py も old_line / new_line を出力しています。

    しかし edit-issue の Delivery-rollup Parent Body Update Mode は、手順 3 で parent_body_updates[*].replace を parent_body_updates[*].with に置換すると書いています。 これは V1 由来のフィールド名が残っている状態に見えます。結果として、起票後に parent body の stale placeholder を更新する経路が実行時に破綻する可能性があります。

    5. create-issue の fallback が fail-open になっている

    create-issue の delivery-rollup child materialization 手順は、plan を入口にして action: create_issue の child だけを create_issue_txn.py で起票する設計です。 これはよいです。create_issue_txn.py 側も body-derived parent 抽出、--parent-issue との mismatch fail-closed、422 idempotency、parent read-back を持つので、child 登録の transaction boundary として妥当です。

    ただし同じ節に「plan が存在しない / 取得できない場合は通常の create-issue フローにフォールバック」とあります。 delivery-rollup materialization 文脈ではこれは危険です。plan が取れないなら通常起票に戻すのではなく、materialization_plan_unavailable として fail-closed すべきです。

    「Issue 本文ではなく Sub-issue 読み取りから行うべきか」

    結論は Sub-issue 読み取りだけでは不十分、だが Sub-issue 読み取りを actual state の正本にすべきです。

    理由は単純です。未起票 child は GitHub native Sub-issues にはまだ存在しません。したがって Sub-issue API だけを読むと、今回の A/B/C/D のような「本文には desired child があるが、まだ materialize されていない」候補を発見できません。一方、Issue 本文だけを正本にすると、すでに起票・登録済みなのに本文が古い、あるいは本文に #N があるが native Sub-issue 登録されていない、といった drift を検出できません。

    採るべき設計は two-source reconciliation です。

    body_inventory:
      source: "## Child Issues / Remaining Parent Gaps"
      role: desired child plan / unmaterialized candidates
    
    github_subissues:
      source: native GitHub Sub-issues read-back
      role: actual materialized parent-child relationship
    
    dedupe_search:
      source: dedupe_key search across open/closed issues
      role: duplicate prevention / reuse candidate discovery

    GitHub の Sub-issues API は child を parent に追加する endpoint を持ち、追加時は sub_issue_id が必須で、同一 repository owner 配下の issue である必要があります。さらに Issues write 権限が必要で、secondary rate limiting の対象にもなり得ます。([GitHub Docs]10) 422 は validation failure や spam 判定などで返り得るため、create_issue_txn.py のような read-back / idempotency helper に閉じ込める設計が妥当です。([GitHub Docs]10)

    #328 の高品質化方針

    #328 は次のように改訂すべきです。

    1. Issue タイトルを広げる

    現タイトルは parser/gate 修正に見えます。実際には control-plane 修正なので、例えば以下が妥当です。

    実装: delivery-rollup child materialization を body/sub-issue reconciliation で fail-closed 化する
    

    2. In Scope を追加する

    現在の #328 は plan_child_materialization.py / issue-refinement-loop/SKILL.md / issue-author.md が中心ですが、最低限これを追加すべきです。

    - .claude/skills/create-issue/tests/test_plan_child_materialization.py
    - .claude/skills/edit-issue/SKILL.md
    - docs/dev/agent-skill-boundaries.md
    

    理由は、parser 変更なのに test path がない、edit-issue の V2 field mismatch が残っている、CHILD_MATERIALIZATION_RESULT_V2 を出すなら schema 正本が必要、の 3 点です。

    3. plan_child_materialization.py の仕様を parser 追加ではなく reconciler にする

    最低限の分類はこうです。

    child_reconciliation_states:
      - desired_in_body_unmaterialized:
          condition: body child candidate exists, no issue ref, no sub-issue
          action: create_issue
      - desired_issue_ref_not_registered:
          condition: body has #N, but #N parent read-back != parent
          action: register_subissue_or_human_escalation
      - registered_subissue_missing_from_body:
          condition: native sub-issue exists, body inventory lacks it
          action: update_parent_body_or_human_escalation
      - stale_body_only:
          condition: body says 未起票 but issue/sub-issue exists
          action: update_parent_body
      - parser_gap:
          condition: candidate_checkbox_count > parsed_child_count
          action: human_escalation

    A/B/C/D の追加はこの一部でしかありません。

    4. on_no_children: pass: true を廃止する

    delivery-rollup / child-complete parent で ## Child Issues または Remaining Parent Gaps に checkbox/bullet candidate がある場合、parsed child が 0 件なら pass ではなく parser_gap です。on_no_children は、次の条件をすべて満たす場合だけ pass にすべきです。

    on_no_children_pass_allowed_if_all:
      - parent_mode != delivery-rollup
        OR closure_mode != child-complete
        OR no child candidate section exists
      - no Remaining Parent Gaps child-like checkbox exists
      - native sub-issues read-back is empty or intentionally n/a

    5. issue-author に明示 task を追加する

    issue-author に以下の入力を追加すべきです。

    task: materialize_children
    input:
      child_materialization_plan: CHILD_MATERIALIZATION_PLAN_V2
    required_outputs:
      CHILD_MATERIALIZATION_RESULT_V2:
        status: ok | partial_failure | failed | human_escalation
        created_issues: []
        reused_issues: []
        parent_body_updates_applied: []
        subissue_registrations_verified: []
        failures: []

    1 件でも create / sub-issue registration / parent update が失敗したら、approved ではなく materialization_failed または human_escalation にするべきです。

    6. edit-issue の V2 field mismatch を #328 に含める

    replace / with を使う記述は old_line / new_line に修正し、expected_match_count != 1 は必ず abort させるべきです。現状のままだと parent body update mode が V2 schema を正しく消費できません。

    推奨 AC 差し替え案

    - [ ] AC1: `plan_child_materialization.py` は `C254-3` 形式と `A:` / `B:` / `C:` / `D:` 形式の両方を `## Child Issues` 配下で parse できる
    - [ ] AC2: `## Child Issues` 配下の checkbox/bullet candidate 数が parsed child 数を上回る場合、`parser_gap` として `human_escalation` を返す
    - [ ] AC3: plan は `body_inventory` と `github_subissues_actual` を分離して出力し、actual state は native Sub-issue read-back を優先する
    - [ ] AC4: body に `#N` があるが native Sub-issue parent read-back が一致しない場合、`no_op` ではなく `register_subissue_or_human_escalation` になる
    - [ ] AC5: `issue-refinement-loop` の approve 経路は `approve -> Step 4.5 -> Step 5` に統一され、Guardrails の approve 即終了記述が削除または delivery-rollup 例外付きになる
    - [ ] AC6: `issue-author` は `task: materialize_children` を受け取り、`CHILD_MATERIALIZATION_RESULT_V2` を返す
    - [ ] AC7: `edit-issue` の delivery-rollup-parent-update は `old_line/new_line/expected_match_count` を使い、`replace/with` を参照しない
    - [ ] AC8: child 起票・sub-issue 登録・parent body update のいずれかが失敗した場合、`termination_reason: approved` にならない

    実装上の補足

    gh issue create は --body-file をサポートしており、- で stdin から本文を読むこともできます。本文は inline --body ではなく body-file 経由に統一する現行方針を維持すべきです。([GitHub CLI]11)

    Claude Code の Subagent は独立 context を持つため main context を節約できますが、非 fork 型 subagent は会話履歴や既読ファイルをそのまま見ません。([Claude API Docs]12) したがって、child materialization の判定は subagent の自由推論に任せるのではなく、Skill 配下の script が小さな plan を返し、issue-author は mutation boundary だけを担当する設計が正しいです。Claude Code Skills は .claude/skills/ 配下に SKILL.md と scripts を同梱できるため、この用途に合っています。([Claude API Docs]13)

    最終判断として、#328 は 実装に流してよいが、as-is では不足です。parser 拡張 Issue ではなく、body desired state と GitHub native Sub-issue actual state を reconciliation する fail-closed control-plane Issueとして改訂してから着手するのが妥当です。

  4. changed the title [-]実装: issue-refinement-loop の delivery-rollup child materialization gate を fail-closed 化し A/B/C/D 形式の child line を検出できるようにする[/-] [+]実装: delivery-rollup child materialization を body/sub-issue reconciliation で fail-closed 化する[/+] on May 24, 2026
  5. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: iteration 1 改善適用 (2026-05-24)

    anchor_comment: #328 (comment)
    final_classification: feedback_update_required
    scope_impact: amend

    主な変更点

    • タイトル変更: parser fix → body/sub-issue reconciliation で fail-closed 化
    • AC を 5 件 → 8 件に差し替え(reconciler 設計 / sub-issue read-back / edit-issue V2 修正 / issue-author task 追加)
    • 不足セクション追加: Outcome / Parent Issue / Current Validated Scope / Remaining Parent Gaps / Required Skills / Runtime Verification Applicability
    • In Scope 拡張: test files / edit-issue SKILL.md / agent-skill-boundaries.md
    • VC を pytest ベースに更新
  6. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: iteration 2 構造修正 (2026-05-24)

    修正内容:

  7. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: 完了 (2026-05-24T01:53:22Z)

    • iteration: 2

    • verdict: approve

    • termination_reason: approved

    • 改善履歴:

      • iter 0→1: タイトル変更(parser fix → body/sub-issue reconciliation で fail-closed 化)/ AC を 5 件 → 8 件に差し替え / Outcome・Parent Issue・Current Validated Scope・Remaining Parent Gaps・Required Skills・Runtime Verification Applicability セクション追加 / In Scope・Allowed Paths・VC 拡張
      • iter 1→2: Parent Goal Ref セクション追加 / Stop Conditions を 4 件 → 6 件に補強 / VC を $ prefix 形式に統一 / Required Skills から workflow tools を削除 / AC 全件に runtime-verification: true タグ追加
    • anchor_comment: 実装: delivery-rollup child materialization を parser_gap 自動修復付き reconciliation で fail-closed 化する #328 (comment)

    • final_classification: feedback_update_required

    • scope_impact: amend

    • 次アクション: issue-contract-review を実行してから impl-review-loop / implement-issue で着手してください

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      follow_up_issues: []
      note_only_observations: []
  8. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    人間からの指摘です。
    「AC2: ## Child Issues 配下の checkbox/bullet candidate 数が parsed child 数を上回る場合、parser_gap として human_escalation を返す」とあるがcheckbox/bullet candidate 数 と parsed child 数が異なる場合、人間にエスカレーションされても「直して」とか「起票して」とか言うことしかないと思うから可能な限り決定論的に修正完了まで自走してほしい。例えばgapの内容を出力してAIエージェントフレンドリーに修正(issue執筆サブエージェントに修正させる)導線を設ければいいのではないか?

  9. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST CHANGES

    #328 は方向性は正しいですが、現状の AC2 は 「fail-closed」を「人間停止」と混同しています。人間指摘の通り、checkbox/bullet candidate 数 > parsed child 数 のたびに human_escalation しても、人間は結局「直して」「起票して」と返すだけになりやすい。ここは parser_gap を人間向け停止理由ではなく、AI エージェント向け修復計画に変換する設計へ変えるべきです。

    #328 自体は plan_child_materialization.py の parser 欠陥、on_no_children: pass: true、approve 即終了、issue-author の materialize_children 未定義、edit-issue の V1/V2 schema mismatch、create-issue の fail-open fallback を根本原因として列挙しており、問題認識は広いです。 ただし既存コメントでも指摘されている通り、現 Issue はまだ「parser に A/B/C/D を足す」方向へ寄りがちで、create/edit/issue-author/refinement 全体の control-plane 修復としては不足しています。

    重大な見落とし

    一番危険なのは、現在の parser が C\d+-\d+ しか読めないだけでなく、## Child Issues 配下で 次の見出しが出たら終了する実装になっている点です。#244 の実本文は ## Child Issues の直下に ### 実装トラック を置き、その下に A/B/C/D bullets があるため、A/B/C/D 正規表現を足しても、section extraction が ### で止まるなら候補行まで到達しません。

    さらに、現在の build_plan() は parsed children が 0 件でも warning を追加するだけで plan を返します。delivery-rollup / child-complete の parent では、これは fail-open です。

    #299 / PR #315 で CHILD_MATERIALIZATION_PLAN_V2 と plan_child_materialization.py は導入済みですが、PR #315 時点の実装も C\d+-\d+ 前提でした。つまり #328 は「新規機能」ではなく、#299/#315 で導入された child materialization control-plane の欠陥修正です。

    AC2 はこう差し替えるべき

    現 AC2:

    AC2: `## Child Issues` 配下の checkbox/bullet candidate 数が parsed child 数を上回る場合、`parser_gap` として `human_escalation` を返す

    推奨差し替え:

    - [ ] AC2a: `plan_child_materialization.py` は `## Child Issues` セクション配下の checkbox/bullet candidate を parser 前に全件 inventory 化し、`candidate_count`, `parsed_count`, `parser_gap_report[]` を出力する
    - [ ] AC2b: `parser_gap_report[]` は `line_number`, `raw_line`, `gap_reason`, `suggested_repair`, `repair_confidence`, `minimal_context` を含む
    - [ ] AC2c: すべての parser_gap が `repair_confidence: high` の場合、`human_escalation` ではなく `issue-author task: materialize_children` に修復を委譲し、修復後に plan を再実行する
    - [ ] AC2d: 修復後の再実行で `candidate_count == parsed_count`、`parser_gap_report == []`、`required_issue_creations == []`、`required_subissue_registrations == []`、`parent_body_updates == []` になるまで `termination_reason: approved` にしない
    - [ ] AC2e: `human_escalation` は duplicate child_id / multiple issue refs / missing title / cross-owner issue / GitHub API 403・404・410・422 / `expected_match_count != 1` など、決定論的修復不能な gap に限定する

    要するに、parser_gap は停止理由ではなく、まず修復対象です。fail-closed の意味は「approved に進めない」であって、「即人間に投げる」ではありません。

    推奨 schema

    CHILD_MATERIALIZATION_PLAN_V2 に additive fields として足すか、破壊的変更なら V3 に上げるべきです。現行 schema は children, parent_body_updates, required_issue_creations, warnings 中心で、body_inventory / github_subissues_actual / parser_gap_report がありません。

    body_inventory:
      child_issues_section:
        found: true
        start_line: 42
        end_line: 71
        candidate_count: 4
        parsed_count: 4
      candidates:
        - line_number: 47
          raw_line: "- [ ] A: Issue body validator 実装 — #327"
          candidate_kind: checkbox
          parsed: true
          child_id: "A"
          title: "Issue body validator 実装"
          issue_ref: 327
          normalized_dedupe_key: "delivery-rollup:244:A"
    
    parser_gap_report:
      - line_number: 52
        raw_line: "- [ ] ???"
        gap_reason: missing_child_id | unsupported_child_id_format | missing_title | multiple_issue_refs | malformed_checkbox
        suggested_repair:
          action: normalize_child_line | create_issue | register_subissue | update_parent_body | human_escalation
          confidence: high | medium | low
          minimal_context:
            parent_issue: 244
            section: "Child Issues"
            raw_line: "..."

    修復可能な gap は例えば次の扱いにします。

    repairable_gap_rules:
      unsupported_child_id_format:
        example: "A: ..."
        action: parse_as_track_id
        human_escalation: false
    
      checkbox_without_issue_ref_but_title_present:
        action: create_issue
        human_escalation: false
    
      issue_ref_present_but_not_native_subissue:
        action: register_subissue_or_escalate_on_conflict
        human_escalation: false_if_same_owner_and_no_conflicting_parent
    
      stale_placeholder_with_issue_ref:
        action: update_parent_body
        human_escalation: false
    
    unsafe_gap_rules:
      duplicate_child_id: human_escalation
      multiple_issue_refs: human_escalation
      missing_title: human_escalation
      cross_owner_issue: human_escalation
      github_api_422: human_escalation

    issue-author 導線は必須

    現在の issue-author は「新規起票」「既存修正」「起票 + 即時修正」しか入力に持たず、task: materialize_children がありません。 #328 の AC6 は妥当ですが、単に task 名を足すだけでは不足です。parser_gap_report を受け取り、作成・Sub-issue 登録・parent body patch・再検証までを結果 schema で返す必要があります。

    task: materialize_children
    input:
      child_materialization_plan: CHILD_MATERIALIZATION_PLAN_V2
      parser_gap_report: []
      allowed_mutations:
        - create_missing_child_issue
        - register_existing_issue_as_subissue
        - patch_parent_body_line
    
    required_output:
      CHILD_MATERIALIZATION_RESULT_V2:
        status: ok | partial_failure | failed | human_escalation
        created_issues: []
        registered_subissues: []
        parent_body_updates_applied: []
        parser_gaps_resolved: []
        remaining_gaps: []
        replan:
          candidate_count: <int>
          parsed_count: <int>
          required_issue_creations: []
          required_subissue_registrations: []
          parent_body_updates: []

    ここで重要なのは、issue-author に raw parent body 全文を渡さないことです。Claude Code の subagent は独立 context を持ち、会話履歴・既読ファイル・すでに呼ばれた skill を自動では共有しません。したがって、orchestrator は parser_gap_report と CHILD_MATERIALIZATION_PLAN だけを渡し、修復に必要な最小コンテキストに限定すべきです。([Claude API Docs]1) Skills は SKILL.md に加えて scripts / references を同梱できるため、判定ロジックは script、mutation 境界は issue-author + skill に寄せる設計が適切です。([Claude API Docs]2)

    GitHub Sub-issues 実装上の注意

    人間コメントの「Issue 本文ではなく Sub-issue 読み取りから行った方が確実では」は半分正しいです。actual state は native Sub-issues read-back を正本にすべきですが、未起票 child は Sub-issues 側には存在しないため、desired state は body inventory から読む必要があります。

    GitHub REST API には sub-issues の list endpoint があり、parent issue の native child actual state を読めます。([GitHub Docs]3) 一方、sub-issue 追加は Issues write 権限が必要で、body に sub_issue_id が必須、かつ sub-issue は同一 repository owner 配下である必要があります。replace_parent もあるため、既存 parent を持つ child を勝手に移動しない guard が必要です。([GitHub Docs]3) 422 は validation failure または spam 判定でも返るため、自動リトライで押し切らず human_escalation に落とすべきです。([GitHub Docs]3)

    また、GitHub CLI の gh issue create は --body-file をサポートしますが、公式 manual 上の gh issue create flags には native sub-issue parent 指定は出ていません。([GitHub CLI]4) したがって #328 では、native sub-issue 登録は create_issue_txn.py --parent-issue の内部実装、または gh api / REST API 経由の read-back 付き transaction として明記すべきです。

    他の必須修正

    issue-refinement-loop は文書内矛盾が残っています。冒頭と Loop Structure は review-issue approve → 終了 と書いており、routing も approve → Step 5 です。 一方で後段には Step 4.5 の materialization gate があり、on_no_children: pass: true も残っています。 これは LLM にとって危険なので、routing 自体を次に固定すべきです。

    if status == ok and verdict == approve:
      proceed_to: Step 4.5
    
    Step 4.5:
      if parent_mode == delivery-rollup and closure_mode == child-complete:
        run materialization gate
        auto_repair_parser_gap_if_possible
        materialize_children
        replan
        if clean: proceed_to Step 5
        else: human_escalation
      else:
        proceed_to Step 5

    create-issue の delivery-rollup materialization は、plan 不在時に通常 create-issue フローへ fallback すると書いています。これは delivery-rollup context では fail-open です。 materialization_plan_unavailable として停止し、approved にしない設計に修正すべきです。

    edit-issue は CHILD_MATERIALIZATION_PLAN_V2 の parent_body_updates を使うと言いながら、手順では replace/with を参照しています。V2 正本は old_line/new_line/expected_match_count なので、このままだと parent body update が壊れます。

    追加すべき Verification Commands

    # #244 形状: ## Child Issues → ### 実装トラック → A/B/C/D bullets を fixture 化し、4 件 parse できること
    uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py \
      -k "child_section_subheading or abcd_track_ids" -v
    
    # candidate inventory と parser_gap_report が出ること
    uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py \
      -k "candidate_inventory or parser_gap_report" -v
    
    # repairable parser_gap が human_escalation ではなく suggested_repair を返すこと
    uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py \
      -k "repairable_parser_gap or suggested_repair" -v
    
    # unsafe gap のみ human_escalation になること
    uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py \
      -k "unsafe_parser_gap or duplicate_child_id or multiple_issue_refs" -v
    
    # approve routing が Step 4.5 を必ず通ること
    rg "approve.*Step 4\\.5|proceed_to: Step 4\\.5" .claude/skills/issue-refinement-loop/SKILL.md
    
    # approve 即終了の残存禁止
    ! rg "approve.*即終了|approve → 終了|approve -> 終了" .claude/skills/issue-refinement-loop/SKILL.md
    
    # issue-author が materialize_children と result schema を持つこと
    rg "task: materialize_children|CHILD_MATERIALIZATION_RESULT_V2" .claude/agents/issue-author.md
    
    # edit-issue が V2 patch fields を使い、replace/with を参照しないこと
    rg "old_line|new_line|expected_match_count" .claude/skills/edit-issue/SKILL.md
    ! rg "parent_body_updates\\[\\*\\]\\.(replace|with)" .claude/skills/edit-issue/SKILL.md

    最終提案

    #328 は parser_gap を human_escalation する Issue ではなく、次の Issue として再定義するのが妥当です。

    delivery-rollup parent の body desired state と native GitHub Sub-issue actual state を reconciliation し、parser_gap を AI-friendly repair plan として materialize し、修復不能な gap だけを human_escalation する。

    人間が見るべきなのは「修復不能な曖昧さ」だけです。A/B/C/D のような形式差分、### subheading 配下の候補、未起票 checkbox、body に #N があるが native sub-issue 未登録、placeholder drift は、決定論的に report → issue-author → create/edit/register → replan まで自走させるべきです。

  10. changed the title [-]実装: delivery-rollup child materialization を body/sub-issue reconciliation で fail-closed 化する[/-] [+]実装: delivery-rollup child materialization を parser_gap 自動修復付き reconciliation で fail-closed 化する[/+] on May 24, 2026
  11. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    edit-issue: Issue #328 本文更新

    変更理由

    OWNER(squne121) の anchor_comment_feedback に基づき、AC2 の設計を human_escalation 一辺倒から parser_gap 自動修復導線に全面再設計。

    変更セクション一覧

    セクション 変更内容
    タイトル body/sub-issue reconciliation → parser_gap 自動修復付き reconciliation に更新
    Outcome parser_gap 自動修復(repair_confidence: high → issue-author 委譲)の説明を追加
    Summary 根本原因 7 を追加(parser_gap 即 human_escalation の問題)
    Goal candidate inventory 化、repair_confidence high 時の委譲、修復不能 gap のみ human_escalation を明記
    In Scope plan_child_materialization.py に body_inventory / parser_gap_report[] / repairable_gap_rules / unsafe_gap_rules / 修復委譲ロジックを追加
    AC2 → AC2a-e human_escalation を削除し、candidate inventory / parser_gap_report schema / repairable 委譲 / 再実行収束条件 / unsafe gap 限定 に分解
    AC3 body_inventory(desired state)/ github_subissues_actual(actual state)の分離出力を明確化
    AC6 CHILD_MATERIALIZATION_RESULT_V2 の schema(status/created_issues/registered_subissues/parser_gaps_resolved/remaining_gaps/replan)を明記
    AC7 old_line/new_line/expected_match_count 使用・replace/with フィールド参照禁止を明確化
    Verification Commands AC2a-2b / AC2c / AC2e / AC5 routing / AC5 no-immediate-exit / AC6 schema / AC7 no-v1-refs の VC を追加

    Guard 結果

    all_passed: true
    guards:
      template_guard: pass
      outcome_quality_guard: pass
      diff_threshold: pass (orig=177 lines, new=198 lines)
      ac_vc_alignment: pass (7 AC / 7 VC)

    変更前バックアップ

    tmp/issue_328_backup_1779588649.md

  12. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: 完了 (2026-05-24T02:18:32Z)

    改善履歴

    変更 内容
    タイトル 「body/sub-issue reconciliation で fail-closed 化」→「parser_gap 自動修復付き reconciliation で fail-closed 化」
    AC2 差し替え human_escalation → AC2a-e(parser_gap_report inventory + repair_confidence 判定 + issue-author 委譲 + 再実行条件 + unsafe gap のみ human_escalation)
    AC3 強化 body_inventory / github_subissues_actual の分離出力を明確化
    AC6 強化 task: materialize_children + CHILD_MATERIALIZATION_RESULT_V2 の output schema を明記
    AC7 強化 old_line/new_line/expected_match_count の明示、replace/with 不使用を明記
    VC 追加 parser_gap_report / repair_confidence / AC5-AC7 各検証コマンドを追加
    In Scope 追加 body_inventory / parser_gap_report / repairable_gap_rules / unsafe_gap_rules / materialize_children 委譲ロジック

    事実確認(codebase-investigator による確認済み)

    次アクション

    issue-contract-review を起動して実装着手前の preflight を実施してください。

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      follow_up_issues: []
      note_only_observations: []
  13. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-24T02:42:00Z)

    • Outcome: delivery-rollup / child-complete parent の approve フローで A/B/C/D 形式含む全 child candidate が materialize されるまで termination_reason: approved に移行しない
    • Acceptance Criteria: AC1, AC2a, AC2b, AC2c, AC2d, AC2e, AC3, AC4, AC5, AC6, AC7, AC8(計 8 条件、全件 <!-- runtime-verification: true -->)
    • Verification Commands: pytest -k "abcd or c254", "candidate_inventory or parser_gap_report", "repairable_parser_gap or repair_confidence", "unsafe_parser_gap or duplicate_child_id or multiple_issue_refs", "inventory_split or subissues_actual", "register_subissue"; rg AC5/AC6/AC7/AC8; pnpm typecheck/lint/test/build
    • Allowed Paths: .claude/skills/create-issue/scripts/plan_child_materialization.py, .claude/skills/create-issue/tests/test_plan_child_materialization.py, .claude/skills/issue-refinement-loop/SKILL.md, .claude/agents/issue-author.md, .claude/skills/edit-issue/SKILL.md, docs/dev/agent-skill-boundaries.md
    • Worktree: .claude/worktrees/issue-328-delivery-rollup-child-materialization-pa
    • Branch: worktree-issue-328-delivery-rollup-child-materialization-pa
    • VC preflight: baseline fail = 10, 想定外 pass = 0, 実行不可 = 0

    VC preflight 詳細

    AC コマンド種別 exit 分類 判定
    AC1 pytest -k "abcd or c254" 0 unknown (c254 tests pass, abcd tests 未作成) ⚠️ warning
    AC2a/2b pytest -k "candidate_inventory or parser_gap_report" 5 expected_baseline_fail (テスト未作成) ✅ GO
    AC2c pytest -k "repairable_parser_gap or repair_confidence" 5 expected_baseline_fail ✅ GO
    AC2e pytest -k "unsafe_parser_gap or duplicate_child_id or multiple_issue_refs" 5 expected_baseline_fail ✅ GO
    AC3 pytest -k "inventory_split or subissues_actual" 5 expected_baseline_fail ✅ GO
    AC4 pytest -k "register_subissue" 5 expected_baseline_fail ✅ GO
    AC5a rg "approve.*Step 4.5..." SKILL.md 1 expected_baseline_fail (パターン未存在) ✅ GO
    AC5b ! rg "approve.*即終了..." SKILL.md 1 expected_baseline_fail (旧パターン現存) ✅ GO
    AC6 rg "task: materialize_children..." issue-author.md 1 expected_baseline_fail ✅ GO
    AC7a rg "old_line|new_line|expected_match_count" edit-issue/SKILL.md 0 unknown (new_lines が false positive) ⚠️ warning
    AC7b ! rg "parent_body_updates[*].(replace|with)" edit-issue/SKILL.md 1 expected_baseline_fail (V1 refs 現存) ✅ GO
    AC8 rg "partial_failure|materialization_failed..." SKILL.md 1 expected_baseline_fail ✅ GO
    全体 pnpm typecheck/lint/test/build 0 expected pass (TS/JS 変更なし) ✅ GO

    ⚠️ Warning: AC1 VC — -k "abcd or c254" が baseline で exit 0(c254 テストが通過、abcd テストは未作成のため選択なし)。A:/B:/C:/D: 形式テストは実装中に追加が必要。
    ⚠️ Warning: AC7a VC — rg "new_line" が new_lines (ISSUE_EDIT_RESULT_V1 の別フィールド) に substring マッチ。V2 schema フィールドの追加は実装で確認すること。

    CONTRACT_REVIEW_RESULT_V1

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: 2026-05-24T02:42:00Z
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/328
      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: 10
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          classifications:
            - ac: AC1
              command: "uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py -k 'abcd or c254' -v"
              exit_code: 0
              category: unknown
              confidence: medium
              evidence:
                stdout_excerpt: "3 passed (c254 tests only), abcd: 0 selected"
                stderr_excerpt: ""
              decision: human_judgment
            - ac: AC2a_2b
              command: "uv run pytest ... -k 'candidate_inventory or parser_gap_report' -v"
              exit_code: 5
              category: expected_baseline_fail
              confidence: high
              evidence:
                stdout_excerpt: "61 deselected in 0.02s"
                stderr_excerpt: ""
              decision: go
            - ac: AC2c
              command: "uv run pytest ... -k 'repairable_parser_gap or repair_confidence' -v"
              exit_code: 5
              category: expected_baseline_fail
              confidence: high
              evidence: {stdout_excerpt: "61 deselected", stderr_excerpt: ""}
              decision: go
            - ac: AC2e
              command: "uv run pytest ... -k 'unsafe_parser_gap or duplicate_child_id or multiple_issue_refs' -v"
              exit_code: 5
              category: expected_baseline_fail
              confidence: high
              evidence: {stdout_excerpt: "61 deselected", stderr_excerpt: ""}
              decision: go
            - ac: AC3
              command: "uv run pytest ... -k 'inventory_split or subissues_actual' -v"
              exit_code: 5
              category: expected_baseline_fail
              confidence: high
              evidence: {stdout_excerpt: "61 deselected", stderr_excerpt: ""}
              decision: go
            - ac: AC4
              command: "uv run pytest ... -k 'register_subissue' -v"
              exit_code: 5
              category: expected_baseline_fail
              confidence: high
              evidence: {stdout_excerpt: "61 deselected", stderr_excerpt: ""}
              decision: go
            - ac: AC5a
              command: "rg 'approve.*Step 4.5|...' .claude/skills/issue-refinement-loop/SKILL.md"
              exit_code: 1
              category: expected_baseline_fail
              confidence: high
              evidence: {stdout_excerpt: "", stderr_excerpt: ""}
              decision: go
            - ac: AC5b
              command: "! rg 'approve.*即終了|approve → 終了|approve -> 終了' .claude/skills/issue-refinement-loop/SKILL.md"
              exit_code: 1
              category: expected_baseline_fail
              confidence: high
              evidence: {stdout_excerpt: "old pattern exists", stderr_excerpt: ""}
              decision: go
            - ac: AC6
              command: "rg 'task: materialize_children|CHILD_MATERIALIZATION_RESULT_V2' .claude/agents/issue-author.md"
              exit_code: 1
              category: expected_baseline_fail
              confidence: high
              evidence: {stdout_excerpt: "", stderr_excerpt: ""}
              decision: go
            - ac: AC7a
              command: "rg 'old_line|new_line|expected_match_count' .claude/skills/edit-issue/SKILL.md"
              exit_code: 0
              category: unknown
              confidence: medium
              evidence:
                stdout_excerpt: "new_lines: <int> (ISSUE_EDIT_RESULT_V1 の別フィールドに substring マッチ)"
                stderr_excerpt: ""
              decision: human_judgment
            - ac: AC7b
              command: "! rg 'parent_body_updates[*].(replace|with)' .claude/skills/edit-issue/SKILL.md"
              exit_code: 1
              category: expected_baseline_fail
              confidence: high
              evidence: {stdout_excerpt: "V1 refs exist at line 305", stderr_excerpt: ""}
              decision: go
            - ac: AC8
              command: "rg 'partial_failure|materialization_failed|materialization.*human_escalation' .claude/skills/issue-refinement-loop/SKILL.md"
              exit_code: 1
              category: expected_baseline_fail
              confidence: high
              evidence: {stdout_excerpt: "", stderr_excerpt: ""}
              decision: go
        ac_verifiability: pass
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings:
        - "AC1 VC: pytest -k 'abcd or c254' exits 0 at baseline (c254 tests pass; abcd tests TBD). Implementation must add abcd tests."
        - "AC7a VC: rg 'new_line' matches 'new_lines' (false positive). Verify V2 schema fields added in delivery-rollup-parent-update section after implementation."
        - "Runtime Verification Applicability: decision=immediate but applicable_acs/env/skip-rules not explicit. Pure pytest tests assumed vacuously satisfied."
  14. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 実装完了 (2026-05-24T02:50:54Z)

    Draft PR: #341

    検証結果

    • uv run pytest .claude/skills/create-issue/tests/test_plan_child_materialization.py — 87 tests passed
    • uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py — 21 tests passed
    • pnpm typecheck / lint / test / build — all PASS

    AC 対応状況

    AC 状態
    AC1 A/B/C/D regex DONE
    AC2 BodyInventory + parser_gap DONE
    AC3 body_inventory / github_subissues_actual 分離 DONE
    AC4 register_subissue_or_human_escalation DONE
    AC5 approve → Step 4.5 mandatory gate DONE
    AC6 issue-author materialize_children + CHILD_MATERIALIZATION_RESULT_V2 DONE
    AC7 edit-issue V1 replace/with → V2 old_line/new_line DONE
    AC8 partial_failure/materialization_failed → human_escalation routing DONE
    IMPLEMENT_RESULT_V1:
      status: success
      issue_number: 328
      pr_url: https://github.com/squne121/loop-protocol/pull/341
      worktree: .claude/worktrees/issue-328-delivery-rollup-child-materialization-pa
      branch: worktree-issue-328-delivery-rollup-child-materialization-pa
      verification:
        pytest_plan_child_materialization: 87 passed
        pytest_model_routing: 21 passed
        pnpm_typecheck: PASS
        pnpm_lint: PASS
        pnpm_test: 25 passed
        pnpm_build: PASS
      ac_coverage:
        AC1: done
        AC2: done
        AC3: done
        AC4: done
        AC5: done
        AC6: done
        AC7: done
        AC8: done
  15. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-05-24T02:59:30Z)

    変更サマリ

    ファイル 変更内容
    plan_child_materialization.py _CHILD_LINE_RE に A/B/C/D 形式追加、BodyInventory / ParserGapEntry 追加、reconcile ロジック
    test_plan_child_materialization.py AC1-AC4 テスト追加 (87 tests 全 pass)
    issue-refinement-loop/SKILL.md approve → Step 4.5 (mandatory gate) → Step 5 に統一、immediate-exit 削除
    issue-author.md task: materialize_children + CHILD_MATERIALIZATION_RESULT_V2 追加
    edit-issue/SKILL.md V1 replace/with → V2 old_line/new_line/expected_match_count
    agent-skill-boundaries.md CHILD_MATERIALIZATION_RESULT_V2 スキーマ正本追加
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      follow_up_issues: []
      note_only_observations: []
    ISSUE_SCOPE_ROLLUP_DECISION_V2:
      schema_version: 2
      recorded_at: "2026-05-24T02:42:30Z"
      decision: skipped
      skipped_reason: "confidence: high 候補なし。medium 候補はすべて CLOSED 済みまたは別 tracker の child issue"
      executed_actions: []
      candidates_reviewed:
        - kind: issue
          number: 332
          confidence: medium
          suggested_action: amend_current_issue
          final_decision: deferred
          rejection_reason: null
        - kind: issue
          number: 329
          confidence: medium
          suggested_action: amend_current_issue
          final_decision: deferred
          rejection_reason: null
        - kind: issue
          number: 316
          confidence: medium
          state: CLOSED
          suggested_action: human_review_required
          final_decision: rejected
          rejection_reason: CLOSED issue
        - kind: issue
          number: 303
          confidence: medium
          state: CLOSED
          suggested_action: human_review_required
          final_decision: rejected
          rejection_reason: CLOSED issue
  16. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    結論

    Issue #328 の問題設定は妥当です。#244 の ## Child Issues には A/B/C/D の子 Issue 群が明記されており、#327/#329/#330/#331 も正式に起票済みですが、従来の plan_child_materialization.py が C\d+-\d+ 形式しか読めないため、本文上の desired state と GitHub native Sub-issues の actual state が乖離する、という診断は正しいです。([GitHub]1)

    ただし、対応 PR #341 は最終的に APPROVE になっていますが、敵対的レビューとしては このまま merge 可とは見ません。理由は「テストは通っているが、実 #244 形式・GitHub Sub-issues API の失敗系・schema enum の整合性にまだ穴がある」ためです。

    主要ブロッカー

    1. A/B/C/D 対応が広すぎる

    Issue #328 の scope は、A/B/C/D トラック ID と既存 C254-N 形式の reconciliation です。Out of Scope でも一般的な任意 child id 形式への拡張は明示的に外されています。([GitHub]2)

    PR #341 の patch では _CHILD_LINE_RE が C\d+-\d+|[A-Z] を許容しており、A/B/C/D ではなく任意の単一大文字を child_id として受けます。これは設計スコープを超え、将来 NOTE:, Q:, X: のような本文要素を child candidate と誤認するリスクがあります。

    修正案:
    (?P<child_id>C\d+-\d+|[A-D]) に限定する。将来拡張したいなら、Issue 本文の Machine-Readable Contract に allowed_child_id_patterns を明示するまでは一般化しない。


    2. 実 #244 のネスト bullet を parser_gap と誤認する可能性が高い

    #244 の child list は単純な A/B/C/D 4 行だけではなく、各 child の下に absorbs / output / validates / optional などのネスト bullet を含んでいます。([GitHub]1)

    一方、PR #341 の _is_candidate_line() は ^[-*] で始まる行を child candidate と見なす構造です。つまり、実 #244 のネスト bullet まで candidate_count に入り、malformed_checkbox などの低 confidence parser_gap として human_escalation を誘発する可能性があります。PR の追加 fixture は A/B/C/D の平坦な4行だけで、実 #244 のネスト構造を再現していません。

    修正案:
    child candidate は「トップレベル child row」だけに限定する。少なくとも次を条件にするべきです。

    # 例: 先頭 0〜2 spaces のトップレベル bullet のみ
    ^\s{0,2}[-*]\s+(?:\[[ xX]?\]\s+)?(?:#\d+\s*[—–-]\s*)?(?:C\d+-\d+|[A-D])(?:[::]\s+|\s+[—–-]\s+).+

    ネスト bullet は ignored_child_metadata_lines のような別 inventory に入れ、parser_gap_report には入れない方がよいです。


    3. “repairable parser gap” の統合テストが弱い

    Issue #328 は、修復可能な parser_gap は issue-author に渡して自動修復し、修復不能なものだけ human_escalation にする設計です。AC2 でも parser_gap_report、repair_confidence、high-confidence repair delegation が求められています。([GitHub]2)

    しかし PR patch 上の _CHILD_LINE_RE は [:\s]+ を許容するため、- [ ] A Issue body validator のような「コロン欠落」の行が、そもそも parser_gap にならず普通に parse される可能性があります。追加テストは _classify_parser_gap() を直接呼ぶものが中心で、build_plan() 経由で candidate → parse失敗 → high repair の統合経路を十分に証明していません。

    修正案:
    A/B/C/D は A: 形式を必須にする。A Title は parsed_count=0 / candidate_count=1 / repair_confidence=high / suggested_repair="- [ ] A: Title" になる統合テストを追加する。


    4. GitHub Sub-issues API 失敗時に fail-closed できていない

    GitHub の Sub-issues REST API には list/add endpoints があり、list は per_page/page pagination を持ち、404/410 を返し得ます。add は sub_issue_id が必須で、Issues write permission が必要、403/404/410/422 と secondary rate limit があり得ます。([GitHub Docs]3)

    PR patch の _fetch_subissues_actual() は gh api 失敗時に [] を返す設計です。これは危険です。[] が「API は成功し、native Sub-issues が0件」と「403/404/410/認証失敗/rate limit/network errorで読めなかった」を区別できません。Issue #328 の Stop Conditions は GitHub API の 403/404/410/422 を human_escalation として扱う方向なので、ここは fail-open ではなく fail-closed にすべきです。([GitHub]2)

    修正案:
    list[dict] ではなく、次のような状態付き readback にする。

    @dataclass
    class SubissuesReadback:
        status: Literal["ok", "api_error", "forbidden", "not_found", "gone", "rate_limited"]
        items: list[dict]
        http_status: int | None
        stderr: str | None
        complete: bool

    complete == false の場合は register_subissue_or_human_escalation を出さず、human_escalation に寄せる。actual state が不明な状態で mutation plan を作らない。


    5. native Sub-issue 登録の mutation contract が粗い

    Issue #299 では plan_child_materialization.py は read-only script で、mutation は create/edit 側に委譲する設計でした。([GitHub]4)

    PR #341 の issue-author.md は register_subissue_or_human_escalation を追加していますが、実際の GitHub REST add endpoint は issue_number ではなく sub_issue_id を body parameter に要求します。つまり #327 の number だけでは登録できず、対象 issue の REST id を取得してから POST /repos/{owner}/{repo}/issues/{parent}/sub_issues する必要があります。([GitHub Docs]3)

    修正案:
    issue-author の contract に最低限これを追加する。

    subissue_registration:
      preconditions:
        - child issue number is resolved to repository-local REST id
        - parent issue actual subissues readback status is ok
        - child belongs to same repository owner
      mutation:
        - gh api --method POST repos/{repo}/issues/{parent}/sub_issues -f sub_issue_id=<child_issue_id>
      postconditions:
        - re-read GET repos/{repo}/issues/{parent}/sub_issues
        - child issue number appears exactly once
      failure_routing:
        403: human_escalation
        404: human_escalation
        410: human_escalation
        422: human_escalation
        rate_limit: human_escalation

    6. CHILD_MATERIALIZATION_RESULT_V2.status の enum が Issue #328 と PR 実装でズレている

    Issue #328 の AC6 は status: ok | partial_failure | failed | human_escalation を求めています。([GitHub]2)

    PR patch 側の issue-author.md では success | partial_failure | materialization_failed | materialization_human_escalation になっています。これは軽微な表記差ではなく、issue-refinement-loop 側の Step 4.5 / AC8 ルーティングで consumer が見る enum を曖昧にします。

    修正案:
    どちらかに統一する。個人的には Issue 側の短い enum を採用し、詳細理由は reason / errors[] に分離する方がよいです。

    status: ok | partial_failure | failed | human_escalation
    reason: null | string
    created_issues: []
    registered_subissues: []
    updated_parent: true | false
    escalation_items: []
    errors: []

    7. GitHub の hidden/Bidi Unicode warning を無視している

    PR ページ上で「hidden or bidirectional Unicode text」警告が表示されています。PR #341 は parser / workflow / agent spec を扱うため、Bidi 制御文字や不可視文字はレビュー対象として低く扱うべきではありません。([GitHub]5)

    修正案:
    検証コマンドに不可視制御文字 scan を追加する。

    python - <<'PY'
    from pathlib import Path
    import unicodedata
    
    targets = [
        ".claude/skills/create-issue/scripts/plan_child_materialization.py",
        ".claude/skills/create-issue/tests/test_plan_child_materialization.py",
        ".claude/agents/issue-author.md",
        ".claude/skills/issue-refinement-loop/SKILL.md",
        ".claude/skills/edit-issue/SKILL.md",
    ]
    
    bad = []
    for p in targets:
        text = Path(p).read_text(encoding="utf-8")
        for i, ch in enumerate(text):
            cat = unicodedata.category(ch)
            name = unicodedata.name(ch, "")
            if cat in {"Cf", "Cc"} and ch not in "\n\r\t":
                bad.append((p, i, hex(ord(ch)), name))
    
    if bad:
        for item in bad:
            print(item)
        raise SystemExit(1)
    PY

    高品質化方針

    Issue #328 自体は「desired body inventory」「actual native subissues」「mutation plan」「human escalation」を分ける方向で正しいです。問題は PR #341 がまだ「本文 parser の都合」と「GitHub API 実状態」を安全に分離しきれていない点です。

    実装は次の4層に分けるのが安全です。

    1. BodyInventory
      ## Child Issues からトップレベル child row だけを抽出する。ネスト bullet は child metadata として無視または別管理する。

    2. ParserGapReport
      child row らしいが parse 不能な行だけを gap にする。A/B/C/D のコロン欠落などは high-confidence repair、複数 issue refs / duplicate id / title欠落は human_escalation。

    3. SubissuesReadback
      GitHub native Sub-issues API の結果を ok と api_error で明確に分ける。[] を error sentinel に使わない。pagination を処理する。

    4. MaterializationResult
      create issue、register subissue、parent body update を分離し、各 mutation 後に read-after-write する。最終結果 enum は single source of truth にする。

    PR に貼るならこのコメント

    REQUEST_CHANGES
    
    Issue #328 の方向性は妥当ですが、PR #341 はまだ fail-closed reconciliation として不足があります。
    
    Blockers:
    
    1. `_CHILD_LINE_RE` が `C\d+-\d+|[A-Z]` を許容しており、Issue #328 の scope である A/B/C/D を超えて任意の単一大文字を child_id として受けます。`[A-D]` に限定してください。
    
    2. `_is_candidate_line()` が `^[-*]` bullet を広く candidate 扱いするため、実 #244 の `absorbs` / `output` / `validates` 等のネスト bullet を parser_gap と誤認する可能性があります。実 #244 形式の fixture を追加し、トップレベル child row のみ candidate_count に含めるよう修正してください。
    
    3. `- [ ] A Title` のような A/B/C/D コロン欠落は high-confidence repair になるべきですが、現在の `[:\s]+` では普通に parse される可能性があります。`build_plan()` 経由の統合テストで parser_gap → suggested_repair を確認してください。
    
    4. `_fetch_subissues_actual()` が API failure と valid empty list をどちらも `[]` に潰しています。403/404/410/422/rate limit/network error は human_escalation にする必要があり、actual readback 不完全な状態で register mutation plan を出すべきではありません。
    
    5. GitHub REST add sub-issue は `sub_issue_id` が必須です。`#N` の issue number から REST issue id を解決する precondition と、POST 後の read-after-write postcondition を `issue-author` contract に明記してください。
    
    6. `CHILD_MATERIALIZATION_RESULT_V2.status` が Issue #328 AC6 の `ok|partial_failure|failed|human_escalation` と PR 側の `success|partial_failure|materialization_failed|materialization_human_escalation` で不一致です。consumer contract を統一してください。
    
    7. GitHub page の hidden/Bidi Unicode warning を受け、対象ファイルに不可視制御文字 scan を verification に追加してください。

    最終判定は Request Changes。CI と既存 pytest が通っていることは評価できますが、現在の test fixture は実 #244 のネスト構造と API 失敗系を十分に殺せていません。

  17. added a commit that references this issue on May 24, 2026
  18. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    implement-issue: iteration 2 修正完了 (2026-05-24T03:17:40Z)

    修正サマリ (fix_delta iteration 2)

    blocker 対応
    blocker_1 _CHILD_LINE_RE_ABCD を [A-Z] → [A-D] に限定
    blocker_2 _is_candidate_line() で 2+ leading spaces を nested として除外
    blocker_3 A/B/C/D コロン必須化 + build_plan() 経由の統合テスト追加
    blocker_4 SubissuesReadback dataclass 導入 (fail-closed: 403/404/410/422/rate_limit → human_escalation)
    blocker_5 issue-author.md に subissue_registration contract 追加
    blocker_6 CHILD_MATERIALIZATION_RESULT_V2.status enum を `ok
    blocker_7 hidden/Bidi Unicode scan テスト追加

    Verification

    • pytest: 100/100 passed (13 new tests added)
    • pnpm typecheck: pass
    • pnpm lint: pass
    • pnpm test: 25/25 passed
    • pnpm build: pass
  19. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-05-24T03:22:37Z)

    iteration 履歴

    iter ステップ 結果
    0 implementation + verification + pr-review REQUEST_CHANGES (Schema Change Applicability / Safety Claim Matrix 欠落)
    1 PR 本文修正 + pr-review APPROVE → 人間レビューで REQUEST_CHANGES (7 blockers)
    2 7 blockers 修正 + verification + pr-review APPROVE

    iteration 2 修正内容

    # ブロッカー 対応
    1 _CHILD_LINE_RE が [A-Z] を許容 [A-D] に限定
    2 ネスト bullet を candidate 誤認 トップレベル child row のみ候補化、実 #244 fixture 追加
    3 A/B/C/D コロン欠落の統合テスト不足 build_plan() 経由 high-repair 統合テスト追加
    4 _fetch_subissues_actual() fail-open SubissuesReadback 型導入、API error を fail-closed
    5 sub_issue_id 取得・read-after-write 未定義 subissue_registration contract 追加
    6 status enum 不一致 ok|partial_failure|failed|human_escalation に統一
    7 Bidi Unicode 警告 不可視制御文字 scan テスト追加
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      follow_up_issues: []
      note_only_observations: []
    ISSUE_SCOPE_ROLLUP_DECISION_V2:
      schema_version: 2
      recorded_at: "2026-05-24T02:42:30Z"
      decision: skipped
      skipped_reason: "confidence: high 候補なし。medium 候補はすべて CLOSED 済みまたは別 tracker の child issue"
      executed_actions: []
      candidates_reviewed:
        - kind: issue
          number: 332
          confidence: medium
          suggested_action: amend_current_issue
          final_decision: deferred
        - kind: issue
          number: 329
          confidence: medium
          suggested_action: amend_current_issue
          final_decision: deferred
        - kind: issue
          number: 316
          confidence: medium
          state: CLOSED
          final_decision: rejected
          rejection_reason: CLOSED issue
        - kind: issue
          number: 303
          confidence: medium
          state: CLOSED
          final_decision: rejected
          rejection_reason: CLOSED issue
  20. added a commit that references this issue on May 24, 2026
  21. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    post-merge-cleanup: 完了 (2026-05-24T03:29:38Z)

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      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

    area/ai-opskind/implementationworkflow

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions