Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "guard-issue-body.py の template_guard を false-positive にする fence 誤ペアリング不具合を修正する"
change_kind: codeParent Issue
none
Parent Goal Ref
- Goal: guard-issue-body.py の
_strip_fenced_code_blocks()が Issue 本文の実 Markdown fence 境界を正しく識別し、template_guard 等のガードが false-positive を出さない状態にする - Desired Destination: なし(単独改善)
Current Validated Scope
.claude/skills/edit-issue/scripts/guard-issue-body.pyの_FENCED_CODE_BLOCK_REを削除し、_strip_fenced_code_blocks()は既存.claude/skills/create-issue/scripts/prose_boundary_policy.py::iter_markdown_blocks()のBLOCK_KIND_CODE_FENCEだけを除外する薄い consumer に変更する(既存 sibling-skill import pattern を使用)。共有 parser は変更しない。.claude/skills/edit-issue/tests/test_guard_issue_body.pyにguard_template()consumer 経由の回帰テストを追加する。Allowed Paths はこの2ファイルに固定する。
Remaining Parent Gaps
なし
Outcome
guard_template() が共有 Markdown block parser に委譲して code fence 内の見出しのみを除外し、prose 内の不揃いな backtick 列と後続の実 VC fence を誤ペアリングせず、実在する必須見出しを検出できる状態。独自 fence regex/scanner を残さず、既存テストと追加の consumer-level 回帰テストが PASS する。
Runtime Verification Applicability
- decision: not_applicable
- reason: 静的なテキスト処理ロジック(正規表現/文字列解析)の修正であり、pytest による静的検証のみで完結するため
Background
Issue #2788 の本文編集時、guard-issue-body.py の _strip_fenced_code_blocks() の独自 _FENCED_CODE_BLOCK_RE(現在の HEAD でも非行指向の non-greedy regex と .sub('', text) が残る)が prose の backtick 列と後続の実 VC bash fence を誤ペアリングし、template_guard.missing_sections が実在する見出しを false-positive で列挙して transaction を妨げた。
元の #2794 Background は #2788 に「バックティック3文字 + bash + バックティック1文字」という不揃いな表現があったと記録している。ただし #2788 の当時の raw 行の原本は現時点で取得・検証できていない(現行 #2788 本文は修正済みで、取得できた timeline API / 保存本文にも旧 raw 行はない)。テストでは #2794 の既存記録に基づく形を literal fixture にし、当時の実 raw bytes と同一だったと断定しない。原本が取得できた場合だけ比較して差異を評価する。
fence 境界の既存 SSOT は .claude/skills/create-issue/scripts/prose_boundary_policy.py::iter_markdown_blocks()(#659 / PR #669)。GFM の opener/closer は先頭 0–3 spaces、同種かつ適切な長さの delimiter、backtick opener の info string に backtick を含めない等を既に処理する。別 consumer の委譲 precedent は PR #1717。anchor-comment 専用 scanner の 0–8 spaces / blockquote 処理は本 guard の Markdown 見出し検出に転用しない。共有 parser の golden grammar corpus は既存 test_prose_boundary_policy.py が担う。
In Scope
_FENCED_CODE_BLOCK_REを削除し、_strip_fenced_code_blocks()をprose_boundary_policy.iter_markdown_blocks()が返す block のうちBLOCK_KIND_CODE_FENCEのみ除外して非 fence block を連結する薄い adapter にする。import wiring は repo の既存 sibling-skill pattern に合わせる。guard_template()の見出し判定自体は維持する。guard_template()に対し、孤立 backtick の行頭/inline・空白位置・info string 内 backtick、後続の正しい bash fence と見出し、4-backtick 中の3-backtick、tilde fence、4-space indented non-fence、EOF 未閉 fence、正常 fenced heading の除外と後続実見出しの保持を代表ケースとしてテストする。共有 parser の全 golden corpus はコピーしない。- guard test で共有 parser への委譲と独自 regex 撤去も固定する。
Out of Scope
prose_boundary_policy.py本体・その grammar の変更、Markdown parser 全体の刷新、別の fence scanner/toggle/regex の追加issue_body_validation/ac_vc_alignment等の別 guard の解析・意味論変更、および anchor-comment 専用 scanner の変更・その 0–8 spaces 意味論の流用- 実装: guard-issue-body.py の AC/VC alignment を共有パーサーへ統合し VC grammar parity/LP010/authoring reference を同期する #1719(AC/VC alignment)、調査: canonical Markdown section extractor の重複実装を棚卸しし parser drift 再発箇所を特定する #2784(research-only parser drift inventory)、PR fix: baseline_vc_preflight の通常実行を shared VC parser に統一する #2796 の別スコープ実装、新規 follow-up Issue の起票
Acceptance Criteria
- AC1: 既存 実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 Background の記録(U+0060 3文字 +
bash+ U+0060 1文字の不揃い表現)に基づく literal fixture をテストファイル内に生 Markdown として固定する。行頭と inline、先頭の空白数、info string 内の末尾 backtick の位置を fixture 文字列そのものと assertion で検証し、直後に置いた正しい VC bash fence と実在する## Outcome/## In Scope等の見出しをguard_template()が missing と誤判定しない。実装: baseline_vc_preflight の通常実行を shared VC parser に統一し説明用 bash 行の誤実行候補化を防ぐ #2788 の旧 raw 行が取得できた場合だけ原本との一致/差異を検証し、未取得のまま歴史的 bytes の一致を主張しない。 - AC2:
guard_template()経由の代表ケースで、4-backtick fence 中の3-backtick、tilde fence、4-space-indented non-fence、EOF 未閉 fence、正常な fence 内の偽見出しを除外し、その後にある実見出しは維持する。行頭 0–3 spaces と 4 spaces の差、backtick opener の info string 内 backtick 禁止、closer の種類/長さは共有 parser の意味論を継承し、独自 0–8 spaces scanner を導入しない。 - AC3:
_FENCED_CODE_BLOCK_REの定義/使用が削除され、_strip_fenced_code_blocks()が_pbp.iter_markdown_blocks()のBLOCK_KIND_CODE_FENCEだけを除外する薄い consumer であることを新規 guard test assertion で確認する。既存 guard test 全件と共有 parser の focused fence tests が PASS する(共有 parser の golden corpus は複製しない)。
Verification Commands
# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/edit-issue/tests/test_guard_issue_body.py::TestGuardTemplate::test_orphan_backtick_shared_parser_adapter -q
# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/edit-issue/tests/test_guard_issue_body.py::TestGuardTemplate::test_shared_parser_fence_boundary_cases -q
# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/edit-issue/tests/test_guard_issue_body.py::TestGuardTemplate::test_shared_parser_delegation_without_regex -q
$ uv run --locked pytest .claude/skills/edit-issue/tests/test_guard_issue_body.py -q
$ uv run --locked pytest .claude/skills/create-issue/scripts/tests/test_prose_boundary_policy.py -k fence -qAllowed Paths
.claude/skills/edit-issue/scripts/guard-issue-body.py.claude/skills/edit-issue/tests/test_guard_issue_body.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- Allowed Paths 外の変更、共有 parser の grammar 修正、新 parser/security gate、別 guard の変更が必要と実証された場合は停止し scope extension を owner に確認する(この refinement では新規 Issue を起票しない)
- 固定契約(キー集合・スキーマ・型定義)の変更、外部サービス利用・権限昇格・既存テスト大規模改変が必要な場合は停止する
- 実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 に記録された不揃い backtick の literal fixture で再現できず、実装: baseline_vc_preflight の通常実行を shared VC parser に統一し説明用 bash 行の誤実行候補化を防ぐ #2788 の当時の raw 行も得られないため適切な再現条件が確定できない場合は停止して根拠を再調査する。推測の fixture で false-green としない
- 実装: guard-issue-body.py の AC/VC alignment を共有パーサーへ統合し VC grammar parity/LP010/authoring reference を同期する #1719 の live PR/HEAD 状態は実装開始時に再確認する。同じファイルを扱うだけでは停止せず、実際の変更衝突や scope extension が判明した場合に調整する
Required Skills
なし
Required Design References
docs/dev/workflow.md.claude/skills/create-issue/scripts/prose_boundary_policy.py(既存 Markdown block SSOT、閲覧のみ).claude/skills/create-issue/scripts/tests/test_prose_boundary_policy.py(既存 grammar tests、閲覧/実行のみ)
Delivery Rule
1 Issue = 1 PRとする- 作業は専用 worktree で行う
- Draft PR を既定とする
Notes for Reviewer
- OWNER direct human feedback: 実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 (comment) (URL から live 取得)。実装方針を「regex → 別 scanner」から「既存 parser SSOT の consumer」へ改訂した。
- 本 Issue は 実装: baseline_vc_preflight の通常実行を shared VC parser に統一し説明用 bash 行の誤実行候補化を防ぐ #2788 の refinement 作業中に発見した独立の follow-up。実装: baseline_vc_preflight の通常実行を shared VC parser に統一し説明用 bash 行の誤実行候補化を防ぐ #2788 の旧 raw 行は未検証であり、AC1 は本 Issue の記録に基づく literal fixture を要求する。
- dedupe_key:
follow-up:squne121/loop-protocol:issues/2788:guard-issue-body-fence-pairing-prose-backtick - Scope Collision (C1): 実装: guard-issue-body.py の AC/VC alignment を共有パーサーへ統合し VC grammar parity/LP010/authoring reference を同期する #1719 は
ac_vc_alignmentguard の別 concern(実装着手前に live PR/HEAD の衝突を確認するが単なる同一ファイルでは停止しない)。調査: canonical Markdown section extractor の重複実装を棚卸しし parser drift 再発箇所を特定する #2784 は research-only inventory で依存なし。PR fix: baseline_vc_preflight の通常実行を shared VC parser に統一する #2796 は merged だが本 regex consumer は未変更。両関数の意味論を混ぜない。 _anchor_scope_reframe_fence_present()の独自 scanner への統合や重複実装判断は不要。共有 SSOT に不足が実証され、現行2ファイルを越える場合のみ Stop Conditions に従う。
Activity
squne121 commentedon Sep 27, 2026
敵対的レビュー結果
現状の #2794 は、目的自体は妥当ですが、実装契約を修正してから着手すべきです。 最大の問題は、既に repository 内に fence segmentation の SSOT が存在するのに、Issue が別の line-oriented scanner を新設する方向へ実装者を誘導していることです。
確認時点の
mainでは、対象コードはまだre.compile(r'```.*?```', re.DOTALL)のままで、報告された failure class は残っています。[guard-issue-body.py on main](https://github.com/squne121/loop-protocol/blob/main/.claude/skills/edit-issue/scripts/guard-issue-body.py?utm_source=chatgpt.com)P1 / Blocker — 新しい fence scanner を作る契約が、既存 SSOT と衝突しています。
実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 は
_strip_fenced_code_blocks()を独自の line-oriented scanner に置き換え、_anchor_scope_reframe_fence_present()を参考実装にするよう指定しています。ところが repository には既に.claude/skills/create-issue/scripts/prose_boundary_policy.py::iter_markdown_blocks()があり、これはまさに「独自 non-greedy fence regex による parser drift をなくす」ために 実装: split_markdown_blocks の GFM 準拠セグメンテーションを prose_boundary_policy SSOT へ委譲 #659 / PR feat(#659): prose_boundary_policy に GFM 準拠 iter_markdown_blocks SSOT を追加し split_markdown_blocks を委譲 #669 で導入された共有 authority です。[Issue #659](https://github.com/squne121/loop-protocol/issues/659?utm_source=chatgpt.com) [PR #669](https://github.com/squne121/loop-protocol/pull/669?utm_source=chatgpt.com)さらに PR fix: validate_issue_body.py の LP010 が AC/VC 番号不一致を検出できない偽陰性を修正する #1717 でも、別 consumer が独自 fence scanner を持ったことに対するレビュー finding として、
prose_boundary_policy.iter_markdown_blocks()への委譲が要求され、最終的にその形で着地しています。[PR #1717](https://github.com/squne121/loop-protocol/pull/1717?utm_source=chatgpt.com)影響: 実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 を現契約のまま実装すると、今回の1ケースは直っても、同じ Markdown semantics を2箇所で再実装することになり、将来また opener/closer、tilde、長さ、indent の drift が発生します。
最小修正:
_FENCED_CODE_BLOCK_REは置換ではなく削除し、_strip_fenced_code_blocks()をiter_markdown_blocks()の薄い consumer にしてください。Allowed Paths は現在の2ファイルのままで実現できます。prose_boundary_policy.py自体を変更する必要はありません。P1 — Issue に記載された「0–8 space indent」は GFM の fence semantics ではありません。
実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 が参考にしている anchor-comment 用 scanner は、reference 上「0–8 spaces」「nested blockquote」などを扱う用途固有の scanner です。一方、GitHub Flavored Markdown の fenced code block は opener/closer とも 最大3 spaces の indent が許容され、4 spaces 以上は通常の fenced opener として扱われません。また backtick opener の info string に backtick 自体を含めることは禁止されています。:chatgpt-content-reference{index="4"}
今回問題になった「
```bashにさらに孤立 backtick が付く」形では、この info string 内 backtick 禁止 が重要です。既存prose_boundary_policyはこの条件も既に実装しています。影響: 0–8 space をそのまま持ち込むと、4-space indented code 中の backtick 列を fence として誤認し、新しい
template_guardfalse-positive を作れます。最小修正: anchor scanner のコピーをやめ、GFM semantics は共有 parser から継承する、と契約を固定してください。blockquote 専用の複雑さも不要です。
guard_template()が探すのは column-0 相当の##見出しなので、通常の> ## Outcomeはそもそも実見出しとしてマッチしません。P1 — AC1〜AC3 は happy-path が狭すぎ、間違った独自実装でも green になれます。
現 AC1 は「孤立 backtick + 後続 bash fence」、AC2 は「正常 fence を引き続き除去」、AC3 はテスト存在、という構成です。これでは
r'^\s*```'のような単純 toggle scanner でも通過できます。実装: split_markdown_blocks の GFM 準拠セグメンテーションを prose_boundary_policy SSOT へ委譲 #659 では既に 4-backtick 内の 3-backtick、tilde/backtick mismatch、short closer、unclosed fence、3-space/4-space indent、closer の trailing text 等が failure matrix として固定されています。実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 側でその全 golden corpus をコピーする必要はありません。むしろ SSOT へ委譲したことを直接固定する adapter-level regression にするべきです。最低限、実際の 実装: baseline_vc_preflight の通常実行を shared VC parser に統一し説明用 bash 行の誤実行候補化を防ぐ #2788 由来 orphan fixture、4-backtick 内 3-backtick、tilde fence、4-space-indented non-fence、unclosed fence を
guard_template()経由で確認すれば十分です。共有 parser 自体の grammar は既存テストへ任せる方が重複がありません。P2 — 再現 fixture が「似た文字列」ではなく、実 failure の raw layout を固定していません。
実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 の AC1 は「3連backtickの直後にbash・直後にbacktick1文字」のように自然言語で説明していますが、Markdown では 行頭か inline か、何 spaces indent か、info string に backtick が入るか で意味が変わります。
影響: 実際の 実装: baseline_vc_preflight の通常実行を shared VC parser に統一し説明用 bash 行の誤実行候補化を防ぐ #2788 とは異なる fixture を作ってテストだけ green にする false-green が可能です。
最小修正: regression test に 実装: baseline_vc_preflight の通常実行を shared VC parser に統一し説明用 bash 行の誤実行候補化を防ぐ #2788 で実際に guard を壊した raw line sequence を literal fixture として固定し、その直後に本物の VC fenceと
## Outcome等を配置してください。fixture の意図をコメントだけで説明するのではなく、生の Markdown 構造を assertion 対象にします。P2 — Stop Condition が、人間判断を不必要に増やします。
現在は「
_anchor_scope_reframe_fence_present()と完全に同一実装になる場合、共通化すべきか判断を仰ぐ」とあります。しかし current repository では共通 authority が既にprose_boundary_policyとして存在します。ここは実装中に人間へ戻す問題ではありません。最小修正: 「独自 fence parser を追加しない。既存
prose_boundary_policy.iter_markdown_blocks()を使用する」に事前決定してください。共有 SSOT に不足が実証された場合だけ、その時点で scope extension / follow-up を検討すれば足ります。個人開発のワークフローとしてもこちらの方が停止が少なく、保守コストも低いです。推奨する契約修正
Current Validated Scope / In Scopeの中心は、概ね次の形に変更するのが適切です。実装イメージもこの程度で足ります。
実際の import wiring は既存 repository の sibling-skill import patternに合わせるべきで、新ライブラリ、新 wrapper、新 security gate は不要です。
Verification Commands の改善
現在の target test 2本に加えて、共有 semantics の既存 regression を focused に1本通す程度が妥当です。たとえば
test_guard_issue_body.pyの全件に加え、test_prose_boundary_policy.py -k fenceを実行し、さらにrgで_FENCED_CODE_BLOCK_REが消え、iter_markdown_blocksを consume していることを確認する構成です。repo-wide test を #2794 の固有 VC として毎回要求する必要はありません。関連 Issue の整理では、#2784 はまさに parser drift の横断 inventory ですが research-only かつ blocker ではないため、#2794 を待たせる必要はありません。[Issue #2784](https://github.com/squne121/loop-protocol/issues/2784?utm_source=chatgpt.com) #1719 は同じ
guard-issue-body.pyを触るものの AC/VC alignment の別 concern なので、実装開始時に live PR/HEAD の衝突だけ確認すれば十分です。#2796 は #2794 を既知の別 Issue として明示的に scope out しており、本不具合を解消していません。[PR #2796](https://github.com/squne121/loop-protocol/pull/2796?utm_source=chatgpt.com)結論: #2794 は「regex → 独自 line scanner」ではなく、**「残存している独自 fence regex consumer を既存
prose_boundary_policySSOT へ収束させる Issue」**として精緻化するのが最小かつ再発しにくい修正です。現状のまま実装すると、#659 と PR #1717 で既に排除した parser duplication を再導入します。squne121 commentedon Sep 27, 2026
確認した限り、推奨ルートは #2794 を実装へ進めず、OWNER の対象コメントを trusted human context として
issue-refinement-loopで契約修正する ことです。current main は確認時点で8fac56af67e9f8da89092e880b5c9a1ab3c8d2f6、#2794 は open のままで、対象の独自 fence 処理も残っています。対象コメントの技術指摘も妥当です。GFM の fenced code block は opener/closer とも最大3 spacesのindentで、backtick fence の info string には backtick を含められません。したがって Issue 本文の「0–8 spaces の独自scannerを参考にする」方向より、repository既存の
prose_boundary_policy.iter_markdown_blocks()に収束させる方が整合します。:chatgpt-content-reference{index="0"}current
issue-refinement-loopでは iterationごとの承認は既定で不要です。一方、Step 2 は現在issue-reviewerSubAgentではなく root-ownedrun_root_review_pipeline.pyが正規経路です。SubAgent は Step 1 のcodebase-investigator、必要時のweb-researcher、rewrite時のissue-editorを使わせ、各結果を待ってから後続へ進ませるのが現在の契約に合います。そのまま、既に auto mode で起動している Claude-GPT / Native Claude Code のどちらにも貼れる共通プロンプトです。
repo:
squne121/loop-protocol対象:
#2794https://github.com/squne121/loop-protocol/issues/2794#issuecomment-5859799739.claude/skills/issue-refinement-loop/SKILL.mdこの既存の対話セッションをそのまま継続し、Issue #2794 に対して current repository の
issue-refinement-loopを最後まで実行してください。このセッションは既に auto mode で起動済みです。iteration ごとの人間承認は求めず、repository の loop policy が許す範囲で自律継続してください。
Claude-GPT セッションの場合は repository-owned Claude-GPT launcher/profile/backend mapping をそのまま維持してください。再起動、別frameworkへの切替、model alias の固定推測、permission mode の変更は不要です。Native Claude Code の場合も同じ Claude Code harness 契約に従ってください。
最初に必ず fresh state を取得する
過去の会話・過去のSHA・古いSkill仕様を正本にしないでください。
開始時に current state を fresh 取得し、少なくとも以下を確認してください。
5859799739の現在の内容、author association、対象Issue bindingmainHEAD SHACLAUDE.md.claude/skills/issue-refinement-loop/SKILL.mdreferences/**anchor-comment-handling.mdloop-state.mdtermination-policy.md.claude/agents/codebase-investigator.md.claude/agents/web-researcher.md.claude/agents/issue-editor.mdprompt作成時点では main=
8fac56af67e9f8da89092e880b5c9a1ab3c8d2f6だったが、これを固定値として使わず実行開始時の fresh main を authority にしてください。anchor comment の扱い
対象コメントは Issue OWNER による明示的な adversarial review / contract correction directive です。
したがって、URLだけの unlabeled anchor や agent-report lane として扱わず、current Skill の canonical direct human context lane を使用してください。
current contract が変わっていなければ、canonical root/main control-plane から:
preflight.run.with_human_contextを用い、対象 anchor URL と Issue #2794 を binding してください。
run_refinement_preflight.pyを production entrypoint として直接叩いたり、独自にplanner判定を再実装したりしないでください。command registry / canonical executor を authority にしてください。preflight が trusted contract patch / contract update を要求した場合は current Skill の Step 0g に従い、
contract_update.run.with_human_contextを main/root control-plane から実行してください。
NEXT_ACTION: issue_editor_requiredが返った場合は同じ contract-update を無意味に再試行せず、current Skill の canonical Step 4 rewrite routeへ進めてください。今回の refinement で解消すべき中心 finding
anchor comment の指示を単なる参考情報ではなく、trusted human context として current repository evidence と照合してください。
特に次を精緻化対象とします。
実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 の現在の「独自 line-oriented fence scanner を新設する」という方向を再検討する。
current repository に既存の fence segmentation authority
.claude/skills/create-issue/scripts/prose_boundary_policy.py::iter_markdown_blocks()が存在し、current main でも有効なSSOTであることを確認する。
repository evidence が anchor comment を支持する場合、Issue契約を概ね次へ収束させる。
guard-issue-body.py::_strip_fenced_code_blocks()の独自_FENCED_CODE_BLOCK_REを撤去する。prose_boundary_policy.iter_markdown_blocks()に委譲する。_strip_fenced_code_blocks()はBLOCK_KIND_CODE_FENCEを除外する薄い consumer / adapter とする。prose_boundary_policy.py自体は、current evidenceで不足が実証されない限り変更対象へ広げない。Issue本文にある anchor-comment専用 scanner の「0–8 spaces」等のsemanticsを、GFM fence grammarとしてコピーしない。
external semantics が refinement decision に materially 必要なら、後述する
web-researcherで GitHub Flavored Markdown / CommonMark の一次仕様を検証する。Acceptance Criteria / Verification Commands を false-green しにくい形へ修正する。
最低限検討するもの:
## Outcome等が template guard から正しく見えることただし shared parser 自体の golden corpus を 実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 側へ大量コピーしないでください。
shared parser のgrammarは既存テストをauthorityとし、#2794では consumer/adapter-level parity を中心に固定してください。
Verification Commands には current pathsを確認した上で、少なくとも以下の意図を反映してください。
test_guard_issue_body.pyの新regressionをfocused実行test_guard_issue_body.py全件test_prose_boundary_policy.pyの fence 関連focused regression_FENCED_CODE_BLOCK_REの撤去確認iter_markdown_blocksを consumer が利用することの確認現Issueにある
「anchor scanner と同一実装になる場合は共通化すべきか人間判断」
のような不要な停止条件は、既存SSOTへの委譲が repository evidence で確定するなら除去・置換してください。
独自 parser を追加しないことを契約上事前決定し、通常の実装時に不要なhuman stopを発生させない形を優先してください。
関連stateの確認
少なくとも以下を fresh 確認し、scope collision / dependencyを current事実から評価してください。
guard-issue-body.pyを触るが AC/VC alignment / shared VC parser 系の別concern既存の follow-up / dedupe がある場合、新しい重複Issueを作らないでください。
SubAgent の使用
Step 1: codebase-investigator
current Skill が Step 1 investigation を要求する場合、custom SubAgent
codebase-investigatorを使用してください。dispatch時には親会話の暗黙contextに依存させず、少なくとも以下を明示してください。
guard-issue-body.py::_strip_fenced_code_blocks_FENCED_CODE_BLOCK_REprose_boundary_policy.iter_markdown_blocksBLOCK_KIND_CODE_FENCESubAgent をdispatchしただけで完了扱いしないでください。必ず最終resultが返るまで待ち、そのresultを取得・検証してから downstream Stepへ進んでください。
Step 1b: web-researcher
planner / current Skill が critical external claim の検証を要求する場合だけ
web-researcherを起動してください。今回の候補claimは主に:
GitHub Flavored Markdown / CommonMark の一次資料を優先してください。
repository evidenceだけで disposition が確定でき、external claim が dispositive でない場合は、不必要なweb researchをhard blockerにしないでください。
起動した場合は、web-researcher の最終resultを待ち、citation/source contentを確認してから downstreamへ進んでください。
Step 2: Review
current
issue-refinement-loopの canonical Step 2 に従ってください。現行contractが維持されている限り、
issue-reviewerSubAgentを起動しないでください。Step 2 は root-owned
run_root_review_pipeline.py produceの結果を直接consumeする経路です。legacy
issue-reviewerSubAgent / legacy relay を canonical routing に持ち込まないでください。Step 4: Rewrite
review / contract-update routing が rewrite を要求した場合は current
issue-editorSubAgent を使ってください。edit-issueの controlled transaction routeを使用するgh issue editでcanonical transactionを迂回しないissue-editor をdispatchした後も必ずterminal resultを待ち、readbackを取得してから fresh reviewへ進んでください。
自律継続
current Skill の既定
max_iterations/ routing authorityに従ってください。特段の理由がなければcurrent defaultを使用してください。以下は人間承認を挟まず自動継続してください。
needs-fix→ 上限内の rewrite iterationissue_editor_required→ canonical issue-editor rewrite人間承認不要という指示を Claude Code の permission bypass と混同しないでください。
以下を要求・変更しないでください。
bypassPermissions--dangerously-skip-permissions不要な停止を避ける
以下だけを理由に停止しないでください。
triage-required等のpresentation labelだけneeds-fixcanonical planner / reviewer / deterministic checker の判断を自然言語で上書きしないでください。
一方、current repository authority が最終的に
human_judgment_requiredと判定する非決定的なscope conflict、evidence integrity failure、irreconcilable contract conflict、loop上限到達などは、その正規termination routeに従ってください。この invocation の到達点
今回は Issue refinement のみ が依頼されています。
したがって refinement が approved になっても、この invocation から以下を開始しないでください。
impl-review-loopcurrent Skill が
LOOP_HANDOFF_RESULT_V1/ termination report を要求する場合は正規手順で出力・投稿し、そこで終了してください。approvedを implementation authorization とみなさないでください。follow-up
refinement中に新しい独立した recurrent defect が見つかった場合は、まず current open/closed Issues を dedupeしてください。
既に #2784 / #1719 等が同じ問題を十分coverしているなら新規Issueを作らないでください。
current
issue-refinement-loopの follow-up materialization authority が新規Issueを要求する場合のみ、そのcanonical routeに従ってください。タイトル類似だけで重複判定しないでください。停止境界
通常のrefinement作業では人間承認を求めないでください。
ただし以下は停止/escalation可能です。
human_judgment_required他Issueのdirty worktree、foreign branch、別taskの未commit変更を勝手に変更・削除しないでください。
最終報告
terminal state に到達したら、簡潔に次を報告してください。
_FENCED_CODE_BLOCK_RE → 独自scannerではなく sharedprose_boundary_policySSOT へ収束したかimpl-review-loop #2794が実行可能かどうか成功・approvedを推測で報告せず、GitHub readbackとcurrent canonical artifactsで確認してから終了してください。
このケースでは、人間承認不要を強めるために独自コマンド列を増やすより、current Skill の
with_human_context → contract_update / issue-editor → fresh reviewをそのまま最後まで走らせるのが適切です。特に今回は対象コメント自体が十分具体的なので、手書きの追加ANCHOR_SCOPE_REFRAME_V1をユーザーへ要求させない方針にしています。squne121 commentedon Sep 27, 2026
Contract Review Result
squne121 commentedon Sep 28, 2026
issue-refinement-loop: approved
prose_boundary_policy.iter_markdown_blocks()を使う薄い consumer へ変更した。Allowed Paths は guard script とその test の 2 ファイルを維持した。baseline-expect: failの期待どおり現時点で未実装。既存 guard tests は 67 passed、共有 parser の fence focused tests は 29 passed。approve/step_2_5。final review gate: allowed。semantic join:approve、medium warning 1 件(AC2 の未閉 fence は EOF まで code であり、そこに続く見出し風行は実見出しではないことを実装時に明確化する)。go。現行本文 SHA-256sha256:d8e0a035d2dd42c7aabd2d19950572022fad42af55f42fa4a22341712dc933dcと 実装: guard-issue-body.py の _strip_fenced_code_blocks() が prose 内の孤立backtick列を実fenceと誤ペアリングし template_guard を false-positive にする不具合を修正する #2794 (comment) の snapshot が一致。snapshot publisher は postcondition failure を返したが、remote comment の存在と同一本文へのgoは別途 readback と fresh static review で確認した。proceed/no_hard_dependencies_confirmed_this_cycle。scope-rollup の execution decision は未分類 coordination signal によりdeferred(predecessors 空)であり、実装開始許可ではない。follow-up Issue は起票していない。impl-review-loop、worktree 作成、commit、push、PR、merge は行っていない。実装着手には独立した明示依頼と fresh entry gate が必要。squne121 commentedon Sep 28, 2026
確認した live state では、#2794 は実装へ進める状態です。Issue は open、refinement は
approved、current main077919b431d2dc4ded1762dc851c14fe578d2a02には問題の_FENCED_CODE_BLOCK_RE = re.compile(r'```.*?```', re.DOTALL)がまだ残っています。契約で追加予定の3つの regression test も current main には存在しません。また、#1719 は現在も open Issue ですが、確認範囲では対応する open PR は見つかっていません。#2794 自身も「同一ファイルを扱うだけでは停止せず、実際の衝突または scope extension がある場合のみ調整」としています。PR #2796 は既に merged で、#2794 の Allowed Paths には触れていません。
したがって推奨は、current
impl-review-loopの Root-Owned Synchronous Entry Transition → Evidence-Based Landing Disposition を通し、通常実装へ進めることです。既存 PR が fresh discovery で見つかった場合だけ resume し、重複 PR は作らせません。以下を、そのまま既に auto mode で起動している Claude-GPT に貼れます。
repo:
squne121/loop-protocol対象:
https://github.com/squne121/loop-protocol/issues/2794.claude/skills/impl-review-loop/SKILL.mdこの既存の対話的 Claude-GPT セッションをそのまま継続し、Issue #2794 に対して current repository の
impl-review-loopを実行してください。目的は、Issue #2794 の実装、検証、Draft PR 作成、PR review、必要な修正と再検証を自律反復し、人間が merge 判断できる直前の状態まで到達させることです。
iteration ごとの人間承認は要求しないでください。通常の test failure、CI failure、REQUEST_CHANGES、stale review、BEHIND、修正可能な PR hygiene 問題は停止理由にせず、current
impl-review-loopの canonical routing に従って自動修復・再検証してください。ただし実 merge / auto-merge は行わないでください。
Claude-GPT セッションの扱い
このセッションは既に auto mode で起動済みです。
--dangerously-skip-permissions/bypassPermissions等を要求しない0. 必ず fresh state から開始する
この prompt 内の SHA や状態は参考情報であり authority ではありません。
開始時に live state を fresh 取得し、少なくとも以下を確認してください。
mainHEAD SHACLAUDE.mddocs/dev/workflow.md.claude/skills/impl-review-loop/SKILL.mdimpl-review-loop/steps/**preparation.mdstep-1-implementation.mdstep-2-verification.mdstep-4-pr-review.mdstep-5-feedback-and-termination.mdstep-5-mergeability-handling.mdconflicting-pr-escalation-runbook.mdcontext-protocol-and-guardrails.md.claude/skills/implement-issue/SKILL.md.claude/skills/pr-review-judge/SKILL.md.claude/skills/open-pr/SKILL.md.claude/agents/implementation-worker.md.claude/agents/test-runner.md.claude/agents/pr-reviewer.mdprompt 作成時点の観測値は以下ですが、必ず fresh read で再確認してください。
077919b431d2dc4ded1762dc851c14fe578d2a02https://github.com/squne121/loop-protocol/issues/2794#issuecomment-5869477039https://github.com/squne121/loop-protocol/issues/2794#issuecomment-5860320598sha256:d8e0a035d2dd42c7aabd2d19950572022fad42af55f42fa4a22341712dc933dcこのユーザー指示自体を、refinement 完了後の 独立した明示的 implementation request として扱ってください。
1. current impl-review-loop の entry contract を厳守する
過去の contract snapshot comment や handoff comment を Step 1 authorization token として再利用しないでください。
current
impl-review-loopが要求する Root-Owned Synchronous Entry Transition を root/main thread 自身が current run で実行してください。すなわち同一の継続 invocation の中で:
issue-contract-reviewまでを一続きで実行してください。
旧 invocation token、古い snapshot、GitHub comment、artifact、digest 等を単独の authorization として扱わないでください。
current Skill の deterministic router / script が authority の判断を持つ場合は、それを prose で再実装しないでください。
2. Step 1 前の duplicate / already-landed 判定
worker dispatch、worktree 作成、新規 PR 作成より前に、current
preparation.mdの Evidence-Based Landing Disposition を canonical producer / router 経由で評価してください。結果に従い:
implementation_already_landedexisting_pr_resumealready_satisfiedordinary_dispatch_or_explicit_recoveryreconciliation_requiredGitHub search の単純な title / branch 名だけで candidate identity を判断しないでください。
3. Issue #2794 の live contract を implementation authority とする
実装内容は必ず current live Issue body の Outcome / In Scope / Out of Scope / AC / Verification Commands / Allowed Paths / Stop Conditions を正本にしてください。
現時点の意図は次のとおりですが、fresh body を優先してください。
Allowed Paths
変更可能なのは次の2ファイルだけです。
.claude/skills/edit-issue/scripts/guard-issue-body.py.claude/skills/edit-issue/tests/test_guard_issue_body.py閲覧・テスト実行のために以下を参照してよいですが、#2794 では変更しないでください。
.claude/skills/create-issue/scripts/prose_boundary_policy.py.claude/skills/create-issue/scripts/tests/test_prose_boundary_policy.pydocs/dev/workflow.md実装方針
guard-issue-body.pyで独自 fence parser を新設しないでください。_FENCED_CODE_BLOCK_REを削除する_strip_fenced_code_blocks()を既存prose_boundary_policy.iter_markdown_blocks()の薄い consumer にする
BLOCK_KIND_CODE_FENCEの block だけを除外するprose_boundary_policy.py自体は変更しないcurrent main に旧
_FENCED_CODE_BLOCK_RE = re.compile(r'```.*?```', re.DOTALL)がまだ存在することは prompt 作成時点で確認済みですが、実装前に fresh HEAD でも確認してください。Regression tests
Issue の AC が指定する consumer-level regression を追加してください。
特に current contract の以下3 node-id:
test_orphan_backtick_shared_parser_adaptertest_shared_parser_fence_boundary_casestest_shared_parser_delegation_without_regexprompt 作成時点の main にはまだ存在しません。
baseline-expect が
failの VC について、実装前の missing node-id / expected failure と、実装後の PASS を明確に区別してください。共有 parser 自体の golden grammar corpus を guard tests にコピーしないでください。
AC2 の EOF 未閉 fence の解釈
refinement final comment の semantic warning を必ず確認してください。
EOF 未閉 fence は opener 以降 EOF まで code fence content です。その中に現れる
## ...を「後続の実見出し」として保持するような誤った regression test を作らないでください。「fence 後の実見出しを保持する」ケースと「EOF 未閉 fence 内の見出し風文字列を除外する」ケースを semantics 上区別してください。
4. #1719 collision は actual evidence で判断する
Issue #1719 は同じ
guard-issue-body.pyを扱う別 concern です。単に同じファイルを扱うだけで停止しないでください。
fresh state で:
を確認してください。
実際の conflict または #2794 Allowed Paths / scope を越える変更が必要と実証された場合のみ、current Issue Stop Conditions に従って停止してください。
5. SubAgent を canonical role で使う
root/main thread は control-plane に徹し、current
impl-review-loopが指定する canonical SubAgents を使用してください。最低限:
Step 1
implementation-worker渡す context:
Step 2
test-runner渡す context:
Step 4
pr-reviewer渡す context:
pr-review-judgeSubAgent に root conversation の暗黙 context を推測させないでください。
SubAgent 自身に不要な nested delegation をさせないでください。Issue #2794 の live Stop Conditions が nested delegation を停止条件として維持している場合は、それを尊重してください。
6. SubAgent の作業完了を必ず待つ
SubAgent dispatch だけで完了扱いしてはいけません。
current
impl-review-loopの Common Completion Protocol を厳密に守ってください。各 dispatch について必ず:
spawn_agentの戻り値から canonicaltask_nameを保存するwait_agentは mailbox activity を待つ用途だけに使うlist_agentsで同じ canonicaltask_nameの terminal state がcompletedであることを確認するcompletedの両方が揃ってから downstream step へ進む以下は成功扱いしない:
erroredinterruptedshutdownnot_foundこれらを観測した場合、result を捏造して次 Step へ進まず current Skill の fail-closed / recovery contract に従ってください。
特に:
7. 実装 → 検証 → PR → review/fix loop
current canonical procedure に従って:
inspect → implement → test → Draft PR作成/更新 → CI → PR review → fix → re-test → fresh re-reviewを実行してください。
Issue #2794 の Verification Commands をすべて current contract から取得して実行してください。
現時点では少なくとも以下が含まれていますが、live body を authority としてください。
prose_boundary_policyfence-focused tests実装後は narrow VC だけでなく、current workflow が要求する relevant regression / repository checks も実行してください。
8. PR
1 Issue = 1 PRを維持してください。新規 PR が必要な場合:
open-prSkill を使うCloses #2794を正しく設定する9. REQUEST_CHANGES / CI failure は自動修復する
pr-reviewer が
REQUEST_CHANGESを返した場合、actual conflict や current canonical hard stop でない限り止まらないでください。blockers を exact
fix_deltaとして次 iteration のimplementation-workerに渡し:を行ってください。
stale review は fresh HEAD で再レビューしてください。
BEHINDは currentroute_loop_verdict_v2()がroute_to_update_branchを返す場合、その action を canonical worker に委譲し、更新後に verification と PR review を再実行してください。mergeability
UNKNOWN等は current bounded retry contract に従ってください。10. 終了条件
終了は current
route_loop_verdict_v2()を authority としてください。目標状態は:
APPROVEblockers == []ここまで到達したら
draft_pr_ready相当として終了し、merge はしないでください。max iteration は current Skill の policy に従ってください(現在の既定は 3)。上限に達するまでは通常の修正可能 finding ごとに人間承認を要求しないでください。
11. 停止境界
以下の場合だけ current canonical contract に従って停止 / escalate してください。
HUMAN_REVIEW_REQUIRED/ hard stop と判定するscope-rollup / contract snapshot / launch ledger 等の advisory artifact の missing/stale だけを理由に停止しないでください。
今回の変更は repository-internal な static Markdown processing 修正なので、外部調査は原則不要です。
external_research_skip_basisにその根拠を記録してください。Issue Stop Conditions に反して外部サービスを勝手に利用しないでください。12. 最終報告
最終的に以下を簡潔かつ具体的に報告してください。
completedを確認したこと実 merge / auto-merge / irreversible cleanup は行わず、merge 判断直前で停止してください。
特に重要なのは、今回は refinement 済みなので単純に worker を起動するのではなく、current-run entry transition と pre-Step-1 landing disposition を通したうえで
implementation-worker → test-runner → pr-reviewerを回す点です。また、各 SubAgent は final result とlist_agentsの terminalcompletedの両方を確認するまで次へ進ませない構成にしています。squne121 commentedon Sep 28, 2026
implement-issue: 実装完了 (2026-09-28T12:44:37Z)
.claude/worktrees/issue-2794-guard-fence-parserworktree-issue-2794-guard-fence-parsersqune121 commentedon Sep 30, 2026
impl-review-loop: 完了(2026-09-30T11:51:55Z)
existing_pr_resume、新規 PR・branch・worktree なし)。APPROVE、Step 5route_loop_verdict_v2_resolve_semantic_ambiguity()の live-facts route はapproved。PR HEADcd753f2d3731ef7283dfffbd258701e7e22d7127、live main / PR base8eeca46aea2ffcffc88b29428c1b1da205c5b556、MERGEABLE/CLEAN、Draft 維持。VC_ADJUDICATION_RESULT_V1:pass/blocking: false、Step 4 current-head gate:invoke。ok、変更 2 ファイルのみ。fix: guard_template の fence 判定を共有 parser に委譲する (#2794) (#2818)