Skip to content

実装: grounded_research の citation truncation撤廃とstructured output対応 (#2034 follow-up) #2038

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2034"
goal_ref: >
  #2034 の調査で確認された、grounded_research route における citation/source
  provenance 喪失の2つの構造的欠陥(citation `[:1]` 切り詰め、AGY structured
  output 未使用)を、provenance-bound structured event adapter で解消する
change_kind: implementation

Parent Issue

#2034(research-only、AC1-AC6充足・AC7は本Issue起票により充足)

Parent Goal Ref

Current Validated Scope

  • _build_agy_inner_argv() / _validate_agy_invocation_argv()(run_gemini_headless.py:2698-2758)への --output-format {json,stream-json} allowlist 追加
  • _extract_structured_citations() / _build_agy_grounded_research_metadata()(run_gemini_headless.py:3205-3517)の [:1] truncation 撤廃
  • .claude/agents/web-researcher.md の materialization 手順更新
  • 上記に対する positive/negative test 追加

Remaining Parent Gaps

  • WEB_RESEARCH_RESULT_V1.claims[].evidence[] への source-claim 関連付けの deterministic 実装。claim-source は 1:1 ではなく one-to-many/many-to-many(例: source A→claim1, source B→claim1,2, source C→claim2)であるため、単純な cardinality 保持では正しい対応付けにならない。stable source_id を用いた relation schema(source record を複製せず claim evidence から参照する設計)の実装を別 follow-up Issue(未起票)に切り出す

Outcome

.claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py の grounded_research route において、以下2点が解消され、既存の fail-closed citation policy(generic URL 無条件拒否、Issue #1266/#1708確立)を弱めることなく複数 source の evidence が delegation_result/v1.grounded_research_evidence.sources[] まで保持される状態になる:

  1. _build_agy_grounded_research_metadata() の citation_evidence = structured_citations[:1] truncation が撤廃され、web_tool_call_count / search_query_count が実測値を反映する
  2. AGY invocation が --output-format json(または stream-json)を利用可能になり、既存の _validate_agy_invocation_argv() 位置allowlist(Issue 実装: AGY permission-bypass flag 拒否のfail-closed実装と再実行可能テストを追加する #1807)を維持したまま、structured tool-result由来のsource provenanceを保持できる

claim-source の 1:1 対応付けは one-to-many/many-to-many の実態と矛盾するため、本 Issue のスコープは provider boundary(AGY structured event adapter、delegation_result/v1.grounded_research_evidence.sources[] まで)に縮小する。WEB_RESEARCH_RESULT_V1.claims[].evidence[] への deterministic claim-source materialization は別 follow-up Issue(未起票、Remaining Parent Gaps に記載済み)に切り出す。

In Scope

  • _build_agy_inner_argv() / _validate_agy_invocation_argv()(run_gemini_headless.py:2698-2758)を拡張し、--output-format {json,stream-json} を allowlist に追加する(既存の flag-injection 対策の構造は維持する)
  • structured output 対応判定は runner が独自に agy --help を判定する設計にせず、preflight_agy.py の既存 capability matrix(同一 binary 束縛)を runner が consume する設計とする
  • stream-json 使用時は init/step_update/result の protocol invariants を strict parser で検証し、malformed/truncated/duplicate terminal stream を fail-closed で拒否する
  • _extract_structured_citations() / _build_agy_grounded_research_metadata()(run_gemini_headless.py:3205-3517)の [:1] truncation を撤廃し、複数 source を cardinality を保持したまま citation_evidence に含める。web_tool_call_count / search_query_count を実測値(stream-jsonのtool_infoイベント数、またはtext modeでの既存hook event数)から算出する
  • structured output(json/stream-json)が利用できない環境・バージョンでは明示的に capability_unavailable failure_class を返し、旧来の stdout best-effort parsing へ silent fallback しない
  • .claude/agents/web-researcher.md の materialization 手順を、delegation_result/v1.grounded_research_evidence.sources[](provider boundary)を正しく参照する記述に更新する。claims[].evidence[] への claim-source 1:1 対応付けの決定的手順は本 Issue の Outcome に含めない(別 follow-up Issue に分離。Remaining Parent Gaps 参照)
  • 上記変更に対する positive/negative test を .claude/skills/gemini-cli-headless-delegation/tests/ に追加する

Out of Scope

  • citation_countを0→1にするだけの局所修正(#2034で明示的に不採用と結論済み)
  • generic URLの無条件regex許可(_extract_structured_citations()のfail-closed policyを弱める変更は禁止)
  • AGY/Gemini CLI本体(provider側実装)の修正
  • _validate_agy_invocation_argv()の-p/--model以外の任意flag許可(--output-formatの値域を明示的に列挙したallowlist拡張のみ許可し、任意文字列を通す変更は禁止。Issue #1807のflag-injection対策を弱めない)
  • claim-source の 1:1 対応付け・WEB_RESEARCH_RESULT_V1.claims[].evidence[] への deterministic materialization(one-to-many/many-to-many の実態と矛盾するため別 follow-up Issue に分離。Remaining Parent Gaps 参照)

Acceptance Criteria

  • AC1: _build_agy_inner_argv()が--output-format jsonまたはstream-jsonをargvに含められるようになっており、_validate_agy_invocation_argv()がこの2値のみを許可し他の値を引き続きrejectすることがテストで示されている
  • AC2: _build_agy_grounded_research_metadata()のcitation_evidenceが[:1]に切り詰められず、複数sourceが存在する場合はcardinalityを保持したまま返されることがテストで示されている
  • AC3: web_tool_call_count/search_query_countが実際の呼び出し回数を反映し、固定値1にならないことがテストで示されている
  • AC4: structured output非対応(preflight_agy.pyのcapability matrixがunsupported/unavailable/evidence_invalidのいずれかを返す、または実行結果がparse不能)の場合にcapability_unavailable相当のfailure_classを返し、旧来のstdout scrapingへsilent fallbackしないことがテストで示されている
  • AC5: _extract_structured_citations()は Vertex host に限定せず data.sources/data.citations/data.grounding.sources の non-empty URL を無条件収集し、Vertex grounding-api-redirect 限定 regex は validated hook event はあるが structured citation がない場合の stdout fallback 専用として維持されるという既存の fail-closed trust policy が、変更後も維持されていることが既存テストの再実行で示されている

Verification Commands

pytest の未収集(no tests ran matching given pattern 等)や usage error は exit 4/5 であり、これは
Verification Infrastructure Failure(テストパス誤り・selector誤り・テスト未追加によるインフラ状態)
として扱い、AC failure とは区別する。AC failure の baseline は「収集成功後の assertion failure、
すなわち exit 1」のみを指す。AC1-AC4 は対象テスト関数がまだ存在しないため、実装者はまずテストを
追加し、追加直後に exit 1(収集成功・assertion failure)を確認してから実装を進めること。

# AC1
# --output-format allowlist(新規テストファイル test_agy_structured_output.py を追加する)
# baseline-expect: fail
# (テスト追加後は exit 1、テスト未追加時点の exit 4 は Verification Infrastructure Failure)
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_output_format_stream_json_allowlisted -q
# AC2
# citation cardinality 保持(新規テストファイル test_agy_structured_output.py に追加する)
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_citation_evidence_cardinality_not_truncated_to_one -q
# AC3
# web_tool_call_count / search_query_count が実測値を反映する
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_tool_call_count_reflects_actual_invocations -q
# AC4
# capability SSOT(preflight_agy.py)を consume し、非対応時は capability_unavailable を返す(新規テストファイル test_agy_structured_output.py に追加する)
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_structured_output_capability_unavailable_returns_fail_closed -q
# AC5
# 既存の fail-closed citation trust boundary が変更後も維持されている(既存テストの再実行)
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provenance_grounding_wiring.py::test_generic_url_without_vertex_grounding_pattern_not_counted_as_citation .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provenance_grounding_wiring.py::test_validated_hook_event_with_real_grounding_citation_url_is_grounded -q

Close gate(PR 提出前に実装者が手動実行し、結果を PR に記載する。baseline_vc_preflight による自動実行対象外とする。理由: 現行 tests/ 配下の実行に約2分を要し、かつ本 Issue のスコープと無関係な既存 failure(test_agy_provider.py::test_ac7_agy_github_research_dispatches_to_e2e_route)が baseline に既に存在するため、Issue-authoring 時点の静的 readiness check では自動実行しない):

uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/ -q

実装完了後、上記コマンドを実行し、本 Issue の変更に起因する新規 failure がないことを確認する。既存の無関係な pre-existing failure が残っている場合は、その旨と該当テスト名を PR 本文に明記し、本 Issue のスコープ外として扱う(別途 follow-up で対処する)。

Allowed Paths

  • .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py
  • .claude/skills/gemini-cli-headless-delegation/scripts/preflight_agy.py
  • .claude/skills/gemini-cli-headless-delegation/scripts/setup_check.py
  • .claude/skills/gemini-cli-headless-delegation/tests/
  • .claude/skills/gemini-cli-headless-delegation/tests/test_agy_capability_gate.py
  • .claude/skills/gemini-cli-headless-delegation/tests/test_setup_check.py
  • .claude/agents/web-researcher.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • Python subprocess / argv builder パターン
  • NDJSON / stream-json protocol parsing
  • pytest

Required Design References

  • .claude/agents/web-researcher.md(WEB_RESEARCH_RESULT_V1 スキーマ定義・citation_evidence の materialization 手順)
  • docs/dev/agy-cli-contract-20260701.md(AGY CLI argv contract。--output-format allowlist 拡張の前提)

Runtime Verification Applicability

decision: immediate
reason: >
  外部 CLI (AGY) の structured-output protocol / NDJSON event schema /
  version-specific runtime semantics を変更対象とし、#2034 で未実測の H5
  を本 Issue で解決するため。
applicable_acs:
  - AC1
  - AC2
  - AC3
  - AC4
skip_conditions:
  - "AGY CLI (`agy`) が実行環境に存在しない、または `preflight_agy.py` の capability matrix が supported 以外を返す場合は SKIP exit 77 とし、PASS へフォールバックしない"
  - "AGY 認証(quota/auth/permission)が未設定で live invocation ができない場合は SKIP exit 77 とする"
execution_environment:
  cli_tools:
    - agy
    - python3
    - uv
  auth_required: true
  network_required: true
fallback_policy:
  fallback_success_is_pass: false
  notes: "structured output 非対応・parse failure 時の stdout best-effort fallback 経由の成功は PASS に変換しない(AC4 の capability_unavailable 判定を維持する)"
artifact_requirements:
  - "preflight_agy.py capability matrix 出力(same-binary evidence: realpath/SHA-256/version)"
  - "bounded live invocation の sanitized argv / event manifest(raw transcript・credential・絶対 HOME パスを含まない)"
  - "pytest output"

Notes for Reviewer

  • 調査: web-researcher の citation_count 0 fail-closed root cause を特定する #2034(本Issue親)の調査で確定した2つの構造的欠陥(citation_evidence[:1]切り詰め: run_gemini_headless.py:3489、argv allowlistが--output-formatを構造的に拒否: run_gemini_headless.py:2698-2758)の解消を目的とする。
  • _validate_agy_invocation_argv()はIssue #1807のflag-injection対策で意図的に厳格化されている。本Issueでの拡張は「値域を列挙したallowlist追加」に限定し、任意flag許可には広げないこと。
  • H5(structured outputがstdout best-effort parsingを置換できるか)は#2034ではinconclusiveだったため、本Issueの実装/spikeで実測してAC4のfail-closed設計に反映すること。
  • P0-4(stream-json event model)補足: upstream の正式な event vocabulary は init/step_update/result のみであり、tool_info は独立した event type ではなく各 tool call に付随する object である。--json-schema は stream-json 全体ではなく terminal result event にのみ適用される。strict parser は「exactly one init」「zero or more step_update」「exactly one terminal result(stream の最後の accepted event)」「非空stdout行は必ず1 JSON object」「malformed/truncated/duplicate terminal streamの拒否」「line byte数/event数/nesting depthの上限」「unknown event/step_typeに対するclosed policy」「invalid streamのprefixからのpartial success禁止」を満たすこと。1.1.9以前はinitが利用不能toolを広告し得たため、init.toolsだけをcapability authorityにしない。
  • P1 群(実装時の追加防御、要約): (P1-1) stream-jsonのtool情報とtext modeのhook eventの二重計上を避け、web_tool_call_attempt_count/web_tool_call_success_count等のcount semanticsを分離する。hookはsource payloadのauthorityにしない。(P1-2) tool_info.output等のraw NDJSON全文・parametersを永続化せず、redactionをpersistence前のcommon finalizerで実施し、line byte/event count/URL長等を上限管理する。(P1-3) capability probe(1 query/1 URL/short timeout)とproduction grounded research(bounded N tool calls/M source records/明示的truncation status)を分離し、silent truncationを禁止する。(P1-4) --output-format対応は汎用flag parserへ退化させず、route-specificなtyped argv builderとし、unknown value/duplicate flag/permission bypass option等のnegative testを追加する。(P1-5) structured route既定化はprovider == agy and tool_profile == grounded_research and capability == supportedに限定し、他profileの既存argv/stdout semanticsを回帰テストで維持する。これらはAC/VCへの新規追加は行わず、実装時の設計判断として本セクションに要約するに留める。

Activity

  1. added
    phase/research
    phase/implementation
    agent/implementer
    follow-up
    and removed
    phase/research
    on Aug 8, 2026
  2. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — P0 6件。現行の Issue 契約では実装開始不可です。

    問題設定そのものは妥当です。現行コードには、複数 citation を structured_citations[:1] で切り捨て、tool-call 数を実質的な真偽値へ潰している実装があり、_build_agy_inner_argv()/_validate_agy_invocation_argv() も --output-format を受け付けない固定構造です。親 Issue #2034 でも、この欠陥は確認された一方、structured output が既存経路を置換できるかは inconclusive のまま #2038 に委譲されています。

    ただし #2038 は、以下の独立した責務を一つの曖昧な契約へまとめています。

    1. AGY capability detection
    2. stream-json プロトコル解析
    3. tool-call と source の provenance 保持
    4. source と claim の関連付け
    5. WEB_RESEARCH_RESULT_V1 の materialization

    この状態では、citation の件数だけ増え、実際の claim-level evidence が誤対応したままでも AC を通せます。


    P0 — 実装前に Issue 契約を修正すべき事項

    P0-1. Verification Commands が成立しておらず、baseline failure を誤認する

    Issue はテスト追加先と全 pytest コマンドを次のディレクトリへ向けています。

    .claude/skills/gemini-cli-headless-delegation/scripts/tests/
    

    しかし現行リポジトリのテストルートは次です。

    .claude/skills/gemini-cli-headless-delegation/tests/
    

    既存の test_agy_invocation_argv_allowlist.py、test_agy_provenance_grounding_wiring.py、test_agy_capability_gate.py なども後者にあります。Issue の Allowed Paths も誤った scripts/tests/ だけを許可しているため、正しい場所へテストを追加すると scope violation、契約どおりに追加すると既存テスト体系から分離されます。

    さらに AC5 の selector:

    -k "generic_url_rejected or vertex_redirect_only"

    は、現行の実テスト名である以下のいずれにも一致しません。

    test_generic_url_without_vertex_grounding_pattern_not_counted_as_citation
    test_validated_hook_event_with_real_grounding_citation_url_is_grounded
    

    したがって AC5 はポリシー検証ではなく、未収集終了になる可能性があります。

    pytest では、テストが収集されて assertion が失敗した場合は exit 1、コマンド使用法の誤りは exit 4、テスト未収集は exit 5 です。現在の baseline-expect: fail はこの区別を要求していないため、パス誤りや selector 誤りを「期待した赤テスト」と誤認できます。([pytestドキュメント]1)

    必須修正

    • テストルートと Allowed Paths を .../tests/ へ修正する。
    • -k の曖昧な部分一致ではなく、ファイル名と node ID を固定する。
    • baseline は「収集成功後の exit 1」でなければならないと明記する。
    • exit 4/5 は AC failure ではなく Verification Infrastructure Failure とする。
    • AC6 の rg -n "cardinality" は削除する。単語が存在することは materialization の正しさを証明しない。
    • 最後に skill 全テストを実行する close gate を追加する。

    P0-2. Runtime Verification: not_applicable は親 Issue と外部 CLI の性質に矛盾する

    #2038 は runtime verification を「skill/script と agent prompt の変更のみ」として not_applicable にしています。しかし変更対象は、外部配布物である AGY CLI の argv、出力形式、NDJSON event schema、tool payload を実際に解釈する runtime adapter です。親 #2034 は、installed AGY 1.1.11 が --output-format を持つことまでしか確認できず、structured output の source provenance が十分かどうかを #2038 の live prototype に明示的に委譲しています。

    また、元の grounded-research 実装契約 #1266 は runtime verification を immediate とし、mock/fixture のみでは close 不可、bounded な live AGY WebSearch evidence を必須としていました。

    AGY 1.1.8 で json/stream-json が導入された後、1.1.9 では stream-json の init event が実際には利用不能な tool を広告する不具合が修正されています。つまり、help text や自作 fixture だけでは runtime semantics を証明できません。([Google Antigravity]2)

    必須修正

    Runtime Verification Applicability:
      decision: immediate
      reason: >
        外部 CLI の structured-output protocol、tool payload、version-specific
        runtime semantics を変更対象とし、#2034 で未実測の H5 を解決するため。

    最低限、同一 binary に束縛した以下の sanitized evidence が必要です。

    • binary realpath/SHA-256/version
    • capability matrix
    • bounded live invocation の argv shape
    • init/step_update/result event 件数
    • canonical tool names
    • raw source URL を保存しない、または許可された sanitized source record
    • parse status
    • terminal result の有無
    • redaction status
    • raw transcript/credential/absolute HOME の非保存
    • quota、auth、permission failure の分類

    P0-3. Capability detection の既存 SSOT を破壊する

    PR #1982/Issue #1941 は、preflight_agy.py を AGY capability detection の唯一の実装 SSOT とし、同一 binary identity への束縛、isolated runtime probe、cost-confirmation gate、sanitization、次の5値分類を導入しています。

    supported
    unsupported
    unavailable
    inconclusive
    evidence_invalid
    

    setup_check.py もこの capability matrix を consume する設計です。

    対して #2038 は、runner 側で agy --help に --output-format があるかを独自判定する設計を要求しています。しかも Allowed Paths に preflight_agy.py、setup_check.py、capability tests が含まれていません。これでは同じ AGY binary に対して二つの capability authority が生まれます。

    さらに AC4 は、以下を同じ capability_unavailable へ潰しています。

    • help に flag がない
    • flag はあるが runtime で拒否された
    • subprocess が auth/quota で失敗した
    • NDJSON が malformed
    • stream が途中で切れた
    • terminal result がない
    • parser 実装にバグがある

    これは capability と protocol evidence validity の混同です。

    必須修正

    preflight_agy.py の capability matrix に、少なくとも以下の predicate を追加します。

    print_output_format_stream_json
    stream_json_typed_events
    stream_json_tool_info
    

    runner は独自に agy --help を呼ばず、同一 binary identity に束縛された capability result を consumeします。

    分類も分けるべきです。

    unsupported:
      binary が flag/機能を実装していない
    
    unavailable:
      auth、quota、permission、cost gate 等で probe を実行できない
    
    evidence_invalid:
      binary drift、malformed stream、schema contradiction
    
    inconclusive:
      parser acceptance は確認できたが semantic evidence が不足
    

    そのため、Allowed Paths には最低でも次を追加する必要があります。

    .claude/skills/gemini-cli-headless-delegation/scripts/preflight_agy.py
    .claude/skills/gemini-cli-headless-delegation/scripts/setup_check.py
    .claude/skills/gemini-cli-headless-delegation/tests/test_agy_capability_gate.py
    .claude/skills/gemini-cli-headless-delegation/tests/test_setup_check.py
    

    P0-4. stream-json のイベントモデルを誤認している

    Issue は web_tool_call_count を「stream-json の tool_info イベント数」から算出するとしています。これは upstream protocol と一致しません。

    Google の正式な changelog が保証している event vocabulary は次です。

    init
    step_update
    result
    

    tool_info は独立した event type ではなく、各 tool call に付随する object です。また --json-schema は stream-json 全体ではなく、terminal result event にだけ適用されます。([Google Antigravity]2)

    したがって、現在の契約からは次が定まりません。

    • tool_info がどの event/field に入るか
    • 一つの step_update に複数 tool call が存在し得るか
    • tool failure も件数へ含めるか
    • result より後の event を許可するか
    • duplicate init/result をどう扱うか
    • malformed 1行を読み飛ばすか、stream 全体を失敗にするか
    • unknown event/step type を forward-compatible として保持するか、fail-close するか
    • stdout と stderr が混在した場合の扱い
    • process exit 0 だが terminal result がない場合の扱い

    また AC1 の「json または stream-json」も弱すぎます。公式資料は stream-json について per-tool の tool_info と correlation 可能な payload を明示していますが、通常の json が同等の per-call provenance を保持することまでは、この資料から確認できません。([Google Antigravity]2)

    必須修正

    grounded-research route では、原則として stream-json を必須にします。json を同等の選択肢に残すなら、同じ source/tool correlation が得られる live evidence と fixture を別途要求すべきです。

    strict parser の最低条件は次です。

    exactly one init
    zero or more step_update
    exactly one terminal result
    result must be the last accepted event
    every non-empty stdout line must be one JSON object
    malformed/truncated/duplicate terminal stream is rejected
    bounded line bytes / event count / nesting depth
    closed policy for unknown event and step_type
    no partial success from a prefix of an invalid stream
    

    1.1.9 以前の init は利用不能 tool を広告し得たため、init.tools だけを capability authority にしてはいけません。([Google Antigravity]2)


    P0-5. 「cardinality 保持」と「claim-source 対応」を同一視している

    Issue は、複数の citation_evidence を WEB_RESEARCH_RESULT_V1.claims[].evidence[] へ「1:1で対応付ける」としています。これは一般には成立しません。

    例として、3 source が2 claimを支える場合、関係は次のような many-to-many です。

    source A -> claim 1
    source B -> claim 1, claim 2
    source C -> claim 2
    

    source 3件と evidence 3件という cardinality を維持しても、どの source がどの claim を裏付けるかは決まりません。全 source を全 claim へ複製すれば件数は増えますが、実際には裏付けていない source を evidence として誤表示する false grounding になります。

    現行 WEB_RESEARCH_RESULT_V1 の evidence 要素は概ね次だけです。

    kind: web
    ref: <url>
    summary: <string>

    source_id、tool_call_id、step_idx、args_sha256、query_id など、wrapper の source record と claim evidence を機械的に結ぶキーがありません。web-researcher は SubAgent-owned SSOT ですが、現在の materialization は自然言語手順であり、親 #2034 も deterministic converter 不在を partially_supported と判定しています。

    web-researcher.md に「cardinality」と書き、rg で単語を確認しても、この問題は解消しません。

    必須修正は二択です。

    選択肢A: #2038 を provider boundary に縮小する

    Outcome を次までに限定します。

    AGY stream-json
      -> delegation_result/v1.grounded_research_evidence.sources[]
    

    WEB_RESEARCH_RESULT への deterministic claim association は別 Issue に分けます。

    選択肢B: relation schema を実装する

    少なくとも source record に次を持たせます。

    source_id: <stable per-run id>
    step_idx: <int>
    tool_name: search_web | read_url_content
    tool_call_fingerprint: <sha256>
    url: <normalized URL>
    title: <bounded string|null>
    source_kind: search_result | fetched_page | grounding_redirect

    claim evidence は source を複製するのではなく、参照します。

    claims:
      - claim_id: C1
        evidence:
          - source_id: S1
            summary: ...
          - source_id: S2
            summary: ...

    これは WEB_RESEARCH_RESULT_V1 の意味論変更になるため、暗黙に v1 を再解釈せず、schema version の更新または明示的な additive compatibility contract が必要です。


    P0-6. AC5 が既存の citation trust boundary を誤記している

    Issue は _extract_structured_citations() が「generic URL を拒否し、Vertex grounding-api-redirect のみ許可する」と記載しています。実装は異なります。

    現行 _extract_structured_citations() は structured data の次の field を読みます。

    data.sources
    data.citations
    data.grounding.sources
    

    そして各 entry の url が non-empty string なら収集します。関数単体では Vertex host に限定していません。

    Vertex redirect 専用 regex は、validated hook event はあるが structured citation がない場合の stdout fallback にだけ適用されます。そこでは free-form stdout の通常 URL を evidence へ昇格させないため、Vertex redirect shape に限定しています。

    この区別を誤ったまま AC5 を実装すると、二つの危険があります。

    • structured tool result に含まれる正当な origin URL まで Vertex 以外として捨てる
    • 逆に、model prose に現れた通常 URL を structured source と誤認する

    正式な structured stream は canonical tool name、parameters、output を含む tool_info を提供します。したがって trust の根拠は URL hostname ではなく、「どの canonical tool call の output から得た source か」であるべきです。([Google Antigravity]2)

    修正すべき trust policy

    受理:
      validated stream event
      + canonical web tool
      + tool-call correlation
      + structured tool output内のsource record
      + URL sanitization成功
    
    拒否:
      model response textだけに現れたURL
      prompt echo内のURL
      arbitrary stdout scanで見つかったURL
      tool provenanceと対応しないsource
    

    URL validation も明文化すべきです。

    • scheme は http/https のみ
    • userinfo 禁止
    • control character 禁止
    • 最大長
    • canonical normalization
    • fragment を重複判定に含めるか明示
    • redirect URL と resolved origin URL の扱い
    • 同一 normalized URL の deduplication

    P1 — 実装時に必要な追加防御

    P1-1. hook と stream の二重計上を防ぐ

    Issue は件数を「stream-json の tool 情報、または text mode の hook event」から得るとしていますが、同じ tool call が両方に現れた場合の優先順位がありません。

    正式な Hooks 仕様では、PreToolUse は toolCall.name/toolCall.args/stepIdx を持ちます。一方、PostToolUse は stepIdx と optional error を持つだけで、tool output 自体は返しません。従って hook は「実行が試みられたこと」の補助証跡にはなりますが、source payload の authority にはできません。([Google Antigravity]3)

    推奨 authority は次です。

    stream-json:
      tool result / source provenance の authority
    
    PreToolUse hook:
      attempted tool execution の corroboration
    
    PostToolUse hook:
      step completion/error の corroboration
    

    件数も一つの曖昧な count ではなく、最低限分離します。

    web_tool_call_attempt_count
    web_tool_call_success_count
    search_web_success_count
    read_url_content_success_count
    source_record_count
    unique_source_url_count
    

    hook と stream の correlation が取れない場合は、最大値や合計値で誤魔化さず、明示的な provenance mismatch にすべきです。


    P1-2. tool_info.output の保存・サイズ・秘密情報境界がない

    upstream の tool_info は parameters と output を含みます。そこには検索 query、ページ本文、認証エラー、内部 URL、長大な response が入る可能性があります。([Google Antigravity]2)

    現行 failure surface は parsed_evidence を結果に含められる構造です。このまま stream 全体を parsed evidence として保存すると、既存の「raw transcript を保存しない」という安全条件を迂回します。

    最低限、以下を契約化すべきです。

    • raw NDJSON 全文を output artifact に保存しない
    • tool_info.parameters をそのまま永続化しない
    • tool output は source抽出後に破棄する
    • line byte、event count、source count、URL/title length、nesting depth を制限
    • invalid UTF-8、巨大整数、深いJSON、duplicate keys の扱い
    • redaction を parse後ではなく persistence前の共通 finalizer で実施
    • failure message に argv値、prompt、URL本文を出さない
    • sanitized fixture と live artifact の schema を分離
    • source payload の必要部分だけを allowlist projection する

    P1-3. 1件制限撤廃と quota-bound probe を分離する

    現行コードの [:1] には、#1266 の「1 query/1 URL の bounded live probe」という由来コメントがあります。

    ただし、これは production research の source cardinality と capability probe のコスト上限を混同した設計です。単に slice を削除すると、今度は source 数や output サイズが無制限になります。

    次の二つを分けるべきです。

    capability/live verification probe:
      1 query
      1 URL
      no retry storm
      short timeout
    
    production grounded research:
      bounded N tool calls
      bounded M source records
      deterministic deduplication
      truncation時は dropped_source_count を明示
    

    silent truncation は禁止し、上限到達時は例えば次を返します。

    source_limit:
      max_records: 20
      observed_records: 27
      retained_records: 20
      dropped_records: 7
      status: truncated

    ただし critical claim の source が落ちた状態を grounded として成功扱いしてはいけません。


    P1-4. argv allowlist を汎用 flag parser に退化させてはいけない

    現行 builder は実行 argv と audit表示 argv の共通 SSOTであり、validator は固定位置を検証することで、未知の permission-bypass flag や secret-bearing flag を構造的に拒否しています。

    --output-format 対応は、任意の trailing option を反復解析する実装にしてはいけません。推奨形は route-specific な typed builder です。

    例:

    [agy_bin, "-p", prompt, "--output-format", "stream-json"]
    [agy_bin, "-p", prompt, "--output-format", "stream-json", "--model", model]
    

    または model を先にするなら、その一つの順序だけを canonical とします。

    negative test が必要です。

    • --output-format text を grounded route で拒否
    • unknown value
    • value欠落
    • duplicate --output-format
    • duplicate --model
    • extra trailing option
    • permission bypass option
    • secret-bearing option
    • prompt本文が --output-format で始まるケースは固定 slot の prompt として安全に受理
    • rejection message が rejected value を echo しない
    • grounded-research 以外の route に flag が付かない

    P1-5. structured route を全 profile に波及させない

    _build_agy_inner_argv() は複数 profile の共通経路です。既定で stream-json を追加すると、no_tools、proposal_only、local_asset_research などの既存 consumer が text stdout を期待している場合に破壊的変更になります。

    契約は次に限定すべきです。

    provider == agy
    and tool_profile == grounded_research
    and capability == supported
    

    それ以外の route は既存 argv/stdout semantics を維持し、回帰テストで不変を証明します。


    推奨スコープ分割

    現行 #2038 は一つの PR としては責務が広すぎます。次の二つへ分割する方が安全です。

    Issue A: AGY structured-event adapter

    対象:

    • preflight capability SSOT
    • fixed argv allowlist
    • strict stream-json parser
    • canonical tool correlation
    • provenance-bound source records
    • bounded counts
    • failure taxonomy
    • sanitization
    • live runtime evidence

    到達点:

    AGY
      -> delegation_result/v1.grounded_research_evidence.sources[]
    

    Issue B: deterministic claim-source materializer

    対象:

    • WEB_RESEARCH_RESULT schema versioning
    • stable source_id
    • claim-source edge
    • orphan source/unknown source reference 検出
    • duplicate evidence 検出
    • claim coverage gate
    • web-researcher prompt依存の縮小
    • end-to-end fixture

    到達点:

    delegation_result/v1.sources[]
      -> WEB_RESEARCH_RESULT.claims[].evidence[].source_id
    

    単一 Issue を維持するなら、少なくとも両方を実コードと end-to-end test で実装し、web-researcher.md の文言変更だけで後半を満たしたことにしてはいけません。


    修正版 Outcome 案

    goal_ref: >
      provider=agy + tool_profile=grounded_research に限り、
      preflight_agy.py の同一binary capability matrixが stream-json を
      supported と判定した場合だけ、固定argv shapeで
      --output-format stream-json を使用する。
    
    outcome:
      - >
        strict NDJSON parserが init / step_update / terminal result の
        protocol invariantsを検証し、malformed・truncated・duplicate terminal
        streamをfail-closedで拒否する。
      - >
        canonical search_web / read_url_content のtool_infoに束縛された
        source recordだけを抽出し、free-form model textやarbitrary stdout URLを
        citationへ昇格させない。
      - >
        citation/source recordは定義済み上限までcardinalityを保持し、
        silent [:1] truncationを行わない。上限超過は明示的に分類する。
      - >
        attempted/successful tool calls、search calls、source records、
        unique URLsのcount semanticsを分離する。
      - >
        unsupported capability、unavailable probe、invalid stream、
        incomplete stream、no citation、auth/quota/query failureを
        別のreason codeとして保持する。
      - >
        raw tool parameters/output/transcriptを永続化せず、
        allowlist projection済みsource recordのみを結果へ含める。
      - >
        claim-level materializationを本Issueに含める場合はstable source_idと
        claim-source relationを実装し、prompt文言だけに依存しない。
      - >
        structured output非対応時やparse failure時にtext stdout scrapingへ
        silent fallbackしない。

    修正版 Acceptance Criteria

    1. Capability SSOT
      preflight_agy.py が same-binary evidence で stream-json/tool_info capability を5値分類し、runner がその結果を consumeする。

    2. Typed argv
      grounded-research route だけが固定位置の --output-format stream-json を使用し、unknown/duplicate/extra flag を fail-close する。

    3. Protocol parser
      init → step_update* → result を strict に検証し、malformed、truncated、duplicate terminal、result後eventを拒否する。

    4. Source provenance
      source record が canonical tool call と step_idx/fingerprint で対応し、model proseだけのURLは受理されない。

    5. Cardinality and bounds
      複数 source を silent truncationせず保持し、deduplication・上限・上限超過statusが定義される。

    6. Count semantics
      attempted、successful、search、read、source、unique URL の件数がfixtureの実測値と一致する。

    7. Failure taxonomy
      unsupported/unavailable/evidence_invalid/incomplete/no_citations/auth/quota/query_error を混同しない。

    8. Security
      prompt、credential、raw transcript、raw tool output、repo absolute path が result/error/artifact に残らない。

    9. Claim relation
      scopeに残す場合、複数claim・複数source fixtureで正しい many-to-many associationを検証し、unknown/orphan source_id を拒否する。

    10. Runtime evidence
      current installed AGY binaryで bounded live run を実行し、sanitized event manifest と derived source recordsを保存する。mock-onlyではclose不可。

    11. Regression
      grounded-research 以外の profile の argv/stdout semantics が変化していない。

    12. Full suite
      skill配下の全テストが成功する。


    修正版 Verification Commands 案

    TEST_ROOT=.claude/skills/gemini-cli-headless-delegation/tests
    
    # Collection itself must succeed.
    uv run --locked python -m pytest \
      "$TEST_ROOT/test_agy_structured_output.py" \
      --collect-only -q

    baseline は、上記収集が成功した後の assertion failure、すなわち exit 1 のみを期待値とします。exit 4/5 は baseline failure として受理しません。([pytestドキュメント]1)

    # Typed argv and injection resistance
    uv run --locked python -m pytest \
      "$TEST_ROOT/test_agy_invocation_argv_allowlist.py" \
      -q
    # Capability SSOT and same-binary binding
    uv run --locked python -m pytest \
      "$TEST_ROOT/test_agy_capability_gate.py" \
      "$TEST_ROOT/test_setup_check.py" \
      -q
    # New strict stream parser tests
    uv run --locked python -m pytest \
      "$TEST_ROOT/test_agy_structured_output.py" \
      -q
    # Existing free-text URL / validated grounding behavior
    uv run --locked python -m pytest \
      "$TEST_ROOT/test_agy_provenance_grounding_wiring.py::test_generic_url_without_vertex_grounding_pattern_not_counted_as_citation" \
      "$TEST_ROOT/test_agy_provenance_grounding_wiring.py::test_validated_hook_event_with_real_grounding_citation_url_is_grounded" \
      -q
    # Deterministic claim-source association
    uv run --locked python -m pytest \
      "$TEST_ROOT/test_web_research_source_materialization.py" \
      -q
    # Full regression gate
    uv run --locked python -m pytest \
      "$TEST_ROOT/" \
      -q

    総合判断

    #2038 が対象としている実不具合は存在します。しかし現在の Issue は、

    • 誤ったテストパス
    • 未収集を許す baseline
    • capability SSOT の二重化
    • tool_info を event とみなす protocol 誤認
    • capability failure と parse failure の混同
    • source cardinality と claim association の混同
    • structured citation と stdout fallback の trust boundary 誤記
    • external CLI変更なのに runtime verification 不要という判定

    を含んでいます。

    このまま実装すると、citation 件数だけ増えた false-green、source と claim の誤対応、または正当な通常URLの全廃棄のいずれかへ進む可能性が高いです。Issue 本文を先に改稿し、provider adapter と claim materializer を分離した後に実装へ進むのが妥当です。

  3. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-08-08T13:39:14Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/2038
      body_sha256: "sha256:42dc47ad21d040ac5f68832b13ed0b087b66b0f800bbe0f652c5d16702bc9216"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:42dc47ad21d040ac5f68832b13ed0b087b66b0f800bbe0f652c5d16702bc9216","source_provenance":{"source_type":"body_file","body_file":"/tmp/contract_review_once_body_0kj7mlfp.md"}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":5,"raw_command":"uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_output_format_stream_json_allowlisted -q","command_hash":"sha256:9ef75efd5168d15e59272539cb423694d5b83ad515356549f6120c238588ad6c","execution_key_hash":"sha256:7f1cd56a73b09ea93007b9869f8c926b898507c64ba304042afd3802f588c526","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.01s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_output_format_stream_json_allowlisted"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":433,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC2","line":4,"raw_command":"uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_citation_evidence_cardinality_not_truncated_to_one -q","command_hash":"sha256:dee22b0161bdcc094afa80986c4ef52f2a5c9fc5f1728887bd08ea0627ac19c0","execution_key_hash":"sha256:410358bbbd7377cd3329313984cde8643f2a2d0cfaab87965fe30e0b491dd956","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.00s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_citation_evidence_cardinality_not_truncated_to_one"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":370,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":3,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC3","line":4,"raw_command":"uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_tool_call_count_reflects_actual_invocations -q","command_hash":"sha256:9c42c36f9282c1e596d2030d488f1a564c8d9a5aea09e94340142d59d6578d12","execution_key_hash":"sha256:f754a08fd6e7701c645ed6e84d13c76cf9a4d1ee5a1046bc5311cff88bfbd73c","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.00s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_tool_call_count_reflects_actual_invocations"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":425,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":3,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC4","line":4,"raw_command":"uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_structured_output_capability_unavailable_returns_fail_closed -q","command_hash":"sha256:dbf0e848f6a4bc4dfde1594bf1dc5730a9edde7f3f80550c7863f69fb2ead666","execution_key_hash":"sha256:5aa00c9767aa092cf7bfe1cab1c4167607f9fd898eedf0d5fd8f8a529692d0a2","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["no tests ran in 0.00s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_structured_output.py::test_structured_output_capability_unavailable_returns_fail_closed"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":409,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":3,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC5","line":4,"raw_command":"uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provenance_grounding_wiring.py::test_generic_url_without_vertex_grounding_pattern_not_counted_as_citation .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provenance_grounding_wiring.py::test_validated_hook_event_with_real_grounding_citation_url_is_grounded -q","command_hash":"sha256:99239d61a18f39a2c237f424f5fadc1111c18690459d532ff3607f471a841915","execution_key_hash":"sha256:ede5c5d44ee5b6bf0b255230f5eb95a07a8fc211dd50f34be733d7f192878410","runner":"exec","exit_code":0,"classification":"expected_pass","category":"baseline_expect_pass","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["..                                                                       [100%]","2 passed in 0.05s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":485,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"pass","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":3,"raw":"# baseline-expect: pass"},"strict":null,"repair":null}]
        declared_path_overlap: {"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"166d5d5089a0a827dd476882f59b5ebfe8c0a15b","draft_policy":"include_drafts","prs":[{"number":1528,"title":"feat(cleanup): 同一実行内の branch-only fallback を追加","base_ref_name":"main","head_ref_name":"worktree-issue-1403-post-merge-cleanup-dedicated-branch-forc","head_ref_oid":"b29007580ae225eb9676c7f32c878ee2bb9ccaa9","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1528","changed_files_count_graphql":4},{"number":2026,"title":"fix: trusted OWNER directive を contract update へ正規化","base_ref_name":"main","head_ref_name":"worktree-issue-1951-trusted-directive","head_ref_oid":"3ae35d6c8b6780bcd549ae2c03bf7c34d8b78c7c","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2026","changed_files_count_graphql":14}],"fetched_count":2,"totalCount":2,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:acbba47fe4d81c0661461f8741315290fb04a0c9dd3677eb7b516e28b98ee4cc","errors":[]},"inventory_digest_extended":"sha256:f66e98fc9cc412b21143b8a0702e9ff561b98cdf279ac26df5c747b56a57869a","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: {"issue_number":2038,"contract_source_kind":"issue_comment","contract_source_id":"5226349078","contract_body_sha256":"sha256:42dc47ad21d040ac5f68832b13ed0b087b66b0f800bbe0f652c5d16702bc9216","allowed_paths_normalized_sha256":"330c78c0584ab8b3aecfd1d64f4acfc290c17f365b9cbaa6f2724609dd632acf","base_ref":"main","base_sha_at_snapshot":"166d5d5089a0a827dd476882f59b5ebfe8c0a15b"}
  4. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: approved

    反映した修正(iteration ごと)

    • iteration 0(構造修正): テンプレート必須セクション6件(Parent Goal Ref / Current Validated Scope / Remaining Parent Gaps / Required Skills / Stop Conditions / Required Design References)を追加。preflight の missing_required_section blocker を解消。
    • iteration 1: anchor comment の P0-1/P0-2/P0-3/P0-5/P0-6 を反映
      • Verification Commands のテストルートパスを .claude/skills/gemini-cli-headless-delegation/scripts/tests/ → .claude/skills/gemini-cli-headless-delegation/tests/ に修正(codebase-investigator の fact-check で実在パスを確認)
      • AC5 の VC selector を実在テスト関数名(test_generic_url_without_vertex_grounding_pattern_not_counted_as_citation 等)へ修正
      • Runtime Verification Applicability を not_applicable → immediate へ変更
      • Allowed Paths に preflight_agy.py / setup_check.py / 関連テストを追加し capability SSOT 統合方針を明記
      • AC6(cardinality記述)を削除し、claim-source materializer を別 Issue(provider boundary への scope 縮小)へ分離
      • AC5 の trust policy 記述を実装(_extract_structured_citations())に整合させて修正
      • review 結果: VERDICT: needs-fix(C11: decision: immediate に対し AC への runtime-verification: true タグ欠落)
    • iteration 2: AC1〜AC4 に <!-- runtime-verification: true --> タグを追加。review 結果: VERDICT: approve(blockers: 0)

    Final Gate

    Follow-up Materialization

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues:
        - request_dedupe_key: "follow-up:squne121/loop-protocol:issuecomment-5226138774:claim-source-materializer"
          status: created
          issue:
            number: 2042
            url: "https://github.com/squne121/loop-protocol/issues/2042"
          reason: null
      note_only_observations:
        - dedupe_key: "follow-up:squne121/loop-protocol:issuecomment-5226138774:stream-json-event-model-p0-4"
          source_url: "https://github.com/squne121/loop-protocol/issues/2038#issuecomment-5226138774"
          source_note_id: "P0-4"
          summary: "stream-json の init/step_update/result event model 誤認、および P1-1〜P1-5(hook/stream二重計上・tool_info保存境界・quota-bound probe分離・argv allowlist設計・profile波及防止)は本Issueの実装時詳細設計判断に委ねるためNotes for Reviewerへ要約記載のみとし、AC/VC追加は見送った"
    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: "https://github.com/squne121/loop-protocol/issues/2038#issuecomment-5226349078"
        generated_at: "2026-08-08T13:37:59.671359Z"
        body_sha256: "sha256:42dc47ad21d040ac5f68832b13ed0b087b66b0f800bbe0f652c5d16702bc9216"
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-08-08T13:39:36Z"
      checked_body_sha256: "sha256:42dc47ad21d040ac5f68832b13ed0b087b66b0f800bbe0f652c5d16702bc9216"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
  5. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-08T14:20:00Z)

    • PR: 実装: grounded_research route の citation truncation と AGY structured output 未使用を解消する #2043
    • Worktree: .claude/worktrees/issue-2038-agy-structured-output
    • Branch: worktree-issue-2038-agy-structured-output
    • Verification: 4/4 PASS(typecheck / lint / test / build)+ skill 側 close gate 1522 passed(1件は Issue 本文記載の pre-existing 無関係 failure)
    • Runtime Verification(decision: immediate): 実 agy バイナリに対する same-binary evidence 付き bounded probe を実行し、正当な SKIP(capability status: inconclusive)を確認。PR 本文の ## Runtime Verification Evidence(動作検証の証跡) 参照
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
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/implementerfollow-upphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions