Skip to content

実装: orchestrate_runtime_smoke() の completed structured runtime-smoke で post-session statusLine observation を not_applicable として扱う #2747

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "completed structured runtime-smoke で post-session statusLine observation を not_applicable として明示し、aggregate result.status の単独 fail 要因にしない"
change_kind: code

Parent Issue

none

(補足: #2744 実装中に発見された、#2568 / PR #2708 由来の既存動作に関する独立した改善。関連: #2744。#2744 自身ではこのタイミング問題自体の修正は Out of Scope)

Parent Goal Ref

  • Goal: なし(単独改善)
  • Desired Destination: なし(単独改善のため parent tracker への destination mapping は不要)

Remaining Parent Gaps

なし

Current Validated Scope

  • scripts/task-context/task_context_runtime_smoke_verifier.py の orchestrate_runtime_smoke() / collect_statusline_evidence() が返す statusline_evidence の解釈方法(aggregate RuntimeSmokeOrchestrationResult.status への反映方法)の見直しのみ

Outcome

scripts/task-context/task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke() は、invoke_generic_runner() の blocking subprocess.run() 完了後に collect_statusline_evidence() を呼ぶ現在の evidence lifecycle を維持したまま、completed non-interactive structured session(claude -p 等の structured runtime-smoke 実行が既に完了した状態)における post-session statusLine observation が collect_statusline_evidence() から "executed_degenerate" を返し、かつその根拠となる raw statusLine render(rendered フィールド)が "Unbound" である場合に限り、これを not_applicable として明示し、それ単独では RuntimeSmokeOrchestrationResult.status を "fail" にしない実装へ修正する。rendered が "Degraded" または空文字("")の場合は、collect_statusline_evidence() の戻り値が同じ "executed_degenerate" に分類されていても not_applicable へ昇格させず、引き続き violations に含め aggregate status を "fail" にする(.claude/hooks/task_context/statusline.py は "Degraded" を genuine な DB/query/transport failure として exit code 0 で返す設計であり、"Unbound"(binding/task が無い正常系)と意味論が異なるため区別する)。collect_statusline_evidence() が "failed"(statusline スクリプト自体の例外・非ゼロ終了)または "skipped"(claude_session_id が観測できない、すなわち runner の evidence 契約が壊れている可能性を示すケース)を返した場合も、not_applicable へ丸め込まず、引き続き violations に含め aggregate status を "fail" にする。collect_statusline_evidence() 自体が live/applicable statusLine observation を評価する場合の executed / executed_degenerate / failed の既存 fail-closed semantics(_DEGENERATE_STATUSLINE_RENDERS の定義を含む)は変更しない。この変更と、PR #2745 由来の tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py の既知 timing limitation 特例の撤去を含めた回帰テストが main にマージされている状態がゴールである。

因果説明の訂正: 当初の Outcome は「completed structured session では Claude session(SessionEnd を含む)が既に完了し operator Binding が SUSPENDED 状態になった時点で statusLine query が実行されるため非退化レンダリングを得られない」という因果を前提としていたが、これは scripts/task-context/task_context_hook_flows.py::_end_current_run() の実装(SessionEnd は runtime_health のみ SUSPENDED に変更し、current_claude_session_id はクリアしない)および .claude/hooks/task_context/statusline.py::render()(runtime_health != "ACTIVE" の binding も除外せず health={health} を付記してレンダリングする設計)と一致しないため撤回する。より正確な説明は「structured non-interactive run(claude -p)完了後に行う out-of-band statusLine probe は、interactive UI lifecycle 中の live statusLine verification と等価ではない。smoke seed が作る synthetic Binding には実 Claude session の claude_session_id が事前付与されていないため、実 SessionStart は seed Binding を復元できず別の新規 Binding を作る。その新規 ExecutionRun は task_id=None のまま開始され、nonce prompt も target classification を発生させないため Task へ bind されない。したがって statusline.py::render() は task = data.get("task") が偽のため "Unbound" を返す(session が終了しているから ではなく そのセッションに最初から Task が紐付いていないから)」である。

Runtime Verification Applicability

  • decision: deferred
  • reason: collect_statusline_evidence() が "executed_degenerate" を返す決定論的な再現は実 claude CLI 環境の起動を要し、CI 標準実行では検証できないため。実装 PR では pytest によるモック検証(orchestrate_runtime_smoke() の aggregate 判定ロジック)を主とし、live 環境での再現確認は本 Issue の実装 PR で defer する。
  • deferred_destination: 実装 PR のレビューコメントで live claude CLI 環境での bounded live canary 実行結果(AC4 の tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py 実行結果を含む)を報告する
  • deferred_verification_condition: 実装 PR が実 claude CLI 環境で completed structured runtime-smoke を1回以上実行し、result.status が post-session statusLine observation だけを理由に "fail" にならないこと、かつ tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py の live test が既知 limitation 特例なしで result.status == "pass" を確認できた時点

In Scope

  • orchestrate_runtime_smoke() 内で、completed structured runtime-smoke(invoke_generic_runner() の blocking 実行が既に完了した後の状態)における post-session statusLine observation を、collect_statusline_evidence() の呼び出しタイミング自体は変更せず、statusline_evidence の解釈(aggregate status への反映方法)だけを変更する。この再解釈の対象は collect_statusline_evidence() が "executed_degenerate" を返し、かつ rendered == "Unbound" の場合に限る。 rendered が "Degraded" または空文字の場合は、"executed_degenerate" に分類されていても not_applicable へ昇格させず、引き続き violations に含め aggregate status を "fail" にする(Degraded は genuine な DB/query/transport failure を表しうるため)。not_applicable として格納する evidence dict には元の status を underlying_status として、rendered はそのまま保持し、タイミング起因の既知の non-applicability と genuine な regression を診断上区別できるようにする。
  • collect_statusline_evidence() 自体が返す executed / executed_degenerate / failed / skipped の判定ロジック(leaf 関数の fail-closed semantics、_DEGENERATE_STATUSLINE_RENDERS = frozenset({"Unbound", "Degraded", ""}) の集合定義自体を含む)は変更しない。executed_degenerate を PASS 相当に読み替える設計、および orchestrate_runtime_smoke() 側で failed / skipped を not_applicable に丸め込む設計は禁止する。
  • runner failure、canonical_delta failure、その他 applicable な scenario failure が存在する場合、statusLine が not_applicable でも aggregate status が必ず "fail" のままであることを保証する。
  • tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py に残る _KNOWN_STATUSLINE_TIMING_LIMITATION(PR 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2745 由来の既知 timing limitation 許容ロジック)を撤去し、live structured run の aggregate result.status == "pass" を通常条件で検証できるようにする。
  • 上記変更に対する回帰テスト(rendered == "Unbound" の completed structured session を模したケースで result.status が statusline evidence だけを理由に "fail" にならないこと、rendered == "Degraded" および rendered == "" の completed structured session ケースでは not_applicable へ昇格せず aggregate status が "fail" のままであること、および executed / executed_degenerate / failed の既存 fail-closed semantics が変更されていないことを検証するテスト)の追加。

Out of Scope

  • 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2744 で追加された canonical entrypoint 強制・isolation 検証ロジック自体の変更。
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py(generic runner)の default behavior 変更。
  • statusLine のレンダリング仕様自体(executed / executed_degenerate の判定ロジック)の変更。
  • invoke_generic_runner() の subprocess.run() を Popen へ変更する等、runner 完了前に statusLine を評価するための concurrency 機構(stdout streaming、polling、evidence channel 拡張、generic runner protocol 拡張を含む)の導入。これは現在の evidence lifecycle と責務境界(generic runner = transport / Task Context verifier = semantics)に対して侵襲的であり、費用対効果が低いため採用しない。
  • statusLine の本当の runtime verification(interactive/live session lifecycle での検証)自体の設計・実装。これは 実装: worktree-agent-runtime-smokeにrun-scoped isolated Task Context検証を追加する #2568 の既存方針どおり interactive lane の責務のままとする。
  • RuntimeSmokeOrchestrationResult.status トップレベルの schema を pass/fail の二値から変更すること(statusLine subsystem 内部の状態区分のみを明示すれば足り、top-level schema の三値化は行わない)。

Acceptance Criteria

  • AC1: completed structured runtime-smoke(invoke_generic_runner() の blocking 実行完了後の post-session statusLine observation)で collect_statusline_evidence() が "executed_degenerate" を返し、かつ rendered == "Unbound" の場合に限り、statusline_evidence が not_applicable(元の status を underlying_status として、rendered をそのまま保持したもの)と明示され、それ単独で aggregate RuntimeSmokeOrchestrationResult.status を "fail" にしない。同じ "executed_degenerate" であっても rendered が "Degraded" または空文字の場合、あるいは collect_statusline_evidence() が "failed" または "skipped" を返した場合は not_applicable へ丸め込まず、引き続き violations に含め aggregate status を "fail" にする。
  • AC2: collect_statusline_evidence() 自体の applicable な経路における executed / executed_degenerate / failed / skipped の既存 fail-closed semantics(executed_degenerate を PASS に読み替えない挙動を含む)は変更しない。
  • AC3: runner failure、canonical_delta failure、その他 applicable な scenario failure が存在する場合、statusLine が not_applicable でも aggregate status は必ず "fail" のままである。
  • AC4: tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py に残る、PR 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2745 由来の live-shadow-isolation test の既知 timing limitation 特例(_KNOWN_STATUSLINE_TIMING_LIMITATION およびそれを許容する assert 分岐)を撤去し、live structured run で aggregate result.status == "pass" を通常条件(特例なし)で確認できる。
  • AC5: --max-turns の値やターン数を completed-session 判定のヒューリスティックとして使用しない(orchestrate_runtime_smoke() の実装が、実行された agentic turn 数や --max-turns 引数の値を参照して not_applicable 判定を行っていない)。
  • AC6: 単一ターン・複数ターンいずれの completed structured runtime-smoke でも、collect_statusline_evidence() が "executed_degenerate" を返し rendered == "Unbound" である限り statusline evidence の扱いに起因する挙動差が生じない(両ケースとも AC1 と同一の not_applicable 扱いになる)。rendered が "Degraded" または空文字の場合は単一/複数ターンいずれでも not_applicable の対象外であり、この区別は turn 数ではなく rendered 値のみに基づく(「複数ターンなら executed を返せる」という未検証の前提を新たな AC として固定しない)。
  • AC7: 既存の tests/task-context/test_runtime_smoke_verifier.py / tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py の既存テストが全件 PASS を維持する(orchestrate_runtime_smoke() の aggregate 判定ロジック変更に対する regression coverage)。

Verification Commands

# AC5
$ rg -n "max_turns" scripts/task-context/task_context_runtime_smoke_verifier.py
# AC1
# AC2
# AC3
# AC6
$ uv run pytest tests/task-context/test_runtime_smoke_verifier.py -v
# AC7
$ uv run pytest tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py -v
# AC4
# baseline-expect: deferred
$ uv run pytest tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py -v -m claude_live

上記最後の live test(test_runtime_smoke_verifier_live_shadow_isolation.py)は実 Claude CLI lifecycle に依存するため、通常 CI の無条件必須ゲートにはしない。実装 PR で明示的に1回以上のライブ実行を行い、その証跡(AC4 の result.status == "pass" 確認結果を含む)を PR コメントで報告する(Runtime Verification Applicability: deferred の deferred_destination を参照)。SKIP を PASS と同一視しない docs/dev/runtime-verification-policy.md の既存方針を維持する。

Allowed Paths

  • scripts/task-context/task_context_runtime_smoke_verifier.py
  • tests/task-context/test_runtime_smoke_verifier.py
  • tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py
  • tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • invoke_generic_runner() の subprocess.run() を Popen へ変更する、または stdout streaming / polling / evidence channel 拡張が必要と判明した場合(Out of Scope 節参照。判明した時点で実装を進めず本 Issue を止める)
  • collect_statusline_evidence() の executed / executed_degenerate / failed の既存 fail-closed 判定ロジック自体の変更が必要と判明した場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • statusLine のレンダリング仕様自体(executed / executed_degenerate の判定基準)の変更が必要と判明した場合

Required Skills

なし

Required Design References

  • scripts/task-context/task_context_runtime_smoke_verifier.py
  • docs/dev/runtime-verification-policy.md

Scope Delta(該当時のみ記載)

N/A

Notes for Reviewer

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Sep 24, 2026
  2. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    総評

    Issue #2747 が指摘している現象そのものは正しいです。現在の orchestrate_runtime_smoke() は generic runner を subprocess.run() で最後まで待ち、その後に statusLine を再実行するため、live test では executed_degenerate が発生し、aggregate result.status が statusLine だけを理由に fail になります。PR #2745 の live test も、まさにこの既知制約だけを特例で許容しています。

    ただし、Issue の契約はそのまま実装に入れるには粗いです。特に「single-turn structured lane の statusLine をどう扱うか」という問題設定が、本来の #2568 の設計と Claude Code の statusLine ライフサイクルを混同しています。

    私なら 実装前に #2747 をもう一度 refinement します。実装方針は「runner と並行して statusLine を無理に叩く」ではなく、completed structured lane では statusLine を not_applicable と明示し、aggregate failure の対象外にする方向を推します。

    敵対的レビュー Findings

    ID | 優先度 | Finding | 影響 -- | -- | -- | -- F1 | P0 | Verification Commands / Allowed Paths のテストディレクトリが間違っている | 現契約のままでは正しい回帰テストを追加・実行できない F2 | P1 | statusLine を structured lane の終了後検証として扱う設計自体が #2568 とずれている | 「意味のある evidence」の定義を誤る F3 | P1 | --max-turns 2 等を single-turn の識別子にできない | ヒューリスティック実装が誤判定する F4 | P1 | 「runner 完了前に statusLine を評価」は現在の evidence channel ではかなり侵襲的 | Popen/stream/polling を持ち込みワークフローを複雑化 F5 | P1 | 「複数ターン structured なら executed を返せる」という AC の前提が実証されていない | 不安定な挙動を互換契約として固定しかねない F6 | P2 | 既存 live test の「既知 limitation 許容」を撤去するファイルが Allowed Paths にない | 修正後も弱い回帰オラクルが残る

    F1 — テストパスが現リポジトリと一致していない

    #2747 は、

    scripts/task-context/tests/

    を AC3、Verification Commands、Allowed Paths に指定しています。

    しかし現在のテストは、

    tests/task-context/

    にあります。実際に関連する既存資産も、

    tests/task-context/test_runtime_smoke_verifier.py
    tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py
    tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py

    です。

    したがって現在の

    uv run pytest scripts/task-context/tests/ -k runtime_smoke -v

    は正しい VC ではありません。

    これは単なる typo より重大です。scripts/task-context/tests/ が Allowed Paths に固定されているため、実装エージェントが契約を忠実に守るほど、既存テスト体系とは別のテストディレクトリを新設する方向に誘導されます。

    最低限、

    Allowed Paths:
    - scripts/task-context/task_context_runtime_smoke_verifier.py
    - tests/task-context/test_runtime_smoke_verifier.py
    - tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py

    などに直すべきです。


    F2 — 根本問題は「single-turn」ではなく、statusLine の観測時点

    ここが一番重要です。

    元 Issue #2568 の runtime matrix はすでに、

    • carrier inheritance → structured lane
    • /clear
    • statusLine
    • fresh-conversation restoration

    について、後者を interactive lane で検証する方針を明記しています。

    一方 #2747 は、structured claude -p が終了した後に statusLine script を手動再実行し、その値を aggregate verdict に使おうとしています。

    Claude Code の公式仕様上、status line は端末 UI の下部に表示される status bar であり、設定した script はセッション開始、assistant message 到着などのイベントで実行されます。つまり生きているセッションに付随する UI/evidence channelです。Claude

    さらに SessionEnd は文字通り Claude Code session が終了すると実行される hook です。Claude

    したがって、

    Claude session 終了後に、session ID を使って statusline.py をもう一度外部実行する

    ことは、実際の Claude Code がセッション中に statusLine をロード・実行したという evidence と同義ではありません。

    PR #2708 で追加した collect_statusline_evidence() はmechanism probeとしては有用ですが、それを completed structured run の必須 verdict にしたことが設計上の歪みです。

    推奨する意味論

    structured run 完了後は例えば、

    statusline_evidence = {    "status": "not_applicable",    "reason": "structured runtime session completed before out-of-band statusLine observation",    "rendered": None,}

    として、

    not_applicable → aggregate violation にしない
    failed         → applicable な経路では fail
    executed       → applicable な経路では pass
    executed_degenerate → applicable な経路では fail

    と分離する方が筋が通ります。

    executed_degenerate を PASS に読み替えるのは避けるべきです。 それでは「本当に binding が壊れて Unbound なのか」「正常な teardown 後だから Unbound なのか」を区別できなくなります。


    F3 — --max-turns 2 を single-turn 判定に使ってはいけない

    Issue 本文は、

    単一ターン structured lane(-p --max-turns 2 等)

    と記述していますが、Claude Code の --max-turns は実際に何ターン実行されたかではなく、agentic turn の上限です。公式 CLI reference も明確に「Limit the number of agentic turns」としています。Claude

    つまり、

    --max-turns 2

    から、

    actual_turn_count == 1

    は導けません。

    したがって実装で、

    if max_turns <= 2:    statusline_not_applicable = True

    のようにしてはいけません。

    むしろ今回の distinction は、

    single-turn vs multi-turn

    ではなく、

    completed non-interactive structured session
    vs
    live/applicable statusLine observation

    で定義する方が堅牢です。

    Issue タイトル・AC1 もこの用語へ変更した方がいいです。


    F4 — 「subprocess 完了前に評価」はコストに見合わない

    現在の流れは、

    invoke_generic_runner()
      └─ subprocess.run()
          └─ generic runner
              └─ claude -p ...
                 ...
              ← child completion
          ← runner completion
    

    runner evidence JSON 読込
    parent_session_id 取得
    collect_statusline_evidence()

    です。

    Python の subprocess.run() 自体が「command が完了するまで待って CompletedProcess を返す」APIです。Python documentation

    さらに current generic runner は、

    1. structured stdout 全体が返ってから extract_claude_parent_session_id(out) を実行
    2. schema_summary["parent_session_id"] を構築
    3. 最後に --evidence-json を書き込む

    構造です。

    つまり verifier が単純に subprocess.run() を Popen() に変えても、今使っている evidence JSON から session ID を早期取得できません。

    実現しようとすると、

    • stdout を逐次読む
    • stream-json から session ID を verifier 側でも解析
    • DB を polling
    • runner に途中 evidence channel を追加

    などが必要になります。

    しかも PIPE を伴う Popen の非同期管理では、stdout/stderr の読み方を誤ると pipe buffer による deadlock を起こし得るため、Python 公式も communicate() 等を使った慎重な管理を要求しています。Python documentation

    個人開発で品質・有用性とワークフローの軽さを優先するなら、ここに concurrency protocol を追加する価値は薄いです。


    F5 — 「multi-turn structured は現状どおり executed」の AC は根拠不足

    AC2 は、

    複数ターン structured lane(statusline evidence が "executed" を返せるケース)では既存挙動を維持

    としています。

    しかし current implementation はターン数にかかわらず、

    generic runner が完全終了
    ↓
    SessionEnd 済み
    ↓
    statusLine probe

    です。

    したがって「2ターン以上なら終了後にも non-degenerate statusLine を取得できる」という区別には、少なくとも現在確認した Issue / PR / code 内に十分な根拠がありません。

    ここを AC に固定すると、たまたま現在そう見える lifecycle artifact を仕様化する可能性があります。

    この AC は、

    collect_statusline_evidence() 自体の applicable な経路では、executed / failed / executed_degenerate の既存 fail-closed 判定を変更しない

    程度へ置き換える方が安全です。


    F6 — PR #2745 の workaround も同時に掃除すべき

    現在の、

    tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py

    には明示的に、

    _KNOWN_STATUSLINE_TIMING_LIMITATION =
    "statusline_evidence status='executed_degenerate', expected 'executed'"

    があり、aggregate result が fail でも、その violation 1件だけなら live isolation test を続行する例外があります。

    #2747 が直ったら、この exception を残す理由はありません。

    今回ここを Allowed Paths に追加し、

    assert result.status == "pass"

    を通常条件へ戻す方が、回帰テストとしてははるかに強くなります。


    推奨する #2747 の設計

    大規模には触らず、次の方向が最も費用対効果が高いです。

    structured runtime-smoke:
    runner / canonical delta / hook evidence → aggregate PASS/FAIL 対象
    post-session statusLine probe → not_applicable

    statusLine の本当の runtime verification:
    interactive/live session lifecycleで検証

    トップレベルの RuntimeSmokeOrchestrationResult.status は今の "pass" | "fail" を維持して構いません。statusLine subsystem だけ、

    executed
    executed_degenerate
    failed
    skipped
    not_applicable

    のように明示すれば十分で、top-level schema を三値化する必要はありません。

    そして collect_statusline_evidence() の "executed_degenerate" 判定自体は弱めないのが重要です。「structured post-session だから collector を必須評価しない」と、「degenerate を成功扱いする」は別物です。

    AC は例えばこう直すのがよいです

    AC1:
    completed structured runtime-smoke では、post-session statusLine observation が
    not_applicable と明示され、それ単独で aggregate result.status を fail にしない。

    AC2:
    statusLine evidence が applicable な経路における
    executed / executed_degenerate / failed の既存 fail-closed semantics は変更しない。

    AC3:
    runner failure、canonical_delta failure、その他 scenario failure が存在する場合、
    statusLine が not_applicable でも aggregate status は必ず fail のままである。

    AC4:
    PR #2745 で追加された live-shadow-isolation test の既知 limitation 特例を撤去し、
    live single structured run で aggregate result.status == "pass" を確認する。

    Verification Commands も最低限、

    uv run pytest tests/task-context/test_runtime_smoke_verifier.py -v

    uv run pytest
    tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py
    -v

    uv run pytest
    tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py
    -v

    へ修正すべきです。

    最後の live test は通常 CI に無理に常駐させる必要はありません。#2747 の現方針どおり、実装 PR で1回明示的に live canary を走らせ、その証跡を残す程度で十分です。今回の問題は real Claude lifecycle に依存するので、mock だけで完了扱いするよりはこの1本だけ残す価値があります。

    結論

    問題発見は妥当、修正対象も狭くてよい。ただし current Issue contract のまま impl-review-loop に投入するのは勧めません。

    特に実装前に直すべきなのは、① scripts/task-context/tests/ → tests/task-context/、② single/multi-turn という区分の撤去、③ pre-completion concurrency 案を実質不採用にして structured post-session statusLine を明示的 N/A にする、④ PR #2745 の live-test workaround を scope に含めて撤去する、の4点です。

    この形なら generic runner、statusLine renderer、ハーネス自体には手を広げず、#2568 の「generic runner = transport / Task Context verifier = semantics」という責務境界も維持できます。また、#2568 が元々 statusLine を interactive lane の検証対象としていた設計とも整合します。

    なお、PR #2745 は 2026-09-25 にすでに merge 済みで Issue #2744 も completed なので、#2747 Notes にある「#2745 merge 待ち」は現在は解消済みです。

    ## 総評

    [Issue #2747](#2747) が指摘している現象そのものは正しいです。現在の orchestrate_runtime_smoke() は generic runner を subprocess.run() で最後まで待ち、その後に statusLine を再実行するため、live test では executed_degenerate が発生し、aggregate result.status が statusLine だけを理由に fail になります。PR #2745 の live test も、まさにこの既知制約だけを特例で許容しています。

    ただし、Issue の契約はそのまま実装に入れるには粗いです。特に「single-turn structured lane の statusLine をどう扱うか」という問題設定が、本来の #2568 の設計と Claude Code の statusLine ライフサイクルを混同しています。

    私なら 実装前に #2747 をもう一度 refinement します。実装方針は「runner と並行して statusLine を無理に叩く」ではなく、completed structured lane では statusLine を not_applicable と明示し、aggregate failure の対象外にする方向を推します。

    敵対的レビュー Findings

    ID 優先度 Finding 影響
    F1 P0 Verification Commands / Allowed Paths のテストディレクトリが間違っている 現契約のままでは正しい回帰テストを追加・実行できない
    F2 P1 statusLine を structured lane の終了後検証として扱う設計自体が #2568 とずれている 「意味のある evidence」の定義を誤る
    F3 P1 --max-turns 2 等を single-turn の識別子にできない ヒューリスティック実装が誤判定する
    F4 P1 「runner 完了前に statusLine を評価」は現在の evidence channel ではかなり侵襲的 Popen/stream/polling を持ち込みワークフローを複雑化
    F5 P1 「複数ターン structured なら executed を返せる」という AC の前提が実証されていない 不安定な挙動を互換契約として固定しかねない
    F6 P2 既存 live test の「既知 limitation 許容」を撤去するファイルが Allowed Paths にない 修正後も弱い回帰オラクルが残る

    F1 — テストパスが現リポジトリと一致していない

    #2747 は、

    scripts/task-context/tests/
    

    を AC3、Verification Commands、Allowed Paths に指定しています。

    しかし現在のテストは、

    tests/task-context/
    

    にあります。実際に関連する既存資産も、

    tests/task-context/test_runtime_smoke_verifier.py
    tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py
    tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py
    

    です。

    したがって現在の

    uv run pytest scripts/task-context/tests/ -k runtime_smoke -v

    は正しい VC ではありません。

    これは単なる typo より重大です。scripts/task-context/tests/ が Allowed Paths に固定されているため、実装エージェントが契約を忠実に守るほど、既存テスト体系とは別のテストディレクトリを新設する方向に誘導されます。

    最低限、

    Allowed Paths:
    - scripts/task-context/task_context_runtime_smoke_verifier.py
    - tests/task-context/test_runtime_smoke_verifier.py
    - tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py
    

    などに直すべきです。


    F2 — 根本問題は「single-turn」ではなく、statusLine の観測時点

    ここが一番重要です。

    元 Issue #2568 の runtime matrix はすでに、

    • carrier inheritance → structured lane
    • /clear
    • statusLine
    • fresh-conversation restoration

    について、後者を interactive lane で検証する方針を明記しています。

    一方 #2747 は、structured claude -p が終了した後に statusLine script を手動再実行し、その値を aggregate verdict に使おうとしています。

    Claude Code の公式仕様上、status line は端末 UI の下部に表示される status bar であり、設定した script はセッション開始、assistant message 到着などのイベントで実行されます。つまり生きているセッションに付随する UI/evidence channelです。:chatgpt-content-reference{index="0"}

    さらに SessionEnd は文字通り Claude Code session が終了すると実行される hook です。:chatgpt-content-reference{index="1"}

    したがって、

    Claude session 終了後に、session ID を使って statusline.py をもう一度外部実行する

    ことは、実際の Claude Code がセッション中に statusLine をロード・実行したという evidence と同義ではありません。

    PR #2708 で追加した collect_statusline_evidence() はmechanism probeとしては有用ですが、それを completed structured run の必須 verdict にしたことが設計上の歪みです。

    推奨する意味論

    structured run 完了後は例えば、

    statusline_evidence = {
        "status": "not_applicable",
        "reason": "structured runtime session completed before out-of-band statusLine observation",
        "rendered": None,
    }

    として、

    not_applicable → aggregate violation にしない
    failed         → applicable な経路では fail
    executed       → applicable な経路では pass
    executed_degenerate → applicable な経路では fail
    

    と分離する方が筋が通ります。

    executed_degenerate を PASS に読み替えるのは避けるべきです。 それでは「本当に binding が壊れて Unbound なのか」「正常な teardown 後だから Unbound なのか」を区別できなくなります。


    F3 — --max-turns 2 を single-turn 判定に使ってはいけない

    Issue 本文は、

    単一ターン structured lane(-p --max-turns 2 等)

    と記述していますが、Claude Code の --max-turns は実際に何ターン実行されたかではなく、agentic turn の上限です。公式 CLI reference も明確に「Limit the number of agentic turns」としています。:chatgpt-content-reference{index="2"}

    つまり、

    --max-turns 2
    

    から、

    actual_turn_count == 1
    

    は導けません。

    したがって実装で、

    if max_turns <= 2:
        statusline_not_applicable = True

    のようにしてはいけません。

    むしろ今回の distinction は、

    single-turn vs multi-turn
    

    ではなく、

    completed non-interactive structured session
    vs
    live/applicable statusLine observation
    

    で定義する方が堅牢です。

    Issue タイトル・AC1 もこの用語へ変更した方がいいです。


    F4 — 「subprocess 完了前に評価」はコストに見合わない

    現在の流れは、

    invoke_generic_runner()
      └─ subprocess.run()
          └─ generic runner
              └─ claude -p ...
                 ...
              ← child completion
          ← runner completion
    
    runner evidence JSON 読込
    parent_session_id 取得
    collect_statusline_evidence()
    

    です。

    Python の subprocess.run() 自体が「command が完了するまで待って CompletedProcess を返す」APIです。:chatgpt-content-reference{index="3"}

    さらに current generic runner は、

    1. structured stdout 全体が返ってから extract_claude_parent_session_id(out) を実行
    2. schema_summary["parent_session_id"] を構築
    3. 最後に --evidence-json を書き込む

    構造です。

    つまり verifier が単純に subprocess.run() を Popen() に変えても、今使っている evidence JSON から session ID を早期取得できません。

    実現しようとすると、

    • stdout を逐次読む
    • stream-json から session ID を verifier 側でも解析
    • DB を polling
    • runner に途中 evidence channel を追加

    などが必要になります。

    しかも PIPE を伴う Popen の非同期管理では、stdout/stderr の読み方を誤ると pipe buffer による deadlock を起こし得るため、Python 公式も communicate() 等を使った慎重な管理を要求しています。:chatgpt-content-reference{index="4"}

    個人開発で品質・有用性とワークフローの軽さを優先するなら、ここに concurrency protocol を追加する価値は薄いです。


    F5 — 「multi-turn structured は現状どおり executed」の AC は根拠不足

    AC2 は、

    複数ターン structured lane(statusline evidence が "executed" を返せるケース)では既存挙動を維持

    としています。

    しかし current implementation はターン数にかかわらず、

    generic runner が完全終了
    ↓
    SessionEnd 済み
    ↓
    statusLine probe
    

    です。

    したがって「2ターン以上なら終了後にも non-degenerate statusLine を取得できる」という区別には、少なくとも現在確認した Issue / PR / code 内に十分な根拠がありません。

    ここを AC に固定すると、たまたま現在そう見える lifecycle artifact を仕様化する可能性があります。

    この AC は、

    collect_statusline_evidence() 自体の applicable な経路では、executed / failed / executed_degenerate の既存 fail-closed 判定を変更しない

    程度へ置き換える方が安全です。


    F6 — PR #2745 の workaround も同時に掃除すべき

    現在の、

    tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py

    には明示的に、

    _KNOWN_STATUSLINE_TIMING_LIMITATION =
      "statusline_evidence status='executed_degenerate', expected 'executed'"
    

    があり、aggregate result が fail でも、その violation 1件だけなら live isolation test を続行する例外があります。

    #2747 が直ったら、この exception を残す理由はありません。

    今回ここを Allowed Paths に追加し、

    assert result.status == "pass"

    を通常条件へ戻す方が、回帰テストとしてははるかに強くなります。


    推奨する #2747 の設計

    大規模には触らず、次の方向が最も費用対効果が高いです。

    structured runtime-smoke:
      runner / canonical delta / hook evidence → aggregate PASS/FAIL 対象
      post-session statusLine probe            → not_applicable
    
    statusLine の本当の runtime verification:
      interactive/live session lifecycleで検証
    

    トップレベルの RuntimeSmokeOrchestrationResult.status は今の "pass" | "fail" を維持して構いません。statusLine subsystem だけ、

    executed
    executed_degenerate
    failed
    skipped
    not_applicable
    

    のように明示すれば十分で、top-level schema を三値化する必要はありません。

    そして collect_statusline_evidence() の "executed_degenerate" 判定自体は弱めないのが重要です。「structured post-session だから collector を必須評価しない」と、「degenerate を成功扱いする」は別物です。

    AC は例えばこう直すのがよいです

    AC1:
    completed structured runtime-smoke では、post-session statusLine observation が
    not_applicable と明示され、それ単独で aggregate result.status を fail にしない。
    
    AC2:
    statusLine evidence が applicable な経路における
    executed / executed_degenerate / failed の既存 fail-closed semantics は変更しない。
    
    AC3:
    runner failure、canonical_delta failure、その他 scenario failure が存在する場合、
    statusLine が not_applicable でも aggregate status は必ず fail のままである。
    
    AC4:
    PR #2745 で追加された live-shadow-isolation test の既知 limitation 特例を撤去し、
    live single structured run で aggregate result.status == "pass" を確認する。
    

    Verification Commands も最低限、

    uv run pytest tests/task-context/test_runtime_smoke_verifier.py -v
    
    uv run pytest \
      tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py \
      -v
    
    uv run pytest \
      tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py \
      -v

    へ修正すべきです。

    最後の live test は通常 CI に無理に常駐させる必要はありません。#2747 の現方針どおり、実装 PR で1回明示的に live canary を走らせ、その証跡を残す程度で十分です。今回の問題は real Claude lifecycle に依存するので、mock だけで完了扱いするよりはこの1本だけ残す価値があります。

    結論

    問題発見は妥当、修正対象も狭くてよい。ただし current Issue contract のまま impl-review-loop に投入するのは勧めません。

    特に実装前に直すべきなのは、① scripts/task-context/tests/ → tests/task-context/、② single/multi-turn という区分の撤去、③ pre-completion concurrency 案を実質不採用にして structured post-session statusLine を明示的 N/A にする、④ PR #2745 の live-test workaround を scope に含めて撤去する、の4点です。

    この形なら generic runner、statusLine renderer、ハーネス自体には手を広げず、#2568 の「generic runner = transport / Task Context verifier = semantics」という責務境界も維持できます。また、#2568 が元々 statusLine を interactive lane の検証対象としていた設計とも整合します。

    なお、PR #2745 は 2026-09-25 にすでに merge 済みで Issue #2744 も completed なので、#2747 Notes にある「#2745 merge 待ち」は現在は解消済みです。

  3. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    確認した現状では、#2747 は実装へ進める前に、対象コメントを trusted human context の anchor として issue-refinement-loop を回すのが適切です。

    現行 main では PR #2745 はすでに merge 済みで、tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py には executed_degenerate だけを許容する workaround がまだ存在します。また collect_statusline_evidence() の結果は dict[str, Any] で、トップレベル RuntimeSmokeOrchestrationResult.status も "pass" | "fail" のままなので、現時点では not_applicable 導入のために外部 schema を必ず変更する構造には見えません。ただし refinement 中に consumer を検索して確定させるべきです。

    対象コメントの設計判断も妥当です。Claude Code の status line はセッション開始時や assistant message 到着時などに実行されるセッション付随の表示機構であり、SessionEnd はセッション終了時の hook です。したがって終了済み structured session に対する外部再実行を live statusLine evidence と同一視しない整理には根拠があります。:chatgpt-content-reference{index="0"} また --max-turns は「実際のターン数」ではなく agentic turn の上限なので、single/multi-turn 判定に使うべきではありません。:chatgpt-content-reference{index="1"}

    推奨アクションは次の通りです。

    • #issuecomment-5826095234 を direct human context として固定し、preflight.run.with_human_context 系の canonical lane から開始する。通常 iteration の承認確認は行わない。
    • F1〜F6 を Issue contract に反映する。特に scripts/task-context/tests/ → tests/task-context/、single/multi-turn 区分の撤去、pre-completion concurrency 案の不採用、not_applicable semantics、実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2745 workaround 撤去を明示する。
    • not_applicable が既存 consumer/type/schema に波及するかは codebase-investigator に調査させる。exact path が不足しても、skill に既存の trusted-human recovery route があるため、すぐ人間へ戻さない。
    • rewrite が必要なら issue-editor SubAgent に任せ、SubAgent の終了を必ず待ってから readback → fresh review → readiness を進める。background のまま次段階へ進まない。
    • refinement が approve になるまで自動反復する。ただし canonical planner/router が最終的に human_judgment_required を返す genuine hard stop まで無理に PASS 化しない。
    • 今回の依頼範囲は Issue refinement までとし、実装コードの変更には入らない。

    既に auto mode で起動している Claude Code へ、そのまま貼れる形です。

    Repository: squne121/loop-protocol

    対象 Issue:
    #2747

    今回の trusted anchor / human review directive:
    #2747 (comment)

    使用する skill:
    https://github.com/squne121/loop-protocol/tree/main/.claude/skills/issue-refinement-loop

    この Issue #2747 に対して .claude/skills/issue-refinement-loop/SKILL.md を SSOT として issue refinement loop を実行してください。

    現在の Claude Code セッションはすでに auto mode で起動済みです。
    permission mode の変更、Claude Code の再起動、--dangerously-skip-permissions 等への切り替えは不要です。

    Execution policy

    • 通常の loop iteration ごとに人間承認を要求しないでください。
    • loop_iteration_approval_gate.default_required: false として扱い、needs-fix は max_iterations 未到達なら自動継続してください。
    • deterministic repair、trusted human-context に基づく contract update、Issue rewrite、再レビューについて、skill が許可する範囲では確認待ちにせず継続してください。
    • max_iterations は特段の理由がなければ skill 既定値 3 を使用してください。
    • planner / router / reviewer / worker が返した machine-readable decision を main thread が prose で再判定しないでください。
    • skill の canonical command registry / controlled executor を使用し、raw gh issue edit や独自 GitHub mutation 経路を作らないでください。

    今回指定した anchor comment は OWNER による direct human context として扱ってください。
    URL だけの unlabeled lane や agent-report lane として処理せず、canonical な preflight.run.with_human_context 相当の経路を使用してください。

    SubAgent requirements

    必要な調査・rewrite は SubAgent を積極的に使用してください。

    最低限、planner / skill の routing に従って以下を使用してください。

    • repository/current-main の事実確認: codebase-investigator
    • external claim の確認が必要な場合: canonical web research SubAgent / web-researcher
    • Issue 本文 rewrite: issue-editor
    • follow-up materialization が本当に必要になった場合のみ: issue-creator

    重要:

    起動した SubAgent は必ず作業完了まで待ってください。

    SubAgent の partial output、起動済みという事実、background task の進行中状態だけを根拠に次の phase へ進まないでください。

    SubAgent の final result / required artifact が実際に返ってから、その結果を親 control-plane で consume してください。

    worker SubAgent から nested delegation を行わせないでください。各 agent/skill の既存 delegation boundary を守ってください。

    transient/environment failure に canonical bounded retry が定義されている場合は、先にそれを消化してください。人間確認を retry の代替にしないでください。

    First: establish current repository state

    mutation 前に current main を調査してください。

    少なくとも以下を確認してください。

    1. PR 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2745 が main に merge 済みであること。
    2. Issue 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2744 が完了済みで、実装: orchestrate_runtime_smoke() の completed structured runtime-smoke で post-session statusLine observation を not_applicable として扱う #2747 Notes に残っている「実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2745 merge 待ち」が stale であること。
    3. runtime-smoke 関連テストの実在パスが tests/task-context/ であること。
    4. 少なくとも以下の current-main 資産を確認すること。
    • scripts/task-context/task_context_runtime_smoke_verifier.py
    • tests/task-context/test_runtime_smoke_verifier.py
    • tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py
    • tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py
    1. test_runtime_smoke_verifier_live_shadow_isolation.py に、実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2745 由来の _KNOWN_STATUSLINE_TIMING_LIMITATION / executed_degenerate 特例が現在も存在すること。
    2. collect_statusline_evidence()、RuntimeSmokeOrchestrationResult、orchestrate_runtime_smoke() の current implementation と全 consumer/callsite を検索すること。
    3. statusline_evidence.status = "not_applicable" の追加が、別 schema、Literal/Enum、固定 consumer、Allowed Paths 外の変更を本当に必要とするか確認すること。

    current implementation では statusline_evidence が generic dict として保持されているように見えるため、外部 schema change が必要だと最初から仮定しないでください。一方、検索せず「不要」と断定することもしないでください。

    Anchor comment を反映する refinement direction

    target comment の F1〜F6 を authoritative review feedback として反映してください。

    特に以下を Issue contract に落とし込んでください。

    1. Test path correction

    現在の誤った

    scripts/task-context/tests/

    を削除し、current repository に存在する

    tests/task-context/

    配下の exact paths に修正してください。

    最低限、実装スコープ候補として:

    • scripts/task-context/task_context_runtime_smoke_verifier.py
    • tests/task-context/test_runtime_smoke_verifier.py
    • tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py

    を調査してください。

    test_runtime_smoke_verifier_canonical_carrier_regression.py についても regression coverage 上必要か調査し、必要性を contract に明示してください。

    2. Problem framing correction

    Issue の semantic distinction を

    single-turn vs multi-turn

    から

    completed non-interactive structured session
    vs
    live/applicable statusLine observation

    へ変更してください。

    --max-turns 2 等を actual turn count の判定ヒューリスティックとして使用する設計は禁止してください。

    Issue title、Outcome、In Scope、Acceptance Criteria、Notes 等も、この semantic correction と整合させてください。

    3. Do not introduce unnecessary concurrency

    invoke_generic_runner() の blocking execution 中に session id を横取りして statusLine を実行するためだけに、

    • subprocess.Popen
    • stdout streaming
    • polling
    • intermediate evidence channel
    • generic runner protocol extension

    等を追加する設計を既定案にしないでください。

    current evidence lifecycle と責務境界を維持し、個人趣味開発として implementation complexity を増やさない方向を優先してください。

    4. Recommended statusLine semantics

    completed structured runtime-smoke の post-session statusLine observation は、概念上:

    status = "not_applicable"

    として明示し、それ単独を aggregate RuntimeSmokeOrchestrationResult.status == "fail" の violation にしない設計を第一候補としてください。

    ただし、

    collect_statusline_evidence() 自体の applicable な経路における

    • executed
    • executed_degenerate
    • failed

    の fail-closed semantics は弱めないでください。

    特に executed_degenerate を単純に PASS へ読み替える設計は禁止です。

    「completed structured run では collector verdict を aggregate 必須条件にしないこと」と、
    「degenerate evidence を成功扱いすること」を混同しないでください。

    5. Preserve aggregate fail-closed behavior

    statusLine が not_applicable でも、

    • generic runner failure
    • canonical delta failure
    • その他 applicable scenario failure

    が存在する場合は aggregate result.status が必ず fail のままになる AC を明記してください。

    6. Remove #2745 workaround

    tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py に残っている既知 timing limitation の特例を #2747 の implementation scope に含めてください。

    #2747 実装後には、statusLine timing violation だけを特別許容する条件を撤去し、live structured runtime-smoke の aggregate result を通常の条件で検証できる contract にしてください。

    実装時の期待形は概念上、

    assert result.status == "pass"

    へ戻せることです。

    これは今回の refinement ではコード変更せず、Issue の Allowed Paths / AC / VC に正しく反映してください。

    Acceptance Criteria refinement target

    anchor comment の提案を起点として、少なくとも次の意味を検証可能な AC にしてください。

    AC1:
    completed structured runtime-smoke では post-session statusLine observation が not-applicable と明示され、それ単独で aggregate result.status を fail にしない。

    AC2:
    statusLine evidence が applicable な経路における executed / executed_degenerate / failed の既存 fail-closed semantics を変更しない。

    AC3:
    runner failure、canonical-delta failure、その他 applicable scenario failure がある場合、statusLine が not-applicable でも aggregate status は fail のままである。

    AC4:
    PR #2745 由来の live-shadow-isolation test の既知 timing limitation 特例を撤去し、live structured run で aggregate result.status == "pass" を検証できる。

    必要なら codebase investigation の結果に基づいて AC を追加・分割して構いませんが、根拠のない新規機能領域へ scope expansion しないでください。

    Verification Commands

    current repository layout に合わせて Verification Commands を修正してください。

    最低限の候補:

    uv run pytest tests/task-context/test_runtime_smoke_verifier.py -v

    uv run pytest tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py -v

    uv run pytest tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py -v

    ただし exact VC は current tests と refined AC を照合した上で決定してください。

    live test を通常 CI の無条件必須にする必要はありません。
    real Claude lifecycle に依存する検証については、Issue の Runtime Verification Applicability を明確化し、implementation PR で bounded live canary を少なくとも1回実施して証跡を残す方式を検討してください。

    SKIP を PASS と同一視しない current runtime-verification policy は維持してください。

    External research

    web research routing が applicable なら実行してください。

    特に current Claude Code official documentation で以下を確認してください。

    • statusLine の lifecycle / update trigger
    • SessionEnd lifecycle
    • --max-turns の意味

    ブログ等より公式 Claude Code docs を優先してください。

    external evidence は Issue の設計判断に必要な範囲だけ使用し、外部仕様を過剰に contract 化しないでください。

    Trusted-human recovery / scope changes

    anchor comment が意味論的には path expansion を要求しているが exact repository-relative path が不足している場合、すぐ人間へ質問しないでください。

    issue-refinement-loop の current trusted-human handling / #2086 recovery route に従い、read-only codebase-investigator SubAgent を使って current main から exact path を導出してください。

    導出後は canonical classifier / contract update consumer に戻してください。

    contract_update.run.with_human_context が NEXT_ACTION: issue_editor_required を返した場合も、人間確認を要求せず、skill の既存 issue-editor controlled rewrite route へ進んでください。

    人間に手書き ANCHOR_SCOPE_REFRAME_V1 を再入力させないでください。

    Review loop

    Issue 本文の mutation 後は必ず:

    1. body/title readback
    2. fresh preflight/static readiness
    3. fresh root review
    4. applicable なら semantic design review
    5. final review gate
    6. next-action routing

    を current skill の順序で実施してください。

    review が needs-fix の場合、max iteration 未到達なら issue-editor へ戻し、自動で再度 review してください。

    SubAgent の完了を待たずに review を開始しないでください。

    stale artifact、body hash mismatch、binding mismatch を無視して approval に進まないでください。

    Stop policy

    通常の承認確認では停止しないでください。

    canonical skill に既存の automatic recovery / deterministic repair / bounded retry / trusted-human-context recovery が存在する場合は、それらを先に全て使用してください。

    それでも canonical planner/router が以下を terminal と判定した場合のみ停止してください。

    • genuine human_judgment_required
    • max_iterations exhausted
    • unrecoverable environment/integrity failure
    • skill が明示する fail-closed terminal state

    その場合は勝手に approve へ読み替えず、blocker、実行済み recovery、残った判断点を具体的に termination report に残してください。

    Completion boundary

    今回のタスクは Issue #2747 の refinement 完了まで です。

    refinement が approve されたら、current skill が要求する termination report / LOOP_HANDOFF_RESULT_V1 等の handoff bookkeeping を完了してください。

    ただし、このプロンプトでは #2747 の実装コード変更、PR 作成、merge は開始しないでください。

    canonical root transition が downstream implementation を示す場合も、refinement の approved handoff 状態を報告したところで本タスクを終了し、implementation mutation には入らないでください。

    Final response

    終了時は簡潔に以下を報告してください。

    • final refinement verdict
    • Issue body/title が更新されたか
    • iteration count
    • 主な contract delta
    • SubAgent 実行結果と、全 SubAgent の完了を待ったこと
    • Verification/readiness/review の最終結果
    • human escalation があれば exact reason
    • implementation-ready かどうか
    • 実装自体には着手していないこと

    この形なら、対象コメントを単なる「参考意見」ではなく trusted anchor として contract rewrite に使わせつつ、通常の確認待ちを排除できます。特に with_human_context → contract update / issue-editor → fresh review の canonical route を明記した点が重要です。

  4. changed the title [-]実装: orchestrate_runtime_smoke() が単一ターン structured lane でも statusline evidence 判定を意味あるものにする[/-] [+]実装: orchestrate_runtime_smoke() の completed structured runtime-smoke で post-session statusLine observation を not_applicable として扱う[/+] on Sep 25, 2026
  5. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    Issue Refinement Loop — 終了報告

    verdict: approved(deterministic checker: APPROVE, semantic design review: 2周実施しblocker/high finding解消、残存は non-blocking low severity 1件)

    iteration count: deterministic review 4回実行(1回目 needs-fix: VC test path exit5、2回目 needs-fix: baseline VC preflight regression-gate 誤分類、3回目 approve、semantic finding反映後の4回目 approve)。semantic design review 2周(1周目 high severity finding 1件 → fix_delta → 2周目 low severity finding 1件のみ、rewrite対象外)。

    Anchor / trusted human context: OWNER trusted anchor #2747 (comment) を preflight.run.with_human_context / contract_update.run.with_human_context 経由で処理。この anchor は複数の指摘(F1〜F6)と concept-level directive を含む freeform review であり、classify_scope_delta_authority() は expands_allowed_paths boundary で route.action: human_escalation(mixed extracted_directives により _has_explicit_exact_allowed_path_expansion() が不成立)と判定した。investigation_derived_path_literals 経路(#2086 AC3)は当該コメントに既存の正規 path literal が含まれるため適用対象外と判断し、full-rewrite lane(issue-editor 経由の全面書き換え)へ進んだ。

    Contract Delta(主な変更点)

    1. Test path 修正(F1): 誤った scripts/task-context/tests/ を実在する tests/task-context/test_runtime_smoke_verifier.py / test_runtime_smoke_verifier_canonical_carrier_regression.py / test_runtime_smoke_verifier_live_shadow_isolation.py へ修正。
    2. 問題設定の再定義(F2/F3): 「single-turn vs multi-turn」を廃し、「completed non-interactive structured session vs live/applicable statusLine observation」へ変更。--max-turns をヒューリスティックに使わない AC5 を追加。
    3. concurrency 拡張の明示的排除(F4): invoke_generic_runner() を Popen 化する等の設計を Out of Scope / Stop Conditions に明記。
    4. not_applicable 設計の scope 限定(F5, semantic design review反映): 当初 AC1 は completed structured runtime-smoke であれば無条件に not_applicable としていたが、semantic design review(high severity finding)で collect_statusline_evidence() が返しうる "failed"/"skipped" まで丸め込みうる曖昧さを指摘され、"executed_degenerate" の場合に限定するよう Outcome/In Scope/AC1/AC2/AC6 を改訂。
    5. PR 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2745 workaround 撤去(F6): _KNOWN_STATUSLINE_TIMING_LIMITATION 特例撤去を Allowed Paths / AC4 に追加。
    6. VC baseline preflight 対応: AC4 の live test に -m claude_live(pyproject.toml の marker gating)と # baseline-expect: deferred annotation を追加し、deterministic checker の regression-gate 誤分類を解消。
    7. Notes for Reviewer: PR 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2745 マージ済み・Issue 実装: worktree-agent-runtime-smoke の structured lane 既定invocationがcanonical Task Context DBへunscopedで書き込む問題を解消する #2744 completed による Scope Collision 解消を明記し、OWNER anchor 反映内容・semantic review 反映内容を記録。

    Verification / Readiness / Review 最終結果

    • contract_readiness_check.py --mode execute: status: go
    • guard-issue-body.py --issue-kind implementation: all_passed: true
    • deterministic review(run_root_review_pipeline.py produce): VERDICT: approve, BLOCKERS: 0
    • semantic design review(issue-design-reviewer, 2周): 最終 effective_verdict: approve(残存 finding は non-blocking low severity 1件、route_high_open_to_rewrite policy 上 rewrite 対象外)
    • dependency_materializer.py gate: decision: proceed, reason: no_hard_dependencies_confirmed_this_cycle(本 Issue に対する native predecessor 関係の確定なし)

    SubAgent 実行

    • codebase-investigator(read-only 事前調査、1回、完了待機済み)
    • issue-editor(本文 rewrite/fix_delta、計4回、いずれも完了待機済み。edit_issue_txn.py controlled executor 経由、raw gh issue edit 不使用)
    • issue-design-reviewer(semantic design review、2回、いずれも完了待機済み)
    • web-researcher は今回起動不要と判断(anchor comment 自体が公式ドキュメントの該当箇所を引用しており、repository evidence(実コード確認)で独立に検証可能だったため)

    Human Escalation

    なし(genuine human_judgment_required は発生していない)。

    Implementation-Ready 状態について

    deterministic review / semantic design review はいずれも approve 済みであり、本 Issue の contract 自体は改善済み・安定した状態にある。

    ただし、本タスクの Completion Boundary により、issue-contract-review(実装着手直前の decision gate)および impl-review-loop への handoff(root_entry_router.py 経由の run_root_transition())は意図的に実行していない。したがって LOOP_HANDOFF_RESULT_V1 marker(status: impl_ready 等)は本レポートでは発行しない。実装着手が必要な場合は、別途 issue-contract-review の実行から開始すること。

    実装コード変更・PR 作成・merge は一切開始していない。

  6. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-25T05:35:00Z)

    実装内容

    • scripts/task-context/task_context_runtime_smoke_verifier.py::orchestrate_runtime_smoke(): collect_statusline_evidence() が "executed_degenerate" を返した場合に限り not_applicable(underlying_status/rendered 等を保持)として再解釈し、単独では aggregate result.status を "fail" にしないよう変更。"failed" / "skipped" は引き続き violations に含め fail のまま(丸め込みなし)。collect_statusline_evidence() 自体の leaf 判定ロジックは無変更。
    • tests/task-context/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 とする形に書き換え(AC4)。
    • tests/task-context/test_runtime_smoke_verifier.py: 回帰テストを追加(executed_degenerate → not_applicable かつ aggregate not fail、failed/skipped → 引き続き fail、executed → 既存 semantics 不変、runner failure が not_applicable にマスクされないこと の4系統)。

    Verification Commands 実行結果

    $ rg -n "max_turns" scripts/task-context/task_context_runtime_smoke_verifier.py
    

    → マッチなし(既存記述以外の新規ターン数依存ロジックを追加していないことを確認。AC5)。

    $ uv run pytest tests/task-context/test_runtime_smoke_verifier.py -v
    

    → 42 passed(新規5テストを含む)。

    $ uv run pytest tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py -v
    

    → 4 passed(AC7: 既存テスト全件 PASS 維持)。

    live canary(deferred verification)の実行結果

    実 claude CLI 環境(claude 2.1.282、.claude/worktrees/issue-2747-statusline-not-applicable worktree 内、canonical repository root からは generic runner の root-checkout guard により実行不可のため worktree 内で実行)で以下を実行:

    $ uv run pytest tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py -v -m claude_live
    

    → 1 passed(result.status == "pass"、result.violations == []、_KNOWN_STATUSLINE_TIMING_LIMITATION 特例なしで PASS)。Issue #2747 の deferred_verification_condition を満たした。証跡ログは worktree local artifacts/runtime-verification-AC2-20260925T053257Z.log(.gitignore 対象のためリポジトリには含めていない)。

    後続

    • PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  7. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    Contract Reconciliation Request(PR #2749 OWNER レビュー由来)

    PR #2749 の OWNER レビューコメント(https://github.com/squne121/loop-protocol/pull/2749#issuecomment-5827999244)を root/main thread が調査・正規化した technical recommendation です。raw comment 本文の直接転記ではなく、live Issue / PR diff / repository 実装と照合した上での要約です。

    検出された contract conflict

    現行 AC1 / AC6 は「collect_statusline_evidence() が \"executed_degenerate\" を返した場合は(Unbound/Degraded/空文字の区別なく)一律 not_applicable とし、単独では aggregate を \"fail\" にしない」と定めています。

    一方 OWNER 指摘(P1-1)は、.claude/hooks/task_context/statusline.py の実装上 Degraded は genuine な DB/query/transport failure を表しうる(Degraded を print して exit 0 する設計)ため、executed_degenerate を一律 not_applicable にすると本物の障害を PASS へ丸め込んでしまう、という点を指摘しています。

    これは現行 AC1/AC6 の文言(executed_degenerate という leaf 戻り値だけを判定材料にする)と直接矛盾します。

    推奨される契約修正(最小限)

    OWNER 自身が「最低限の fix」として提示した方式を採用する:

    • orchestrate_runtime_smoke() 側の not_applicable 判定条件を、collect_statusline_evidence() が \"executed_degenerate\" を返し、かつ その根拠となる raw statusLine render が \"Unbound\" の場合に限定する。
    • \"Degraded\" および空文字 (\"\") の raw render は、executed_degenerate に分類されていても not_applicable へ昇格させず、引き続き violations に含め aggregate status を \"fail\" のままにする。
    • collect_statusline_evidence() 自体(leaf 関数)の executed/executed_degenerate/failed/skipped 判定ロジック・_DEGENERATE_STATUSLINE_RENDERS の集合自体は変更しない(AC2 / Stop Conditions の制約を維持)。orchestrate_runtime_smoke() 側で raw render 値(rendered フィールド)を追加参照し、not_applicable への昇格可否をさらに絞り込む。

    因果説明の修正(P1-2)

    現行 Issue の「SessionEnd 相当のライフサイクルを終えた状態のため Binding が SUSPENDED になり非退化レンダリングを得られない」という説明は、Task Context 実装(on_session_start() は SessionEnd で current_claude_session_id をクリアせず runtime_health のみ SUSPENDED にする設計)と整合しません。より正確な、より弱い因果説明に置き換える必要があります:

    「structured non-interactive run(claude -p)完了後に行う out-of-band statusLine probe は、interactive UI lifecycle 中の live statusLine verification と等価ではない(seed Binding に claude_session_id が無いため実 SessionStart が新規 Binding を作り、そのため task_id=None のまま Unbound を観測している可能性が高い)」

    --max-turns を実行ターン数の識別子として扱わない、という既存 AC5 の方針は変更不要(OWNER も妥当と認めている)。

    スコープ境界

    • invoke_generic_runner() の subprocess.run() → Popen 化、stdout streaming、statusLine polling、並行 observer、generic runner protocol 拡張は引き続き Out of Scope のまま維持する(Owner 推奨、Stop Conditions 既存方針と一致)。
    • Allowed Paths の追加は不要と判断する(変更は scripts/task-context/task_context_runtime_smoke_verifier.py の orchestrate_runtime_smoke() 内の判定ロジックと、対応する tests/task-context/test_runtime_smoke_verifier.py の回帰テストのみで完結する)。

    以上を Issue #2747 の Outcome / In Scope / AC1 / AC6 / Notes for Reviewer に反映することを推奨します。

  8. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-09-25T00:00:00Z)

    PR #2749 を current head 9ce36ee8a28227fac9035b402489321e88695ada で impl-review-loop に再投入し、stale-head evidence を解消した。

    current-head 独立検証(test-runner)

    • head_sha 一致確認: PR live head / worktree checkout / test-runner 報告値がすべて 9ce36ee8a28227fac9035b402489321e88695ada で一致
    • rg -n "max_turns" scripts/task-context/task_context_runtime_smoke_verifier.py → no match (exit 1, AC5 期待どおり PASS)
    • uv run pytest tests/task-context/test_runtime_smoke_verifier.py -v → 44 passed (AC1/AC2/AC3/AC6)
    • uv run pytest tests/task-context/test_runtime_smoke_verifier_canonical_carrier_regression.py -v → 4 passed (AC7)
    • uv run pytest tests/task-context/test_runtime_smoke_verifier_live_shadow_isolation.py -v -m claude_live → 1 passed(実 claude CLI 環境で genuinely 実行、SKIP ではない。AC4 deferred_verification_condition 充足)

    current-head 独立 PR レビュー(pr-reviewer)

    • verdict: APPROVE / reviewed_head_sha: 9ce36ee8a28227fac9035b402489321e88695ada / blockers: []
    • Allowed Paths gate: ok(3変更ファイルとも Issue 実装: orchestrate_runtime_smoke() の completed structured runtime-smoke で post-session statusLine observation を not_applicable として扱う #2747 の Allowed Paths 内)
    • 実装ロジックを直接読解し、AC1-AC7 全件が実コードで満たされていることを確認(rendered=="Unbound" のみ not_applicable、"Degraded"/""/"failed"/"skipped" は引き続き fail 扱い)
    • CI required checks: current head で全 PASS(python-test-core, python-test, test, build, typecheck, lint, e2e, agy-causal-claim-drift-gate 等)
    • warning(non-blocking): PR 本文の IMPLEMENTATION_SCOPE_COVERAGE_V1.pr_head_sha が旧 head 5457a88a... のまま stale。hygiene blocker ではないため本ループでは body-only 更新を実施していない(次回本文更新時の是正を推奨)

    live mergeability

    • mergeable: MERGEABLE / merge_state_status: CLEAN / isDraft: true(本コメント投稿後、owner 指示により Ready for Review へ遷移予定。マージ自体は実行しない)
    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2749"
      head_sha: "9ce36ee8a28227fac9035b402489321e88695ada"
      issue_number: 2747
      termination_reason: approved
      merge_ready: true
      iteration: 1
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "pr-2749-stale-implementation-scope-coverage-pr-head-sha"
          source_url: "https://github.com/squne121/loop-protocol/pull/2749"
          source_note_id: "pr-reviewer-warning-i1"
          summary: "PR body IMPLEMENTATION_SCOPE_COVERAGE_V1.pr_head_sha は旧 head 5457a88a... のまま。non-blocking advisory。"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions