Repository navigation
fix: 完了済み structured runtime-smoke の post-session statusLine を not_applicable として扱う - #2749
Conversation
…plicable として扱う (#2747) orchestrate_runtime_smoke() が collect_statusline_evidence() から "executed_degenerate" を受け取った場合に限り、これを not_applicable として 再解釈し、単独では aggregate result.status を fail にしないようにした。 "failed"/"skipped" は引き続き violations に含め fail にする既存の fail-closed 挙動を維持する。collect_statusline_evidence() 自体の leaf semantics は変更していない。 あわせて test_runtime_smoke_verifier_live_shadow_isolation.py に残っていた PR #2745 由来の _KNOWN_STATUSLINE_TIMING_LIMITATION 特例を撤去し、通常の result.status == "pass" を oracle とする形に書き換えた。回帰テストを test_runtime_smoke_verifier.py に追加した (executed_degenerate → not_applicable、failed/skipped → 引き続き fail、 executed → 既存 semantics 不変、runner failure が not_applicable に マスクされないことの確認)。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2749/ The preview will be removed when this PR is closed. |
|
現状の PR #2749 は、マージ前に修正した方がよいです。レビュー判定なら PR #2749 と Issue #2747、起点の PR #2745、PR #2708、Task Context実装を追いました。
優先度 | Finding | 影響
-- | -- | --
P1 / blocker | executed_degenerate を一括 not_applicable にしており、本物の Degraded 障害までPASSへ丸める | DB/query/transport破損をruntime smokeが見逃せる
P1 / blocker | 「session終了後だからUnboundになる」という因果説明がリポジトリ実装と一致せず、live test自身が最初からTask未bindのsessionを作っている | タイミング問題を直したように見えて、実際は不適切なtest scenarioを無効化している可能性が高い
P3 | live証跡の報告先がIssue契約では「PR comment」なのに、現在PR conversationにはpreview botしかない | 品質には直接影響なし。個人開発なら非blocker
P1-1: |
| 優先度 | Finding | 影響 |
|---|---|---|
| P1 / blocker | executed_degenerate を一括 not_applicable にしており、本物の Degraded 障害までPASSへ丸める |
DB/query/transport破損をruntime smokeが見逃せる |
| P1 / blocker | 「session終了後だからUnboundになる」という因果説明がリポジトリ実装と一致せず、live test自身が最初からTask未bindのsessionを作っている | タイミング問題を直したように見えて、実際は不適切なtest scenarioを無効化している可能性が高い |
| P3 | live証跡の報告先がIssue契約では「PR comment」なのに、現在PR conversationにはpreview botしかない | 品質には直接影響なし。個人開発なら非blocker |
P1-1: Degraded まで not_applicable に落ちる
ここが最も明確なバグです。
_DEGENERATE_STATUSLINE_RENDERS = frozenset({"Unbound", "Degraded", ""})としており、3種類すべてを executed_degenerate に畳み込んでいます。そのうえPR #2749は、
if statusline_evidence["status"] == "executed_degenerate":
statusline_evidence["status"] = "not_applicable"相当の処理をしています。
Unbound= binding/task が無い正常系の可能性Degraded= genuine DB/query failure- transport/query failureでも
"Degraded"をprintして exit 0
と定義しています。
つまりこの実行系列が成立します。
statusLine query故障 → "Degraded", rc=0 → executed_degenerate → not_applicable → aggregate PASS
これは #2747 の「genuine regression と timing limitation を診断上区別する」という設計意図と衝突します。新しいunit testも主に rendered="Unbound" を使ったaggregate変換の検証で、Degraded を絶対にPASSへ昇格させない否定ケースを持っていません。
最低限のfixは、executed_degenerate だけを判定材料にせず、少なくとも rendered == "Unbound" の場合だけN/A候補とし、"Degraded" と "" は従来どおりfailureに残すことです。
P1-2: そもそも今回の Unbound は「post-session timing」が原因とは考えにくい
PRのコメントには、
runner終了 → SessionEnd済み → Binding SUSPENDED → post-session statusLineはdegenerate
という説明があります。
しかしTask Context実装は逆です。on_session_start() のコメントにもある通り、SessionEndでも current_claude_session_id はclearされず、runtime_health だけSUSPENDEDになります。さらにstatusLine queryのbinding検索はSUSPENDEDを除外していません。
Taskが正しく結び付いていれば、SUSPENDED後も例えば
#2747 · native · health=SUSPENDED
のようにレンダリング可能な設計です。したがって 「SUSPENDEDになったからUnbound」はコード上成立しません。
もっと決定的なのがlive testです。[test_runtime_smoke_verifier_live_shadow_isolation.py](https://github.com/squne121/loop-protocol/blob/bc402fb9ac6c8a0f05b9ba5fd93dbbfff4a5e951/tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py) は実Claudeに、
Respond with exactly this single line... Do not use any tool.
というGitHub targetを含まないnonce promptを投げています。
一方、smoke seed が作るsynthetic BindingにはClaude session IDもHerdr locationも付いていません。そのため実Claudeの SessionStart はseed Bindingを復元できず、別の新規Bindingを作ります。そのExecutionRunは開始時点で task_id=None。nonce promptもtarget classificationを発生させないのでTaskへbindされません。
するとstatusLineは、sessionがまだ生きていたとしても、
task = data.get("task")
if not task:
return "Unbound"になります。
つまり現在のlive canaryは、かなり高い確度で
「終了後だからUnbound」ではなく「そのruntime sessionに最初からTaskが紐付いていないからUnbound」
を観測しています。
これはPR #2749の修正が、タイミング問題を解決するのではなく、テストシナリオの不足をN/A化してaggregateをgreenにしていることを意味します。
Claude Code公式仕様でも、status lineはインタラクティブUIの下部に表示され、session startやassistant messageなどを契機として実行される仕組みです。-p はnon-interactive print modeです。:chatgpt-content-reference{index="0"} またPythonの subprocess.run() はchild終了まで待つため、現在の呼び出し順序で「実セッション中のstatusLine」を後から観測できない点自体は正しいです。:chatgpt-content-reference{index="1"}
さらに、Claude Codeにはprint modeで正常終了時に SessionEnd が発火しないという未解決の公開報告もあり、-p の終了 lifecycle を「必ずSessionEnd済み」と前提化するのも避けた方がよいです。これは公式契約ではなくbug reportなので補助証拠ですが、今回の因果説明を固定しない理由にはなります。:chatgpt-content-reference{index="2"}
推奨修正
- まずPR #2749では
Degraded/空文字をN/A化しない。Unboundだけを限定的に扱う回帰テストを追加し、Degraded → aggregate failを必須テストにします。 - #2747の原因説明を修正する。 「SessionEnd/SUSPENDEDなのでUnbound」ではなく、「structured
-p完了後のout-of-band statusLine probeはlive statusLine verificationではない」と定義する方が正確です。 - 本質的には、structured laneではstatusLineをverification対象から外し、
not_applicableをlane semanticsから決めるのが最も単純です。statusLine実動作は、元の 実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568 が既に定義していた通りinteractive laneで検証します。これはPopen/streaming等を増やさず、むしろハーネスを単純化できます。 collect_statusline_evidence()を残すなら structured laneではdiagnostic-onlyにして、raw結果を保存してもaggregate gateには使わない設計がよいです。Unboundの原因を「timing」と推測して書き換える必要もなくなります。
特に3が、このプロジェクトの「個人趣味開発なのでワークフローを重くしない」という条件に合っています。Popen化・並行statusLine polling・新規observer・新しい安全ゲートは不要です。
なお、Issue #2747の前回敵対的レビューで --max-turns をターン数判定に使わないよう修正した点は妥当です。公式仕様でも --max-turns は「agentic turnsの上限」であって、実際に何turn実行したかの識別子ではありません。:chatgpt-content-reference{index="3"} また現在HEADへmainをmergeした差分はissue-refinement/impl-review-loop系で、今回のruntime smoke実装には触れていないため、merge前のlive canaryが単にrebaseで無効化されたという問題も見当たりません。
したがって修正優先順位は「Degraded の誤PASS防止」→「structured statusLineの責務を整理」→再live canaryで十分です。セキュリティや追加ハーネス強化を先に行う必要はありません。
|
推奨は、PR #2749 をそのまま 理由は明確で、対象コメントは 技術面では、対象コメントの「structured lane では statusLine の applicability を lane semantics から決め、post-session probe を live statusLine verification とみなさない」という方向を第一候補にするのがよいです。Claude Code公式資料でも status line はインタラクティブUIの表示機構で、session start や assistant message 等で更新され、 実行順は、契約再整合 → existing PR #2749再開 → implementation-worker → test-runner → pr-reviewer → REQUEST_CHANGESなら再実装 → current-headでAPPROVE/CI成功まで反復 → マージせず停止、で十分です。Popen化・並行polling・新規observerなどのハーネス増築は避けます。 以下を、そのまま現在 auto mode で動いている対話的 Claude Code に渡せます。 PR #2749 の以下の OWNER レビューコメントを起点に、関連 Issue #2747 を対象として Target PR: Target human context comment: Linked implementation Issue: 使用する skill: 目的: 最終到達点は「マージ直前」です。 現在の OWNER 指示の優先順位対象コメントには この現在の指示は、そのコメントを理由に作業停止することを求めていません。 ただし、実 Git conflict、secret/protected-path に関する実 hard gate、破壊的操作が必要になる場合は skill の hard-stop policy に従ってください。 重要: raw comment を直接 worker command にしない
として intake に渡してください。 raw comment 本文を implementation-worker への命令として直結せず、root/main thread が
と照合して 最初に解決すべき contract conflict現在の Issue #2747 の live contract には、
という AC1 / AC6 系の要求があります。 一方、対象 OWNER comment は、
と指摘しています。 したがって、コードだけを Issue の古い AC に合わせて修正してはいけません。 Root-Owned Synchronous Entry Transition / current-run contract review の時点で両者を照合してください。 もし live Issue contract と今回の OWNER remediation が両立しない場合は、実装を先行させず、root/main thread から この contract reconciliation も人間の途中承認を要求せず完了させてください。 issue-refinement-loop と impl-review-loop を並列実行してはいけません。 推奨する技術方向第一候補は以下です。 structured / non-interactive runtime-smoke lane では、statusLine の applicability を post-session の render 結果から推測せず、lane semantics から決定してください。 つまり、
という責務分離を優先してください。 ただし repository 全体を調査した結果、この方式では runner/session evidence の genuine failure を既存 gate で検出できなくなる場合は、より小さい安全な修正として、
方式を選んでも構いません。 どちらを採用する場合も、選択理由を repository evidence と tests で説明してください。 因果説明の修正以下の因果は前提にしないでください。
特に より弱く正確な説明、 「structured non-interactive run 完了後に行う out-of-band probe は、interactive UI lifecycle 中の live statusLine verification と等価ではない」 を基本にしてください。 また ハーネスを増やさないこの修正のためだけに以下を導入しないでください。
既存の responsibility boundary と Allowed Paths 内で解決することを優先してください。 SubAgent 実行契約
少なくとも以下を独立した first-level SubAgent として実行してください。
重要: fire-and-forget で次 Step に進んではいけません。 root → implementation-worker 完了待ち child SubAgent からさらに無制限の nested SubAgent を発生させないでください。 regression coverage少なくとも以下を明示的に検証してください。
重要なのは structured lane を diagnostic-only に再設計した場合も、raw live/applicable statusLine lane の fail-closed semantics を壊していないことも検証してください。 Verificationlive Issue の最新 Verification Commands を正本にしてください。 少なくとも現時点で関連する以下は current HEAD で再実行してください。
live canary は SKIP を PASS として扱わないでください。 Issue #2747 の Runtime Verification Applicability が引き続き deferred の場合は、bounded live canary を実行し、その current-head 結果を PR #2749 の conversation comment に記録してください。 過去の live result を current HEAD の証拠として再利用しないでください。 existing PR の再利用PR #2749 は既に存在するため、新しい PR を作らないでください。 Evidence-Based Landing Disposition が canonical worktree / branch / current HEAD を live に再取得し、stale な main drift があれば skill の update-branch / scope-clean reconciliation route に従って解消し、その後 verification と review を current HEAD でやり直してください。 review looppr-reviewer が
これを SubAgent の単なる 完了条件以下がすべて成立するまで「完了」としないでください。
ここまで到達したら PR はマージしないでください。 最終報告最後に簡潔に以下を報告してください。
途中経過の人間承認は求めず、上記の hard stop が発生しない限り自律的に最後まで進めてください。 この形なら、対象コメントを単に worker に貼り付けるのではなく、リポジトリ側が既に用意している |
OWNER レビュー指摘(PR #2749 comment)により、collect_statusline_evidence() が "executed_degenerate" を返した際、rendered の内訳(Unbound/Degraded/空文字)を 区別せず一律 not_applicable にしていた問題を修正する。 .claude/hooks/task_context/statusline.py の "Degraded" は exit code 0 で表現される genuine な DB/query/transport failure であり、これを not_applicable に丸め込むと 本物の障害を見逃す。rendered=="Unbound" の場合のみ not_applicable への再解釈を行い、 "Degraded"/空文字は既存の fail-closed 分岐(violations 追加)へフォールスルーする。 回帰テストとして rendered in ["Degraded", ""] のケースで aggregate status が "fail" のまま維持されることを検証する parametrize テストを追加する。 Refs: #2747 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Runtime Verification 実行結果(review iteration 2, current HEAD 再実行)pr-reviewer の REQUEST_CHANGES(blocker 1)に基づき、core ロジック変更を含む 現在の HEAD
pytest 出力サマリ判定PASS(SKIP ではなく実行・完走した上での PASS)。 これにより Issue #2747 の 参考: 他の Verification Commands(同 HEAD で再実行) |
|
結論として、今はまだマージしない方がよいです。実装上の重大な問題はほぼ解消されていますが、 確認結果は以下です。
ただし、最後の live verification / review 対象は それでも、このリポジトリの
という契約になっています。また VC の current-head gate も 加えて、PR #2749 は現在 Draft のままです。 したがって次の1ステップだけ通すのが適切です。 PR #2749 を現HEAD つまり、**「コードとしてはマージ候補まで来ているが、プロジェクト自身の current-head gate 上はあと1回レビューが必要」**という状態です。 [PR #2749](#2749) / [Issue #2747](#2747) |
|
確認した限り、推奨は PR #2749 を新規実装せず、既存 PR の current HEAD で 再発防止については、#2102 の既存 そのまま Claude Code に投入するプロンプトです。 PR #2749 を対象に、 対象:
実行方針:
人間に途中承認を求めず、auto mode の範囲で canonical skill に従って可能な限り自律完走してください。 今回のポイントは、修正を前提に Step 1 からやり直すのではなく、まず current-head verification → current-head review を成立させることです。そこで新しい blocker が出た場合だけ実装修正へ戻すのが最短です。 |
impl-review-loop: current-head PR review 結果
verdict: APPROVE
reviewed_head_sha: "9ce36ee8a28227fac9035b402489321e88695ada"
blockers: []
warnings:
- "PR body IMPLEMENTATION_SCOPE_COVERAGE_V1 self-report metadata still cites stale pr_head_sha 5457a88a5beaf610d213786a2a381c0fd8c43ff1 instead of current head 9ce36ee8a28227fac9035b402489321e88695ada (advisory only, non-blocking)" |
Summary
orchestrate_runtime_smoke()が完了済み structured runtime-smoke session の post-session statusLine observation でcollect_statusline_evidence()から"executed_degenerate"を受け取った場合に限り、これをnot_applicableとして再解釈し、単独では aggregateresult.statusを"fail"にしないよう修正した("failed"/"skipped"は引き続き violations に含め fail のまま)。test_runtime_smoke_verifier_live_shadow_isolation.pyに残っていた PR 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2745 由来の_KNOWN_STATUSLINE_TIMING_LIMITATION特例を撤去し、通常のresult.status == "pass"を oracle とする形に書き換えた。test_runtime_smoke_verifier.pyに追加した(executed_degenerate→not_applicable、failed/skipped→ 引き続き fail、executed→ 既存 semantics 不変、runner failure が not_applicable にマスクされないことの確認)。Checks
uv run pytest tests/task-context/test_runtime_smoke_verifier.py -vuv run pytest tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py -vuv run pytest tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py -v -m claude_live(実 claude CLI 環境で実行、詳細は「Runtime Verification 実行結果」参照)rg -n "max_turns" scripts/task-context/task_context_runtime_smoke_verifier.py(既存記述以外の新規ターン数依存ロジックなし)pnpm typecheck/pnpm lint/pnpm test/pnpm build(フロントエンド TS/JS 対象)は対象外。上記のローカル検証コマンドをすべて実行し成功を確認した。Schema Change Applicability
not_schema_changecollect_statusline_evidence()/RuntimeSmokeOrchestrationResultは固定 Enum/Literal/TypedDict を持たない genericdict[str, Any]として実装されており、not_applicable値の追加は既存の producer-consumer 境界を越えた fixed contract の変更ではない(Issue 実装: orchestrate_runtime_smoke() の completed structured runtime-smoke で post-session statusLine observation を not_applicable として扱う #2747 本文のissue-refinement-loopcodebase-investigator 事前調査で確認済み)。Schema Consumer Inventory
N/A(
not_schema_changeのため)。Compatibility Decision(互換性判定)
N/AN/AN/AN/AVisual Impact Declaration(視覚影響申告)
UI(DOM/CSS)変更を含まないため省略。
Safety Claim Matrix
N/A — reason: 本 PR は Task Context runtime-smoke verifier 内部の evidence 解釈ロジックのみを変更し、安全境界・権限・サンドボックス・transport・auth・MCP・native tools・approvalMode・runtime verification gate 自体(
collect_statusline_evidence()の leaf fail-closed 判定ロジック)には触れていない。Runtime Verification 実行結果
Issue #2747 の
Runtime Verification Applicability: deferred(collect_statusline_evidence()が"executed_degenerate"を返す決定論的な再現は実 claude CLI 環境の起動を要するため、本 PR で live 実行結果を報告する契約)に基づき、実 claude CLI 環境(claude 2.1.282)で live canary を実行した。uv run pytest tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py -v -m claude_live(.claude/worktrees/issue-2747-statusline-not-applicableworktree 内で実行。generic runner の root-checkout guard により canonical repository root からは実行不可)1 passed(result.status == "pass"、result.violations == [])。deferred_verification_condition(本 PR が実 claude CLI 環境で completed structured runtime-smoke を1回以上実行し、post-session statusLine observation だけを理由にresult.statusが"fail"にならないこと、かつ live test が既知 limitation 特例なしでresult.status == "pass"を確認できること)を満たした。artifacts/、.gitignore対象のため本 PR には含めない):artifacts/runtime-verification-AC2-20260925T053257Z.logrunner_returncode: 0canonical_delta.status: "pass"execution_runs_delta.addedに期待通り 1 件の roll-up のみresult_status: "pass"/result_violations: []Notes
scripts/task-context/task_context_runtime_smoke_verifier.pyのorchestrate_runtime_smoke()内、statusLine evidence 解釈ロジックのみに限定。collect_statusline_evidence()自体の leaf 判定ロジック、invoke_generic_runner()の subprocess 呼び出し方式、RuntimeSmokeOrchestrationResult.statusトップレベル schema はいずれも変更していない。implement-issueskill 手順)による実装。Acceptance Criteria 対応状況
not_applicableへの再解釈はcollect_statusline_evidence()が"executed_degenerate"を返し、かつrendered == "Unbound"の場合に限る。renderedが"Degraded"または空文字("")の場合、あるいは"failed"/"skipped"の場合は引き続きviolationsに含め aggregatestatusを"fail"にする。実装済み・tests/task-context/test_runtime_smoke_verifier.py::test_given_completed_structured_session_when_statusline_executed_degenerate_then_reinterpreted_not_applicable(Unbound → not_applicable、PASS)および::test_given_completed_structured_session_when_statusline_executed_degenerate_not_unbound_then_still_fails_aggregate[Degraded]/[...](renderedが"Degraded"/""の場合は not_applicable へ昇格せず fail のまま、PASS)で検証。collect_statusline_evidence()自体のexecuted/executed_degenerate/failed/skippedの既存 fail-closed semantics は変更していない。実装済み・test_given_completed_structured_session_when_statusline_failed_or_skipped_then_still_fails_aggregate[failed]/[skipped]、test_given_completed_structured_session_when_statusline_executed_then_unchanged_pass_semanticsで検証(いずれも PASS)。not_applicableでも aggregatestatusは必ず"fail"のまま。実装済み・test_given_runner_failure_and_statusline_not_applicable_when_orchestrated_then_aggregate_still_failsで検証(PASS)。tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.pyの_KNOWN_STATUSLINE_TIMING_LIMITATION特例を撤去し、通常条件でresult.status == "pass"を確認する形に書き換え済み。review iteration 2 で current HEAD5457a88a5beaf610d213786a2a381c0fd8c43ff1に対して live canary を再実行し1 passed(result_status: "pass",result_violations: [])を確認した(詳細は下記「検証コマンド結果」および PR コメント 参照)。--max-turnsの値やターン数を completed-session 判定のヒューリスティックとして使用しない。実装済み・rg -n "max_turns" scripts/task-context/task_context_runtime_smoke_verifier.pyがマッチなし(exit 1)であることを確認 — 本ファイルにmax_turns参照自体が存在せず、ターン数依存の判定ロジックが導入されていないことを示す。rendered == "Unbound"である限り挙動差が生じない。この区別はターン数ではなくrendered値のみに基づく。実装済み・AC1 と同一のtest_given_completed_structured_session_when_statusline_executed_degenerate_then_reinterpreted_not_applicable/test_given_completed_structured_session_when_statusline_executed_degenerate_not_unbound_then_still_fails_aggregate[...]は turn 数を fixture に含めずrendered値のみをパラメータ化しており、判定がターン数に依存していないことを構造的に示す(PASS)。tests/task-context/test_runtime_smoke_verifier.py/tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.pyは全件 PASS を維持。test_runtime_smoke_verifier.py: 44 passed、test_runtime_smoke_verifier_canonical_carrier_regression.py: 4 passed(いずれも review iteration 2、current HEAD で再実行済み)。検証コマンド結果
review iteration 2(current HEAD
5457a88a5beaf610d213786a2a381c0fd8c43ff1)で以下を再実行した。Allowed Paths 遵守
Issue #2747 の Allowed Paths(4ファイル):
scripts/task-context/task_context_runtime_smoke_verifier.pytests/task-context/test_runtime_smoke_verifier.pytests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.pytests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py本 PR の変更ファイル(
gh pr diff 2749 --name-onlyで確認):scripts/task-context/task_context_runtime_smoke_verifier.pytests/task-context/test_runtime_smoke_verifier.pytests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py3ファイルとも Allowed Paths 内(
test_runtime_smoke_verifier_canonical_carrier_regression.pyは既存テストを regression として再実行するのみで変更なし)。Allowed Paths 外の変更なし。