Skip to content

実装: runtime smoke の marker provenance を SubagentStop の last_assistant_message 欠落時に handbackReport へ適応する(Claude Code 2.1.285 対応) #2848

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "Claude Code 2.1.285 で SubagentStop payload から last_assistant_message が欠落しても、runner の marker provenance が Agent tool の handbackReport に fail-closed で適応し、SubAgent causal evidence が hook_id_correlated として成立する"
change_kind: code
dedupe_key: "runtime-smoke:subagentstop-last-assistant-message-absent:handbackreport-provenance:v1"

Parent Issue

なし(研究元は調査 Issue #2846。#2846 は research のため親 tracker ではなく、本 Issue は単独の実装 Issue として扱う)

Parent Goal Ref

  • Goal: runtime_only の AC が --require-subagent-causal-evidence と --expect-marker-source subagent を併用して、現行の Claude Code(2.1.285)でも PASS できる状態にする。
  • Desired Destination: N/A(単独改善 Issue)。

Current Validated Scope

2026-09-30 に、ローカルに導入済みの Claude Code 2.1.284 と 2.1.285 のバイナリを、同一 worktree・同一 prompt・同一 argv で直接実行して測定した事実のみを記載する。詳細は #2846 (comment) を正本とする。

Remaining Parent Gaps

Outcome

scripts/agent-ops/run_worktree_agent_runtime_smoke.py の causal evidence parser が、SubagentStop に last_assistant_message が無い場合に相関済みの handbackReport.text を fail-closed で marker provenance に使うようになり、対応する fixture pytest と live smoke(Claude Code 2.1.285 以降)が PASS して causal_evidence_source == hook_id_correlated となった状態で PR が merge される。

Runtime Verification Applicability

  • decision: immediate
  • reason: 本 Issue は scripts/agent-ops/**(runner)の causal evidence parser を変更し、extension-surface policy の hard trigger(subagent-lifecycle-start-stop-delegation-fallback)に一致する。upstream の payload 変更に対する適応は、fixture の pytest だけでは実 runtime での成立を証明できないため。
    applicable_acs: [AC3]
    execution_environment: 現在の Claude Code session と repository の scripts/agent-ops/run_worktree_agent_runtime_smoke.py(claude 実行ファイルが PATH 上にあり 2.1.285 以降であること、uv が利用可能であること)。SubAgent が text の marker を 1 行返すだけの無害な fixture prompt を使う。mutation・外部 code 実行・network は行わない。
    skip_conditions: claude 実行ファイルまたは uv が利用不能な場合は、runner / VC は exit 77 と stdout 先頭 SKIP: で SKIP を宣言する(docs/dev/runtime-verification-policy.md の SKIP 規約に従う)。SKIP は PASS ではなく Stop Condition として扱う。
    fallback_policy: pytest の PASS・fake claude・runner の SKIP・unverified の結果を、AC3 の PASS として扱わない。
    artifact_requirements: AC3 は worktree-local の artifacts/runtime-smoke/subagentstop-handback-provenance/(main へ commit しない)配下の runner evidence を証跡とする。新しい schema・receipt・publisher は追加しない。

runtime_assertion_bindings:

  • profile: subagent-lifecycle-causal-evidence-smoke
    assertion: subagent_start_stop_causal_evidence_correlated
    ac: AC3

In Scope

  • runner の causal evidence parser の最小適応。相関した SubagentStop event に空でない last_assistant_message が無い場合に限り、hook の agent_id と agentId が一致し、かつ status == completed(terminal 成功)である Agent tool の tool_use_result.handbackReport.text を、marker provenance の追加入力として使う。
  • last_assistant_message が存在する場合の既存挙動は byte-identical に保つ。
  • start/stop の相関、tool invocation の相関、qualifying candidate がちょうど 1 件であること、agent_transcript_path の存在といった既存の要件は緩めない。
  • handbackReport が無い・相関しない・terminal でない・矛盾する場合は no_evidence のままとする(fail-closed)。
  • 使用した provenance source を、evidence summary の既存 schema の慣習に収まる場合に限り、allowlist 済みの加算的 field として記録する。収まらない場合は記録しない。
  • 上記の fixture pytest を scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py に追加する。
  • 無害な live smoke 用 fixture prompt を新規に追加する。実装: 独立 claude -p の runtime VC に bounded な approval carrier と non-executable 検出を追加する (#2839) #2844 が追加する runtime_vc_lifecycle_smoke_prompt.md とは file 名を分け、衝突を避ける。

Out of Scope

Acceptance Criteria

  • AC1: last_assistant_message が無い SubagentStop event と、hook の agent_id に一致する agentId・status == completed・期待 marker を持つ handbackReport.text の組が hook_id_correlated になることが、fixture pytest で検証されている。last_assistant_message が存在する場合の結果が従来どおりであることも検証されている(test 名に handbackreport_provenance を含める)。
  • AC2: handbackReport の agentId 不一致・status が completed でない・marker 欠落・矛盾する重複のいずれの場合も hook_id_correlated にならない(fail-closed)ことが、fixture pytest で検証されている(test 名に handbackreport_fail_closed を含める)。
  • AC3: 実 runtime の run で、runner が --require-subagent-causal-evidence を付けた構造化 mode の smoke に PASS し、causal_evidence_source == hook_id_correlated となる(Claude Code 2.1.285 以降)。
  • AC4: 既存の causal evidence test(47 件)が引き続き PASS している。

Verification Commands

# AC1
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -q -k handbackreport_provenance

# AC2
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -q -k handbackreport_fail_closed

# AC3
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode structured --worktree "$PWD" --prompt-file scripts/agent-ops/tests/fixtures/subagentstop_handback_provenance_smoke_prompt.md --output-dir artifacts/runtime-smoke/subagentstop-handback-provenance --timeout-seconds 300 --max-turns 6 --agent-type pr-reviewer --expect-marker-source subagent --expect-marker "SUBAGENTSTOP_HANDBACK_PROVENANCE_SMOKE_OK" --require-subagent-causal-evidence --require-min-subagents 1 --require-clean-postcondition

# AC4
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -q

Allowed Paths

  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py
  • scripts/agent-ops/tests/fixtures/subagentstop_handback_provenance_smoke_prompt.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 実装が --require-subagent-causal-evidence の要件の緩和、または generic な compatibility 層を必要とすると判明した場合
  • AC3 が SKIP(exit 77)または FAIL になった場合は PASS 扱いにせず、報告して停止する(原因を修正した新しい head でのみ再実行する)

Required Skills

なし

Required Design References

  • docs/dev/runtime-verification-policy.md
  • docs/dev/extension-surface-runtime-policy.yaml
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py

Delivery Rule

Scope Delta(任意)

なし

Notes for Reviewer

  • 新規の fixture prompt は .md のため PR Body Japanese Check の対象になる。各 prose block に日本語の注記を含める。
  • references/claude-code.md の更新は、skill 契約の hard trigger を避けるため Out of Scope とした。

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Sep 30, 2026
  2. squne121 commented on Sep 30, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了

  3. squne121 commented on Sep 30, 2026

    @squne121
    OwnerAuthor

    完了報告

    PR #2849(merge commit ab2d9238f4c762a68da29d4da7b36597161f5f41)が main に merge され、この Issue の受け入れ条件 AC1〜AC4 は同 PR で満たされています。PR 本文の Closes #2848 による自動 close が反映されなかったため、手動で close します。

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/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions