Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "anchor_comment 処理パイプラインが CF_HTML/clipboard 由来の contamination を安全に扱えるようにし、Issue本文破損(#2290 実害)を再発させない"
change_kind: codeParent Issue
none
Parent Goal Ref
- Goal: なし(単独改善のため親 Issue なし)
- Desired Destination: なし
Current Validated Scope
.claude/skills/issue-refinement-loop/scripts/scope_signal_delta.pyのextract_directive_items()の入力境界(raw anchor comment body → normalized directive)に、CF_HTML/clipboard contamination(<!--StartFragment-->/<!--EndFragment-->marker を伴う HTML+Markdown 二重連結)を検出し、後半の Markdown 部分のみを canonical input として切り出す、または一意に切り出せない場合は当該 directive を無効化する normalization boundary を追加する.claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py::_normalize_exact_repository_path_literal()/_extract_path_literals_from_text()(derive_contract_patch_operations()の Allowed Paths 分岐、~1189〜1194行から呼び出される、authorization-bearing exact path token extractor 本体)に、</>/<!--StartFragmentを含む token を path literal として認めない安価な最終防御を追加する- 必要な場合のみ
.claude/skills/issue-refinement-loop/scripts/anchor_context.py::extract_candidates()にも同じ normalization helper を再利用する(上流2箇所で十分に防げる場合は変更不要と判断してよい) - 上記に対応する regression test / fixture(実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290 の構造を匿名化した CF_HTML envelope fixture、および正当な
<details>混入時の非regressionケース)を.claude/skills/issue-refinement-loop/tests/および.claude/skills/issue-refinement-loop/tests/fixtures/に追加する
Remaining Parent Gaps
- GitHub コメント producer 側(リッチテキスト貼り付け由来の HTML混入そのもの)の是正は本 Issue の対象外。repo の制御範囲外であり、GitHub 側の挙動に依存する
- 完全な HTML sanitizer / 汎用 HTML parser(
bleach等の外部ライブラリ導入や DOM構築)の導入は行わない。CF_HTML のStartFragment/EndFragmentmarker を狙い撃ちした小さな deterministic boundary の追加に留める
Outcome
CF_HTML/clipboard artifact(<!--StartFragment-->/<!--EndFragment--> marker を伴う HTML+Markdown 二重連結)が、anchor comment から派生する directive / contract patch operation へ伝播しなくなる状態。同時に、GitHub の正当な raw HTML(<details>/<summary> 等の GFM raw HTML)を含む既存 Issue body に対する、HTML混入のない通常の contract update は妨げられない。対応する regression test が .claude/skills/issue-refinement-loop/tests/ に追加され PASS している。
Runtime Verification Applicability
- decision: not_applicable
- reason: 静的な pytest fixture ベースの検証(CF_HTML envelope 混入 anchor に対する deterministic な canonicalize/reject 挙動確認、および正当な raw HTML の非regression確認)のみで完結するため。外部サービスや実 GitHub mutation の system test を追加する利益は小さい
In Scope
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py::_build_scope_delta_authority_evidence()(5478行、directives = extract_directive_items(comment_body)で raw comment_body を無加工のまま渡している箇所)の直前、または.claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py::extract_directive_items()(966〜975行、現状は"- "/"* "bullet marker を外すのみで HTML 処理を一切行わない)の入力境界に、CF_HTML envelope 検出・canonicalize/reject ロジックを追加するStartFragment+EndFragment+ HTML wrapper + 同内容の trailing Markdown(実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290/導入: Issue contract / DoR / dependency 判定による AI 実装前提基盤の整備 (parent) #40/実装: 動作検証 AC の適用判定・延期契約・SKIP/fallback 取扱い・VC 推奨コマンド方針を各 skill/docs に反映する #77 型)を検出した場合は後半の Markdown 部分のみを canonical input として使う。marker はあるが trailing Markdown を一意に切り出せない場合は、その directive を無効化する(後続の operation 化を行わない)- 汎用の HTML タグ全面除去・全面拒否は行わない(
<details>等の正当な GFM raw HTML を破壊しないため) .claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py::_normalize_exact_repository_path_literal()(731〜751行、現状は null/CR/LF・backslash・://・先頭/・空/./..セグメントのみを検査し</>を検査していない)および_extract_path_literals_from_text()(686行、PATH_TOKEN_RE(71行)を用いてderive_contract_patch_operations()の Allowed Paths 分岐(~1189〜1194行)から呼び出される、authorization-bearing exact path token extractor 本体)に、</>/<!--StartFragmentを含む token を path literal として認めない防御を追加する。run_refinement_preflight.py::_normalize_scope_reframe_delta_literal()(5598行)は構造化されたANCHOR_SCOPE_REFRAME_V1.allowed_path_deltas専用の別ヘルパーであり、freeform directive の path-token scan(本 AC の対象)ではないため変更対象に含めない- 必要な場合のみ
.claude/skills/issue-refinement-loop/scripts/anchor_context.py::extract_candidates()(195〜255行付近、_BULLET_LINE_REマッチ後の candidate text 生成箇所。ただしこの関数は multi-turn 話者分離・candidate surfacing 用の pure analyzer であり、実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290 の実害が発生した単一ターン freeform human-context 経路の主防御点ではないことに留意する)にも同じ normalization helper を再利用する - 実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290 の構造を匿名化した CF_HTML envelope fixture(先頭 HTML wrapper →
<!--StartFragment-->→ closing wrapper → Markdown duplicate)と、正当な<details>を含む clean anchor fixture を.claude/skills/issue-refinement-loop/tests/fixtures/に追加する - 上記 fixture を用いた regression test を
.claude/skills/issue-refinement-loop/tests/に追加する。production chain(raw comment → _build_scope_delta_authority_evidence → extract_directive_items → derive_contract_patch_operations、必要ならrun_trusted_anchor_iteration_zeroまで)を通し、operationsに CF_HTML marker が含まれないかwrites == 0のいずれかで PASS することを確認する
Out of Scope
- 完全な HTML sanitizer(例:
bleach等の外部ライブラリ導入)や汎用 HTML parser(html.parser越えの DOM構築等)の導入。小さな deterministic な CF_HTML marker 検出ベースの boundary に留める - GitHub コメント投稿 UI(producer 側)の是正。リッチテキスト貼り付けによる HTML混入そのものは GitHub 側の挙動であり repo の制御範囲外
- 調査: issue-refinement-loop の anchor_comment に HTML マークアップが混入した場合のパース安全性を確認する #132 で調査対象になっている「HTML混入時のパース安全性」全般の網羅的な仕様化。本 Issue は 実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290 で実害が出た書き込みパスの防御に限定する
- 既存の clean Markdown anchor_comment 処理ロジックのリファクタリング(挙動変更を伴わない範囲を除く)
- 「candidate body / Issue body に HTML タグが1つでも含まれていたら reject」という広範な条件を Acceptance Criteria に要求しない。GitHub Flavored Markdown は raw HTML(
<details>/<summary>等)を正式にサポートしており、無関係な既存 HTML の存在だけで無関係な contract update を止めてはならない
Acceptance Criteria
- AC1: 実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290 の構造を匿名化した CF_HTML envelope fixture(先頭 HTML wrapper →
<!--StartFragment-->→ closing wrapper → 同内容 Markdown duplicate)を normalization boundary(extract_directive_items()またはその直前の helper)に与えた場合、後半の Markdown 部分のみが canonical directive として抽出され、<!--StartFragment-->/<!--EndFragment-->marker や HTML wrapper タグが結果に含まれないことがテストで確認できる - AC2: 通常の bullet 形式(HTML混入なし)の anchor directive を同じ normalization boundary に与えた場合、既存の正常系抽出結果(bullet marker を除いた text がそのまま返る)が変化しないことがテストで確認できる(regression なし)
- AC3: AC1 の CF_HTML envelope fixture を実 production chain(
raw comment → _build_scope_delta_authority_evidence → extract_directive_items → derive_contract_patch_operations)に通した場合、生成される operation のいずれの text にも CF_HTML marker(<!--StartFragment-->等)や HTML wrapper タグ文字列が含まれないか、canonicalize 不能な場合はoperationsが空(mutation 前にwrites == 0相当)になることがテストで確認できる - AC4:
</>/<!--StartFragmentを含む token は、Allowed Paths の exact path literal として認識・operation化されないことがテストで確認できる - AC5: 既存 Issue body に正当な
<details>/<summary>等の GFM raw HTML が既に含まれる状態で、HTML混入のない clean anchor directive による無関係な contract update がcandidate_readiness()でgoを維持し、無関係にブロックされないことがテストで確認できる(regression: HTML全面禁止ではないことの証明) - AC6: 既存の
issue-refinement-loopテストスイート(.claude/skills/issue-refinement-loop/tests/)が本変更後も全件 PASS する
Verification Commands
# AC1
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta_cf_html_sanitization.py::test_extract_directive_items_canonicalizes_cf_html_envelope -v
# AC2
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta_cf_html_sanitization.py::test_extract_directive_items_preserves_clean_bullet_text -v
# AC3
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta_cf_html_sanitization.py::test_production_chain_stops_or_canonicalizes_before_write -v
# AC4
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta_cf_html_sanitization.py::test_contaminated_token_not_accepted_as_allowed_path_literal -v
# AC5
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta_cf_html_sanitization.py::test_existing_details_block_does_not_block_unrelated_clean_update -v
# AC6
# preflight-scope: pr_review_only
$ uv run pytest .claude/skills/issue-refinement-loop/tests/ -vAllowed Paths
- .claude/skills/issue-refinement-loop/scripts/anchor_context.py
- .claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py
- .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
- .claude/skills/issue-refinement-loop/tests/**
- .claude/skills/issue-refinement-loop/tests/fixtures/**
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合(例: 完全な HTML sanitizer ライブラリの新規依存追加が必要と判明した場合は、Out of Scope 逸脱として直ちに停止し人間判断を仰ぐ)
Required Skills
なし
Required Design References
- .claude/skills/issue-refinement-loop/references/anchor-comment-handling.md
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PR を原則とする。worktree を使用し、Draft PR をデフォルトとする。
Background
- Issue 実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290(
実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する)の refinement loop 実行中に、OWNER の GitHub コメント(gh api repos/squne121/loop-protocol/issues/comments/5396239195)に含まれていた literal HTML(リッチテキストエディタ貼り付け由来と推定、<html><body><!--StartFragment-->...等)が、サニタイズなしで Issue 実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290 本文へそのまま書き込まれ、本文が破損した(6944→7605文字、## Allowed Paths節等に不正な HTML断片混入)。破損前スナップショット sha256:195213c18a9c4b7c9438d3d4c65dc1906a5b1fcc76fd2c581b31432406e30db7へ既に復元済み - 既存の関連調査 Issue 調査: issue-refinement-loop の anchor_comment に HTML マークアップが混入した場合のパース安全性を確認する #132(
調査: issue-refinement-loop の anchor_comment に HTML マークアップが混入した場合のパース安全性を確認する、OPEN)が同種の事象(Issue 実装: 動作検証 AC の適用判定・延期契約・SKIP/fallback 取扱い・VC 推奨コマンド方針を各 skill/docs に反映する #77 で発生、当時は実害なし)を調査していたが未結論だった。今回 実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290 で実害が確認されたため、調査: issue-refinement-loop の anchor_comment に HTML マークアップが混入した場合のパース安全性を確認する #132 には別 SubAgent が並行して結論コメントを投稿している - 本 Issue のレビューコメント(実装: issue-refinement-loop の anchor_comment 処理で HTML混入コメントを安全に処理する(reject/canonicalize boundary の追加) #2333 (comment) )で、当初契約案の主防御点(
anchor_context.py::extract_candidates()/candidate_readiness())が実際の production mutation path とずれている可能性、および「HTML が1つでもあれば reject」という AC4/AC5 が GFM の正当な raw HTML と衝突する可能性が指摘された。以下は codebase-investigator による read-only 独立検証(本 Issue 用、2026-08-25)で確認された事実であり、上記 In Scope はこの検証結果を反映して更新済み- 一次原因(producer側): OWNER コメント自体がリッチテキスト貼り付けによると推定される literal HTML を含んだ状態で GitHub に保存されていた。ツールのバグではなく入力自体が汚染されているケース
- 伝播(normalization bug、検証済み):
run_refinement_preflight.py::_build_scope_delta_authority_evidence()(5478行)がdirectives = extract_directive_items(comment_body)として raw comment_body を無加工のままscope_signal_delta.extract_directive_items()へ渡している。同関数(scope_signal_delta.py966〜975行)は"- "/"* "bullet marker を外すのみで、HTML 検出・除去ロジックは存在しない anchor_context.py::extract_candidates()の位置づけ(検証済み): 同関数はrun_refinement_preflight.py内で計算されてはいる(6534行)が、これは multi-turn 話者分離・candidate surfacing 用の別経路であり、実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290 の実害を生んだ単一ターン freeform human-context directive の抽出(上記2.)とは独立している。したがって当初契約案のようにこの関数だけを修正しても、実際の伝播経路は残り得る- 適用(patch application bug):
scope_signal_delta.py::build_section_aware_candidate_body()(1358行)がoperation["text"]を.strip()するだけで Issue body へ literal に挿入する。HTML/マークアップの妥当性検証がない - 検知漏れ(pre-write validation gap、検証済み):
run_refinement_preflight.py::consume_trusted_anchor_contract_patch_plan()内のcandidate_readiness()(5868行、candidate_readiness(current_issue.get("body", "")))は書き込み直前に 現在の Issue body 全体 を検査するが、Markdown構造(見出し・AC番号等)のみが検査対象であり literal HTML タグの存在は対象外のためfresh_readiness: "go"を返して通過する。逆に言えば、もし AC4/AC5 を「body 全体に HTML タグが1つでもあれば reject」という設計にした場合、既存 Issue body に正当な<details>等が1個でもあるだけで無関係な contract update まで巻き込んでブロックされ得る(本 Issue の AC4/AC5 はこれを避けるよう、anchor 由来 directive/operation の CF_HTML marker 存在に限定して検査する設計に変更済み) .claude/skills/issue-refinement-loop/tests/に CF_HTML envelope 混入パターンをカバーする regression test は現状存在しない
- 設計方針: 過剰な sanitizer / 巨大 HTML parser を導入せず、CF_HTML の
StartFragment/EndFragmentmarker を狙い撃ちして、malformed anchor context を mutation 前に reject/canonicalize する小さな deterministic boundary を優先する
Notes for Reviewer
- 本 Issue は当初
anchor_context.py::extract_candidates()を主防御点としていたが、レビューコメント(issuecomment-5401904404)の指摘と codebase-investigator による独立検証の結果、実際の 実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290 実害経路はrun_refinement_preflight.py::_build_scope_delta_authority_evidence()→scope_signal_delta.extract_directive_items()であることが確認されたため、In Scope / Acceptance Criteria / Verification Commands をこの経路を主対象とする内容へ更新した(reframe_in_place) - reject(安全に倒す)と canonicalize(trailing Markdown を切り出して使う)のどちらの挙動を採用するかは実装時の技術判断に委ねる。いずれの場合も「CF_HTML marker が anchor 由来 operation へ伝播しない」という不変条件と、「正当な GFM raw HTML(
<details>等)を含む既存 body への無関係な contract update を妨げない」という不変条件の両方を満たすこと scope_signal_delta.py::build_section_aware_candidate_body()への変更要否は、extract_directive_items()境界と Allowed Paths token extractor の2箇所で十分に防御できるかどうかで判断してよい(In Scope 参照)- AC6 の Verification Command には
# preflight-scope: pr_review_onlymarker を付与している(既存テストスイート全件実行は静的 baseline preflight のタイムアウト対象になり得るため、PR review 時の test-runner 実行に委ねる) - Scope Collision advisory(導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860 Owner Decision により起票停止理由にしない): overlap preflight(
check_issue_overlap.py)が同一.claude/skills/issue-refinement-loop/scripts/anchor_context.py/run_refinement_preflight.py/scope_signal_delta.py/tests/を Allowed Paths に含む多数の OPEN Issue(実装: capability_preflight_result() の nested timeout 構造を単一 deadline 共有方式へ改善する #2322 実装: reviewer transport の claude-native / claude-gpt session continuation native canary を追加する #2153 実装: reviewer transport の command_registry.py に --validate サブコマンドを追加する #2152 実装: SHA-bound evidence index と command fingerprint budget で再読・重複調査・wait polling による context churn を抑制する #2052 実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する #1975 実装: 両review loopの人間向けGitHub作業履歴をphase-awareに整理し推奨理由を記録する #1908 実装: docs/dev/schema-governance.md に REVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1 を登録し command_registry.py に phase_state.build.review を追加する #1829 実装: test(review-compact): Consumer Inventory の taxonomy parity テストを追加する #1812 実装: fix(replay-taxonomy): readiness rule_id/category を deterministic_domain_key taxonomy に正規化する #1810 実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601 実装: run_refinement_preflight.py の結果に decisions フィールドを出力しSKILL.mdとのSSOT乖離を解消する #1556 実装: reviewer_claim_replay.py の taxonomy に RDR001 / VCP_COMMAND_NOT_ALLOWED を追加し parent_replay_binding.py に C9 evidence 経路を追加する #1555 実装: issue-refinement-loop の SubAgent 起動を planner-declared launch plan に制限する #1288 実装: fix(issue-refinement-loop): no-human-approval autonomy mode を loop state routing に明示する #1007 実装: issue-refinement-loop の preflight result から LOOP_STATE を生成する route wrapper を追加し CLI/schema 迷走を防ぐ #1006 feat(agent-ops): issue-contract-fixer SubAgent を追加し、LLM rewrite 前に deterministic contract repair を完了させる #998 feat(issue-refinement-loop): LOOP_ITERATION_CAPSULE_V1 を導入し、raw body / raw log の main context 流入を禁止する #997 実装: issue-refinement-loop の rewrite routing が既存 blocker contract を consume して non-body-author-fixable blocker を早期停止できるようにする #944 test: scope_signal_guard termination の publisher-level 回帰テストを追加する #926 実装: decide_rewrite_route.py に --print-schema / --example-input / --from-file を追加し入力 state 契約を self-describe 可能にする #917 実装: plan_refinement_loop の fail_closed reason code exhaustiveness invariant をテストする(#661 follow-up) #667 実装: plan_refinement_loop の _extract_missing_contract_keys を PyYAML 不在時に fail-closed にする(#661 follow-up) #666)を報告した。これらは issue-refinement-loop 配下の共有スクリプト/テストディレクトリへの広範な参照による false positive(同一ファイルの異なる関数・異なる懸念への変更)であり、本 Issue の CF_HTML sanitize という明確に独立した scope とは non_conflict。実装時は他 Issue との同時並行実装を避け、マージコンフリクトが生じた場合は rebase で解消する
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Activity
squne121 commentedon Aug 24, 2026
判定
REQUEST_CHANGES。P0 が2件あります。
#2333 の目的自体――#2290 で実際に起きた Issue 本文破損を再発させない――は妥当です。ただし現状の契約のまま実装すると、実際の汚染経路を完全には塞がない一方、正当な GitHub Markdown/HTML を広範囲に拒否する可能性があります。個人開発の運用性を考えると、ここは実装前に scope を少し組み替えた方がよいです。#2290 では OWNER コメントに CF_HTML 由来と見られる HTML と、その後ろに同内容の Markdown が連結され、それが patch operation に伝播したことが確認されています。 #132 でも同型事故について「対応が必要」と結論済みです。
優先度 | Finding | 判定 -- | -- | -- P0 | 防御対象が実際の production mutation path とずれている | blocker P0 | AC4/AC5 の「literal HTML 全面禁止」は GFM と衝突し、正常操作を止める | blocker P1 | 「regex でタグ除去して canonicalize」は意味破壊を起こし得る | 要修正 P1 | synthetic な1行 fixture だけでは #2290 の事故を再現していない | 要修正 P1 | candidate_readiness() を汎用 HTML gate にするのは責務過多 | 縮小推奨 P2 | malformed HTML という問題設定が少し不正確 | 文言修正P0-1 —
anchor_context.extract_candidates()を直しても、実事故経路が残り得るここが最大の blocker です。
#2333 は主防御点を
anchor_context.py::extract_candidates()とcandidate_readiness()に置いています。 しかし current main の freeform human-context 経路では、run_refinement_preflight.py::_build_scope_delta_authority_evidence()が rawcomment_bodyを直接scope_signal_delta.extract_directive_items(comment_body)に渡しています。そして
extract_directive_items()は現在、bullet の-/*を外すだけです。さらに downstream のderive_contract_patch_operations()がその文字列から section operation を作ります。 この freeform contract-update lane は PR #1332 で導入された経路です。一方、
anchor_context.pyは PR #1923 で、複数ターンコメントの話者分離・candidate surfacing 用 pure analyzer として追加されたもので、candidate はunclassified、final_candidateも選ばない設計です。通常の単一ターンレビューは multi-turn route の対象ですらありません。したがって、
raw anchor → _build_scope_delta_authority_evidence → extract_directive_items → derive_contract_patch_operations → build_section_aware_candidate_body → readiness → transactionが主に守るべき経路です。
修正案: normalization を
extract_candidates()固有機能にせず、raw anchor → normalized directive の境界に置いてください。scope_signal_delta.pyはすでに #2333 の Allowed Paths に入っているので、scope expansion は不要です。P0-2 — 「HTML が1つでもあれば reject」は GitHub の入力言語を壊す
AC4 は最終 candidate body に
<html>/<body>/<code/<p>/<li>/<ul>等が「一切含まれない」こと、AC5 は HTML を含む candidate body をgoにしないことを要求しています。これは契約として広すぎます。
GitHub Flavored Markdown は raw HTML を正式に扱い、GFM spec でも raw HTML block / inline raw HTML が定義されています。危険な一部タグは tagfilter されますが、それ以外の HTML tag は残されます。(GitHub Docs) さらに GitHub 自身が issue/comment で
<details>/<summary>を使うことを公式に推奨しています。(GitHub Docs)つまり、たとえば既存 Issue 本文に正当な
<details>が1個あるだけで、無関係な Allowed Paths 更新までcandidate_readiness_not_goになる設計になり得ます。これは今回の運用方針と逆です。守るべき invariant は、
「candidate body に HTML が存在しない」ではなく、「anchor 由来の clipboard contamination が新たに mutation payload へ混入しない」
です。
P1 — arbitrary HTML sanitizer より、CF_HTML 汚染を狙い撃ちした方がよい
#2290 の raw comment は単なる「HTMLを使ったコメント」ではありません。
<!--StartFragment-->/<!--EndFragment-->を含む HTML serialization の後ろに、同内容の Markdown が再度連結されています。Microsoft の CF_HTML 仕様でも、この
StartFragment/EndFragmentコメントは HTML clipboard fragment の境界 marker として明示的に規定されています。(Microsoft Learn)なので、小規模プロジェクト向けには汎用 sanitizer より次の実装が適しています。
raw snapshot 自体は現在どおり無加工で保存する。GitHub REST の
bodyは仕様上「raw markdown body」なので、HTMLが入っていること自体は API 異常ではありません。(GitHub Docs)directive extraction 前に
normalize_anchor_comment_for_directives()相当の pure function を1つ通す。通常コメントは byte-for-byte pass-through。StartFragment+EndFragment+ HTML wrapper + trailing Markdown という 実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290/導入: Issue contract / DoR / dependency 判定による AI 実装前提基盤の整備 (parent) #40/実装: 動作検証 AC の適用判定・延期契約・SKIP/fallback 取扱い・VC 推奨コマンド方針を各 skill/docs に反映する #77 型だけを検出したら、後半の Markdown copy を canonical input とする。marker はあるが trailing Markdown を一意に切り出せない場合だけ、その anchor-derived contract update を
blocked / writes: 0にする。汎用 HTML tag stripping はしない。authorization-bearing Allowed Paths の exact path extractor には安価な最終防御として
</>や<!--StartFragmentが混ざった token を path literal と認めない。この方式なら HTML parser や
bleachは不要です。body_textに切り替える案もありますが、GitHub API の text representation は Markdown 構造を落とすため、bullet/path directive extraction には向きません。(GitHub Docs)P1 — AC は実事故経路を通すべき
現在の再現 fixture は、
という、すでに途中まで壊れた1行から始まっています。これだけだと
anchor_contextの unit test を通しても、production producer が untouched なままという実装が可能です。#2290 の構造を匿名化して、そのまま fixture 化する方が強いです。つまり「先頭 CF_HTML envelope →
EndFragment→ closing wrapper →## 判定以下の Markdown duplicate」を入力し、raw comment → _build_scope_delta_authority_evidence → extract_directive_items → derive_contract_patch_operations → run_trusted_anchor_iteration_zeroまで通してください。成功条件は clean operation だけが書かれる、canonicalize 不能なら
writes == 0のどちらかで十分です。PR #2057 で既に production consumer と callback-based transaction lane が整備されているため、新しい live GitHub mutation harness は不要です。逆方向の regression として、既存 Issue body に
<details>がある状態で clean anchor update が正常継続するケースも必須です。#2333 をどう直すか
Outcome は「HTMLを除去する」ではなく、**「CF_HTML/clipboard artifact が normalized directive / patch operation に伝播しない」**へ変更するのがよいです。主変更点は
scope_signal_delta.extract_directive_items()の前段 normalization と、必要ならanchor_context.extract_candidates()から同じ helper を再利用する形です。AC も、概ね「実 #2290 型入力が deterministic に canonicalize または reject」「生成 operation に CF_HTML marker / HTML suffix がない」「contaminated Allowed Paths token は operation 化されない」「正当な
<details>等の GFM raw HTML は妨げない」「ambiguous contamination は mutation 前に writes=0」「既存 suite PASS」にすると、目的とテストが一致します。candidate_readiness()への全 body HTML scan とscope_signal_delta.build_section_aware_candidate_body()への第三の sanitizer は削ってよいです。既存 mutation lane は readiness → fresh Issue/anchor reread → anchor identity 再検証 → transaction という順序をすでに持っています。 source normalization 1層 + authorization-bearing path token の小さな防御 + production-path regression test で十分です。また Runtime Verification Applicability の
not_applicableはそのままでよいです。外部サービスや実 GitHub mutation の system test を足す利益は小さく、uv run --locked pytestの deterministic fixture で今回の事故は十分再現できます。PR #1923/#2057 もこの系統の検証を--lockedpytest で行っています。結論として、#2333 は close/reject ではなく
## 判定reframe_in_placeが適切です。 P0-1 と P0-2 を直せば、変更量はむしろ現在案より小さくなり、#2290 の実害に対する回帰防止精度も上がります。REQUEST_CHANGES。P0 が2件あります。
#2333 の目的自体――#2290 で実際に起きた Issue 本文破損を再発させない――は妥当です。ただし現状の契約のまま実装すると、実際の汚染経路を完全には塞がない一方、正当な GitHub Markdown/HTML を広範囲に拒否する可能性があります。個人開発の運用性を考えると、ここは実装前に scope を少し組み替えた方がよいです。#2290 では OWNER コメントに CF_HTML 由来と見られる HTML と、その後ろに同内容の Markdown が連結され、それが patch operation に伝播したことが確認されています。 #132 でも同型事故について「対応が必要」と結論済みです。
candidate_readiness()を汎用 HTML gate にするのは責務過多malformed HTMLという問題設定が少し不正確P0-1 —
anchor_context.extract_candidates()を直しても、実事故経路が残り得るここが最大の blocker です。
#2333 は主防御点を
anchor_context.py::extract_candidates()とcandidate_readiness()に置いています。 しかし current main の freeform human-context 経路では、run_refinement_preflight.py::_build_scope_delta_authority_evidence()が rawcomment_bodyを直接scope_signal_delta.extract_directive_items(comment_body)に渡しています。そして
extract_directive_items()は現在、bullet の-/*を外すだけです。さらに downstream のderive_contract_patch_operations()がその文字列から section operation を作ります。 この freeform contract-update lane は PR #1332 で導入された経路です。一方、
anchor_context.pyは PR #1923 で、複数ターンコメントの話者分離・candidate surfacing 用 pure analyzer として追加されたもので、candidate はunclassified、final_candidateも選ばない設計です。通常の単一ターンレビューは multi-turn route の対象ですらありません。したがって、
raw anchor → _build_scope_delta_authority_evidence → extract_directive_items → derive_contract_patch_operations → build_section_aware_candidate_body → readiness → transactionが主に守るべき経路です。
修正案: normalization を
extract_candidates()固有機能にせず、raw anchor → normalized directive の境界に置いてください。scope_signal_delta.pyはすでに #2333 の Allowed Paths に入っているので、scope expansion は不要です。P0-2 — 「HTML が1つでもあれば reject」は GitHub の入力言語を壊す
AC4 は最終 candidate body に
<html>/<body>/<code/<p>/<li>/<ul>等が「一切含まれない」こと、AC5 は HTML を含む candidate body をgoにしないことを要求しています。これは契約として広すぎます。
GitHub Flavored Markdown は raw HTML を正式に扱い、GFM spec でも raw HTML block / inline raw HTML が定義されています。危険な一部タグは tagfilter されますが、それ以外の HTML tag は残されます。([GitHub Docs]1) さらに GitHub 自身が issue/comment で
<details>/<summary>を使うことを公式に推奨しています。([GitHub Docs]2)つまり、たとえば既存 Issue 本文に正当な
<details>が1個あるだけで、無関係な Allowed Paths 更新までcandidate_readiness_not_goになる設計になり得ます。これは今回の運用方針と逆です。守るべき invariant は、
「candidate body に HTML が存在しない」ではなく、「anchor 由来の clipboard contamination が新たに mutation payload へ混入しない」
です。
P1 — arbitrary HTML sanitizer より、CF_HTML 汚染を狙い撃ちした方がよい
#2290 の raw comment は単なる「HTMLを使ったコメント」ではありません。
<!--StartFragment-->/<!--EndFragment-->を含む HTML serialization の後ろに、同内容の Markdown が再度連結されています。Microsoft の CF_HTML 仕様でも、この
StartFragment/EndFragmentコメントは HTML clipboard fragment の境界 marker として明示的に規定されています。([Microsoft Learn]3)なので、小規模プロジェクト向けには汎用 sanitizer より次の実装が適しています。
bodyは仕様上「raw markdown body」なので、HTMLが入っていること自体は API 異常ではありません。([GitHub Docs]4)normalize_anchor_comment_for_directives()相当の pure function を1つ通す。通常コメントは byte-for-byte pass-through。StartFragment+EndFragment+ HTML wrapper + trailing Markdown という 実装: Claude extension surface risk-trigger policy を review-issue / issue-contract-review の deterministic gate に配線する #2290/導入: Issue contract / DoR / dependency 判定による AI 実装前提基盤の整備 (parent) #40/実装: 動作検証 AC の適用判定・延期契約・SKIP/fallback 取扱い・VC 推奨コマンド方針を各 skill/docs に反映する #77 型だけを検出したら、後半の Markdown copy を canonical input とする。blocked / writes: 0にする。汎用 HTML tag stripping はしない。</>や<!--StartFragmentが混ざった token を path literal と認めない。この方式なら HTML parser や
bleachは不要です。body_textに切り替える案もありますが、GitHub API の text representation は Markdown 構造を落とすため、bullet/path directive extraction には向きません。([GitHub Docs]4)P1 — AC は実事故経路を通すべき
現在の再現 fixture は、
という、すでに途中まで壊れた1行から始まっています。これだけだと
anchor_contextの unit test を通しても、production producer が untouched なままという実装が可能です。#2290 の構造を匿名化して、そのまま fixture 化する方が強いです。つまり「先頭 CF_HTML envelope →
EndFragment→ closing wrapper →## 判定以下の Markdown duplicate」を入力し、raw comment → _build_scope_delta_authority_evidence → extract_directive_items → derive_contract_patch_operations → run_trusted_anchor_iteration_zeroまで通してください。成功条件は clean operation だけが書かれる、canonicalize 不能なら
writes == 0のどちらかで十分です。PR #2057 で既に production consumer と callback-based transaction lane が整備されているため、新しい live GitHub mutation harness は不要です。逆方向の regression として、既存 Issue body に
<details>がある状態で clean anchor update が正常継続するケースも必須です。#2333 をどう直すか
Outcome は「HTMLを除去する」ではなく、**「CF_HTML/clipboard artifact が normalized directive / patch operation に伝播しない」**へ変更するのがよいです。主変更点は
scope_signal_delta.extract_directive_items()の前段 normalization と、必要ならanchor_context.extract_candidates()から同じ helper を再利用する形です。AC も、概ね「実 #2290 型入力が deterministic に canonicalize または reject」「生成 operation に CF_HTML marker / HTML suffix がない」「contaminated Allowed Paths token は operation 化されない」「正当な
<details>等の GFM raw HTML は妨げない」「ambiguous contamination は mutation 前に writes=0」「既存 suite PASS」にすると、目的とテストが一致します。candidate_readiness()への全 body HTML scan とscope_signal_delta.build_section_aware_candidate_body()への第三の sanitizer は削ってよいです。既存 mutation lane は readiness → fresh Issue/anchor reread → anchor identity 再検証 → transaction という順序をすでに持っています。 source normalization 1層 + authorization-bearing path token の小さな防御 + production-path regression test で十分です。また Runtime Verification Applicability の
not_applicableはそのままでよいです。外部サービスや実 GitHub mutation の system test を足す利益は小さく、uv run --locked pytestの deterministic fixture で今回の事故は十分再現できます。PR #1923/#2057 もこの系統の検証を--lockedpytest で行っています。結論として、#2333 は close/reject ではなく
reframe_in_placeが適切です。 P0-1 と P0-2 を直せば、変更量はむしろ現在案より小さくなり、#2290 の実害に対する回帰防止精度も上がります。squne121 commentedon Aug 24, 2026
issue-refinement-loop: approved
sha256:59eb4c048633ac90c96a20b59c3178800e9e05929609d8579a589604a8ccca94経緯
codebase-investigatorによる read-only 独立検証で、レビュー指摘の P0-1(主防御点が実際の production mutation path とずれている)が事実であることを確認(run_refinement_preflight.py::_build_scope_delta_authority_evidence()5478行が raw comment_body を無加工のままscope_signal_delta.extract_directive_items()へ渡している)。run_root_review_pipeline.py produce): 初回VERDICT: needs-fix(blocker 2件: Required Design References 欠落、AC6 VC の baseline preflight timeout)。issue-editor経由で Issue 契約を全面改訂。主防御点を実 production path(scope_signal_delta.py::extract_directive_items()入力境界、および Allowed Paths token extractor)へ reframe。AC4/AC5 の「HTML 全面禁止」を撤回し、GFM の正当な raw HTML(<details>等)を妨げない設計へ縮小。CF_HTML envelope fixture・<details>非regression fixture を要求する AC へ更新。AC6 VC に# preflight-scope: pr_review_onlyを付与して timeout を解消。Required Design References に既存 doc を追加。VERDICT: approve(blocker 0)。issue-design-reviewer):severity: highfinding 1件 — 「Allowed Paths exact path token extractor」の実装対象ファイルがrun_refinement_preflight.pyと誤記載されており、実際はscope_signal_delta.py::_normalize_exact_repository_path_literal()/_extract_path_literals_from_text()(derive_contract_patch_operations()の Allowed Paths 分岐、~1189〜1194行から呼び出される)であることが2つの独立 review agent で確認された。rewrite_lane: semantic): 該当箇所を修正。VERDICT: approve。Step 2.5 再実行:assessment: clear(findings 0件、全 line 参照が現在のソースと完全一致することを独立検証済み)。gate-final-review:final_review_allowed: true。最終状態
Issue #2333 は refinement loop 上
approvedで終了。契約は #2290 実害の実防御経路(scope_signal_delta.py::extract_directive_items()の入力境界、および同ファイルの Allowed Paths exact path token extractor)を正しく対象とし、GitHub Flavored Markdown の正当な raw HTML を破壊しない設計へ収束している。Final Gate: passed(
gate-final-reviewfinal_review_allowed: trueを確認済み)。次の canonical step は
impl-review-loopへの handoff(root_entry_router.py::run_root_transition())だが、本セッションのスコープはissue-refinement-loopの完了までとし、実装フェーズの自動起動は行っていない。squne121 commentedon Aug 24, 2026
implement-issue: 実装完了 (2026-08-25T00:00:00Z)
.claude/worktrees/issue-2333-cf-html-anchor-sanitizeworktree-issue-2333-cf-html-anchor-sanitizetest_command_registry.pyの既存環境依存uv_version_mismatch、本PR変更とは無関係、main側でも同一failureを確認済み)fix: CF_HTML canonicalization boundary/evidence一貫性の欠陥をfix_delta修正 (#2333
fix: anchor comment処理でCF_HTML/clipboard混入を検出しcanonicalize/reject (#2336)