Repository navigation
feat: canonical preflight.run に workflow capability preflight gate を配線する - #2320
Conversation
…線する (#2311) canonical bare `preflight.run` の first-hop を `run_refinement_preflight.py` 直接起動から、新設 `workflow_start_entry.py` 経由に atomic migration する。 `workflow_start_entry.py` は `root_entry_router.capability_preflight_result()` を一度だけ呼び出し、`decision: blocked`(または producer 呼び出し失敗/malformed) の場合は inner preflight を一切起動せず、`ready`/`degraded` の場合のみ trusted interpreter 経由で `run_refinement_preflight.py` を一度だけ起動する。 - command_registry.py / skill_runtime_command_policy.py / skill_runtime_exec.py の pre-dispatch first-hop check を同一 PR で atomic に同期(sibling anchor-comment profile は無変更) - root_entry_router.py に構造化結果を返す capability_preflight_result() を 追加、既存 capability_preflight() は boolean adapter として後方互換維持 - 対応する 7 件の fixture/snapshot テストを migration parity のため更新 - fixture hermeticity: 6 テストファイルの _install_skill_runtime_exec_fixture 系ヘルパーに、root pyproject.toml の [tool.uv].required-version を動的に 読み取る最小 pyproject.toml(managed=false) を seed し、pre-existing local uv_version_mismatch fixture gap を解消 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2320 closed). |
reviewer が PR #2320 で REQUEST_CHANGES(Blocking, B1)として指摘した通り、 `command_registry.py` の canonical bare `preflight.run` argv は `--issue-number`/`--repo` のみを渡し `--planned-operations-json` を供給する 経路が存在しないため、`workflow_start_entry.py` の `_parse_planned_operations()` が `planned_operations_missing` として producer 呼び出し前に常に fail-closed していた。 `build_capability_request()`/`run()` に `planned_operations_omitted` を 追加し、`main()` が CLI フラグと `LOOP_PLANNED_OPERATIONS_JSON` の両方が 未指定であることを検出した場合のみこのフラグを True にして、 `workflow_capability_preflight.py` producer 自身の「omitted は有効な空リスト」 という既存セマンティクスと同じ扱いで producer 呼び出しへ進むようにした。 明示的に空文字列/不正な JSON が渡された場合は引き続き AC5 通り fail-closed する。既存の `run()` 直接呼び出しの契約(`planned_operations_json=None` を 渡すと fail-closed する AC9 の否定テスト含む)は変更していない。 新規テスト3件を追加し、CLI 経由で `--planned-operations-json` を渡さない 本番同型の呼び出しが producer 呼び出しまで到達することを検証した。 reviewer が再現した本番形式コマンドを worktree 内で再実行し、 `environment_failure:planned_operations_missing` が発生せず `run_refinement_preflight.py` まで到達することを確認した。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
fix_delta 対応完了報告(B1: canonical bare
|
判定
レビュー対象は現行 head P0-1: canonical経路で capability request が消失し、空要求として
|
human OWNER の PR #2320 REQUEST_CHANGES を反映するfix_delta: - skill_runtime_exec.py の _sanitize_env() が command_id=="preflight.run" の場合に限り LOOP_SPARK_MODE/LOOP_SPARK_FALLBACK/LOOP_PLANNED_OPERATIONS_JSON を child process へ通すようallowlistを拡張し(P0-1)、canonical executor 経由で caller の capability request が producer へ到達しない欠陥を修正した。 - workflow_start_entry.py の planned_operations_omitted 緩和(前回fix_delta で追加された「省略は空集合として許可」の例外)を削除し、request欠落を 元のIssue契約通りfail-closed(environment_failure)へ戻した(P0-1)。 - wrapper の planned_operations スキーマを producer(workflow_capability_ preflight.py)と一致する {phase, actor_role, operation, requires_mutation} の4フィールドに揃え、operationをnon-empty string必須・requires_mutationを bool型必須にした。spark_mode/spark_fallbackも固定enumとしCLI/env両方の 経路でvalidateする(P0-2)。 - SKILL.md Step 0fの実行コードブロックを、旧 run_refinement_preflight.py 直接起動から canonical executor 経由の bare preflight.run invocation へ置換した(P0-3)。500行制約を維持したまま capability request の 1回限りenv設定手順を追記した。 - workflow_start_entry.py を直接起動する fake ではなく、実際に skill_runtime_exec.py --command-id preflight.run をsubprocessとして 起動し _sanitize_env() を実際に通す real end-to-end テストを新規追加し、 unsupported operation と required+forbidden Spark がinner preflight 起動前にblockedになることを証明した。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
fix_delta 実施報告 (2026-08-24, control-plane/AI 実行)human OWNER の REQUEST_CHANGES(https://github.com/squne121/loop-protocol/pull/2320#issuecomment-5386763548)に対する fix_delta を実施し、head 修正内容P0-1 (canonical経路でcapability requestが消失する)
P0-2 (wrapperとreal producerの入力schema不一致)
P0-3 (SKILL.mdに旧production commandが残っている)
追加した実end-to-endテスト
検証結果
Allowed Paths 内のみで変更( 後続: pr-review-judge による再レビューをお願いします。 |
importlib.util の import をファイル先頭の import ブロックへ移動し、 python-test-core CI job の ruff E402(module level import not at top of file)失敗を解消する。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
fix_delta: E402 修正(control-plane / AI 実行)
修正内容
検証結果
commit
|
Summary
preflight.run(issue-refinement-loopのISSUE_REFINEMENT_COMMAND_REGISTRY_V1)の first hop を、run_refinement_preflight.py直接起動から新設workflow_start_entry.py経由に atomic migration した。workflow_start_entry.pyはroot_entry_router.capability_preflight_result()を一度だけ呼び出し、decision: blocked(または producer 呼び出し失敗・結果 malformed)の場合はrun_refinement_preflight.pyを一切起動せず compact blocked result を返す。ready/degradedの場合のみ、trusted interpreter 経由でrun_refinement_preflight.pyを一度だけ起動する。command_registry.py/skill_runtime_command_policy.pyの exact argv contract /skill_runtime_exec.pyの pre-dispatch first-hop integrity check を同一 PR で atomic に同期した(sibling の anchor-comment 駆動 profile.with_anchor/.with_human_context/.with_agent_report/.fixture/.fixture.with_human_contextは無変更)。root_entry_router.pyに構造化結果(decision/checks/reasons)を返すcapability_preflight_result()を新設し、既存capability_preflight()はこれを boolean へ縮退させる後方互換 adapter として維持した(Step 5 の既存呼び出し元・既存テストは無変更で PASS)。_install_skill_runtime_exec_fixture系ヘルパーが temporary repo にpyproject.tomlを seed しておらず、uvが account-home lane から解決されるローカル環境でuv_version_mismatchが発生する)を、対象 6 テストファイルの fixture に rootpyproject.tomlの[tool.uv].required-versionを動的に読み取る最小pyproject.toml(managed = false)を seed することで解消した。production の trusted-uvresolver semantics 自体は変更していない。本 PR は Issue #2311 の実装であり、マージ後に自動クローズさせるため以下を明記する: Closes #2311
Checks
pnpm typecheck— 対象外(Python-only 変更。TypeScript ファイルの変更なし)pnpm lint— 対象外(Python-only 変更)pnpm test— 対象外(Python-only 変更)pnpm build— 対象外(Python-only 変更)Schema Change Applicability
uncertainCLAUDE_GPT_WORKFLOW_CAPABILITIES_V1等)は変更していないが、新設したroot_entry_router.capability_preflight_result()(構造化結果を返す新しい module-level function)とworkflow_start_entry.pyのWORKFLOW_START_ENTRY_RESULT_V1(compact result の内部形状)は新しい producer-consumer 境界であるためuncertainとした。Schema Consumer Inventory
変更対象 schema:
capability_preflight_result()の戻り値形状({"decision", "checks", "reasons"})、および新設WORKFLOW_START_ENTRY_RESULT_V1(workflow_start_entry.pyの compact result)before/after 差分:
Consumer 列挙(rg コマンド例と結果):
Consumer 更新状況:
root_entry_router.py(GhCliGitHubEntryTransport.capability_preflight())test_ac11_capability_preflight_blocked_stops_before_mutationPASS で確認済み)workflow_start_entry.pycapability_preflight_result()を injectable dependency として消費test_workflow_start_entry.pycommand_registry.pybarepreflight.runWORKFLOW_START_ENTRY_RESULT_V1の直接 consumer ではないが、first-hop target をworkflow_start_entry.pyに変更Compatibility Decision(互換性判定)
additivebackward_compatiblenoN/Acapability_preflight()の外部から観測可能な戻り値・呼び出し契約(引数・boolean 戻り値・エラー時False)は完全に維持されている(test_loop_handoff_contract.py31/31 PASS、test_root_entry_router_workflow_capability.py7/7 PASS で無回帰確認)。新設capability_preflight_result()とWORKFLOW_START_ENTRY_RESULT_V1は完全に新規の additive API であり、既存 consumer を破壊しない。Visual Impact Declaration(視覚影響申告)
N/A — UI(DOM/CSS)変更を含まない(Python スクリプト・SKILL.md のみの変更)。
Safety Claim Matrix
decision: blocked(または producer 呼び出し失敗/結果 malformed)の場合、run_refinement_preflight.pyは一切起動されないtest_workflow_start_blocked_does_not_invoke_inner_preflight/test_workflow_start_blocked_performs_no_github_mutation/test_workflow_start_malformed_producer_result_fails_closed(3/3 PASS、下記検証コマンド結果参照)decision: ready/degradedの場合、run_refinement_preflight.pyは正確に一度だけ起動されるtest_workflow_start_ready_invokes_inner_once/test_workflow_start_degraded_uses_declared_fallback_once(2/2 PASS)planned_operations等)が欠落/malformed な場合、producer を呼ばずenvironment_failureで fail closed するtest_workflow_start_missing_planned_operations_fails_closed(7 parametrize、7/7 PASS)workflow_start_entry.pyは結果を呼び出し元に返すのみで、ファイル・環境変数・digest 等への永続化を行わない(Step 0/Step 5 が同一の再提示可能な authorization を共有しない構造)独立した fresh call)+workflow_start_entry.pyのコード(run()は dict を返すのみで write を行わない)preflight.runの first-hop 変更がskill_runtime_command_policy.py/skill_runtime_exec.pyの既存 exact-match / integrity check と整合するtest_skill_runtime_policy_commands.py28/28 PASS、7 件の real-dispatch fixture 全 PASS(下記参照).with_anchor等)の production argv・first-hop は本 PR で変更されていないtest_skill_runtime_exec_anchor.py8/8 PASS、test_preflight_run_with_anchor.py44/44 PASSNotes
preflight.run経路に配線する部分のみ。anchor-comment 駆動経路(.with_anchor等)への配線は Remaining Parent Gaps に記載の follow-up Issue スコープ(本 PR には含まない)検証コマンド結果(Issue #2311 Verification Commands)
AC1(検証結果)
PASS(baseline-expect: fail → 実装後 match)
AC2(検証結果)
PASS(baseline-expect: fail → 実装後 match)
AC3(検証結果)
PASS
AC4(検証結果)
PASS
AC5(検証結果)
PASS
AC6(検証結果)
PASS(baseline-expect: fail → 実装後 match)。加えて既存 Step 5 回帰テスト
uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_loop_handoff_contract.py -q= 31 passed(test_ac11_capability_preflight_blocked_stops_before_mutation含む)で無回帰を確認。AC7(検証結果)
PASS
AC8(検証結果)
PASS(baseline-expect: fail → 実装後 match)
AC9(検証結果)
PASS
AC10(検証結果)
PASS
Scope Delta parity(移行整合性とテスト環境修復の検証コマンド)
いずれも
pr_review_only指定の 6 コマンドを含め、Draft PR 作成前にローカルで実際に実行し全 PASS を確認した(fixture gap によるuv_version_mismatchは解消済み)。CI での実結果は本 PR の CI run を参照。追加の無回帰確認(Allowed Paths 外 consumer、Stop Condition 対象外の diligence)
以下は Allowed Paths 外の周辺テストに対する参考実行結果であり、本 PR の判定には使用しないが無回帰の追加確認として記載する。
.claude/skills/issue-refinement-loop/tests/(test_command_registry.py除く): 1686 passed.claude/skills/issue-refinement-loop/scripts/tests/: 76 passed.claude/hooks/tests/test_local_main_branch_guard.py: 374 passedtests/codex/test_local_main_branch_guard.py+tests/codex/test_scope_rollup_run_exact_executor.py: 324 passedscripts/claude-gpt/tests/test_workflow_capability_preflight.py: 22 passedscripts/ci/tests/test_python_test_plan.py: 55 passeduv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py: 24 passedtest_command_registry.py(Allowed Paths 外)と、同様に Allowed Paths 外の一部 anchor/decide/authority_transport 系テスト(test_skill_runtime_exec_stdout.py等)には、本 PR の変更と無関係な pre-existing localuv_version_mismatchfixture gap による failure が baseline(未変更 main)でも再現することを確認済み(本 PR による新規 regression ではない)。Allowed Paths 準拠
変更ファイルは Issue #2311 の Allowed Paths と完全一致(14ファイル):
.claude/skills/issue-refinement-loop/SKILL.md.claude/skills/issue-refinement-loop/scripts/root_entry_router.py.claude/skills/issue-refinement-loop/scripts/command_registry.py.claude/skills/issue-refinement-loop/scripts/workflow_start_entry.py(新規).claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry.py(新規)scripts/agent-guards/skill_runtime_command_policy.pyscripts/agent-guards/skill_runtime_exec.pyscripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.pyscripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.pyscripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.pyscripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.pyscripts/agent-guards/tests/test_skill_runtime_exec_anchor.pytests/agent_guards/test_worktree_scope_guard.py.claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py