Skip to content

実装: structural_repair_action.apply を root skill runtime executor へ配線する #2402

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: >-
  PR #2400 delivered the structural repair consumer and registry entry. Close
  the remaining root gaps: exact skill-runtime executor dispatch and the
  canonical issue-refinement-loop route for NEXT_ACTION
  apply_deterministic_structural_repair.
change_kind: workflow-runtime

Parent Issue

none (standalone improvement)

Parent Goal Ref

  • Goal: make a fresh preflight structural repair action reachable only through the canonical root/main route.
  • Desired Destination: none; this Issue owns the narrow root dispatch and route documentation, not the structural consumer.

Current Validated Scope

  • Add the dedicated structural outer flag and exact policy/parser/renderer/dispatcher wiring.
  • Add the canonical apply_deterministic_structural_repair route to .claude/skills/issue-refinement-loop/SKILL.md.
  • Verify the real root executor → real policy → real registry → fixture child chain, including argv, stdout, stderr, return code, and pre-spawn rejection.
  • Preserve PR feat: structural repair actionをcontrolled consumerへ接続する #2400's registry argv and structural consumer without schema or consumer changes.

Remaining Parent Gaps

Background

Scope Collision Record

Outcome

The documented canonical structural repair route and root runtime safely invoke structural_repair_action.apply only with its dedicated outer transport validation, while production-shaped fixture tests prove the exact child argv and stdout/stderr/nonzero-return relay without live GitHub mutation.

Runtime Verification Applicability

decision: immediate
reason: >-
  The production root executor launches a fixture child through the real exact
  policy and registry. AC4 and AC5 directly observe the changed subprocess
  boundary; a generic Claude worktree inspection does not invoke or observe
  this structural route.
applicable_acs: [AC4, AC5]
execution_environment: >-
  Hermetic root chain with python3, uv, and git; no authentication, network,
  credential, or live GitHub Issue mutation.
skip_conditions: >-
  A missing required AC4/AC5 subprocess result, unavailable fixture runtime,
  or fallback-only result is non-PASS and blocks review; do not convert it to
  PASS.
fallback_policy: >-
  Fallback success is not PASS. The real root executor → policy → registry →
  fixture-child test remains required evidence for AC4 and AC5.
artifact_requirements: >-
  Focused pytest output proving byte-for-byte stdout, stderr, return code, and
  no-spawn negatives, bound to the reviewed PR head.

In Scope

  • Dedicated --apply-structural-repair-action parsing in skill_runtime_exec.py, mutually exclusive with generic apply.
  • A sibling structural exact policy that accepts only structural_repair_action.apply, its dedicated flag, trusted repo, target Issue's safe repo-relative artifact path, canonical root/default branch, and active Issue worktree.
  • Rendering the existing registry command with preflight_result_path and reusing existing child supervision, write checks, and stdout/stderr/returncode relay.
  • SKILL.md documentation that maps the structural next action only to the structural command and flag, normalizes the artifact path, prohibits cross-route flag pairing, and resumes fresh preflight/Step 2 only after exit 0, complete phase, null failure code, and applied/no_change outcome.
  • Production-shaped fixture tests with only the leaf child substituted; policy and registry remain real.

Out of Scope

  • Changing command-registry argv, run_refinement_preflight.py, the structural consumer, its payload/schema/digest validation, or any schema.
  • Root re-parsing of nested structural payload semantics, disposition, item digests, provenance, or body drift.
  • Generic repair behavior changes, new ledger/state store/broker/authorization infrastructure, or permission broadening.
  • Live GitHub mutation, network/auth dependency, or model-specific canary as runtime verification.

Acceptance Criteria

  • AC1: .claude/skills/issue-refinement-loop/SKILL.md lists apply_deterministic_structural_repair as a canonical next action and maps it only to structural_repair_action.apply with --apply-structural-repair-action and a target-Issue repo-relative preflight artifact.
  • AC2: The root parser accepts the structural flag and generic/structural apply flags are mutually exclusive.
  • AC3: The structural exact policy accepts only the fixed structural command shape and validates canonical root/default branch, active Issue worktree, repository identity, and the target Issue artifact path.
  • AC4: A real hermetic chain using the production root executor, production exact policy, and production command registry proves observed child argv, byte-for-byte stdout relay, stderr sentinel relay, and nonzero child return-code propagation.
  • AC5: Missing, mixed, or extra flags; wrong command/flag pairing; absolute/traversal/symlink/cross-Issue paths; and wrong repo/Issue/cwd/branch/active-Issue context fail before the fixture child starts.
  • AC6: An executable documentation-contract test loads SKILL.md and proves that the canonical structural route permits fresh preflight/Step 2 only for exit 0, phase: complete, null failure_code, and mutation_outcome applied/no_change; it asserts that unknown, not_attempted, incomplete, and nonzero results are not blindly retried.
  • AC7: Existing generic root wiring plus the merged structural consumer, structural deadlock-arbitration, and generic repair consumer suites pass unchanged.
  • AC8: Verification adds no live canary, network/auth dependency, credential requirement, schema, ledger, persistent state store, generic broker, permission broadening, or unrelated runtime harness. This bounded negative-scope assertion is not an agent-runtime smoke gate; AC4 and AC5 remain the immediate runtime verification evidence. The fresh PR review must enforce the live Allowed Paths gate and assess this assertion through Schema Change Applicability, Schema Consumer Inventory, and Safety Claim Matrix.

Verification Commands

# AC1
# baseline-expect: fail
$ rg -n "apply_deterministic_structural_repair" .claude/skills/issue-refinement-loop/SKILL.md
# AC2
# baseline-expect: fail
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_commands.py -k "structural_repair_action_apply" -v
# AC3
# baseline-expect: fail
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_commands.py -k "structural_repair_action_apply" -v
# AC4
# baseline-expect: fail
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py -k "structural_repair_action_apply" -v
# AC5
# baseline-expect: fail
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py -k "structural_repair_action_apply" -v
# AC6
# baseline-expect: fail
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_commands.py -k "structural_repair_route_documents_resume_gate" -v
# AC7
# baseline-expect: fail
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_commands.py scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py -q
# AC8
# baseline-expect: pass
# preflight-scope: pr_review_only
$ git diff --check

Allowed Paths

  • .claude/skills/issue-refinement-loop/SKILL.md
  • scripts/agent-guards/skill_runtime_exec.py
  • scripts/agent-guards/skill_runtime_command_policy.py
  • scripts/agent-guards/tests/test_skill_runtime_policy_commands.py
  • scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • The command-registry argv, structural consumer, or schema must change.
  • A genuine semantic contradiction, actual Git conflict, secret/credential exposure, or permission escalation/bypass cannot be resolved by the declared route.
  • A live GitHub mutation would be required as runtime verification.

Required Skills

  • Python
  • pytest subprocess fixtures

Required Design References

Scope Delta(任意)

  • Correct AC8's verification target: the prior generic Claude worktree smoke neither invoked nor observed structural_repair_action.apply, so it is removed as a merge gate without weakening AC4/AC5's production-shaped subprocess evidence.
  • Preserve decision: immediate for AC4/AC5 and retain AC8 as the bounded no-live-mutation/no-broadening assertion.

Delivery Rule

