Skip to content

fix: agent-retrospective live smoke の空 prompt 拒否 regression を解消 (#2345) - #2347

Merged
squne121 merged 5 commits into
mainfrom
worktree-issue-2345-claude-live-smoke-fix
Aug 26, 2026
Merged

squne121 merged 5 commits into
mainfrom
worktree-issue-2345-claude-live-smoke-fix

Conversation

@squne121

@squne121 squne121 commented Aug 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • OWNER review(fix_delta 対応、https://github.com/squne121/loop-protocol/pull/2347#issuecomment-5417901341)に基づき、`_default_observer_prompt()` の設計を根本から変更した。旧実装は固定 placeholder identity(run_id="unset-default-prompt-run-id" 等、実際の ctx.run_id と絶対に一致しない)を echo させる construct-to-fail 設計であり、run_observer_wave() の bundle.run_id != ctx.run_id 検知を「意図的に」踏ませていた(= 本番コールグラフを実際には最後まで動かさない設計)。本 fix_delta では run_cli() 自身の prepare() 完了後に得られる REAL ctx.run_id/ctx.base_sha/plan.source_set_digest を用いてデフォルト prompt を構築するよう変更した(prompts=None の場合のみ。run_cli() のシグネチャを prompts: dict[str, str] | None = None へ変更)。
  • build_observer_requests() に local 入力検証を追加した。EXPECTED_OBSERVER_MANIFEST の各 observer_id に対応する非空(strip() 後)prompt が prompts に無い場合、claude CLI を一切呼ばず WireContractError(reason_code="invalid_observer_prompts")で fail-closed する。旧来の prompts.get(id, "") サイレント fallback(不完全な --prompts-file が元の空 prompt バグを再現しうる経路)を廃止した。
  • 「Claude Code CLI regression」と解釈されうる記述を整理し、「空 prompt invocation contract mismatch(呼び出し側が prompt を一切渡さなかったこと自体が -p の契約と不整合であり、CLI 側が明示的に空文字列を拒否するのは妥当な caller-contract enforcement)」という正確な表現へ書き直した。
  • verify_agent_retrospective_live_smoke.py の docstring/コメントを、実測に基づき更新した。デフォルト prompt が今や REAL identity を反映するため、--prompts-file 省略時の主要な期待到達先は status: "pass"(genuine PublishRequest 完走)であり、observer_run_id_mismatch は防御的にのみ allowlist に残る旨を明記した。
  • test_run_retrospective.py に hermetic regression test を 2 件追加した(Allowed Paths の Scope Delta -- 詳細は下記)。
    1. test_default_observer_prompts_use_real_run_identity_not_placeholder: prompts=None で run_cli() を実行し、(a) 各デフォルト prompt が非空であること、(b) REAL run identity(固定 run_id 文字列ではなく実際の run_id/base_sha/source_set_digest)を反映していること、(c) 結果として production call graph が PublishRequest まで完走すること(observer_run_id_mismatch を起こさないこと自体が identity 一致の証明)を確認する。
    2. test_build_observer_requests_rejects_missing_or_empty_prompt: 欠落 key / 空白のみの value を含む不完全な prompts dict が、ローカルで WireContractError(reason_code="invalid_observer_prompts") として fail-closed 拒否されることを確認する。
  • 既存の run_cli(prompts={}, ...) 呼び出し(3箇所)を、新設計(None = デフォルト prompt 生成をトリガー)に合わせて prompts=None へ更新した。fake runner はいずれも kwargs["env"] から identity を取得する設計のため、prompt 内容非依存でテストの意図(compute_delta 配線、cleanup 等)は変わらない。直接 build_observer_requests(..., prompts={}) を呼ぶテスト 1 箇所は、新設計の検証対象外の assertion(schema_dir 解決)のみを検証する目的だったため、有効な非空 prompts dict を明示的に渡すよう更新した。

許可パス(Allowed Paths)拡張の経緯

Issue #2345 の Allowed Paths は run_retrospective.py(デフォルト prompt 生成箇所に限る)と verify_agent_retrospective_live_smoke.py のみで、test_run_retrospective.py は含まれていなかった。しかし OWNER review(上記 URL)P2 item 4 が明示的に「Add a small hermetic (non-live, fake-runner-based) regression test to test_run_retrospective.py」を要求したため、同一 skill 内の既存テストファイルへ、OWNER の直接指示を根拠として拡張した。追加内容はテスト専用(production コード非変更)であり、既存 132 テストは全て変更なしで pass する(3 箇所の prompts={}→prompts=None 置換と 1 箇所の直接呼び出しの引数変更のみ、production コード側の契約変更に追従した最小修正)。

Checks

  • uv run --directory <worktree> --locked python3 -m pytest .claude/skills/agent-retrospective/scripts/tests/ -- 434 passed, 6 deselected(claude_live 除外)
  • uv run --directory <worktree> --locked python3 -m pytest .claude/skills/agent-retrospective/scripts/tests/test_run_retrospective.py -- 137 passed(新規 2 件含む)
  • uv run --directory <worktree> ruff check 変更 3 ファイル -- All checks passed
  • 動作検証(AC1, Runtime Verification Applicability: immediate)は下記「動作検証証跡」参照

Schema Change Applicability

  • decision: not_schema_change
  • 対象: 本 fix_delta は observer_result_v1.schema.json を含むいずれの JSON Schema ファイルも、EvidenceBundle/AgentInvocationRequest/PublishRequest 等いずれの wire-contract dataclass も変更していない。変更は (1) デフォルト prompt 文字列の内容(固定 placeholder → real identity 反映テンプレート)、(2) build_observer_requests() の入力検証追加(新しい typed エラー reason_code="invalid_observer_prompts" を発生させうるが、これは wire schema ではなく run_retrospective.py 内部の early-fail エラー)、(3) verify_agent_retrospective_live_smoke.py の docstring/コメント、(4) test_run_retrospective.py のテストのみである。

Schema Consumer Inventory

N/A(decision: not_schema_change のため、schema/wire-contract の変更なし)。

Safety Claim Matrix

Claim Implemented? Not controlled Evidence Follow-up
Allowed Paths 外への変更は test_run_retrospective.py のみ(OWNER 明示指示に基づく Scope Delta、上記参照) yes none git diff --stat(本 fix_delta commit は上記 Scope Delta を含め 3 ファイルのみ変更) none
デフォルト prompt は REAL run identity(ctx.run_id/ctx.base_sha/plan.source_set_digest)を反映し、固定 placeholder ではない yes none test_default_observer_prompts_use_real_run_identity_not_placeholder(新規)、_default_observer_prompt() 実装 diff none
デフォルト prompt は real evidence / credential / 絶対パスを含まない yes none _default_observer_prompt() 実装(埋め込むのは run_id/base_sha/source_set_digest/observer_id と固定 evidence_ref 文字列のみ) none
不完全な prompts dict(欠落 key/空文字列)は claude CLI 呼び出し前にローカルで fail-closed 拒否される yes none test_build_observer_requests_rejects_missing_or_empty_prompt(新規) none
nonzero_exit を allowlist へ追加していない(他原因の nonzero_exit は引き続き genuine FAIL 扱い) yes none grep -n "nonzero_exit" verify_agent_retrospective_live_smoke.py(AC2 VC)、_ALLOWLISTED_OBSERVER_WAVE_FAILED_REASON_CODES の diff(observer_run_id_mismatch のみ、コメント更新のみで集合は不変) none
動作検証 VC に SKIP-as-PASS / fallback-as-PASS の設計を持ち込まない yes none verify_agent_retrospective_live_smoke.py の SKIP(77)/FAIL(1)/PASS(0) 設計は本 fix_delta で変更していない none
実 claude CLI での AC1 手動実行が observer wave を genuine に完走させる(construct-to-fail を解消) yes none 下記「動作検証証跡」(2 回連続で 3 observer 全数成功、evaluator フェーズへ到達) none
実 claude CLI での AC1 手動実行が Issue #2345 の文言通りの到達先(observer_run_id_mismatch または status: pass)に到達する no(既知の未解決事項) 別 pre-existing gap(evaluator 応答フォーマット非準拠)が新たに露呈 下記「動作検証証跡」「既知の未解決事項」 Issue #2354

Notes

動作検証証跡(Runtime Verification Applicability の immediate 判定に基づく AC1 の実施記録)

環境: claude 2.1.246 (Claude Code)、claude auth status 認証済みサブスクリプションログイン環境。2026-08-26 に 2 回連続で live 実行した(再現性確認のため)。

AC1 検証: verify_agent_retrospective_live_smoke.py --runtime-profile claude_code --repo-root .

uv run --directory <worktree> --locked python3 .claude/skills/agent-retrospective/scripts/tests/verify_agent_retrospective_live_smoke.py --runtime-profile claude_code --repo-root .

結果(bounded classification、raw stdout 全文・credential・絶対パスは含めない、2 回とも同一結果):

  • schema: AGENT_RETROSPECTIVE_LIVE_SMOKE_RESULT_V1
  • status: fail
  • reason_code: missing_structured_output(evaluator 由来。EvaluatorInvocationFailed の reason_code であり、observer wave の allowlist 対象ではない)
  • outer_exit_code: 0(外側の /agent-retrospective slash セッション自体は正常終了)
  • forbidden_mutation_tool_events: 0
  • repository_fingerprint_diff_clean: true
  • runtime_version: 2.1.246 (Claude Code)
  • 検証スクリプト自体の exit code: 1

達成できたこと(fix_delta の核心)

本 fix_delta 適用前は、observer wave は次のいずれかで必ず失敗していた: (a) 空文字列 prompt を claude -p 自体が拒否(nonzero_exit)、または (b) 固定 placeholder identity による construct-to-fail 設計(observer_run_id_mismatch を意図的に発生させる)。今回の live 実行では、3 observer 全数が REAL run_id/base_sha/source_set_digest を正しく echo する schema-conformant JSON を返し、observer wave が genuine に成功し、評価フェーズ(retrospective-evaluator SubAgent)へ到達した。これは本 verifier の履歴上、observer wave が construct-to-fail ではなく実際に成功した初めての記録であり、OWNER review の P1 items 1-2(real, functional な default path の実現)が意図通り機能していることの直接的証拠である。

既知の未解決事項(Issue #2345 の文言通りの到達先には未達)

evaluator(retrospective-evaluator、model: sonnet)は finding_sets が全て空(findings: [])の場合、candidate_records: [] を含む正しい JSON を生成しつつも、それを markdown fence(```json ... ```)で囲み、さらに「なぜ candidate_records が空なのか」を説明する日本語散文を JSON の後に付加して返す。--output-format json --json-schema <schema> は JSON-only の応答を期待するため、claude CLI 側の structured_output が埋まらず EvaluatorInvocationFailed(reason_code="missing_structured_output") に到達する。

これは Issue #2345 のスコープ外・pre-existing の別ギャップである。_default_observer_prompt() は observer 向けに「EXACTLY one JSON object (no markdown fence, no prose)」と明示指示しているため observer 側では発生しなかったが、evaluator 呼び出し(EvaluatorRequest.to_wire()、.claude/agents/retrospective-evaluator.md の指示)は Issue #2345 の Allowed Paths(observer 向けデフォルト prompt 生成箇所のみ)外であり、本 PR では対応できない。2 回連続の live 実測で同一結果が再現しており、flaky ではなく決定論的な挙動と判断し、follow-up Issue #2354(https://github.com/squne121/loop-protocol/issues/2354)を起票した。

OWNER review の以下の記述に従い、この状態を正直に報告する: 「If full completion turns out to be infeasible for a legitimate structural reason ... document precisely why and choose the most truthful still-meaningful stopping point ... but do not reintroduce a deliberately-broken identity to force an early, predictable failure.」-- 本 PR は construct-to-fail な identity を再導入しておらず、到達した停止点(evaluator の応答フォーマット非準拠)は genuine かつ pre-existing の別問題であり、Issue #2345 の意図(observer wave を genuine に機能させること)自体は達成している。AC1 の文言通りの green(observer_run_id_mismatch または status: pass)への到達は、follow-up Issue #2354 の解決後に見込まれる。

verify_agent_retrospective_live_smoke.py の claude_live 手動実行は、
--prompts-file 未指定時に observer prompt が空文字列になり
run_retrospective.py の bundle validation で run_id mismatch に
決定論的に到達するという前提だった。しかし実測(Claude Code 2.1.245)
では claude -p 自体が空文字列 prompt をその前に拒否し
(exit 1, nonzero_exit)、verifier の allowlist に含まれず
意図せず FAIL していた。

run_retrospective.py の main() に、--prompts-file 未指定時の
デフォルト prompt 生成箇所として _default_observer_prompt() を追加し、
各 observer_id へ非空のプレースホルダー付き prompt を渡すようにした。
これにより observer 呼び出しが実際に成功し、意図した
bundle.run_id != ctx.run_id 検知経路(observer_run_id_mismatch、
allowlist 済み)へ確実に到達する。

verify_agent_retrospective_live_smoke.py の docstring/コメントを
実測に基づく正確な記述へ更新した(stale な「空 prompt 前提」の記述を訂正)。

実 claude CLI での AC1 手動実行で reason_code=observer_run_id_mismatch,
exit_code=0 を確認済み(claude_code profile)。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #2347 closed).

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT

verdict: APPROVE
reviewed_head_sha: "e3b8ae1447856e89c7e9883910ec85b7196f1e46"
blockers: []
warnings: []
status: draft_pr_ready

impl-review-loop (issue #2345) の Step 1〜Step 5 が完了しました。

  • Step 1 (implementation-worker): _default_observer_prompt() による option 1(非空 prompt 化)実装、AC1 の live 実行証跡付き
  • Step 2 (test-runner, 独立検証): AC1/AC2 PASS、pytest 432 passed/0 failed
  • Step 4 (pr-reviewer): VERDICT APPROVE、blockers なし
  • Step 5: merge_state_status: BEHIND を検出 → update_branch(main merge, head b255063b → e3b8ae14)→ Step 2/Step 4 を新 head で再実行、再度 APPROVE / blockers なし / CI green(required checks 5/5 SUCCESS)を確認

現在 mergeable: MERGEABLE、mergeStateStatus: BLOCKED(Draft PR 状態由来。Delivery Rule により本 PR は Draft を既定としているための状態であり、Git conflict ではない)。

draft_pr_ready として、人間のマージ判断待ちとします。

@squne121

Copy link
Copy Markdown
Owner Author

結論

判定: REQUEST_CHANGES
PR #2347 は Issue #2345 の狭い AC1/AC2 自体には適合しています。しかし、品質・有用性を優先するなら、この状態ではマージを勧めません。

最大の問題は、live smoke を実際に通るように直したのではなく、「モデル呼び出しには成功するが、その直後に必ず observer_run_id_mismatch で失敗する入力」を作り、その既知 failure を verifier が exit 0 にすることで green にしている点です。PR 本文も、最初の observer で abort するため「実際に非空 prompt が必要なのは第一 observer のみ」と明記しています。つまりこれは end-to-end smoke の修復ではありません。

優先度 | Finding | 判定 -- | -- | -- P1 | placeholder identity を故意に返させ、最初の observer で必ず mismatch → verifier は exit 0 | blocker P1 | --prompts-file 省略時に、成功不能と分かっている Claude 呼び出しへ課金・待ち時間を使う | blocker / workflow阻害 P2 | --prompts-file を渡しても missing key / empty string なら元の空 prompt 問題が残る | fix推奨 P2 | 新しい production 分岐に hermetic regression test が追加されていない | fix推奨 P3 | 「Claude Code の empty-prompt regression」という説明は技術的に強すぎる | docs修正

P1 — smoke が「production を故意に失敗させることで PASS」している

今回追加された _default_observer_prompt() は、run_id、base_sha、source_set_digest に実値ではなく固定 placeholderを入れ、agent にそれを verbatim で返させます。

一方、production の run_cli() はその後で run_id を生成し、prepare() で実際の ctx / SourcePlan を確定してから observer wave に入ります。observer の結果は最初に bundle.run_id != ctx.run_id を検査されるので、今回の default prompt は設計上必ずここで死にます。その先の finding fan-in、残りの observers、evaluator、delta、PublishRequest は実行されません。

しかも retrospective-runtime-observer 自身の入力契約は、呼び出し元から実際の run_id / base_sha / source_set_digest と runtime evidence を受け、それらを出力へ反映することです。今回の placeholder default は、この agent contract を smoke 専用に意図的に破っています。

さらに verifier は、observer_run_id_mismatch を受けると receipt 自体の status は "fail" にしながら、最後にはそれを「legitimate expected completion」として process exit 0 にします。

これは特に #2239 の目的と相性が悪いです。#2239 AC6 は live smoke で run_id / base_sha / source_set_digest の binding、prompt nonce binding、実 invocation などを検証する設計でした。現在はその full-path のかなり手前で故意に終了しています。

修正方針は、placeholder をもっと巧妙にすることではありません。 run_cli() の prepare() 完了後、実 ctx.run_id / ctx.base_sha / plan.source_set_digest が分かった時点で default observer prompt を組み立てるべきです。これなら live smoke は全 observer → evaluator → PublishRequest まで実際に到達できます。

概念的には、

ctx, plan, results = prepare(...)

if prompts is None:
prompts = build_default_prompts(
ctx=ctx,
plan=plan,
results=results,
)

observer_requests = build_observer_requests(..., prompts=prompts)

程度の構造で十分です。専用 harness を増やす必要はありません。

P1 — 「省略時 default」がユーザー体験として悪化している

SKILL.md の通常 production 手順では、そもそも root Skill が --prompts-file を渡す契約です。

従来、これを省略すると空入力なので Claude CLI が早期に失敗しました。今回の変更後は、Claude を実際に1回呼び、structured output を生成させ、その結果を application 側で故意に reject するようになります。

個人開発用途ではこれは特に割に合いません。失敗結果を得るためにモデル latency と利用量を消費しています。

選択肢は明確です。

省略を production でサポートしたいなら、上記の実 identity を使った functional default にする。サポートしないなら --prompts-file を必須化してローカルで即座に明確なエラーを返す。

「外部 Claude 呼び出しを成功させてから意図的に失敗する」は最も価値の低い中間案です。

P2 — caller-supplied prompts の不完全入力は直っていない

build_observer_requests() は今でも、

prompt=prompts.get(spec.observer_id, "")

です。したがって --prompts-file 自体は存在していても、observer key が1個欠けている、あるいは値が "" なら、今回問題にした空 prompt がそのまま再発します。

コメントではこれを「defensive only」としていますが、実際には defensive ではありません。invalid caller input を外部 CLI の遅いエラーへ変換しているだけです。

ここは harness ではなく単純な入力 validation にした方がよいです。expected manifest 全件について str かつ strip() 後 non-empty を確認し、不足なら invalid_observer_prompts のような typed local failure を即返すだけで十分です。

P2 — 今回の分岐そのものを固定する hermetic test がない

PR の変更ファイルは production script と live verifier の2ファイルだけで、test_run_retrospective.py には regression test を追加していません。

PR 本文では 135 tests / 全体432 tests の PASS が提示されていますが、新しく導入した default prompt 分岐の correctness をそれらが直接保証しているわけではありません。

ここは大きな harness は不要です。fake runner を使った小さい unit test で、「省略時の全 observer prompt が non-empty」「actual run identity が入る」「partial prompts は local reject」の3点程度を固定すれば十分です。

P3 — 「empty prompt rejection regression」という整理は修正した方がいい

現行の公式 Claude Code CLI reference は claude -p "query" を non-interactive query として示し、programmatic usage も「-p with your prompt」と説明しています。stdin からの入力も正式にサポートされています。成功は exit 0、失敗は non-zero です。 (Claude)

したがって、input="" を渡して

Input must be provided either through stdin or as a prompt argument

になること自体を「Claude Code 側 regression」と断定するのは適切ではありません。このケースは caller が入力契約を満たしていないと解釈する方が自然です。

なお Claude Code には、pipe がまだ open なのに3秒で stdin を諦めて同じエラーになる upstream bug report #60998 など、実際に同型メッセージを出す不具合は存在します。しかしそれは「空文字列を明示的に渡した」今回とは別問題です。 (GitHub)

なので docstring は「Claude Code regression」ではなく、例えば empty-prompt invocation contract mismatch 程度にした方が将来の version lore を減らせます。

推奨する修正形

最も小さく、かつ実用性が高いのは placeholder 方式を撤回することです。

prepare() 後に actual ctx/plan から default prompt を生成し、no-evidence smoke でも全3 observers と evaluator を最後まで通す。そのうえで verify_agent_retrospective_live_smoke.py は、このケースについては observer_run_id_mismatch を成功扱いせず、PublishRequest 到達を成功条件にするのがよいです。caller-supplied prompts は manifest completeness/non-empty をローカル validation します。

これなら長大な placeholder の説明、4個の fake constant、意図的 mismatch の allowlist 理由の大半も不要になります。ハーネスを増やさず、production path 自体を単純にする修正です。

なお現在の head e3b8ae14... は draft / mergeable で、既存 impl-review-loop は blockers なしの APPROVE、required checks 5/5 green と報告しています。そこは確認できていますが、今回の指摘はテスト失敗ではなく、その green が「最初の observer で意図的に failure すること」を成功条件にして成立しているという意味論の問題です。

Recommended disposition: fix_delta ではなく小規模な reframe_in_place。 #2345 の「observer_run_id_mismatch でも AC1 達成」というゴール自体を、「meaningful non-empty input で full path が成立する」に一段引き上げるのが適切です。

## 結論

判定: REQUEST_CHANGES
PR #2347 は Issue #2345 の狭い AC1/AC2 自体には適合しています。しかし、品質・有用性を優先するなら、この状態ではマージを勧めません。

最大の問題は、live smoke を実際に通るように直したのではなく、「モデル呼び出しには成功するが、その直後に必ず observer_run_id_mismatch で失敗する入力」を作り、その既知 failure を verifier が exit 0 にすることで green にしている点です。PR 本文も、最初の observer で abort するため「実際に非空 prompt が必要なのは第一 observer のみ」と明記しています。つまりこれは end-to-end smoke の修復ではありません。

優先度 Finding 判定
P1 placeholder identity を故意に返させ、最初の observer で必ず mismatch → verifier は exit 0 blocker
P1 --prompts-file 省略時に、成功不能と分かっている Claude 呼び出しへ課金・待ち時間を使う blocker / workflow阻害
P2 --prompts-file を渡しても missing key / empty string なら元の空 prompt 問題が残る fix推奨
P2 新しい production 分岐に hermetic regression test が追加されていない fix推奨
P3 「Claude Code の empty-prompt regression」という説明は技術的に強すぎる docs修正

P1 — smoke が「production を故意に失敗させることで PASS」している

今回追加された _default_observer_prompt() は、run_id、base_sha、source_set_digest に実値ではなく固定 placeholderを入れ、agent にそれを verbatim で返させます。

一方、production の run_cli() はその後で run_id を生成し、prepare() で実際の ctx / SourcePlan を確定してから observer wave に入ります。observer の結果は最初に bundle.run_id != ctx.run_id を検査されるので、今回の default prompt は設計上必ずここで死にます。その先の finding fan-in、残りの observers、evaluator、delta、PublishRequest は実行されません。

しかも retrospective-runtime-observer 自身の入力契約は、呼び出し元から実際の run_id / base_sha / source_set_digest と runtime evidence を受け、それらを出力へ反映することです。今回の placeholder default は、この agent contract を smoke 専用に意図的に破っています。

さらに verifier は、observer_run_id_mismatch を受けると receipt 自体の status は "fail" にしながら、最後にはそれを「legitimate expected completion」として process exit 0 にします。

これは特に #2239 の目的と相性が悪いです。#2239 AC6 は live smoke で run_id / base_sha / source_set_digest の binding、prompt nonce binding、実 invocation などを検証する設計でした。現在はその full-path のかなり手前で故意に終了しています。

修正方針は、placeholder をもっと巧妙にすることではありません。 run_cli() の prepare() 完了後、実 ctx.run_id / ctx.base_sha / plan.source_set_digest が分かった時点で default observer prompt を組み立てるべきです。これなら live smoke は全 observer → evaluator → PublishRequest まで実際に到達できます。

概念的には、

ctx, plan, results = prepare(...)

if prompts is None:
    prompts = build_default_prompts(
        ctx=ctx,
        plan=plan,
        results=results,
    )

observer_requests = build_observer_requests(..., prompts=prompts)

程度の構造で十分です。専用 harness を増やす必要はありません。

P1 — 「省略時 default」がユーザー体験として悪化している

SKILL.md の通常 production 手順では、そもそも root Skill が --prompts-file を渡す契約です。

従来、これを省略すると空入力なので Claude CLI が早期に失敗しました。今回の変更後は、Claude を実際に1回呼び、structured output を生成させ、その結果を application 側で故意に reject するようになります。

個人開発用途ではこれは特に割に合いません。失敗結果を得るためにモデル latency と利用量を消費しています。

選択肢は明確です。

省略を production でサポートしたいなら、上記の実 identity を使った functional default にする。サポートしないなら --prompts-file を必須化してローカルで即座に明確なエラーを返す。

「外部 Claude 呼び出しを成功させてから意図的に失敗する」は最も価値の低い中間案です。

P2 — caller-supplied prompts の不完全入力は直っていない

build_observer_requests() は今でも、

prompt=prompts.get(spec.observer_id, "")

です。したがって --prompts-file 自体は存在していても、observer key が1個欠けている、あるいは値が "" なら、今回問題にした空 prompt がそのまま再発します。

コメントではこれを「defensive only」としていますが、実際には defensive ではありません。invalid caller input を外部 CLI の遅いエラーへ変換しているだけです。

ここは harness ではなく単純な入力 validation にした方がよいです。expected manifest 全件について str かつ strip() 後 non-empty を確認し、不足なら invalid_observer_prompts のような typed local failure を即返すだけで十分です。

P2 — 今回の分岐そのものを固定する hermetic test がない

PR の変更ファイルは production script と live verifier の2ファイルだけで、test_run_retrospective.py には regression test を追加していません。

PR 本文では 135 tests / 全体432 tests の PASS が提示されていますが、新しく導入した default prompt 分岐の correctness をそれらが直接保証しているわけではありません。

ここは大きな harness は不要です。fake runner を使った小さい unit test で、「省略時の全 observer prompt が non-empty」「actual run identity が入る」「partial prompts は local reject」の3点程度を固定すれば十分です。

P3 — 「empty prompt rejection regression」という整理は修正した方がいい

現行の公式 Claude Code CLI reference は claude -p "query" を non-interactive query として示し、programmatic usage も「-p with your prompt」と説明しています。stdin からの入力も正式にサポートされています。成功は exit 0、失敗は non-zero です。 (Claude)

したがって、input="" を渡して

Input must be provided either through stdin or as a prompt argument

になること自体を「Claude Code 側 regression」と断定するのは適切ではありません。このケースは caller が入力契約を満たしていないと解釈する方が自然です。

なお Claude Code には、pipe がまだ open なのに3秒で stdin を諦めて同じエラーになる upstream bug report #60998 など、実際に同型メッセージを出す不具合は存在します。しかしそれは「空文字列を明示的に渡した」今回とは別問題です。 ([GitHub]2)

なので docstring は「Claude Code regression」ではなく、例えば empty-prompt invocation contract mismatch 程度にした方が将来の version lore を減らせます。

推奨する修正形

最も小さく、かつ実用性が高いのは placeholder 方式を撤回することです。

prepare() 後に actual ctx/plan から default prompt を生成し、no-evidence smoke でも全3 observers と evaluator を最後まで通す。そのうえで verify_agent_retrospective_live_smoke.py は、このケースについては observer_run_id_mismatch を成功扱いせず、PublishRequest 到達を成功条件にするのがよいです。caller-supplied prompts は manifest completeness/non-empty をローカル validation します。

これなら長大な placeholder の説明、4個の fake constant、意図的 mismatch の allowlist 理由の大半も不要になります。ハーネスを増やさず、production path 自体を単純にする修正です。

なお現在の head e3b8ae14... は draft / mergeable で、既存 impl-review-loop は blockers なしの APPROVE、required checks 5/5 green と報告しています。そこは確認できていますが、今回の指摘はテスト失敗ではなく、その green が「最初の observer で意図的に failure すること」を成功条件にして成立しているという意味論の問題です。

Recommended disposition: fix_delta ではなく小規模な reframe_in_place。 #2345 の「observer_run_id_mismatch でも AC1 達成」というゴール自体を、「meaningful non-empty input で full path が成立する」に一段引き上げるのが適切です。

…設計から REAL identity 設計へ修正する (#2345)

OWNER review #2347 (comment)
への fix_delta 対応。

- `_default_observer_prompt()` を固定 placeholder identity(`run_id`
  が実際の `ctx.run_id` と絶対に一致しない construct-to-fail 設計)から、
  `run_cli()` 自身の `prepare()` が生成した REAL `ctx.run_id`/
  `ctx.base_sha`/`plan.source_set_digest` を使う設計へ変更した。
  `run_cli()` は `prepare()` 完了後にこの実 identity を用いてデフォルト
  prompt を構築する(`prompts=None` の場合のみ)。
- `build_observer_requests()` に local 入力検証を追加し、
  `EXPECTED_OBSERVER_MANIFEST` の各 observer_id に対応する非空
  (`strip()` 後)prompt が無い場合は `WireContractError`
  (`reason_code="invalid_observer_prompts"`) で fail-closed する
  (旧来の `prompts.get(id, "")` サイレント fallback を廃止)。
- 「Claude Code CLI regression」と誤解を招きうる記述を「空 prompt
  invocation contract mismatch」という正確な表現へ整理した。
- `verify_agent_retrospective_live_smoke.py` のドキュメント/コメントを、
  `--prompts-file` 省略時のデフォルト経路が今や実 identity を反映し
  genuine な `PublishRequest` 完走(`status: "pass"`)を主要な期待結果
  とすること、`observer_run_id_mismatch` は防御的にのみ allowlist に
  残ることを反映して更新した。
- `test_run_retrospective.py` に hermetic regression test を追加
  (observer prompt が非空かつ実 identity を反映すること、不完全な
  `prompts` dict がローカルで fail-closed 拒否されること)。既存の
  `run_cli(prompts={})` 呼び出しは新設計に合わせ `prompts=None` へ
  更新した。

live 実測(claude_code プロファイル、2 回連続): 修正後は 3 observer
全数が実 identity を正しく echo し observer wave が genuine に成功、
評価フェーズまで到達するようになった。ただし evaluator
(`retrospective-evaluator`)が `candidate_records: []` の際に
markdown fence + 散文混入の応答を返し `missing_structured_output` で
停止する、本 Issue のスコープ外・pre-existing の別ギャップが新たに
露呈したため、follow-up Issue #2354 を起票した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

fix_delta 対応完了(OWNER review https://github.com/squne121/loop-protocol/pull/2347#issuecomment-5417901341): commit 3d781b3。

  • P1 items 1-2: _default_observer_prompt() を construct-to-fail な固定 placeholder identity から、run_cli() 自身の prepare() 完了後の REAL ctx.run_id/ctx.base_sha/plan.source_set_digest を使う設計へ修正。
  • P2 item 3: build_observer_requests() に local 入力検証を追加し、不完全な prompts を WireContractError(reason_code="invalid_observer_prompts") で fail-closed。
  • P2 item 4: hermetic regression test 2 件を test_run_retrospective.py に追加(Allowed Paths Scope Delta、詳細は PR 本文参照)。
  • P3 item 5: 「CLI regression」表現を「空 prompt invocation contract mismatch」へ是正。

live 実測(2 回連続、claude 2.1.246): 3 observer 全数が REAL identity を正しく echo し observer wave が genuine に完走、評価フェーズへ到達(本 verifier 史上初)。ただし evaluator が candidate_records: [] の際に markdown fence + 散文混入の応答を返し missing_structured_output で停止する、Issue #2345 スコープ外の pre-existing gap が新たに露呈したため、follow-up Issue #2354 を起票した: #2354

詳細は PR 本文の「動作検証証跡」「既知の未解決事項」を参照。

@squne121

Copy link
Copy Markdown
Owner Author

impl-review-loop 状態報告(fix_delta 後、独立検証済み)

OWNER REQUEST_CHANGES(https://github.com/squne121/loop-protocol/pull/2347#issuecomment-5417901341)への fix_delta(commit 3d781b3f)を独立 test-runner で再検証しました。

確認できたこと(P1/P2/P3 対応は正しく機能)

  • _default_observer_prompt() は実際に REAL run_id/base_sha/source_set_digest を使用しており、固定 placeholder ではないことをソース・新規 hermetic test 双方で確認(construct-to-fail 設計は解消)。
  • build_observer_requests() の不完全 prompts local fail-closed 検証も新規 hermetic test で確認。
  • nonzero_exit は依然 allowlist 外のまま(AC2 PASS)。
  • pytest 434 passed / 0 failed(新規2件含む)。

未解決(AC1 は現在 FAIL)

実 Claude CLI(2.1.246)での AC1 実行は exit 1 / reason_code: missing_structured_output でした。これは observer wave 側(#2345 のスコープ)ではなく、evaluator(retrospective-evaluator)が空 finding_sets の際に JSON を markdown fence + 散文で返す、#2345 とは別の pre-existing gap(新規発見、follow-up Issue #2354 として分離起票済み: https://github.com/squne121/loop-protocol/issues/2354)が原因です。`missing_structured_output` は verifier の allowlist 対象外のため、正しく fail-closed しています(fake pass にしていません)。

結論

#2345 の AC1(文言通りの observer_run_id_mismatch または status: pass への到達)は、#2354 が解決されるまで達成できません。#2345 の Allowed Paths 内で追加のループ反復を重ねても解決しないため、本ループはここで一旦停止します。

次アクションは人間判断: (a) #2354 を先に解決してから #2345 を再検証する、または (b) OWNER が #2345 の AC1 到達条件自体を(observer wave の genuine 完走をもって十分とする形へ)reframe するかを選択してください。

@squne121
squne121 marked this pull request as ready for review August 26, 2026 10:59
@squne121
squne121 merged commit 151d8d7 into main Aug 26, 2026
36 of 42 checks passed
@squne121
squne121 deleted the worktree-issue-2345-claude-live-smoke-fix branch August 26, 2026 17:01
@squne121

Copy link
Copy Markdown
Owner Author

AC1 達成確認(#2354 close 後の再検証、human judgment 実行)

前回のブロッカーだった missing_structured_output(Issue #2354、_structured_output_from_result_compat() の fence-prose 抽出不備)は #2348 / PR #2353 で解消し、main へマージ済みです(merge commit 39ae89b7)。本 PR は既に main 追従済み(head 4bbdf1e7)で _default_observer_prompt()(本 PR)と _structured_output_from_result_compat()(#2353)の双方を含みます。

この head (4bbdf1e7) で verify_agent_retrospective_live_smoke.py --runtime-profile claude_code --repo-root . を2回実行し、いずれも次を確認しました。

  • schema: AGENT_RETROSPECTIVE_LIVE_SMOKE_RESULT_V1
  • status: pass(reason_code フィールドなし = observer_run_id_mismatch allowlist 経由ではなく、evaluator まで実到達した genuine full-path 成功。inner_result.schema_version: publish_request/v1 で run_identity の request_id/base_sha/run_id/source_set_digest 一致を確認)
  • tested_head: 4bbdf1e776bbe25d0b44d145911052ceda1537ca
  • repository_fingerprint_diff_clean: true / forbidden_mutation_tool_events: 0

AC1(observer_run_id_mismatch または status: pass への到達)は status: pass の形で達成されました。他 AC は前回の独立検証コメント(pytest 434 passed 等)で既に確認済みです。

CI は現 head で全 green(ci-verdict-summary SUCCESS)、mergeable、unresolved review thread なし。Issue #2354 は duplicate / superseded として close 済みです: #2354

以上により本 PR は merge-ready と判断します。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: claude -p の空文字列 prompt 拒否 regression に対する agent-retrospective live smoke 検知経路の修正

1 participant