Skip to content

実装: multi-turn anchor の owner turn を chronology metadata として扱い、reaction decision flow を issue-refinement-loop と impl-review-loop へ導入する #1950

Closed
2 of 2 issues completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1890"
goal_ref: "anchor comment の全文・話者分離・取得完全性を維持したまま、owner turn は chronology metadata として保持するに留め(precedence/authorization には昇格させない)、競合する重い mutation だけを owner reaction へ保留する。同じ provenance 分離(human_supplied vs controlled_agent_report、呼び出し元引数で分類)を impl-review-loop の intake / capsule / preparation / Step 1 delegation へも伝搬する。"
change_kind: workflow

Parent Issue

#1890

Parent Goal Ref

#1890 の anchor comment 読了保証・話者分離・supersession 検出を維持し、複数ターンであること自体を hard blocker にしない最小の continuation を追加する。

Current Validated Scope

  • anchor_context.py の既存分節・話者判定・source span・区間和集合による取得完全性を再利用する。
  • run_refinement_preflight.py の _apply_multi_turn_candidate_route() と blockering を、trusted OWNER segment が存在する場合の advisory route へ限定して変更する。
  • root control-plane が競合時に controlled comment lane で選択肢を投稿し、repository owner の reaction を readback して競合 mutation だけを適用できる手順を Skill / reference に定義する。
  • impl-review-loop の build_intake_capsule.py は既に Issue コメントを全ページ取得し author_id / author_type / author_association を保持している。この既存取得結果に、呼び出し元が明示指定した human context / agent report の comment ID を additive に紐付ける(新規 fetch 経路は追加しない)。

Remaining Parent Gaps

Outcome

trusted OWNER を含む multi-turn anchor が、取得完全性・trusted author・heavy mutation gate を保ったまま warn / proceed_with_notes と最後の owner segment の chronology metadata を返し、競合時だけ owner reaction 待ちへ遷移する実装と回帰テストが完成している。同じ human_supplied / controlled_agent_report 分離が impl-review-loop の intake capsule・preparation・Step 1 delegation まで一貫して伝搬し、raw human comment が worker への実行命令として直接連結されないことが production-shaped test で検証されている。

Background

現在は marker 付き segment が2件以上かつ候補が複数なら、候補間の意味関係を判定せず ANCHOR_MULTI_TURN_FAIL_CLOSED として停止する。#1891 / PR #1923 により全文処理・話者分離・source span は既に実装済みである。