1 Issue = 1 PR. Use an isolated worktree and create a Draft PR by default. Do not merge. Shared paths are advisory only: retain the Scope Collision Record, rebase if necessary, and stop only for actual Git conflict or genuine semantic contradiction. No live GitHub mutation is runtime verification.

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Aug 29, 2026
  2. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES / reframe_in_place を推奨します。

    実装の必要性は明確です。PR #2400 は structural_repair_action.apply の command registry entry と consumer を追加し、現在の main にマージ済みです。しかし #2402 の現行契約どおり4ファイルだけを変更すると、完成するのは人間がコマンド名を知っていれば実行できる root executorまでであり、issue-refinement-loop が NEXT_ACTION: apply_deterministic_structural_repair を受信して専用 consumer を選ぶ正規ルートは未定義のまま残ります。現在の main は PR #2400 の merge commit 12806d85639567998ee5121f7196a3c8afe0d54e です。

    review_verdict: request_changes
    recommended_disposition: reframe_in_place
    implementation_ready: false
    primary_blocker: canonical_issue_refinement_route_is_out_of_scope
    scope_change_size: small
    split_required: false
    live_canary_required: false

    重大所見

    重要度 | 所見 | 影響 | 必須対応 -- | -- | -- | -- P0 | canonical NEXT_ACTION route が Allowed Paths 外 | executor は存在しても通常の refinement loop から選ばれない | SKILL.md を追加し structural route を規定 P1 | Runtime Verification が not_applicable | リポジトリ自身の検証ポリシーと矛盾 | hermetic subprocess を immediate として扱う P1 | AC4 が stdout しか要求しない | stderr 消失・exit code 0 化・mock false-green を検出できない | real root chain で argv/stdout/stderr/returncode を検証 P1 | 「payload の cross-route 防止」が root の責務になっている | artifact semantic parsingの重複実装を誘発 | root は command/flag/path isolation、payload は既存 consumer に委ねる P1 | AC6・AC7 と Verification Commands が一致しない | generic regression や no-spawn を証明できない | focused E2E と full root regression を分離 P2 | #2180 の参照が粗く、#2393との順序も曖昧 | 将来の実装者が誤った起点や並列編集を選び得る | exact incident comment と明示的な直列化を記載

    P0 — root executor の配線だけでは正規フローが閉じない

    現在の .claude/skills/issue-refinement-loop/SKILL.md が列挙する canonical NEXT_ACTION は、

    proceed
    proceed_with_notes
    apply_deterministic_repair
    human_judgment_required
    fix_environment
    issue_editor_required

    で、apply_deterministic_structural_repair が含まれていません。詳細な後続処理も generic の apply_deterministic_repair → repair_action.apply → --apply-repair-action だけが定義されています。

    一方、PR #2400 後の preflight は structural deadlock override 成立時に、

    STATUS: needs_fix
    NEXT_ACTION: apply_deterministic_structural_repair

    を返します。しかし commands は structural arbitration より前に _commands_from_plan() から構築され、その後 structural next action が選ばれても専用 command が追加されません。つまり COMMANDS_JSON が自動的に欠落を補う設計にもなっていません。

    #2402 は SKILL.md を Required Design Reference に指定しながら、Allowed Paths には含めていません。現行の4ファイルだけで Outcome の「typed structural repair dispatch」を主張するのは過剰です。

    必須修正

    .claude/skills/issue-refinement-loop/SKILL.md を Allowed Paths に追加し、generic route と並べて次を明文化する必要があります。

    fresh preflight
      STATUS: needs_fix
      NEXT_ACTION: apply_deterministic_structural_repair
      structural_repair_action.disposition_summary: auto_apply_safe
        ↓
    canonical main/root thread
        ↓
    skill_runtime_exec.py
      --command-id structural_repair_action.apply
      --apply-structural-repair-action <repo-relative preflight artifact>

    consumer の戻り値は少なくとも次のように扱うべきです。

    exit 0
    AND phase == complete
    AND failure_code == null
    AND mutation_outcome in {applied, no_change}
      → fresh preflight → fresh Step 2 review
    

    それ以外
    → implementation authorization を出さず停止
    → unknown / not_attempted / nonzero を盲目的に再試行しない

    この結果判定は generic route の既存規則を structural result shape に読み替えるだけでよく、新しい state machine や schema は不要です。


    P1 — Runtime Verification Applicability: not_applicable は誤り

    #2402 は「fixture subprocess が exact child argv と stdout relay を証明する」と要求しながら、Runtime Verification を not_applicable としています。

    ところがリポジトリの正本では、

    • not_applicable: プロセス起動・通信・I/O が不要な静的検証

    • immediate: 本 Issue 内でプロセス起動・I/O を伴う動作検証が成立する

    と区別されています。したがって、hermetic な subprocess test であっても immediate が正しい分類です。

    これは live GitHub mutation を要求するという意味ではありません。ネットワーク、認証、実 Issue mutation を使わず、isolated Git fixture と fixture child だけで完結させれば十分です。同じリポジトリの #2401 も root-to-producer の hermetic process invocation を immediate としています。

    推奨形は次です。

    ## Runtime Verification Applicability

    decision: immediate
    reason: >-
    The production root executor launches a real fixture child process through
    the real exact policy and command registry, and the test verifies process
    argv and output/exit propagation.
    applicable_acs:

    • AC4
    • AC5
      execution_environment:
      cli_tools: [python3, uv, git]
      auth_required: false
      network_required: false
      skip_conditions:
    • If the isolated Git fixture cannot execute, record environment_blocked;
      do not convert it to PASS.
      fallback_policy:
      fallback_success_is_pass: false
      artifact_requirements:
    • Targeted pytest output proving observed child argv, stdout, stderr,
      return code, and no-spawn rejection cases.

    P1 — AC4 は false-green を許す

    現行 AC4 は「fixture subprocess が exact child argv と stdout relay を証明する」だけです。これでは次の欠陥が残っても PASS できます。

    • subprocess.run や supervisor を monkeypatch し、実 registry を通していない

    • structural command が実際には generic branch に入っている

    • child stderr が捨てられる

    • child の非ゼロ終了が root で 0 に正規化される

    • invalid input を拒否した後も child が一度起動されている

    現在の executor は、実 registry の render_command() をロードして child を起動し、最後に stdout、stderr、returncode をそれぞれ親へ転送します。またコード内には、過去に stub renderer が undeclared params を無視したため、production registry では失敗する経路をテストが通してしまったという false-green の記録もあります。

    既存 generic test も、real executor・real policy・real registry・real child chain を通すことを明示しています。新しい structural test はこの形を踏襲すべきです。

    Python の subprocess API でも return code、stdout、stderr は別の観測値です。stdout だけの確認では process relay の契約を証明できません。argv は文字列ではなく sequence のまま扱う現在の実装を維持するのが適切です。(Python documentation)

    必要な test oracle

    real root executor から real policy・real registry を経由し、fixture child だけを置き換えます。fixture child は、

    1. 受け取った sys.argv を stdout に JSON 出力

    2. 固有の sentinel を stderr に出力

    3. 意図的に 17 などの非ゼロで終了

    とします。

    親テストは次を検証します。

    observed script argv:
    --issue-number 2402
    --repo squne121/loop-protocol
    --apply-structural-repair-action
    .claude/artifacts/issue-refinement-loop/2402/refinement_preflight_result_v1.json

    parent stdout == child stdout
    parent stderr contains child sentinel
    parent returncode == 17

    これは live mutation testではありません。実 child consumer の semantic correctness は PR #2400 で追加済みの consumer suitesが担当し、ここでは root wiring だけを production-shaped に証明します。


    P1 — root で payload を再検証してはいけない

    現行 AC3 の、

    Generic and structural repair flags, payloads, and dispatch routes cannot cross-route.

    という表現は、payloads まで root executor の責務に読めます。

    しかし root が扱うべきなのは次だけです。

    • command ID

    • outer CLI flag

    • repo slug

    • Issue番号

    • artifact path

    • cwd / branch / active Issue context

    repair_action と structural_repair_action の nested payload、disposition、item schema、digest 等は child consumer の責務です。PR #2400 が追加した structural consumer は、structural bundle の provenance・disposition・item digest・body drift を既に検証します。root 側でも JSON を開いて同じ判定を行うと、consumer が二重化し、将来の schema変更で split-brain を起こします。

    AC3 は次のように狭めるべきです。

    - structural command + generic flag は拒否

    • generic command + structural flag は拒否
    • 両 flag 同時指定は拒否
    • command に必要な flag がない場合は拒否
    • extra argv は拒否
    • 拒否時は child を起動しない

    outer argparse では両 apply flag を mutually exclusive group に入れられます。ただし、command ID と flag の対応関係は引き続き exact policy で検証します。(Python documentation)


    P1 — 新しい安全ハーネスは不要

    generic の exact apply parser は既に次を実装しています。

    • 固定12 token shape

    • flag順序の固定

    • trusted repo slug

    • 正の Issue番号

    • eligible command ID

    • Issue固有 artifact root

    • canonical root / default branch

    • active Issue worktree

    また _is_safe_issue_artifact_path() は absolute path、traversal、symlink component、別 Issue の artifact root、shlex round-tripで意味が変わるパスを拒否します。

    structural route ではこれをそのまま再利用すれば十分です。次は追加しない方がよいです。

    • 新しい artifact schema

    • 新しい authorization receipt

    • 新しい persistent state / ledger

    • 汎用 command broker

    • live GitHub canary

    • native / Claude-GPT の反復比較 matrix

    • permission bypass

    • exact parser family 全体の大規模リファクタリング

    #2396 の敵対的レビューも、残すべき境界を provenance、single mutation、stale guard、authoritative readback、fresh validation、unknown outcome の blind retry 禁止に限定し、global state machine や enforcing hook 等は不要としています。

    個人趣味開発としては、generic parserを大きく抽象化せず、structural sibling を1本追加して既存 helperを共有する程度が最も実用的です。


    P2 — 参照元と scope collision を明確化する

    #2180

    #2180 自体の主題は percentile estimator の統一です。structural repair の契機は Issue本文ではなく、Runtime Verification Applicability 欠落により、

    missing_required_section
    structural_repair_action_deferred
    PLANNER_FAIL_CLOSED

    となったコメント上のインシデントです。

    したがって goal_ref は曖昧に「Issue #2180 described」とするのではなく、次を参照する方が追跡しやすくなります。

    #2393

    #2393 は現在 open で、skill_runtime_command_policy.py と skill_runtime_exec.py、さらに SKILL.md を変更対象としています。また #2199 の完了待ちで、共有ファイルの並列編集を禁止しています。

    #2402 を #2393 に依存させる必要はありませんが、次の順序を明記すると実務上十分です。

    #2402 を先に実装・マージする。
    #2393 は #2199 完了後、最新 main に rebase し、
    新設された structural profile を保持する。
    両 PR で shared files を同時編集しない。

    最小の実装設計

    skill_runtime_exec.py

    • --apply-structural-repair-action を追加

    • generic flag と mutually exclusive にする

    • is_structural_repair_action_apply_command を dedicated execution class から判定

    • structural command 専用 exact-policy predicate を呼ぶ

    • structural render params へ preflight_result_path を渡す

    • child supervision、write checks、artifact projection、stdout/stderr/returncode relay は既存共通経路をそのまま使う

    skill_runtime_command_policy.py

    • EXACT_STRUCTURAL_REPAIR_ACTION_APPLY 相当の execution classを追加

    • structural専用 parser / predicateを追加

    • command ID は structural_repair_action.apply のみ

    • flag は --apply-structural-repair-action のみ

    • path検証は既存 _is_safe_issue_artifact_path() を再利用

    • generic parserの意味論は変更しない

    SKILL.md

    • canonical NEXT_ACTION enum に apply_deterministic_structural_repair を追加

    • dedicated command / flag / artifact normalizationを記載

    • generic routeとの cross-route禁止を記載

    • mutation_outcome / phase / failure_code に基づく後続処理を記載

    • success後の fresh preflight / Step 2再開を記載

    • unknown / not_attempted / nonzeroのblind retry禁止を記載

    Tests

    • policy parser positive/negative matrix

    • real root→real policy→real registry→fixture child

    • stdout・stderr・returncode relay

    • invalid input時の child no-spawn

    • full root test filesによる generic regression
      -既存 structural consumer/deadlock suitesは無変更で実行


    Issue本文の推奨差し替え

    ## Machine-Readable Contract
    
    
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: none
    goal_ref: &gt;-
      PR #2400 delivered the distinct structural repair consumer and registry
      entry. Close both remaining root gaps: exact skill-runtime executor
      dispatch and the canonical issue-refinement-loop route for
      NEXT_ACTION apply_deterministic_structural_repair.
    change_kind: workflow-runtime</code></pre><h2>Current Validated Scope</h2><ul><li><p>Add the dedicated outer structural flag and exact structural command<br>policy/parser/dispatcher wiring.</p></li><li><p>Add the canonical <code inline="">apply_deterministic_structural_repair</code> route to<br><code inline="">issue-refinement-loop/SKILL.md</code>.</p></li><li><p>Reuse the existing repository, Issue, active-worktree and<br><code inline="">_is_safe_issue_artifact_path()</code> validation.</p></li><li><p>Prove the real root executor → real exact policy → real command registry →<br>fixture child chain, including argv, stdout, stderr and return-code<br>propagation.</p></li><li><p>Preserve the merged PR #2400 registry argv and structural consumer.</p></li></ul><h2>Runtime Verification Applicability</h2><p>decision: immediate<br>reason: &gt;-<br>The production root executor launches a real fixture child process through<br>the real exact policy and registry. No network, authentication or live<br>GitHub Issue mutation is required.<br>applicable_acs: [AC4, AC5]<br>execution_environment:<br>cli_tools: [python3, uv, git]<br>auth_required: false<br>network_required: false<br>skip_conditions:</p><ul><li><p>If the isolated Git fixture cannot execute, record environment_blocked<br>and do not treat the result as PASS.<br>fallback_policy:<br>fallback_success_is_pass: false<br>artifact_requirements:</p></li><li><p>Targeted pytest output containing the observed child argv, stdout,<br>stderr, return code and no-spawn negative cases.</p></li></ul><h2>Acceptance Criteria</h2><ul class="contains-task-list"><li class="task-list-item"><p><input type="checkbox" disabled=""> AC1: <code inline="">issue-refinement-loop/SKILL.md</code> lists<br><code inline="">apply_deterministic_structural_repair</code> as a canonical next action and<br>maps it only to <code inline="">structural_repair_action.apply</code> with<br><code inline="">--apply-structural-repair-action</code>.</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC2: The root parser accepts the structural flag, and generic and<br>structural apply flags are mutually exclusive.</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC3: The structural exact policy accepts only the fixed structural<br>command shape and validates canonical root/default branch, active Issue,<br>repository identity and the target Issue's repo-relative artifact path.</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC4: A real hermetic subprocess chain using the production root<br>executor, production exact policy and production command registry proves<br>the observed child argv, stdout relay, stderr relay and nonzero child<br>return-code propagation.</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC5: Missing, mixed or extra flags; wrong command/flag pairing;<br>absolute/traversal/symlink/cross-Issue paths; wrong repo, Issue, cwd,<br>branch or active-Issue context fail before the fixture child starts.</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC6: The canonical route permits fresh preflight/review continuation<br>only for exit 0 + phase complete + failure_code null +<br>mutation_outcome applied/no_change. Unknown, not_attempted and nonzero<br>outcomes are not blindly retried.</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC7: Existing generic root wiring and the merged structural consumer<br>and deadlock-arbitration suites pass unchanged.</p></li><li class="task-list-item"><p><input type="checkbox" disabled=""> AC8: Verification is hermetic and adds no live mutation, network<br>dependency, credential requirement, schema, ledger, state store or<br>permission broadening.</p></li></ul><h2>Verification Commands</h2><pre><code class="language-bash">rg -n \
      "apply_deterministic_structural_repair|structural_repair_action.apply|--apply-structural-repair-action" \
      .claude/skills/issue-refinement-loop/SKILL.md</code></pre><pre><code class="language-bash">uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_policy_commands.py \
      -k "structural or repair_action" -v</code></pre><pre><code class="language-bash">uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py \
      -k "structural or repair_action" -v</code></pre><pre><code class="language-bash">uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_policy_commands.py \
      scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py -q</code></pre><pre><code class="language-bash">uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_structural_repair_action_apply_consumer.py \
      .claude/skills/issue-refinement-loop/tests/test_structural_repair_deadlock_arbitration.py \
      .claude/skills/issue-refinement-loop/tests/test_repair_action_apply_consumer.py \
      -q</code></pre><h2>Allowed Paths</h2><ul><li><p><code inline="">.claude/skills/issue-refinement-loop/SKILL.md</code></p></li><li><p><code inline="">scripts/agent-guards/skill_runtime_exec.py</code></p></li><li><p><code inline="">scripts/agent-guards/skill_runtime_command_policy.py</code></p></li><li><p><code inline="">scripts/agent-guards/tests/test_skill_runtime_policy_commands.py</code></p></li><li><p><code inline="">scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py</code></p></li></ul><h2>Scope Collision Record</h2><ul><li><p>#2393 overlaps the two root runtime files and <code inline="">SKILL.md</code>.</p></li><li><p>Implement and merge #2402 first while #2393 remains blocked by #2199.</p></li><li><p>Do not develop overlapping PRs in parallel.</p></li><li><p>#2393 must rebase onto the merged #2402 result and preserve the structural<br>command profile.</p></li></ul><h2>Out of Scope</h2><ul><li><p>Changes to command-registry argv, <code inline="">run_refinement_preflight.py</code>, the<br>structural consumer or schemas.</p></li><li><p>Live GitHub mutation or model-specific repeated canaries.</p></li><li><p>New authorization infrastructure, ledger, persistent state, global<br>command framework or permission broadening.</p></li></ul><pre><code>
    ## 最終評価
    
    #2402 は**分割せず、その場で小さく reframe すれば implementation-ready にできます**。追加が必要なのは主に `SKILL.md` 1ファイルと、既存 subprocess test の oracle強化です。
    
    live canary、モデル別3回実行、新規schema、追加ledger、権限ハーネスは不要です。逆に、canonical route・stderr・returncode・no-spawn の証明を削ると「コマンドは追加されたが通常フローから使われない」「失敗を成功として扱う」という実用上の欠陥を残します。</code></pre></body></html><!--EndFragment-->
    </body>
    </html>## 判定
    
    **`REQUEST_CHANGES` / `reframe_in_place` を推奨します。**
    
    実装の必要性は明確です。PR #2400 は `structural_repair_action.apply` の command registry entry と consumer を追加し、現在の `main` にマージ済みです。しかし #2402 の現行契約どおり4ファイルだけを変更すると、完成するのは**人間がコマンド名を知っていれば実行できる root executor**までであり、`issue-refinement-loop` が `NEXT_ACTION: apply_deterministic_structural_repair` を受信して専用 consumer を選ぶ**正規ルート**は未定義のまま残ります。現在の `main` は PR #2400 の merge commit `12806d85639567998ee5121f7196a3c8afe0d54e` です。
    
    ```yaml
    review_verdict: request_changes
    recommended_disposition: reframe_in_place
    implementation_ready: false
    primary_blocker: canonical_issue_refinement_route_is_out_of_scope
    scope_change_size: small
    split_required: false
    live_canary_required: false
    

    重大所見

    重要度 所見 影響 必須対応
    P0 canonical NEXT_ACTION route が Allowed Paths 外 executor は存在しても通常の refinement loop から選ばれない SKILL.md を追加し structural route を規定
    P1 Runtime Verification が not_applicable リポジトリ自身の検証ポリシーと矛盾 hermetic subprocess を immediate として扱う
    P1 AC4 が stdout しか要求しない stderr 消失・exit code 0 化・mock false-green を検出できない real root chain で argv/stdout/stderr/returncode を検証
    P1 「payload の cross-route 防止」が root の責務になっている artifact semantic parsingの重複実装を誘発 root は command/flag/path isolation、payload は既存 consumer に委ねる
    P1 AC6・AC7 と Verification Commands が一致しない generic regression や no-spawn を証明できない focused E2E と full root regression を分離
    P2 #2180 の参照が粗く、#2393との順序も曖昧 将来の実装者が誤った起点や並列編集を選び得る exact incident comment と明示的な直列化を記載

    P0 — root executor の配線だけでは正規フローが閉じない

    現在の .claude/skills/issue-refinement-loop/SKILL.md が列挙する canonical NEXT_ACTION は、

    proceed
    proceed_with_notes
    apply_deterministic_repair
    human_judgment_required
    fix_environment
    issue_editor_required
    

    で、apply_deterministic_structural_repair が含まれていません。詳細な後続処理も generic の apply_deterministic_repair → repair_action.apply → --apply-repair-action だけが定義されています。

    一方、PR #2400 後の preflight は structural deadlock override 成立時に、

    STATUS: needs_fix
    NEXT_ACTION: apply_deterministic_structural_repair
    

    を返します。しかし commands は structural arbitration より前に _commands_from_plan() から構築され、その後 structural next action が選ばれても専用 command が追加されません。つまり COMMANDS_JSON が自動的に欠落を補う設計にもなっていません。

    #2402 は SKILL.md を Required Design Reference に指定しながら、Allowed Paths には含めていません。現行の4ファイルだけで Outcome の「typed structural repair dispatch」を主張するのは過剰です。

    必須修正

    .claude/skills/issue-refinement-loop/SKILL.md を Allowed Paths に追加し、generic route と並べて次を明文化する必要があります。

    fresh preflight
      STATUS: needs_fix
      NEXT_ACTION: apply_deterministic_structural_repair
      structural_repair_action.disposition_summary: auto_apply_safe
        ↓
    canonical main/root thread
        ↓
    skill_runtime_exec.py
      --command-id structural_repair_action.apply
      --apply-structural-repair-action <repo-relative preflight artifact>
    

    consumer の戻り値は少なくとも次のように扱うべきです。

    exit 0
    AND phase == complete
    AND failure_code == null
    AND mutation_outcome in {applied, no_change}
      → fresh preflight → fresh Step 2 review
    
    それ以外
      → implementation authorization を出さず停止
      → unknown / not_attempted / nonzero を盲目的に再試行しない
    

    この結果判定は generic route の既存規則を structural result shape に読み替えるだけでよく、新しい state machine や schema は不要です。


    P1 — Runtime Verification Applicability: not_applicable は誤り

    #2402 は「fixture subprocess が exact child argv と stdout relay を証明する」と要求しながら、Runtime Verification を not_applicable としています。

    ところがリポジトリの正本では、

    • not_applicable: プロセス起動・通信・I/O が不要な静的検証
    • immediate: 本 Issue 内でプロセス起動・I/O を伴う動作検証が成立する

    と区別されています。したがって、hermetic な subprocess test であっても immediate が正しい分類です。

    これは live GitHub mutation を要求するという意味ではありません。ネットワーク、認証、実 Issue mutation を使わず、isolated Git fixture と fixture child だけで完結させれば十分です。同じリポジトリの #2401 も root-to-producer の hermetic process invocation を immediate としています。

    推奨形は次です。

    ## Runtime Verification Applicability
    
    decision: immediate
    reason: >-
      The production root executor launches a real fixture child process through
      the real exact policy and command registry, and the test verifies process
      argv and output/exit propagation.
    applicable_acs:
      - AC4
      - AC5
    execution_environment:
      cli_tools: [python3, uv, git]
      auth_required: false
      network_required: false
    skip_conditions:
      - If the isolated Git fixture cannot execute, record environment_blocked;
        do not convert it to PASS.
    fallback_policy:
      fallback_success_is_pass: false
    artifact_requirements:
      - Targeted pytest output proving observed child argv, stdout, stderr,
        return code, and no-spawn rejection cases.
    

    P1 — AC4 は false-green を許す

    現行 AC4 は「fixture subprocess が exact child argv と stdout relay を証明する」だけです。これでは次の欠陥が残っても PASS できます。

    • subprocess.run や supervisor を monkeypatch し、実 registry を通していない
    • structural command が実際には generic branch に入っている
    • child stderr が捨てられる
    • child の非ゼロ終了が root で 0 に正規化される
    • invalid input を拒否した後も child が一度起動されている

    現在の executor は、実 registry の render_command() をロードして child を起動し、最後に stdout、stderr、returncode をそれぞれ親へ転送します。またコード内には、過去に stub renderer が undeclared params を無視したため、production registry では失敗する経路をテストが通してしまったという false-green の記録もあります。

    既存 generic test も、real executor・real policy・real registry・real child chain を通すことを明示しています。新しい structural test はこの形を踏襲すべきです。

    Python の subprocess API でも return code、stdout、stderr は別の観測値です。stdout だけの確認では process relay の契約を証明できません。argv は文字列ではなく sequence のまま扱う現在の実装を維持するのが適切です。([Python documentation]1)

    必要な test oracle

    real root executor から real policy・real registry を経由し、fixture child だけを置き換えます。fixture child は、

    1. 受け取った sys.argv を stdout に JSON 出力
    2. 固有の sentinel を stderr に出力
    3. 意図的に 17 などの非ゼロで終了

    とします。

    親テストは次を検証します。

    observed script argv:
      --issue-number 2402
      --repo squne121/loop-protocol
      --apply-structural-repair-action
      .claude/artifacts/issue-refinement-loop/2402/refinement_preflight_result_v1.json
    
    parent stdout == child stdout
    parent stderr contains child sentinel
    parent returncode == 17
    

    これは live mutation testではありません。実 child consumer の semantic correctness は PR #2400 で追加済みの consumer suitesが担当し、ここでは root wiring だけを production-shaped に証明します。


    P1 — root で payload を再検証してはいけない

    現行 AC3 の、

    Generic and structural repair flags, payloads, and dispatch routes cannot cross-route.

    という表現は、payloads まで root executor の責務に読めます。

    しかし root が扱うべきなのは次だけです。

    • command ID
    • outer CLI flag
    • repo slug
    • Issue番号
    • artifact path
    • cwd / branch / active Issue context

    repair_action と structural_repair_action の nested payload、disposition、item schema、digest 等は child consumer の責務です。PR #2400 が追加した structural consumer は、structural bundle の provenance・disposition・item digest・body drift を既に検証します。root 側でも JSON を開いて同じ判定を行うと、consumer が二重化し、将来の schema変更で split-brain を起こします。

    AC3 は次のように狭めるべきです。

    - structural command + generic flag は拒否
    - generic command + structural flag は拒否
    - 両 flag 同時指定は拒否
    - command に必要な flag がない場合は拒否
    - extra argv は拒否
    - 拒否時は child を起動しない
    

    outer argparse では両 apply flag を mutually exclusive group に入れられます。ただし、command ID と flag の対応関係は引き続き exact policy で検証します。([Python documentation]2)


    P1 — 新しい安全ハーネスは不要

    generic の exact apply parser は既に次を実装しています。

    • 固定12 token shape
    • flag順序の固定
    • trusted repo slug
    • 正の Issue番号
    • eligible command ID
    • Issue固有 artifact root
    • canonical root / default branch
    • active Issue worktree

    また _is_safe_issue_artifact_path() は absolute path、traversal、symlink component、別 Issue の artifact root、shlex round-tripで意味が変わるパスを拒否します。

    structural route ではこれをそのまま再利用すれば十分です。次は追加しない方がよいです。

    • 新しい artifact schema
    • 新しい authorization receipt
    • 新しい persistent state / ledger
    • 汎用 command broker
    • live GitHub canary
    • native / Claude-GPT の反復比較 matrix
    • permission bypass
    • exact parser family 全体の大規模リファクタリング

    #2396 の敵対的レビューも、残すべき境界を provenance、single mutation、stale guard、authoritative readback、fresh validation、unknown outcome の blind retry 禁止に限定し、global state machine や enforcing hook 等は不要としています。

    個人趣味開発としては、generic parserを大きく抽象化せず、structural sibling を1本追加して既存 helperを共有する程度が最も実用的です。


    P2 — 参照元と scope collision を明確化する

    #2180

    #2180 自体の主題は percentile estimator の統一です。structural repair の契機は Issue本文ではなく、Runtime Verification Applicability 欠落により、

    missing_required_section
    structural_repair_action_deferred
    PLANNER_FAIL_CLOSED
    

    となったコメント上のインシデントです。

    したがって goal_ref は曖昧に「Issue #2180 described」とするのではなく、次を参照する方が追跡しやすくなります。

    • #2180 の具体的な停止コメント
    • #2396
    • merged PR #2400

    #2393

    #2393 は現在 open で、skill_runtime_command_policy.py と skill_runtime_exec.py、さらに SKILL.md を変更対象としています。また #2199 の完了待ちで、共有ファイルの並列編集を禁止しています。

    #2402 を #2393 に依存させる必要はありませんが、次の順序を明記すると実務上十分です。

    #2402 を先に実装・マージする。
    #2393 は #2199 完了後、最新 main に rebase し、
    新設された structural profile を保持する。
    両 PR で shared files を同時編集しない。
    

    最小の実装設計

    skill_runtime_exec.py

    • --apply-structural-repair-action を追加
    • generic flag と mutually exclusive にする
    • is_structural_repair_action_apply_command を dedicated execution class から判定
    • structural command 専用 exact-policy predicate を呼ぶ
    • structural render params へ preflight_result_path を渡す
    • child supervision、write checks、artifact projection、stdout/stderr/returncode relay は既存共通経路をそのまま使う

    skill_runtime_command_policy.py

    • EXACT_STRUCTURAL_REPAIR_ACTION_APPLY 相当の execution classを追加
    • structural専用 parser / predicateを追加
    • command ID は structural_repair_action.apply のみ
    • flag は --apply-structural-repair-action のみ
    • path検証は既存 _is_safe_issue_artifact_path() を再利用
    • generic parserの意味論は変更しない

    SKILL.md

    • canonical NEXT_ACTION enum に apply_deterministic_structural_repair を追加
    • dedicated command / flag / artifact normalizationを記載
    • generic routeとの cross-route禁止を記載
    • mutation_outcome / phase / failure_code に基づく後続処理を記載
    • success後の fresh preflight / Step 2再開を記載
    • unknown / not_attempted / nonzeroのblind retry禁止を記載

    Tests

    • policy parser positive/negative matrix
    • real root→real policy→real registry→fixture child
    • stdout・stderr・returncode relay
    • invalid input時の child no-spawn
    • full root test filesによる generic regression
      -既存 structural consumer/deadlock suitesは無変更で実行

    Issue本文の推奨差し替え

    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: none
    goal_ref: >-
      PR #2400 delivered the distinct structural repair consumer and registry
      entry. Close both remaining root gaps: exact skill-runtime executor
      dispatch and the canonical issue-refinement-loop route for
      NEXT_ACTION apply_deterministic_structural_repair.
    change_kind: workflow-runtime
    

    Current Validated Scope

    • Add the dedicated outer structural flag and exact structural command
      policy/parser/dispatcher wiring.
    • Add the canonical apply_deterministic_structural_repair route to
      issue-refinement-loop/SKILL.md.
    • Reuse the existing repository, Issue, active-worktree and
      _is_safe_issue_artifact_path() validation.
    • Prove the real root executor → real exact policy → real command registry →
      fixture child chain, including argv, stdout, stderr and return-code
      propagation.
    • Preserve the merged PR #2400 registry argv and structural consumer.

    Runtime Verification Applicability

    decision: immediate
    reason: >-
    The production root executor launches a real fixture child process through
    the real exact policy and registry. No network, authentication or live
    GitHub Issue mutation is required.
    applicable_acs: [AC4, AC5]
    execution_environment:
    cli_tools: [python3, uv, git]
    auth_required: false
    network_required: false
    skip_conditions:

    • If the isolated Git fixture cannot execute, record environment_blocked
      and do not treat the result as PASS.
      fallback_policy:
      fallback_success_is_pass: false
      artifact_requirements:
    • Targeted pytest output containing the observed child argv, stdout,
      stderr, return code and no-spawn negative cases.

    Acceptance Criteria

    • AC1: issue-refinement-loop/SKILL.md lists
      apply_deterministic_structural_repair as a canonical next action and
      maps it only to structural_repair_action.apply with
      --apply-structural-repair-action.

    • AC2: The root parser accepts the structural flag, and generic and
      structural apply flags are mutually exclusive.

    • AC3: The structural exact policy accepts only the fixed structural
      command shape and validates canonical root/default branch, active Issue,
      repository identity and the target Issue's repo-relative artifact path.

    • AC4: A real hermetic subprocess chain using the production root
      executor, production exact policy and production command registry proves
      the observed child argv, stdout relay, stderr relay and nonzero child
      return-code propagation.

    • AC5: Missing, mixed or extra flags; wrong command/flag pairing;
      absolute/traversal/symlink/cross-Issue paths; wrong repo, Issue, cwd,
      branch or active-Issue context fail before the fixture child starts.

    • AC6: The canonical route permits fresh preflight/review continuation
      only for exit 0 + phase complete + failure_code null +
      mutation_outcome applied/no_change. Unknown, not_attempted and nonzero
      outcomes are not blindly retried.

    • AC7: Existing generic root wiring and the merged structural consumer
      and deadlock-arbitration suites pass unchanged.

    • AC8: Verification is hermetic and adds no live mutation, network
      dependency, credential requirement, schema, ledger, state store or
      permission broadening.

    Verification Commands

    rg -n \
      "apply_deterministic_structural_repair|structural_repair_action.apply|--apply-structural-repair-action" \
      .claude/skills/issue-refinement-loop/SKILL.md
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_policy_commands.py \
      -k "structural or repair_action" -v
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py \
      -k "structural or repair_action" -v
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_skill_runtime_policy_commands.py \
      scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py -q
    
    uv run --locked pytest \
      .claude/skills/issue-refinement-loop/tests/test_structural_repair_action_apply_consumer.py \
      .claude/skills/issue-refinement-loop/tests/test_structural_repair_deadlock_arbitration.py \
      .claude/skills/issue-refinement-loop/tests/test_repair_action_apply_consumer.py \
      -q
    

    Allowed Paths

    • .claude/skills/issue-refinement-loop/SKILL.md
    • scripts/agent-guards/skill_runtime_exec.py
    • scripts/agent-guards/skill_runtime_command_policy.py
    • scripts/agent-guards/tests/test_skill_runtime_policy_commands.py
    • scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py

    Scope Collision Record

    • #2393 overlaps the two root runtime files and SKILL.md.
    • Implement and merge #2402 first while #2393 remains blocked by #2199.
    • Do not develop overlapping PRs in parallel.
    • #2393 must rebase onto the merged #2402 result and preserve the structural
      command profile.

    Out of Scope

    • Changes to command-registry argv, run_refinement_preflight.py, the
      structural consumer or schemas.
    • Live GitHub mutation or model-specific repeated canaries.
    • New authorization infrastructure, ledger, persistent state, global
      command framework or permission broadening.
    
    ## 最終評価
    
    #2402 は**分割せず、その場で小さく reframe すれば implementation-ready にできます**。追加が必要なのは主に `SKILL.md` 1ファイルと、既存 subprocess test の oracle強化です。
    
    live canary、モデル別3回実行、新規schema、追加ledger、権限ハーネスは不要です。逆に、canonical route・stderr・returncode・no-spawn の証明を削ると「コマンドは追加されたが通常フローから使われない」「失敗を成功として扱う」という実用上の欠陥を残します。
    
  3. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    推奨アクションは、現行 #2402 のまま実装開始せず、指定コメントを OWNER の human-context anchor として issue-refinement-loop を再実行し、reframe_in_place を controlled mutation で反映してから実装へ handoff です。指定コメント自身が REQUEST_CHANGES / reframe_in_place / implementation_ready: false としており、P0 は SKILL.md が Allowed Paths 外で canonical structural route が閉じていない点です。 現在の #2402 本文も Allowed Paths が4ファイルのみで、Runtime Verification は not_applicable のままです。

    なお、レビューコメント投稿時点の main=12806d... はすでに古く、現在の main は 132b08c257d6add00c51ff660761cb6e6c90bf53 です。 ただし最新 main の SKILL.md を再確認しても canonical NEXT_ACTION は generic apply_deterministic_repair までで、apply_deterministic_structural_repair はまだありません。したがってレビューの中心的な P0 は現在も有効です。

    また #2393 は SKILL.md と root runtime 2ファイルを共有し、#2199 完了後に実施する契約です。 #2199 は現在も open で、さらに前提の #2197 も open なので、#2402 に形式的な依存を追加する必要はありませんが、共有ファイルの並行実装を避けて #2402 を先に完了させる方針が妥当です。

    Claude-GPT には以下を渡すのを推奨します。

    あなたは squne121/loop-protocol の root control-plane として、Issue #2402 を指定 OWNER comment を human-context anchor にして再 refinement し、implementation-ready になった場合だけ実装・レビューへ進んでください。

    対象:

    この anchor は OWNER による REQUEST_CHANGES / reframe_in_place であり、現行 #2402 をそのまま実装する authority ではありません。

    目的は次の順序です。

    1. current main と repository/GitHub state を fresh に再確認する。
    2. anchor を direct human context として canonical issue-refinement-loop を実行する。
    3. 実装: structural_repair_action.apply を root skill runtime executor へ配線する #2402 を split せず、小さく reframe_in_place する。
    4. fresh preflight / fresh Step 2 review で implementation-ready を再確認する。
    5. canonical handoff が実装開始を許可した場合だけ、isolated worktree で実装し Draft PR を作成する。
    6. focused test、回帰 test、PR review/fix loop を行い merge-ready まで進める。
    7. merge 自体は行わない。

    最初に必ず current state を再取得する

    プロンプト作成時点では main は 132b08c257d6add00c51ff660761cb6e6c90bf53 まで進んでいますが、この SHA を authority として固定しないでください。作業開始時に remote/current main を fresh に取得してください。

    指定 anchor が書かれた時点では main=12806d85639567998ee5121f7196a3c8afe0d54e でした。したがって anchor 内の「current main」という表現をそのまま事実として再利用せず、各技術的 finding を current main に対して再検証してください。

    最低限、次を確認してください。

    古い anchor の finding が current main ですでに解消済みなら stale と明記し、不要な実装を行わないでください。

    SubAgent 利用は必須

    root/main thread から、read-only の bounded SubAgent を複数起動してください。

    最低限、以下の3レーンを分担してください。

    SubAgent A: runtime wiring fact check

    current main 上で以下を独立調査してください。

    • structural_repair_action.apply registry entry
    • structural consumer
    • apply_deterministic_structural_repair producer/arbitration
    • root executor の structural dispatch の有無
    • SKILL.md canonical NEXT_ACTION / orchestration route の有無
    • generic repair_action.apply の既存 exact-policy pattern

    SubAgent B: test/evidence fact check

    以下を調査してください。

    • generic root executor test が real executor → real policy → real registry を通しているか
    • fixture child の差し替え方法
    • stdout / stderr / child returncode relay
    • invalid input 時の child no-spawn oracle
    • absolute / traversal / symlink / cross-Issue / wrong-repo path rejection
    • stub renderer / monkeypatch による false-green を避ける既存 test pattern

    SubAgent C: dependency/scope collision fact check

    GitHub Issue/PR/current repository stateから以下を調査してください。

    必要な外部仕様が disposition に影響する場合のみ、追加で web-researcher 相当を使用してください。Python argparse / subprocess 等の既知仕様を再確認する程度に留め、大規模な一般調査は不要です。

    SubAgent の厳守事項

    • nested SubAgent delegationは禁止。
    • SubAgent に Issue edit、comment投稿、branch作成、commit、push、PR作成等の mutation をさせない。
    • root/main thread が mutation owner。
    • 起動した全 SubAgent が terminal completion を返すまで必ず wait/join すること。
    • 一部だけ完了した状態で先へ進まない。
    • 未完了結果を推測で補完しない。
    • 全結果を統合する前に Issue rewrite、implementation、PR 作成へ進まない。

    Phase 1: #2402 を canonical refinement する

    指定 anchor は必ず human-context lane として扱ってください。URLだけから origin を推定し直したり、agent-report / unlabeled lane に渡したりしないでください。

    canonical main root / default branch から current registry に従い fresh:

    preflight.run.with_human_context

    を実行してください。

    過去の preflight artifact やレビュー結果を implementation authority として再利用しないでください。

    trusted contract patch plan が生成された場合は current canonical contract に従って:

    contract_update.run.with_human_context

    相当の controlled mutation phase を root/main thread から実行してください。

    raw gh issue edit や自由記述による直接書き換えで迂回しないでください。

    もし controlled update が issue_editor_required / full_rewrite_required を返すなら、現在の SKILL.md に定義された controlled issue-editor / edit-issue handoff に従ってください。同一 contract update の no-progress retry はしないでください。

    mutation 後は必ず GitHub から body を readback し、fresh preflight と fresh Step 2 review を実行してください。

    blocked / environment_failure / human_judgment_required が残る場合は bypass せず、その exact blocker と evidence を報告して停止してください。

    #2402 の reframe で維持すべき意図

    current main の fact check で anchor の findings が維持される場合、Issue は概ね次の契約へ reframe してください。

    Scope

    root executor wiring だけでなく、

    fresh preflight
    → NEXT_ACTION: apply_deterministic_structural_repair
    → root/main orchestrator
    → structural_repair_action.apply
    → --apply-structural-repair-action <repo-relative preflight artifact>

    までの canonical route を #2402 の Outcome に含めてください。

    .claude/skills/issue-refinement-loop/SKILL.md を Allowed Paths に追加してください。

    Runtime Verification

    not_applicable ではなく immediate を基本候補としてください。

    ただし live GitHub mutation canary は不要です。

    production-shaped な hermetic subprocess chain:

    real root executor
    → real exact policy
    → real command registry
    → fixture child

    で runtime wiring を検証してください。

    network/auth/live GitHub Issue mutation を runtime verification の条件にしないでください。

    Root/consumer responsibility

    root runtime が検証するのは outer transport boundary に限定してください。

    • command ID
    • apply flag
    • repo
    • issue number
    • artifact path
    • cwd
    • branch
    • active Issue/worktree context

    structural_repair_action 内部の nested payload、disposition、item digest、body drift、provenance 等を root で再パース・再実装しないでください。それらは PR #2400 の structural consumer の責務です。

    新規 schema、ledger、persistent state、汎用 command broker、新規 authorization infrastructure は追加しないでください。

    Cross-route isolation

    最低限以下を fail-closed で固定してください。

    • structural command + generic flag → reject
    • generic command + structural flag → reject
    • generic/structural apply flags 両方 → reject
    • required apply flag 不在 → reject
    • extra argv → reject
    • invalid input では child を spawn しない

    outer argparse で mutually exclusive group を使えるなら current implementationとの整合を確認した上で採用してください。ただし command ID ↔ flag の exact pairing は policy 側でも維持してください。

    Success semantics

    structural consumer 実行後に fresh preflight / Step 2 review を再開できるのは最低限:

    • process exit == 0
    • phase == complete
    • failure_code == null
    • mutation_outcome in {applied, no_change}

    の場合だけとしてください。

    unknown / not_attempted / nonzero / incomplete phase は blind retry しないでください。

    generic lane の現在の結果処理を structural result shape に読み替えて再利用し、新しい state machine を作らないでください。

    Scope collision

    #2393 は SKILL.md、skill_runtime_exec.py、skill_runtime_command_policy.py と重複します。

    current GitHub state を再確認した上で、重複実装がまだ開始されていないなら:

    という coordination を Issue #2402 に記録してください。

    ただし #2393 を不必要に formal dependency として追加しないでください。current evidence が変わっている場合は current state を優先してください。

    Phase 2: approved 後だけ implementation

    fresh refinement loop が approved に到達し、current canonical LOOP_HANDOFF_RESULT_V1 / root_entry_router が implementation handoff を許可した場合だけ implementation に進んでください。

    古い #2402 body の phase/implementation label だけを implementation authority とみなさないでください。

    canonical handoff が許可しなければ実装を開始しないでください。

    Implementation 方針

    1 Issue = 1 PR。

    専用 isolated implementation worktree を使用してください。

    最小差分を優先し、大規模 refactor はしないでください。

    想定変更先は reframe 後の Allowed Paths を authority としますが、current evidence が anchor と一致する場合は概ね:

    • .claude/skills/issue-refinement-loop/SKILL.md
    • scripts/agent-guards/skill_runtime_exec.py
    • scripts/agent-guards/skill_runtime_command_policy.py
    • scripts/agent-guards/tests/test_skill_runtime_policy_commands.py
    • scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py

    です。

    skill_runtime_exec.py

    • dedicated --apply-structural-repair-action outer flag
    • generic apply flagとの mutual exclusion
    • structural execution class の独立判定
    • structural exact-policy predicate の使用
    • registry renderer に正しい structural params を渡す
    • existing child supervision / write checks / stdout/stderr/returncode relay を再利用

    skill_runtime_command_policy.py

    • dedicated structural exact execution class
    • dedicated exact parser/predicate
    • structural_repair_action.apply のみを受理
    • structural apply flag のみを受理
    • current generic lane が使う安全な repo-relative Issue artifact path helper を再利用
    • generic parser の意味論を変更しない

    helper 名は anchor の記述を盲目的にコピーせず current source を確認してください。

    SKILL.md

    • canonical next-action surface に apply_deterministic_structural_repair
    • dedicated command/flag/path normalization
    • generic laneとの cross-route禁止
    • consumer resultの success/failure routing
    • success後の fresh preflight / fresh Step 2
    • unknown/not_attempted/nonzero の blind retry禁止

    を generic repair route と整合する形で追加してください。

    thin-entrypoint の設計を壊して別の state machine を埋め込まないでください。

    Test oracle

    mock/stub-only test を acceptance evidence にしないでください。

    少なくとも production root executor、production exact policy、production registry を実際に通し、fixture child だけを controlled substitute とする test を追加してください。

    fixture child は例えば:

    • 受信 sys.argv を JSON で stdout に出す
    • unique sentinel を stderr に出す
    • 意図的に exit 17 等で終了する

    形にし、親から以下を検証してください。

    • exact child argv
    • stdout byte relay
    • stderr relay
    • nonzero return code propagation

    structural invocation の expected argv は current registry を authority として検証してください。

    negative matrix では invalid input 時に「エラーになった」だけでなく child spawn が0回であることを確認してください。

    generic repair lane が壊れていないことも full root test files で確認してください。

    既存 PR #2400 の structural consumer / deadlock arbitration suites は変更せず PASS させてください。

    Verification

    Issue reframe 後の Verification Commands を authority とし、最低限:

    • focused structural policy tests
    • focused structural root subprocess tests
    • root policy/exec test files全体
    • existing structural consumer tests
    • existing structural deadlock arbitration tests
    • existing generic repair consumer tests
    • repository-standard lint/typecheck/test/build の applicable なもの
    • git diff --check

    を実行してください。

    SKIP、environment-blocked、fallback success を PASS に読み替えないでください。

    live GitHub mutation を runtime verification として実行しないでください。

    PR

    全 AC が evidence 付きで満たされたら Draft PR を作成してください。

    PR body に:

    Closes #2402

    を入れてください。

    PR body には少なくとも:

    を記録してください。

    その後 current repository の canonical implementation/review loop に従い、SubAgent reviewer を含む必要なレビューを実行してください。

    レビュー用 SubAgent を起動した場合も 全員の terminal completion を wait/join してください。

    request changes が出た場合は blocker を current head で再現・fact-checkしてから必要な fix delta のみを実装し、focused + regression tests を再実行してください。

    merge-ready まで進めますが、merge は実行しないでください。

    自律実行と停止条件

    通常の read、GitHub調査、controlled Issue refinement、isolated worktree作成、実装、test、commit、push、Draft PR作成、review/fix iteration は、リポジトリの canonical workflow が許可する範囲で自律的に進めてください。

    以下だけは停止してください。

    • current canonical workflow が human_judgment_required を返す
    • reframe 後 Allowed Paths 外の実装変更が必要
    • command-registry argv、structural consumer、schema の変更が必要
    • 新規 Issue 分割が必要
    • 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 等との active shared-file PR collision が発生
    • destructive operation が必要
    • secret/credential の開示・変更が必要
    • permission escalation / bypass が必要
    • live GitHub mutationを runtime verification として必要とする設計になる
    • nested SubAgent delegation が必要

    停止時は bypass 案を実行せず、exact blocker、確認した evidence、completed SubAgents、未完了作業、推奨 next action を報告してください。

    最終報告

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

    • tested/current main SHA
    • anchor comment URL
    • 全 SubAgent が terminal completion 済みか
    • Issue reframe の実施有無と final Issue state
    • fresh preflight / Step 2 verdict
    • implementation handoff の authority
    • implementationした場合の branch / commit / PR
    • ACごとの PASS/FAIL/SKIP
    • runtime verification evidence
    • review findings と対応
    • remaining blocker
    • merge-ready か否か

    過去のログや anchor の結論を再掲するだけではなく、current repository/GitHub state を authority とした実行結果を返してください。

    この形なら、今回のコメントを単なる「実装指示」と誤解せず、まずレビュー指摘を Issue 契約へ正規反映し、その fresh contract を実装 authority にする流れになります。特に今回の欠陥は「root commandを足せば終わり」ではなく「通常の refinement loop からその command に到達できること」が本丸なので、reframe を先に通すのが重要です。

  4. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    今回の「実装禁止条件」は、#2402 の Issue 契約から出たものではありません。実行時に与えられたオーケストレーション指示に、独自の停止条件として

    #2393 等との active shared-file PR collision が発生

    が入っています。

    そして Claude Code は、PR #2398 が SKILL.md を変更している → #2402 の reframe 後も SKILL.md を Allowed Paths に追加する必要がある → 同一ファイルなので「並行実装禁止条件」に該当、という判定をしています。

    この判定は強すぎます

    現在の #2402 本文はむしろ逆です。#2393 と skill_runtime_command_policy.py / skill_runtime_exec.py が重複することを認識しつつ、対象 profile が別なので coordination は必要だが dependency は宣言しないと明記されています。

    これはリポジトリ内の既存方針とも一致します。#2152 は、Allowed Paths の文字列重複自体は停止理由にせず、実際の Git conflict は worktree / PR 作成時に検出する、と明文化しています。 #2403 も、#2402/#2393 と skill_runtime_exec.py を共有しながら、validated edit intent が異なるので dependency にはしない、PR 作成時に line-level coordination を行う、としています。

    さらに、まさにこのための #387 scope_collision_check があります。そこでも path overlap は collision candidate にすぎず、C1 相当の「同じ path だが意味的 conflict なし」は edit_intent / non_conflict_reason の追加情報で分類する設計です。逆に predecessor が open で順序依存が明確な場合だけ wait_for_predecessor になります。

    したがって、ユーザーが今説明した基準の方が、このリポジトリで既に形成されている設計に近いです。

    私なら判定基準をこう直します

    ファイル重複は停止条件ではなく、調査トリガーにします。同じファイル・同じ行付近・同じ関数・同じ route を編集していても、最終状態が両立するなら並行作業を許可します。

    止めるのは、「同じ decision point に対して A は残す、B は消す」「同じ enum/route の意味を別々に変更する」「先行 Issue の成果物がなければ後続 Issue の実装自体を定義できない」といった semantic conflict / genuine ordering dependency が確認された場合です。

    実 Git conflict はさらに別です。これは運用上の conflict なので、ユーザーが意図している通り owner coordination の対象にはしてよいですが、Git conflict が起こり得るというだけで dependency に昇格させる必要はありません。

    そして genuine dependency と判定された場合は、ユーザーの案でよいです。つまり、実装をただ止めるのではなく、まず対象 Issue を controlled reframe して依存理由・edit intent・predecessor を本文へ反映し、GitHub native blocked by を設定して readback した後、コード実装を開始せず終了する。ちなみに現時点の #2402 の native blocked_by は空です。

    #2402について

    現時点では、PR #2398 が SKILL.md を触っているという理由だけで #2402 を止めるべきではありません。取得した #2398 の差分は Step 2 routing table 側の変更で、一方 #2402 が必要としている structural NEXT_ACTION の canonical dispatch は preflight / deterministic repair routing 側です。少なくとも現在確認できる差分から「残す vs 消す」のような semantic contradiction は確認できません。

    したがって次回は、fresh diff で edit intent を比較し、semantic conflict がなければ #2402 の controlled reframe → fresh review → implementation に進む、が妥当です。

    また、ワークフロー修正の Issue は新規起票する価値があります。#387 は collision evidence producer / issue-contract-review 最小 wiring が主目的で、#385 自身も「impl-review-loop などでの consumer wiring は別 Issue」と明記しています。 なので、新 Issue は別の collision checker を作るのではなく、consumer が C1/shared-file overlap を hard stop に誤変換しないことに限定するのがよいです。

    Claude Codeには、今のセッションを次の指示で再開させるのが適切です。

    #2402
    の作業を再開してください。

    今回の停止判断について OWNER 方針を明示します。

    「OPEN PR / Issue と Allowed Paths または変更ファイルが重複している」こと自体を implementation hard stop にしないでください。
    特に active shared-file PR collision のような、ファイル単位の重複だけを理由とする停止条件は採用しません。

    Scope Collision は次の基準で再評価してください。

    1. shared file / directory overlap は advisory evidence とする。
      ファイル名が一致するだけでは dependency / implementation prohibition にしない。

    2. current Issue と OPEN Issue/PR の actual diff、対象 symbol/function/route/section、Acceptance Criteria、Outcome、edit intent を比較する。

    3. 次のような semantic conflict がある場合だけ OWNER judgment / dependency candidate とする。

      • 同じ処理に対し、一方が残す・一方が削除するなど最終状態が両立しない
      • 同じ decision point / enum / route / schema semantics を相反する方向へ変更する
      • predecessor の成果物がなければ successor の実装内容または検証条件を確定できない
      • merge 順序によって一方の契約が無効になる
    4. 同じファイルでも別 section / 別 function / 別 profile で、双方の Outcome が同時に成立するなら並行作業を許可する。
      edit_intent と non_conflict_reason を Issue/作業記録に残し、通常どおり進める。
      将来的な軽微な rebase/merge conflict の可能性だけを dependency と解釈しない。

    5. actual Git conflict、または同一 hunk / symbol に対する競合が実際に発生した場合は、勝手に片方を捨てず OWNER coordination の対象とする。
      ただし textual conflict と semantic dependency は区別する。

    6. genuine dependency が確認された場合は、単に実装を停止して終わらない。
      先に current GitHub Issue を controlled transaction で修正し、

      • dependency の相手
      • semantic / ordering dependency の具体的根拠
      • Scope Collision Record
      • Delivery Rule / implementation start condition
        を反映する。
        その後 GitHub native Issue dependency の blocked by を設定し、Issue body と native dependency の両方を readback する。
        ここまで完了してから、その Issue のコード実装は開始せず終了する。
    7. 実装: structural_repair_action.apply を root skill runtime executor へ配線する #2402 について fresh state で PR feat: route_canonical_step2_result() に verified failure_class ベースの operator intervention route を追加する #2398、実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393、実装: preflight.run の GH_CONFIG_DIR を command-scoped に伝播する #2403 その他 relevant OPEN work を確認する。
      PR feat: route_canonical_step2_result() に verified failure_class ベースの operator intervention route を追加する #2398 が .claude/skills/issue-refinement-loop/SKILL.md を変更しているという理由だけで停止しない。
      actual diff と 実装: structural_repair_action.apply を root skill runtime executor へ配線する #2402 が追加する structural repair canonical route の edit intent を比較し、semantic conflict がなければ 実装: structural_repair_action.apply を root skill runtime executor へ配線する #2402 の controlled reframe を完了して fresh preflight / Step 2 review へ進む。

    8. 実装: structural_repair_action.apply を root skill runtime executor へ配線する #2402 の review で既に判明している contract gap、

      • .claude/skills/issue-refinement-loop/SKILL.md の Allowed Paths 追加
      • canonical apply_deterministic_structural_repair route
      • Runtime Verification Applicability の修正
      • argv/stdout/stderr/return-code および no-spawn negative verification
        を current main と fresh review に基づいて reframe する。
        reframe 後に implementation-ready なら、そのまま implementation → tests → Draft PR → review loop → merge-ready まで進める。
        merge 自体は行わない。
    9. この停止誤判定を再発させないため、既存 Issue を dedupe 調査したうえで narrow follow-up Issue を起票する。
      実装: issue-contract-review に scope_collision_check を JSON / script-first で追加する #387、実装: ssot-discovery に汎用 section retrieval evidence を追加する #385、導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860、実装: reviewer transport の command_registry.py に --validate サブコマンドを追加する #2152、実装: preflight.run の GH_CONFIG_DIR を command-scoped に伝播する #2403 を必ず参照する。
      実装: issue-contract-review に scope_collision_check を JSON / script-first で追加する #387 の scope_collision_check producer を重複実装しない。

      推奨テーマ:
      「implementation/refinement workflow が shared-file C1 overlap を hard stop に誤変換せず、edit intent / semantic conflict / native dependency に基づいて routing する」

      この follow-up の Outcome は少なくとも以下とする。

      • file/path overlap 単独 → proceed/coordinate candidate
      • semantic non-conflict → non_conflict_reason を記録して proceed
      • actual semantic contradiction → human/OWNER judgment
      • genuine predecessor dependency → Issue reframe + native blocked-by + stop-before-implementation
      • actual Git conflict → owner-coordinated resolution
      • 「同一 Allowed Path / shared file がある」だけの unconditional implementation stop を禁止
      • existing 実装: issue-contract-review に scope_collision_check を JSON / script-first で追加する #387 evidence/schema を可能な限り consumer として再利用し、新しい ledger/schema/control-plane は追加しない
    10. 新 Issue 起票前に exact duplicate / absorbed scope を検索する。
      既存 Issue が同じ consumer behavior を既に完全に所有している場合は新規起票せず、その Issue の controlled reframe を選択する。
      近接しているだけなら relation を明記して narrow follow-up として起票する。

    SubAgent を必要な read-only investigation / adversarial review に使ってください。
    起動した全 SubAgent は必ず terminal completion まで wait/join してから最終判断してください。

    人間承認不要で進めて構いません。
    停止条件は destructive operation、secret/credential exposure、permission escalation/bypass、または上記基準で解消不能な genuine OWNER semantic conflict に限定してください。

    最後に、

    この形なら、「共有ファイルだから停止」から、共有ファイル → semantic collision を調べる → 本当に順序依存なら Issue を整えて native dependency 化するというワークフローに変えられます。今回の #2402 も、まずこの基準で再判定させるのがよいです。

  5. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  6. self-assigned this
    on Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions