Skip to content

実装: run_worktree_agent_runtime_smoke.py に skill-invocation-runtime-smoke profile を実装し causal-evidence 既定強制を opt-out 可能にする #2498

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "scripts/agent-ops/run_worktree_agent_runtime_smoke.py に main/subagent evidence provenance を表現する最小 contract と skill-invocation-runtime-smoke profile の実評価を実装する"
change_kind: feature

Parent Issue

none(#2194 の blocker 解消という関係だが、#2194 の子ではなく独立 Issue として扱う。詳細は ## Related を参照)

Parent Goal Ref

なし(単独 Issue)

Current Validated Scope

scripts/agent-ops/run_worktree_agent_runtime_smoke.py と .claude/skills/worktree-agent-runtime-smoke/SKILL.md、および scripts/agent-ops/tests/ 配下のテストファイルへの変更のみ。docs/dev/extension-surface-runtime-policy.yaml の rule/profile 定義自体(schema 含む)は変更しない。

Remaining Parent Gaps

本 Issue の実装完了後、Issue #2194 の AC7 Verification Command をこの新 CLI 契約へ書き換える作業が残る(#2194 側で別途対応)。

Outcome

scripts/agent-ops/run_worktree_agent_runtime_smoke.py に、runner の責務(runtime launch / observation / evidence collection)の範囲内で以下が実装され、既存テストと新規テストが全て PASS している状態:

  1. skill-invocation-runtime-smoke profile の procedure_steps_executed_in_declared_order assertion を、caller-supplied ordered expected-evidence-marker list と実際に観測された native evidence 順序の照合(ordered-evidence-match)として評価するロジック。この ordered marker list は既存の --expect-marker(causal-evidence 既定強制と結合済みの既存引数)とは独立した新規 CLI 引数 --expect-ordered-marker(--expect-marker と同様 action="append")で受け取る。runner 自身が任意の SKILL.md の Markdown Procedure を汎用解釈することはしない。
  2. 同 profile の output_contract_schema_fields_present assertion を、caller が指定する既存の canonical JSON Schema ファイル(例: .claude/skills/review-issue/schemas/review_issue_result_v1.json)に対する jsonschema.validate() による full schema validation として評価するロジック(--output-schema-path 引数)。runner に generic multi-domain schema registry は追加しない。
  3. --expect-marker 使用時の SubAgent causal-evidence 既定強制に対する additive な provenance 引数 --expect-marker-source main|subagent(省略時デフォルトは既存の暗黙強制と完全一致する subagent)。
  4. main 指定時に direct Skill invocation の発生を native evidence(UserPromptExpansion の command_name フィールド)で検証する --expect-skill-command <name> 引数。--expect-marker-source main は --expect-skill-command との必須ペアとし、--expect-skill-command を伴わない --expect-marker-source main は usage error(non-PASS)として拒否する。これにより --expect-marker-source main 単独が「causal-evidence 要件の無条件 opt-out」に退化することを防ぐ(Step 2.5 semantic design review 指摘、severity: high)。

Runtime Verification Applicability

decision: immediate
applicable_acs:
  - AC7
execution_environment:
  cli_tools:
    - python3
    - uv
  runtime_launch: claude
  auth_required: true
  network_required: false
skip_conditions:
  - "対象 worktree で Claude Code runtime(`claude` CLI)が起動不可の場合は SKIP(exit 77 相当の pytest skip)とし、Stop Condition の human escalation へ倒す"
  - "認証済み Claude Code セッションが利用不可の場合も同様に SKIP とする"
fallback_policy:
  fallback_success_is_pass: false
  notes: "fallback 経由でのみ得られた PASS は runtime-verification の成立要件を満たさない。non-fallback PASS のみを証跡として認める"
artifact_requirements:
  - "run_worktree_agent_runtime_smoke.py の構造化 output(PASS/FAIL/SKIP 判定と evidence 種別を含む JSON artifact)"
  - "pytest 実行ログ"
  • reason: 変更対象は scripts/agent-ops/**(docs/dev/extension-surface-runtime-policy.yaml の subagent-lifecycle-start-stop-delegation-fallback rule の selector path_globs に含まれる)であり、delegation_trigger_condition / fallback_path_logic 相当のロジック変更を伴うため、policy 上 default_decision: immediate が適用される。
  • 対応 AC: AC7(<!-- runtime-verification: true --> タグ付与)で以下を実機確認する:
    • --expect-marker-source main --expect-skill-command review-issue 経由で、review-issue Skill への direct /review-issue invocation が SubAgent spawn なしで観測され、non-fallback PASS が得られること
    • 既存の --expect-marker-source subagent(省略時デフォルトを含む、実際に SubAgent 委譲が発生するケース)経路が従来通り FAIL/PASS を正しく判定すること(causal-evidence 強度の低下がないこと、回帰なし)
  • 証跡: PR 本文 ## Runtime Verification Evidence に実行ログを引用する

In Scope

  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py: skill-invocation-runtime-smoke profile の2 assertion(ordered-evidence-match / canonical JSON Schema full validation)の評価ロジック実装
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py: --expect-marker-source main|subagent および --expect-skill-command <name> の additive CLI 引数追加(--expect-marker 単独の既存挙動は破壊しない)
  • .claude/skills/worktree-agent-runtime-smoke/SKILL.md: 新引数・新 profile 評価ロジックの使い方の説明追加
  • scripts/agent-ops/tests/test_skill_invocation_runtime_smoke_profile.py(新規、AC1/AC2 用)と scripts/agent-ops/tests/test_expect_marker_source_provenance.py(新規、AC3/AC4/AC7 用)の作成。.github/ci/python-test-plan.json は scripts/agent-ops/tests/ ディレクトリを既に target としているため、この2ファイル追加のための target 更新は不要(実装時に個別ファイル名指定になっている等の理由で対象外と判明した場合のみ Allowed Paths 内の .github/ci/python-test-plan.json 更新を検討する)

Out of Scope

Acceptance Criteria

  • AC1: skill-invocation-runtime-smoke profile の procedure_steps_executed_in_declared_order assertion を、新規 CLI 引数 --expect-ordered-marker(action="append"、--expect-marker とは独立、causal-evidence 既定強制を一切トリガーしない)で受け取る caller-supplied ordered expected-evidence-marker list と、実際に観測された native evidence 順序の ordered-evidence-match として評価する実装が run_worktree_agent_runtime_smoke.py に存在する(runner は任意 SKILL.md の Markdown を汎用解釈しない。期待順序の SKILL.md からの抽出は呼び出し側テストの責務とする)
  • AC2: 同 profile の output_contract_schema_fields_present assertion を、caller が指定する単一の canonical JSON Schema ファイルパス(--output-schema-path 引数)に対する jsonschema.validate() の full schema validation として評価する実装が存在する(required-key existence のみの独自チェッカーは新設しない)
  • AC3: --expect-marker 使用時の SubAgent causal-evidence 既定強制に対する additive な provenance 引数 --expect-marker-source main|subagent が実装されており、省略時は既存の暗黙 subagent 強制動作と完全に同一である
  • AC4: --expect-marker-source main 指定時に、--expect-skill-command <name> 引数と native UserPromptExpansion.command_name evidence の一致判定により、SubAgent causal-evidence を要求せず direct Skill invocation の発生を検証できる。--expect-marker-source main は --expect-skill-command を伴わない場合は usage error(non-PASS)として拒否される(--expect-marker-source main 単独での無条件 causal-evidence opt-out を禁止する)
  • AC5: 新引数を使わない既存呼び出し(--expect-marker + --require-subagent-causal-evidence あり/なし、および --expect-marker-source 省略時)の挙動に回帰がない(既存テスト全件 PASS)
  • AC6: 新規/既存テストで AC1〜AC5 をカバーする
  • AC7: 実際に review-issue Skill への direct /review-issue invocation を --expect-marker-source main --expect-skill-command review-issue 経由で観測し、SubAgent spawn が発生しないこと・non-fallback PASS が得られることを実機確認する。同一実行セットで既存 --expect-marker-source subagent(省略時デフォルト)経路の causal-evidence 強度が低下していないことも確認する

Verification Commands

# AC1
$ uv run --locked pytest scripts/agent-ops/tests/test_skill_invocation_runtime_smoke_profile.py::test_procedure_steps_executed_in_declared_order_ordered_evidence_match -v
# AC2
$ uv run --locked pytest scripts/agent-ops/tests/test_skill_invocation_runtime_smoke_profile.py::test_output_contract_schema_fields_present_full_schema_validation -v
# AC3
$ uv run --locked pytest scripts/agent-ops/tests/test_expect_marker_source_provenance.py::test_expect_marker_source_main_opts_out_of_causal_evidence -v
# AC4
$ uv run --locked pytest scripts/agent-ops/tests/test_expect_marker_source_provenance.py::test_expect_skill_command_native_user_prompt_expansion_evidence -v
# AC5
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -v
# AC6
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py scripts/agent-ops/tests/test_skill_invocation_runtime_smoke_profile.py scripts/agent-ops/tests/test_expect_marker_source_provenance.py -q
# AC7
$ uv run --locked pytest scripts/agent-ops/tests/test_expect_marker_source_provenance.py::test_live_skill_invocation_main_source_non_fallback_pass -v

補足(VC 設計ノート): AC1〜AC4/AC7 の Verification Command は、scripts/agent-ops/tests/ 配下に本 Issue の実装で新規作成する予定の 2 ファイル(test_skill_invocation_runtime_smoke_profile.py / test_expect_marker_source_provenance.py)に対する「未作成ファイル + 明示 node-id」形式で記述している。これは .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py の pytest exit code 分類(exit 4 の file-not-found は expected_baseline_fail/go、既存ファイルへの -k フィルタが 0 件マッチする exit 5 は vc_no_tests_collected として contract_readiness_check.py の分類表に未登録のため human_judgment にフォールバックする)という repo の決定論的ルールに基づく。既存ファイルへの -k フィルタや、既存ファイルに新規関数を追加する形(existing_file_missing_node_id_noncanonical、Issue #1285 / PR #1305 で禁止済み)は使わない。

Allowed Paths

  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py
  • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
  • scripts/agent-ops/tests/**

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合(本 Issue では skill-invocation-runtime-smoke / subagent-lifecycle-causal-evidence-smoke の assertion ID・スキーマ・型定義を指す)
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合(例: Issue 実装: review-issue.md と issue-reviewer.md の責務重複を解消し mutation経路を一本化する #2194 の AC7 書き換え自体を本 PR に含める必要が生じた場合)
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • UserPromptExpansion.command_source の実際の値が「main session direct invocation」を一意に識別できないと実機検証で判明した場合(--expect-skill-command の判定根拠を command_name 一致のみに縮退させて対応できない場合は human escalation)

補足(本 Issue 固有の追加 Stop Condition):

  • 動作検証 AC(AC7)の Verification Command が SKIP(pytest skip / exit 77 相当)を返した場合は直ちに作業を停止し、Issue comment に状況を記録する
  • fallback 経由でのみ「成功」する場合は直ちに作業を停止し、Issue comment に状況を記録する
  • 既存 subagent-lifecycle-causal-evidence-smoke 経路(--expect-marker-source subagent および省略時デフォルト)に回帰が生じる実装しかできないと判明した場合は直ちに作業を停止し、Issue comment に状況を記録する

Required Skills

なし

Required Design References

  • docs/dev/runtime-verification-policy.md(セクション10: SubAgent causal evidence 要件、セクション11: extension-surface risk-trigger policy)
  • docs/dev/extension-surface-runtime-policy.yaml(verification_profiles.skill-invocation-runtime-smoke / subagent-lifecycle-causal-evidence-smoke の既存宣言)
  • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py(causal_evidence_required / subagent_causal_evidence_verdict() 判定ロジック周辺)
  • .claude/skills/review-issue/schemas/review_issue_result_v1.json(AC2 が参照する canonical JSON Schema の実例)
  • Claude Code 公式ドキュメント(UserPromptExpansion の command_name / command_args / command_source フィールド仕様。command_source の値は "main" / "subagent" を明示的に区別する形で公式に列挙されていないため、AC4 の実装は command_name 一致のみを判定根拠とし、command_source の未確認な値域には依存しない)

Scope Delta(任意)

N/A

Background

Issue #2194(PR #2497 の紐付け Issue、現在 human escalation により停止中)は、write-capable standalone review-issue SubAgent(.claude/agents/review-issue.md)を削除し、canonical review UX を .claude/skills/review-issue/SKILL.md(main/root session 内 inline 実行、SubAgent 委譲なし)へ一本化する変更である。

この変更自体(PR #2497)は正しい設計判断だが、AC7 の literal Verification Command(scripts/agent-ops/run_worktree_agent_runtime_smoke.py --expect-marker ... --require-subagent-causal-evidence)は、SubAgent 委譲を前提とした causal-evidence 要件(docs/dev/runtime-verification-policy.md セクション10、docs/dev/extension-surface-runtime-policy.yaml の verification_profiles.subagent-lifecycle-causal-evidence-smoke)を要求するため、SubAgent 委譲のない inline Skill 実行アーキテクチャとは構造的に非両立で FAIL する。

独立した調査(codebase-investigator による current main 事実確認)で以下が確認されている:

  1. run_worktree_agent_runtime_smoke.py には causal_evidence_required = args.require_subagent_causal_evidence or (args.runtime == "claude" and bool(args.expect_marker)) という実装があり、--expect-marker を指定するだけで --require-subagent-causal-evidence の有無に関わらず causal-evidence 要件が既定強制される。回避オプションは argparse 上に存在しない。
  2. docs/dev/extension-surface-runtime-policy.yaml の verification_profiles.skill-invocation-runtime-smoke(assertion: procedure_steps_executed_in_declared_order / output_contract_schema_fields_present)は、SubAgent 委譲を前提としない Skill 実行を検証する意図の profile として policy YAML 上に宣言されているが、scripts/agent-ops/run_worktree_agent_runtime_smoke.py にも .claude/skills/**/SKILL.md 側にもこれらの assertion ID を実際に評価するコードが一切存在しない。
  3. output_contract_schema_fields_present が検証すべき domain output(例: REVIEW_ISSUE_RESULT_V1)については、.claude/skills/review-issue/schemas/review_issue_result_v1.json に既に full JSON Schema(draft/2020-12、required/properties 定義済み)が存在する。この既存 schema を source of truth として使うべきであり、runner 側に独自の required-key existence checker を新設すべきではない。
  4. SubagentStart / SubagentStop hook のペイロード schema は公式ドキュメント上で未確定(既知の documentation gap)であり、parent_tool_use_id は complete message 上でのみ main/subagent の区別に使える(streaming event では常に null)。UserPromptExpansion の command_name / command_args / command_source フィールドは公式に存在が確認されているが、command_source の具体的な値が main session direct invocation を一意に示すかは公式ドキュメント上で列挙されていない。このため、本 Issue の --expect-skill-command 実装は command_name 一致のみを判定根拠とし、command_source の未確認な値域には依存しない設計とする。

このため、Issue #2194 は自身の Allowed Paths(scripts/agent-ops/** を含まない)の中では AC7 を fallback なしで PASS させる手段を持たず、Stop Condition「Allowed Paths 外の変更が必要と判明した場合」に該当してエスカレーションされた。本 Issue はその runner 側の不足を解消する follow-up である。

anchor human comment(#2498 (comment))による REQUEST_CHANGES を受け、以下の方針転換を行った:

  • AC1 を「任意 SKILL.md の Markdown Procedure を runner が generic に解釈する」仕様から、「caller-supplied ordered evidence marker list と native evidence の照合」という runner の責務範囲内(runtime launch / observation / evidence collection)に縮退した
  • AC2 を「新規 required-key existence checker」から、「既存の canonical JSON Schema ファイルに対する full jsonschema.validate()」に置き換えた
  • AC3/AC4 を「--skill-invocation-lane のような Skill 固有 boolean opt-out」ではなく、「main/subagent の evidence provenance を表現する additive CLI 契約(--expect-marker-source / --expect-skill-command)」として再設計した。この際、公式ドキュメントで未確定な command_source の値域には依存せず、command_name 一致のみを判定根拠とした
  • Verification Commands のテストファイルパスを実際の scripts/agent-ops/tests/ へ修正し、VC preflight allowlist に適合しない uv run python3 直接呼び出しを uv run --locked pytest 経由の呼び出しへ修正した
  • Runtime Verification Applicability セクションに decision: immediate で必須の applicable_acs / execution_environment / skip_conditions / fallback_policy / artifact_requirements フィールドを追加した
  • Verification Commands(AC1/AC2/AC3/AC4/AC7)を、既存テストファイルへの -k フィルタ形式から、scripts/agent-ops/tests/ 配下の新規未作成ファイルを明示 node-id で参照する形式へ修正した(pytest exit 5 "no tests collected" は .claude/skills/issue-contract-review/scripts/contract_readiness_check.py の分類表に未登録のため human_judgment にフォールバックし、canonical_step2_route: step_5_operator_intervention_required を誘発することを repo 実装読解で確認したため。exit 4 "file or directory not found" は expected_baseline_fail/go に確実分類される)
  • Step 2.5 semantic design review(issue-design-reviewer)の指摘(severity: high)を受け、AC1 に専用 CLI 引数名 --expect-ordered-marker を明記し、AC4 に「--expect-marker-source main は --expect-skill-command との必須ペアであり、単独指定は usage error として拒否される」という明示規約を追加した。これにより --expect-marker-source main 単独が実質的な「causal-evidence 無条件 opt-out」に退化する設計上の抜け穴を塞いだ

Delivery Rule

1 Issue = 1 PR を原則とする。専用 worktree で作業し、Draft PR を既定とする。

Related

Activity

  1. squne121 commented on Sep 4, 2026

    @squne121
    OwnerAuthor

    結論

    REQUEST_CHANGES です。

    Issue #2498 が解こうとしている根本問題は正しいです。現在の runner は Claude structured lane で --expect-marker を指定しただけで SubAgent causal evidence を要求するため、main/root session 内で実行される inline Skill と構造的に噛み合いません。これは #2183 / PR #2220 で「SubAgent が出したと称する marker を parent が偽装する」false-positive を防ぐために導入された制約であり、inline Skill にまで同じ意味論を適用したことが問題です。

    ただし、#2498 の現在案は 「この誤った結合を外す」問題と「generic Skill runtime verifier を作る」問題を混ぜています。後者をそのまま実装すると、harness が肥大化する割に、AC1/AC2 を本当に証明できません。個人趣味開発で品質・有用性を優先するなら、もっと薄くできます。

    敵対的レビュー findings

    1. P0 — AC1 procedure_steps_executed_in_declared_order を generic runner で証明する契約は成立していません。
      現行 runtime-verification-policy.md は run_worktree_agent_runtime_smoke.py の責務を runtime 起動・観測・evidence 収集に限定し、semantic 判定は caller 所有としています。一方 実装: run_worktree_agent_runtime_smoke.py に skill-invocation-runtime-smoke profile を実装し causal-evidence 既定強制を opt-out 可能にする #2498 は runner 自身に、任意の SKILL.md の Procedure を読み、「実際にその意味上の手順が宣言順で実行された」と判断させようとしています。これは既存の責務境界に逆行します。
      さらに Claude Code の Skill は frontmatter + 任意の Markdown instructions です。「Procedure Step 2 を実行した」という native runtime event はありません。Claude 公式も Skill 評価では「Skill が呼ばれたか」と「呼ばれた結果が期待どおりか」を別々に測ることを推奨しています。(Claude) (Claude)
      ここを generic parser で実装すると、「Step 1 の文中にあるコマンドと似た tool event が先に出た」程度を手順実行の証明に読み替える危険があります。AC1 は runner から外し、必要な Skill ごとの domain verifier に委ねるのが妥当です。

    2. P0 — skill-invocation-runtime-smoke を評価するための入力契約が不足しています。
      実装: run_worktree_agent_runtime_smoke.py に skill-invocation-runtime-smoke profile を実装し causal-evidence 既定強制を opt-out 可能にする #2498 の AC6 command が runner に渡すのは worktree、prompt、marker、--skill-invocation-lane 程度で、どの Skill を検証するのか、どの output schema を使うのか、どの verification profile を選んだのかがありません。一方 policy YAML にある assertion ID は現状 YAML にしか存在しません。
      --skill-invocation-lane だけ追加しても「causal gate を無効化した main-session run」になるだけで、skill-invocation-runtime-smoke profile を実装したことにはなりません。

    3. P1 — causal-evidence opt-out は「Skill が実際に呼ばれた」証拠ではありません。
      ここは現在の Claude Code なら軽量に改善できます。公式 hook に UserPromptExpansion があり、/review-issue ... のような direct Skill invocation では command_name, command_args, command_source が取れます。しかも docs は、direct /skillname は PreToolUse:Skill を通らず UserPromptExpansion がその経路を観測すると明示しています。(Claude)
      対照的に SubagentStart は Agent tool で本当に SubAgent が spawn された時だけ発火します。(Claude)
      したがって 実装: review-issue.md と issue-reviewer.md の責務重複を解消し mutation経路を一本化する #2194 の smoke は、「SubAgent evidence を要求しない」だけでなく、UserPromptExpansion.command_name == "review-issue" を観測する方が証明として直接的です。追加の approval や重い guard は不要で、passive hook 一つで済みます。

    4. P1 — AC2 の「schema fields が全部ある」は既存契約より弱いです。
      review-issue には既に REVIEW_ISSUE_RESULT_V1 の JSON Schema があり、required fields だけでなく enum、型、SHA-256 pattern などまで定義されています。単なる key existence check を新設するのは品質低下です。
      既存 schema をそのまま jsonschema で validate するべきです。repo は既に jsonschema を dependency に持っているので追加依存も不要です。Claude Code 自体にも現在 --output-format json --json-schema があり、schema-constrained output を native に取得できます。(Claude)
      runner の stream-json observability を維持したいなら、Claude の --json-schema へ切り替える必要すらなく、terminal result から JSON を取り出して既存 schema validator に渡すだけで十分です。

    5. P1 — --skill-invocation-lane は abstraction が狭すぎます。
      問題の本質は Skill かどうかではなく、marker の provenance をどこに要求するかです。実際、repo 内には --claude-agent-name issue-creator で main-session persona を起動し、SubAgent を spawn せず --expect-marker を使っている runtime smoke が既にあります。これも 実装: review-issue.md と issue-reviewer.md の責務重複を解消し mutation経路を一本化する #2194 と同じ構造的不整合です。
      さらに Claude Code の Skill は context: fork を付ければ Skill 自体が SubAgent context で走れます。つまり「Skill lane = non-SubAgent」という分類も将来的に成立しません。(Claude)
      CLI を追加するなら --expect-marker-source main|subagent のような evidence provenance を表す名前の方が長期的に正しいです。

    6. P1 — Verification Commands に実際の不備があります。
      AC1/2/3/5 は tests/agent_ops/test_run_worktree_agent_runtime_smoke.py を参照していますが、実ファイルは scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py です。
      また AC4 の $ pnpm test は Vitest の JS/TS suite であり、Python runner の回帰を検証しません。
      さらに .github/ci/python-test-plan.json は既に scripts/agent-ops/tests/ ディレクトリ全体を target にしているため、そこへ新しい pytest file を置く場合に CI plan への追加登録は不要です。

    7. P2 — policy profile の generic evaluator を今回作ること自体が over-engineering です。
      extension-surface-runtime-policy.yaml 自身が policy definition と enforcement を分離しており、matcher も profile ID を返すところまでです。
      趣味開発の今回の目的は「実装: review-issue.md と issue-reviewer.md の責務重複を解消し mutation経路を一本化する #2194 の正しい inline Skill architecture を live で確認できること」です。ここで Markdown procedure interpreter / generic profile engine / 新しい receipt schema まで増やすのは、保守コストに対して得られる有用性が小さいです。

    推奨する再設計

    私なら #2498 の Outcome を「generic skill-invocation-runtime-smoke evaluator 実装」から、次の 観測 primitive の追加へ縮小します。

    証明したいこと | 推奨 evidence | 所有者 -- | -- | -- Skill が本当に起動した | direct /review-issue + UserPromptExpansion.command_name | runner が観測 main/root 内で実行された | SubAgent lifecycle 不在、main stream の parent_tool_use_id == null | runner が観測 SubAgent が必要なケース | SubagentStart/Stop + 現行 hook-ID causal evidence | 現行 runner を維持 final output が正しい | canonical JSON Schema validation | domain verifier/caller Procedure の意味上の順序 | Skill-specific deterministic checker が必要な場合だけ | domain verifier marker | completion diagnostic。source を main/subagent で明示 | runner

    Claude の stream-json は現在、SubAgent message に parent_tool_use_id、main conversation に null を付けるため、main/subagent の区別にも native evidence が使えます。(Claude)

    この構成なら、SubAgent に関する既存の causal-evidence 強度は一切落としません。単に「SubAgent を証明する必要がない実行に SubAgent の証明を要求しない」だけです。

    CLI はこうした方がよいです

    現在案:

    --skill-invocation-lane

    より、

    --expect-marker-source main
    --expect-skill-command review-issue

    のように、何を観測したいかを直接表す方がよいです。

    互換性を最優先するなら当面 --expect-marker 単独時の既存挙動を保持し、--expect-marker-source main だけを additive に追加できます。ただし中期的には、--expect-marker だけで SubAgent causal gate を暗黙発動する設計自体を廃止し、実際に child を証明したい caller が --require-subagent-causal-evidence / --require-min-subagents 1 を明示する形の方が分かりやすいです。repo の impl-review-loop docs も、実際に child delegation を証明するときは --require-min-subagents 1 と child marker を使う方向に既に寄っています。

    Verification Commands も修正すべきです

    少なくとも runner regression はこの系統にします。

    uv run --locked pytest \
      scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py \
      scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py \
      -q

    広く確認する最終 gate なら:

    uv run --locked pytest scripts/agent-ops/tests/ -q

    pnpm test は一般回帰として併用して構いませんが、AC4 の causal-evidence non-regression の証拠にはしない方がよいです。

    live AC は、自由文で「review-issue Skill を使って」とモデルに選ばせるより、non-interactive session でも利用できる canonical /review-issue command を明示的に起動し、UserPromptExpansion を捕捉する方が deterministic です。Claude Code の project Skill は .claude/skills/<name>/SKILL.md から /name として公開され、non-interactive session でも command namespace が存在します。(Claude)

    配布・ポータビリティ面

    もう一つ、SKILL.md 自体へ runtime-verifier 固有の metadata や procedure trace annotation を追加する方向にはしない方がよいです。Claude Code Skills は Agent Skills open standard を基礎にしており、Claude Code-specific extension もあります。(Claude)

    portable な Skill 本体は普通の SKILL.md のまま維持し、UserPromptExpansion 等の Claude Code 固有 observability は worktree-agent-runtime-smoke 側に閉じ込めるのが配布物としてきれいです。

    最終判定

    #2498 は 「実装開始してよい Issue」ではなく、一度 in-place refinement してから実装するのが妥当です。

    最優先で直すべきなのは、AC1 の generic procedure-order evaluator を runner から外すこと、AC2 を既存 JSON Schema validation に置き換えること、--skill-invocation-lane を単なる causal opt-out ではなく Skill invocation evidence / marker provenance の明示契約へ変えること、そして壊れている Verification Commands を修正することです。

    この形なら #2194 / PR #2497 の blocker を解消しつつ、#2183 で苦労して作った SubAgent causal evidence を弱めず、harness の肥大化も避けられます。

    ## 結論

    REQUEST_CHANGES です。

    Issue #2498 が解こうとしている根本問題は正しいです。現在の runner は Claude structured lane で --expect-marker を指定しただけで SubAgent causal evidence を要求するため、main/root session 内で実行される inline Skill と構造的に噛み合いません。これは #2183 / PR #2220 で「SubAgent が出したと称する marker を parent が偽装する」false-positive を防ぐために導入された制約であり、inline Skill にまで同じ意味論を適用したことが問題です。

    ただし、#2498 の現在案は 「この誤った結合を外す」問題と「generic Skill runtime verifier を作る」問題を混ぜています。後者をそのまま実装すると、harness が肥大化する割に、AC1/AC2 を本当に証明できません。個人趣味開発で品質・有用性を優先するなら、もっと薄くできます。

    敵対的レビュー findings

    1. P0 — AC1 procedure_steps_executed_in_declared_order を generic runner で証明する契約は成立していません。
      現行 runtime-verification-policy.md は run_worktree_agent_runtime_smoke.py の責務を runtime 起動・観測・evidence 収集に限定し、semantic 判定は caller 所有としています。一方 実装: run_worktree_agent_runtime_smoke.py に skill-invocation-runtime-smoke profile を実装し causal-evidence 既定強制を opt-out 可能にする #2498 は runner 自身に、任意の SKILL.md の Procedure を読み、「実際にその意味上の手順が宣言順で実行された」と判断させようとしています。これは既存の責務境界に逆行します。
      さらに Claude Code の Skill は frontmatter + 任意の Markdown instructions です。「Procedure Step 2 を実行した」という native runtime event はありません。Claude 公式も Skill 評価では「Skill が呼ばれたか」と「呼ばれた結果が期待どおりか」を別々に測ることを推奨しています。([Claude]1) (Claude)
      ここを generic parser で実装すると、「Step 1 の文中にあるコマンドと似た tool event が先に出た」程度を手順実行の証明に読み替える危険があります。AC1 は runner から外し、必要な Skill ごとの domain verifier に委ねるのが妥当です。

    2. P0 — skill-invocation-runtime-smoke を評価するための入力契約が不足しています。
      実装: run_worktree_agent_runtime_smoke.py に skill-invocation-runtime-smoke profile を実装し causal-evidence 既定強制を opt-out 可能にする #2498 の AC6 command が runner に渡すのは worktree、prompt、marker、--skill-invocation-lane 程度で、どの Skill を検証するのか、どの output schema を使うのか、どの verification profile を選んだのかがありません。一方 policy YAML にある assertion ID は現状 YAML にしか存在しません。
      --skill-invocation-lane だけ追加しても「causal gate を無効化した main-session run」になるだけで、skill-invocation-runtime-smoke profile を実装したことにはなりません。

    3. P1 — causal-evidence opt-out は「Skill が実際に呼ばれた」証拠ではありません。
      ここは現在の Claude Code なら軽量に改善できます。公式 hook に UserPromptExpansion があり、/review-issue ... のような direct Skill invocation では command_name, command_args, command_source が取れます。しかも docs は、direct /skillname は PreToolUse:Skill を通らず UserPromptExpansion がその経路を観測すると明示しています。([Claude]2)
      対照的に SubagentStart は Agent tool で本当に SubAgent が spawn された時だけ発火します。([Claude]2)
      したがって 実装: review-issue.md と issue-reviewer.md の責務重複を解消し mutation経路を一本化する #2194 の smoke は、「SubAgent evidence を要求しない」だけでなく、UserPromptExpansion.command_name == "review-issue" を観測する方が証明として直接的です。追加の approval や重い guard は不要で、passive hook 一つで済みます。

    4. P1 — AC2 の「schema fields が全部ある」は既存契約より弱いです。
      review-issue には既に REVIEW_ISSUE_RESULT_V1 の JSON Schema があり、required fields だけでなく enum、型、SHA-256 pattern などまで定義されています。単なる key existence check を新設するのは品質低下です。
      既存 schema をそのまま jsonschema で validate するべきです。repo は既に jsonschema を dependency に持っているので追加依存も不要です。Claude Code 自体にも現在 --output-format json --json-schema があり、schema-constrained output を native に取得できます。([Claude]3)
      runner の stream-json observability を維持したいなら、Claude の --json-schema へ切り替える必要すらなく、terminal result から JSON を取り出して既存 schema validator に渡すだけで十分です。

    5. P1 — --skill-invocation-lane は abstraction が狭すぎます。
      問題の本質は Skill かどうかではなく、marker の provenance をどこに要求するかです。実際、repo 内には --claude-agent-name issue-creator で main-session persona を起動し、SubAgent を spawn せず --expect-marker を使っている runtime smoke が既にあります。これも 実装: review-issue.md と issue-reviewer.md の責務重複を解消し mutation経路を一本化する #2194 と同じ構造的不整合です。
      さらに Claude Code の Skill は context: fork を付ければ Skill 自体が SubAgent context で走れます。つまり「Skill lane = non-SubAgent」という分類も将来的に成立しません。([Claude]1)
      CLI を追加するなら --expect-marker-source main|subagent のような evidence provenance を表す名前の方が長期的に正しいです。

    6. P1 — Verification Commands に実際の不備があります。
      AC1/2/3/5 は tests/agent_ops/test_run_worktree_agent_runtime_smoke.py を参照していますが、実ファイルは scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py です。
      また AC4 の $ pnpm test は Vitest の JS/TS suite であり、Python runner の回帰を検証しません。
      さらに .github/ci/python-test-plan.json は既に scripts/agent-ops/tests/ ディレクトリ全体を target にしているため、そこへ新しい pytest file を置く場合に CI plan への追加登録は不要です。

    7. P2 — policy profile の generic evaluator を今回作ること自体が over-engineering です。
      extension-surface-runtime-policy.yaml 自身が policy definition と enforcement を分離しており、matcher も profile ID を返すところまでです。
      趣味開発の今回の目的は「実装: review-issue.md と issue-reviewer.md の責務重複を解消し mutation経路を一本化する #2194 の正しい inline Skill architecture を live で確認できること」です。ここで Markdown procedure interpreter / generic profile engine / 新しい receipt schema まで増やすのは、保守コストに対して得られる有用性が小さいです。

    推奨する再設計

    私なら #2498 の Outcome を「generic skill-invocation-runtime-smoke evaluator 実装」から、次の 観測 primitive の追加へ縮小します。

    証明したいこと 推奨 evidence 所有者
    Skill が本当に起動した direct /review-issue + UserPromptExpansion.command_name runner が観測
    main/root 内で実行された SubAgent lifecycle 不在、main stream の parent_tool_use_id == null runner が観測
    SubAgent が必要なケース SubagentStart/Stop + 現行 hook-ID causal evidence 現行 runner を維持
    final output が正しい canonical JSON Schema validation domain verifier/caller
    Procedure の意味上の順序 Skill-specific deterministic checker が必要な場合だけ domain verifier
    marker completion diagnostic。source を main/subagent で明示 runner

    Claude の stream-json は現在、SubAgent message に parent_tool_use_id、main conversation に null を付けるため、main/subagent の区別にも native evidence が使えます。(Claude)

    この構成なら、SubAgent に関する既存の causal-evidence 強度は一切落としません。単に「SubAgent を証明する必要がない実行に SubAgent の証明を要求しない」だけです。

    CLI はこうした方がよいです

    現在案:

    --skill-invocation-lane
    

    より、

    --expect-marker-source main
    --expect-skill-command review-issue
    

    のように、何を観測したいかを直接表す方がよいです。

    互換性を最優先するなら当面 --expect-marker 単独時の既存挙動を保持し、--expect-marker-source main だけを additive に追加できます。ただし中期的には、--expect-marker だけで SubAgent causal gate を暗黙発動する設計自体を廃止し、実際に child を証明したい caller が --require-subagent-causal-evidence / --require-min-subagents 1 を明示する形の方が分かりやすいです。repo の impl-review-loop docs も、実際に child delegation を証明するときは --require-min-subagents 1 と child marker を使う方向に既に寄っています。

    Verification Commands も修正すべきです

    少なくとも runner regression はこの系統にします。

    uv run --locked pytest \
      scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py \
      scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py \
      -q

    広く確認する最終 gate なら:

    uv run --locked pytest scripts/agent-ops/tests/ -q

    pnpm test は一般回帰として併用して構いませんが、AC4 の causal-evidence non-regression の証拠にはしない方がよいです。

    live AC は、自由文で「review-issue Skill を使って」とモデルに選ばせるより、non-interactive session でも利用できる canonical /review-issue command を明示的に起動し、UserPromptExpansion を捕捉する方が deterministic です。Claude Code の project Skill は .claude/skills/<name>/SKILL.md から /name として公開され、non-interactive session でも command namespace が存在します。(Claude)

    配布・ポータビリティ面

    もう一つ、SKILL.md 自体へ runtime-verifier 固有の metadata や procedure trace annotation を追加する方向にはしない方がよいです。Claude Code Skills は Agent Skills open standard を基礎にしており、Claude Code-specific extension もあります。(Claude)

    portable な Skill 本体は普通の SKILL.md のまま維持し、UserPromptExpansion 等の Claude Code 固有 observability は worktree-agent-runtime-smoke 側に閉じ込めるのが配布物としてきれいです。

    最終判定

    #2498 は 「実装開始してよい Issue」ではなく、一度 in-place refinement してから実装するのが妥当です。

    最優先で直すべきなのは、AC1 の generic procedure-order evaluator を runner から外すこと、AC2 を既存 JSON Schema validation に置き換えること、--skill-invocation-lane を単なる causal opt-out ではなく Skill invocation evidence / marker provenance の明示契約へ変えること、そして壊れている Verification Commands を修正することです。

    この形なら #2194 / PR #2497 の blocker を解消しつつ、#2183 で苦労して作った SubAgent causal evidence を弱めず、harness の肥大化も避けられます。

  2. squne121 commented on Sep 4, 2026

    @squne121
    OwnerAuthor

    推奨は、#2498 を実装へ進めず、指定コメントを human-context anchor にして in-place refinement を完走させることです。現在の issue-refinement-loop は反復ごとの人間承認を既定で要求せず、anchor_comment_url を入力として扱えます。調査は codebase-investigator、rewrite は issue-editor が担当し、Step 2 の canonical review は issue-reviewer SubAgent ではなく root-owned pipeline です。

    指定コメントの主要指摘は現行 main と整合しています。--expect-marker が Claude lane で暗黙に SubAgent causal evidence を要求する実装が現存し、procedure_steps_executed_in_declared_order / output_contract_schema_fields_present は policy YAML にしか実装参照がありません。一方、既存の REVIEW_ISSUE_RESULT_V1 full JSON Schema validator と正しい runner test 群は既に存在し、scripts/agent-ops/tests/ 自体が CI target です。

    また現行 Claude Code 公式仕様でも、direct /skillname は PreToolUse:Skill を通らず UserPromptExpansion で観測でき、command_name / command_args / command_source が得られます。stream-json では main conversation の parent_tool_use_id は null、SubAgent message は spawn 元 tool call ID になります。したがってコメントが提案する「generic Markdown procedure verifier ではなく native observability を使う」という方向が妥当です。([Claude]1) ([Claude]2)

    以下をそのまま Claude Code の auto mode の対話セッションへ貼るのを推奨します。

    Issue #2498 を issue-refinement-loop で refinement してください。

    対象:

    このタスクの目的は Issue #2498 の契約を implementation-ready になるまで in-place refinement することです。
    実装、branch 作成、code change、PR 作成には進まないでください。
    refinement が成功して implementation_ready になった時点で終了してください。

    Human approval policy

    この anchor comment は owner/human が直接指定した refinement feedback として扱ってください。

    issue-refinement-loop の
    loop_iteration_approval_gate.default_required: false
    に従い、needs-fix iteration 間の人間承認を要求せず自動継続してください。

    以下について人間に確認を求めないでください。

    • 次 iteration へ進むか
    • reviewer finding を Issue 本文へ反映するか
    • deterministic / semantic rewrite を適用するか
    • focused verification を実行するか
    • fresh review を再実行するか

    Claude Code 自体の permission model と repo の loop approval policy は混同しないでください。
    auto mode のまま作業し、permission bypass のために設定を書き換えたり --dangerously-skip-permissions 等へ切り替えたりしないでください。

    repo evidence で解決可能な判断は自律的に解決してください。

    Anchor handling

    anchor comment は direct human context として扱ってください。

    canonical workflow が要求する場合は
    preflight.run.with_human_context
    および、それが生成した trusted contract patch plan に対する
    contract_update.run.with_human_context
    の正規経路を使用してください。

    agent-report lane や unlabeled anchor lane に読み替えないでください。

    mutation 前には current Issue body / updatedAt / body hash を再取得し、stale snapshot を使用しないでください。

    必須 SubAgent 方針

    SubAgent を使用してください。

    1. codebase-investigator

    最初の investigation では codebase-investigator SubAgent を起動してください。

    codebase-investigator の作業完了を必ず待ってください。
    完了前に review / rewrite へ進んではいけません。

    最低限、current main で以下を再確認させてください。

    特に以下を current main で事実確認してください。

    1. --expect-marker と SubAgent causal-evidence gate の現在の結合条件
    2. skill-invocation-runtime-smoke profile の assertion ID がどこで実際に評価されているか
    3. generic Procedure-order assertion を runner が意味的に証明できる native evidence が存在するか
    4. canonical full JSON Schema validator が既に存在するか
    5. runner regression test の正しいパス
    6. .github/ci/python-test-plan.json が scripts/agent-ops/tests/ directory を既に包含しているか
    7. main-session / SubAgent provenance を既存 runner がどこまで native evidence から取得できるか

    調査結果を推測で補わないでください。

    2. web-researcher

    planner が web research required と判定するか、anchor comment 中の Claude Code runtime API / hooks に関する external claim が disposition に影響する場合は web-researcher SubAgent を起動してください。

    web-researcher の作業完了を必ず待ってください。

    一次情報を優先し、Claude Code 公式ドキュメントで最低限以下を確認してください。

    • UserPromptExpansion

      • direct /skillname invocation の観測経路
      • command_name
      • command_args
      • command_source
    • PreToolUse:Skill と direct slash invocation の違い

    • SubagentStart / SubagentStop

    • stream-json の parent_tool_use_id

    • main conversation と SubAgent message の識別方法

    • Skill の context: fork

    • 必要なら --output-format json --json-schema

    ブログや推測より公式仕様を優先してください。

    3. canonical review

    Step 2 review は current issue-refinement-loop 契約に従って root-owned canonical review pipeline を使用してください。

    legacy issue-reviewer SubAgent を canonical Step 2 の代替として起動しないでください。

    SubAgent を使えという本指示を理由に、廃止済みの orchestration topology を復活させないでください。

    4. issue-editor

    review が needs-fix を返し rewrite が必要になった場合は、canonical routing が要求する issue-editor SubAgent を使用してください。

    issue-editor の作業完了を必ず待ってください。

    issue-editor 完了前に fresh preflight / review を開始しないでください。

    既存 Issue の mutation は repo の controlled edit-issue transaction 経路を使い、raw gh issue edit による迂回を行わないでください。

    nested SubAgent delegation は行わないでください。

    Anchor comment の disposition

    anchor comment の REQUEST_CHANGES を単なる参考意見として無視しないでください。

    ただし recommended fix を機械的に転記するのではなく、codebase-investigator と必要な web research の current evidence に照らして Issue contract に反映してください。

    現時点の推奨 refinement direction は次です。

    A. generic Procedure interpreter を作らない

    現在の AC1
    procedure_steps_executed_in_declared_order
    を、任意の SKILL.md の Markdown Procedure を runner が generic に解釈して証明する仕様にはしないでください。

    native runtime evidence で証明できない semantic procedure-order assertion を runner の責務にしないでください。

    必要なら Skill-specific deterministic verifier / caller-owned verification として責務を分離してください。

    B. key-presence checker を新設しない

    現在の
    output_contract_schema_fields_present
    を単なる required-key existence checker として新規実装しないでください。

    既に canonical JSON Schema が存在する domain output については full JSON Schema validation を source of truth としてください。

    ただし generic domain schema validation engine を runner に押し込まないでください。
    runner は runtime launch / observation / evidence collection の責務境界を維持してください。

    C. causal evidence の「opt-out」ではなく provenance を表す

    --skill-invocation-lane のような Skill 固有 boolean abstraction を第一候補にしないでください。

    問題を
    「marker / evidence を main session と SubAgent のどちらに帰属させるか」
    としてモデル化してください。

    current implementation と compatibility を調査した上で、例えば次のような additive contract を検討してください。

    • --expect-marker-source main|subagent
    • --expect-skill-command review-issue

    名称は current CLI naming convention と整合するものに最終決定して構いません。

    重要なのは、名前ではなく以下の意味論です。

    • main source:
      SubAgent causal evidence を要求しない
    • subagent source:
      現行の強い hook-ID / Agent tool invocation / transcript / marker provenance validation を維持する
    • skill command expectation:
      direct Skill invocation が実際に観測されたことを native Claude Code evidence で検証する
    • legacy invocation:
      backward compatibility を意図せず壊さない

    今回の refinement では、可能なら --expect-marker 単独の既存挙動を維持した additive change を優先してください。
    暗黙 causal gate 全廃のような広い migration は、本 Issue の blocker 解消に不要なら scope を広げないでください。

    D. #2194 の live proof を deterministic にする

    #2194 / PR #2497 が本当に必要としている証明へ contract を寄せてください。

    期待する live evidence は概ね次です。

    • canonical direct /review-issue invocation が発生した
    • UserPromptExpansion.command_name == review-issue 等の native evidence で invocation を確認できる
    • execution が main/root session に帰属する
    • review-issue 用 SubAgent spawn が発生していない
    • expected completion marker が main source から観測される
    • existing SubAgent-required lane の causal-evidence 強度は低下していない

    自由文でモデルに Skill を選ばせる smoke より、direct invocation を使った deterministic smoke を優先してください。

    E. Verification Commands を修正する

    current repo を確認した上で、少なくとも Python runner regression は正しい test path に直してください。

    候補:

    uv run --locked pytest \
      scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py \
      scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py \
      -q

    広い runner regression gate の候補:

    uv run --locked pytest scripts/agent-ops/tests/ -q

    pnpm test を一般回帰として残すこと自体は構いませんが、
    Python causal-evidence non-regression の主証拠にはしないでください。

    .github/ci/python-test-plan.json が既に scripts/agent-ops/tests/ directory を target としていることが確認できた場合、新規 test file を同 directory に追加するだけの理由で test-plan を変更対象にしないでください。

    Scope の目標

    refinement 後の #2498 は、可能な限り薄い Issue にしてください。

    概ね以下を In Scope とする方向を優先してください。

    以下は Out of Scope を優先してください。

    docs/dev/extension-surface-runtime-policy.yaml の既存 profile definition を変更する必要が本当にあるかは調査してください。
    単に policy assertion が generic runtime evaluator を意味しないよう clarification が必要というだけなら、本 Issue で policy schema を変更する方向へ安易に拡大しないでください。

    Allowed Paths / Stop Conditions の refinement

    Allowed Paths は actual implementation need に合わせて最小化してください。

    候補:

    • scripts/agent-ops/run_worktree_agent_runtime_smoke.py
    • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
    • scripts/agent-ops/tests/**

    current evidence により追加 path が本当に必要と証明された場合のみ追加してください。

    通常の refinement / rewrite / test-command correction を人間停止条件にしないでください。

    ただし以下は canonical policy に従い fail-closed してください。

    • repository evidence だけでは解けない genuine owner/product decision
    • destructive operation が必要
    • secret / credential の入力・開示が必要
    • nested SubAgent delegation が必要
    • unrelated Issue / PR の mutation が必要
    • scope を大幅に拡張しないと blocker を解消できない
    • external permission escalation が必要
    • current repo contract が明示的に human judgment を要求する

    「少し判断が難しい」だけで human_judgment_required にしないでください。
    調査、公式 docs、既存 tests、related Issue/PR から解けるものは自律的に disposition してください。

    Iteration sequencing

    各 iteration は必ず次の順で進めてください。

    1. fresh preflight / planner
    2. 必要な SubAgent investigation
    3. 起動した SubAgent の完了を待つ
    4. conditional web research
    5. web-researcher を起動した場合は完了を待つ
    6. canonical root-owned review
    7. needs-fix なら canonical rewrite routing
    8. issue-editor を起動した場合は 完了を待つ
    9. GitHub の fresh readback
    10. fresh preflight / review
    11. 次 iteration

    SubAgent を background に投げたまま、その結果を待たず次 phase へ進まないでください。

    複数 SubAgent の結果に依存する phase では、必要な全 SubAgent が terminal state になったことを確認してから進んでください。

    Completion gate

    refinement 完了条件は単なる reviewer approve ではありません。

    current repo の canonical final gate に従い、

    • canonical review が approve
    • latest contract review が status: go
    • freshness が確認済み

    のすべてを満たしたときだけ implementation_ready としてください。

    Issue body を rewrite した場合は stale な prior review / readiness result を再利用しないでください。

    implementation_ready になったらそこで停止してください。

    このセッションでは impl-review-loop を開始しないでください。
    PR を作らないでください。
    #2194 / PR #2497 を変更しないでください。

    最後に簡潔に以下を報告してください。

    途中の通常判断について人間承認を求めず、canonical stop condition に達するまで自律的に進めてください。

    このプロンプトでは、「無人化するために repo の fail-closed 規則を無効化する」のではなく、通常の review/rewrite iteration だけを無人化しています。#2498 は最大3 iterationで implementation_ready まで持っていき、そこから先の実装は別セッションに切るのが現在の workflow と最も整合します。

  3. squne121 commented on Sep 4, 2026

    @squne121
    OwnerAuthor

    Refinement Loop Termination: approved

    issue-refinement-loop(anchor human context, iterative rewrite: 3 body revisions)が本 Issue を implementation_ready として終了する。

    経緯サマリ

    1. codebase-investigator による current main 事実確認(テストパス実在確認、既存 canonical JSON Schema の実在確認、--expect-marker causal-evidence 既定強制の実装確認、Issue 実装: review-issue.md と issue-reviewer.md の責務重複を解消し mutation経路を一本化する #2194/実装: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定と runtime verification policy 更新を導入する #2183/PR refactor: review-issue Skill へ mutation 経路を一本化し standalone Agent を削除 (#2194) #2497/feat: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定を追加する #2220 の関係確認)
    2. web-researcher による Claude Code 公式仕様の一次資料確認(UserPromptExpansion フィールド仕様、parent_tool_use_id、SubagentStart/SubagentStop の documentation gap、context: fork の既知の制限)
    3. anchor human comment(owner REQUEST_CHANGES、実装: run_worktree_agent_runtime_smoke.py に skill-invocation-runtime-smoke profile を実装し causal-evidence 既定強制を opt-out 可能にする #2498 (comment))の全指摘を repo evidence で検証の上、Issue 契約を全面的に縮小・再設計(issue-editor 経由、3 回の body rewrite)
    4. canonical deterministic review(run_root_review_pipeline.py): 初回 needs-fix(8 blockers: RVA 必須フィールド欠落、VC allowlist 違反)→ 修正後 needs-fix(VC の pytest exit-5 分類問題、canonical_step2_route: step_5_operator_intervention_required)→ repo 実装読解(baseline_vc_preflight.py / contract_readiness_check.py の pytest exit code 分類表)に基づき自律修正 → approve
    5. Step 2.5 semantic design review(issue-design-reviewer): 1 回目で severity: high finding(--expect-marker-source main 単独指定が無条件 causal-evidence opt-out に退化しうる設計上の抜け穴)→ 修正(--expect-skill-command との必須ペア化、--expect-ordered-marker 専用引数名の明記)→ 2 回目で high finding 解消確認、残る medium/low finding は non-blocking warning として記録(join_review_results.py effective_verdict: approve)
    6. 最終ゲート(run_contract_review_once.py --mode execute --evidence-mode baseline): status: go、readiness: go、vc_preflight: pass、blockers: pass、product_spec: pass

    Anchor REQUEST_CHANGES 主要指摘の disposition

    指摘 disposition
    A. AC1 generic Procedure interpreter禁止 反映済み。caller-supplied ordered-evidence-match(--expect-ordered-marker)に縮退し、runner は SKILL.md を汎用解釈しない
    B. AC2 key-presence checker禁止 反映済み。既存 canonical JSON Schema(.claude/skills/review-issue/schemas/review_issue_result_v1.json)への jsonschema.validate() full validation(--output-schema-path)に置換
    C. causal evidence の provenance化(boolean opt-out禁止) 反映済み。`--expect-marker-source main
    D. #2194 live proof の deterministic化 反映済み。AC7 を --expect-marker-source main --expect-skill-command review-issue 経由の direct /review-issue invocation smoke に変更
    E. Verification Commands 修正 反映済み。テストパスを実在する scripts/agent-ops/tests/ へ修正。加えて pytest exit-5(no tests collected)が repo の readiness checker で human_judgment にフォールバックする実装上の制約を発見し、新規テストファイル + 明示 node-id 参照(exit 4 パターン)へ再修正

    Final Gate

    • CONTRACT_REVIEW_RESULT_V1.status: go
    • readiness: go / vc_preflight: pass / blockers: pass / product_spec: pass
    • checked_body_sha256: sha256:b0f9909a44161c62cb1a071f9ff26cb0d90a93f52411326d1259bfc5a8200f2e
    • Issue body updatedAt: 2026-09-04T22:47:33Z(この gate 実行後、本文への追加変更なし)

    Handoff

    impl-review-loop への自動起動(root_entry_router.py による run_root_transition())は、このセッションでは明示的に見送っている(呼び出し元からの指示: 本セッションでは impl-review-loop を開始しない)。次のセッションで /impl-review-loop 2498 を実行することで実装フェーズへ進める。

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: none
        generated_at: "2026-09-04T22:59:18Z"
        body_sha256: "sha256:b0f9909a44161c62cb1a071f9ff26cb0d90a93f52411326d1259bfc5a8200f2e"
      metadata:
        title_prefix_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-09-04T22:59:18Z"
      checked_body_sha256: "sha256:b0f9909a44161c62cb1a071f9ff26cb0d90a93f52411326d1259bfc5a8200f2e"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []

    Note: routing_action: run_impl_review_loop は canonical policy 上の推奨アクションの記録であり、本セッションでは呼び出し元の明示指示によりこの turn 内で自動実行しない(root_entry_router.py 未実行)。

  4. squne121 commented on Sep 5, 2026

    @squne121
    OwnerAuthor

    推奨アクションは、#2498 を新しい Claude Code の interactive auto mode セッションでそのまま impl-review-loop に投入することです。refinement はすでに完了しており、最終 handoff は status: impl_ready / routing_action: run_impl_review_loop、contract review も status: go です。したがって issue-refinement-loop へ戻す必要はありません。

    ただし、過去の handoff comment を実装 authorization として再利用するのではなく、現行 impl-review-loop の Root-Owned Synchronous Entry Transition に従い、同一 invocation 内で live Issue → fresh contract review → live readback → Step 1 と進ませるのが適切です。また現行 loop は approved 到達後も PR を自動マージせず、人間のマージ判断へ渡す設計なので、「マージ直前まで無承認」という目的とそのまま一致します。

    SubAgent については単に「使う」と書くだけではなく、final result の取得と canonical task の terminal completed の両方を確認するまで次 phase に進まないことを明示するのが重要です。特に test-runner は、この完了確認が Step 4 起動条件として明文化されています。

    以下をそのまま貼るのを推奨します。

    Issue #2498 を、current main の canonical impl-review-loop で実装してください。

    対象:

    目的は、Issue #2498 について

    実装 → 独立検証 → PR 作成 → PR review → REQUEST_CHANGES 修正 → 再検証 → 再review

    を、人間の逐次承認なしで自律的に反復し、マージ可能な PR が完成した直後、実際の merge 操作を行う前で停止することです。

    最重要方針

    通常の iteration の進行について、人間に確認を求めないでください。

    以下について「進めてよいですか」「修正しますか」「次の iteration に進みますか」等の承認要求をしないでください。

    • Step 1 Implementation の開始
    • Allowed Paths 内のコード変更
    • テスト追加・修正
    • Verification Commands の実行
    • commit
    • 対象 worktree branch の push
    • PR 作成・更新
    • canonical workflow が要求する PR metadata / body の修正
    • test-runner の再実行
    • pr-reviewer の再実行
    • REQUEST_CHANGES の fix
    • stale head の再review
    • BEHIND に対する canonical update-branch
    • required CI の待機・再取得
    • 次 iteration への遷移

    repo evidence、Issue contract、tests、CI、review result から決定できる通常判断は自律的に解決してください。

    ただし、無人化のために safety boundary を無効化してはいけません。

    Claude Code は現在の auto mode のまま使用してください。

    • permission 設定を書き換えない
    • --dangerously-skip-permissions 等へ切り替えない
    • guard / hook / repo policy を無効化しない
    • denied action があれば、contract 内で可能なより安全な正規経路をまず試す
    • genuine hard blocker の場合だけ停止する

    Entry — fresh contract を必ず使う

    過去の LOOP_HANDOFF_RESULT_V1 や過去の CONTRACT_REVIEW_RESULT_V1 だけを根拠に Step 1 を直接起動しないでください。

    current impl-review-loop の Root-Owned Synchronous Entry Transition に従い、同一の継続した root/main control flow 内で、

    1. capability preflight
    2. live Issue 実装: run_worktree_agent_runtime_smoke.py に skill-invocation-runtime-smoke profile を実装し causal-evidence 既定強制を opt-out 可能にする #2498 fetch
    3. current-run issue-contract-review
    4. live Issue の再取得
    5. current routing decision
    6. route が implementation 起動を許可した場合のみ Step 1

    の順で進めてください。

    fresh contract review が invoke_impl_review_loop 相当へ到達できない場合は、古い impl_ready comment を使って強行しないでください。

    ただし artifact / snapshot / advisory metadata の欠落だけを理由に不要な human escalation を作らず、current repo の canonical routing に従ってください。

    Issue #2498 は refinement 済みなので、fresh live contract が implementation-ready である限り、通常は issue-refinement-loop に戻らず implementation を開始してください。

    Issue contract の扱い

    実装開始時に Issue #2498 の 現在の本文を再取得し、それを literal contract として使用してください。

    このプロンプト内の要約より live Issue 本文を優先してください。

    特に current contract の以下を維持してください。

    • --expect-ordered-marker は --expect-marker と独立した repeatable input
    • ordered marker expectation 自体は SubAgent causal-evidence default enforcement を発火させない
    • arbitrary SKILL.md Markdown Procedure の generic interpreter を作らない
    • --output-schema-path は既存 canonical JSON Schema に対する full jsonschema.validate() を使用する
    • required-key existence だけの独自 validator を作らない
    • --expect-marker-source main|subagent を additive に実装する
    • source 省略時の legacy behavior は既存 subagent semantics と互換にする
    • --expect-marker-source main は --expect-skill-command <name> と必須ペア
    • main 単独指定を causal-evidence の無条件 opt-out にしない
    • direct Skill invocation は native UserPromptExpansion.command_name evidence で確認する
    • command_source の未保証な値域に correctness を依存させない
    • existing SubAgent causal-evidence path の強度を低下させない
    • generic semantic Skill evaluator / generic profile execution engine / persistent ledger / receipt framework を新設しない

    Allowed Paths は live Issue #2498 の宣言を厳守してください。

    原則として変更対象は次に閉じてください。

    • scripts/agent-ops/run_worktree_agent_runtime_smoke.py
    • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
    • scripts/agent-ops/tests/**

    Issue 本文が current contract として許可していない別領域へ変更を広げないでください。

    Issue #2194 / PR #2497 自体の変更はこの PR に混ぜないでください。

    Mandatory SubAgent execution

    impl-review-loop の canonical topology に従って SubAgent を必ず使用してください。

    root/main thread が control-plane を担当し、実装・検証・PR review を root が横取りしないでください。

    Step 1 — implementation-worker

    implementation-worker SubAgent を起動し、implement-issue の canonical procedure を実行させてください。

    実際の Issue number、Issue URL、Allowed Paths、current fix_delta 等を materialize して渡してください。

    placeholder のまま child に渡さないでください。

    implementation-worker の作業完了を必ず待ってください。

    Step 2 — test-runner

    implementation と PR 作成後、current PR head に対して test-runner SubAgent を起動してください。

    live Issue #2498 の Acceptance Criteria と Verification Commands を文字列どおり取得し、その head に bind して渡してください。

    test-runner は read-only independent verification とし、current head SHA と literal Verification Command の binding を確認してください。

    test-runner の作業完了を必ず待ってください。

    test-runner 完了前に pr-reviewer を起動してはいけません。

    Step 4 — pr-reviewer

    current-head verification gate が nonblocking であることを確認した場合のみ、pr-reviewer SubAgent を起動してください。

    PR diff、Issue contract、current head、verification evidence を対象として canonical PR review を実行させてください。

    pr-reviewer の作業完了を必ず待ってください。

    SubAgent completion protocol

    起動したすべての SubAgent について、次の規則を守ってください。

    1. spawn_agent の戻り値から canonical task_name を保存する
    2. wait_agent の mailbox activity、途中 update、steer、timeout を completion とみなさない
    3. 対象 task の final result を必ず取得して消費する
    4. その後 list_agents で同じ canonical task_name が terminal completed であることを確認する
    5. final result と terminal completed の両方が揃った場合だけ、その SubAgent の Step を完了扱いにする
    6. 複数 SubAgent の結果に依存する場合は、必要な全 task の完了を待つ
    7. SubAgent を background に残したまま次 phase へ進まない

    errored、interrupted、lifecycle integrity failure 等は canonical recovery/routing に従ってください。

    Issue #2498 の Stop Conditions に従い、nested SubAgent delegation は行わないでください。

    必要な追加調査がある場合も root/main から直接委譲してください。

    Verification

    Issue #2498 の Verification Commands を live Issue から再取得し、literal command contract として扱ってください。

    最低限、

    • AC1 ordered evidence matching
    • AC2 canonical JSON Schema full validation
    • AC3 marker source provenance
    • AC4 native Skill command evidence + invalid pairing rejection
    • AC5 legacy regression
    • AC6 focused combined suite
    • AC7 live runtime verification

    を current PR head で成立させてください。

    特に AC7 は runtime verification なので、unit test の mock PASS だけで代用しないでください。

    AC7 では current Issue contract が要求する direct /review-issue invocation を使い、

    • --expect-marker-source main
    • --expect-skill-command review-issue
    • native invocation evidence
    • expected marker
    • review-issue 用 SubAgent spawn がないこと
    • non-fallback PASS

    を current head で実証してください。

    同じ implementation によって、既存 subagent source / source省略時の causal-evidence enforcement が弱くなっていないことも確認してください。

    Issue contract に従い、

    • AC7 が SKIP
    • fallback 経由でしか PASS しない
    • existing SubAgent causal-evidence path に regression

    のいずれかであれば、PASS と偽装せず canonical Stop Condition として扱ってください。

    Review / fix loop

    pr-reviewer が REQUEST_CHANGES を返した場合は、人間に確認せず次 iteration へ進んでください。

    blockers を exact fix_delta として implementation-worker に渡し、

    implementation-worker
    → test-runner
    → current-head verification gate
    → pr-reviewer
    → routing

    を再実行してください。

    reviewed head と current PR head が不一致なら、人間に聞かず current head で再reviewしてください。

    PR が BEHIND の場合、canonical router が update_branch を選択したなら、implementation-worker に mechanical update を委譲し、その完了を待ってから verification と PR review を両方再実行してください。

    UNKNOWN / BLOCKED / UNSTABLE / DRAFT 等については、それ自体を即 human escalation に変換せず、current impl-review-loop の bounded retry / current-head CI evaluator / canonical routing に従ってください。

    SubAgent が単に human_review_required: true boolean を自己申告しただけでは停止しないでください。

    停止権限を持つ canonical result / hard condition と区別してください。

    Human stop conditions

    通常の implementation/review iteration では人間を呼ばないでください。

    ただし以下は強行せず停止してください。

    「判断が少し難しい」「artifact が不足した」「reviewer が warning を返した」というだけで停止しないでください。

    repo、tests、official docs、live GitHub state から決定できるものは自律的に解決してください。

    PR / CI completion gate

    PR 作成後は required CI を current head に対して確認してください。

    head が変わった場合、古い verification / review / CI evidence を current evidence として再利用しないでください。

    必要な current-head verification と review を再実行してください。

    pr-reviewer の APPROVE 単独を完了条件にしないでください。

    canonical route_loop_verdict_v2() が approved を返すために必要な、

    • current reviewed head == current PR head
    • independent Verification Commands が current head で nonblocking
    • required CI が current head で PASS
    • reviewer verdict == APPROVE
    • blockers == []
    • live mergeability が approvable
    • actual Git conflict がない

    をすべて確認してください。

    マージ直前で必ず停止

    route_loop_verdict_v2() が approved となり、PR が人間の merge 判断へ渡せる状態になったら そこで終了してください。

    以下は絶対に実行しないでください。

    PR を ready-for-review にすることが canonical loop の必要な mechanical step なら、merge 以外は通常の loop として完了させて構いません。

    最終状態は、

    「このまま人間が Merge を実行できる直前」

    にしてください。

    最終報告

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

    • termination reason
    • iterations used
    • Issue 実装: run_worktree_agent_runtime_smoke.py に skill-invocation-runtime-smoke profile を実装し causal-evidence 既定強制を opt-out 可能にする #2498 の current contract review status
    • PR number / URL
    • branch
    • current head SHA
    • changed files
    • Allowed Paths compliance
    • AC1〜AC7 の結果
    • AC7 が non-fallback runtime PASS であること
    • required CI status
    • final pr-reviewer verdict
    • reviewed_head_sha
    • blockers
    • warnings
    • live mergeability / merge_state_status
    • route_loop_verdict_v2() の最終 route
    • 起動した全 SubAgent の task_name / role / final status
    • 各 SubAgent の final result を取得し terminal completed を確認してから次 phase へ進んだこと
    • merge は実行していないこと
    • 人間に残された次アクションが「PR を確認して Merge すること」だけであるか

    通常の途中判断では人間承認を要求せず、canonical hard stop または approved 到達まで自律的に進めてください。

    この形なら、#2498 自身の narrow scope と Stop Conditionsを維持しつつ、REQUEST_CHANGES → 修正 → 再検証 → 再review を無人化できます。現行 workflow も impl-review-loop の次を「人間レビュー → merge」と定義しているため、merge を明示禁止したこの終了点が最も自然です。

    必要なら、これを**もっと短くして「Claude Code に貼る実戦用・半分程度の長さ」**にも圧縮できます。

  5. squne121 commented on Sep 5, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  6. squne121 commented on Sep 5, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-05T00:00:00Z)

    Verification Commands 結果

    • AC1: test_procedure_steps_executed_in_declared_order_ordered_evidence_match → PASS
    • AC2: test_output_contract_schema_fields_present_full_schema_validation → PASS
    • AC3: test_expect_marker_source_main_opts_out_of_causal_evidence → PASS
    • AC4: test_expect_skill_command_native_user_prompt_expansion_evidence → PASS
    • AC5: test_run_worktree_agent_runtime_smoke.py + test_run_worktree_agent_runtime_smoke_causal_evidence.py → 129 passed(既存回帰なし)
    • AC6: 上記4ファイル一括 → 148 passed
    • AC7(runtime-verification: true): test_live_skill_invocation_main_source_non_fallback_pass → PASS(非 fallback。実 claude プロセスで hermetic stand-in review-issue Skill への direct /review-issue invocation を UserPromptExpansion.command_name evidence で観測、SubAgent spawn なしを確認。同一実行セットで既存 --expect-marker-source subagent(省略時デフォルト)経路が正しく FAIL することも確認し、causal-evidence 強度の低下がないことを検証)

    後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup

  7. squne121 commented on Sep 5, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  8. added a commit that references this issue on Sep 5, 2026
    2cbe2f2
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

    phase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions