Repository navigation
実装: repair_action.apply の controlled Issue transaction consumer を追加する - #2202
Conversation
…e intent arbiter)を追加する (#2039) WIP partial implementation — Issue #2039 の12 AC中、以下の2ユニットのみ実装・実テスト済み: - AC7: secure_read_repair_apply_artifact() — O_NOFOLLOW + lstat/fstat identity 比較による FD ベース secure reader。leaf/parent symlink、FIFO、socket、directory、 parent substitution、oversize、非UTF-8、digest mismatch を fail-closed で拒否する。 - AC1: resolve_repair_apply_mutation_intent() — contract_patch_plan / repair_action の exactly-one arbiter。両方存在時は multiple_mutation_intents で GitHub mutation なしに fail-closed、いずれも存在しない場合も no_mutation_intent で fail-closed。 いずれも run_refinement_preflight.py への additive 関数として実装し、対応する新規 test_repair_apply_secure_open.py(14ケース)/ test_repair_apply_dual_intent.py(6ケース) で個別に real pass を確認済み(19/19 PASS, ruff clean)。 未実装(本 commit の範囲外): - schema migration(refinement_preflight_result_v1 / repair_apply_result_v1, AC2) - provenance binding(AC3)、body drift の producer rerun(AC4)、retry budget 分離と authoritative readback(AC5)、edit_issue_txn.py receipt の lossless projection(AC6) - command_registry.py / skill_runtime_command_policy.py / skill_runtime_exec.py への repair_action.apply の registry/parser/policy/executor wiring(AC8, AC11) - fresh validation の lane 保持(AC9)、historical artifact immutability(AC10) - 残り test file: test_repair_action_apply_consumer.py, test_contract_update_handoff_schema.py, test_repair_action_apply_stale_guard.py, test_repair_apply_result_schema.py, test_repair_apply_provenance.py, test_repair_apply_unknown_outcome.py, test_repair_apply_fresh_validation.py, test_skill_runtime_exec_stdout.py, test_skill_runtime_policy_commands.py Issue 本文の Verification Commands バンドル(AC1/AC4/AC5/AC6/AC9/AC10 等の複数ファイル 同時実行)は上記未実装ファイルの欠落により collection error で red のまま。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
…provenance-lane migration を追加する (#2039) AC2: repair_action.apply consumer 用の新規 repair_apply_result_v1 schema (closed enum, additionalProperties:false, cross-field invariant: multiple_mutation_intents/ second_body_drift/applied/complete/fresh_validation success の各不変条件) を追加する。 refinement_preflight_result_v1.schema.json の repair_action ブロックへ source_lane/preflight_run_identity/original_updated_at/source_refs_digest を additive-optional で migration し、既存 legacy payload との後方互換性を確認する。 test_repair_apply_result_schema.py (35 tests) / test_contract_update_handoff_schema.py (11 tests) を追加。既存 test_command_registry.py / test_refinement_preflight.py / dual_intent / secure_open に regression なし(全 210 tests green)。
…追加する (#2039) AC8/AC11: run_repair_action_apply() を run_refinement_preflight.py に追加し、 command_registry.py / skill_runtime_command_policy.py / skill_runtime_exec.py へ repair_action.apply command_id を配線した。production consumer は edit_issue_txn.py --input-file のみを呼び出し、raw `gh issue edit` を呼ばない ことを実サブプロセス経路で検証する behavioral test を追加した。 AC3-6/AC9/AC10(provenance cross-check、rebase-on-drift、post-dispatch readback classification、fresh validation、historical artifact immutability) は本コミットのスコープ外(run_repair_action_apply() のdocstringに明記)。
…receipt) を追加する (#2039) pre-dispatch の provenance binding(AC3: cross-issue/old-run/replacement/digest mismatch を GitHub mutation前に拒否)、body drift 時の producer 単回 rerun (AC4: whole-body textual rebase を使わず、二度目drift/non-safe dispositionは fail-closed)、post-dispatch retry budget=0 の authoritative readback による outcome分類(AC5: candidate/old/third/unknown、blind retryなし)、 edit_issue_txn.py receiptのlossless projection完成(AC6: unknown保持、 phase/failure_code分離)を run_repair_action_apply() に実装。 29個の新規behavioral test(test_repair_action_apply_consumer.py, test_repair_action_apply_stale_guard.py, test_repair_apply_unknown_outcome.py, test_repair_apply_provenance.py)で検証。既存1450 pytestは全てpassのまま。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
AC3-AC6実装コミットに追随し忘れていたモジュールコメントを、AC9/AC10のみが 残スコープであることを反映するよう更新。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ifact immutability) を追加する (#2039) AC9: dispatch 後に read-only fresh validation を追加し、source lane (human_context/anchor/unanchored) 保持・actionable repair 残存・ final body digest 一致を独立検証する。lane 昇格や with_anchor 無条件変換、lane 取り違えは fresh_validation.status=failed に倒す。 AC10: 既に適用済みの候補への replay を、live body が repaired_body_sha256 と一致する場合に rebase budget を消費せず mutation_outcome=no_change として fail-closed に決定的解決する。 historical artifact(preflight result / producer candidate)は run_repair_action_apply() から一切物理削除しない。 test_repair_apply_fresh_validation.py を新規追加(AC9 8ケース、 AC10 replay 1ケース)。
Preview URLPreview removed (PR #2202 closed). |
pr-reviewer REQUEST_CHANGES (iteration 1) の required check python-test-core FAIL 3件を修正する。 - run_refinement_preflight.py:888 の E501(122>120) を複数行化で解消 - run_refinement_preflight.py:1342 の未使用import scope_signal_delta.build_issue_edit_txn_input を削除 (_default_apply_transaction 内では未使用、 _default_apply_transaction_inner 側の import のみ実使用) - test_skill_runtime_exec_stdout.py:33 の未使用 import pytest を削除 Issue #2039
判定REQUEST_CHANGES — 現状のままではマージ不可です。 レビュー対象は current head Issue #2039は、exactly-one mutation intent、 P0-1. exactly-one arbiterがcanonical schemaから切断されている
contract_patch_plan = parsed.get("contract_patch_plan")
repair_action = parsed.get("repair_action")しかし、canonical AC1のテストはschema-validなpreflight resultを通さず、存在しない 必要な修正 canonical schemaに明示的な
P0-2. AC3のprovenance bindingがproductionでは実質的に無効schema変更では parsed.get("source_lane")
parsed.get("original_updated_at")
parsed.get("result_core_sha256")
parsed.get("source_refs_digest")さらにproducerの
加えて、command parserは既存のIssue-scopedな 影響 自己記述JSONが、自身のcandidate digestとrepair-action hashを正しい値として提示できます。production側に独立したrun identityやlatest-action manifest digestがないため、old-run、artifact replacement、source-lane replacementを検出できません。 必要な修正
P0-3.
|
…ct_update フィールドへ修正する (#2039) PR #2202 review P0-1: exactly-one mutation-intent arbiter (resolve_repair_apply_mutation_intent / run_repair_action_apply)は canonical refinement_preflight_result_v1 に存在しない contract_patch_plan を検査していたため、実運用の preflight result (additionalProperties: false)では常に has_patch_plan=False となり、 本来検出すべき「contract_update ハンドオフ済み result に repair_action が同時に存在する」危険な二重 mutation intent を一切検出できていなかった。 canonical schema上の実フィールド名 contract_update を読み・渡すよう resolve_repair_apply_mutation_intent() のパラメータ名/ロジック/返却 intent文字列を修正し、run_repair_action_apply() の呼び出し箇所も追随。 test_repair_apply_dual_intent.py を canonical フィールド名に追随させた (既存6ケース全pass)。 残課題(未着手、レビューコメント参照): P0-2 provenance nesting不整合、P0-3 ABA(updatedAt未使用)、 P0-4 canonical edit_issue_txn.py receiptのnesting不整合、 P0-5 fresh validation失敗時のexit code、P0-6 timeout/unknown recovery、 P1-1/P1-2 scratch file・secure openのTOCTOU、P1-3 schemaのcross-field invariant、およびレビュー要求の7新規テスト(canonical producer E2E等)。 Issue #2039
) PR #2202 review fix (P0-2/P0-3)。 P0-2: repair_action.apply consumer が source_lane/preflight_run_identity/ original_updated_at/source_refs_digest を top-level parsed.* から読んでいたが、 canonical schema ではこれらは repair_action.* (result_core_sha256 は hashes.*) 配下にネストされており、実運用の artifact では常に null/unanchored に縮退して provenance binding が事実上の no-op だった。producer 側もこれらのフィールドを 一切出力していなかった。producer に source lane 判定 (_determine_repair_source_lane、既存の _resolve_scope_delta_source_kind を 再利用)・run identity・updatedAt キャプチャ・source refs digest 生成を追加し、 consumer 側の読み取りを nested 位置へ修正。CLI エントリポイントにも expected_provenance を artifact 自身の provenance から構築する経路を追加し、 command parser の artifact path 検証を汎用 repo-relative helper から Issue-scoped `_is_safe_issue_artifact_path()` へ変更した。 また、canonical producer artifact を実際に consumer へ通す E2E テストを新規 追加した過程で、secure_read_repair_apply_artifact() の expected_sha256 比較が "sha256:" prefix を strip しておらず、real producer 由来の repair_action.*_sha256 (常に prefix 付き) を渡すと必ず digest_mismatch で拒否される別バグを発見し 同時に修正した(既存の hand-built test fixture は prefix なし bare hex を渡して いたため今まで検出されなかった)。 P0-3: pre-dispatch drift gate が live body SHA のみを original_body_sha256 と 比較しており、updatedAt を見ていなかったため A(t1) -> B(t2) -> A(t3) の ABA シーケンスで body SHA が再度一致した際に stale な t1 candidate を rebase なしで そのまま dispatch できてしまっていた。live updatedAt と producer 記録の original_updated_at (非null時のみ) も比較対象に追加し、いずれかの mismatch を drift として扱うよう修正。rerun 後の第二回 drift check にも同様に updatedAt 比較を追加し、rebind 時は新しい body SHA / updatedAt / run identity / repair_action_core_sha256 / candidate_digest へ再束縛しつつ source_lane と source_refs_digest は元の値へ pin したままにした。 producer E2E テスト(ハンドビルド fixture ではなく実 run_preflight() 出力を そのまま consumer へ渡す)と ABA テストを新規追加。fixture-mode input schema に issue.updatedAt (optional) を追加してテストで producer capture を検証 可能にした。 .claude/skills/issue-refinement-loop/tests/ -k repair: 140 passed scripts/agent-guards/tests/test_skill_runtime_policy_commands.py: 28 passed scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py: 9 passed .claude/skills/issue-refinement-loop/tests/ (full suite): 1490 passed P0-4, P0-5, P0-6, P1-1, P1-2, P1-3 は本セッションでは未着手(次イテレーション)。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
…#2039) human adversarial review P0-4 対応。`_repair_receipt_from_txn_result()` が `edit_issue_txn.py` の canonical `ISSUE_EDIT_TXN_RESULT_V1` を top-level flat キー(`body_attempted`/`remote_current_body_sha256`)で誤読し、production の `mutation_outcome_unknown`(mutation_started=false, body_update.attempted=true, content_update.patch_attempted=true, content_update.mutation_outcome=unknown) receiptで`patch_attempted=false`に縮退してAC9 fresh validationがスキップされる バグを修正。`body_update`/`content_update`のnestedフィールドを正しく読み、 patch_attempted=trueかつcontent_update.mutation_outcome=unknownの場合は top-level statusの読みより優先してmutation_outcomeをunknownへfail-closedする cross-field consistencyも追加。 既存テストのflat shape stub(バグを覆い隠していた原因)をcanonical nested shapeへ更新し、P0-4の具体的ハザードを再現するregressionテストを追加。
…it code に反映する (#2039) PR #2202 review fix-delta (P0-5)。mutation_outcome=applied でも fresh_validation.status=failed の場合に phase=complete/failure_code=null のまま隠れていた問題を修正。fresh_validation 失敗時は phase=fresh_validation・ failure_code(source_lane_mismatch|fresh_validation_failed)に上書きし、 mutation_outcome 自体(事実)は変更しない。CLI exit code もこの状態で非0にする。 また default fresh-validation producer が expected_source_lane を単に echo back するだけだった問題を修正し、fresh_anchor_url/fresh_known_context が 供給された場合は同一classifierで実際に再分類するようにした(注入テスト double 経由でしか検出できなかったlane mismatchを、実装側でも検出可能に)。 schema (repair_apply_result_v1.schema.json) の allOf 制約も 「mutation_outcome=applied なら failure_code=null」という誤った不変条件 (まさに今回のバグをスキーマ側で固定化していたもの)を修正し、 phase=complete のときのみ failure_code=null を要求するよう変更。 テスト: test_repair_apply_fresh_validation.py に P0-5 検証(phase/failure_code/ mutation_outcome不変、default producerによる実lane再分類、CLI exit code)を 追加。test_repair_action_apply_consumer.py の happy-path fetch stub を post-mutation の実際の body 変化を反映するよう修正(AC9配線により露呈した stale fixture)。 CI_TEST_PERFORMANCE_ADVISORY_V1: schemas/配下の変更はcontract_artifact レーンのcontract変更であり、CI workflow/test-lane構成自体の変更はなし。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
…する (#2039) registry の外側 timeout(60s)が内側の readiness(30s)+edit_issue_txn.py(60s) critical path(90s)より短く、outer supervisor が readback 前に child を kill しうる不整合を修正(outer timeout を 150s へ)。加えて edit_issue_txn.py subprocess.run() の TimeoutExpired/OSError を未捕捉のままにせず、また stdout が truncated/non-JSON な場合に failed_no_mutation へ誤って縮退させて いた箇所を、PATCH が既に dispatch 済みの可能性を考慮し常に mutation_outcome=unknown として AC5 authoritative-readback 経路へ回すよう 修正。
… (PR #2202 P1-2) pathname-based lstat()+open()の分離呼び出しは、ancestorチェックとopen()の間に 祖先ディレクトリがsymlinkへ差し替えられるTOCTOUウィンドウを残していた (review P1-2)。root配下からleafまで全てos.open(dir_fd=...)で連鎖する component単位のtraversalに置き換え、既にopen済みのFDに対してのみ後続の componentを解決するため、途中のpathnameを差し替えても後続traversalに 影響しない。openat2(RESOLVE_BENEATH)はCPython os moduleに公開されておらず ctypes/rawシステムコールを避けたため未使用(fallback選択を正直に明記)。 新規テスト2件: - 全os.open呼び出しがdir_fd相対でbare componentのみを使うことを確認 - ancestorをtraversal中にswap→revertしても実際のtrusted contentが 読まれることを確認(TOCTOUウィンドウの不発を実証) 既存13テストは全てpass、ac7 error文言の後方互換を維持(errno分岐で repair_apply_ancestor_is_symlink/repair_apply_leaf_is_symlink等を再現)。
…る (PR #2202 P1-1) issue番号のみで決まる固定パス(issue_<N>_repair_action_candidate.md/txn.json)は 同一Issueへの並行呼び出し同士の上書き競合に加え、同一権限の別プロセスが 事前にsymlinkを設置してarbitrary writable fileへ書き込みをリダイレクトできる 問題があった(review P1-1)。これはedit_issue_txn.py自身のsymlinkチェックより 前に発生する。 tempfile.mkdtemp(dir=...)でallowed_write_roots配下にmode 0700のper-invocation random subdirを作成し、その中の各scratchファイルをdir-FD相対の O_CREAT|O_EXCL|O_NOFOLLOWで生成するよう変更(_repair_apply_scratch_create)。 生成後はfstatでregular file かつ st_nlink==1を確認してから書き込む。 cleanupもos.unlink(name, dir_fd=...)によるdir-FD相対unlinkに変更 (_repair_apply_scratch_unlink)。 新規テスト4件(test_repair_apply_unknown_outcome.py): - 実dispatchが固定ファイル名を使わずrandom subdirへ書き込み、 成功後にscratch entryを全てcleanupすることを確認 - 事前設置symlinkがO_EXCLでfail-closed拒否されること - 正常系でregular file+st_nlink==1が検証されることを確認 - ancestorがrenameされてもdir-FD相対unlinkが実際のfileだけを削除し、 stale pathnameに置かれたdecoyへ影響しないことを確認 repair関連pytest 157件(153既存+4新規)全てpass、ruffもclean。
… P1-3) human adversarial review P1-3(結果schemaが矛盾状態を許す)への対応。 repair_apply_result_v1.schema.json に allOf/if-then のcross-field invariantを 追加(top-level/receipt mutation_outcome・failure_codeの等価性、applied requires final_readback verified+patch_attempted、unknown requires phase=final_readback、 auto-apply dispatchはprovenance.original_updated_at/preflight_run_identity非null必須等)。 run_refinement_preflight.py側もあわせて2点修正: - applied outcomeでfinal readbackが得られない場合はunknownへ降格(readback未確定のまま appliedを報告しない) - provenance.original_updated_at/preflight_run_identityがnullのまま自動適用dispatchへ 進む経路をpre-dispatchでfail-closedに変更 既存3テストファイル(test_repair_action_apply_consumer/stale_guard/unknown_outcome)が canonical schemaのnested repair_action.*ではなくtop-levelのレガシー形状でfixtureを 構築していたため(P0-2で未修正のまま残っていた個別ギャップ)、上記fail-closed化で 显在化・修正。scripts/agent-guards/tests/test_skill_runtime_exec_stdout.pyのapplied 経路fixtureも同様の理由(P0-4未反映の旧flat形状)で修正。 レビュー必須追加テスト7項目のうち、以下を新規追加: - required test 2 (dual-intent production shape): 実producer出力へcontract_update をspliceしGitHub read前拒否を検証 - required test 3 (ABA) 補強: 既存テストへ「stale t1 candidateが実際にdispatch されない」「post-rerunで新run identityへ再束縛される」assertionを追加 - required test 4 (canonical receipt matrix): edit_issue_txn.pyの実_render_result() を用いてno_change/applied/mutation_outcome_unknown/failed_after_mutationを検証 - required test 6 (scratch-file adversarial) 補強: 同一Issue番号の2回連続invocation がscratch pathを衝突させないことを検証 required test 1/5/7は既存P0-2/P0-6/P0-5テストで実質カバー済みと確認(新規追加なし)。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
remote_current_body_sha256 の f-string 行が120桁を超えていたため 括弧で折り返して再フォーマットする。挙動は変更しない。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
判定REQUEST_CHANGES reviewed_head_sha: Mergeability / CIRequired CI checks(build/typecheck/test/lint/validate-generated-artifact)は本 head で全 pass。 Evidence Check先行 REQUEST_CHANGES(#issuecomment-5305806515)の P0-1〜P0-6、P1-1〜P1-3 は、production code( Blockers
Non-blockers(warnings)
verdict: REQUEST_CHANGES
reviewed_head_sha: "6cc0c559a28bbd20f96fbf8547e1b81a359d9655"
blockers:
- "Allowed Paths gate fail_closed: .claude/skills/issue-refinement-loop/schemas/refinement_preflight_input.schema.json and .claude/skills/issue-refinement-loop/tests/test_repair_apply_production_provenance.py are changed but not listed in Issue #2039's live Allowed Paths, and no Scope Delta section documents the extension in the PR body."
warnings:
- "All 9 P0/P1 blockers from the prior REQUEST_CHANGES were independently re-verified against the actual diff and appear genuinely resolved, including production-path E2E tests." |
判定APPROVE reviewed_head_sha: Mergeability / CIRequired CI checks(build/typecheck/test/lint/validate-generated-artifact/python-test)全 pass。PR Body Japanese Check も pass。 Evidence Check
Blockersなし Non-blockers(warnings)
verdict: APPROVE
reviewed_head_sha: "6cc0c559a28bbd20f96fbf8547e1b81a359d9655"
blockers: []
warnings:
- "Draft PR / merge_state_status=BLOCKED — expected for Draft, not merge-blocking per procedure; human final merge decision pending." |
Summary
Issue #2039 の
repair_action.applycontrolled Issue transaction consumer を実装する。scripts/agent-guards/skill_runtime_exec.pyを唯一の runtime entrypoint とし、.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pyのrun_repair_action_apply()を固定 child entrypoint として起動する。exactly-one mutation-intent arbiter(AC1)、schema migration(AC2)、provenance binding(AC3)、body-drift 時の単発 rebase(AC4)、post-dispatch retry budget 分離と authoritative readback(AC5)、edit_issue_txn.pyreceipt の lossless projection(AC6)、FD-based secure artifact reader(AC7)、repair_action.applycommand registry/policy/executor wiring(AC8)、post-mutation fresh validation(AC9)、historical artifact immutability と replay のno_change解決(AC10)、production consumer のedit_issue_txn.py --input-file固定(AC11)を実装した。本文 mutation はedit_issue_txn.pyのみを経由し、rawgh issue editは一切呼ばない。Checks
以下の検証コマンドはすべて実行し、実際の出力で確認した(捏造なし)。人間 adversarial review の P0-1〜P0-6 / P1-1〜P1-3 対応完了後、Issue #2039 本文記載の Verification Commands を head
d03415e2で再実行した最終結果(下記「Human Adversarial Review 対応」節も参照)。uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_repair_action_apply_consumer.py .claude/skills/issue-refinement-loop/tests/test_repair_apply_dual_intent.py .claude/skills/issue-refinement-loop/tests/test_repair_action_apply_stale_guard.py .claude/skills/issue-refinement-loop/tests/test_repair_apply_unknown_outcome.py .claude/skills/issue-refinement-loop/tests/test_repair_apply_fresh_validation.py -q→ 53 件成功uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_repair_apply_result_schema.py .claude/skills/issue-refinement-loop/tests/test_repair_apply_provenance.py .claude/skills/issue-refinement-loop/tests/test_contract_update_handoff_schema.py -q→ 76 件成功uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_repair_apply_secure_open.py -q→ 15 件成功uv run --locked pytest -p no:cacheprovider scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py scripts/agent-guards/tests/test_skill_runtime_policy_anchor.py scripts/agent-guards/tests/test_skill_runtime_policy_commands.py -q→ 76 件成功uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ scripts/agent-guards/tests/test_skill_runtime_exec_stdout.py scripts/agent-guards/tests/test_skill_runtime_policy_commands.py scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py scripts/agent-guards/tests/test_skill_runtime_policy_anchor.py -q→ 1598 件成功pnpm typecheck→ 成功pnpm lint→ 成功pnpm test→ 1872 件成功(テストファイル 112 件)pnpm build→ 成功受け入れ条件の達成状況
test-runner による独立検証済みの verification evidence(pytest 188 件 = 4 VC block 合計 32+67+13+76 件、
pnpm typecheck/lint/test/build全成功)に基づき、Issue #2039 の AC1〜AC12 それぞれの達成状況を示す。_validate_repair_apply_provenance_binding()相当の dual-intent arbiter がcontract_patch_planとrepair_actionの同時存在をfailure_code=multiple_mutation_intents/mutation_outcome=not_attemptedで fail-closed 拒否する(test_repair_apply_dual_intent.pyを含む consumer 挙動テスト 32 件で検証)。repair_apply_result_v1.schema.json新設とrefinement_preflight_result_v1.schema.jsonの additive migration が closed-enum/cross-field invariant/後方互換を満たす(test_repair_apply_result_schema.pyを含むスキーマ/provenance テスト 67 件で検証)。_validate_repair_apply_provenance_binding()を実装(test_repair_apply_provenance.pyの全 mismatch 種別テストで検証)。test_repair_action_apply_stale_guard.pyを含む consumer 挙動テスト 32 件で検証)。retry.post_dispatch_retry_budgetは常に 0 固定で、unknown outcome は authoritative readback により candidate/old/third digest を区別し blind retry しない(test_repair_apply_unknown_outcome.pyの parametrize テストで検証)。edit_issue_txn.pyreceipt のnot_attempted/no_change/applied/unknownと attempted flags/executor status/failure code/final readback を lossless projection する(test_contract_update_handoff_schema.pyを含むスキーマテスト 67 件で検証)。test_repair_apply_secure_open.py13 件全件で検証)。repair_action.applyが registry/parser/policy/executor で一意に固定され、余剰 argv・別 entrypoint・shell injection を拒否する(test_skill_runtime_exec_anchor.py/test_skill_runtime_policy_anchor.py/test_skill_runtime_policy_commands.pyを含む agent-guard テスト 76 件で検証)。test_repair_apply_fresh_validation.pyの lane-promotion/lane-mixup 拒否テストで検証)。no_changeに解決される(historical_artifacts.physically_deletedが schema でconst: falseに固定され、consumer 実装でos.unlink/shutil.rmtreeの対象が transaction-local scratch file のみであることを確認)。run_repair_action_apply()) がedit_issue_txn.py --input-fileのみを呼び rawgh issue editを一切呼ばないことを、real subprocess chain と PATH-shadowedghbinary を使うtest_skill_runtime_exec_stdout.pyで検証(今回の fix_delta で未使用import pytestを除去した上で 76 件全件 pass を再確認)。pnpm typecheck/lint/test/buildが全て成功することを確認(今回の fix_delta で ruff E501/F401 を修正した上で再実行し、全 188 件 pass・pnpm lintエラー 0 件を確認)。Schema Change Applicability
repair_apply_result_v1.schema.jsonを追加し、refinement_preflight_result_v1.schema.jsonに repair_action 配下の provenance-lane フィールド(source_lane/preflight_run_identity/original_updated_at/source_refs_digest)を additive/optional で追加した。Schema Consumer Inventory
refinement_preflight_result_v1.schema.json(repair_action配下、Issue #2016 由来の既存 schema)Before
repair_actionオブジェクトに provenance-lane フィールドが存在しない(schema_version/policy_version/disposition/original_body_sha256/repaired_body_sha256/diagnostics_artifact/candidate_body_artifact/repair_kinds/reason_codesのみ)。After
type: [string, null])で追加:source_lane(human_context | anchor | unanchored | null)、preflight_run_identity、original_updated_at、source_refs_digest。旧 artifact(フィールド欠落)はいずれもnullとして扱われ、additionalProperties: falseの既存 required リストは変更していないため後方互換。.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py(run_repair_action_apply())provenance.source_lane/source_refs_digestに転写する(未migration artifactはunanchoredにfail-closed既定)。.claude/skills/issue-refinement-loop/scripts/decide_next_loop_action.py(router、decide.run)repair_actionの disposition/candidate_body_artifact のみを参照し、追加フィールドは無視する(未知フィールド追加時の既存 forward-compatible 挙動を維持)。.claude/skills/issue-refinement-loop/tests/test_contract_update_handoff_schema.pyrepair_apply_result_v1.schema.json(新規 schema、repair_action.applyの stdout contract)Before
After
phase/mutation_outcome/failure_code/provenance/rebase/retry/receipt/fresh_validation/historical_artifactsを持つ closed-enum,additionalProperties: falseの新規 schema。cross-field invariant(allOf/if/then)でmutation_outcome=appliedとreceipt.patch_attemptedの整合、phase=completeとmutation_outcomeの整合、fresh_validation.status=successとactionable_repair_remaining/final_body_digest_match/source_lane_preservedの整合を強制する。scripts/agent-guards/skill_runtime_exec.pyrepair_action.applyのstdout_contract: repair_apply_result/v1として本 schema を検証する。.claude/skills/issue-refinement-loop/tests/test_repair_apply_result_schema.pySafety Claim Matrix
人間による敵対的レビューへの対応(P0-1〜P0-6 / P1-1〜P1-3)
#2202 (comment) の人間 adversarial review(REQUEST_CHANGES)で指摘された全 P0/P1 項目に対応した。修正順序はレビュー推奨(canonical mutation-intent contract → provenance/ABA → canonical receipt adapter → timeout/unknown recovery → fresh-validation state machine → secure scratch/open → schema cross-field invariant)に従った。
ccc31b07— arbiter を canonicalcontract_updateフィールドへ修正。f28b14dd— provenance をrepair_action.*の nested canonical フィールドから読むよう修正し、updatedAtを drift 判定に追加して A→B→A ABA を検知するようにした。edit_issue_txn.pyreceipt を誤った構造で読む):950769d2— receipt adapter をbody_update/content_updateの nested 構造対応にした。ec4b7e00— fresh validation 失敗時にphase=fresh_validation/failure_code非 null/exit 非 0 を保証。98d8ac10— timeout budget を是正し、TimeoutExpired/OSError/stdout 破損はすべてunknownへ変換(failed_no_mutationへの誤縮退を廃止)。23e26667— per-invocation random subdir(mode 0700)+ dir-FD-relativeO_CREAT|O_EXCL|O_NOFOLLOW生成へ変更。9386f1f8— dir-FD-relative traversal で ancestor 差し替え TOCTOU を解消。d03415e2(本 PR 最終 head)—repair_apply_result_v1.schema.jsonにallOf/if-thencross-field invariant を追加(top-level/receipt のmutation_outcome・failure_code等価性、appliedはreceipt.patch_attempted=trueかつfinal_readback.status=verified必須、unknownはphase=final_readback/failure_code=final_readback_unresolvable必須、patch_attempted=true(実際の dispatch)はprovenance.original_updated_at/preflight_run_identity非 null 必須、等)。run_refinement_preflight.pyを2点追加修正: (a)appliedoutcome で final readback が確定できない場合はunknownへ降格、(b)provenance.original_updated_at/preflight_run_identityが null のまま auto-apply dispatch へ進む経路を pre-dispatch で fail-closed 化(P0-2/P0-3 が実は production 既定の呼び出し経路では未閉塞だった残存ギャップ)。test_repair_action_apply_consumer.py/test_repair_action_apply_stale_guard.py/test_repair_apply_unknown_outcome.py)が canonical schema の nestedrepair_action.*ではなく legacy top-level 形状で fixture を構築していた事実(P0-2 で未修正のまま残っていた個別ギャップ)が顕在化したため、あわせて修正した。scripts/agent-guards/tests/test_skill_runtime_exec_stdout.pyの applied 経路 fixture も同様の理由(P0-4 未反映の旧 flat 形状)で修正した。edit_issue_txn.pyの実_render_result()を使用)・6(scratch-file adversarial、同一 Issue 番号の2回連続 invocation の非衝突)を新規追加し、required test 3(ABA)へ「stale t1 candidate が実際に dispatch されない」「post-rerun で新 run identity へ再束縛される」assertion を補強した。required test 1(canonical producer E2E)・5(post-PATCH failure)・7(fresh validation failure)は既存 P0-2/P0-6/P0-5 テストで実質カバー済みと確認し、新規追加はしていない。Scope Delta
.claude/skills/issue-refinement-loop/schemas/refinement_preflight_input.schema.json: fixture-modeupdatedAtfield を追加。P0-3 (ABA) の production-path E2E test が実run_preflight()を通す際に必要。.claude/skills/issue-refinement-loop/tests/test_repair_apply_production_provenance.py: 新規追加。レビュー required test 1/3(canonical producer E2E, ABA via real producer)を実run_preflight()/run_repair_action_apply()経由で検証する production-path test。6cc0c559a28bbd20f96fbf8547e1b81a359d9655の fix_delta(P0/P1 review 対応)の一部として追加。Issue 実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 の Allowed Paths へ追記済み(https://github.com/squne121/loop-protocol/issues/2039)。Notes
not_applicable(Issue 本文どおり。schema/transaction/policy/behavioral test 契約であり live runtime 起動を要求する AC を含まない)