Repository navigation
Description
Parent Issue
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2192"
goal_ref: "#2192 の Child 5: agent-retrospective run の永続化と agent_retro_index/v1 統合を実装する"
change_kind: codeParent Goal Ref
- Goal: 継続的 retrospective Skill(
.claude/skills/agent-retrospective/)を、run boundary(bounded observation)・claim-class 単位の source authority・mutation boundary(artifact-publication / remediation の区別)・public/private artifact 境界(allowlist モデル)が確定した状態で実現する(導入: Claude-GPT運用ログの継続的レトロスペクティブと改善提案を行う agent-retrospective Skill を確立する #2192 参照) - Desired Destination: 導入: Claude-GPT運用ログの継続的レトロスペクティブと改善提案を行う agent-retrospective Skill を確立する #2192 の Child Issues 7 件すべてがマージされ、
.claude/skills/agent-retrospective/が MVP として動作する状態(本 Issue はそのうち Child 5)
Current Validated Scope
.claude/skills/agent-retrospective/scripts/persist_retrospective_run.pyの新規実装、既存 production CLI(run_retrospective.py)からの実接続、agent_retro_index/v1への derived-index 統合- 本 Issue の永続化契約は、Child 1(実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234)の ADR(
docs/adr/0007-agent-retrospective-boundaries.md)が定義する mutation boundary(artifact-publication mutationとremediation mutationの区別)およびoptimistic concurrency(stale-write の事後検出)とidempotency(duplicate suppression)の区別に整合させる(2026-08-18 OWNER レビュー、実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234 issuecomment-5327616033 を反映) - 2026-08-22 OWNER 敵対的レビュー(実装: agent-retrospective の run 永続化と agent_retro_index/v1 統合を実装する #2238 issuecomment-5379964604、
Verdict: REQUEST_CHANGES — reframe_in_place)を反映し、以下を本 Issue の正本契約として再構成する:- production
main()(run_retrospective.py)が実際に persistence-backed provider を生成・使用する経路を持つことを本 Issue の実装対象に含める(Allowed Paths にrun_retrospective.py/SKILL.md/references/wire-contract.mdを追加) agent_retro_index/v1のadditionalProperties: false閉じたスキーマは PR/merge_sha を持たない retrospective run を表現できないため、トップレベル optional なretrospective_runs[]セクション(既存entries[]とは独立、additive のみ)を追加する(Allowed Paths にdocs/schemas/agent-retro-index.schema.json/scripts/agent-logs/lib/retro-index-builder.mjsを追加)- human authorization の契約は producer 側の単独 flag(例:
--authorized-by-human)に依存せず、(a) 通常経路は TTY 上の明示確認、(b) non-interactive 経路は別コマンドが発行する短命なhuman_authorization_receipt/v1ファイルの検証、のいずれかを必須とする receipt-based 設計に統一する(既存PUBLISH_REQUEST_V1がauthorized/authorized_by_human/authorization_token/mutation_capabilityfield を禁止している契約と矛盾しないようにする) - AC6(旧: 不一致なら書き込みを絶対拒否する optimistic concurrency)は、GitHub Issue comment API が原子的な compare-and-swap を保証しないという API 制約に合わせ、「POST 前後の head 再確認 + sibling 検出による事後検出(best-effort)」へ修正する。本文中の「immutable」は「tool-managed append-only public record(tool は既存 run comment を PATCH/DELETE しない。GitHub 自体の不可変性は主張しない)」に置換する
- production
Remaining Parent Gaps
- 本 Issue が実装する
(repo, base_sha, source_set_digest, scope)ベースの重複書き込み防止は、Child 1 の ADR 用語ではidempotency(duplicate suppression)であり、stale-write protectionではない。真の stale-write protection(optimistic concurrency)はexpected_previous_digestを用いた別メカニズムとして本 Issue で追加実装する(AC5)。ただし GitHub Issue comment API の制約上、この concurrency guard は絶対保証ではなく best-effort な事後検出(post-write rescan + sibling detection)である(AC6) -
agent_retrospective_run/v1を Issue comment として自動投稿する処理は、Child 1 の ADR が定義する mutation boundary 上artifact-publication mutationに分類される。この mutation class の human authorization point は Child 1 の ADR(実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234)が「事前の人間承認必須」と定義済みだが、その承認をどう実行時に確認するか(TTY 確認 / receipt file)の具体的メカニズムは本 Issue のスコープで定義する(AC4) - Child 6(security/eval/live smoke、検証: agent-retrospective のsecurity boundary・evaluation・dual-runtime smokeを統合検証する #2239)は本 Issue で実装する永続化パスを前提に実装される。検証: agent-retrospective のsecurity boundary・evaluation・dual-runtime smokeを統合検証する #2239 は live smoke/security test を担当し、最終 POST 直前の public-safety validator の実装責任は本 Issue(実装: agent-retrospective の run 永続化と agent_retro_index/v1 統合を実装する #2238)が持つ(AC12)
- Child 7(plugin distribution)は Child 4 完了後に着手する。現段階では
.claude/standalone 構成を維持し、plugin 化は本 Issue のスコープ外とする -
agent_improvement_candidate/v1の additive 拡張(stable finding identity・delta evaluation contract)は 実装: agent-retrospective candidate schema に stable finding identity と delta evaluation contract を追加する #2288 で確定済み(CLOSED)。本 Issue の candidate state 永続化ロジックはこの確定済み契約(finding_contract.identity/claim_class/evaluations[])に従う
Outcome
.claude/skills/agent-retrospective/scripts/persist_retrospective_run.py が新規追加され、既存 production CLI(run_retrospective.py)から実接続された状態で、以下が成立する。
run_retrospective.py main()がIssueCommentPreviousStateProvider(または同等の persistence-backed provider)を実際に生成・使用し、fixture-only の previous state ではなく実際の永続化済み previous run を読む。provider が返すread_versionはcompute_delta()を経由してPUBLISH_REQUEST_V1のexpected_previous_digestへ伝播するpersist_retrospective_run.pyがPUBLISH_REQUEST_V1を消費し、delta_resultsを含む全 mutation payload からpublication_digestを計算する。既存public_projection_digestの意味は変更せず、publisher 専用の digest として追加する- Child 2 の
agent_retrospective_run/v1を tool-managed append-only な public-safe Issue comment として投稿する機能を持つ。この投稿は Child 1 の ADR(実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234)が定義する mutation boundary 上artifact-publication mutationに分類される。GitHub 自体の不可変性は主張せず、「tool は既存 run comment を PATCH/DELETE しない」という運用契約のみを保証する - 投稿後の post-write readback を、POST response の comment ID を用いた GET → marker/fenced JSON 抽出 → schema 検証 → canonical JSON(
sha256-jcs-v1)digest 再計算 →publication_digestとの比較、という方式で行う(Markdown 生 bytes 比較は行わない) - 同一
(repo, base_sha, source_set_digest, scope)での重複書き込みを防ぐ idempotency guard(duplicate suppression)を持つ。idempotency key は caller 供給値をそのまま信用せず、publisher 側でsha256-jcs-v1({repository_id, base_sha, source_set_digest, scope})として再計算し、caller 値とは照合のみ行う。判定は「same key + same publication digest → no-op」「same key + different publication digest → conflict」「new key → publish」の三値 expected_previous_digestに基づく optimistic concurrency guard(stale-write の事後検出)を持つ。GitHub Issue comment API は原子的な compare-and-swap を提供しないため、この guard は絶対保証ではなく best-effort とする: (a) POST 前に head digest を再確認、(b)parent_record_digestを含む新規 comment を append、(c) POST 後に全 record を再走査、(d) 同一 parent を持つ sibling comment が複数存在すればconflict_detectedを返す。conflict 検出時、provider は次 run に対してstaleを返し、resolved等を断定しない- mutation 実行前に human authorization を確認する human authorization gate を持つ。単独の
--authorized-by-humanflag は承認として扱わない。次のいずれかを必須とする: (a) 通常経路: TTY 上に投稿先・candidate 件数・delta 要約・publication_digestを表示し明示確認を取る、(b) non-interactive 経路: 別コマンド(authorize相当)が発行したhuman_authorization_receipt/v1(request_id/publication_digest/repository_id/target_issue/operation/approved_at/expires_atを含む短命ファイル)を検証する。既存PUBLISH_REQUEST_V1の禁止 field(authorized/authorized_by_human/authorization_token/mutation_capability)はそのまま維持し、authorization は別チャネル(receipt file または TTY)で確認する - ambiguous POST failure(timeout 等)からの回収を持つ。盲目的な再試行はせず、再試行前に
request_id/ idempotency key を全ページ検索し、同一 digest が見つかれば成功として回収、異なる digest なら conflict、見つからなければ bounded retry を行う - candidate state の永続化・再読込みが、
candidate_status単体ではなく candidate record 全体・finding_contract.identity・finding_contract.claim_class・finding_contract.evaluations[]・delta_results・legacy candidate のlegacy_unavailable判定を含めて round-trip する。candidate lifecycle transition(candidate_statusをaccepted等へ変更する機能)自体は本 Issue のスコープに含めない(snapshot の保存・再読込みに限定) - 最終 POST 直前に public-safety validator を実行する。canonical candidate/run schema validation、raw transcript/credential-bearing field の拒否、明白な absolute local path・token pattern の拒否、public comment size の事前確認を行う(自動 redaction は行わず、理由付きで publish を停止する)
既存 agent_retro_index/v1(docs/schemas/agent-retro-index.schema.json / scripts/agent-logs/update-retro-index.mjs / scripts/agent-logs/lib/retro-index-builder.mjs)は、既存 entries[] の意味を破壊せず、トップレベルに optional な retrospective_runs[](run_comment_url / run_digest / base_sha / source_set_digest / candidate_count / delta_summary を持つ derived section。candidate lifecycle state の正本はここに置かない)を additive に追加する形で統合される。一次 run comment の投稿成功後に index update が失敗しても、run 投稿自体は失敗扱いにせず、published_index_stale として区別する(primary persistence をロールバックしない)。
Runtime Verification Applicability
- decision: not_applicable
- reason: 永続化ロジックは GitHub API 呼び出しをモック化した hermetic pytest/vitest で検証可能であり、live GitHub 呼び出しを伴う実地検証は Child 6(検証: agent-retrospective のsecurity boundary・evaluation・dual-runtime smokeを統合検証する #2239、live smoke)の責務とするため。本 Issue では production
main()を実際に通す production-shaped hermetic test(AC1)を必須とし、live mutation smoke は毎 PR 必須にしない
In Scope
.claude/skills/agent-retrospective/scripts/persist_retrospective_run.pyの新規実装(Issue comment としての run 永続化、post-write readback、idempotency guard、optimistic concurrency guard、human authorization gate、public-safety validator).claude/skills/agent-retrospective/scripts/run_retrospective.pyのmain()から persistence-backedPreviousStateProvider(IssueCommentPreviousStateProvider等)を実際に生成・使用する接続実装(--state-backend issue-comments等の CLI 引数からの provider 生成、read_version→expected_previous_digestへの伝播、compute_delta()との接続).claude/skills/agent-retrospective/SKILL.md/.claude/skills/agent-retrospective/references/wire-contract.mdへの、上記 production CLI 接続とhuman_authorization_receipt/v1契約の文書化agent_improvement_candidate/v1の candidate state(candidate record 全体・finding identity・evaluations・delta results)の永続化・再読込みロジックdocs/schemas/agent-retro-index.schema.jsonへのトップレベル optionalretrospective_runs[]derived section の additive 追加(既存entries[]フィールドの削除・型変更は行わない)scripts/agent-logs/lib/retro-index-builder.mjs/scripts/agent-logs/update-retro-index.mjsへのretrospective_runs[]生成ロジックの追加(additive のみ)- 同一
(repo, base_sha, source_set_digest, scope)の重複 run を検出する idempotency guard の実装(publisher 側での idempotency key 再計算を含む) expected_previous_digestに基づく best-effort optimistic concurrency guard の実装(post-write rescan + sibling detection による事後検出)- non-interactive 経路向け
human_authorization_receipt/v1の検証ロジック、および TTY 明示確認経路の実装(mutation 実行前の human authorization gate。authorization が確認できない場合は fail-closed で mutation を拒否する) - ambiguous POST failure(timeout 等)からの request_id ベース回収ロジック
- 最終 POST 直前の public-safety validator(field allowlist・credential/absolute-path/token pattern 拒否・size 事前確認)
.claude/skills/agent-retrospective/scripts/tests/配下への fixture ベース pytest 追加、tests/agent-logs/配下への vitest 追加
Out of Scope
- schema・adapter・Skill/SubAgent 定義そのものの変更(Child 2・Child 3・Child 4 で完結済みの契約に依存する。ただし
agent-retro-index.schema.jsonへの additiveretrospective_runs[]追加のみ本 Issue で行う) - Child 1 の ADR(実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234)自体の内容変更(run consistency model、claim-class source authority、threat/trust matrix、mutation boundary、public/private allowlist の定義は ADR の責務であり、本 Issue はその定義に従うのみ)
- candidate lifecycle transition(
candidate_statusをaccepted等へ変更する機能。remediation mutation は本 Issue のスコープ外) - cryptographic signature/PKI、外部 database、distributed lock service、GitHub App 化、webhook daemon、event-sourced candidate lifecycle、exhaustive secret scanner、property-based test の大量導入、毎回の live mutation smoke
- plugin packaging(Child 7)。現段階では
.claude/standalone 構成を維持する retro-index-comment-helper.mjsの責務変更(derived index comment の upsert 専用のまま維持し、run history の append-only 保存には流用しない)- セキュリティ境界の自動テスト・live smoke(Child 6、検証: agent-retrospective のsecurity boundary・evaluation・dual-runtime smokeを統合検証する #2239)。ただし最終 POST 直前の public-safety validator 実装自体は本 Issue の責務とする(検証: agent-retrospective のsecurity boundary・evaluation・dual-runtime smokeを統合検証する #2239 はその検証を担当する)
Acceptance Criteria
- AC1:
run_retrospective.py main()が persistence-backedPreviousStateProviderを実際に生成・使用し、fixture fallback ではないことを production-shaped integration test で証明する - AC2: provider の
read_versionがPUBLISH_REQUEST_V1.expected_previous_digestへ実際に伝播することをテストで確認する - AC3:
persist_retrospective_run.pyがPUBLISH_REQUEST_V1を消費し、delta_resultsを含む全 mutation payload からpublication_digestを生成する - AC4: interactive TTY 確認または
human_authorization_receipt/v1のいずれもない場合、persist_retrospective_run.pyが Issue comment mutation(POST)を実行しないことを pytest で証明する(fail-closed)。単独の--authorized-by-humanflag は承認として扱わない - AC5: 同一 idempotency key・同一 publication digest は no-op、同一 idempotency key・異なる publication digest は conflict になることをテストで区別する(idempotency key は publisher 側で
(repository_id, base_sha, source_set_digest, scope)から再計算し、caller 供給値とは照合のみ行う) - AC6: POST 前後の head 照合と post-write rescan による sibling detection を行い、GitHub Issue comment backend に原子的 compare-and-swap があるとは主張しない best-effort optimistic concurrency guard として実装されていることをテストで確認する(AC5 の idempotency guard とは独立した検証パスであることを区別する)
- AC7: POST response の comment ID を用いた GET と、
sha256-jcs-v1による canonical JSON digest readback が一致することをテストで確認する(Markdown 生 bytes 比較は行わない) - AC8: candidate record 全体・
finding_contract.identity・finding_contract.claim_class・finding_contract.evaluations[]・delta_resultsが round-trip し、candidate:finding の 1:1 cardinality が検証されることをテストで確認する - AC9: provider が previous state の
available/no_history/legacy_unavailable/partial/staleを fixture ではなく実データ形状から区別することをテストで確認する - AC10: ambiguous POST failure(timeout 等)発生時、再 POST 前に
request_id/idempotency key を検索して既存投稿を回収することをテストで確認する - AC11: run comment 投稿成功後に
agent_retro_index/v1の index update が失敗した場合、戻り値がpublished_index_staleとなり、一次 run record(Issue comment 投稿)がロールバックされないことをテストで確認する。docs/schemas/agent-retro-index.schema.jsonへのretrospective_runs[]additive 追加が既存entries[]フィールドを削除・型変更しないことをpnpm testで確認する - AC12: 最終 POST 直前に public-safety validator(credential/absolute-path/token pattern 拒否、size 事前確認)が実行され、違反時は理由付きで publish を停止することをテストで確認する
Verification Commands
# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k production_provider_used -v# AC2
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k read_version_propagates_to_expected_previous_digest -v# AC3
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k publish_request_produces_publication_digest -v# AC4
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k authorization_gate_blocks_without_receipt_or_confirmation -v# AC5
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k idempotency_key_noop_vs_conflict -v# AC6
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k optimistic_concurrency_best_effort_conflict_detection -v# AC7
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k canonical_get_readback_digest_match -v# AC8
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k candidate_finding_delta_full_roundtrip -v# AC9
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k previous_state_status_classification -v# AC10
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k ambiguous_post_failure_recovery_by_request_id -v# AC11
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k index_update_failure_does_not_rollback_primary_record -v# AC11
$ pnpm test# AC12
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -k public_safety_validator_runs_before_post -vAllowed Paths
.claude/skills/agent-retrospective/SKILL.md.claude/skills/agent-retrospective/references/wire-contract.md.claude/skills/agent-retrospective/scripts/run_retrospective.py.claude/skills/agent-retrospective/scripts/persist_retrospective_run.py.claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.pydocs/schemas/agent-retro-index.schema.jsonscripts/agent-logs/update-retro-index.mjsscripts/agent-logs/lib/retro-index-builder.mjstests/agent-logs/retro-index-update.test.ts
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
docs/schemas/agent-retro-index.schema.jsonのentries[]既存フィールドの削除・型変更が必要と判明した場合- candidate lifecycle transition(
candidate_statusのaccepted等への変更)の実装が必要と判明した場合(remediation mutation はスコープ外のため)
Required Skills
なし
Required Design References
- docs/dev/agent-retro-index.md
- .claude/skills/agent-retrospective/schemas/agent_retrospective_run_v1.schema.json(Child 2)
- docs/adr/0007-agent-retrospective-boundaries.md(Child 1、実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234。mutation boundary・optimistic concurrency/idempotency の区別の正本)
- 実装: agent-retrospective candidate schema に stable finding identity と delta evaluation contract を追加する #2288(delta-evaluation schema 拡張契約。
agent_improvement_candidate/v1のフィールド拡張。CLOSED・確定済み) - 実装: agent-retrospective の run 永続化と agent_retro_index/v1 統合を実装する #2238 issuecomment-5379964604(2026-08-22 OWNER 敵対的レビュー。production call graph・index schema・human authorization contract・optimistic concurrency の再構成根拠)
Scope Delta(任意)
N/A
Source
- Parent: 導入: Claude-GPT運用ログの継続的レトロスペクティブと改善提案を行う agent-retrospective Skill を確立する #2192
- dedupe_key: follow-up:squne121/loop-protocol:issuecomment-5315493153:child-5
- Refinement: 2026-08-18、実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234(Child 1 ADR)の issue-refinement-loop 改訂(OWNER レビュー issuecomment-5327616033 反映)に合わせて用語・概念モデルを同期(
stale-write guard→idempotency guard+ 別メカニズムのoptimistic concurrency guard、mutation boundary のartifact-publication mutation分類を明記)。同日の issue-refinement-loop 実行で、deterministic repair(AC1 VC への# baseline-expect: fail挿入)と review-issue の needs-fix 指摘(AC4 VC が pnpm allowlist 外のpnpm exec vitest run <file>を使用していた点、実リポジトリでscripts/agent-logs/lib/update-retro-index.mjsではなくscripts/agent-logs/update-retro-index.mjsが実在パスである点、およびpnpm test -- <file>も pnpm gate registry の exact argv allowlist(("pnpm","test")のみ許可、追加引数不可)に違反していた点)を反映し、AC4 VC を barepnpm test(引数なし、全体テストスイート実行)に統一 - Refinement: 2026-08-22、OWNER 敵対的レビュー(issuecomment-5379964604、
Verdict: REQUEST_CHANGES — reframe_in_place)を issue-refinement-loop で反映。実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234/実装: agent-retrospective の agent_retrospective_run/v1・agent_improvement_candidate/v1 schema と validator を実装する #2235/実装: agent-retrospective の Orchestrator Skill と retrospective-runtime-observer・retrospective-evaluator SubAgent を実装する #2237/実装: agent-retrospective candidate schema に stable finding identity と delta evaluation contract を追加する #2288 のマージ後の実コードと Allowed Paths・AC1〜AC7・human authorization 契約・AC6 の絶対保証記述との不整合を解消するため、Allowed Paths を 9 ファイルへ拡張し、AC を AC1〜AC12 へ再構成し、human authorization gate を receipt-based(TTY 確認 orhuman_authorization_receipt/v1)へ変更し、AC6 を best-effort optimistic concurrency(post-write rescan + sibling detection)へ修正し、agent_retro_index/v1の統合方式をトップレベル additiveretrospective_runs[]セクションへ変更した
Delivery Rule
1 Issue = 1 PR。専用 worktree で作業し、Draft PR を既定とする。Depends on #2234(Child 1 ADR、CLOSED)。Depends on #2235(Child 2、CLOSED)。Depends on #2237(Child 4、CLOSED)。Depends on #2288(delta-evaluation schema 拡張契約、CLOSED)。
Activity
squne121 commentedon Aug 18, 2026
issue-refinement-loop 完了報告
#2234(Child 1 ADR)の issue-refinement-loop 改訂(OWNER レビュー issuecomment-5327616033、verdict:
REQUEST_CHANGES/ disposition:reframe_in_place)が確立した新用語・概念モデルに、Child 5(本 Issue #2238)の本文を同期させる目的でissue-refinement-loopを実行した。反映した用語・概念モデルの同期
stale-write guard(単一の重複抑止メカニズム)を、Child 1 の ADR 用語に合わせてidempotency guard(duplicate suppression、(repo, base_sha, source_set_digest, scope)ベース) とoptimistic concurrency guard(真の stale-write protection、expected_previous_digest/versionベース) の2つの独立したメカニズムへ分離した(Outcome / In Scope / AC3 / AC6 / VC)agent_retrospective_run/v1の Issue comment 自動投稿を、Child 1 の ADR が定義する mutation boundary 上のartifact-publication mutationに明示的に分類した。この mutation class の human authorization point は ADR(実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234)を正本とし、本 Issue では上書きしない旨を明記したCurrent Validated Scopeに、本 Issue の永続化契約が Child 1 ADR の mutation boundary / optimistic concurrency・idempotency 区別に整合させる旨を追記したRemaining Parent Gapsセクションを新設し、実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234 側の Remaining Parent Gaps に記録されていた Child 5 向け追随修正項目(idempotency/optimistic concurrency の区別、mutation boundary 再確認)をそのまま Child 5 側にも明記したStop Conditionsに「Child 1 の ADR(実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234)が未マージ・未確定の場合は着手せず停止する」を追加し、Delivery Ruleの Depends on にも 実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234 を追加したRequired Design Referencesにdocs/adr/0007-agent-retrospective-boundaries.md(Child 1、実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234)を追加したIteration 履歴
STATUS: needs_fix/NEXT_ACTION: apply_deterministic_repair(insert_baseline_expect_fail、AC1 の VC に# baseline-expect: failが欠落)。1件のみで安全なため適用し、STATUS: passに到達。VERDICT: needs-fix。blocker: AC4 の VCpnpm exec vitest run <file>が pnpm allowlist(typecheck/lint/test/buildのみ)に違反。pnpm test -- <file>に修正。あわせて control-plane の独立調査で判明した実在しないパス参照(scripts/agent-logs/lib/update-retro-index.mjs→ 実際はscripts/agent-logs/update-retro-index.mjs)も修正(Outcome / In Scope / Allowed Paths の3箇所)。VERDICT: needs-fix。理由:pnpm test -- <file>も pnpm gate registry(.claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py)の exact-argv allowlist(("pnpm","test")の完全一致のみ許可、追加引数不可)に違反することが判明。pnpm test(引数なし)に修正。VERDICT: approve。C1〜C13 すべてpass/n/a、blocking_issues: 0。REVIEWED_BODY_SHA256: sha256:e0dbed6e53adee3e10952a10aa82a3fa2818007a20aa38045537c3060c649298(control-plane がgh api repos/squne121/loop-protocol/issues/2238 -q .body | sha256sumで独立に再計算し一致を確認済み)。1回目の rewrite で terminology sync 自体は完了したが、その後 2 回の追加 iteration(pnpm allowlist 関連の非互換性、計 3 iteration)を要して
approveに到達した。自律判断した分岐点
STATUS: needs_fix/NEXT_ACTION: apply_deterministic_repair(Step 0f preflight、AC1 の baseline-expect 欠落): 本 skill は現時点でapply_deterministic_repairの auto-apply consumer を持たないため、SKILL.md の記述上はSTATUS: blocked相当の informational route として扱うのが原則だが、実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234 自身の直前の refinement loop 実行が同種のケースで「Step 4 相当の編集の中で機械的に反映する」という前例を確立していたため、同じ判断を踏襲し、issue-editor による最小限の1行挿入として即座に適用した(新たな mutation を発生させず、後続 iteration の土台を整えるだけの安全な機械的修正と判断)。pnpm test -- <file>)の許容性: iteration 2 の review がhuman_judgment_requiredとして停止を示唆したが、control-plane が.claude/skills/issue-contract-review/scripts/pnpm_gate_registry.pyのソースを直接確認し、("pnpm","test")の完全一致のみが許可されている(追加引数は一切許可されない)ことをコードから確定的に検証できたため、human escalation を経ずに barepnpm test(全体テストスイート実行)へ変更する判断を自律的に下した。VC の意味(agent_retro_indexupsert の additive 拡張検証)はpnpm test実行にtests/agent-logs/retro-index-update.test.tsが含まれるため損なわれない。pnpm testは現状の repository で既に PASS する可能性が高く、baseline-expect: fail の要否が曖昧だったが、Step 0f preflight の deterministic repair 機構が該当 VC を repair 対象として検出しなかった(対象は AC1 のみだった)ため、追加の annotation は挿入せず、preflight の判定をそのまま採用した。new_body_sha256と、control-plane がgh apiで独立に再計算した sha256 が複数回一致しなかった。調査の結果、edit_issue_txn.pyの内部 stale-precondition readback が GitHub 側でストレージ時に付与される末尾の空行1行を含めずに hash を計算するのに対し、gh api/GraphQL の live read はその空行を含めて hash を計算するという、無害な正規化差異であることを特定した(実コンテンツの相違ではない)。今後同種の不一致が出た場合の参考のため本報告に記録する。Remaining Parent Gapsセクションの新設: 元の 実装: agent-retrospective の run 永続化と agent_retro_index/v1 統合を実装する #2238 本文にはこのセクションが存在しなかったが、実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234(parent ADR Issue)側に既に Child 5 向けの gap 項目が記録されていたため、Child 5 自身の本文にもミラーとして明記することで、Child 5 単体を読んだ実装者にも ADR との非同期リスクが伝わるようにした(スコープや意図の変更ではなく、既存の parent 記述の重複明示)。LOOP_HANDOFF_RESULT_V1のstatus:issue-contract-reviewskill(別スキル)による freshCONTRACT_REVIEW_RESULT_V1: go判定を本ループでは取得していないため、impl_readyinvariant を満たさない。したがってstatus: blocked/routing_action: blocked/gate_result: missing_goとして正直に報告する(過大な readiness 主張をしない。実装: agent-retrospective の ADR で run boundary・source authority・mutation boundary・public/private artifact 境界を確定する #2234 の直前の refinement loop 完了報告と同じ扱い)。未解決の懸念
docs/adr/0007-agent-retrospective-boundaries.md)がまだ存在しないことを前提に、その将来の定義(用語・mutation boundary・authorization point)を先取りして参照している。ADR が実際にマージされacceptedになった際、本 Issue が参照する具体的な用語・構造(artifact-publication mutationの human authorization point の値など)と ADR 本文が完全に一致するかは、ADR マージ後に改めて確認が必要(本 Issue の Stop Conditions に明記済み)agent_retrospective_run_v1.schema.json)はまだ存在しないため、本 Issue が参照するsource_set_digest/base_sha/scope等のフィールド名が Child 2 の実際の schema と一致するかは未検証(Child 2 マージ後に再確認が必要)issue-contract-review(実装着手直前の preflight)は未実行のため、実装着手には別途その skill のgo判定が必要Final Gate:
LOOP_HANDOFF_RESULT_V1を出力する(issue_kind: implementation)。status: blocked/routing_action: blocked(理由:contract_review.gate_result: missing_go— 本ループではissue-contract-reviewを実行していないため)。squne121 commentedon Aug 21, 2026
issue-refinement-loop: approved (body) / handoff blocked
Issue #2238 の refinement loop(通常モード・anchorなし)を実行した結果を報告する。
実施内容
Step 0f preflight:
run_refinement_preflight.py→STATUS: pass/NEXT_ACTION: proceedStep 2 review(1周目):
run_root_review_pipeline.py produce→VERDICT: approve(ISSUE_REVIEW_RESULT_V1.blocking_issues: []、C1〜C13 deterministic checks 全pass/n/a)Final Gate(issue-contract-review)確認:
run_contract_review_once.py --mode staticを実行したところ、readiness_status: goだがcheck_blockersがhuman_escalationを返した。gh api .../dependencies/blocked_by):2235, 2237Depends on #N記述:2234, 2235, 2237, 2288機械的修正(issue-editor へ委譲): 本文側の依存記述は正しい意図(直前パッチで 実装: agent-retrospective candidate schema に stable finding identity と delta evaluation contract を追加する #2288 dependency を追加済み)だったため、native 側に
#2234/#2288をadd_blocked_byとして追加するedit-issuecontrolled transaction(native_relationshipsのみ、body は不変)を issue-editor SubAgent に委譲して実行した。[2234, 2235, 2237, 2288](本文と一致)sha256:d591471f9d6f2ae3a128c3ee4c7d648eb0d4dc8e551406b38062f502644cfa3b)、本文は無変更Final Gate 再確認:
run_contract_review_once.py --mode static再実行 → dependency parser 不一致は解消(check_blockersの native/body mismatch エラーは消滅)。ただしstatus: blockedが残存。理由は open blocker:#2237(state=OPEN)#2288(state=OPEN)両 Issue がまだ close されていないための正当な待機状態であり、Issue 実装: agent-retrospective の run 永続化と agent_retro_index/v1 統合を実装する #2238 本文の欠陥・品質問題ではない。issue-editor による本文修正では解消できない(本文はすでに正しい依存関係を宣言しており、native 関係も正しく同期済み)。
結論
VERDICT: approve、blocker 0、iteration 1 で完了(機械的修正1回のみ、rewrite loop の反復は不要だった)。CONTRACT_REVIEW_RESULT_V1.status == go)は未達:#2237/#2288が open のためstatus: blocked。これは Issue 実装: agent-retrospective の run 永続化と agent_retro_index/v1 統合を実装する #2238 が正しく他 Issue のマージ完了を待つ構造になっていることの反映であり、human-in-the-loop での Issue 内容判断を要する stop condition ではない。#2237/#2288のマージ完了後にissue-contract-reviewを再実行すればstatus: goに遷移する見込み。実装: agent_improvement_candidate/v1 に finding_contract versioned envel…
fix: PR #2293 iteration-4 fix_delta -- compute_delta 本番配線・frontmatter…
実装: agent-retrospective の Orchestrator Skill と retrospective-runtime-…
squne121 commentedon Aug 22, 2026
敵対的レビュー結論
Verdict:
REQUEST_CHANGES—reframe_in_place現行 Issue 本文のまま実装 PR を開始すべきではありません。
問題の中心は、セキュリティ対策やテストハーネスが不足していることではなく、現在の production call graph・永続化形式・既存 index schema が相互接続できないことです。2026年8月21日の refinement コメントは「本文品質は approve、依存 Issue が閉じれば go へ移行する見込み」としていますが、これは #2237/#2288 の具体的な実装が確定する前の判断です。マージ後の実コードを照合すると、その前提は維持できません。
P0-1 — production CLI が永続化済み previous state を読めず、AC5・AC6を成立させられない
現在の
run_cli()は Python オブジェクトとしてprevious_state_providerを受け取れますが、公開main()の CLI 引数には provider や永続化先を指定する経路がありません。main()からの通常実行では常に空のFixturePreviousStateProviderが使われます。さらに、PreviousStateResult.read_versionは取得されるものの、finalize()のexpected_previous_digestへ渡されていません。その結果、文書化された production entrypoint では次の状態になります。
finding_contractを持つ current candidate は原則すべてnew扱いになるexpected_previous_digestはNoneのままpersist_retrospective_run.pyを追加しても、delta 算出済みの上流処理へ接続されない一方、#2238 の Allowed Paths は
run_retrospective.py、SKILL.md、references/wire-contract.mdを含まず、これらを直すと即座に Stop Condition へ到達します。必須修正
Allowed Paths に少なくとも次を追加すべきです。
production CLI は、例えば次の引数から
IssueCommentPreviousStateProviderを内部生成する構造にします。そして必ず次を実装します。
依存性注入フレームワークや plugin registry は不要です。
persist_retrospective_run.pyに provider class を置き、run_retrospective.pyが遅延 import する程度で十分です。P0-2 —
agent_retro_index/v1統合は現行 Allowed Paths では実装不能現在の
agent_retro_index/v1schema はadditionalProperties: falseで、各entries[]に次を必須要求します。report_comment_urlreport_digestissueprmerge_shatagsfriction_summaryquality_signalsfollow_up_issuesつまり、PR や merge SHA を持たない一般的な retrospective run を正しく表現できません。URL pattern も
squne121/loop-protocolに固定されています。さらに現在の builder は、コメントから
agent_run_report/v1を抽出し、validateAgentRunReport()で検証する実装です。agent_retrospective_run/v1や新しい persistence record を認識する経路はありません。しかし #2238 の Allowed Paths には、次の実際の変更対象が含まれていません。
update-retro-index.mjsだけを変更しても、closed schema と builder parser を通せません。既存 fields に無理やり run を詰めると、架空の PR 番号や merge SHA を生成することになり、index の意味を破壊します。必須修正
後方互換性を維持するなら、既存
entriesを変形するより、トップレベルに optional な derived section を追加する方が安全です。{ "schema": "agent_retro_index/v1", "generation_verdict": "complete", "entries": [], "retrospective_runs": [ { "run_comment_url": "...", "run_digest": "sha256:...", "base_sha": "...", "source_set_digest": "...", "candidate_count": 3, "delta_summary": { "new": 1, "resolved": 1, "unchanged": 1 } } ], "orphan_reports": [], "ambiguous_links": [] }ここには candidate lifecycle state の正本を置かず、リンク・digest・件数・要約だけを置きます。ADR も
agent_retro_index/v1を derived index とし、run/candidate state の保存先にしてはならないと定めています。また、一次 run comment の投稿成功後に index 更新が失敗しても、run 投稿を失敗扱いにしてはいけません。戻り値は例えば次のように分離します。
P0-3 — human authorization の契約が producer と consumer で矛盾している
#2238 本文は human authorization の例として、
--authorized-by-humanや authorization token を挙げています。ところが現在のPUBLISH_REQUEST_V1は以下の field を明示的に禁止しています。また、現在の Skill は human authorization を
HUMAN_AUTHORIZATION_RECEIPT_V1相当の別 trusted channel で渡す設計としています。単なる
--authorized-by-humanflag は、AI やスクリプトも付けられるため、承認確認として機能しません。さらに
public_projection_digestはdelta_resultsを hash preimage に含めていません。したがって、この digest だけに承認を結び付けると、承認された delta と実際に投稿された delta が一致する保証がありません。趣味開発向けの最小設計
署名基盤や秘密鍵は不要です。次の二経路で十分です。
authorizeコマンドが生成した短命な receipt file を要求するreceipt は最低限、次へ束縛します。
publication_digestは次の全 mutation payload から計算します。{ "repository_id": "...", "scope": "repository", "target_issue": 123, "request_id": "...", "parent_record_digest": "...", "publish_request": { "...": "...", "candidate_records": [], "delta_results": [] } }既存
public_projection_digestの意味は変更せず、publisher 専用のpublication_digestを追加する方が低リスクです。P0-4 — GitHub Issue comment では原子的な compare-and-swap を保証できない
GitHub の Create Issue Comment API が mutation request として受け取るのは基本的に
bodyだけです。通常の unsafe method に対する conditional request は、個別 endpoint が明示しない限りサポートされません。したがって、二つの publisher が同じ previous digest を読んだ後、両方とも POST に成功する race を Issue comment POST 単独では原子的に拒否できません。これは API 仕様からの推論です。([GitHub Docs]1)また Issue comment には update と delete の endpoint があるため、「GitHub 上で immutable」は事実ではありません。保証できるのは「この tool は既存 run comment を更新・削除しない」という運用契約までです。([GitHub Docs]2)
AC6 の修正
現行の「不一致なら書き込みを拒否する」という絶対保証は、次の best-effort optimistic concurrency に変更すべきです。
parent_record_digestを含む新規 comment を appendconflict_detectedstaleを返し、次 run でresolved等を断定しない同一 PC・同一リポジトリ内の自己競合だけは、短時間の local lock で抑止できます。外部 DB、distributed lock、GitHub App、webhook worker は不要です。
本文中の “immutable” は、次に置換するのが正確です。
P1-1 — 保存対象の envelope が定義されていない
agent_retrospective_run/v1は primary run record ですが、内容はrun_identityとsource_observationsです。repository、scope、request、approval、candidate、delta、comment chain などの persistence metadata は持ちません。一方
PUBLISH_REQUEST_V1は candidate と delta を持ちますが、GitHub comment として何をどの形式で保存するかが #2238 に定義されていません。この状態では実装者が独自の comment format を作ることになります。MVP では新たな大規模 schema package を作らず、
persist_retrospective_run.py内の closed dataclass と wire-contract 文書で次を固定すれば十分です。コメントは stable marker と fenced JSON を一つずつ持つ形にします。
判定は次の三値にします。
P1-4 — post-write readback は Markdown の生 bytes 比較にしてはいけない
既存の refinement コメント自身が、GitHub 保存時に付加された末尾空行の差で body hash が一致しなかった事例を記録しています。
したがって AC2 の「comment 内容が一致」は、次の意味に限定すべきです。
publication_digestと比較JSON の hash を安定させるには、既に finding identity で使っている
sha256-jcs-v1と同じ JCS 実装を再利用するのが妥当です。RFC 8785 は JSON を決定論的に整列・直列化し、反復可能な hash 対象を作るための方式です。([RFC Editor]3)Python 側の record digest と、既存 JavaScript index builder の独自 digest を混同してはいけません。index digest は引き続き JS builder に計算させます。
P1-5 — ambiguous POST failure と pagination の契約がない
典型的な失敗経路は「GitHub は comment を作成したが、client は response を受信する前に timeout した」です。盲目的に POST を再試行すると duplicate comment ができます。
再試行前に必ず
request_id/idempotency key を全ページ検索し、とする必要があります。
GitHub REST API の list は paginated であり、
Linkheader に従って最終ページまで辿るのが公式方式です。多くの endpoint ではper_pageの上限は100です。途中で traversal を打ち切った場合、no_historyではなくpartialを返す必要があります。([GitHub Docs]4)mutation は直列化し、rate limit 時は
Retry-Afterに従います。ただし大規模 queue や常駐 worker は不要で、publisher 内の数回の bounded retry で十分です。([GitHub Docs]5)Issue comment 作成は通知を発生させるため、専用の ledger Issue を一つ設ける方が、通常 Issue/PR の会話を汚しません。([GitHub Docs]1)
P1-6 — public-safe validation の実装責任が空白になっている
ADR は public artifact に対し、
の二層を要求しています。
しかし #2238 の AC には final publication validation がなく、#2239 は security test/live smoke を担当する一方で persistence 実装変更を Out of Scope としています。
したがって #2238 が最終 POST 直前の validator を実装し、#2239 がそれを検証する構造に直す必要があります。
ただし、ここで DLP システムを作る必要はありません。
この一回の preflight だけで十分です。
推奨する最小アーキテクチャ
必要な主要 component は四つだけです。
抽象 factory、DI container、event bus、database migration framework は不要です。
Issue 本文に追加すべき Acceptance Criteria
現行 AC1〜AC7 は、次の内容へ再構成するのが妥当です。
main()が persistence-backedPreviousStateProviderを実際に生成・使用し、fixture fallback ではないことを integration test で証明するread_versionがPublishRequest.expected_previous_digestにそのまま伝播するPUBLISH_REQUEST_V1を消費し、delta_resultsを含むpublication_digestを生成する--authorized-by-humanflag は承認として扱わないavailable/no_history/legacy_unavailable/partial/staleを実データから区別するpublished_index_staleとなり、一次記録をロールバックしないAllowed Paths の修正版
retro-index-comment-helper.mjsは、run comment の append に流用せず、derived index comment の upsert 専用のまま維持する方が安全です。現在の updater は index comment を更新する設計であり、run history の append-only 保存とは責務が異なります。テスト戦略
#2238 では次の hermetic cases に絞るべきです。
read_versionが publish request へ伝播するpartiallive GitHub smoke は #2239 に一件だけ置けば十分です。毎 PR で live mutation を必須にする必要はありません。
これは特に重要です。#2293 では一度、required CI と99件の hermetic test を根拠に approve されましたが、その後の production-path 敵対的レビューで CLI protocol や call graph の P0 が見つかっています。テスト数を増やすより、公開
main()を通す production-shaped test を一つ持つ方が価値があります。配布形態について
個人趣味開発の現段階では、現在の
.claude/standalone 構成を維持するのが妥当です。Claude Code 公式ドキュメントも、standalone configuration を個人ワークフロー、project-specific customization、quick experiment 向けとし、plugin を共有・versioned release・複数 project 再利用向けとしています。(Claude)後から plugin 化する場合だけ、次の配置にします。
bin/の executable は plugin 有効時の PATH に追加されます。([Claude]7)ただし現在の index schema/updater は repository 名を hard-code しているため、これを generic plugin core に含めるべきではありません。persistence core は repository-neutral、
loop-protocolの retro-index adapter は project-local として分離するのが適切です。意図的に実装しないもの
個人趣味開発という前提では、次は不要です。
維持すべきなのは、次の実用上の保護だけです。
最優先は、
PreviousStateProvider.read_versionを production CLI へ接続することと、現行 index schema では retrospective run を表現できない問題を解消することです。ここを直さずにpersist_retrospective_run.pyの実装へ進むと、テスト上は通っても実運用では常に履歴なしとして動作する永続化層になります。squne121 commentedon Aug 22, 2026
issue-refinement-loop 完了報告(2 iteration)
termination_cause: approved
final body_sha256:
sha256:f56514e717eaffc9ad1a7352cf5e16f7dfa9f5f3d7e547ffb25b8c349191683a経緯
Verdict: REQUEST_CHANGES — reframe_in_place)を anchor comment として反映し、VERDICT: needs-fix(BLOCKERS: 10)と判定。構造的契約チェック(C1-C13)自体は approve だったが、P0-1〜P0-4/P1-1〜P1-6 の semantic gap(Allowed Paths 不足、production CLI 未接続、agent_retro_index/v1schema 表現不能、human authorization 契約矛盾、GitHub API 原子性の誤った絶対保証記述)を検出。SKILL.md/references/wire-contract.md/run_retrospective.py/docs/schemas/agent-retro-index.schema.json/scripts/agent-logs/lib/retro-index-builder.mjsを追加)--authorized-by-humanflag から「TTY 確認 orhuman_authorization_receipt/v1検証」の receipt-based 設計へ変更agent_retro_index/v1統合方式をトップレベル additiveretrospective_runs[]セクション追加へ変更(既存entries[]は非破壊)VERDICT: approve。結果
state: approved。iteration 上限(3)に達する前に 2 iteration で収束。追加の follow-up Issue 起票は不要(本 Issue のスコープ内で完結)。human 承認待ちのブロッキング stop は発生しなかった。squne121 commentedon Aug 22, 2026
implement-issue: 実装完了 (2026-08-22T12:20:21Z)
.claude/worktrees/issue-2238-persist-retro-runworktree-issue-2238-persist-retro-runfix_delta: PR #2304 OWNER adversarial review 7 P0 + 4 P1 を解消する (#2238)
実装: agent-retrospective の run 永続化と agent_retro_index/v1 統合を実装する (#2304)