Skip to content

実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2271"
goal_ref: "Parent #2271 が要求する (1) workflow capability preflight (2) optional Spark delegation (3) Issue契約修復・GitHub mutation (4) fresh review (5) implementation entry の順序のうち、(1) を issue-refinement-loop の bare `preflight.run` command(parent-owned preflight / isolation worktree 委譲経路)で、最初の mutation または SubAgent dispatch より前に到達する executable gate として保証する。anchor-comment 駆動経路(`preflight.run.with_anchor` / `.with_human_context` / `.with_agent_report`)への同種配線は本 Issue のスコープ外とし、follow-up Issue で扱う"
change_kind: workflow

Parent Issue

#2271

Parent Goal Ref

Current Validated Scope

  • canonical ISSUE_REFINEMENT_COMMAND_REGISTRY_V1 の bare preflight.run エントリ(preflight.run.with_anchor / .with_human_context / .with_agent_report 等の sibling エントリは対象外。これらは Remaining Parent Gaps に follow-up として記載する)が、既存の run_refinement_preflight.py 直接起動ではなく、新設する薄い同期 wrapper workflow_start_entry.py を起動するように変更する。
  • workflow_start_entry.py は次の3段を一続きに実行する: (1) 構造化 workflow capability preflight(root_entry_router.py に新設する capability_preflight_result() を利用)を一度だけ実行する、(2) decision: blocked または producer 呼び出し失敗/結果 malformed の場合は run_refinement_preflight.py を一切起動せず compact blocked result を返して終了する、(3) decision: ready または degraded の場合のみ trusted uv 経由で run_refinement_preflight.py を一度だけ起動する。
  • root_entry_router.py に、既存の boolean-only capability_preflight() とは別に、CLAUDE_GPT_WORKFLOW_CAPABILITIES_V1 の decision / checks / reasons をそのまま保持する capability_preflight_result() を追加する。既存 capability_preflight() はこの構造化結果を boolean へ縮退させる後方互換 adapter として維持し、Step 5(run_root_transition)の既存呼び出し・既存テスト(test_ac11_capability_preflight_blocked_stops_before_mutation 等)の挙動を変更しない。
  • Step 0 の caller は capability request として spark_mode / spark_fallback / invocation-scoped planned_operations(各 operation に phase / actor_role / requires_mutation を持つ)を明示的に渡す。static な全 operation superset は禁止し、request が欠落または malformed な場合は environment_failure として fail-closed する。
  • .claude/skills/issue-refinement-loop/SKILL.md の Step 0 系に、workflow capability preflight が Step 0g(trusted contract update mutation)・Step 1 SubAgent dispatch・Step 4 Issue mutation のいずれよりも前に、preflight.run の一部として一度だけ実行されることを明記する。Step 0 の capability preflight と Step 5 の capability preflight は独立した fresh call であり、Step 0 の結果を Step 5 の implementation-entry authorization として再利用しないことも明記する。
  • 上記変更を検証する hermetic behavioral test(fake transport / fake gh、live GitHub 呼び出し不要)を .claude/skills/issue-refinement-loop/scripts/tests/ に追加する。

Remaining Parent Gaps

Outcome

canonical bare preflight.run(command_registry.py の ISSUE_REFINEMENT_COMMAND_REGISTRY_V1。anchor-comment 駆動の sibling エントリは対象外)から到達する workflow_start_entry.py が、Step 0g mutation・SubAgent dispatch(Step 1/1b)・Step 4 Issue mutation のいずれよりも前に workflow capability preflight を一度だけ実行し、decision: blocked または producer 呼び出し失敗/malformed の場合に run_refinement_preflight.py を含む後続処理を一切起動しないことが、hermetic behavioral test で証明できる状態。decision: ready / degraded の場合は run_refinement_preflight.py を trusted uv 経由で一度だけ起動し、structured な checks / reasons が blocked result に保持される。

Runtime Verification Applicability

decision: immediate
reason: "producer が実際に一度だけ呼ばれる/blocked で downstream 呼び出しがゼロ回になる/ready・degraded で一度だけ次へ進む、という runtime control-flow は静的 grep や文言確認だけでは証明できないため。"
applicable_acs:
  - AC2
  - AC3
  - AC4
  - AC5
  - AC7
  - AC9
execution_environment:
  cli_tools:
    - python3
    - uv
  auth_required: false
  network_required: false
skip_conditions:
  - "local repository checkout が存在しない場合は SKIP ではなく environment blocked として扱う"
fallback_policy:
  fallback_success_is_pass: false
  notes: "fallback 経由の成功を PASS に変換しない。live GitHub API 呼び出しや live Claude-GPT E2E は要求しない(統合 live smoke は #2278 が別途担当)"
artifact_requirements:
  - "pytest output(test_workflow_start_entry.py の hermetic fake transport / fake gh 実行ログ)"

本 Issue が証明対象とするのは「producer が実際に一度だけ呼ばれる」「blocked で downstream(run_refinement_preflight.py 起動・GitHub mutation)呼び出しがゼロ回になる」「ready/degraded で一度だけ次へ進む」という runtime control-flow であり、静的 grep や文言確認だけでは証明できない。hermetic fake transport(stub producer JSON・fake gh/uv 呼び出し記録)を用いた subprocess/behavioral pytest で検証する。

In Scope

  • command_registry.py の bare preflight.run argv を workflow_start_entry.py 起動に変更する(preflight.run.with_anchor / .with_human_context / .with_agent_report 等の sibling エントリは変更しない)

  • workflow_start_entry.py の新規実装(capability preflight 実行 → blocked分岐 → ready/degraded分岐 → run_refinement_preflight.py 起動)

  • root_entry_router.py への capability_preflight_result() 追加と、既存 capability_preflight() の後方互換 adapter化

  • capability request(spark_mode / spark_fallback / planned_operations[].{phase,actor_role,requires_mutation})の caller 側組み立てと、欠落/malformed 時の environment_failure fail-closed

  • .claude/skills/issue-refinement-loop/SKILL.md の Step 0 系への上記 ordering・freshness 契約の明記

  • 対応する hermetic behavioral test の追加

  • AC1 の command migration は、以下3つの consumer を同一 PR で atomic に同期する契約とする:

    1. command_registry.py — canonical bare preflight.run argv
    2. skill_runtime_command_policy.py — _EXPECTED_ARGV_BY_COMMAND["preflight.run"]
    3. skill_runtime_exec.py — pre-dispatch integrity/symlink check の first-hop target

    三者とも bare preflight.run について workflow_start_entry.py を指すこと。これは policy の一般化・緩和ではなく、既存 exact-match command contract の atomic migration である。

    上記migrationに伴い、bare preflight.run を real executor 経由で real-dispatch する既存 fixture/snapshot テスト7件(Allowed Paths参照)も同一PRで migration parity のため更新する。これらは production behavior変更ではなく、既存テストが検証しているbare preflight.run の first-hop契約をmigration後の値に追従させるものである。

    変更しないもの: preflight.run.with_anchor / .with_human_context / .with_agent_report / .fixture / .fixture.with_human_context の production argv・wiring(これらは引き続き run_refinement_preflight.py を first-hop とする)。

Out of Scope

Acceptance Criteria

  • AC1: command_registry.py の ISSUE_REFINEMENT_COMMAND_REGISTRY_V1 の bare preflight.run(.with_anchor 等の suffix を持たない既定エントリ)の canonical argv が workflow_start_entry.py を起動する(run_refinement_preflight.py を直接指さない)。同時に、skill_runtime_command_policy.py の exact argv policy(_EXPECTED_ARGV_BY_COMMAND["preflight.run"])と skill_runtime_exec.py の pre-dispatch integrity/symlink check の first-hop target も同じ workflow_start_entry.py に同期し、real privileged executor の validate_registry_entry() を通過して argv_template_mismatch を発生させないことを確認する。sibling エントリ(preflight.run.with_anchor / .with_human_context / .with_agent_report / .fixture / .fixture.with_human_context)の argv・first-hop target は変更しない
  • AC2: workflow_start_entry.py は Step 0g mutation・SubAgent dispatch・GitHub mutation のいずれよりも前に、root_entry_router.capability_preflight_result() を実際に import/呼び出しして workflow capability preflight producer を一度だけ実行する(workflow_start_entry.py が独自に preflight 呼び出しを再実装しないことを静的チェックで確認する)。この runtime 順序の証明は AC9 の test_workflow_start_ready_invokes_inner_once / test_workflow_start_blocked_does_not_invoke_inner_preflight が担う
  • AC3: producer の decision は ready / degraded / blocked の3値のみであり、blocked、または producer subprocess 呼び出し自体の失敗・結果 JSON の malformed(この2つを合わせて以下 producer 呼び出し失敗/malformed と呼ぶ)の場合、workflow_start_entry.py は run_refinement_preflight.py を一切起動せず、compact blocked result(reason を含む)を返して終了する
  • AC4: capability preflight の結果が ready または degraded の場合、workflow_start_entry.py は trusted uv 経由で run_refinement_preflight.py を一度だけ起動する
  • AC5: caller は capability request として spark_mode / spark_fallback / invocation-scoped planned_operations(各 operation に phase / actor_role / requires_mutation)を明示的に渡す。static global superset は使わず、caller が渡した capability request 自体(producer の応答ではない)が欠落または malformed な場合は、producer を呼び出す前に environment_failure として fail-closed する。この caller-side 欠落/malformed ケースは AC3 の producer 応答 malformed ケースとは別の専用テスト(test_workflow_start_missing_planned_operations_fails_closed)で検証する
  • AC6: root_entry_router.py に構造化結果を返す capability_preflight_result() が追加され、既存 capability_preflight() boolean adapter はこれを内部で呼ぶ後方互換 wrapper として維持される(Step 5 の既存呼び出し元・既存テストの挙動は変更しない)。実装者は pnpm test 相当の全体検証の一環として、既存の test_ac11_capability_preflight_blocked_stops_before_mutation(.claude/skills/issue-refinement-loop/tests/test_loop_handoff_contract.py)が無回帰で PASS することも確認する(VC 単一コマンド制約のため個別 AC の Verification Command には含めない)
  • AC7: blocked の理由(checks/reasons)が workflow_start_entry.py の compact result に保持される(Step 5 の ready|degraded -> True / blocked|producer呼び出し失敗/malformed -> False という boolean 縮退は Step 0 経路には適用しない)
  • AC8: .claude/skills/issue-refinement-loop/SKILL.md に、Step 0 の capability preflight と Step 5 の capability preflight が独立した fresh call であり、Step 0 の結果を Step 5 の implementation-entry authorization として再利用しないことが明記されている
  • AC9: .claude/skills/issue-refinement-loop/scripts/tests/ に hermetic fake transport / fake gh を用いた behavioral test が追加され PASS する(test_workflow_start_blocked_does_not_invoke_inner_preflight / test_workflow_start_blocked_performs_no_github_mutation / test_workflow_start_ready_invokes_inner_once / test_workflow_start_degraded_uses_declared_fallback_once / test_workflow_start_passes_exact_spark_and_planned_operations / test_workflow_start_missing_planned_operations_fails_closed / test_workflow_start_preserves_block_reason / test_workflow_start_malformed_producer_result_fails_closed の8本を含む)
  • AC10: .claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.py(SKILL.md 500行制約)が引き続き PASS する

Verification Commands

# AC1
# baseline-expect: fail
$ rg -n "workflow_start_entry" .claude/skills/issue-refinement-loop/scripts/command_registry.py

# AC2
# baseline-expect: fail
$ rg -n "capability_preflight_result" .claude/skills/issue-refinement-loop/scripts/workflow_start_entry.py

# AC3
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry.py -q -k "test_workflow_start_blocked_does_not_invoke_inner_preflight or test_workflow_start_blocked_performs_no_github_mutation or test_workflow_start_malformed_producer_result_fails_closed"

# AC4
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry.py -q -k "test_workflow_start_ready_invokes_inner_once or test_workflow_start_degraded_uses_declared_fallback_once"

# AC5
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry.py -q -k "test_workflow_start_passes_exact_spark_and_planned_operations or test_workflow_start_missing_planned_operations_fails_closed"

# AC6
# baseline-expect: fail
$ rg -n "capability_preflight_result" .claude/skills/issue-refinement-loop/scripts/root_entry_router.py

# AC7
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry.py -q -k "test_workflow_start_preserves_block_reason"

# AC8
$ rg -n "独立した fresh call" .claude/skills/issue-refinement-loop/SKILL.md

# AC9
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry.py -v

# AC10
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.py -v

# Scope Delta parity(AC1 consumer sync・migration parity)
# test_skill_runtime_policy_commands.py は変更対象ファイルではなく no-op regression 確認用
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_commands.py -v
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -v
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py -v
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py -v
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py -v
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -v
# preflight-scope: pr_review_only
$ uv run --locked pytest tests/agent_guards/test_worktree_scope_guard.py -v
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -v

Allowed Paths

  • .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/
  • scripts/agent-guards/skill_runtime_command_policy.py
  • scripts/agent-guards/skill_runtime_exec.py
  • scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py
  • scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
  • scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py
  • scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py
  • scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
  • tests/agent_guards/test_worktree_scope_guard.py
  • .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
    • 本Issueの scope delta(skill_runtime_command_policy.py, skill_runtime_exec.py, 7つのfixture/snapshotテスト)は、複数ラウンドの独立SubAgent調査とOWNER承認を経て確定済み。これ以上のwhole-repo scope再探索は不要。
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 新しい enforcing hook(PreToolUse 等)の追加が必要になった場合

Required Skills

  • なし

Required Design References

  • docs/dev/workflow.md
  • docs/dev/agent-skill-boundaries.md

Scope Delta(任意)

N/A