本 Issue は当初、最後の owner segment を primary resolution input として precedence 付ける設計だった。この前提は誤りとして棄却する。 指定 anchor comment(#1950 コメント、2ターンの敵対的レビュー)により、以下が事実として確認され、矛盾なく反映する:

  • 最後の owner turn という chronology の事実 と、その turn が持つ semantic relation(追加・撤回・置換・質問・仮定)、technical recommendation、mutation authorization は別軸であり、chronology だけで残り三者を決定してはならない。latest_owner_turn は参考メタデータとして normalized context に残すが、precedence や authorization の根拠にはしない。
  • 人間が投稿したコメントと、SubAgent が返した構造化 report は、本文解析(author_association: OWNER・構造化 marker の有無・投稿アカウント)では分類できない。同一アカウントから機械生成コメント(例: create-issue transaction partial-failure)と人間コメントが混在しうるため、呼び出し元が渡した引数(どの comment URL をどちらの引数として渡したか)だけを origin 判定根拠にする。
  • impl-review-loop は現在この provenance 分離を持たず、issue_number / contract_snapshot_url / max_iterations のみを入力とする。Allowed Paths をこの Issue に含めない限り、ユーザー要求(issue-refinement-loop と impl-review-loop の両方への適用)は半分しか実装されない。二重実装を避けるため、共通 resolver を別 child に切り出すのではなく、本 Issue に impl-review-loop の intake / capsule / preparation / Step 1 delegation への additive 拡張を含める。
  • GitHub reaction API は排他的なラジオボタンではなく、reacting user と content を持つレコード一覧である。有効 principal は stable user ID で固定し、許可 reaction が一意に決まらない場合は unresolved として再評価に戻す。
  • speaker: owner はそれ単体で mutation authorization にはならない(質問・希望・仮説・過去判断の説明でありうる)。技術推奨(repository facts・diff・test・外部仕様から control-plane が決定する)と、明示的な owner 承認(standalone owner decision または decision preview に束縛された reaction)は別に扱う。

新しい semantic classifier、decision ledger、独立 schema、publisher は追加しない。運用だけで multi-turn anchor を避ける workaround は、owner の自由記述を構造化させるため採用しない。

In Scope

issue-refinement-loop 側(既存)

  • trusted OWNER の multi-turn anchor で最後の owner segment の index / source span を latest_owner_turn として normalized context に chronology metadata のみとして記録する(technical recommendation・mutation authorization の precedence には使用しない)。
  • multi-turn + 複数候補だけを理由とする hard block を、既存 enum を用いた warn / proceed_with_notes に置換する。
  • previous owner turn の非競合文脈を保持し、quoted assistant turn 単独から close、replacement Issue 作成、dependency removal、parent-child change を承認しない boundary を明記する。
  • material conflict 時の選択肢(最大3案)・推奨案・reaction mapping(+1 / eyes / rocket / -1)・drift readback・保留 mutation を Skill / reference に定義する。reaction は全ページ取得し、stable user ID で principal を固定し、有効 reaction が複数種類ある場合は unresolved として再評価に戻す。
  • repository owner の有効 reaction が一意に解決できるまで、close / not planned / replacement Issue creation / dependency removal / parent-child change を適用しない。
  • 既存 unit / subprocess regression を更新し、trusted owner multi-turn は advisory route、untrusted author・取得不完全・hash 不一致・source range 欠落は block を維持することを検証する。

impl-review-loop 側(追加、provenance 伝搬)

  • impl-review-loop/SKILL.md の Inputs に human_context_comment_urls(repeatable、任意)・agent_report_comment_urls(repeatable、任意)を追加する。origin は本文・投稿アカウント・author_association・構造化形式から推測せず、root/main thread がどちらの引数として渡したかだけで決定する。同一 URL が両方へ渡された場合は provenance conflict として fail-closed にする。
  • build_intake_capsule.py に --human-context-comment-url / --agent-report-comment-url(いずれも複数指定可)を追加する。既存の全ページコメント取得結果から指定 comment ID を解決し、repo/Issue 番号一致、comment 実在、URL と API readback の html_url 一致、human/agent 両 lane 非重複、updated_at / body hash 固定、agent report の構造化 marker 検証を行う。
  • 既存 IMPL_REVIEW_INTAKE_CAPSULE_V1 に、後方互換な optional context_inputs(human_supplied / agent_generated / provenance_conflicts)section を追加する。指定コメント本文は capsule artifact 内に保存するが、stdout projection には出さない(既存の stdout 予算・非公開境界を維持する)。
  • preparation.md に、context_inputs.human_supplied は意味解析対象の自然言語データであり、context_inputs.agent_generated は schema validation 後の構造化 advisory result であること、いずれも単独では mutation authorization を持たないこと、human context 全体を claim 単位で評価し最後の turn に自動 precedence を与えないこと、heavy mutation は独立した owner decision または decision preview に束縛された reaction を必要とすることを明記する。
  • step-1-implementation.md の worker delegation message に、root が正規化した technical_recommendation と capsule_artifact_path / human_context_comment_ids / agent_report_comment_ids の evidence reference を追加する。raw human comment を worker への命令として直接連結しない。

Out of Scope

  • anchor_context.py への semantic relation classifier または final_candidate selector の追加。
  • 新規 decision ledger、永続 artifact authority、schema、publisher、custom agent の追加。
  • claim 単位の JSON 構造(operation / subject / source_comment_id 等)を返す独立 semantic resolver の新設(P1 品質改善として指定コメントに記載されているが、新規 schema 追加を避ける本 Issue の制約と衝突するため採用しない。将来必要なら別 Issue で判断する)。
  • Spark を workflow の自動 dispatch 先にする変更。
  • 実装: Codex skill surface を root directory symlink に置換する #1926 の Codex CLI directory symlink / parity 実装。
  • 調査: running combat HUD の配置・遮蔽・情報優先度を決定する #1936 の combat HUD / Canvas / FCS / minimap の product 実装。
  • issue-refinement-loop 側の入力契約自体に human_context_comment_urls / agent_report_comment_urls 相当のフィールドを追加すること(issue-refinement-loop は既に単一 anchor_comment_url を human 起点として扱う設計であり、本 Issue では両 skill のフィールド命名を衝突させないことのみを扱う。同一分離の issue-refinement-loop 入力面への正式導入は別 Issue とする)。

Acceptance Criteria

  • AC1: trusted OWNER の multi-turn anchor は最後の owner segment の index / source span を latest_owner_turn として normalized context に含めるが、technical recommendation・mutation authorization の precedence としては使用しない。multi-turn だけでは blocked にならない。
  • AC2: quoted assistant proposal 単独は authority を持たず、untrusted author、取得不完全、hash 不一致、source range 欠落、および owner 明示決定のない heavy mutation は fail-closed を維持する。
  • AC3: material conflict では owner reaction による選択肢を提示し、reaction 前は disputed heavy mutation のみを保留する手順が Skill / anchor reference に記載される。
  • AC4: owner reaction は全ページ取得し stable user ID で principal を固定する。対象 comment / anchor / Issue body の drift、および同一 principal の複数種類の有効 reaction は再評価へ戻し、untrusted reaction は決定として消費しない。
  • AC5: existing multi-turn regression と subprocess preflight regression が、trusted owner advisory route と上記 fail-closed invariant の両方を検証する。
  • AC6: impl-review-loop は human_context_comment_urls / agent_report_comment_urls を独立入力として受け取り、投稿者や本文形式から origin を推測しない。同一 URL の両 lane 指定は provenance conflict として fail-closed にする。
  • AC7: capsule artifact は指定コメントの provenance・body snapshot・hash・updated_at を保持し、stdout は raw body を含まない。
  • AC8: repository/Issue/comment mismatch、二重 lane 指定、存在しない comment、invalid structured agent report を fail-closed にする。
  • AC9: preparation は human natural-language context と structured agent result を別処理し、いずれも単独では mutation authorization に昇格させない。
  • AC10: Step 1 delegation は root が生成した technical recommendation と capsule reference を受け取り、raw comment を実行命令として直接連結しない。
  • AC11: production-shaped subprocess test が CLI 引数から capsule artifact、preparation routing、Step 1 context binding までを検証する。

Verification Commands

# AC1
# baseline-expect: fail
$ rg -nF "chronology metadata" .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
# AC2
# baseline-expect: pass
$ rg -nF "heavy_mutation_requires_owner_explicit_decision" .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
# AC3
# baseline-expect: fail
$ rg -nF "owner reaction" .claude/skills/issue-refinement-loop/references/anchor-comment-handling.md
# AC4
# baseline-expect: fail
$ rg -nF "untrusted reaction" .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py
# AC5
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py -v
# AC6
# baseline-expect: fail
$ rg -nF "human_context_comment_urls" .claude/skills/impl-review-loop/SKILL.md
# AC7
# baseline-expect: fail
$ rg -nF "context_inputs" .claude/skills/impl-review-loop/scripts/build_intake_capsule.py
# AC8
# baseline-expect: fail
$ rg -nF "provenance_conflict" .claude/skills/impl-review-loop/scripts/build_intake_capsule.py
# AC9
# baseline-expect: fail
$ rg -nF "treat_as_untrusted_natural_language" .claude/skills/impl-review-loop/steps/preparation.md
# AC10
# baseline-expect: fail
$ rg -nF "technical_recommendation" .claude/skills/impl-review-loop/steps/step-1-implementation.md
# AC11
# baseline-expect: fail (file does not exist yet)
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_intake_capsule_provenance_e2e.py -v

Runtime Verification Applicability

  • decision: deferred
  • reason: GitHub reaction API・pagination・stable user identity・reaction 削除/複数化・drift は外部システム統合動作であり、rg による文字列存在確認だけでは検証にならない。live GitHub reaction API への疎通確認は本 Issue の Runtime Verification としては deferred とし、非破壊の専用 test Issue/comment を用いた実 API 検証は別途 owner 判断で実施する。AC4・AC5・AC11 が要求する mocked subprocess E2E(reaction レスポンスを fixture 化した test_anchor_context_multi_turn_supersession.py / test_intake_capsule_provenance_e2e.py 経由)は本 Issue の Verification Commands として即時必須とし、実環境未確認である旨を PR 本文に明記する。
  • deferred_destination: 別途 owner 判断による非破壊の専用 test Issue/comment を用いた live GitHub reaction API 疎通確認(本 Issue の follow-up、新規 Issue 起票は不要)
  • deferred_verification_condition: repository owner が live reaction 疎通確認を実施する専用 test Issue/comment を用意し、実 API での reaction readback が mocked E2E と同等の挙動を示すことを確認できた時点

Allowed Paths

  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
  • .claude/skills/issue-refinement-loop/references/anchor-comment-handling.md
  • .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py
  • .claude/skills/impl-review-loop/SKILL.md
  • .claude/skills/impl-review-loop/steps/preparation.md
  • .claude/skills/impl-review-loop/steps/step-1-implementation.md
  • .claude/skills/impl-review-loop/scripts/build_intake_capsule.py
  • .claude/skills/impl-review-loop/tests/test_intake_capsule_provenance_e2e.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合。ただし IMPL_REVIEW_INTAKE_CAPSULE_V1 への backward-compatible optional context_inputs section の追加は本 Issue の In Scope とし、この停止条件には該当しない。
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • semantic relation classifier、final_candidate selector、claim 単位 JSON を返す独立 semantic resolver、または新規 ledger / schema / publisher が必要になった場合は停止する。
  • repository owner の reaction を対象 Issue / decision comment / anchor の fresh readback に安全に束縛できない場合は停止する。
  • untrusted author、取得不完全、hash 不一致、source range 欠落の fail-closed を緩和する必要が生じた場合は停止する。
  • issue-refinement-loop の入力契約自体に human/agent 分離フィールドを追加する必要が生じた場合は停止する(別 Issue 判断)。
  • 実装: Codex skill surface を root directory symlink に置換する #1926 の Codex CLI 配線または 調査: running combat HUD の配置・遮蔽・情報優先度を決定する #1936 の product UI 実装へ scope を広げる必要が生じた場合は停止する。

Required Skills

  • なし

Required Design References

  • docs/dev/workflow.md
  • docs/dev/agent-skill-boundaries.md#Manual Codex Spark Agents
  • .claude/skills/issue-refinement-loop/references/anchor-comment-handling.md
  • .claude/skills/impl-review-loop/steps/preparation.md

Delivery Rule

  • 1 Issue = 1 PR
  • 専用 worktree で実装し、Draft PR を既定とする。

Notes for Reviewer

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    create-issue transaction partial-failure

    Issue: #1950
    Failure stage: dedupe-race-detection
    Message: dedupe-search failed

    Requested:

    Failure context: command=gh issue list --repo squne121/loop-protocol --state open --search in:title "実装: multi-turn anchor の後方 owner turn 優先解釈と reaction decision flow を導入する" --limit 200 --json number,title,url
    output=Post "https://api.github.com/graphql": dial tcp [64:ff9b::141b:b174]:443: connect: network is unreachable
    matching_issue_numbers=[]
    issue_number=1950

    Recovery hint: dedupe-race-detection — automatic recovery is not possible.
    Manual action required: inspect open issues with the same title and decide which to close.
    gh issue list --repo squne121/loop-protocol --state open --search '<title>'
    idempotent re-run: no (requires manual deduplication first)

    Please recover deterministically before re-running the create issue transaction.

  2. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    create-issue transaction partial-failure

    Issue: #1950
    Failure stage: dedupe-label-readback
    Message: label read-back mismatch after retries (dedupe path)

    Requested:

    Failure context: (none)

    Recovery hint: dedupe-label-readback failed for #1950.
    Script-mediated re-apply command (idempotent: yes):
    uv run python3 .claude/skills/create-issue/scripts/create_issue_txn.py reconcile --repo squne121/loop-protocol --issue 1950 --label
    PROHIBITED: raw direct mutation commands are forbidden.
    Recovery MUST go through the reconcile subcommand for audit trail and idempotency.
    Verify:
    gh issue view 1950 --repo squne121/loop-protocol --json labels

    Please recover deterministically before re-running the create issue transaction.

  3. added
    phase/implementation
    agent/implementer
    enhancement
    on Aug 2, 2026
  4. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 、 impl-review-loop に人間が与えるGitHubコメントのURLについては、基本的に人間が出力したコメントです。それに対して、エージェントスキルの中でカスタムサブエージェントが出力してメインエージェントに返すGitHubコメントは、AIエージェントが出力した構造化されたものです。構造化されているAIエージェントの出力と、構造化されていない人間の与えるコメントは分けて処理してほしいです。その中で、人間が与える入力については、AIチャットとのやり取りの中でターンの進みがあり、最終的な人間の判断は変わる可能性があります。そのため、一つのコンテクストの中で競合がある可能性もあるので、AIエージェントはそれらをフラットに解析し、技術的な推奨を判断してほしいです。人間から与えられたコンテクストの中から、人間の判断に固執せず、競合する技術があれば、推奨値を人間に提案してほしいです。

  5. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    you asked

    message time: 2026-08-02 13:56:27

    #1950
    #1950 (comment)
    内容について関連Issue、PR、リポジトリ資産、コメントを参照した上で敵対的レビューして。
    取り扱う技術や配布物の実装をWEB検索し高品質化してほしい。


    chatgpt response

    Issue 本文・指定コメント・関連する Issue/PR・実装資産・CI を突き合わせ、外部仕様も確認します。結論は重大度順の指摘と、Issue 改稿案までまとめます。

    指定コメントは Issue 本文の設計前提を実質的に反転しています。本文は「最新 owner turn を優先」しますが、コメントは「人間コンテキストをフラットに評価し、技術推奨を独立提示」と要求しており、この不整合を中心に追います。

    現行 main には reaction decision 実装はまだありません。また #1950 は issue-refinement-loop の4ファイルだけを許可しており、指定コメントが明示した impl-review-loop 側の入力分類を変更できない構造です。これは現時点で独立した P0 候補です。

    判定

    REQUEST_CHANGES。現行 #1950 のまま実装へ進めるべきではありません。

    方向性自体――multi-turn 入力を即 human_escalation にせず、非競合部分を継続し、重い競合だけを owner 判断へ送る――は妥当です。しかし、指定コメントの核心である「人間入力と AI 生成コメントの出所分離」「全人間ターンをフラットに技術評価」「issue-refinement-loop と impl-review-loop の両方への適用」が契約に反映されていません。指定コメントは単なる補足ではなく、#1950 の設計前提を変更しています。

    P0 — Blocker

    P0-1. latest_owner_turn 優先は指定コメントと正面から矛盾する

    #1950 は「最後の owner segment」を primary resolution input とし、latest_owner_turn precedence を追加しようとしています。

    しかし指定コメントは、時系列上最後の人間判断に従うのではなく、すべての人間ターンをフラットに解析し、リポジトリ・外部仕様・技術的妥当性に基づく推奨を独立して提示するよう求めています。したがって必要なのは次の分離です。

    • chronology: 後続ターンであるという事実
    • semantic relation: 追加、撤回、置換、質問、仮定、説明
    • technical recommendation: 実装・仕様調査に基づく推奨
    • mutation authorization: 重い変更を実行してよいという明示的承認

    「最後」という事実だけで後三者を決めてはいけません。latest_owner_turn は参考メタデータにはできますが、precedence や authorization にしてはいけません。

    P0-2. 人間コメントと agent report を本文から判別できない

    同じ Issue 内で、同じ squne121 アカウントから、人間の指定コメントだけでなく create-issue transaction partial-failure という機械生成コメントも投稿されています。

    したがって、次の情報だけでは出所を分類できません。

    • GitHub の投稿ユーザー
    • author_association: OWNER
    • # you asked / # chatgpt response の本文マーカー
    • JSON・YAML 風に構造化されているか

    出所は本文解析ではなく、呼び出し元で付与する provenance にすべきです。

    human_supplied_context
      人間が loop 起動時に明示指定したコメント URL
    
    controlled_agent_report
      main thread が起動した subagent の直接返却値
      または main thread が記録した既知の comment ID
    
    repository_context
      調査中に発見した Issue / PR / comment
    

    subagent の主経路は GitHub コメントを IPC にせず、構造化結果を main thread へ直接返す方が簡潔です。GitHub 投稿は監査・可視化用の副次記録に限定すべきです。

    長期的に bot 投稿を識別するなら、GitHub App installation token の活動は App に帰属させられます。一方、同じユーザートークンで投稿したコメントを後から「手入力か AI か」判別することはできません。GitHub も mutable な login ではなく stable ID の利用を推奨しています。(GitHub Docs)

    P0-3. impl-review-loop が完全にスコープ外

    指定コメントは issue-refinement-loop と impl-review-loop の両方を明示しています。

    しかし #1950 の Allowed Paths は issue-refinement-loop の4ファイルだけです。 現行 impl-review-loop の入力契約は issue_number、任意の contract_snapshot_url、max_iterations が中心で、人間指定コメントと agent report の origin 分類を持ちません。

    このままでは AC をすべて満たしても、ユーザー要求の半分しか実装されません。

    修正方法は二択です。

    1. 実装: multi-turn anchor の owner turn を chronology metadata として扱い、reaction decision flow を issue-refinement-loop と impl-review-loop へ導入する #1950 に impl-review-loop の intake、preparation、capsule、テストを追加する。
    2. 両 loop が使う共通の transaction-local context resolver を別 child に切り出し、実装: multi-turn anchor の owner turn を chronology metadata として扱い、reaction decision flow を issue-refinement-loop と impl-review-loop へ導入する #1950 をその依存先にする。

    後者の方が二重実装を避けられます。

    P0-4. reaction decision flow に実行 consumer が存在しない

    #1950 は reaction mapping、drift readback、競合 mutation の保留を Skill/reference に記載する計画ですが、現在の canonical router には次の状態がありません。

    decision_requested
    continue_non_disputed_work
    apply_selected_mutation
    decision_stale
    

    現行 decide_next_loop_action.py は pass / warn / human_escalation / inconsistent_state と、既存の bounded-loop action だけを扱い、未知・blocked を最終的に human escalation へ送ります。

    しかも router、loop state、termination policy、reaction reader は Allowed Paths に含まれていません。したがって AC3・AC4 は文書に文字列を書くだけで通る false-green 契約です。

    関連 PR #1923 では、実 subprocess まで通して ANCHOR_MULTI_TURN_FAIL_CLOSED が wrapper の blocked に到達することを検証しました。 #1950 でも同等に、publisher → reaction readback → principal filter → drift check → router → mutation gate の production-shaped test が必要です。

    P0-5. GitHub reaction は単一選択 UI ではない

    GitHub の reaction API は、+1、-1、eyes、rocket などを持つ reaction レコードの一覧です。各レコードには reacting user と content が含まれ、reaction は削除も可能です。排他的なラジオボタンではありません。(GitHub Docs)

    最低限、次を契約化する必要があります。

    • 全ページを取得する。
    • decision principal は login ではなく stable user ID で固定する。
    • 有効 principal の許可 reaction がちょうど1種類であること。
    • 同一 principal の複数 reaction は unresolved とする。
    • decision comment の ID、node ID、body hash、updated_at を固定する。
    • anchor comment と Issue body の hash、updated_at を再取得する。
    • mutation 直前にも再 readback する。
    • reaction が消された、変わった、対象 Issue が変化した場合は適用しない。
    • reaction を使えない場合の Option: A 形式の明示返信 fallback を持つ。

    eyes や rocket は意味が直感的ではないため、option ID と reaction の対応表を decision comment 本文に明示すべきです。

    P0-6. 推奨と承認が混線している

    既存 PR #1923 の heavy mutation gate は、概念上 approved_by_trusted_anchor と OWNER association を満たせば許可する構造です。

    しかし exported conversation 内の owner 発言は、次のいずれにもなり得ます。

    • 質問
    • 希望
    • 仮説
    • AI 提案への追加質問
    • 過去判断の説明
    • 明示的な実行承認

    したがって speaker: owner は authorization evidence ではありません。

    #1936 の実例でも、混在した長文 anchor の後に、独立した ## Owner decision コメントが投稿され、それを根拠に処理が確定しました。 この境界を維持すべきです。

    technical_recommendation:
      main thread がコード・Issue・外部仕様から決定
    
    explicit_owner_authorization:
      standalone owner decision
      または preview に束縛された reaction / reply
    

    P1 — 品質改善

    semantic resolver は read-only に限定する

    人間コンテキストの意味解釈は、決定論的 parser ではなく main thread または低コスト read-only subagent に任せるのが妥当です。ただし GitHub コメントは外部・引用コンテンツを含むため、命令ではなく untrusted data として渡す必要があります。

    resolver は次だけを返すべきです。

    {
      "claims": [
        {
          "operation": "add | replace | retract | confirm | question",
          "subject": "...",
          "source_comment_id": 123,
          "source_span": {"start_line": 10, "end_line": 14}
        }
      ],
      "conflicts": [],
      "technical_recommendation": "...",
      "authorization": "absent"
    }

    shell、GitHub mutation、権限判定は持たせません。OWASP も外部コンテンツと命令の分離、least privilege、高リスク操作への人間承認を推奨しています。(OWASP Gen AI Security Project)

    Runtime Verification を not_applicable にしてはいけない

    reaction API、pagination、user identity、削除・複数 reaction、drift は外部システムとの統合動作です。rg で文字列が存在することは検証になりません。

    Runtime Verification は少なくとも次のいずれかです。

    • immediate: 非破壊の専用 test Issue/comment で reaction readback を確認
    • conditional: live API が使えない場合は mocked subprocess E2E を必須にし、実環境未確認を明記

    推奨する #1950 の再定義

    推奨タイトル

    実装: human context と agent report を分離し、claim-level technical recommendation と bounded owner decision を両 loop に導入する

    最小構成

    1. intake 時に input_origin を付与する。
    2. すべての human context を claim 単位で解析する。
    3. 最新ターンは chronology として保持するが、自動 precedence を与えない。
    4. repository facts と外部仕様から technical recommendation を生成する。
    5. 非競合の調査・本文案作成は継続する。
    6. 競合する heavy mutation だけを preview 付き decision comment に束縛する。
    7. stable user ID の一意 reaction または明示返信を取得する。
    8. drift を再検証してから mutation を適用する。
    9. issue-refinement-loop と impl-review-loop の両方を production-shaped E2E で通す。
    10. 永続 ledger・新しい authority artifact は追加しない。

    結論

    #1950 は、「最後の owner turn を優先する機能」から、「入力 provenance・意味評価・技術推奨・実行承認を分離する機能」へ in-place rewrite するべきです。

    現在の契約で実装すると、今回なくしたい ANCHOR_MULTI_TURN_FAIL_CLOSED は減りますが、代わりに「最後の人間文を過剰に権威化する誤 mutation」と「文書上だけ存在する reaction flow」が導入されます。これは改善ではなく、障害形態の置換です。


    you asked

    message time: 2026-08-02 14:06:48

    #1950 に impl-review-loop の intake、preparation、capsule、テストを追加する。


    chatgpt response

    了解です。#1950 を単一 Issue のまま拡張し、impl-review-loop の入力 provenance が実際の実行経路まで伝搬する契約に修正します。関連ファイルの現行責務を確認して、In Scope・AC・Allowed Paths・検証コマンドの差分を具体化します。

    build_intake_capsule.py は既に Issue コメントを全ページ取得し、author_id・author_type・author_association を保持していますが、用途は contract snapshot 判定だけで、呼び出し時に指定された人間コメント/agent report の provenance を capsule へ渡していません。ここを拡張点にします。

    採用します。これにより前回指摘の P0-3「impl-review-loop がスコープ外」 は解消できます。ただし、単に Allowed Paths を増やすだけでは capsule に未使用フィールドが残るため、intake → capsule artifact → preparation → Step 1 delegation まで接続する必要があります。

    現行 preparation は capsule-first を要求し、fresh な capsule がある場合はコメントを再取得しない契約です。 一方、現在の capsule は全 Issue コメントを取得して author ID 等を保持しますが、指定された人間コメントと agent report を分類・格納していません。

    #1950 へ追加する実装契約

    1. impl-review-loop の入力

    SKILL.md の Inputs に次を追加します。

    human_context_comment_urls: []  # repeatable、任意
    agent_report_comment_urls: []   # repeatable、任意

    分類は本文、投稿アカウント、author_association、構造化形式から推測せず、root/main thread がどちらの引数として渡したかだけで決定します。

    同一 URL が両方へ渡された場合は provenance conflict として停止します。

    2. build_intake_capsule.py

    CLI に次を追加します。

    --human-context-comment-url <URL>   # 複数指定可能
    --agent-report-comment-url <URL>    # 複数指定可能

    既存の全ページコメント取得結果から指定 comment ID を解決し、次を検証します。

    • repository が対象 repo と一致
    • Issue 番号が対象 Issue と一致
    • comment ID が実在
    • URL と API readback の html_url が一致
    • human/agent の両 lane に重複しない
    • comment の updated_at と body hash を固定
    • agent report は許可された構造化 marker を持つ
    • human context は構造化 marker の有無にかかわらず human lane のまま

    既存 IMPL_REVIEW_INTAKE_CAPSULE_V1 に、後方互換な optional section を追加します。新しい schema family や ledger は作りません。

    context_inputs:
      human_supplied:
        - comment_id: 5155478002
          html_url: ...
          author_id: 63350259
          author_association: OWNER
          created_at: ...
          updated_at: ...
          body_sha256: sha256:...
          origin: human_supplied_context
          treat_as_untrusted_natural_language: true
    
      agent_generated:
        - comment_id: 123
          html_url: ...
          author_id: ...
          body_sha256: sha256:...
          origin: controlled_agent_report
          structured_marker: IMPLEMENT_RESULT_V1
          structure_valid: true
    
      provenance_conflicts: []

    指定コメントの本文は既存 capsule artifact 内に保存しますが、stdout projection には出しません。現行テストも stdout に Issue 全文を含めないことを保証しているため、この境界を維持します。

    3. preparation.md

    preparation で次を明記します。

    • context_inputs.human_supplied は意味解析対象の自然言語データ
    • context_inputs.agent_generated は schema validation 後の構造化 advisory result
    • どちらも単独では mutation authorization を持たない
    • human context 全体を claim 単位で評価し、最後の turn に自動 precedence を与えない
    • agent report と human context の内容が競合した場合、repository facts・実 diff・実 test・外部仕様から main thread が技術推奨を決定する
    • heavy mutation は独立した owner decision または decision preview に束縛された reaction を必要とする

    4. Step 1 への伝搬

    step-1-implementation.md も Allowed Paths に必要です。現行の worker message は Issue URL、Allowed Paths、fix_delta だけを渡しており、capsule の context input を渡す経路がありません。

    delegation message へ次を追加します。

    Context input:
      capsule_artifact_path: <absolute-or-repo-relative-path>
      human_context_comment_ids: [...]
      agent_report_comment_ids: [...]
      technical_recommendation: <root-owned normalized recommendation>

    raw human comment を worker への命令として直接連結してはいけません。root が claim と推奨を正規化し、worker には bounded context と evidence reference を渡します。

    追加する Acceptance Criteria

    • AC6: impl-review-loop は human context URL と agent report URL を独立入力として受け取り、投稿者や本文形式から origin を推測しない。
    • AC7: capsule artifact は指定コメントの provenance、本文 snapshot、hash、updated_at を保持し、stdout は raw body を含まない。
    • AC8: repository/Issue/comment mismatch、二重 lane 指定、存在しない comment、invalid structured agent report を fail-closed にする。
    • AC9: preparation は human natural-language context と structured agent result を別処理し、いずれも mutation authorization に昇格させない。
    • AC10: Step 1 delegation は root が生成した technical recommendation と capsule reference を受け取り、raw comment を実行命令として渡さない。
    • AC11: production-shaped subprocess test が CLI 引数から capsule artifact、preparation routing、Step 1 context binding までを検証する。
    • AC12: issue-refinement-loop と impl-review-loop で同じ URL を入力した場合、origin、comment ID、hash、authority boundary が一致する。

    追加する Allowed Paths

    .claude/skills/impl-review-loop/SKILL.md
    .claude/skills/impl-review-loop/steps/preparation.md
    .claude/skills/impl-review-loop/steps/step-1-implementation.md
    .claude/skills/impl-review-loop/scripts/build_intake_capsule.py
    .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py
    

    test_build_intake_capsule.py は既に capsule の routing、コメント取得異常、stdout budget、artifact 保存を検証しているため、ここへ provenance の回帰テストを追加するのが適切です。

    Stop Conditions の修正

    現在の「固定契約のキー集合変更が必要なら停止」は、この追加と衝突します。次の例外を明記します。

    IMPL_REVIEW_INTAKE_CAPSULE_V1 への backward-compatible optional
    context_inputs section の追加は本 Issue の In Scope とし、
    schema/key change の停止条件には該当しない。
    

    新規 capsule V2、永続 provenance ledger、別 publisher、独立 authority artifact は引き続き禁止します。

    なお、これで impl-review-loop の欠落は解消しますが、#1950 本文の latest_owner_turn precedence は指定コメントと矛盾したままです。chronology metadata として保持するだけに変更し、技術判断・authorization の precedence には使用しない修正も同時に必要です。


    Powered by AI Exporter

  6. changed the title [-]実装: multi-turn anchor の後方 owner turn 優先解釈と reaction decision flow を導入する[/-] [+]実装: multi-turn anchor の owner turn を chronology metadata として扱い、reaction decision flow を issue-refinement-loop と impl-review-loop へ導入する[/+] on Aug 2, 2026
  7. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-02)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions