Skip to content

実装: retro-index-builder が malformed/unverifiable な run comment を discard せず generation_verdict に反映する #2308

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #2304 (Closes #2238) の pr-reviewer 非ブロッキング指摘(P0-7関連)の解消。malformed/structurally-invalid な retrospective-run marker comment を黙って破棄せず、generation_verdict へ反映しつつ index 生成自体は継続する"
change_kind: code

Parent Issue

none(単独改善。関連 Issue #2238 は closed 済みの独立 follow-up)

Parent Goal Ref

  • Goal: なし(親 Issue なし。単独の post-merge follow-up)
  • Desired Destination: なし

Current Validated Scope

  • scripts/agent-logs/lib/retro-index-builder.mjs の buildRetroIndex() 内、normalizeRetrospectiveRunComment() が kind: 'blocked' を返した場合の分岐(現状 continue のみで discard)を変更し、retrospective_runs_blocked フィールドへ run_comment_url + reason を記録し、それが非空なら generation_verdict を少なくとも partial に反映する(既存 blockedReasons 由来の blocked semantics は変更しない)
  • extractRetrospectiveRunPayload() の marker-line 判定(RETROSPECTIVE_RUN_MARKER_LINE 正規表現に完全一致しない場合に null/ignored へ落ちる分岐)を変更し、marker prefix(<!-- agent_retrospective_run:v1)はあるが strict marker parse に失敗するケースも blocked(retrospective_run_marker_malformed)として観測可能にする
  • docs/schemas/agent-retro-index.schema.json に retrospective_runs_blocked を optional additive field として追加する(additionalProperties: false の closed schema に新規 top-level key を追加するための正規の schema migration)

Remaining Parent Gaps

なし

Outcome

scripts/agent-logs/lib/retro-index-builder.mjs の buildRetroIndex() が、agent_retrospective_run_publication/v1 marker付きの run comment を malformed / structurally invalid(normalizeRetrospectiveRunComment() が kind: 'blocked' を返すケース、および marker prefix はあるが strict marker parse に失敗するケース)と判定した場合に、それらを黙って discard せず、生成結果オブジェクトへ retrospective_runs_blocked(run_comment_url + reason を保持する配列)として記録し、retrospective_runs_blocked が非空なら generation_verdict を少なくとも partial に反映する状態を完了とする。既存 blockedReasons(agent_run_report/v1 側の invalidity)に由来する blocked semantics は変更せず、retrospective_runs_blocked のみを理由に index 生成・upsert 自体を止めない。対応する docs/schemas/agent-retro-index.schema.json の schema migration と、既存の unit test(tests/agent-logs/retro-index-update.test.ts / tests/agent-logs/retro-index-schema.test.ts)への新規テストケース追加が pnpm test で PASS している状態を完了とする。

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 静的な unit test(Vitest)検証で完結するため

In Scope

  • scripts/agent-logs/lib/retro-index-builder.mjs の buildRetroIndex() 内、retrospective-run comment が kind: 'blocked' を返した際の分岐(現状の continue のみで discard する箇所)を変更し、blocked 理由(run_comment_url + reason)を集約した新規配列 retrospectiveRunsBlocked へ push する
  • extractRetrospectiveRunPayload() の marker-line 判定を変更し、firstLine が <!-- agent_retrospective_run:v1 prefix を持つが RETROSPECTIVE_RUN_MARKER_LINE に完全一致しない場合(例: idempotency_key 欠損)を kind: 'blocked' / reason: 'retrospective_run_marker_malformed' として返す(marker prefix を一切持たない無関係な通常 comment は従来通り kind: 'ignored' のまま変更しない)
  • retroPayload(retroPayload.schema === 'agent_retro_index/v1' のオブジェクト)へ、集約した blocked 情報を retrospective_runs_blocked フィールドとして含める
  • generation_verdict の判定条件へ retrospectiveRunsBlocked.length > 0 を partial 分岐の追加条件として組み込む(blockedReasons.length > 0 の場合は従来通り blocked を優先する。retrospective_runs_blocked のみが非空の場合は partial とし、index の生成・upsert 自体は継続する)
  • detectSchemaMigrationRequirement() の allowedKeys へ retrospective_runs_blocked を追加する
  • docs/schemas/agent-retro-index.schema.json へ retrospective_runs_blocked(retrospectiveRunBlockedEntry の配列。各要素は run_comment_url + reason、reason は orphan_reports と同様に enum 固定せず minLength/maxLength の自由文字列とする)を optional additive property として追加する
  • 既存コメント(642行目付近の // Issue #2238 Child 5 (additive-only): ... A malformed retrospective-run comment is skipped here (not added to blockedReasons/generation_verdict) so this additive feature cannot regress the existing entries[] generation_verdict semantics. を含む説明文)を、新しい可視化挙動に合わせて更新する
  • 対応する unit test(malformed / structurally-invalid な retrospective-run marker comment を含む fixture、および marker prefix のみで strict parse に失敗する fixture)の追加

Out of Scope

  • 既存の entries[] / orphan_reports / ambiguous_links に基づく既存 blockedReasons の blocked semantics(blockedReasons.length > 0 のときの優先度)の変更
  • publication_digest の再計算による cryptographic な一致検証・author 検証・canonicalization 検証(Node builder 側への完全な verifier 実装)。これらは一次永続化側(persist_retrospective_run.py / parse_verified_run_comment())の責務のままとし、本 Issue では扱わない
  • P0-7 の主要な最小修正(--index-parent-issue 追加、run_digest の publication_digest 参照、readback失敗時のindex更新スキップ)の再実装(PR 実装: agent-retrospective の run 永続化と agent_retro_index/v1 統合を実装する #2304 で対応済み)
  • CLI(production entrypoint)側の呼び出し変更
  • retrospective-run marker のスキーマ自体(agent_retrospective_run_publication/v1)の変更
  • summarizeResult() への retrospective_run_blocked_count 等の追加集計フィールド(有用だが本 Issue の必須スコープではない follow-up 候補)
  • plugins/agent-retrospective/ 配布 runtime・plugin smoke・distribution-specific harness(実装: agent-retrospective を optional plugin distribution として配布可能にする #2240 の独立スコープ)

Acceptance Criteria

  • AC1: normalizeRetrospectiveRunComment() が kind: 'blocked' を返すケース(malformed / structurally-invalid な agent_retrospective_run_publication/v1 marker付き run comment)で、buildRetroIndex() の戻り値オブジェクトに retrospective_runs_blocked(run_comment_url + reason を保持する)フィールドが存在し、該当 comment が記録される
  • AC2: retrospective_runs_blocked が非空の場合、既存 blockedReasons が空である限り generation_verdict は partial になる(blockedReasons.length > 0 の場合は従来通り blocked が優先される)。retrospective_runs_blocked のみを理由に index の生成・upsert 自体は中断されない
  • AC3: marker prefix(<!-- agent_retrospective_run:v1)はあるが strict marker parse に失敗する comment(例: idempotency_key 欠損)が kind: 'ignored' ではなく kind: 'blocked' / reason: 'retrospective_run_marker_malformed' として記録される。marker prefix を一切持たない通常 comment は従来通り ignored のままである
  • AC4: docs/schemas/agent-retro-index.schema.json に retrospective_runs_blocked が optional additive property として追加され、新フィールドを含む artifact が schema validation と detectSchemaMigrationRequirement() の両方を通る(既存 artifact に本フィールドが欠落していても schema-valid のままである)
  • AC5: valid entry + malformed run の fixture で entries[] を失わず retrospective_runs_blocked が1件記録され generation_verdict=partial になる、marker 自体が malformed なケースも記録される、marker のない通常 comment は ignored のままである、正常 run のみなら従来通り generation_verdict=complete になる、の behavior-based regression test が tests/agent-logs/retro-index-update.test.ts および tests/agent-logs/retro-index-schema.test.ts に追加され PASS している
  • AC6: pnpm test が全件 PASS している

Verification Commands

# baseline-expect: fail
# AC1
$ rg -n "retrospective_runs_blocked" scripts/agent-logs/lib/retro-index-builder.mjs
# AC2
$ rg -n "retrospectiveRunsBlocked.length" scripts/agent-logs/lib/retro-index-builder.mjs
# AC3
$ rg -n "retrospective_run_marker_malformed" scripts/agent-logs/lib/retro-index-builder.mjs
# AC4
$ rg -n "retrospective_runs_blocked" docs/schemas/agent-retro-index.schema.json
# AC5
$ pnpm test -- tests/agent-logs/retro-index-update.test.ts tests/agent-logs/retro-index-schema.test.ts
# AC6
$ pnpm test

Allowed Paths

  • scripts/agent-logs/lib/retro-index-builder.mjs
  • docs/schemas/agent-retro-index.schema.json
  • tests/agent-logs/retro-index-update.test.ts
  • tests/agent-logs/retro-index-schema.test.ts

Stop Conditions

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

Required Skills

なし

Required Design References

  • docs/schemas/agent-retro-index.schema.json
  • docs/dev/agent-retro-index.md
  • docs/adr/0007-agent-retrospective-boundaries.md

Scope Delta(任意)

N/A

Source

Notes for Reviewer

Activity

  1. added
    enhancement
    phase/implementation
    agent/implementer
    on Aug 22, 2026
  2. squne121 commented on Aug 27, 2026

    @squne121
    OwnerAuthor

    敵対的レビュー結果

    Verdict: REQUEST_CHANGES — reframe_in_place

    Issue 自体は小さな follow-up として妥当ですが、現在の契約のまま実装すると「schema に違反する」か「Issue の Outcome を満たさない」かの二択になります。作り直しは不要で、Issue 本文の修正で十分です。

    特に、個人趣味開発でワークフローを止めないことを優先するなら、malformed run comment は blocked ではなく partial に劣化させ、正常な index 生成・upsert は続行する設計が最も有用です。

    Severity | 問題 | 判定 -- | -- | -- P0 | retrospective_runs_blocked を追加すると現行 JSON Schema に違反する | 契約上実装不能 P0 | 元の指摘は generation_verdict への反映なのに AC2 がそれを禁止している | Issue の目的未達 P1 | 本当に malformed な marker は今も ignored になる | silent discard が残る P1 | 「unverifiable」と呼んでいるが Node builder は digest を検証していない | 契約の過大主張 P1 | Verification Commands / Allowed Paths が実リポジトリのテスト配置とずれている | false-green / 即 stop P1 | blocked 情報が reason だけでは修復対象を特定しづらい | 可観測性不足

    P0 — 新規フィールド追加と closed schema が正面衝突している

    #2308 は retroPayload に retrospective_runs_blocked などの新しい top-level field を追加することを要求しています。

    しかし現在の agent_retro_index/v1 は additionalProperties: false で、許可済み top-level key に retrospective_runs_blocked はありません。 現行 detectSchemaMigrationRequirement() も schema / generation_verdict / entries / orphan_reports / ambiguous_links / retrospective_runs 以外を schema migration として拒否します。 さらに、その挙動を意図的に固定する regression test まで存在します。

    JSON Schema 2020-12 と Ajv の仕様上も、additionalProperties: false の object に properties で宣言されていない field を追加すれば invalid です。特殊な workaround は不要で、schema に optional property を正規追加するのが普通です。(Ajv)

    しかも #2308 の Allowed Paths に schema がなく、「schema / key 集合変更が必要なら停止」と書かれているため、正しい実装をしようとすると Stop Condition に自分で引っかかります。

    これは過去にも解決済みの問題です。#2238 で retrospective_runs[] を追加した際は、まさに additionalProperties: false のため docs/schemas/agent-retro-index.schema.json を明示的に変更対象へ加えています。

    したがって Allowed Paths は最低でも次へ直すべきです。

    scripts/agent-logs/lib/retro-index-builder.mjs
    docs/schemas/agent-retro-index.schema.json
    tests/agent-logs/retro-index-update.test.ts
    tests/agent-logs/retro-index-schema.test.ts

    additionalProperties: false 自体を緩める必要はありません。これは有用な schema contract なので維持し、新しい optional field だけ正規登録する方が単純です。

    P0 — generation_verdict を変えないなら、元のレビュー指摘を解消していない

    PR #2304 の最終 APPROVE 時に残った warning は非常に明確で、malformed/unverifiable run comment が kind: 'blocked' になっても黙って捨てられ、generation_verdict / blockedReasons に反映されないことを follow-up 候補としていました。

    現行コードも実際に、

    if (retrospectiveRun.kind === 'blocked') {
      continue
    }

    となっており、その直前のコメントにも「blockedReasons/generation_verdict へ追加しない」と明記されています。

    ところが #2308 はタイトルと Current Validated Scope では generation_verdict への反映を掲げながら、In Scope / AC2 では 既存 generation_verdict 判定を変更しないと固定しています。

    これは解消すべきです。

    推奨セマンティクス

    趣味開発・非ブロッキング重視なら、malformed retrospective run は blocked ではなく partial が適切です。

    generation_verdict =
      blockedReasons.length > 0
        ? 'blocked'
        : (
            entries.length === 0
            || orphanReports.length > 0
            || ambiguousLinks.length > 0
            || retrospectiveRunsBlocked.length > 0
          )
          ? 'partial'
          : 'complete'

    つまり既存 agent_run_report の重大な invalidity はこれまで通り blocked、retrospective-run の一部が読めない場合は「index は使えるが完全ではない」ので partial。

    index update 自体は止めないのが重要です。これなら警告を可視化しつつ、壊れた古い comment 1件のために retrospective workflow 全体が止まりません。

    #2239 も現在、#2308 を「index 側を含む完全な可観測性」が成立するための既知 gap と明記しています。 したがって専用 field を付けるだけで generation_verdict: complete のままなのは、その downstream claim とも噛み合いません。

    P1 — 「malformed marker」は現在の #2308 案でも取りこぼす

    現在の parser は first line がこの正規表現に完全一致しない場合、

    /^<!--\s*agent_retrospective_run:v1\s+repository_id=\S+\s+idempotency_key=\S+\s*-->$/

    blocked ではなく null → ignored になります。

    したがって例えば、

    <!-- agent_retrospective_run:v1 repository_id=squne121/loop-protocol -->

    のように marker 自体が欠損している comment は、#2308 をそのまま実装しても依然 silent discard です。

    しかも既存テストの名称は「malformed retrospective-run marker」ですが、fixture の marker 自体は正規表現を満たしており、実際に壊しているのは fenced JSON の欠落です。期待 reason も retrospective_run_payload_unparsable です。

    ここは軽量に、

    const looksLikeRunMarker =
      firstLine.startsWith('<!-- agent_retrospective_run:v1')
    

    if (looksLikeRunMarker && !RETROSPECTIVE_RUN_MARKER_LINE.test(firstLine)) {
    return {
    kind: 'blocked',
    reason: 'retrospective_run_marker_malformed',
    }
    }

    程度で十分です。無関係な通常 comment は今まで通り ignored にできます。

    P1 — 「unverifiable」は現実の実装能力より広い

    現在の Node builder が確認しているのは、おおむね JSON parse、schema version、base_sha / source_set_digest の形式、publication_digest の 文字列形式だけです。publication_digest を再計算して一致検証しているわけではありません。

    つまり、

    "publication_digest": "sha256:aaaaaaaa..."

    のような64桁の偽値でも shape としては通ります。

    一方、PR #2304 の persistence/provider 側では shared parse_verified_run_comment() を導入するところまで改善されています。

    ここで #2308 に Node 側の完全な author/digest/canonicalization verifier まで持ち込むのは、今回の目的に対して重すぎます。個人開発という前提なら、「unverifiable」を Issue の名称・AC から外し、「malformed / structurally invalid」に狭めるのを推奨します。

    derived index は primary state store ではありません。ここで別言語の canonical digest verifierを再実装してハーネスを増やすより、一次永続化側の verification を正本にした方が運用コストが低いです。

    P1 — テスト指定が現リポジトリと一致していない

    #2308 は、

    scripts/agent-logs/lib/retro-index-builder.test.mjs

    をテストファイルとして書いていますが、現在の実テストは、

    tests/agent-logs/retro-index-builder.test.ts
    tests/agent-logs/retro-index-update.test.ts

    です。

    さらに retrospective_run_payload_unparsable はすでに現在のテストに存在します。 したがって AC3 の rg -c は、仮に path を直したとしても baseline から green で、#2308 の実装を何も証明しません。

    文字列検索ではなく behavior を固定してください。

    最小限の regression set は、valid entry + malformed run で entries[] を失わず retrospective_runs_blocked が1件入り generation_verdict=partial、marker 自体の malformed も記録される、marker のない通常 comment は ignored、正常 run のみなら従来通り complete、新フィールドを含む artifact が JSON Schema と detectSchemaMigrationRequirement() の双方を通る、の5ケースで十分です。

    実行コマンドもこれで足ります。

    pnpm test -- 
    tests/agent-logs/retro-index-update.test.ts
    tests/agent-logs/retro-index-schema.test.ts

    pnpm test

    live GitHub mutation、Claude runtime smoke、security harness は不要です。

    出力データも少し修正した方がよい

    reason だけを保存すると、複数 comment が壊れていた場合に人間が修復対象を探す必要があります。

    おすすめは次の最小 contract です。

    {
    "retrospective_runs_blocked": [
    {
    "run_comment_url": "https://github.com/...#issuecomment-...",
    "reason": "retrospective_run_payload_unparsable"
    }
    ]
    }

    reason は enum に固定せず、既存 orphan_reports と同様に minLength / maxLength 程度にしておく方が、reason code を増やすたび schema migration になるのを防げます。

    さらに summarizeResult() に retrospective_run_blocked_count を1個足すのは有用ですが、これは P1/P2 扱いでよく、必須ではありません。

    配布側への波及

    #2240 は agent-retrospective を self-contained な local Claude Code plugin として配布する optional follow-up であり、plugins/agent-retrospective/ に runtime closure を閉じ、${CLAUDE_PLUGIN_ROOT} / ${CLAUDE_PROJECT_DIR} を使う設計です。 これは現在の Claude Code 公式 plugin 仕様とも一致しており、skills/ / agents/ は plugin root、bundled asset は ${CLAUDE_PLUGIN_ROOT} で参照し、--plugin-dir は local testing に使うのが公式方式です。(Claude)

    したがって #2308 に plugin smoke や distribution-specific harness を逆流させる必要はありません。#2308 は agent_retro_index/v1 のデータ品質だけ hermetic Vitest で直すのが適切です。配布 runtime の correctness は #2240 が独立して検証すれば足ります。

    推奨する #2308 の最終スコープ

    Issue を reframe するなら、中心契約は次のようにするのがよいです。

    malformed / structurally-invalid な retrospective-run marker comment を
    silent discard しない。

    • retrospective_runs_blocked[] に run_comment_url + reason を記録する
    • retrospective_runs_blocked が非空なら generation_verdict は少なくとも partial
    • 既存 blockedReasons がある場合の blocked semantics は変更しない
    • partial であること自体は index upsert を禁止しない
    • agent_retro_index/v1 schema に optional field を additive 追加する
    • marker prefix はあるが strict marker parse に失敗した場合も blocked record とする
    • full cryptographic/author verification は本 Issue の責務にしない

    これなら実装差分は小さいまま、**「エラーを隠さない」「正常データは使い続けられる」「壊れた1 comment がワークフローを止めない」**の3点を同時に満たせます。

    現状の #2308 は着手前に contract update を入れるべきです。特に schema Allowed Path、generation_verdict=partial、実テストパスの3点は blocker と判定します。

    #2308 に PR が付いたら、その差分と CI を追って再レビューする運用もできます。

    # 敵対的レビュー結果

    Verdict: REQUEST_CHANGES — reframe_in_place

    Issue 自体は小さな follow-up として妥当ですが、現在の契約のまま実装すると「schema に違反する」か「Issue の Outcome を満たさない」かの二択になります。作り直しは不要で、Issue 本文の修正で十分です。

    特に、個人趣味開発でワークフローを止めないことを優先するなら、malformed run comment は blocked ではなく partial に劣化させ、正常な index 生成・upsert は続行する設計が最も有用です。

    Severity 問題 判定
    P0 retrospective_runs_blocked を追加すると現行 JSON Schema に違反する 契約上実装不能
    P0 元の指摘は generation_verdict への反映なのに AC2 がそれを禁止している Issue の目的未達
    P1 本当に malformed な marker は今も ignored になる silent discard が残る
    P1 「unverifiable」と呼んでいるが Node builder は digest を検証していない 契約の過大主張
    P1 Verification Commands / Allowed Paths が実リポジトリのテスト配置とずれている false-green / 即 stop
    P1 blocked 情報が reason だけでは修復対象を特定しづらい 可観測性不足

    P0 — 新規フィールド追加と closed schema が正面衝突している

    #2308 は retroPayload に retrospective_runs_blocked などの新しい top-level field を追加することを要求しています。

    しかし現在の agent_retro_index/v1 は additionalProperties: false で、許可済み top-level key に retrospective_runs_blocked はありません。 現行 detectSchemaMigrationRequirement() も schema / generation_verdict / entries / orphan_reports / ambiguous_links / retrospective_runs 以外を schema migration として拒否します。 さらに、その挙動を意図的に固定する regression test まで存在します。

    JSON Schema 2020-12 と Ajv の仕様上も、additionalProperties: false の object に properties で宣言されていない field を追加すれば invalid です。特殊な workaround は不要で、schema に optional property を正規追加するのが普通です。(Ajv)

    しかも #2308 の Allowed Paths に schema がなく、「schema / key 集合変更が必要なら停止」と書かれているため、正しい実装をしようとすると Stop Condition に自分で引っかかります。

    これは過去にも解決済みの問題です。#2238 で retrospective_runs[] を追加した際は、まさに additionalProperties: false のため docs/schemas/agent-retro-index.schema.json を明示的に変更対象へ加えています。

    したがって Allowed Paths は最低でも次へ直すべきです。

    scripts/agent-logs/lib/retro-index-builder.mjs
    docs/schemas/agent-retro-index.schema.json
    tests/agent-logs/retro-index-update.test.ts
    tests/agent-logs/retro-index-schema.test.ts
    

    additionalProperties: false 自体を緩める必要はありません。これは有用な schema contract なので維持し、新しい optional field だけ正規登録する方が単純です。

    P0 — generation_verdict を変えないなら、元のレビュー指摘を解消していない

    PR #2304 の最終 APPROVE 時に残った warning は非常に明確で、malformed/unverifiable run comment が kind: 'blocked' になっても黙って捨てられ、generation_verdict / blockedReasons に反映されないことを follow-up 候補としていました。

    現行コードも実際に、

    if (retrospectiveRun.kind === 'blocked') {
      continue
    }

    となっており、その直前のコメントにも「blockedReasons/generation_verdict へ追加しない」と明記されています。

    ところが #2308 はタイトルと Current Validated Scope では generation_verdict への反映を掲げながら、In Scope / AC2 では 既存 generation_verdict 判定を変更しないと固定しています。

    これは解消すべきです。

    推奨セマンティクス

    趣味開発・非ブロッキング重視なら、malformed retrospective run は blocked ではなく partial が適切です。

    generation_verdict =
      blockedReasons.length > 0
        ? 'blocked'
        : (
            entries.length === 0
            || orphanReports.length > 0
            || ambiguousLinks.length > 0
            || retrospectiveRunsBlocked.length > 0
          )
          ? 'partial'
          : 'complete'

    つまり既存 agent_run_report の重大な invalidity はこれまで通り blocked、retrospective-run の一部が読めない場合は「index は使えるが完全ではない」ので partial。

    index update 自体は止めないのが重要です。これなら警告を可視化しつつ、壊れた古い comment 1件のために retrospective workflow 全体が止まりません。

    #2239 も現在、#2308 を「index 側を含む完全な可観測性」が成立するための既知 gap と明記しています。 したがって専用 field を付けるだけで generation_verdict: complete のままなのは、その downstream claim とも噛み合いません。

    P1 — 「malformed marker」は現在の #2308 案でも取りこぼす

    現在の parser は first line がこの正規表現に完全一致しない場合、

    /^<!--\s*agent_retrospective_run:v1\s+repository_id=\S+\s+idempotency_key=\S+\s*-->$/

    blocked ではなく null → ignored になります。

    したがって例えば、

    <!-- agent_retrospective_run:v1 repository_id=squne121/loop-protocol -->
    

    のように marker 自体が欠損している comment は、#2308 をそのまま実装しても依然 silent discard です。

    しかも既存テストの名称は「malformed retrospective-run marker」ですが、fixture の marker 自体は正規表現を満たしており、実際に壊しているのは fenced JSON の欠落です。期待 reason も retrospective_run_payload_unparsable です。

    ここは軽量に、

    const looksLikeRunMarker =
      firstLine.startsWith('<!-- agent_retrospective_run:v1')
    
    if (looksLikeRunMarker && !RETROSPECTIVE_RUN_MARKER_LINE.test(firstLine)) {
      return {
        kind: 'blocked',
        reason: 'retrospective_run_marker_malformed',
      }
    }

    程度で十分です。無関係な通常 comment は今まで通り ignored にできます。

    P1 — 「unverifiable」は現実の実装能力より広い

    現在の Node builder が確認しているのは、おおむね JSON parse、schema version、base_sha / source_set_digest の形式、publication_digest の 文字列形式だけです。publication_digest を再計算して一致検証しているわけではありません。

    つまり、

    "publication_digest": "sha256:aaaaaaaa..."

    のような64桁の偽値でも shape としては通ります。

    一方、PR #2304 の persistence/provider 側では shared parse_verified_run_comment() を導入するところまで改善されています。

    ここで #2308 に Node 側の完全な author/digest/canonicalization verifier まで持ち込むのは、今回の目的に対して重すぎます。個人開発という前提なら、「unverifiable」を Issue の名称・AC から外し、「malformed / structurally invalid」に狭めるのを推奨します。

    derived index は primary state store ではありません。ここで別言語の canonical digest verifierを再実装してハーネスを増やすより、一次永続化側の verification を正本にした方が運用コストが低いです。

    P1 — テスト指定が現リポジトリと一致していない

    #2308 は、

    scripts/agent-logs/lib/retro-index-builder.test.mjs
    

    をテストファイルとして書いていますが、現在の実テストは、

    tests/agent-logs/retro-index-builder.test.ts
    tests/agent-logs/retro-index-update.test.ts
    

    です。

    さらに retrospective_run_payload_unparsable はすでに現在のテストに存在します。 したがって AC3 の rg -c は、仮に path を直したとしても baseline から green で、#2308 の実装を何も証明しません。

    文字列検索ではなく behavior を固定してください。

    最小限の regression set は、valid entry + malformed run で entries[] を失わず retrospective_runs_blocked が1件入り generation_verdict=partial、marker 自体の malformed も記録される、marker のない通常 comment は ignored、正常 run のみなら従来通り complete、新フィールドを含む artifact が JSON Schema と detectSchemaMigrationRequirement() の双方を通る、の5ケースで十分です。

    実行コマンドもこれで足ります。

    pnpm test -- \
      tests/agent-logs/retro-index-update.test.ts \
      tests/agent-logs/retro-index-schema.test.ts
    
    pnpm test

    live GitHub mutation、Claude runtime smoke、security harness は不要です。

    出力データも少し修正した方がよい

    reason だけを保存すると、複数 comment が壊れていた場合に人間が修復対象を探す必要があります。

    おすすめは次の最小 contract です。

    {
      "retrospective_runs_blocked": [
        {
          "run_comment_url": "https://github.com/...#issuecomment-...",
          "reason": "retrospective_run_payload_unparsable"
        }
      ]
    }

    reason は enum に固定せず、既存 orphan_reports と同様に minLength / maxLength 程度にしておく方が、reason code を増やすたび schema migration になるのを防げます。

    さらに summarizeResult() に retrospective_run_blocked_count を1個足すのは有用ですが、これは P1/P2 扱いでよく、必須ではありません。

    配布側への波及

    #2240 は agent-retrospective を self-contained な local Claude Code plugin として配布する optional follow-up であり、plugins/agent-retrospective/ に runtime closure を閉じ、${CLAUDE_PLUGIN_ROOT} / ${CLAUDE_PROJECT_DIR} を使う設計です。 これは現在の Claude Code 公式 plugin 仕様とも一致しており、skills/ / agents/ は plugin root、bundled asset は ${CLAUDE_PLUGIN_ROOT} で参照し、--plugin-dir は local testing に使うのが公式方式です。(Claude)

    したがって #2308 に plugin smoke や distribution-specific harness を逆流させる必要はありません。#2308 は agent_retro_index/v1 のデータ品質だけ hermetic Vitest で直すのが適切です。配布 runtime の correctness は #2240 が独立して検証すれば足ります。

    推奨する #2308 の最終スコープ

    Issue を reframe するなら、中心契約は次のようにするのがよいです。

    malformed / structurally-invalid な retrospective-run marker comment を
    silent discard しない。
    
    - retrospective_runs_blocked[] に run_comment_url + reason を記録する
    - retrospective_runs_blocked が非空なら generation_verdict は少なくとも partial
    - 既存 blockedReasons がある場合の blocked semantics は変更しない
    - partial であること自体は index upsert を禁止しない
    - agent_retro_index/v1 schema に optional field を additive 追加する
    - marker prefix はあるが strict marker parse に失敗した場合も blocked record とする
    - full cryptographic/author verification は本 Issue の責務にしない
    

    これなら実装差分は小さいまま、**「エラーを隠さない」「正常データは使い続けられる」「壊れた1 comment がワークフローを止めない」**の3点を同時に満たせます。

    現状の #2308 は着手前に contract update を入れるべきです。特に schema Allowed Path、generation_verdict=partial、実テストパスの3点は blocker と判定します。

    #2308 に PR が付いたら、その差分と CI を追って再レビューする運用もできます。

  3. squne121 commented on Aug 27, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(human_judgment_required)

    anchor comment(https://github.com/squne121/loop-protocol/issues/2308#issuecomment-5445827853)を human context lane として preflight を実行した結果、以下の状態で Step 0f preflight の時点で停止しました。

    • STATUS: needs_fix
    • NEXT_ACTION: apply_deterministic_repair
    • disposition: auto_apply_safe
    • reason_codes: deterministic_body_author_fix_available
    • repair_kinds: insert_baseline_expect_fail

    検出内容

    Issue 本文の Verification Commands 中、以下のコマンドに baseline-expect 注釈が欠落しています。

    $ rg -c "retrospective_run_payload_unparsable" scripts/agent-logs/lib/retro-index-builder.test.mjs
    

    deterministic repair はこの行の直前に # baseline-expect: fail を挿入する修正案(disposition: auto_apply_safe)を生成しましたが、issue-refinement-loop の現行 orchestrator は NEXT_ACTION: apply_deterministic_repair に対する auto-apply consumer を持たないため(SKILL.md 記載の既知の未接続範囲)、本文への実際の mutation は行わず STATUS: blocked 相当の human 判断待ちとして処理しています。

    証跡

    • diagnostics: .claude/artifacts/issue-refinement-loop/2308/repair_diagnostics.json
    • repaired body candidate: .claude/artifacts/issue-refinement-loop/2308/repaired_issue_body.md
    • original_body_sha256: sha256:8d54b464c3e08678897cee816d945bbca0fc36082326e35c19964f4088979c94
    • repaired_body_sha256: sha256:81f8276643307b2b7a2926b7127f083576a9534cd7bb25e89597f77d797607d9

    次のアクション(人間判断待ち)

    以下のいずれかの対応を人間に判断いただく必要があります。

    1. repaired_issue_body.md の内容を Issue 本文へ手動反映する(該当行に # baseline-expect: fail を挿入するだけの軽微な修正)。
    2. 通常の issue-editor rewrite lane(Step 4)経由で同等の修正を適用するよう明示的に指示する。

    termination_cause: human_judgment_required

  4. squne121 commented on Aug 27, 2026

    @squne121
    OwnerAuthor

    推奨は、「手動で # baseline-expect: fail を追加して終わり」ではなく、既存の repair_action.apply consumer を使って deterministic repair を適用し、その後 #2308 の本来の contract reframe まで refinement loop を継続するです。

    今回の停止理由は実装能力の欠如ではありません。Issue #2039 で repair_action.apply consumer が定義され、PR #2202 はマージ済みです。現行の command_registry.py にも production command として登録されています。

    一方、現在の SKILL.md にはまだ「auto-apply consumer を持たない」という古い記述が残っており、今回 Claude はそれを信じて false block しています。これ自体が Issue #2346 と PR #2351 で既知の regression として扱われており、PR #2351 はまさに repair_action.apply → readback → fresh preflight を正しい手順として記述する修正です。ただし PR #2351 は現時点で open / Draft なので、main の stale documentation に引っ張られたと考えるのが妥当です。

    さらに、アンカーコメントは baseline annotation だけでなく、schema Allowed Paths、generation_verdict=partial、実テストパスなどを blocker として REQUEST_CHANGES — reframe_in_place としています。したがって deterministic repair 後に refinement loop を終了してはいけません。

    以下をそのまま Claude Code に渡すのがよいです。

    サブエージェントを1つ使用して、以下の作業を委譲してください。
    メインスレッドはサブエージェントの作業完了まで待機し、完了後に結果を要約してください。

    対象:

    #2308 (comment)

    目的:

    Issue #2308 に対する issue-refinement-loop を、人間承認不要で可能なところまで継続する。

    直前の実行では Step 0f preflight が

    • STATUS: needs_fix
    • NEXT_ACTION: apply_deterministic_repair
    • repair_action.disposition: auto_apply_safe

    を返したにもかかわらず、

    issue-refinement-loop は apply_deterministic_repair の auto-apply consumer を持たない

    として human_judgment_required に終了した。

    この判断をそのまま採用してはいけない。

    重要な既知事実

    現行 repository には既に repair_action.apply consumer が実装されている。

    一方、.claude/skills/issue-refinement-loop/SKILL.md の
    NEXT_ACTION: apply_deterministic_repair 節には consumer 不在とする stale documentation が残っている。

    これは既知 Issue #2346 で追跡されている。

    PR #2351 は repair_action.apply 実装後の正しい orchestration を記述する docs-only fix であり、現時点で Draft/open の可能性がある。

    したがって今回の #2308 では、stale な SKILL.md の prose を authority として「consumer 不在」と再判定しないこと。
    実装・command registry・runtime policy を authority として扱うこと。

    実行方針

    まず repository の current main を確認し、

    1. repair_action.apply が command registry に存在すること
    2. run_repair_action_apply() が存在すること
    3. PR 実装: repair_action.apply の controlled Issue transaction consumer を追加する #2202 が current main に取り込まれていること

    を短く確認する。

    既に確認できる場合、新規実装や #2346 の修正作業へ脱線しない。

    今回の目的は #2308 の refinement loop 継続であり、#2346 / PR #2351 の実装・merge は別作業とする。

    Phase 1: deterministic repair を正規 consumer で適用

    直前の #2308 preflight artifact を確認する。

    想定:

    .claude/artifacts/issue-refinement-loop/2308/

    配下に、

    • preflight result
    • repair diagnostics
    • repaired/candidate issue body

    が存在する。

    repair_action.disposition == auto_apply_safe であることを機械的に確認する。

    そのうえで、手動 gh issue edit や独自 script ではなく、canonical repair_action.apply consumer を使用する。

    repair_action.apply は active-issue binding を必要とするため、runtime policy が要求する

    を満たすこと。

    必要なら既存の canonical worktree bootstrap mechanism を使う。

    LOOP_ISSUE_NUMBER=2308 等の binding が必要な場合も、repository の command registry / runtime policy / PR #2351 の記述を確認して既存方式に従うこと。
    手書きの代替 mutation path は作らない。

    canonical executor から repair_action.apply を1回実行する。

    mutation_outcome の扱い

    mutation_outcome=applied:

    • authoritative readback 済みであることを確認
    • fresh preflight へ進む

    mutation_outcome=no_change:

    • current body が candidate と等価であることを確認
    • fresh preflight へ進む

    mutation_outcome=unknown:

    • blind retry しない
    • bounded report を残して停止する
    • この場合のみ human judgment が妥当

    mutation_outcome=not_attempted:

    • 同じ repair_action.apply を盲目的に再試行しない
    • failure_code / readiness blocker を確認
    • repository の既存 routing contract に従い、通常の Step 2 review → Step 4 rewrite lane へ進められるなら進む

    Phase 2: fresh preflight

    deterministic repair が applied または no_change なら、必ず fresh preflight を実行する。

    対象 anchor は引き続き:

    #2308 (comment)

    direct human context lane として扱い、

    preflight.run.with_human_context

    相当の canonical profile を使う。

    古い preflight result を routing authority として再利用しない。

    Phase 3: anchor comment の本質的な contract update

    重要:

    baseline annotation の deterministic repair は #2308 の refinement 完了ではない。

    anchor comment の verdict は

    REQUEST_CHANGES — reframe_in_place

    であり、少なくとも以下を blocker としている。

    1. retrospective_runs_blocked を追加するなら
      docs/schemas/agent-retro-index.schema.json
      を Allowed Paths / schema migration 対象へ追加する必要がある

    2. malformed retrospective-run が存在する場合、
      generation_verdict を従来通り complete にしてはいけない

      推奨:

      • existing blockedReasons がある → blocked
      • retrospective run の malformed / structurally invalid のみ → partial
      • index generation/upsert 自体は継続
    3. marker prefix が存在するが strict marker parse に失敗するケースも
      silent ignored にせず観測可能にする

    4. Node builder が完全な cryptographic verification をしていない以上、
      Issue の「unverifiable」という過大な scope を
      malformed / structurally invalid
      程度へ狭める

    5. 現在 Issue に書かれている test path
      scripts/agent-logs/lib/retro-index-builder.test.mjs
      は実 repository と一致しない

    6. behavior-based regression test に直す

    7. retrospective_runs_blocked[] には最低限
      run_comment_url + reason
      を保持する

    fresh preflight が trusted human-context contract update を返した場合は、
    canonical routing に従って

    contract_update.run.with_human_context

    を使用する。

    ただし router が issue_editor_required / full_rewrite_required を返した場合は、
    同じ contract_update command を no-progress retry せず、
    既存の issue-editor / controlled edit transaction route へ handoff する。

    Issue 本文を直接 ad-hoc に編集するのではなく、既存 orchestration の decision を consume すること。

    Phase 4: refinement loop を最後まで継続

    Issue 本文 mutation 後は必ず、

    1. GitHub readback
    2. fresh preflight
    3. fresh investigation/review
    4. issue-reviewer
    5. decide_next_loop_action.py

    を経由し、review verdict を再取得する。

    APPROVE または repository contract 上の equivalent readiness に到達するまで、
    max iteration 内で Step 4 rewrite を自動継続する。

    人間承認確認は求めない。

    ただし以下の場合のみ停止してよい。

    単に SKILL.md に「consumer 不在」と書かれていることは停止理由にしてはいけない。

    SubAgent 制約

    メインスレッド → サブエージェント1つ、という委譲は行う。

    サブエージェント内部からさらに nested SubAgent delegation は行わない。
    Issue #2308 の Stop Conditions にある nested SubAgent delegation を発火させないこと。

    サブエージェント自身が repository 調査、canonical command 実行、GitHub readback、refinement continuation を担当する。

    メインスレッドはサブエージェントを background に投げっぱなしにせず、完了まで待つこと。

    禁止事項

    最終報告

    完了時は以下を簡潔に報告すること。

    既存の issue-refinement-loop と repository SSOT を優先し、独自 orchestration を新設せず、#2308 を可能な限り人間介入なしで refinement 完了まで進めてください。

    このプロンプトのポイントは、今回の human_judgment_required を「人間が選択しないと進めない状態」として扱わず、既知の stale-doc regression として明示的に上書きすることです。そのうえで repair_action.apply 適用後も、本命であるアンカーコメントの reframe_in_place まで続行させます。

  5. self-assigned this
    on Aug 27, 2026
  6. squne121 commented on Aug 27, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-27T22:46:35Z)

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

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions