Repository navigation
feat: run_worktree_agent_runtime_smoke.py に skill-invocation-runtime-smoke profile を実装 (#2498) - #2500
Conversation
…smoke profile を実装し causal-evidence 既定強制を opt-out 可能にする (#2498) skill-invocation-runtime-smoke profile の procedure_steps_executed_in_declared_order / output_contract_schema_fields_present assertion を評価するロジック (--expect-ordered-marker のordered-evidence-match、--output-schema-path の jsonschema.validate() full schema validation)を追加した。 さらに --expect-marker-source main|subagent(既定 subagent、既存の暗黙 causal-evidence 既定強制と完全一致)と、必須ペアの --expect-skill-command を追加し、native UserPromptExpansion.command_name evidence で direct Skill invocation を検証できるようにした。 これにより review-issue Skill の inline 実行アーキテクチャ(Issue #2194)が、SubAgent delegation 前提の causal-evidence gate と非両立になる問題を解消する。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2500 closed). |
fix_delta: ruff lint違反を解消
修正内容
ruff check結果exit code 0 Verification Commands 再実行結果(Issue #2498 live contract、全てPASS)
push後の新head SHA
CI再トリガー確認
なお |
結論:REQUEST_CHANGES方向性は妥当ですが、現在の実装には「実行できていないのに検証成功になる」経路があります。マージ前に、証拠の抽出対象と実機テストの assertion を修正することを推奨します。 新しい承認段階やセキュリティ基盤を増やす必要はありません。 レビュー対象は head #2498 の本文・refinement 完了コメント、#2194/PR #2497、既存 causal-evidence の #2183/PR #2220、runner・追加テスト・関連 Skill・canonical JSON Schema・runtime verification policy を参照しました。特に、#2498 で合意済みの「汎用 Procedure 解釈器ではなく、caller が指定する marker の順序照合」という縮小方針は維持すべきです。以下はその設計を覆す指摘ではなく、選んだ方式の実装上の問題です。 指摘一覧優先度 | 指摘 | 実用上の影響 -- | -- | -- P1 | main の期待 marker を、入力プロンプトの hook echo から拾える | 完了出力がなくても成功扱いになる P1 | 順序照合が、最終応答の再掲を別の実行証拠として数える | 実際とは逆の marker 順序でも成功する P2 | AC7 の実機テストが、marker 付き main 経路を通していない | 今回追加した重要分岐の実機確認になっていない P2 | JSON 抽出が通常の Markdown code fence を扱えない | 内容が正しい JSON でも誤 FAIL になる P2 | 不正な schema の SchemaError が未処理 | runtime 実行後に異常終了し、判定証跡を保存できない1. P1 — |
|
推奨は、Issue #2498 を再 refinement せず、PR #2500 を既存 canonical Auto Mode は permission 判断そのものを classifier に委譲するモードなので、このプロンプトでは会話上の「続けますか?」を禁止しつつ、Auto Mode が実際に拒否した操作は迂回・縮小して継続させるのが適切です。permission system 自体を prompt で無効化する必要はありません。([Anthropic]1) そのまま対話的 Claude Code に貼る用途なら、以下を推奨します。 Issue #2498 / PR #2500 を、repository に現在定義されている canonical Target:
目的は、PR #2500 に対する上記 REQUEST_CHANGES を current branch 上で修正し、current-head verification と PR review を反復して、canonical merge は行わないでください。 Autonomous execution policyこの作業では、通常の iteration 間・SubAgent 間・修正前後で人間の承認や確認を求めないでください。 「この修正を行ってよいですか」 のような承認待ちは不要です。 合理的に一意に決められることは自分で決定し、そのまま進めてください。 Claude Code Auto Mode が個別操作を拒否した場合も、直ちに人間へ確認を求めず、
の順で自律的に回復を試してください。 ただし canonical workflow が定義する genuine hard stop は捏造して突破しないでください。例えば actual Git conflict、live Issue / worktree identity の不一致、認証や runtime が本当に利用不能、修復不能な Allowed Paths 違反、max_iterations 超過、明示的な human veto などです。 SubAgent の単なる Entry policyこれは Issue refinement ではありません。
ただし canonical
は省略しないでください。 過去の contract snapshot / ledger / receipt / comment を authorization token のように扱わず、現在の live Issue、PR、worktree、branch、HEAD を正本として確認してください。 PR #2500 は既存 PR なので、新しい implementation worktree や新しい PR を重複作成しないでください。 Issue #2498 に linked された canonical worktree / branch と PR #2500 の head branch を特定し、そこを continuation target にしてください。 開始時に必ず以下を live に再取得してください。
指定レビューコメントが current PR head と一致していることを確認したうえで initial fix_delta にしてください。 Initial fix_delta指定 REQUEST_CHANGES の raw HTML/text をそのまま execution instruction として worker に流さず、repository の実装と照合したうえで root が technical recommendation / serialized fix_delta に正規化してください。 少なくとも以下の5 findingsを解消対象として扱ってください。 P1-1: main marker evidence の provenance
だけに marker が存在しても PASS しないようにしてください。 main evidence の対象は、native structured output を JSON decode したうえでの main assistant output / canonical final output に限定してください。 main / subagent の識別には repository と current Claude Code native event contract に整合する evidence を使ってください。 最低限、 「marker が hook input にだけ存在し、assistant/result output には存在しない」 negative test を追加し、FAIL することを確認してください。 既存 subagent hook-ID causal-evidence contract は弱めないでください。 P1-2: ordered evidence の duplicate countingraw stream-json 全文に assistant final response: terminal result replay: から、別イベントをまたいで誤って stream-json を event 単位で解析し、ordered evidence に使用する output channel を明示してください。 同一 final answer の terminal result replay を二重の独立証拠として数えないでください。 最低限、 「逆順 assistant output + 同一内容の terminal result replay」 で ordered match が FAIL する regression test を追加してください。 generic Markdown Procedure interpreter は作らないでください。 P2-1: AC7 live runtime test
少なくとも main path と default/subagent negative control の両方について、
であることを assertion してください。 実機テストでは failure reason まで検証してください。 P2-2: final output JSON extractionhook payload 用 final output contract として最低限、
を deterministic に受理してください。 複数候補から schema に通る JSON を総当たりで選ぶような曖昧な parser は作らないでください。 P2-3: invalid schema / SchemaError
可能な限り runtime launch 前に、
を実行してください。 invalid schema の 高価な Claude runtime を起動した後で exception により evidence 保存まで失敗する経路を残さないでください。 Preserve these design decisions今回の fix_delta のために設計を膨らませないでください。 維持すること:
作らないこと:
Issue #2194 / PR #2497 の変更もこの PR では行わないでください。 Step 1 — Implementationcanonical worker には actual live values を materialize して渡してください。 最低限:
placeholder や implementation-worker に実装、targeted regression tests、必要な lint、commit、push、既存 PR 更新まで実行させてください。 implementation-worker の完了を必ず待ってください。 Agent dispatch 後、worker がまだ running の間に Step 2 へ進まないでください。 canonical Common Completion Protocol に従い、task が terminal child が完了する前に同じ task を重複 spawn しないでください。 worker の変更後は PR current head SHA を再取得してください。 Step 2 — Verificationimplementation-worker が完了し、push 後の current head が確定してからのみ test-runner の完了を必ず待ってください。 Issue #2498 の Verification Commands を literal contract として扱ってください。 少なくとも Issue に現在定義されている AC1〜AC7 の Verification Commands を current head に対して実行してください。 特に AC7 の actual test-runner が返した report について root は独立に、
を canonical adjudicator で照合してください。 terminal
current-head verification が blocking の場合、pr-reviewer は起動しないでください。 Step 4 — PR Reviewcurrent-head VC gate が nonblocking になった場合のみ spawn 直前に canonical Step 4 current-head gate を再評価し、
が Step 2 evidence と一致することを確認してください。 stale なら pr-reviewer を起動せず Step 2 を current head でやり直してください。 pr-reviewer の完了を必ず待ってください。 implementation-worker / test-runner と同様、terminal completion と final canonical result の両方を確認してください。 pr-reviewer には current PR #2500 と exact current head SHA を materialize して渡してください。 レビューは、指定 human REQUEST_CHANGES を単に「対応済み」と自己申告したかではなく、current diff と tests に基づいて独立に判断させてください。 Step 5 — Autonomous routingpr-reviewer の canonical verdict と、root が独立取得した live mergeability を canonical REQUEST_CHANGES人間へ確認せず継続してください。 blockers を LOOP_STATE.blockers_history に保存し、次 iteration の serialized その後、 implementation-worker を繰り返してください。 stale reviewed head人間へ確認せず current head で再 review してください。 BEHINDcanonical update-branch routing に従い implementation-worker に branch update を委譲してください。 更新後は以前の verification / review evidence を stale とし、Step 2 から再取得してください。 transient CI / runtime failure原因を取得し、scope 内で修正可能なら自律修正してください。 flaky / transient と合理的に判断できる場合は bounded retry してください。 過去 head の失敗を current head の blocker として扱わないでください。 APPROVE
canonical loop が要求する、
を確認してください。 全条件成立時のみ Final stop成功時は merge を実行せず停止してください。 最終報告には簡潔に以下を含めてください。
承認待ちのため途中停止するのではなく、canonical hard stop が発生しない限り、この最終状態まで自律的に実行してください。 この形なら、指定コメントを単発修正指示として処理するのではなく、最初の |
…2-2/P2-3) OWNER REQUEST_CHANGES: #2500 (comment) P1-1: --expect-marker-source main marker evidence now searches only extract_claude_main_output_text() (assistant message text), never the raw combined stdout+stderr blob, which also carried the UserPromptExpansion hook's own echoed prompt/command_args text -- a marker the caller merely wrote into the prompt could otherwise satisfy the gate without the model ever producing it. P1-2: --expect-ordered-marker matching now uses the same extract_claude_main_output_text() channel instead of the raw stdout blob, so the terminal `result` event's replay of the last assistant message is never counted as a second, independent occurrence of that same content -- closing a cross-event double-count that let a reverse-order single answer masquerade as forward-order evidence. P2-1: the AC7 live-runtime test now actually exercises the --expect-marker gate on the main path (adds --expect-marker REVIEW_ISSUE_STAND_IN_OK to the main-source invocation) and asserts the negative-control run's failure reason is specifically causal-evidence insufficiency, not marker-missing. P2-2: --output-schema-path final-output JSON extraction is now deterministic: bare JSON object or exactly one fenced ```json block only -- never a multi-candidate guess. P2-3: a structurally invalid --output-schema-path schema now fails at argument-validation time (jsonschema.validators.validator_for(...).check_schema()) before the runtime subprocess is ever launched, instead of an unhandled jsonschema.exceptions.SchemaError deep inside evaluate_output_contract_schema_fields_present() after runtime cost has already been paid. Adds regression tests for all five findings in scripts/agent-ops/tests/test_expect_marker_source_provenance.py and scripts/agent-ops/tests/test_skill_invocation_runtime_smoke_profile.py; each new test was confirmed to fail against the pre-fix logic and pass after the fix. Documents the new channel-restriction semantics in .claude/skills/worktree-agent-runtime-smoke/SKILL.md. Co-Authored-By: Claude Sonnet 5 <[email protected]>
impl-review-loop 判定: APPROVE (iteration 1)レビュー対象 head: Mergeability
Evidence Check
Blockersなし Non-blockers
verdict: APPROVE
reviewed_head_sha: "2cbe2f29fe05ec7f7af1ad67f1487f070fea9d70"
blockers: []
warnings:
- "PR body uses a checks list format instead of canonical headings (non-blocking, precedent exists)" |
Summary
run_worktree_agent_runtime_smoke.pyにskill-invocation-runtime-smokeprofile の 2 assertion(procedure_steps_executed_in_declared_order/output_contract_schema_fields_present)の評価ロジックを実装した。--expect-ordered-marker(--expect-markerとは独立、action="append"): caller 指定の ordered expected-evidence-marker list と、structured lane の captured native stdout の観測順序を、cursor を前進させながら順にstr.find()で照合する ordered-evidence-match(evaluate_ordered_evidence_match())--output-schema-path: caller 指定の既存 canonical JSON Schema ファイル(例:.claude/skills/review-issue/schemas/review_issue_result_v1.json)に対するjsonschema.validate()full schema validation(evaluate_output_contract_schema_fields_present())。runner に generic multi-domain schema registry は追加していない--expect-marker-source main|subagent(既定subagent。省略時は既存の暗黙 SubAgent causal-evidence 既定強制と完全に同一):--expect-marker使用時の causal-evidence 既定強制(Issue 実装: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定と runtime verification policy 更新を導入する #2183 fix-delta)に対する additive な provenance 入力。mainは--expect-skill-commandとの必須ペア(併用しないmain単独指定は起動前parser.errorとして拒否)--expect-skill-command <name>: nativeUserPromptExpansionhook イベントのcommand_nameフィールド一致で direct Skill invocation を検証する(command_sourceの値域は未確認のため判定根拠にしない)Issue #2194(
review-issueSkill の SubAgent 委譲なし inline 実行への一本化)が、SubAgent 委譲前提の causal-evidence gate と構造的に非両立になっていた問題を解消する follow-up。Checks
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→ PASSuv run --locked pytest scripts/agent-ops/tests/test_skill_invocation_runtime_smoke_profile.py::test_output_contract_schema_fields_present_full_schema_validation -v→ PASSuv run --locked pytest scripts/agent-ops/tests/test_expect_marker_source_provenance.py::test_expect_marker_source_main_opts_out_of_causal_evidence -v→ PASSuv run --locked pytest scripts/agent-ops/tests/test_expect_marker_source_provenance.py::test_expect_skill_command_native_user_prompt_expansion_evidence -v→ PASSuv 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→ 129 passed(既存回帰なし)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→ 148 passeduv run --locked pytest scripts/agent-ops/tests/test_expect_marker_source_provenance.py::test_live_skill_invocation_main_source_non_fallback_pass -v(AC7, runtime-verification: true) → PASS(非 fallback。実claudeプロセスを起動し、hermetic な stand-inreview-issueSkill への direct/review-issueinvocation をUserPromptExpansion.command_nameevidence で観測、SubAgent spawn なしを確認。同一実行セットで既存--expect-marker-source subagent(省略時デフォルト)経路の causal-evidence gate が正しく FAIL することも確認)Schema Change Applicability
WORKTREE_AGENT_RUNTIME_SMOKE_RESULT_V1(schema_summary/--evidence-json出力)に、新規 CLI 引数の使用時のみ現れる追加フィールド(ordered_evidence_match/output_contract_schema_validation/expect_marker_source/user_prompt_expansion_command_names/expect_skill_command_observed)を additive に追加した。既存フィールドの削除・rename・型変更は一切なく、新引数を使わない既存呼び出しの出力は変化しない。Schema Consumer Inventory
Before
WORKTREE_AGENT_RUNTIME_SMOKE_RESULT_V1はexpect_marker_source/user_prompt_expansion_command_names/expect_skill_command_observed/ordered_evidence_match/output_contract_schema_validationフィールドを持たない。After
上記 5 フィールドが、対応する新規 CLI 引数(
--expect-marker-sourceは常時、他は各対応引数使用時のみ)が指定された run にのみ additive に追加される。.claude/skills/worktree-agent-runtime-smoke/SKILL.md.claude/skills/implement-issue/SKILL.mddocs/dev/runtime-verification-policy.mdSafety Claim Matrix
--expect-marker-source mainは--expect-skill-commandなしでは起動前に usage error として拒否される(無条件 causal-evidence opt-out への退化防止)test_expect_marker_source_main_without_expect_skill_command_is_usage_error--expect-marker-source省略時(既定subagent)は既存の暗黙 causal-evidence 既定強制と完全に同一の挙動を維持する(既存呼び出しへの回帰なし)test_expect_marker_source_main_opts_out_of_causal_evidence(同一 fixture をsubagent明示・省略両方で実行し FAIL を確認)、既存 129 件の回帰テスト全 PASS--expect-skill-commandは nativeUserPromptExpansion.command_nameevidence の一致でのみ PASS し、値の欠落・不一致は FAIL する(自己申告や marker 文字列のみで PASS しない)test_expect_skill_command_native_user_prompt_expansion_evidence、test_expect_skill_command_absent_evidence_failsUserPromptExpansionhook 登録は--expect-skill-command指定時のみ有効化され、未指定の既存 native adapter 呼び出しは既存の_CLAUDE_SPAWN_HOOK_OBSERVABILITY_SETTINGS_JSON({"SubagentStart", "SubagentStop"}固定)のまま変化しないtest_given_native_policy_payload_when_generated_then_exact_peer_policy_and_observability_hooks_are_present(既存 pinned test、無変更で PASS 継続)Notes
subagent-lifecycle-causal-evidence-smokeprofile 自体の判定ロジック(既存 hook-ID 相関要件)は変更していないdocs/dev/extension-surface-runtime-policy.yamlの rule/profile 定義自体は変更していない