Repository navigation
実装: anchor comment の全文取得・複数ターン話者分離・supersession検出をClaude Code経路に配線する - #1923
Conversation
anchor_context.py を新規追加し、run_refinement_preflight.py が生成する既存 snapshot artifact のみを入力に、`# you asked` / `# chatgpt response` マーカー での話者分節(segment)と箇条書き・prose directive 候補抽出(candidates)を 決定論的に行う。セグメント間の意味関係分類と final_candidate の自動選択は Out of Scope のまま維持し、複数候補が存在する場合は known_context の scope_delta_decision を既存の fail_closed(human 判断待ち)ステータスへ route する。known_context に source_fetch_complete / source_hash_verified / source_ranges_covered(interval union 判定)を 追加し、heavy mutation カテゴリ(close / not planned 等)は owner 発言由来の 明示的決定がない限り fail-closed で停止するゲートを追加した。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ese Checkのしきい値以上にする (#1891) PR Body Japanese Check が新規見出し '### segment / candidates' と '### heavy mutation gate(AC6)' の日本語比率0を検出したため、 既存見出しの慣例(英語見出し+括弧書き日本語説明)に倣い併記を追加する。 アンカー構造・見出し文言の意味は変更しない。
Preview URLPreview removed (PR #1923 closed). |
you askedmessage time: 2026-08-01 17:31:09 #1923 chatgpt responsePR #1923の差分、関連Issue・過去PR・レビュー・CI・main契約を横断し、実装と配布経路の破綻や検証漏れを優先度付きで精査します。外部仕様は一次資料で照合します。 chatgpt response初期確認ではdraft・mergeableで既存レビューはなく、変更はAllowed Paths内です。一方、heavy-mutation判定が停止境界へ届かず記録のみの疑いがあり、consumer配線を追跡中です。 chatgpt response実トランザクションはgateを参照せず、完全取得判定も同一snapshot比較で切断を検出できません。さらにGFM構造無視の信頼境界違反と、日本語検査CI失敗を確認しました。 chatgpt response結論:
|
| AC | 評価 | 理由 |
|---|---|---|
| AC1 | Partial | marker分節はあるが、Markdown containerを無視し、you_askedをOWNERへ誤昇格する |
| AC2 | Pass narrowly | markerなし区間はunknown。ただしquoted/container分類はない |
| AC3 | Partial | 複数候補は返すが、日本語非箇条書きを欠落し、source spanも不正確になり得る |
| AC4 | Fail | evidence builderへ候補を渡さず、fail_closedも実停止へ接続されない |
| AC5 | Partial | interval merge utilityはあるが、取得完全性は証明しない |
| AC6 | Fail | helperの戻り値のみ。標準CLI・planner・actual mutationのいずれも停止しない |
| AC7 | Partial/Fail | fixture種類はあるが日本語回帰がなく、current required checkが失敗 |
| AC8 | Pass narrowly | analyzer自身がAPI clientを持たない点は確認できる。ただしproduction wiringの安全性は別問題 |
推奨する最小収束設計
#1860は、live Issue/PR、実diff、実テスト、current-head CI、独立reviewをauthorityとし、新しいledger、digest、checker、enforcing hookを増やさない方針です。 既にマージ済みのPR #1875も、replay authorityや永続state storeを削除し、既存のlive-state境界へ縮退させています。
したがって、修正後の構成は次で十分です。
-
Analyzer
- Markdown block-aware
transcript_user / quoted_assistant / unknown- 言語非依存のparagraph収集
- 意味関係は引き続き
unclassified
-
Preflight
- user turnが2回以上なら既存human-judgment reasonでfail closed
scope_delta_decision.statusを既存blockerへ実際に投影- exit 2までintegration test
-
Mutation
- 新しいglobal hookは作らない
- dependency/relationship操作は既存controlled executorでaction-bound確認
- close/not-plannedについて既存transaction境界がなければ、当面human-onlyにする
-
Freshness
- mutation直前にcomment ID、updated_at、body hashを再確認
- drift時は無操作で停止
- mutation後にlive readback
-
Evidence
- transaction-localなcompact候補だけを保持
- 新しい永続decision ledgerやready artifactは作らない
修正後に必須となるnegative regression
最低限、以下がcurrent headで必要です。
- 日本語の非箇条書き後続方針転換がblockedになる。
You Asked + ChatGPT Responseの一往復だけではmulti-turn扱いしない。- fenced code内のmarkerを無視する。
- OWNERコメント内に貼られた第三者会話をOWNER発言へ昇格しない。
- 非連続行を一つのsource spanへ結合しない。
- full
run_preflight()でmulti-turn ambiguityがexit 2になる。 - owner evidenceなしのheavy mutationでexecutor callbackが一度も呼ばれない。
- body-update承認でclose/dependency removalを許可しない。
- preflight後にcommentが更新された場合、mutationを実行しない。
- current-headの全required checksがgreenになる。
最終判断は REQUEST_CHANGES です。少なくともAC4、AC6、action binding、current CIを修正するまでは、PRをready化せず、Issue #1891もcloseすべきではありません。
なお、sourceとcurrent GitHub Actionsログはcurrent headから確認しましたが、実行環境のGitHub接続制約により、ローカルclone上での独立pytest再実行は行っていません。
you asked
message time: 2026-08-01 18:13:51
#1891 (comment)
#1891 (comment)
コメントの内容と全然ちがくない?
chatgpt response
指摘どおりです。前回は指定2コメントの最終内容ではなく、関連Issue全体の設計論と実装差分を混ぜてレビューしてしまいました。指定コメントをID単位で再取得し、何を要求していたかを切り分けます。
はい。前回のレビューは、指定された2コメントとの対応関係を正しく評価できていませんでした。
5150107711 は「Claude Code用の永続カスタムサブエージェントを追加すると、Codex CLI側にも対応エージェントが要求されるのでは」という質問です。
それに対する 5150201512 の主要な結論は、次の内容です。
- #1891では永続custom agentを追加しない。
- 既存read-only agentかセッション限定agentを使う。
final_candidateを自動選択しない。- マーカーなし区間は
speaker: unknownにする。 - 決定論的処理を取得・hash・範囲検証と候補抽出に限定する。
- 独自のfetch/artifact authorityを重複実装しない。
- 通常改善とheavy mutationを分離する。
- 意味判断はmain threadまたは将来のresolverに残す。
PR #1923は、まさにこのレビュー後に改訂されたIssue本文を実装したものです。具体的には、次の点は指定コメントへの是正として正しく実装されています。
.claude/agents/**や.codex/agents/**を追加していない。- 新規GitHub API取得経路を作らず、既存snapshotを入力としている。
final_candidateは常にNone。- 候補の
relationはunclassified。 - マーカーなし区間は
unknown。 - heavy mutationと通常改善を区別するhelperを追加している。
- 新しい永続decision ledgerやready artifactを追加していない。
したがって、前回私が述べた以下のような論点は、指定コメントに対する「未対応事項」として扱うべきではありませんでした。
final_candidate自動選択への批判- マーカーなし区間をowner扱いするという批判
- 独自fetch/artifact layerを追加したという批判
- 永続Claude agentとCodex counterpartの不整合
- #1860のminimal harness方針を全面的に無視したという批判
これらは、5150201512 が指摘した旧Issue設計の問題であり、PR #1923はその多くを解消しています。私は旧レビューの問題点を、あたかも現PRにもそのまま残っているかのように再掲してしまいました。
正しく評価すべき残論点
指定コメントとの差分として見ると、残る可能性がある問題は限定的です。
- heavy mutation gateの実効配線
helperが blocked/fail_closed を返すことと、実際のmutationが停止することは別です。この点はPR実装に対する独立した技術的確認事項です。ただし、指定コメントの要求を無視したという話ではなく、「要求を実装しようとしているがconsumerまで届いているか」という配線レビューです。
- multi-turn human-judgment routeの実効性
scope_delta_decision.status = fail_closed が最終preflight statusやexit codeへ反映されるかは確認対象です。これも設計方向の不一致ではなく、producer-consumer wiringの問題です。
- CI失敗
current headでは英語Markdown fixtureが日本語比率チェックに失敗しています。これは明確な修正事項ですが、指定コメントの内容との齟齬ではありません。
- AC4の厳密な実装位置
Issue本文は _build_scope_delta_authority_evidence() にcandidate出力を渡すと書いていますが、PRはbuilderの後段でrouteしています。結果が同等か、Issue契約を更新すべきかは精査余地があります。
訂正後の判定
前回の広範な REQUEST_CHANGES は過剰で、根拠の一部が不適切でした。
現時点で妥当なのは次です。
CORRECTED_REVIEW:
specified_comment_alignment: substantially_addressed
persistent_agent_parity_concern: not_applicable
old_design_blockers:
final_candidate_selection: resolved
unmarked_owner_promotion: resolved
duplicate_fetch_authority: resolved
persistent_custom_agent: avoided
remaining_review_scope:
- fail_closed producer-to-consumer wiring
- heavy mutation enforcement wiring
- AC4 implementation-location mismatch
- failing Japanese-content CI
verdict: REQUEST_CHANGES
reason: limited implementation and CI defects, not architectural noncomplianceつまり、PRの設計方向は指定コメントにかなり忠実です。前回は「指定コメントを受けた後の修正版」であることを基準に差分評価せず、指定コメント自身の旧設計批判を現PRへ重ねてしまいました。これは私のレビュー手順上の誤りです。
Powered by AI Exporter
…ers に実配線する PR #1923 OWNER REQUEST_CHANGES (CORRECTED_REVIEW) 対応(iteration 2)。 - _apply_multi_turn_candidate_route() / _classify_heavy_mutation_gate() の 結果が known_context に格納されるだけで blockers(_apply_exit_code_mapping() が参照する唯一のリスト)に一切反映されず、AC4/AC6 が loop を実際には 止めていなかった構造的欠陥を修正。BLOCKER_ANCHOR_MULTI_TURN_FAIL_CLOSED / BLOCKER_HEAVY_MUTATION_FAIL_CLOSED を新設し、該当条件で blockers に追加する。 - AC4: _build_scope_delta_authority_evidence() の呼び出し箇所を anchor_context.py の segment/candidates 出力を実際に受け取る単一箇所へ 是正(segments_result/candidates_result を optional kwarg として追加、 呼び出し順序を Issue In Scope の記述に合わせて再配置)。 _apply_multi_turn_candidate_route() 自体のロジックは変更なし。 - fixture (anchor_multi_turn_869_lines.md) を日本語前置き+コードフェンス でラップし、Japanese Check (per-block) を解消。 検証: - test_anchor_context_multi_turn_supersession.py: 17 tests pass (既存13 + 新規4件の production subprocess integration test) - issue-refinement-loop/tests/ 全体 1142 tests pass (回帰なし) - ruff check: 変更ファイルすべて pass - validate_japanese_content.py: fixture / reference doc 両方 exit 0 - plan_refinement_loop.py は一切編集していない (Allowed Paths 外) Co-Authored-By: Claude Sonnet 5 <[email protected]>
pr-review-judge: APPROVE (2026-08-01T09:40:00Z)OWNER の REQUEST_CHANGES(このPRへの直接コメント、訂正済みCORRECTED_REVIEWブロックが正本)に対する修正が完了し、再レビューで APPROVE となりました。 Mergeability
対応した指摘(iteration 2)
Evidence
verdict: APPROVE
reviewed_head_sha: "616c6509c64c6bfa17e9af851a64e56d0cc9c38b"
blockers: []
warnings:
- "references/anchor-comment-handling.md の追記は blockers/exit-code 配線の事実(iteration 2 修正内容)に触れていない。将来の再発防止のためドキュメントへの言及を推奨(non-blocking)。"次アクション: 人間レビュー → Ready化 → マージ → post-merge-cleanup |
Summary
Issue #1891 の実装です。anchor comment(OWNER 発言を含む長文コメント・複数ターンを含むエクスポート済み会話転記)を扱う際の決定論的処理を、「取得完全性の検証」と「話者候補・claim候補の構造化抽出」に限定した pure analyzer として実装しました。
.claude/skills/issue-refinement-loop/scripts/anchor_context.pyを新規追加しました。run_refinement_preflight.pyが既に生成している snapshot artifact(anchor_comment.snapshot)のみを入力とし、独自の GitHub API 呼び出しは持ちません。segmentサブコマンド:# you asked/# chatgpt responseマーカー(大文字小文字・前後空白差を正規化)で本文を分節し、各セグメントにspeaker: owner | quoted_assistant | unknownとstart_line/end_lineを付与します。マーカーが存在しない区間は常にspeaker: unknownとし、ownerへの自動昇格はしません。candidatesサブコマンド: 各セグメント内の箇条書き・prose directive 候補をsource_span(行範囲)付きで抽出します。全候補はrelation: unclassifiedを持ち、単一のfinal_candidateを選択するロジックは実装していません(意味関係の分類・最終決定の判断は Out of Scope のまま維持)。run_refinement_preflight.pyの anchor comment 処理パスに以下を追加しました。_apply_multi_turn_candidate_route():anchor_context.pyが検出したマーカー付きセグメントが 2 つ以上あり、かつ複数候補が存在する場合に限り、known_context.scope_delta_decision.statusを既存のfail_closed(human 判断待ち)へ route します。単一ターンの通常レビューコメントはこの経路の対象外です。known_contextにsource_fetch_complete/source_hash_verified/source_ranges_coveredの 3 フィールドを追加しました。source_ranges_coveredはanchor_context.compute_source_ranges_covered()による inclusive interval の和集合判定で計算され、単純合計ではなく genuine interval merge を用いるため、重複・オーバーラップする区間による過大評価を防ぎます。_classify_heavy_mutation_gate(): heavy mutation カテゴリ(close/not_planned/replacement_issue_creation/dependency_removal/parent_child_change)は owner 発言由来の明示的決定(scope_delta_decision.status == "approved_by_trusted_anchor"かつanchor_author_association == "OWNER")が確認できない限りstatus: blocked/fail_closed: trueを返します。非 heavy な通常改善・追加調査は従来通りstatus: warnで継続します。.claude/skills/issue-refinement-loop/tests/fixtures/anchor_multi_turn_869_lines.mdを新規追加しました。実際の事故コメントの構造(前半 REQUEST_CHANGES セグメント・後方 owner 方針転換セグメント)を模した、個人情報を含まない合成 869 行 fixture です。.claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.pyを新規追加し、869 行 fixture・追加のみケース・部分撤回ケース・マーカー無し区間ケースの計 4 種の fixture を含む回帰テストを実装しました。.claude/skills/issue-refinement-loop/references/anchor-comment-handling.mdにanchor_context.pyの挙動(segment / candidates / route / known_context フィールド / heavy mutation gate)を追記しました。セグメント間の意味関係(add/replace/retract/confirm/narrow/conditional/explanation/quotation/unknown)の自動分類、および「どの候補が最終決定か」を選ぶロジックは実装していません(Issue #1891 Out of Scope)。Codex CLI 側の同等実装(Child 2、
#1890参照)は本 PR のスコープ外です。Checks
以下の検証コマンドはすべて実行済みで、結果は PASS です。
uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py -k test_segment_splits_you_asked_chatgpt_response_markers— 結果は PASS でした。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py -k test_segment_unmarked_span_is_unknown_speaker— 結果は PASS でした。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py -k test_candidates_returns_multiple_unclassified_no_final_candidate— 結果は PASS でした。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py::test_multiple_candidates_route_to_human_judgment— 結果は PASS でした。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py -k test_source_ranges_covered_interval_union_no_overcount— 結果は PASS でした。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py -k test_heavy_mutation_fail_closed_without_owner_evidence— 結果は PASS でした。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py— 結果は PASS でした。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py -k test_anchor_context_subprocess_e2e_no_own_github_api_call— 結果は PASS でした。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/(全 1138 件、既存回帰含む) — PASSuv run ruff check .claude/skills/issue-refinement-loop/scripts/anchor_context.py .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py— PASSRuntime Verification Applicability:
not_applicable(全 AC は決定論的な分節・候補抽出ロジックと既存 snapshot artifact を pytest で検証でき、実 GitHub API 通信を要する動作検証 AC は存在しません)。Schema Change Applicability
anchor_context.pyは新規ファイルであり既存 schema の破壊的変更を含みません。run_refinement_preflight.pyの変更はknown_contextへの新規フィールド追加(source_fetch_complete/source_hash_verified/source_ranges_covered/heavy_mutation_gate)とscope_delta_decisionの既存fail_closedステータス再利用(新設なし)のみで、既存フィールドの型・意味を変更していません。plan_refinement_loop.py(planner)はknown_contextを透過的に受け取るのみで、新規フィールドの有無に依存する分岐を持ちません。Schema Consumer Inventory
N/A
reason:
not_schema_changeであり、既存 consumer の受け取る契約に破壊的変更(フィールド削除・型変更・意味変更)がないためです。Safety Claim Matrix
anchor_context.pyは独自の GitHub API 呼び出しを持たず、既存 snapshot artifact のみを入力とするtest_anchor_context_subprocess_e2e_no_own_github_api_call(静的ソース検査 + production subprocess 起動、AC8)speaker: unknownのままとしownerへ自動昇格しないtest_segment_unmarked_span_is_unknown_speaker/test_segment_unmarked_leading_span_before_first_marker_is_unknown(AC2)final_candidateの自動選択は行わない(Out of Scope を侵害しない)test_candidates_returns_multiple_unclassified_no_final_candidate等、extract_candidates()は常にfinal_candidate: Noneを返す(AC3)test_heavy_mutation_fail_closed_without_owner_evidence(AC6)source_ranges_coveredは重複・オーバーラップ区間で誤ってtrueにならないtest_source_ranges_covered_interval_union_no_overcount(AC5、interval merge の回帰テスト)Notes
not_applicable(Issue 本文の同セクション参照)。anchor_context.py/run_refinement_preflight.py/test_anchor_context_multi_turn_supersession.py/test_scope_delta_authority.py/anchor_multi_turn_869_lines.md/anchor-comment-handling.md)の範囲内で完結しています(test_scope_delta_authority.pyは今回変更不要でした)。#1890参照)は本 PR のスコープ外です。