Notes for Reviewer

  • 本 Issue は Parent 導入: Claude-GPT → issue-refinement-loop → impl-review-loop の実行契約を end-to-end で整合させる #2271 の順序契約と Issue 実装: Claude-GPT に workflow-profile capability preflight と controlled GitHub route を配線する #2273 の scope 境界を巡る OWNER レビュー(PR 実装: Claude-GPT に workflow-profile capability preflight と controlled GitHub route を配線する #2307 の REQUEST_CHANGES, P0-1: https://github.com/squne121/loop-protocol/pull/2307#issuecomment-5381555495)を受けて、Issue 実装: Claude-GPT に workflow-profile capability preflight と controlled GitHub route を配線する #2273 を「implementation-entry capability preflight」に狭めた際に未解決として残った follow-up。
  • Issue 実装: Claude-GPT に workflow-profile capability preflight と controlled GitHub route を配線する #2273 は Allowed Paths に issue-refinement-loop/SKILL.md を含んでいなかったため、Step 1/1b/4 より前の gate 実装は同一 PR ではなく本 Issue に分離した。
  • Depends on 実装: Claude-GPT に workflow-profile capability preflight と controlled GitHub route を配線する #2273(本 Issue の production consumer wiring の前提となる capability_preflight() 実装が 実装: Claude-GPT に workflow-profile capability preflight と controlled GitHub route を配線する #2273 で行われる)。
  • 本 Issue は 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 (comment) の OWNER REQUEST_CHANGES レビュー(P0-1〜P0-6, P1-1〜P1-4)を反映して全面改訂した。dead code で AC を満たせる問題(P0-1)を production carrier(workflow_start_entry.py + canonical preflight.run 配線)の明記で解消し、「Step 1 より前」ではなく「最初の mutation/SubAgent dispatch より前」(P0-2)、capability request の正本定義(P0-3)、structured result の保持(P0-4)、Runtime Verification Applicability の immediate 化(P0-5)、Allowed Paths と canonical bootstrap の自己矛盾解消(P0-6)、VC の baseline-expect 注釈と canonical pytest 呼び出し形式(P1-1/1-2 相当。checker feedback: uv run --locked python3 -m pytest ではなく uv run --locked pytest を使う)、Remaining Parent Gaps の 統合: merged Child A/B/C の単一 clean HEAD で issue-to-impl E2E を検証する #2278 明記(P1-3)、Step 0/Step 5 preflight の freshness 分離明記(P1-4)を反映した。OWNER が「採用しない方がよい」とした新規 hook・mutation broker・capability ledger・authorization token・digest/receipt・永続 state store・permission registry の新設は Out of Scope に明記して除外した。
  • refinement loop の Step 2.5 semantic design review(issue-design-reviewer)が2ラウンド実施された。1ラウンド目の high finding 2件(AC5 の caller-side capability request 検証テストが AC9 正本リストに無かった/workflow_start_entry.py が root_entry_router.capability_preflight_result を実際に呼ぶことを検証する AC/VC が無かった)は AC5/AC9/AC2 の拡張で解消済み。2ラウンド目で新たに検出された high finding(AC1/In Scope が bare preflight.run のみを差し替え、Step 0g mutation を実際にゲートする anchor-comment 駆動経路 preflight.run.with_anchor / .with_human_context / .with_agent_report には配線が届いていなかった、requires_owner_choice: true)に対しては、スコープを bare preflight.run(parent-owned preflight / isolation worktree 委譲経路)に明示的に narrow し、anchor-comment 駆動経路の配線は Remaining Parent Gaps に follow-up として明記する方針を採用した(Allowed Paths・アーキテクチャ層の拡張は行わない、既存の scope narrowing パターン — 実装: Claude-GPT に workflow-profile capability preflight と controlled GitHub route を配線する #2273 からの分離 — を踏襲)。medium finding 2件(baseline-expect 注釈の AC1/AC6 への拡張、AC6 の既存 Step5 backward-compat 回帰テストの実行を明記)と low finding(AC2 の runtime-verification 対応先の明記)も反映した。AC6 の回帰テストは VC の単一コマンド制約(compound shell operator 禁止)のため個別 VC には追加せず、AC6 の Acceptance Criteria 本文に実装者向け確認事項として明記した。anchor-comment 駆動経路の capability preflight 配線については、bare preflight.run のみへの scope narrowing で進めるか、本 Issue のスコープを拡張するかは OWNER 判断を推奨する。実装着手前に本ノートを確認されたい。
  • Scope Delta parity ブロックの test_skill_runtime_preflight_no_worktree.py / test_skill_runtime_exec_unauthorized_write_path.py / test_skill_runtime_exec_session_manifest_lifecycle.py / test_guard_shadow_log_write_path_policy.py / test_skill_runtime_exec_anchor.py / test_worktree_scope_guard.py の6コマンドは、複数ラウンドの独立SubAgent調査とOWNER承認により pr_review_only として pre-implementation baseline から defer する(# preflight-scope: pr_review_only を付与済み)。理由: current-main の fixture(_install_skill_runtime_exec_fixture 系ヘルパー)が temporary repo に pyproject.toml をseedしないため、uv がaccount-home lane(~/.local/bin/uv)から解決されるローカル環境で skill_runtime_command_policy の trusted-uv version-pin検証が uv_version_mismatch でfail-closedする。これは本 Issue の AC1 production migrationとは無関係な pre-existing local fixture gapであり、テスト免除ではない。実装Phaseで対象6ファイルのfixture helperに、root pyproject.toml の [tool.uv].required-version を動的に読み取って生成する最小 pyproject.toml(managed = false)をseedするhermetic修正を行い、実装後はこれら6コマンドをローカルで実際に実行し、さらにPR CIでの実結果も確認する。CI PASSを未確認のまま最終承認しない。test_skill_runtime_policy_commands.py と test_preflight_run_with_anchor.py(44/44 PASS確認済み)はこのfixture gapの影響を受けないため対象外のまま変更していない。

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 22, 2026
  2. squne121 commented on Aug 23, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES / 現状の Issue 契約では実装着手 NO-GO です。

    問題設定自体は正しいです。PR #2307で残った「workflow 開始前ではなく、Step 5 の implementation-entry でしか preflight していない」という欠陥を #2311 へ分離した判断も妥当です。実際、#2307 の最終レビューでも P0-1 は #2311 に切り出した未解決事項として扱われています。

    ただし、現在の #2311 は SKILL.md に記述を足し、root_entry_router.py に呼べる関数を置くことを主な完了条件にしており、production workflow がその関数を必ず通ることを証明していません。現状の AC1〜AC4 は、実際には使われない helper と説明文だけでも満たせます。


    P0-1: production の呼び出し元が定義されておらず、dead code で AC を満たせる

    現在の root_entry_router.py は、モジュール自身が明記しているとおり Step 5 の root-owned implementation-entry transition です。また、その CLI subprocess 自体は、親の agentic turn における SubAgent tool call を直接制御できないとも明記されています。つまり、ここに「Step 0 から呼べる公開関数」を追加しても、Step 0 の production control flow がそれを呼ばなければ何も変わりません。

    一方、現在の Step 0f の正規経路は run_refinement_preflight.py であり、orchestrator-facing command の正本は ISSUE_REFINEMENT_COMMAND_REGISTRY_V1 の preflight.run です。main thread と SubAgent は手書き shell ではなく、この registry を使う契約です。

    したがって、AC3 の「Step 0 consumer から呼び出す経路が実装されている」では不十分です。少なくとも以下を固定する必要があります。

    • production caller のファイル・関数・command ID
    • capability gate と既存 Step 0f を一続きに実行する executable carrier
    • blocked の場合に既存 Step 0f 以降を呼ばない分岐
    • canonical registry がその carrier を指すこと
    • bypass 用の旧 production command が残らないこと

    Anthropic の公式仕様でも、Skill は「Claude が読み、解釈して従う instructions」であり結果は可変、hook は lifecycle event で必ず発火する決定論的機構とされています。したがって、SKILL.md の記述だけを「実行保証」と呼ぶことはできません。([Claude]1)

    ただし、このリポジトリでは新しい enforcing hook を追加しない判断が既にあり、趣味開発としての運用負荷も考えると、ここで hook を増やすべきではありません。必要なのは 正規 command を一本の同期 executable gate にすることです。PR #2307 の OWNER review も、永続 ledger・broker・hook ではなく単純な同期呼び出しを推奨していました。


    P0-2: 「Step 1 より前」では遅い可能性があり、Step 0g mutation が AC から漏れている

    現行 SKILL の順序は概ね次です。

    Step 0
      ↓
    Step 0f: planner / preflight wrapper
      ↓
    Step 0g: trusted contract update
      ↓
    Step 1 / Step 1b
    

    Step 0g は contract_update.run.with_human_context を通じて Issue 本文を更新し得る mutation phase です。ところが #2311 の AC は主に「Step 1 / 1b / Step 4 より前」としか規定していません。これでは、Step 0g の mutation 後に capability gate を置いても AC1・AC2を満たした扱いになり得ます。

    順序契約は次のように修正すべきです。

    read-only input / planner assembly
      ↓
    current invocation の Spark directive・planned_operations を確定
      ↓
    workflow capability preflight
      ├─ blocked / invalid / timeout
      │    → Step 0g・SubAgent・GitHub mutationを一切開始せず停止
      └─ ready / approved degraded
           → Step 0g または Step 1 へ進む
    

    重要なのは「Step 1 より前」ではなく、最初の mutation または SubAgent dispatch より前です。


    P0-3: Step 0 で渡す capability request が未定義

    既存 producer は、単純な GitHub auth boolean ではありません。以下を caller が渡す前提です。

    • spark_mode
    • spark_fallback
    • invocation-scoped planned_operations
    • 各 operation の phase
    • actor_role
    • requires_mutation

    そして、GitHub read capability と operation route を別々に判定します。

    現在の GhCliGitHubEntryTransport は Step 5 用として、既定の planned_operations に audit comment の issue_comment 一件だけを持ち、結果を最終的に boolean へ潰しています。

    これをそのまま Step 0 から呼ぶと、次の mutation が capability request から漏れます。

    • Step 0g の contract update による issue_edit
    • Step 4 の issue-editor による issue_edit
    • follow-up materialization が有効な場合の issue_create
    • termination/audit comment の issue_comment

    逆に、すべての operation を常時渡す静的 superset にすると、実際には使わない route の不足で workflow を過剰に止める可能性があります。

    Issue 本文で、少なくとも以下を決定してください。

    workflow_capability_request_source:
      spark_directive: <current invocationでの正本>
      planned_operations: <current planner result / enabled phaseから導出>
      static_global_superset: forbidden
      missing_or_malformed_request: environment_failure

    Spark directive の正本が planner、delegation request、launcher input のどれなのかは、現 Issue から判別できません。ここを実装者判断に残すと、再び spark_mode: null で常時 not_required になる回帰が起きます。


    P0-4: boolean consumer では remediation と degraded semantics が消える

    既存 producer は decision に加えて、checks と具体的な reasons を返します。しかし現在の capability_preflight() は次のように集約しています。

    ready / degraded                         -> True
    blocked / timeout / non-JSON / exit != 0 -> False
    

    そのため Step 0 で使うと、例えば以下の違いが消えます。

    • trusted uv がない
    • GitHub repository read ができない
    • required Spark が利用不能
    • preferred Spark の fallback のみ利用可能
    • planned operations JSON が壊れている
    • producer 自体の internal failure

    Step 0 用には構造化結果を保持すべきです。Step 5 との後方互換性は、小さな adapter で維持できます。

    def capability_preflight_result(self) -> dict:
        """CLAUDE_GPT_WORKFLOW_CAPABILITIES_V1 をそのまま返す。"""
        ...
    
    def capability_preflight(self) -> bool:
        result = self.capability_preflight_result()
        return result.get("decision") in {"ready", "degraded"}

    Step 0 consumer は次のように扱います。

    ready
      -> 続行
    
    degraded
      -> directive が許した fallback だけで続行
      -> reason を current result の notes/blockers に保持
    
    blocked
      -> downstream callback を呼ばず停止
    
    producer invocation failure / malformed result
      -> environment_failure
      -> downstream callback を呼ばず停止
    

    新しい永続 schema、receipt、digest、authorization token は不要です。


    P0-5: Runtime Verification Applicability: not_applicable は誤り

    #2311 が証明しようとしているのは、単なる文言や関数シグネチャではありません。

    • producer subprocess が実際に呼ばれる
    • blocked で downstream callback がゼロ回になる
    • ready / degraded で一度だけ次へ進む
    • mutation や Agent dispatch が preflight より前に起きない
    • failure reason が保持される

    これは明確な runtime control-flow の検証です。リポジトリの runtime verification policy でも、not_applicable は静的検証だけで完結し、process・communication・I/O を必要としない場合に限定されています。

    したがって、#2311 は次に変更すべきです。

    runtime_verification_applicability:
      decision: immediate
      execution_environment: hermetic fake transport / fake gh
      skip_conditions: none
      fallback_policy: fallback・SKIPをPASSへ昇格させない

    ここで live Claude-GPT E2E まで要求する必要はありません。統合 live smoke は #2278 が既に担当しており、#2278 自身も #2311 の merge を前提としています。


    P0-6: canonical bootstrap と Allowed Paths が自己矛盾している

    現在の canonical preflight.run は先頭で uv run python3 run_refinement_preflight.py を実行します。

    そのため、workflow gate を単に run_refinement_preflight.py 内部へ追加すると、trusted uv を検査する前に uv 自体を起動した形になります。exact_skill_runtime が常に canonical resolver を経由することを production path で証明するか、system Python で起動する薄い start wrapper を置く必要があります。canonical resolver は既に信頼済み uv の絶対パスを返せるので、新しい resolver は不要です。

    しかし #2311 の Allowed Paths には、以下がありません。

    • command_registry.py
    • run_refinement_preflight.py
    • 新しい workflow-start entrypoint
    • canonical executor 周辺の focused test

    一方で、Allowed Paths 外が必要なら停止する Stop Condition になっています。つまり、正規経路へ配線しようとすると Issue 契約自身が停止条件を発火させます。

    推奨する production carrier

    最も分かりやすいのは、stdlib-only の薄い wrapper 一枚です。

    command_registry.py: preflight.run
      ↓
    workflow_start_entry.py
      1. structured capability preflight
      2. blockedなら既存compact blocked resultを返して終了
      3. ready/degradedならtrusted uv経由で
         run_refinement_preflight.pyを一度だけ起動
    

    SKILL.md は「preflight.run が workflow-start gate を所有する」と一文だけ記述し、判断ロジックを置かない方が適切です。


    P1-1: 現在の Verification Commands は変更前からほぼ green

    現 Issue の VC は、実質的に以下です。

    rg "workflow capability preflight" SKILL.md
    rg "Step 1" SKILL.md
    rg "capability_preflight" root_entry_router.py
    pytest scripts/tests -k capability_preflight

    問題は次のとおりです。

    PR #2307 の最終検証でも、既存の consumer tests は Step 5 側の Spark/planned operations 配線と audit suppression を対象としており、workflow-start gate は #2311 に残されています。

    最低限、以下の behavioral tests が必要です。

    test_workflow_start_blocked_does_not_invoke_inner_preflight
    test_workflow_start_blocked_performs_no_github_mutation
    test_workflow_start_ready_invokes_inner_once
    test_workflow_start_degraded_uses_declared_fallback_once
    test_workflow_start_passes_exact_spark_and_planned_operations
    test_workflow_start_preserves_block_reason
    test_workflow_start_malformed_producer_result_fails_closed
    test_step0_result_is_not_reused_as_step5_authorization
    

    P1-2: SKILL.md の line budget を無視している

    取得した current main の SKILL.md は 499行でした。既存 test_thin_entrypoint.py は 500行以下を強制しています。

    #2311 は Step 0 に複数の説明を追加する契約ですが、現在の VC は scripts/tests/ しか実行せず、tests/test_thin_entrypoint.py を実行しません。

    したがって、SKILL.md への追加は一文程度に限定し、少なくとも次を VC に含めるべきです。

    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.py -v

    詳細な branching semantics は Python 側へ置くべきで、thin entrypoint に再実装してはいけません。


    P1-3: Remaining Parent Gaps: なし は事実と異なる

    #2311 が完了しても、Parent #2271 には #2278 の integration E2E と closure verification が残ります。#2278 は明示的に #2311 の実装 PR merge 後の clean integration HEAD を要求しています。

    次の記述が適切です。

    ## Remaining Parent Gaps
    
    - [ ] #2278 による単一 clean integration HEAD 上の issue-to-impl E2E
    - [ ] Parent #2271 closure requirements の最終確認

    P1-4: Step 0 と Step 5 の preflight は別々の fresh call であるべき

    Step 0 gate は「workflow を開始できるか」を判定します。

    Step 5 gate は、refinement と mutation が終わった後の「今この状態で implementation-entry できるか」を判定します。

    両者の間では、GitHub auth、repository state、Spark route、planned operations、Issue 本文が変化し得ます。したがって、Step 0 の結果を保存・再提示して Step 5 authorization に使ってはいけません。

    Issue に次を明記してください。

    preflight_freshness:
      step0:
        invocation: once
        purpose: workflow_start
      step5:
        invocation: fresh
        purpose: implementation_entry
      reuse_step0_result_for_step5: forbidden
      persistent_authorization_artifact: forbidden

    これは既存 root_entry_router.py の process-local・non-persistent 方針とも整合します。


    非ブロッキングだが、workflow 負荷の観点で直す価値がある点

    現在の producer は spark_mode が未指定でも _run_env_only_preflight() を実行してから not_required を返します。Step 0 へ配線すると、Spark を使わない invocation でも毎回 proxy binary/auth probe が走ります。

    趣味開発の応答性を優先するなら、次の短絡で十分です。

    if not spark_mode:
        env_only_result = {}
        spark_status = SPARK_NOT_REQUIRED
    else:
        env_only_result = _run_env_only_preflight()
        spark_status = _spark_capability(...)

    これは security hardening ではなく、不要な subprocess と認証 probe を減らす単純な性能修正です。


    推奨する Acceptance Criteria

    ## Acceptance Criteria
    
    - [ ] AC1: canonical `preflight.run` production route が、Step 0g・Step 1・Step 1b・Step 4 より前に workflow capability preflight を実行する
    - [ ] AC2: preflight request は current invocation の authoritative Spark directive と bounded planned operations を含み、静的な空配列または無条件 superset に退化しない
    - [ ] AC3: `decision: blocked`、producer non-zero、timeout、malformed JSON の場合、inner refinement preflight・SubAgent dispatch・GitHub mutation callback が一度も呼ばれない
    - [ ] AC4: `decision: ready` の場合、既存 `run_refinement_preflight.py` が一度だけ呼ばれる
    - [ ] AC5: `decision: degraded` の場合、directive が許可した fallback だけで一度だけ続行し、reason が result に保持される
    - [ ] AC6: Step 0 result は Step 5 authorization に再利用されず、Step 5 は fresh preflight を実行する
    - [ ] AC7: SKILL.md は routing ownership の短い記述だけを持ち、500行以下と thin-entrypoint test を維持する
    - [ ] AC8: hermetic process-level tests が blocked/ready/degraded/malformed の各経路を検証する

    推奨する Verification Commands

    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_capability_gate.py \
      -v
    
    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/scripts/tests/test_root_entry_router_workflow_capability.py \
      -v
    
    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.py \
      -v
    
    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_loop_handoff_contract.py \
      -q

    推奨する Allowed Paths

    .claude/skills/issue-refinement-loop/SKILL.md
    .claude/skills/issue-refinement-loop/scripts/root_entry_router.py
    .claude/skills/issue-refinement-loop/scripts/workflow_start_entry.py
    .claude/skills/issue-refinement-loop/scripts/command_registry.py
    .claude/skills/issue-refinement-loop/scripts/tests/
    

    workflow_start_entry.py を作らず既存 wrapper を system-Python bootstrap 化する設計なら、その代わりに run_refinement_preflight.py を Allowed Paths へ追加します。


    採用しない方がよいもの

    今回の修正に、以下は不要です。

    公式には hook の方が強い enforcement を提供しますが、ここで必要なのは adversarial な利用者への防御ではなく、canonical workflow の接続ミスをなくすことです。同期 wrapper と数本の hermetic behavioral test で十分です。live Claude-GPT 上の最終成立性は #2278 に残すのが妥当です。

    verdict: REQUEST_CHANGES
    implementation_ready: false
    core_blockers:
      - canonical production caller が未定義
      - Step 0g mutation が ordering AC から漏れている
      - Spark directive / planned_operations の正本が未定義
      - structured result が boolean に失われる
      - runtime verification が不当に not_applicable
      - Allowed Paths が canonical wiring を許可していない
    recommended_scope:
      - executable workflow-start gate
      - focused hermetic runtime tests
      - no new hook/broker/ledger

    本レビューでは live Issue・関連 Issue/PR/comment と current main の実装資産を確認しました。リポジトリのローカル checkout による pytest 全体の再実行までは行っていません。

  3. squne121 commented on Aug 23, 2026

    @squne121
    OwnerAuthor

    Refinement Loop 完了報告

    結果: approved(deterministic review VERDICT: approve、semantic design review 3ラウンド実施し low finding 1件を除き全て解消・残る low finding は AC8 の baseline-expect 注釈のみで non-blocking)

    経緯

    OWNER の REQUEST_CHANGES レビュー(#2311 (comment) 、P0-1〜P0-6, P1-1〜P1-4)を受けて Issue 契約を全面改訂した。

    • production caller 未定義(P0-1)→ canonical preflight.run(bare エントリ)から到達する新設 workflow_start_entry.py を明記
    • gate 配置順序(P0-2)→「Step 1 より前」ではなく「Step 0g mutation・SubAgent dispatch より前」に修正
    • capability request 未定義(P0-3)→ spark_mode/spark_fallback/planned_operations[].{phase,actor_role,requires_mutation} を明記、caller-side 欠落/malformed の fail-closed も専用テストで担保
    • structured result 消失(P0-4)→ capability_preflight_result() を新設し boolean adapter は後方互換 wrapper化
    • Runtime Verification Applicability 誤り(P0-5)→ immediate に変更、hermetic behavioral test 方針を明記
    • Allowed Paths 自己矛盾(P0-6)→ command_registry.py / workflow_start_entry.py 等を Allowed Paths に追加
    • VC 品質(P1-1/1-2)→ baseline-expect 注釈・canonical uv run --locked pytest 形式に統一、AC ごとに単一 VC
    • Remaining Parent Gaps 誤記載(P1-3)→ 統合: merged Child A/B/C の単一 clean HEAD で issue-to-impl E2E を検証する #2278 を明記
    • Step 0/Step 5 freshness 分離(P1-4)→ 独立した fresh call であることを明記

    Step 2.5 Semantic Design Review(3ラウンド)

    • Round 1: high finding 2件(AC5 caller-side テスト未整備/capability_preflight_result 実呼び出し検証欠落)→ AC5/AC9/AC2 拡張で解消
    • Round 2: high finding 1件(requires_owner_choice: true。AC1/In Scope が bare preflight.run のみを差し替え、Step 0g mutation を実際にゲートする anchor-comment 駆動経路 preflight.run.with_anchor/.with_human_context/.with_agent_report には配線が届いていなかった)→ 本 Issue のスコープを bare preflight.run(parent-owned preflight / isolation worktree 委譲経路)に明示的に narrow し、anchor-comment 駆動経路の配線を Remaining Parent Gaps の follow-up として明記する方針で解決(scope 拡張は行わず、実装: Claude-GPT に workflow-profile capability preflight と controlled GitHub route を配線する #2273 からの分離と同じ narrowing パターンを踏襲)。medium finding 2件も解消。
    • Round 3: low finding 1件(AC8 の VC に baseline-expect 注釈が無い、非 blocking)が残るが、route_high_open_to_rewrite policy 上 rewrite を要求しない severity のため effective_verdict: approve で終了。

    特記事項(OWNER 確認推奨)

    Round 2 で発見された scope narrowing(bare preflight.run のみを対象とし、anchor-comment 駆動経路のゲートを follow-up Issue に分離する)は、Parent #2271 の順序契約を「実際の主要な運用経路(anchor-comment 駆動)」ではなく「parent-owned preflight 経路」にのみ適用する判断です。本 Issue の実装着手前に、この scope narrowing が Parent #2271 の意図と整合するか OWNER の確認を推奨します(Remaining Parent Gaps に follow-up Issue 起票の必要性を記載済み)。

    次のアクション

    Issue は implementation-entry 可能な状態です。実装(impl-review-loop への handoff)は本 refinement loop の依頼スコープ外のため、本 run では起動していません。人間が確認後、impl-review-loop 等で実装に着手してください。

  4. self-assigned this
    on Aug 23, 2026
  5. squne121 commented on Aug 23, 2026

    @squne121
    OwnerAuthor

    推奨アクション

    Option 1 を採用し、同時に Option 2 の内容も Issue 契約へ反映するのが妥当です。つまり、#2311 を別 Issue に分割せず、同一 PR で registry と fail-closed policy の契約を原子的に更新する方針です。

    現在の main では command_registry.py の preflight.run が run_refinement_preflight.py を指しています。 一方、skill_runtime_command_policy.py も _EXPECTED_ARGV_BY_COMMAND["preflight.run"] に同じ旧 argv を独立して固定しており、validate_registry_entry() は完全一致しなければ argv_template_mismatch を返します。

    しかもこれは死んだ検査ではありません。skill_runtime_exec.py は実 dispatch の直前に registry を読み、validate_registry_entry() を実行した後、registry の argv を render して child process を起動しています。したがって policy だけ旧値のまま #2311 を実装すると、指摘どおり production path が fail-closed します。

    Option 3 の follow-up 分離は不適切です。これは「あとで直せる付随機能」ではなく、AC1 の contract consumer です。registry 側だけ先に merge 可能にすると、意図的に壊れた中間状態を main に作ることになります。

    また、現在の #2311 は Allowed Paths 外変更を Stop Condition にしています。 リポジトリ自身の scope guard も、新しい Allowed Paths architecture layer を human escalation とし、承認後も contract review / refinement preflight / allowed-path gate の fresh rerun を要求しています。今回停止したサブエージェントの判断は正しいです。

    なお .specify/memory/constitution.md 自体は現在 non-normative pointer と明記されているので、Claude Code には「constitution がそう言っている」ではなく、実際の scope-signal-guard / Issue contract を根拠に処理させる方が正確です。

    追加スコープはまず以下に限定するのがよいです。

    • scripts/agent-guards/skill_runtime_command_policy.py
    • その registry-policy parity / real dispatch を証明する focused test。既存テストを変更するか専用テストを追加するかは実装調査で決める。

    skill_runtime_exec.py 自体は registry を動的 render しているため、今回の blocker 解消だけなら変更不要です。ただし現在の pre-dispatch integrity check には run_refinement_preflight.py の名前が残っているため、新しい workflow_start_entry.py を first child にした際にもそのチェックの意味が成立するかはサブエージェントに必ず再確認させるべきです。必要変更と判定された場合は、勝手に追加せず再度 Stop Condition とします。

    Claude Code は最近の版ではサブエージェントを background で動かすことがあるので、プロンプトでは foreground を明示するのが確実です。公式仕様でも foreground subagent は完了まで main conversation を block します。([Claude]1)

    Claude Code 作業プロンプト — Issue #2311 再スコープ・実装再開

    対象リポジトリ: squne121/loop-protocol
    対象 Issue: https://github.com/squne121/loop-protocol/issues/2311

    OWNER decision

    Issue #2311 の停止理由について、人間判断は以下で確定した。

    Option 1 を採用し、Option 2 の内容も同時に Issue 契約へ反映する。

    すなわち:

    1. scripts/agent-guards/skill_runtime_command_policy.py と必要最小限の focused tests を Issue 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 の Allowed Paths / In Scope に追加する。
    2. AC1 を、command_registry.py だけを変更する契約ではなく、canonical preflight.run argv と skill_runtime_command_policy.py の exact argv policy を 同一変更で同期する契約として明記する。
    3. この変更は Issue 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 と同一 PR で行う。
    4. この mismatch を別 follow-up Issue には分離しない。
    5. exact policy を一般化・緩和して mismatch を回避してはならない。preflight.run の新しい canonical argv を exact contract として明示的に更新する。

    この指示は scope delta に対する interactive human/OWNER decision である。リポジトリの既存 contract-update / trusted human-context materialization mechanism が必要ならそれを使用し、author provenance を捏造しないこと。


    最重要: 実装前に SubAgent を使うこと

    repo-tracked file を変更する前に、親 Claude Code セッションから read-only の SubAgent を1つ foreground で起動すること。

    • Background 実行は禁止。
    • run_in_background 相当を使用しない。
    • SubAgent が完了するまで親エージェントは実装・Issue mutation・commit・PR 作成へ進まない。
    • SubAgent の最終結果を受け取ってから親エージェントが findings を検証・統合する。
    • SubAgent からさらに SubAgent を起動させない。nested delegationは禁止。
    • SubAgent が API error 等で完了しなかった場合、partial result を「完了」とみなさず、再実行または停止する。

    SubAgent には最低限、以下を独立調査させること。

    1. Issue 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 の最新 body / comments / Allowed Paths / Stop Conditions / AC / Verification Commands を GitHub から取得する。

    2. current main の以下を読む。

      • .claude/skills/issue-refinement-loop/scripts/command_registry.py
      • scripts/agent-guards/skill_runtime_command_policy.py
      • scripts/agent-guards/skill_runtime_exec.py
      • 関連する scripts/agent-guards/tests/
      • .claude/skills/issue-refinement-loop/scripts/tests/
      • .claude/skills/issue-refinement-loop/references/scope-signal-guard.md
    3. 以下の既知 finding を独立検証する。

      • AC1 に従い REGISTRY["preflight.run"]["argv"] の child script を run_refinement_preflight.py から workflow_start_entry.py に変更すると、
      • skill_runtime_command_policy._EXPECTED_ARGV_BY_COMMAND["preflight.run"] が旧 argv のままなので、
      • validate_registry_entry() が argv_template_mismatch で fail-closed すること。
    4. skill_runtime_exec.py が real dispatch 前に validate_registry_entry() を実際に通ることを確認する。

    5. skill_runtime_exec.py 自体の変更が必要かを確認する。

      • 特に、non-decide.run 用の pre-dispatch script integrity check が run_refinement_preflight.py を固定参照している点を確認する。
      • 新しい first child が workflow_start_entry.py になっても security/runtime contract が成立するなら「変更不要」と明記する。
      • skill_runtime_exec.py の変更が本当に必要なら、それは新しい Allowed Paths delta なので、実装せず親へ報告する。
    6. policy と registry の同期に必要な最小 test surface を特定する。

    7. anchor siblings (preflight.run.with_anchor, .with_human_context, .with_agent_report) を今回変更する必要がないことも確認する。

    SubAgent の出力は次だけに絞ること:

    • confirmed findings
    • required files
    • tests to add/update
    • whether skill_runtime_exec.py must change
    • any newly discovered scope delta
    • GO / STOP recommendation

    SubAgent 完了を待ってから以下へ進むこと。


    Phase 1: Issue contract を先に修復

    SubAgent が既知 mismatch を確認し、skill_runtime_exec.py 等の追加 scope が不要なら、コード変更より先に Issue #2311 の契約を修復する。

    既存 Issue body を全面的に書き換えず、必要箇所だけを最小変更する。

    Allowed Paths

    少なくとも以下を追加する:

    - scripts/agent-guards/skill_runtime_command_policy.py

    focused test については SubAgent の調査結果を基に、必要最小の exact path または test directory を追加する。

    既存の unrelated agent-guard 実装全体を Allowed Paths に広げない。

    In Scope

    次を明示する:

    command_registry.py の canonical bare preflight.run argv 更新と同時に、scripts/agent-guards/skill_runtime_command_policy.py の _EXPECTED_ARGV_BY_COMMAND["preflight.run"] を同じ canonical argv へ同期する。

    これは policy relaxation ではなく、同一 command contract の atomic migration である。

    AC1

    AC1 を概ね次の意味になるよう更新する:

    canonical bare preflight.run は workflow_start_entry.py を起動し、skill_runtime_command_policy.py の exact argv contract も同一 argv と一致する。real privileged executor の validate_registry_entry() を通過し、argv_template_mismatch を発生させない。anchor-comment sibling entries は変更しない。

    文面は既存 Issue の用語・schema・style に合わせること。

    Tests / Verification

    以下を runtime/behavioral evidence として要求すること。

    • canonical REGISTRY["preflight.run"] が workflow_start_entry.py を指す。
    • validate_registry_entry("preflight.run", ...) が新 canonical registry entry を受理する。
    • policy に旧 run_refinement_preflight.py の bare preflight.run template が残っていない。
    • preflight.run.with_anchor / .with_human_context / .with_agent_report の argv は変更されていない。
    • privileged executor 経路で bare preflight.run が argv_template_mismatch にならず、新 wrapper へ dispatch 可能である。
    • Issue 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 既存の behavioral tests / backward compatibility tests が PASS する。

    Issue contract 更新後、既存 workflow が要求する contract review、refinement preflight、allowed-path gate を fresh に再実行する。

    fresh rerun が green になるまでは implementation GO とみなさない。


    Phase 2: 実装

    fresh contract checks が green になった場合のみ実装へ進む。

    Issue #2311 の最新 AC を正本として実装する。

    特に以下を守ること。

    実装中にさらに Allowed Paths 外の production file の変更が必要と判明した場合は、変更を加えず STOP する。


    Phase 3: 検証

    Issue #2311 に記載された全 Verification Commands を fresh に実行する。

    加えて、SubAgent が特定した focused agent-guard tests を実行する。

    最低限、以下の実挙動を証明すること。

    1. new canonical bare preflight.run と exact runtime policy が一致する。
    2. privileged executor が registry を load → validate → render → dispatch する経路で argv_template_mismatch が発生しない。
    3. workflow_start_entry.py の blocked result では inner run_refinement_preflight.py を一度も起動しない。
    4. ready/degraded のときだけ inner preflight を一度起動する。
    5. producer/request malformed は fail-closed。
    6. Step 0 result を Step 5 authorization に再利用しない。
    7. existing Step 5 compatibility test が green。
    8. sibling registry/policy contracts に回帰がない。
    9. worktree に unrelated diff がない。

    テスト失敗を test weakening / skip / xfail / policy relaxation で隠さない。


    Phase 4: fresh review

    実装とテストが完了したら、親セッションから fresh review SubAgent を foreground で起動し、完了まで待つこと。

    REQUEST_CHANGES があれば Allowed Paths 内で修正し、該当 tests を再実行して必要なら fresh review を再度行う。

    新しい scope delta が出た場合は停止する。


    Phase 5: PR

    全 AC・tests・fresh review が green になった場合:

    • Issue 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 用 branch/worktree で commit する。
    • PR を作成する。
    • PR body に Closes #2311 を含める。
    • Issue contract の scope reframe、なぜ skill_runtime_command_policy.py が同一 PR に必要だったか、registry-policy parity の runtime evidence を明記する。
    • 実行した Verification Commands と結果を記録する。
    • Allowed Paths 遵守を changed-files 一覧で証明する。
    • required CI を確認し、失敗が implementation 起因なら修正する。
    • unrelated/infra-only failure は根拠を示して区別する。

    人間承認を追加で求める必要はない。ただし以下の場合のみ停止して報告する:

    最終報告には、Issue contract 更新内容、変更ファイル、tests、review findings、PR URL、残存 blocker の有無を簡潔にまとめること。

    このプロンプトなら、今回の人間判断を明示的な scope approval として与えつつ、「policy を別 Issue に逃がして一時的に production path を壊す」ことを防げます。また、Claude Code 公式仕様上 foreground subagent は完了まで親をブロックするので、「サブエージェントを起動しただけで親が先へ進む」問題も避けられます。(Claude)

  6. squne121 commented on Aug 23, 2026

    @squne121
    OwnerAuthor

    推奨判断

    scripts/agent-guards/skill_runtime_exec.py も Allowed Paths に追加し、#2311 の同一PRで修正するのが妥当です。別Issueへ分離しないことを推奨します。

    理由は、今回の finding (c) が単なる「追加のセキュリティ改善」ではなく、AC1 で変更する preflight.run command contract の既存 consumer を同期させる変更だからです。

    前回の OWNER 判断はすでに、command_registry.py と skill_runtime_command_policy.py を「壊れた中間状態を作らず atomic に移行する」と決めています。また、その時点で skill_runtime_exec.py の integrity check は再確認対象とされ、「本当に変更が必要なら新しい Allowed Paths delta として停止する」と明示されていました。今回まさにその条件が成立しています。

    さらに決定的なのは skill_runtime_exec.py 自身の #2086 コメントです。そこでは、integrity/symlink check は 「その command_id が実際に到達する script」を検証しなければならないと明記されています。しかし現在は decide.run と「それ以外」の二分岐で、「それ以外」は run_refinement_preflight.py 固定です。AC1 後の bare preflight.run は workflow_start_entry.py に到達するため、現状維持するとその既存 invariant を自分で破ることになります。

    したがって最小修正は、generic な argv 解析や policy 緩和ではなく、明示的な三分岐です。

    if is_decide_command:
        script_name = "decide_next_loop_action.py"
    elif args.command_id == "preflight.run":
        script_name = "workflow_start_entry.py"
    else:
        script_name = "run_refinement_preflight.py"

    これなら preflight.run.fixture や anchor siblings は従来どおり run_refinement_preflight.py を検証でき、#2311 の scope narrowing も維持できます。skill_runtime_command_policy.py の exact argv も現在は旧 script 名を固定しており、完全一致で argv_template_mismatch にすることも確認できます。

    テストについて

    提示された4本の real-dispatch fixture は実際に bare preflight.run の registry stub と run_refinement_preflight.py をseedしているため、workflow_start_entry.py の first-hop seed を追加する必要があります。

    一方、検索上 run_refinement_preflight.py を参照するテストは他にもあります。たとえば bytecode-cache 系は test-only preflight.run.fixture → real inner preflight を意図的に検証しているので、bare preflight.run の移行に便乗して変えるべきではありません。 したがって Claude Code には「既知4本だけを機械的変更」ではなく、SubAgent に bare preflight.run / sibling / direct-inner-test を分類させるのが安全です。

    また、現在の Issue 本文の Allowed Paths には、前回 OWNER が承認した skill_runtime_command_policy.py すらまだ反映されていません。実装より先に Issue contract を更新するべきです。

    Claude Code は foreground SubAgent なら完了まで main conversation を block します。現行仕様ではSubAgentが background で走る場合もあるため、今回のような phase gate では foreground を明記し、結果を受け取るまで次へ進まない指示が適切です。(Claude)

    以下をそのまま渡すことを推奨します。

    Claude Code 作業プロンプト — Issue #2311 scope delta 承認・atomic migration 実装

    対象リポジトリ: squne121/loop-protocol
    対象 Issue: https://github.com/squne121/loop-protocol/issues/2311

    OWNER decision

    Phase 0 で報告された新しい Allowed Paths delta について、OWNER 判断は以下で確定した。

    scripts/agent-guards/skill_runtime_exec.py を Issue #2311 の Allowed Paths / In Scope に追加し、同一 Issue・同一 PR で修正してよい。

    これは別 Issue に分離しない。

    理由:

    • AC1 は canonical bare preflight.run の first-hop child を run_refinement_preflight.py から workflow_start_entry.py へ変更する command-contract migration である。
    • skill_runtime_command_policy.py の exact argv contract と同様、skill_runtime_exec.py の pre-dispatch integrity/symlink check もその command contract の既存 consumer である。
    • skill_runtime_exec.py 自身の既存 実装: operator-selected human context の scope reframe を自動継続し scope expansion stop を撤去する #2086 コメントが、「integrity check は command_id が実際に到達する script を検証する」という invariant を明示している。
    • AC1 適用後も bare preflight.run について run_refinement_preflight.py を検証し続ける状態は、機能上 dispatch できても integrity check の意味を空洞化する。
    • 新しい hook / broker / ledger / authorization mechanism の追加ではなく、既存検査対象を実際の first-hop child に同期するだけなので、前回 OWNER 判断の atomic migration 方針に含める。
    • generic な policy 緩和は行わない。

    承認する最小実装

    skill_runtime_exec.py の script integrity target を概念的に次の三分岐へすること。

    if is_decide_command:
        script_name = "decide_next_loop_action.py"
    elif args.command_id == "preflight.run":
        script_name = "workflow_start_entry.py"
    else:
        script_name = "run_refinement_preflight.py"

    実コードの既存構造に合わせて最小差分で実装すること。

    以下は変更しない。

    • preflight.run.fixture
    • preflight.run.with_anchor
    • preflight.run.with_human_context
    • preflight.run.with_agent_report
    • その他、現在 run_refinement_preflight.py を first-hop とする sibling command

    preflight_script_invalid 等の既存 error contract も、変更が不要なら維持する。


    Phase 0 — read-only再確認

    コード編集・Issue mutationを始める前に、SubAgentを使用すること。

    SubAgent は foreground で実行すること。background に送らないこと。
    各SubAgentが完全に終了し、その最終結果を受け取るまで main agent は次の Phase に進んではならない。

    nested SubAgent delegationは禁止。

    SubAgent A — command-contract / scope auditor

    read-only で以下を確認させる。

    1. Issue 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 の最新 body / comments / AC / Allowed Paths / Stop Conditions を取得する。

    2. current main の以下を読む。

      • .claude/skills/issue-refinement-loop/scripts/command_registry.py
      • scripts/agent-guards/skill_runtime_command_policy.py
      • scripts/agent-guards/skill_runtime_exec.py
    3. 次を独立に再検証する。

      • bare preflight.run の現在の registry argv
      • _EXPECTED_ARGV_BY_COMMAND["preflight.run"]
      • validate_registry_entry() の exact equality
      • real dispatch 前に validate_registry_entry() が呼ばれること
      • pre-dispatch script integrity/symlink check の target selection
    4. AC1 後の正しい atomic contract が以下であることを検証する。

      • registry bare preflight.run → workflow_start_entry.py
      • exact argv policy → 同じ workflow_start_entry.py
      • integrity target → 同じ workflow_start_entry.py
    5. anchor siblings / preflight.run.fixture を変更する必要がないことを確認する。

    6. これ以外に production source の新しい Allowed Paths delta がないか検索する。

    出力は以下だけに限定する。

    • confirmed findings
    • required production files
    • newly discovered scope delta
    • siblings that must remain unchanged
    • GO / STOP recommendation

    SubAgent A の完了を待つこと。

    SubAgent B — test-impact auditor

    SubAgent A 完了後に foreground で起動する。

    read-only で、run_refinement_preflight.py, preflight.run, workflow_start_entry.py, skill_runtime_exec.py を参照するテストを inventory し、以下に分類する。

    1. bare preflight.run real-dispatch fixture
    2. preflight.run.fixture
    3. anchor-bound sibling
    4. run_refinement_preflight.py を直接テストする inner-preflight test
    5. unrelated reference

    少なくとも以下の既知4ファイルを確認する。

    • scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py
    • scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
    • scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py
    • scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py

    また、

    • scripts/agent-guards/tests/test_skill_runtime_policy_commands.py

    の registry-policy parity test surface を確認する。

    既知4本について、bare preflight.run の registry stub が workflow_start_entry.py を指すよう変更した場合に、fixture repo に最小 workflow_start_entry.py seed が必要か確認する。

    preflight.run.fixture や direct-inner-preflight test を、単に文字列一致したという理由だけで変更対象にしないこと。

    出力:

    • tests that must change
    • tests that must remain unchanged
    • recommended focused integrity regression test
    • any newly required test file outside the approved set
    • GO / STOP recommendation

    SubAgent B の完了を待つこと。

    Phase 0 Stop Condition

    以下の場合はコードもIssueも変更せず停止して報告する。

    • 下記 OWNER 承認済み production/test paths 以外の変更が必要
    • anchor sibling の production behavior 変更が必要
    • fixed schema/key/type contract の変更が必要
    • 新規 hook/broker/ledger/state store 等が必要
    • nested SubAgent が必要
    • destructive operation / secret / credential material が必要

    Phase 1 — Issue #2311 contract repair

    SubAgent A/B が GO の場合のみ進む。

    実装より先に Issue #2311 の契約を修復する。

    既存 body を全面書き換えせず、必要箇所のみ最小編集する。

    1. Allowed Paths

    既存 Allowed Paths に以下を追加する。

    scripts/agent-guards/skill_runtime_command_policy.py
    scripts/agent-guards/skill_runtime_exec.py
    scripts/agent-guards/tests/test_skill_runtime_policy_commands.py
    scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py
    scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
    scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py
    scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py
    

    Phase 0 の inventory でさらにファイルが必要と判明した場合は、勝手に追加せず STOP する。

    2. In Scope

    AC1 の command migration は以下3 consumer を同一変更で同期する、と明記する。

    1. command_registry.py

      • bare preflight.run canonical argv
    2. skill_runtime_command_policy.py

      • _EXPECTED_ARGV_BY_COMMAND["preflight.run"]
    3. skill_runtime_exec.py

      • pre-dispatch integrity/symlink check の actual first-hop script target

    三者とも workflow_start_entry.py を指すこと。

    3. AC1

    AC1 を最低限、以下の意味になるよう更新する。

    • canonical bare preflight.run は workflow_start_entry.py を起動する。
    • exact argv fail-closed policy も同じ canonical argv を要求する。
    • real executor の pre-dispatch integrity/symlink check も bare preflight.run について workflow_start_entry.py を検証する。
    • 三者を同一PRで atomic に変更する。
    • anchor siblings と preflight.run.fixture は変更しない。

    4. Verification

    agent-guard focused tests も verification surface に追加する。

    Issue contract repair 後、リポジトリ所定の contract review / refinement preflight / allowed-path gate を fresh に再実行する。

    fresh check が新しい scope delta を返した場合は STOP。


    Phase 2 — 実装

    Issue contract が fresh validation を通った場合のみコード変更する。

    A. Original #2311 implementation

    Issue 最新 body の AC を正本として、元々の #2311 実装を完了する。

    主対象:

    • .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/root_entry_router.py
    • .claude/skills/issue-refinement-loop/SKILL.md
    • .claude/skills/issue-refinement-loop/scripts/tests/

    既存 AC2〜AC10 を勝手に弱めない。

    B. exact argv policy

    skill_runtime_command_policy.py の bare preflight.run expected argv を workflow_start_entry.py に同期する。

    exact equality 自体は維持する。

    generic allowlist 化、prefix match、任意 script 許可などへの緩和は禁止。

    C. pre-dispatch integrity target

    skill_runtime_exec.py を最小差分で修正する。

    要件:

    • decide.run → decide_next_loop_action.py
    • bare preflight.run → workflow_start_entry.py
    • その他の既存 preflight profiles → 従来の run_refinement_preflight.py

    registry argv から任意 path を無条件に信頼する generic 実装へ広げない。

    D. agent-guard fixture migration

    bare preflight.run を real executor 経由で実行する既知4 fixture を更新する。

    各 fixture の目的を維持すること。

    推奨形:

    skill_runtime_exec.py
      -> fixture command_registry.py
      -> workflow_start_entry.py       # new first-hop stub
      -> existing run_refinement_preflight.py stub
    

    workflow_start_entry.py fixture は、そのテストが capability-preflight semantics 自体を検証する必要がない場合、CLIを受け取り既存 inner stub へ委譲する最小 harness とする。

    各既存テストの本来の検証対象
    (unauthorized write detection / session lifecycle / shadow log / no-worktree 等)
    を capability-preflight test に変質させない。

    wrapper 自身の capability semantics は #2311 の dedicated behavioral tests で検証する。

    E. integrity regression

    少なくとも focused regression を1ケース追加する。

    bare preflight.run について、

    • run_refinement_preflight.py は regular file として存在する
    • workflow_start_entry.py が missing または symlink

    という状態で executor が preflight_script_invalid 相当で fail-closed することを証明する。

    これにより「旧 inner script が存在するだけで integrity check が通ってしまう」回帰を防ぐ。

    regular workflow_start_entry.py なら integrity check を通過して actual dispatch へ進む positive case も、既存 fixture でカバーされないなら追加する。


    Phase 3 — 検証

    まず Issue #2311 に記載された 全 Verification Commands を fresh に実行する。

    その後、少なくとも以下を実行する。

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_commands.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py -v

    さらに Issue 本文が要求する以下の backward-compat / thin-entrypoint verification を必ず実行する。

    SKIP や fallback 成功を PASS に昇格しない。

    失敗を「今回と無関係」と推測だけで除外しない。原因を特定する。


    Phase 4 — fresh adversarial review

    実装とテスト完了後、別の reviewer SubAgent を foreground で起動する。

    background にしない。
    reviewer 完了まで main agent は PR 作成/更新へ進まない。

    reviewer には少なくとも以下を確認させる。

    • Issue 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 最新 AC 全件
    • registry / exact policy / integrity target の3者 parity
    • bare preflight.run actual first-hop が workflow_start_entry.py であること
    • missing/symlink wrapper が旧 inner script の存在によって誤って許可されないこと
    • anchor siblings / preflight.run.fixture が意図せず変更されていないこと
    • wrapper blocked / ready / degraded semantics
    • Step 0 と Step 5 の freshness 分離
    • Allowed Paths compliance
    • test fixture が production semantics を過剰にmockしていないこと
    • generic security/policy relaxation が入っていないこと

    出力:

    • blocking findings
    • non-blocking findings
    • AC coverage gaps
    • test gaps
    • APPROVE / REQUEST_CHANGES

    reviewer が REQUEST_CHANGES の場合は、Allowed Paths 内で直せるものだけ修正し、affected tests + Issue全VCを再実行する。

    修正に新しい Allowed Paths が必要なら STOP。


    Phase 5 — diff / PR

    最終的に変更ファイル一覧を取得し、Issue #2311 の Allowed Paths と機械的に照合する。

    Allowed Paths 外が1件でもあれば PR を完成扱いにしない。

    既存の #2311 implementation PR が存在すればそれを更新する。存在しなければ repository workflow に従い PR を作成する。

    PR body には少なくとも以下を記載する。

    • Closes #2311

    • OWNER-approved scope delta:

      • skill_runtime_command_policy.py
      • skill_runtime_exec.py
      • focused agent-guard tests
    • registry / policy / integrity target を atomic migration したこと

    • anchor siblings / preflight.run.fixture は変更していないこと

    • Verification Commands と実結果

    • fresh reviewer verdict

    • Allowed Paths compliance

    merge は行わない。


    最終報告

    以下の形式で簡潔に報告する。

    1. Issue contract repair 内容
    2. SubAgent A/B の結論
    3. implementation delta
    4. changed files
    5. test / VC results
    6. reviewer verdict
    7. PR URL
    8. remaining blocker / follow-up(なければ none)

    重要: Phase間を飛ばさないこと。特に 各 foreground SubAgent の完了を必ず待ってから次へ進むこと。

    この方針なら、今回の delta は「scope creep」として無制限に取り込むのではなく、bare preflight.run の first-hop migration に直接従属する consumer とテストだけを追加承認する形になります。最も小さく、かつ stale integrity check を残さない境界です。

  7. squne121 commented on Aug 23, 2026

    @squne121
    OwnerAuthor

    結論は、test_skill_runtime_exec_anchor.py の追加自体は承認してよいが、現時点ではまだ実装再開 NO-GO です。

    理由は、SubAgent B の inventory に少なくとも1件の漏れがあるためです。scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py は確かに、fixture 内の bare preflight.run が旧 run_refinement_preflight.py を向き、test_executor_preflight_run_unaffected_without_anchor が real executor 経由で実際に dispatch しているので、今回の migration に追随する必要があります。これは anchor sibling の production behavior 変更ではなく、bare command の fixture parity 修正として扱えます。

    ただし、tests/agent_guards/test_worktree_scope_guard.py も同じく未承認の affected test です。このファイルも production skill_runtime_exec.py / skill_runtime_command_policy.py を temporary repo にコピーし、fixture の bare preflight.run を旧 run_refinement_preflight.py に固定したうえで、skill_runtime_exec.py --command-id preflight.run を実行しています。policy 側の exact argv を workflow_start_entry.py に更新すると、この fixture はそのままでは argv_template_mismatch で壊れます。

    これはまさに Phase 0 の「approved set 外の必要ファイルが判明したら STOP」に該当します。 しかも production policy は bare command の argv を byte-for-byte exact match しており、executor 自身にも現在 run_refinement_preflight.py を検証する integrity check があるため、fixture の見落としは実際の回帰になります。

    したがって推奨は、scope を1ファイルずつ継ぎ足すのではなく、read-only の「Phase 0R」だけをもう一度行い、whole-repo で affected fixture set を有限集合として確定することです。そこで新規必要ファイルが test_skill_runtime_exec_anchor.py と tests/agent_guards/test_worktree_scope_guard.py の2本だけと独立確認できたら、両方を一括 OWNER 承認して同一PRへ入れるのが最も効率的です。なお #2311 自体は bare preflight.run のみに意図的に narrow され、anchor sibling の production wiring は follow-up 扱いなので、この境界は維持すべきです。

    Claude Code は現行仕様では subagent が background になり得るため、foreground を明示し、各 agent の完了結果を受け取るまで次へ進まない指示を入れるのが適切です。公式にも foreground subagent は完了まで main conversation を block すると明記されています。([Claude]1)

    以下をそのまま渡すのを推奨します。

    対象リポジトリ: squne121/loop-protocol
    対象 Issue: https://github.com/squne121/loop-protocol/issues/2311

    目的

    Issue #2311 の Phase 0 は一度 STOP している。

    直前の Phase 0 では、SubAgent A は production files について GO、新規 delta なしと判定した。一方 SubAgent B は OWNER 承認済み test set 外に

    script/agent-guards/tests/test_skill_runtime_exec_anchor.py

    ではなく正確には

    scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py

    が必要と発見した。

    さらに OWNER 側の独立確認で、少なくとも次のもう1ファイルも同種の affected fixture であることが判明している。

    tests/agent_guards/test_worktree_scope_guard.py

    このファイルも production skill_runtime_exec.py / skill_runtime_command_policy.py を temporary repo にコピーし、bare preflight.run の fixture registry argv を run_refinement_preflight.py に固定した上で real executor dispatch を行う。

    したがって、直ちにコード編集を再開せず、まず Phase 0R として scope inventory を一度だけ whole-repo で reconciliation すること。

    OWNER decision

    以下を OWNER decision とする。

    1. scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py は、bare preflight.run migration に必要な fixture parity 修正として追加候補に承認する。

    2. tests/agent_guards/test_worktree_scope_guard.py も同じ理由で追加候補に承認する。

    3. ただし、この2ファイルだけを追加して即実装開始してはならない。Phase 0R の2つの read-only SubAgent が whole-repo inventory を独立確認し、これ以外の新規 required path がないことを確認してから承認を確定する。

    4. Phase 0R でさらに required path が1つでも発見された場合は、コード変更・Issue mutationを行わず再度 STOP して OWNER に完全な finite path list を報告する。

    5. anchor sibling の production behavior は変更しない。

    6. test_skill_runtime_policy_commands.py は現在の調査で migration-specific dispatch assertion を持たないことが判明している。Allowed Paths に残っていても、変更不要なら変更しない。ファイル変更数を稼ぐ目的で触らない。

    7. exact policy を一般化・緩和しない。bare preflight.run の新 canonical argv を exact contract として同期する。


    Phase 0R — scope reconciliation

    repo-tracked file を一切変更する前に SubAgent を使用すること。

    SubAgent は必ず foreground で実行すること。background に送らないこと。

    各 SubAgent が完全に終了し、main session がその最終レポートを受け取るまで次の Phase に進んではならない。

    nested SubAgent delegation は禁止する。

    SubAgent A — whole-repo fixture inventory

    read-only で実行する。

    目的は、今回の bare preflight.run first-hop migration

    run_refinement_preflight.py
    →
    workflow_start_entry.py

    によって変更が必要になる test fixture / regression test を whole-repo で列挙すること。

    最低限、以下のパターンを repository 全体で探索する。

    • _install_skill_runtime_exec_fixture
    • production skill_runtime_exec.py を temporary repo に copy する fixture
    • production skill_runtime_command_policy.py を temporary repo に copy する fixture
    • fixture 内で REGISTRY["preflight.run"] 相当を手書きしている箇所
    • bare preflight.run argv に run_refinement_preflight.py を固定している箇所
    • --command-id preflight.run を real skill_runtime_exec.py subprocess へ渡す test
    • validate_registry_entry() を通過する fixture
    • preflight_script_invalid の target script existence に依存する fixture

    特に以下を必ず確認する。

    Previously OWNER-approved:

    • scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py
    • scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
    • scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py
    • scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py
    • scripts/agent-guards/tests/test_skill_runtime_policy_commands.py

    Newly discovered:

    • scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
    • tests/agent_guards/test_worktree_scope_guard.py

    検索ヒットを機械的に required path にしてはならない。各 hit を次に分類すること。

    • bare preflight.run real-dispatch fixture → migration required
    • bare parser / outer executor-command grammar only →通常変更不要
    • preflight.run.fixture test-only sibling →通常変更不要
    • anchor/human-context/agent-report sibling → production behaviorは変更禁止
    • direct inner run_refinement_preflight.py behavior test →通常変更不要
    • docs / unrelated reference →変更不要

    各 required path について、

    • なぜ migration 後に壊れるか
    • argv_template_mismatch
    • preflight_script_invalid
    • missing workflow_start_entry.py
    • その他

    のどれに該当するかを具体的に示す。

    最終出力:

    • complete required-change path list
    • false-positive / no-change list
    • approved set 外の新規 path
    • GO / STOP recommendation

    SubAgent A の完了を待つこと。

    SubAgent B — adversarial independent validator

    SubAgent A の調査結果を鵜呑みにせず、read-only で独立検証する。

    特に、

    • bare command migration 後の production skill_runtime_command_policy.validate_registry_entry() の exact argv contract
    • skill_runtime_exec.py の script integrity check
    • temporary repo fixture が実際にどの registry/script files を seed しているか
    • test が parser だけなのか、real subprocess dispatch まで到達するのか

    を call site まで追うこと。

    SubAgent A の required path list に対して、各ファイルを

    required / not required / uncertain

    で判定し、理由を示す。

    また repository 全体を独立検索し、A が漏らした同型 fixture がないか確認する。

    anchor sibling production behavior を変更せずに migration を完了できるかも明示する。

    最終出力:

    • validated required path list
    • A からの additions/removals
    • newly discovered unapproved paths
    • GO / STOP recommendation

    SubAgent B の完了を待つこと。

    Phase 0R gate

    両 SubAgent が

    • 新規 required path は

      • scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
      • tests/agent_guards/test_worktree_scope_guard.py
        の2つだけ
    • anchor sibling production change は不要

    • schema/key/type contract の追加変更不要

    で一致した場合のみ GO。

    その場合、この2ファイルへの OWNER conditional approval を確定し、Issue #2311 の Allowed Paths / In Scope へ同一変更で追加してよい。

    それ以外は STOP。


    Phase 1 — Issue contract reconciliation

    Phase 0R が GO の場合のみ実施する。

    repository の既存 trusted human-context / contract-update mechanism が必要ならそれを使用し、human provenance を捏造しない。

    Issue #2311 の Allowed Paths に、Phase 0R で確定した required test paths を追加する。

    少なくとも:

    • scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
    • tests/agent_guards/test_worktree_scope_guard.py

    を追加する。

    In Scope / AC / Verification では、この追加が bare preflight.run command-contract migration に追随する fixture parity 修正であり、

    preflight.run.with_anchor 等の sibling production wiring を workflow_start_entry.py へ変更するものではない

    ことを明記する。

    test_skill_runtime_policy_commands.py が no-op の場合、それも「変更不要」と記録し、無理に変更しない。


    Phase 2 — implementation

    Issue #2311 の最新 AC を正本として実装する。

    特に command migration は atomic に行う。

    A. command_registry.py

    canonical bare preflight.run の first-hop executable を

    run_refinement_preflight.py
    から
    workflow_start_entry.py

    へ変更する。

    最終的な argv shape は Issue #2311 の current contract と完全一致させる。

    anchor/human-context/agent-report sibling の argv は変更しない。

    B. skill_runtime_command_policy.py

    _EXPECTED_ARGV_BY_COMMAND["preflight.run"] を新しい canonical bare argv と exact match するよう同期する。

    exact comparison を緩和・prefix化・wildcard化しない。

    他 command ID の argv contract を巻き込まない。

    C. skill_runtime_exec.py

    script integrity check を bare migration と同期する。

    最低条件:

    • bare preflight.run が first-hop workflow_start_entry.py を検証する
    • anchor sibling が従来どおり inner run_refinement_preflight.py を検証する意味を失わない
    • decide.run その他の既存 command-specific integrity target を回帰させない
    • preflight_script_invalid 等の既存 error contract は必要がなければ維持

    「non-decide は全部 workflow_start_entry.py」のような粗い一般化は禁止。

    D. workflow_start_entry.py / root_entry_router.py

    Issue #2311 AC の通り実装する。

    • root_entry_router.capability_preflight_result() を実際に利用する
    • capability producer を wrapper 内で再実装しない
    • caller capability request の欠落/malformed は producer 前に fail-closed
    • blocked / producer failure / malformed response は inner preflight を0回
    • ready / degraded のみ inner run_refinement_preflight.py を trusted route でちょうど1回
    • blocked result の checks / reasons を保持
    • Step 0 result を Step 5 authorization として再利用しない
    • static global planned_operations superset を作らない

    E. affected test fixtures

    Phase 0R で required と確定した fixture のみ変更する。

    各 fixture では production migration と同じ bare preflight.run argv を seed する。

    必要なら fixture-local workflow_start_entry.py stub を追加し、既存 fake run_refinement_preflight.py へ forwarding するなどして、その test 本来の executor/write-policy/anchor regression intent を維持する。

    重要:

    • fixture の anchor sibling argv は run_refinement_preflight.py のまま
    • anchor sibling を workflow_start_entry.py へ変更しない
    • fixture のテスト目的を capability-preflight test に変質させない
    • production wrapper の詳細ロジックを各 fixture に複製しない
    • bare command の first-hop contractだけを production と parity にする

    Phase 3 — verification

    まず Issue #2311 に現在記載されている 全 Verification Commands を fresh に実行する。

    その後、affected fixture regression を個別に実行する。少なくとも:

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_commands.py -v

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -v

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py -v

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py -v

    uv run --locked pytest scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py -v

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -v

    uv run --locked pytest tests/agent_guards/test_worktree_scope_guard.py -v

    さらに Issue が要求する:

    • workflow-start hermetic behavioral tests
    • existing Step 5 backward compatibility test
    • thin-entrypoint / SKILL line-budget test
    • repository-level required/full test equivalent

    を実行する。

    SKIP や fallback を PASS に昇格させない。

    テスト後に changed-file inventory を取得し、全変更が最終 Allowed Paths 内であることを確認する。

    また検索で以下を確認する。

    • production bare preflight.run が旧 inner scriptを first-hop として残していない
    • exact policy と registry が一致
    • anchor siblings は旧 inner scriptを維持
    • test fixtures に stale bare argv が残っていない

    Phase 4 — fresh independent review

    実装・検証完了後、別の read-only review SubAgent を foreground で起動すること。

    background 禁止。

    reviewer には少なくとも以下を敵対的に確認させる。

    review SubAgent の完了を待つこと。

    blocking finding があれば main agent が修正し、関連テストを再実行した後、fresh reviewer を再度 foreground で完了まで待つ。

    blocking finding が0になるまで review 完了扱いにしない。


    最終報告

    最後に以下を簡潔に報告する。

    • Phase 0R SubAgent A / B の結論
    • 最終 OWNER-approved Allowed Paths delta
    • 実変更ファイル
    • test_skill_runtime_policy_commands.py が no-op だったか
    • Verification Commands と結果
    • focused regression tests と結果
    • fresh reviewer verdict
    • anchor sibling が untouched である確認
    • 残存 blocker / Remaining Parent Gap

    追加 scope が Phase 0R で見つかった場合は、実装せずその path list と理由だけを報告して STOP する。

  8. squne121 commented on Aug 23, 2026

    @squne121
    OwnerAuthor

    推奨判断

    .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py を追加承認し、Phase 0R をこれで閉じて実装再開 GO が妥当です。

    理由は明確です。このテストは preflight.run.with_anchor の production wiring を変更するテストではなく、bare preflight.run の全 entry を _EXPECTED_PREFLIGHT_RUN_ENTRY と完全一致で snapshot しています。現在はその argv に run_refinement_preflight.py が固定されているため、#2311 の AC1 を正しく実装すれば確実に失敗します。anchor sibling 自体の argv は引き続き run_refinement_preflight.py のままでよく、変更対象は bare snapshot の canonical value と、それに伴って古くなる説明コメントだけです。

    さらに _EXPECTED_PREFLIGHT_RUN_ENTRY をリポジトリ全体で確認すると、この exact snapshot は当該ファイルだけです。一般検索では run_refinement_preflight.py 参照は多数ありますが、例えば test_command_registry.py は bare command のレンダリング可能性を検証するだけで script path を固定しておらず、test_step_0f_parent_owned_preflight.py も SKILL 文言契約です。したがって、Phase 0R の両独立 SubAgent が「7件で打ち止め」と一致した判断を覆す根拠は見つかりませんでした。

    ここで Phase 0S のような全リポジトリ再探索をもう一度挟むのは非推奨です。すでに二重独立 inventory が完了しているので、これ以上は scope discovery loop 自体が作業を妨げます。OWNER decision として「7件目を承認し、7件を final finite migration set と確定」と明示して探索を閉じるべきです。なお文言上は「他7ファイルと同様」ではなく **「他6ファイルと同様」**です。

    また、Issue 本文の現在の Allowed Paths は依然として元の5エントリだけなので、コードより先に Issue contract repair → fresh contract/refinement/allowed-path checks → implementation の順にする必要があります。Allowed Paths 外変更が Stop Condition であることも現行 Issue に残っています。

    Claude Code については、現在の公式仕様では subagent はデフォルトで background になり得るため、この種の phase gate では foreground を明示するのが適切です。Foreground subagent は完了まで main conversation を block します。 ([Claude]1)

    以下をそのまま渡す構成を推奨します。

    Claude Code 作業プロンプト — Issue #2311 final scope 承認・実装再開

    対象リポジトリ: squne121/loop-protocol
    対象 Issue: https://github.com/squne121/loop-protocol/issues/2311

    OWNER decision

    Phase 0R の結果に対する OWNER 判断を以下で確定する。

    .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py を Issue #2311 の Allowed Paths / In Scope に追加承認する。

    これにより Phase 0R の scope reconciliation は完了とし、追加の whole-repo scope discovery round は行わない。

    Phase 0R の2つの独立 SubAgent が一致して報告した以下の 7 test files を final finite required-change test set と確定する。

    1. scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py
    2. scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
    3. scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py
    4. scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py
    5. scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
    6. tests/agent_guards/test_worktree_scope_guard.py
    7. .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py

    test_skill_runtime_policy_commands.py は Phase 0R で migration-specific change 不要と確定している。verification のため実行してよいが、変更目的で触らないこと。

    新規7件目について:

    test_preflight_run_with_anchor.py は anchor sibling production behavior の変更ではない。

    同ファイルの _EXPECTED_PREFLIGHT_RUN_ENTRY が canonical bare preflight.run の完全 snapshot を保持しており、現在 run_refinement_preflight.py を固定しているため、#2311 の migration 後には必ず更新が必要になる fixture/snapshot parity 修正である。

    変更時は:

    以下の production delta についても過去の OWNER decision を確定事項として扱う。

    • scripts/agent-guards/skill_runtime_command_policy.py
    • scripts/agent-guards/skill_runtime_exec.py

    bare preflight.run migration は次の3 consumer を atomic に同期する。

    1. command_registry.py

      • canonical bare preflight.run argv
    2. skill_runtime_command_policy.py

      • _EXPECTED_ARGV_BY_COMMAND["preflight.run"]
    3. skill_runtime_exec.py

      • pre-dispatch integrity/symlink check の actual first-hop target

    三者とも bare preflight.run について workflow_start_entry.py を指すこと。

    anchor siblings、preflight.run.fixture、その他既存 inner-preflight command は従来どおり run_refinement_preflight.py を first-hop とする。

    exact argv policy の一般化、prefix match、wildcard、任意 script 許可等への緩和は禁止する。


    Phase 0F — final drift verification

    repo-tracked file または Issue を変更する前に、親 Claude Code セッションから read-only SubAgent を1つ foreground で起動すること。

    これは Phase 0R の whole-repo inventory をやり直すためではない。

    目的は Phase 0R 完了時点から current HEAD が変化しておらず、確定済み finite scope がまだ成立していることだけを確認する drift check とする。

    Background 実行は禁止する。

    SubAgent が完全に終了し、main session が最終レポートを受け取るまで Issue mutation、コード編集、commit、PR作成へ進んではならない。

    nested SubAgent delegation は禁止。

    SubAgent は read-only で以下だけを確認する。

    • Issue 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 の最新 body/comments と本 OWNER decision に矛盾がない。
    • current HEAD の canonical bare preflight.run はまだ旧 first-hop であり、本 Issue の migration が未実装である。
    • skill_runtime_command_policy.py と skill_runtime_exec.py の既知 consumer contract が Phase 0R の結論から変化していない。
    • final required-change test set が上記7件である。
    • .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py の _EXPECTED_PREFLIGHT_RUN_ENTRY が bare preflight.run の旧 argv を snapshot している。
    • anchor sibling production behavior の変更は不要。
    • Phase 0R 後の HEAD drift による新しい production/test dependency が発生していない。

    広範な新規 architecture exploration や「念のため」の新しい scope discovery は行わない。

    出力:

    • HEAD drift: yes/no
    • finite required path list confirmed: yes/no
    • newly introduced dependency since Phase 0R: path または none
    • GO / STOP

    SubAgent の完了を待つこと。

    HEAD drift により新しい required path が実際に発生していた場合のみ STOP する。

    単なる検索ヒットや既知 no-op file は STOP 理由にしない。


    Phase 1 — Issue #2311 contract repair

    Phase 0F が GO の場合のみ実施する。

    コード編集より先に Issue #2311 の contract を修復する。

    既存 body を全面再生成せず、必要部分のみ最小変更する。

    Final Allowed Paths

    既存 Allowed Paths に必要な production/test paths を追加し、最終的に少なくとも以下を許可する。

    .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/
    
    scripts/agent-guards/skill_runtime_command_policy.py
    scripts/agent-guards/skill_runtime_exec.py
    
    scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py
    scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
    scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py
    scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py
    scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
    tests/agent_guards/test_worktree_scope_guard.py
    .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
    

    test_skill_runtime_policy_commands.py は verification-only とし、変更不要なら Allowed Paths を広げる目的で追加しない。

    In Scope / AC1

    AC1 の migration が以下を atomic に同期することを明記する。

    • canonical bare registry argv → workflow_start_entry.py
    • exact command policy → 同じ canonical argv
    • executor integrity target → bare preflight.run では workflow_start_entry.py
    • affected real-dispatch fixtures → 同じ bare first-hop contract
    • test_preflight_run_with_anchor.py の bare-entry snapshot → 新 canonical argv

    以下は変更しないことを明記する。

    test_preflight_run_with_anchor.py の修正は anchor sibling wiring の変更ではなく bare snapshot parity migration と明記する。

    Verification contract

    7 required test filesを verification surface に含める。

    test_skill_runtime_policy_commands.py は no-op regression verification として実行してよいが、変更を要求しない。

    Issue contract 更新後、repository workflow が要求する:

    • contract review
    • refinement preflight
    • allowed-path / scope gate

    を fresh に再実行する。

    fresh validation が green になるまで実装開始しない。


    Phase 2 — implementation

    fresh contract validation が green の場合のみコードを変更する。

    Original #2311 behavior

    Issue #2311 の最新 AC2〜AC10 を弱めず実装する。

    特に:

    • workflow_start_entry.py は root_entry_router.capability_preflight_result() を実際に使用する。
    • capability producer ロジックを wrapper 内へコピーしない。
    • caller capability request の missing/malformed は producer 呼び出し前に fail-closed。
    • blocked / producer failure / malformed result は inner run_refinement_preflight.py を0回。
    • ready / degraded の場合のみ trusted route で inner preflight をちょうど1回。
    • checks / reasons を blocked result に保持する。
    • Step 0 preflight result を Step 5 authorization に再利用しない。
    • invocation-scoped planned_operations を使い、static global superset を作らない。
    • SKILL.md の line budget / thin-entrypoint contract を維持する。

    Atomic command migration

    command_registry.py

    bare preflight.run の first-hop を:

    run_refinement_preflight.py

    から:

    workflow_start_entry.py

    へ変更する。

    sibling argv は変更しない。

    skill_runtime_command_policy.py

    _EXPECTED_ARGV_BY_COMMAND["preflight.run"] を新 canonical argv と byte-for-byte 一致させる。

    exact equality は維持する。

    skill_runtime_exec.py

    pre-dispatch script integrity target を最小差分で同期する。

    概念上:

    if is_decide_command:
        script_name = "decide_next_loop_action.py"
    elif args.command_id == "preflight.run":
        script_name = "workflow_start_entry.py"
    else:
        script_name = "run_refinement_preflight.py"

    既存コード構造に合わせること。

    generic argv parsing や任意 target acceptance に一般化しない。

    Seven required fixture/test migrations

    final required-change test set の7ファイルだけを migration parity のため変更する。

    real executor fixture では必要に応じて fixture-local workflow_start_entry.py first-hop stub を seed し、そのテスト本来の write-policy/session/anchor/no-worktree 等の目的を維持する。

    production capability-preflight implementation を fixture ごとに複製しない。

    test_skill_runtime_exec_anchor.py では bare command と anchor sibling を明確に区別する。

    tests/agent_guards/test_worktree_scope_guard.py でも production exact policy と一致する bare argv を seed する。

    test_preflight_run_with_anchor.py では:

    • bare _EXPECTED_PREFLIGHT_RUN_ENTRY の script path を新 canonical first-hop へ変更
    • snapshot の説明を現在の migration 後の意味に合わせて最小修正
    • preflight.run.with_anchor の exact argv assertion は run_refinement_preflight.py のまま
    • anchor entry の placeholders / execution_class / mutation / network contract は変更しない

    新しい8件目の migration-specific test fileは作らない。

    必要な regression は上記7ファイルまたは既存 .claude/skills/issue-refinement-loop/scripts/tests/ 内へ置く。


    Phase 3 — verification

    Issue #2311 に記載された全 Verification Commands を fresh に実行する。

    その上で以下の focused regression を実行する。

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_commands.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -v
    uv run --locked pytest tests/agent_guards/test_worktree_scope_guard.py -v
    uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -v

    さらに:

    を実行する。

    SKIP / xfail / fallback 成功を PASS に昇格しない。

    test weakening で失敗を隠さない。

    verification 後に検索で以下を確認する。

    • production bare preflight.run の first-hop に stale run_refinement_preflight.py が残っていない。
    • registry / exact policy / executor integrity target が一致。
    • final 7 fixture/snapshot に stale bare argv が残っていない。
    • anchor sibling argv は run_refinement_preflight.py を維持。
    • test_skill_runtime_policy_commands.py は必要がなければ untouched。
    • changed files が final Allowed Paths 内だけ。

    Phase 4 — fresh adversarial review SubAgent

    実装・verification 完了後、親セッションから 別の read-only reviewer SubAgent を foreground で起動すること。

    background 実行は禁止。

    reviewer が完全に終了し、main session が最終 verdict を受け取るまで PR 作成へ進んではならない。

    nested SubAgent delegationは禁止。

    reviewerには Phase 0R の結論を正解として与えず、最新 Issue contract と actual diff/tests から独立レビューさせる。

    最低限確認する事項:

    • AC1〜AC10
    • final Allowed Paths compliance
    • registry / exact policy / integrity target の3者 parity
    • bare preflight.run actual first-hop = workflow_start_entry.py
    • anchor siblings actual first-hop = run_refinement_preflight.py
    • final 7 test fixtures/snapshots の migration parity
    • test_preflight_run_with_anchor.py が bare snapshotだけ更新し anchor sibling contractを変更していないこと
    • blocked/malformed fail-closed
    • ready/degraded exactly-once
    • Step 0 / Step 5 fresh-call separation
    • test fixture が production semantics を過剰mockしていないこと
    • policy relaxation がないこと
    • stale bare run_refinement_preflight.py assertion/fixture の取り残し
    • unrelated diff がないこと

    出力:

    • blocking findings
    • non-blocking findings
    • AC coverage gaps
    • test gaps
    • APPROVE / REQUEST_CHANGES

    reviewer SubAgent の完了を必ず待つこと。

    REQUEST_CHANGES の場合、final Allowed Paths 内で解決できる finding だけ修正し、affected tests と Issue全VCを再実行した後、fresh reviewer をもう一度 foreground で起動して完了まで待つ。

    新しい required path が必要なら勝手に追加せず STOP。


    Phase 5 — branch / commit / PR

    全 AC、tests、fresh reviewer が green の場合のみ進む。

    現在の repository workflow に従って Issue #2311 用 branch/worktree で commit する。

    open implementation PR がなければ PR を作成する。

    PR body に最低限以下を記載する。

    • Closes #2311
    • OWNER-approved final scope delta
    • registry / exact policy / integrity target の atomic migration
    • final seven required test migrations
    • .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py は bare snapshot parity のみであり anchor sibling production behavior は untouched
    • test_skill_runtime_policy_commands.py が no-op / untouched だったか
    • Verification Commands と実結果
    • fresh reviewer verdict
    • final changed-file / Allowed Paths compliance

    merge は行わない。


    Stop Conditions

    以下の場合のみ停止する。

    • Phase 0F 以降の実際の HEAD drift により新しい required path が発生した
    • final Allowed Paths 外の production/test file 変更が本当に必要
    • anchor sibling production behavior の変更が必要
    • fixed schema/key/type contract の追加変更が必要
    • new hook / broker / ledger / persistent state / authorization mechanism が必要
    • nested SubAgent delegation が必要
    • destructive operation が必要
    • secret/credential exposure または permission escalation が必要
    • Issue 分割が新たに必要

    単なる検索ヒット、verification-only file、docs reference は scope delta として扱わない。


    最終報告

    以下を簡潔に報告する。

    1. Phase 0F drift verifier の結果
    2. Issue contract repair 内容
    3. final OWNER-approved finite paths
    4. implementation delta
    5. changed files
    6. test_skill_runtime_policy_commands.py no-op/untouched 確認
    7. Verification Commands / regression results
    8. fresh reviewer verdict
    9. anchor sibling untouched 確認
    10. PR URL
    11. remaining blocker / Remaining Parent Gap (none なら none)

    Phase を飛ばさないこと。特に各 foreground SubAgent の完了結果を受け取る前に次の Phase へ進んではならない。

    この形なら、今回の7件目を承認しつつ、今後また「8件目が出るかもしれない」という理由だけで探索を繰り返すことを止められます。一方で、Phase 0R 後に main が実際に変化していた場合だけ drift verifier が STOP できるので、scope gate の意味も残ります。

  9. squne121 commented on Aug 23, 2026

    @squne121
    OwnerAuthor

    推奨は、提示された 1〜3 のどれかをそのまま採るのではなく、**「Issue #2311 内で preflight 契約だけ修復して Phase 2 に進み、同じ PR で fixture を hermetic 化する」**です。

    現在の #2311 は、問題の7テストをすでに Allowed Paths に含め、bare preflight.run migration に追随する migration-parity test として同一PRで更新する契約になっています。したがって、この fixture gap を別 Issue に切り出す必然性は薄いです。

    一方で、選択肢1の「baseline から失敗しているから無視して実装へ進む」もそのままでは勧めません。issue-contract-review の現行契約では regression_gate は pass → go、fail → blocked で、環境上 baseline 実行が適切でない検証には pr_review_only / runtime_only という正式な defer 手段があります。赤い regression gate を人間判断だけで横断するより、ここを契約上正しく分類する方が後続の自動化を壊しません。

    またユーザーの原因分析は実コードとも整合します。代表 fixture の _install_skill_runtime_exec_fixture() は production executor/policy と temp registry をコピーする一方、pyproject.toml を seed していません。対照的に同じテスト群の大きな fixture は pyproject.toml と uv.lock を明示的に seed しています。 現在の repo pin は uv==0.11.29 で、CI の composite action も同じバージョンを astral-sh/setup-uv でセットアップしています。

    fixture 修正については、本番 resolver を緩和しないのが重要です。uv 公式にも required-version は実行時バージョン制約であり、managed=false は project の自動 lock/sync を止めるための設定として定義されています。 ([Astral Docs]1) ([Astral Docs]2) 私の独立再現では [tool.uv] だけの最小ファイルでは .venv / uv.lock が生成されるケースがありましたが、最小 [project] と managed=false を併用すると生成されませんでした。したがって root の canonical pin を読み取って minimal temp pyproject.toml を生成する案を、実機の pinned uv 0.11.29 で先に検証させるのがよいです。pin の 0.11.29 を各テストへ直書きするのは避けます。

    したがって進行は、①2つの foreground SubAgent で原因・最小fixture修正・CI laneを独立確認 → ②OWNER directive として issue-refinement-loop を execute、人間再承認なしで実行 → ③7本を pre-implementation preflight だけ pr_review_only に defer → ④fresh issue-contract-review が go になったら Phase 2 → ⑤まずfixtureを hermetic化し、7本を実際にローカル実行 → ⑥#2311本体実装 → ⑦全VC+CI+fresh reviewer が最も整合的です。

    Claude Code は現在 background subagent がデフォルトなので、今回の phase gate では foreground を明示する意味があります。公式仕様でも foreground subagent は完了まで main conversation を block します。 ([Claude]3)

    Claude Code 作業プロンプト — Issue #2311 local uv fixture gap を契約修復して実装再開

    対象リポジトリ: squne121/loop-protocol
    対象 Issue: https://github.com/squne121/loop-protocol/issues/2311

    OWNER decision

    Issue #2311 の Phase 1 contract repair 後に fresh issue-contract-review --mode execute が human_judgment で停止した件について、以下を OWNER decision とする。

    今回確認された7件の regression-gate failure は、Issue #2311 の production implementation による regression ではなく、current main の未変更状態でも再現する pre-existing local fixture/environment gap である。

    原因は次の通り。

    • skill_runtime_exec.py の trusted uv resolver は、hostedtoolcache 以外から解決された uv について repository の [tool.uv].required-version と実バイナリを照合する。
    • このローカル環境では uv が real account home の ~/.local/bin/uv から解決されるため、その exact-version validation path を通る。
    • 対象 fixture の _install_skill_runtime_exec_fixture() は temporary repository に pyproject.toml を seed していない。
    • そのため temporary repo に対する _required_uv_version() が None となり、uv_version_mismatch で fail-closed する。
    • current main のコード変更前から同じ failure が発生すること、instrumented repro で required_version=None になることは確認済み。
    • 一方、より完全な別 fixture helper は pyproject.toml / uv.lock を seedしている。
    • したがってこれは 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 の AC1 implementation が作った failure ではない。

    ただし、「pre-existing だから regression_gate failure を無視する」ことはしない。

    現行 issue-contract-review の scope-class contract を維持し、このローカル環境で baseline regression gate として決定論的に実行できない7件については、pre-implementation contract review のみ pr_review_only へ defer する。

    これはテスト免除ではない。

    Phase 2 では対象 fixture 自体を hermetic に修正し、実装後には当該7テストをローカルで実際に実行する。さらに PR CI でも結果を確認する。

    今回の判断について追加の人間承認を要求しないこと。

    issue-refinement-loop は execute mode で実行してよい。
    この OWNER decision の範囲内の Issue contract mutation は人間再承認なしで実施すること。

    新しい production scope、新しい Allowed Path、新しい schema/key/type contract が必要と判明した場合だけ STOP する。

    新しい follow-up Issue は現時点では作成しない。


    Phase 0E — independent environment/scope verification

    repo-tracked file および Issue を変更する前に、2つの SubAgent を使用すること。

    SubAgent execution contract

    すべての SubAgent は foreground で起動する。

    background にしない。

    Claude Code の Agent invocation で指定可能なら run_in_background: false を明示する。

    各 SubAgent が完全に終了し、main session が最終結果を受領するまで、次の SubAgentまたは次Phaseへ進んではならない。

    nested SubAgent delegation は禁止する。


    SubAgent A — local uv / fixture root-cause verifier

    read-only で実行する。

    以下を current main と current local environment から独立に再確認する。

    1. production resolver

    確認対象:

    • scripts/agent-guards/skill_runtime_exec.py
    • root pyproject.toml
    • _resolve_trusted_executable("uv", ...)
    • _trusted_toolchain_dirs("uv")
    • account-home uv lane
    • _validate_trusted_executable_version()
    • _required_uv_version()

    確認事項:

    • current real uv absolute path
    • current real uv --version
    • repository [tool.uv].required-version
    • hostedtoolcache lane に該当するか
    • account-home lane に該当するか
    • temporary repo で pyproject.toml が無い場合に required_version=None となるか
    • その結果 uv_version_mismatch になる call chain

    推測ではなく実行証跡を取る。

    2. affected fixture inventory

    Issue #2311 の現在の Scope Delta parity VC 7件を確認する。

    少なくとも:

    • scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py
    • scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
    • scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py
    • scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py
    • scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
    • tests/agent_guards/test_worktree_scope_guard.py
    • .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py

    各ファイルについて、

    を分類する。

    「7件全部同じはず」と仮定しない。

    3. minimal hermetic fixture experiment

    production resolver は変更せず、scratch temporary directory のみを使って最小 fixture 案を検証する。

    第一候補は、root pyproject.toml から canonical [tool.uv].required-version を読み取り、temporary repo にテスト専用の最小 pyproject.toml を生成する方式。

    概念例:

    [project]
    name = "skill-runtime-fixture"
    version = "0.0.0"
    requires-python = ">=3.12"
    dependencies = []
    
    [tool.uv]
    required-version = "<root pyproject.toml から取得>"
    managed = false

    重要:

    • ==0.11.29 等の version literal を各fixtureへ直書きしない。
    • root pyproject.toml を SSOT とする。
    • actual pinned uv で実証する。
    • uv run python3 ... により .venv / uv.lock / その他 unrelated file が生成されないことを確認する。
    • network access や uv sync が不要であることを確認する。
    • executor の repository-write snapshot を汚染しないことを確認する。

    managed = false だけでは十分と決めつけず、actual pinned uv で確認すること。

    もしこの最小形が成立しなければ、既存の large fixture helper の pyproject.toml / uv.lock seed pattern を調査する。ただし uv sync や full project materialization を7 fixtureへ機械的にコピーする前に、より小さい方法が存在しないことを示す。

    SubAgent A output

    以下のみ返す。

    • root cause: confirmed / disproved
    • affected test list
    • current-main baseline result
    • actual uv lane / version
    • minimal hermetic fixture proposal
    • scratch experiment result
    • repo-tracked paths required to implement it
    • GO / STOP

    SubAgent A の完了を待つこと。


    SubAgent B — contract / CI adversarial verifier

    SubAgent A 完了後に foreground で起動する。

    A の結論を鵜呑みにせず独立に確認する。

    1. Issue contract

    Issue #2311 の最新:

    • body
    • comments
    • AC
    • Verification Commands
    • Allowed Paths
    • Stop Conditions
    • Runtime Verification Applicability

    を取得する。

    確認事項:

    • affected 7 test files が現在すでに Allowed Paths に含まれているか
    • これらが bare preflight.run migration-parity verification として同一PR更新対象になっているか
    • fixture hermeticity repair に新しい production path が必要か
    • new schema/key/type contract が必要か
    • anchor sibling production behavior を変更する必要があるか

    2. issue-contract-review semantics

    current repository の以下を読む。

    • .claude/skills/issue-contract-review/SKILL.md
    • .claude/skills/issue-contract-review/references/vc-preflight.md
    • baseline_vc_preflight.py
    • relevant parser/tests

    確認する:

    • regression_gate failure の正式な扱い
    • pr_review_only の正式な marker syntax
    • verification_owner
    • deferred_reason
    • post-implementation / PR-review での consumer semantics

    syntax は推測しない。current repository の parser/test を正本とする。

    3. CI path

    current workflow/composite action を確認する。

    少なくとも:

    • .github/actions/setup-python-uv/action.yml
    • affected tests を実行する required CI workflow/lane

    について、

    • astral-sh/setup-uv が使用されていること
    • repository pin と setup version が一致していること
    • affected 7 tests が実際にどの CI job で実行されるか
    • hostedtoolcache path を使うという仮説が current CI runner で本当に成立するか

    を確認する。

    「CIでは恐らくPASS」を最終証拠にしない。

    PR 作成後の実 CI result を最終 verification に含められることを確認する。

    SubAgent B output

    • Issue scope classification
    • whether fixture fix fits current Allowed Paths
    • exact pr_review_only contract syntax
    • required post-implementation verification
    • relevant CI jobs
    • new scope delta: yes/no
    • GO / STOP

    SubAgent B の完了を待つこと。


    Phase 0E gate

    以下の場合のみ GO。

    新しい production path または新しい test path が必要なら STOP。

    単に current 7 files 内の test fixture implementation を修正するだけなら STOP しない。


    Phase 1R — issue-refinement-loop execute

    Phase 0E が GO なら、issue-refinement-loop を execute mode で実行する。

    Human approval policy

    この Phase について追加の人間承認は不要。

    OWNER directive はこのプロンプト自体で与えられている。

    issue-refinement-loop 内で human approval checkpoint に到達しても、判断対象が以下の bounded contract repair の範囲内なら自動的に OWNER-approved として続行する。

    • affected 7 parity VC の pre-implementation scope classification 修正
    • pre-existing local uv fixture gap の明記
    • post-implementation local verification / CI verification の明記
    • existing Allowed Paths 内での fixture hermeticity repair の明記

    human provenance を捏造しない。

    必要ならこの prompt を explicit OWNER directive source として扱う。

    issue-refinement-loop SubAgents

    issue-refinement-loop が SubAgent を利用する場合も foreground で実行する。

    各 SubAgent の終了を待ってから次へ進む。

    SubAgent が nested SubAgent を起動することは禁止。


    Required contract repair

    A. affected 7 commands の preflight scope

    今回の local environment で baseline regression gate として決定論的に実行できない affected commands だけを、repository の canonical syntax を使って

    pr_review_only

    へ変更する。

    これは pre-implementation issue-contract-review における defer である。

    baseline_fail_expected へ変えてはならない。

    これらは実装前に fail することが仕様上期待される AC ではないためである。

    B. defer reason / owner

    current parser contract が要求する正式な形式で、

    • verification owner
    • deferred reason

    を設定する。

    意味は次とする。

    • reason: current-main fixture omits project uv pin; account-home trusted-uv lane therefore fails before the intended migration-parity assertion
    • owner: implementation/PR verification + GitHub Actions CI

    実フィールド名・marker placement は current repository implementation に従う。

    C. Verification は削除しない

    7 commands 自体を Issue から削除しない。

    Phase 2/3 の mandatory verification surface として保持する。

    Issue Notes / In Scope に、次を明記する。

    D. fixture repair scope

    existing affected test files の fixture helper に対して、

    • root canonical uv required-version を temporary repo へ反映
    • uv project auto-management による unrelated .venv / uv.lock writeを起こさない
    • production trusted resolver semantics は変更しない

    という test-only repair を #2311 In Scope / Notes に追加する。

    新しい Allowed Paths は追加しない。

    E. production contract を弱めない

    変更しない:


    Phase 1R.5 — fresh issue-contract-review

    Issue mutation 完了後、fresh snapshot から

    issue-contract-review を execute mode で再実行する。

    古い review result は再利用しない。

    期待結果:

    go

    human_judgment または blocked の場合:

    same known local-uv cause

    同じ7 parity VC がまだ baseline execution されている等、Phase 1R の contract repair が正しく反映されていない場合は、parser/marker placement を調査し、current contract syntax の範囲内で修正して再実行する。

    この既知原因について人間へ再質問しない。

    different/new cause

    以下なら STOP。

    • 新しい Allowed Path が必要
    • production scope追加
    • schema/key/type変更
    • unrelated failing regression
    • dependency state conflict
    • new external permission requirement

    go になるまで Phase 2 へ進まない。


    Phase 2 — implementation

    fresh issue-contract-review が go の場合のみコード変更する。

    Phase 2A — fixture hermeticity repair first

    #2311 production migration より先に、affected fixture の local uv gap を current Allowed Paths 内で修正する。

    SubAgent A が実証した最小方式を使う。

    推奨優先順位:

    1. minimal temporary pyproject.toml
    2. canonical root uv pin を動的に参照
    3. proper minimal [project]
    4. [tool.uv] managed = false
    5. no .venv / no uv.lock / no network / no uv sync

    実機検証で成立した場合のみ採用。

    version literal の複製は禁止。

    例えば Python で root pyproject.toml を tomllib で読み、

    tool.uv.required-version

    だけを取得して fixture config を生成する方式を優先する。

    shared helper を新しい path に切り出すために Allowed Paths を増やしてはならない。

    多少の small test-helper duplication の方が、この Issue では新しい production/test infrastructure scope を増やすより良い。

    Phase 2A verification

    production #2311 implementation を行う前に affected commands を実行する。

    ここでは current production semantics + fixture-only repair の状態で、

    • uv_version_mismatch が消えること
    • test が本来の assertion point まで到達すること
    • .venv / uv.lock 等 unrelated writes が発生しないこと

    を確認する。

    本来 current-main で PASS すべき migration-neutral tests は PASS させる。

    #2311 の first-hop migration 前提で expected baseline mismatch になるテストがあれば、その failure reason が #2311 intended delta そのものであることを明示する。

    環境エラーと intended baseline fail を混同しない。


    Phase 2B — original Issue #2311 implementation

    最新 Issue body の AC を正本として実装する。

    command migration

    bare preflight.run について、以下3 consumer を atomic に同期する。

    1. command_registry.py

      • canonical argv → workflow_start_entry.py
    2. skill_runtime_command_policy.py

      • _EXPECTED_ARGV_BY_COMMAND["preflight.run"]
      • canonical argv と exact match
    3. skill_runtime_exec.py

      • pre-dispatch integrity/symlink check target
      • bare preflight.run → workflow_start_entry.py

    generic policy relaxation は禁止。

    workflow start

    Issue AC に従う。

    • root_entry_router.capability_preflight_result() を使用

    • producer logic を duplicate しない

    • missing/malformed caller request は producer 前 fail-closed

    • blocked / producer failure / malformed result:

      • inner preflight 0回
      • mutation 0回
    • ready/degraded:

      • trusted uv route
      • inner preflight exactly once
    • checks / reasons を保持

    • Step 0 result を Step 5 authorization として再利用しない

    fixture first-hop migration

    affected fixture は production bare command と同じ first-hop contract に更新する。

    bare:

    workflow_start_entry.py

    anchor/human-context/agent-report sibling:

    run_refinement_preflight.py

    の境界を維持する。

    fixture-local wrapper が必要な場合は最小 forwarding stub とし、capability producer implementation を各fixtureへ複製しない。


    Phase 3 — verification

    実装後、Issue #2311 の全 Verification Commands を fresh に確認する。

    pr_review_only へ defer した7 commands も、この Phase ではスキップせず手動で実際に実行する。

    少なくとも:

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_guard_shadow_log_write_path_policy.py -v
    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -v
    uv run --locked pytest tests/agent_guards/test_worktree_scope_guard.py -v
    uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -v

    Issue body に現在記載された no-op parity command が別にある場合も、その最新 contract に従う。

    さらに:

    を実施する。

    判定:


    Phase 4 — fresh adversarial reviewer SubAgent

    implementation + local verification 完了後、別の reviewer SubAgent を foreground で起動する。

    完了まで必ず待つ。

    reviewer は read-only。

    確認項目:

    • 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 最新 AC 全件
    • changed files / Allowed Paths
    • registry / exact policy / integrity target parity
    • bare first-hop = workflow_start_entry.py
    • anchor siblings untouched
    • workflow_start blocked/ready/degraded semantics
    • Step 0 / Step 5 freshness
    • fixture hermeticity
    • canonical uv pin の重複 literal が無いこと
    • temp fixture が .venv / uv.lock 等を unintended write しないこと
    • local pre-existing gap が実装後に解消していること
    • 7 deferred commands が実際に post-change 実行されたこと
    • generic security/policy relaxation が無いこと

    出力:

    • blocking findings
    • non-blocking findings
    • AC gaps
    • test gaps
    • APPROVE / REQUEST_CHANGES

    REQUEST_CHANGES の場合、Allowed Paths 内で修正可能なものは修正し、affected verification を再実行してから 新しい reviewer SubAgent を foreground で起動し直す。

    blocking finding が0になるまで review完了扱いにしない。


    Phase 5 — PR / CI

    既存 #2311 implementation PR があれば更新する。

    無ければ repository workflow に従って作成する。

    merge は行わない。

    PR body には最低限:

    • Closes #2311
    • local pre-existing uv fixture gap の説明
    • current-main baseline evidence
    • Issue contract で7 parity VCを pre-implementation pr_review_only にした理由
    • fixture hermeticity repair
    • registry / policy / integrity target atomic migration
    • post-change local 7-test results
    • full VC result
    • fresh reviewer verdict
    • Allowed Paths compliance

    を記載する。

    CI

    PR 作成後、relevant required CI jobs の実結果を確認する。

    特に affected parity tests が実際に CI lane で実行されていることを確認する。

    「setup-uv だから通るはず」では済ませない。

    CI が失敗した場合はログを取得し、

    へ分類する。

    #2311 関連なら修正して再検証・fresh reviewerをやり直す。

    CI evidence が取れる前に最終 APPROVE / ready と報告しない。


    Stop Conditions

    次の場合だけ STOP して報告する。

    • current Allowed Paths 外の repo-tracked file が必要
    • production trusted-uv resolver semantics の変更が必要
    • anchor sibling production wiring の変更が必要
    • fixed schema/key/type contract の変更が必要
    • new hook/broker/ledger/state store が必要
    • nested SubAgent delegation が必要
    • unrelated regression が確認された
    • destructive operation / credential / new permission が必要

    以下は STOP 条件ではない。

    • 今回既知の required_version=None -> uv_version_mismatch
    • affected7 files 内での fixture hermeticity repair
    • bounded pr_review_only contract repair
    • fresh issue-contract-review の同一既知原因に対する marker/syntax修正

    これらについて追加の人間承認を要求しない。


    最終報告

    以下の順で簡潔に報告する。

    1. SubAgent A root-cause verdict
    2. SubAgent B contract/CI verdict
    3. issue-refinement-loop mutation summary
    4. fresh issue-contract-review result
    5. fixture hermeticity implementation
    6. 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 production implementation summary
    7. changed files
    8. local Verification Commands result
    9. deferred 7 parity commands の actual post-change results
    10. reviewer verdict
    11. PR URL
    12. CI result
    13. remaining blocker / follow-up (none if none)

    Phaseを飛ばさないこと。

    特に、各 foreground SubAgent の完了を必ず待ってから次Phaseへ進むこと。

    この形なら、「既知の環境問題だからゲートを無視する」でも「本筋と別の Issue を増やす」でもなく、baseline preflight では正式に deferし、同じ #2311 実装内で fixture 自体を直して post-change では本当に7本を通す、という一貫した扱いになります。

  10. squne121 commented on Aug 23, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了

    Phase 2A: fixture hermeticity 修正

    対象 6 ファイルの fixture install helper(_install_skill_runtime_exec_fixture / _install_lifecycle_fixture)に、root pyproject.toml の [tool.uv].required-version を動的に読み取る最小 pyproject.toml(managed = false、uv sync は呼ばない)を seed する処理を追加した。production の trusted-uv resolver semantics 自体は変更していない。

    修正後、6 ファイル全てで uv_version_mismatch が解消し全 PASS:

    • test_skill_runtime_preflight_no_worktree.py: 20 passed
    • test_skill_runtime_exec_unauthorized_write_path.py: 10 passed
    • test_skill_runtime_exec_session_manifest_lifecycle.py: 13 passed
    • test_guard_shadow_log_write_path_policy.py: 61 passed, 1 skipped
    • test_skill_runtime_exec_anchor.py: 8 passed
    • test_worktree_scope_guard.py: 238 passed

    Phase 2B: AC1 command migration(atomic)

    3 consumer を同一 PR で atomic に同期した:

    1. command_registry.py — bare preflight.run の canonical argv を workflow_start_entry.py に変更
    2. skill_runtime_command_policy.py — _EXPECTED_ARGV_BY_COMMAND["preflight.run"] を同期
    3. skill_runtime_exec.py — pre-dispatch integrity/symlink check を二分岐(decide.run/それ以外)から三分岐(decide.run/preflight.run/その他)に変更

    sibling の anchor-comment 駆動 profile(.with_anchor / .with_human_context / .with_agent_report / .fixture / .fixture.with_human_context)の argv・first-hop は無変更。

    新規 workflow_start_entry.py を実装:

    • root_entry_router.capability_preflight_result() を実際に import して呼び出す(producer logic の複製なし)
    • caller 側 capability request(planned_operations 等)の欠落/malformed は producer 呼び出し前に fail-closed
    • blocked / producer 呼び出し失敗 / malformed result は inner run_refinement_preflight.py を 0 回起動
    • ready / degraded の場合のみ trusted interpreter(sys.executable。hop 1 で skill_runtime_exec.py が既に trusted uv 経由で resolve 済み)経由で inner preflight をちょうど 1 回起動
    • Step 0 preflight を Step 5 authorization として再利用しない設計(永続化なし)

    root_entry_router.py に構造化結果(decision/checks/reasons)を返す capability_preflight_result() を新設し、既存 capability_preflight() は boolean adapter として後方互換維持(Step 5 の既存呼び出し元・既存テスト test_ac11_capability_preflight_blocked_stops_before_mutation を含め無回帰で PASS)。

    7 件の fixture/snapshot テスト(既存 6 ファイル + test_preflight_run_with_anchor.py)の bare preflight.run first-hop を production 同様に migration。全 7 ファイル全 PASS(test_preflight_run_with_anchor.py は 44/44)。

    全 Verification Commands 結果

    AC1〜AC10、Scope Delta parity(8 コマンド)全て PASS。詳細は PR #2320 本文の「検証コマンド結果」セクションを参照。

    Allowed Paths 準拠

    変更ファイルは Issue 契約の Allowed Paths(14ファイル)と完全一致。Allowed Paths 外の変更は行っていない。

    発見した問題

    なし(Allowed Paths 外の周辺テストで pre-existing local uv_version_mismatch fixture gap を複数観測したが、いずれも本 Issue のスコープ外ファイルであり、baseline main でも再現する既知の gap。詳細は PR #2320 本文参照)。

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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