Skip to content

fix(refinement): trusted anchor iteration-zero を実装 (#1877) - #1884

Merged
squne121 merged 13 commits into
mainfrom
worktree-issue-1877-trusted-anchor-iteration-zero
Aug 1, 2026
Merged

squne121 merged 13 commits into
mainfrom
worktree-issue-1877-trusted-anchor-iteration-zero

Conversation

@squne121

@squne121 squne121 commented Jul 31, 2026 •

Copy link
Copy Markdown
Owner

概要(Summary)

  • preflight.run.with_anchor を read-only のまま維持し、main control-plane専用の contract_update.run.with_anchor を追加しました。
  • canonical registry → strict policy → privileged executor → contract-update phase →既存 ISSUE_EDIT_TXN_INPUT_V1 transaction → final readback → fresh preflight/review/readiness handoff を接続します。
  • consumerの候補本文・raw anchor・transaction payloadはtransaction-localに留め、既存 refinement_preflight_result/v1 にboundedな任意 contract_update handoffだけを追加します。

関連Issue: Closes #1877

canonical二段階経路

preflight.run.with_anchor (github_read_only, mutation:false)
  -> planner-produced CONTRACT_PATCH_PLAN_V1
  -> contract_update.run.with_anchor (main control-plane only, mutation:true)
  -> candidate static readiness
  -> existing edit_issue_txn.py
  -> final readback
  -> fresh preflight / review / readiness input

preflight.run.with_anchor のargvには --consume-contract-patch-plan を追加していません。

受け入れ条件の達成状況

以下の表は、各受け入れ条件について実行したテスト名と結果を対応付けるものです。英字のテスト識別子は実行対象を一意に示すため原文のまま保持し、判定内容は日本語で記載します。

AC 状態 current-headでの日本語要約と証跡
AC1 [x] 初回anchor検証: test_classifies_trusted_anchor_without_prior_snapshot (1 PASS)
AC2 [x] bootstrap境界: test_bootstrap_lane_does_not_use_prepatch_human_judgment_as_go (1 PASS)
AC3 [x] patch-plan消費とprocess E2E: 1 PASS / 6 PASS
AC4 [x] section-aware desired state: 1 PASS
AC5 [x] fixture golden hashと非対象文脈: 1 PASS
AC6 [x] 一回だけのrebaseとprocess E2E: 1 PASS / 6 PASS
AC7 [x] 独立state表現: 1 PASS
AC8 [x] replay時のno-change/write 0: 1 PASS
AC9 [x] trust/security fail-closed: 1 PASS
AC10 [x] final readback/fresh checksとprocess E2E: 1 PASS / 6 PASS
AC11 [x] 既存scope回帰: test_scope_delta_authority.py (32 PASS)
AC12 [x] current-main path制約: 1 PASS

変更ファイル(current head)

次の一覧は gh pr diff --name-only のcurrent-head readbackをそのまま転記したものです。既存のtrusted-anchor実装に必要な範囲だけを変更しています。

# 以下はskill定義、既存result schema、phase実装、fixture、policy、executor、境界テストの順です。
.claude/skills/issue-refinement-loop/SKILL.md
.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json
.claude/skills/issue-refinement-loop/scripts/command_registry.py
.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
.claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py
.claude/skills/issue-refinement-loop/tests/fixtures/issue_1835_trusted_anchor_iteration_zero.json
.claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
.claude/skills/issue-refinement-loop/tests/test_trusted_anchor_iteration_zero.py
scripts/agent-guards/skill_runtime_command_policy.py
scripts/agent-guards/skill_runtime_exec.py
scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py

Allowed Paths 遵守

live #1877本文を正本として allowed_paths_review_gate.py をcurrent headに対して実行しました。git_diff_name_status_find_renames_z で13ファイルを監査し、rename provenanceを含めて status: ok、違反なしです。

検証コマンド結果

ローカル検証は、契約に記載された各ACのselector、registryとexecutorをまたぐprocess-boundary E2E、関連回帰、静的解析、差分検査の順に実施しました。外部GitHub Issueをテストから変更していません。

  • focused trusted-anchor / command-policy / executor tests(6be9eb6…): 58 PASS(対象機能)
  • production wrapper process-boundary E2E(6be9eb6…): 3 PASS。これは実production経路を安全に通す検証です。registry → policy → executor → production wrapper → strict transaction helper → fake外部gh → final/fresh inputs と、通常preflightの非mutation・replay no_change / write 0を確認。
  • Issue 実装: 修正: iteration 0 の trusted anchor を body-delta 非依存で contract update へ routing する #1877 AC commands: current-head関連suiteでPASS。
  • related regression(6be9eb6…): 2287 passed、1 skipped、1 deselected。
  • Ruffとsyntax verificationとgit diff --check: PASS
  • current-head CI(6be9eb6b33a42053d035f81ea525af01946be4e9): required checksはすべてPASSです。e2e、python-test-core、test、lint、build、typecheck、codex-execpolicy、deploy-pr、ci-verdict-summaryを確認しました。

Schema Change Applicability

schema_changeです。新しいschema familyではなく、既存結果schemaの任意fieldだけを追加し、親orchestratorが最終readbackとfresh checksの状態を安全に受け取れるようにします。

  • 既存schemaへの狭いadditive extensionだけ: refinement_preflight_result/v1 にboundedな任意 contract_update routing fieldsを追加します。
  • 新しいschema version、artifact family、receipt、publisher、digest family、reason-code enum、persistent state storeは追加しません。

Schema Consumer Inventory

consumer compatibility decision evidence
run_refinement_preflight.py producer 既存v1の任意fieldなので既存preflight出力と互換 test_bounded_contract_update_handoff_retains_only_parent_routing_fields
skill_runtime_exec.py stdout projection contract_update.run.with_anchorだけがbounded fieldを返し、通常preflightは従来どおり test_contract_update_phase_cannot_be_reached_through_preflight_command
route_after_rewrite.py と既存v1 consumers field未参照でも追加任意fieldを許容し互換 existing refinement_preflight_result/v1 schema compatibility tests

Compatibility Decision: additive / backward-compatible。未対応consumerはありません。

安全性主張の対応表

各安全性主張は、実行経路の分離、厳格なcontext binding、再実行時の書込み抑止を個別に確認するテストへ対応付けています。read-only preflightをmutation laneへ変換する変更はありません。

Claim Implemented Not controlled Evidence Follow-up
preflightはread-onlyを維持 はい なし registry invariant + executor regression なし
mutation phaseはroot/default-branch/repo/anchorに固定 はい なし strict parser/policy tests なし
新phaseだけがtransactionに到達 はい なし separate fake transaction process E2E なし
body driftは最大一回rebase はい なし AC6 test なし
replayはwrite 0 はい なし AC8 + process E2E replay なし
Issue metadataは対象Issueだけに限定許可 はい なし exact executor test なし

スコープとdelivery

このPRはDraftのままです。レビューとCIのcurrent-head証跡を確認するまではready化・自動マージ・マージを行いません。

@squne121

Copy link
Copy Markdown
Owner Author

Overlap Preflight Warnings(advisory, #1851)

overlap preflight evidence の検証で以下の warning が検出されましたが、advisory telemetry のため PR 作成はブロックされていません。

  • E_OVERLAP_PREFLIGHT_EVIDENCE_MISSING: evidence_file が存在しないか読み込めません: None

@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1884 closed).

@squne121
squne121 force-pushed the worktree-issue-1877-trusted-anchor-iteration-zero branch from 5bd95f9 to 289f3c9 Compare July 31, 2026 15:56
@squne121

Copy link
Copy Markdown
Owner Author

現在の停止理由(判断依頼)

これは無効compactの再発でも、Issue内容についての人間判断待ちでもありません。Issue #1877 の本文rewriteとfresh reviewは完了しており、invalid compactは一切consumeしていません。

現在のP0は、PR #1884が追加したtrusted-anchorの実装経路が、通常のissue-refinement-loopから起動できないことです。

何が起きているか

  1. canonical Skillは preflight.run.with_anchor を通常経路として指定しています。
  2. command registryではこのコマンドが github_read_only / mutation: false です。
  3. PRのcontract-update consumerは run_refinement_preflight.py --consume-contract-patch-plan を明示した場合にだけ動きます。
  4. そのflagはregistryのcanonical argvに入っておらず、consumer結果も次工程用のcanonical handoffへ渡されません。

したがって、テストではcallback経由でcontrolled transactionと最終readbackを確認できますが、通常のSkill実行だけではplannerから「candidate生成 → controlled Issue mutation → final readback → fresh review/readiness」へ到達しません。これは#1877のAC3とOWNER anchorのP0-1/P0-2/P0-3を満たしていない、という意味です。

推奨案

preflightをmutation可能に変更するのではなく、既存preflightのread-only性を維持したうえで、Skillとcommand registryに明示的な次phaseを追加します。

  1. preflight.run.with_anchor はtrusted anchorの検証・patch plan生成までのread-only phaseとして維持する。
  2. その既存artifactを入力に、main control-planeだけが実行できるcontract-update phaseをcanonical Skill手順・registryへ登録する。
  3. このphaseは既存のcontrolled transaction helperを呼び、mutation直前readback、anchor再検証、body drift時の一回rebase、mutation後readback、fresh preflight/review/readinessを順に実行する。
  4. consumer resultは新しい永続artifactやschemaを作らず、既存artifactの狭いadditive fieldまたはtransaction-local dataで次工程へ渡す。
  5. registryからこのphaseを起動するE2Eで、実際にtransaction request・final readback・fresh review入力まで到達することを検証する。

この方針なら、#1877の「read-only preflightをmutation許可に偽装しない」という制約と、「新schema/digest/receipt/publisher/state storeを増やさない」というowner decisionの両方を守れます。

付随するP1

PR本文も、AC1–AC12を個別証跡で示し、current-headの変更5ファイル(#1835 fixtureを含む)へ更新する必要があります。これは上記P0の修正と同じ反復で修正可能です。

現head 40bbd644c3c0f7e1b5b747738eede6a0fe84f6ea のCIは16件成功、独立テストはfocused 15件・関連1815件成功です。ただし、このP0をCI成功で代用してmerge-readyとは扱いません。自動マージはしていません。

@squne121

Copy link
Copy Markdown
Owner Author

推奨アクション

「Issue #1877の契約を最小限更新してから、PR #1884に明示的なcontract-update phaseを追加する」方針を採用します。

PRの現在headは、停止コメント記載時の 40bbd… ではなく 5f6f6ba52ab35adc595cca90f8d89621c489d474 です。PRは引き続きDraftで、最新commitはmain取り込みだけなので、停止コメントのP0は解消されていません。

現実装では、consumerは --consume-contract-patch-plan 指定時にしか起動せず、成功時の consumer_result はcanonical resultへ格納されないまま破棄されます。 また、通常入口の preflight.run.with_anchor は現在も github_read_only / mutation: false です。

実装前にIssue #1877を更新する必要があります。現在のAllowed Pathsには、少なくとも command_registry.py とprivileged executor側のpolicy/test群が含まれていないため、そのまま修正するとIssue自身のStop Conditionsに抵触します。

採るべき構成は次です。

  1. preflight.run.with_anchor は一切mutation可能にせず、patch-plan handoff生成までに限定する。
  2. main control-plane専用の contract_update.run.with_anchor を新設する。
  3. 新phaseは既存preflight artifactの狭いoptional fieldを入力にし、専用の薄いwrapperから既存transaction helperを呼ぶ。
  4. callback単体テストではなく、registry → privileged executor → phase wrapper → transaction request → final readback → fresh checksを通るprocess-boundary E2Eを追加する。
  5. PR本文を実際の変更ファイル一覧とAC1–AC12の個別証跡で全面更新する。
  6. Draft維持・自動マージ禁止とする。

以下をCodex CLIへ投入してください。

あなたは squne121/loop-protocol のPR #1884を修正するmain control-plane agentです。

対象:

目的は、PR #1884のtrusted-anchor iteration-zero実装を、callbackテスト内だけでなく、通常のissue-refinement-loopのcanonical実行経路から起動可能にすることです。

PRはDraftのまま維持してください。自動マージ、ready化、mergeは行わないでください。

最重要判断

次の方針を採用してください。

  • preflight.run.with_anchor はread-onlyのまま維持する。
  • preflight.run.with_anchorをmutation: trueに変更しない。
  • 通常のpreflight argvへ単純に--consume-contract-patch-planを追加しない。
  • main control-planeだけが実行できる、明示的な次phaseを追加する。
  • 仮称はcontract_update.run.with_anchorとする。既存の命名・registry規則を調べ、より適切な既存命名規則があればそれに従ってよい。
  • 新しい永続state store、receipt、publisher、digest family、schema version、reason-code enumは追加しない。
  • 既存artifact/schemaの狭いoptional extension、またはtransaction-local dataだけを使う。
  • callback injectionだけでE2Eを成立させたことにしない。canonical registryとprivileged executorのprocess boundaryを必ず通す。

最初に実施する確認

作業開始時に、インストール済みのgh CLIのusageを再確認してください。

gh --version
gh auth status
gh pr view --help
gh pr diff --help
gh pr checks --help
gh issue view --help
gh api --help

その後、remote stateをfresh readしてください。

git fetch --prune origin

gh pr view 1884 \
  --repo squne121/loop-protocol \
  --json number,state,isDraft,headRefName,headRefOid,baseRefName,mergeable,mergeStateStatus,title,body,url

gh pr diff 1884 \
  --repo squne121/loop-protocol \
  --name-only

gh issue view 1877 \
  --repo squne121/loop-protocol \
  --json number,state,title,body,comments,url

gh api repos/squne121/loop-protocol/issues/comments/5145209579
gh api repos/squne121/loop-protocol/issues/comments/5143816923

コメント本文は必ず全文を読んでください。headなどで冒頭だけを読み、末尾のowner decisionや結論を見落としてはいけません。

停止コメントに記載された旧head 40bbd644...を作業基準にしないでください。実行時に取得したheadRefOidを正本としてください。

サブエージェント使用契約

main agentがGitHub mutation、ファイル編集、commit、push、PR更新の責任を保持します。

最初に、独立した第一階層サブエージェントを並列起動してください。利用可能な場合は全てgpt-5.3-codex-sparkモデルを優先してください。利用できない場合だけ、利用可能な最強のCodex reasoning modelへfallbackし、最終報告にfallback理由を記録してください。

サブエージェント自身によるnested delegationは禁止します。

Subagent A: canonical-path-auditor

read-onlyで次を調査してください。

  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/scripts/command_registry.py
  • .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
  • .claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py
  • scripts/agent-guards/skill_runtime_command_policy.py
  • scripts/agent-guards/skill_runtime_exec.py
  • 関連するcommand-policy/executor tests

出力:

  1. 現在のcanonical call graph
  2. --consume-contract-patch-planが通常経路から到達不能である具体的証拠
  3. 新phaseを追加するために必要な最小変更ファイル
  4. skill_runtime_exec.py本体の変更が本当に必要か
  5. root/default-branch/main-control-plane限定を維持する方法
  6. 既存exact execution classを安全に再利用できるか、新しいclassが必要か

ファイル変更は禁止します。

Subagent B: contract-scope-auditor

Issue #1877本文、OWNER anchor、PR停止コメントを全文で比較してください。

出力:

  1. 現在のAllowed Pathsで不足している正確なパス
  2. AC3、AC6、AC10、Runtime Verification、Verification Commandsに必要な最小追記
  3. Stop Conditionsとの矛盾
  4. Issue本文を広げすぎない最小patch案
  5. 新Issueへの分割が不要であること、または必要であることの根拠

ファイル・Issue変更は禁止します。

Subagent C: adversarial-test-designer

read-onlyで、次のテスト設計を提示してください。

  • registry entryからphaseを起動するpositive E2E
  • privileged executorを実際に通るprocess-boundary E2E
  • transaction request生成到達
  • mutation直前Issue/anchor readback
  • anchor ID、repo/issue binding、author association、source-body hash再検証
  • body drift時の一回だけのdesired-state rebase
  • final readback
  • fresh preflight入力
  • fresh review/readiness入力
  • replay時のno-change、write 0、iteration消費0
  • URL context mismatch
  • root以外のcwd
  • default branch以外
  • untrusted anchor
  • edited anchor
  • artifact mismatch
  • candidate readiness failure
  • transaction failure
  • path traversal・shell token injection
  • preflight commandが引き続きmutation不可である回帰

callback-onlyテストではなく、実際のregistry、policy、executor、phase wrapperを通す方法を指定してください。外部GitHubへの実mutationはテストで行わず、fake ghまたは既存fixture方式でprocess boundaryを維持してください。

Subagent D: minimalism-reviewer

A〜Cの結果を受け取った後、設計が過剰になっていないか独立確認してください。

拒否対象:

  • 新規state machine
  • 新規永続artifact family
  • 新規receipt
  • 新規publisher
  • 新規state store
  • 不要なdigest
  • preflightとcontract-updateの責務混同
  • generic workflow engine化
  • Issue #1877以外の大規模リファクタリング
  • #1882のcompact producer remediation混載

推奨する最小構成と、削除できる案を返してください。

Phase 1: Issue #1877のcontract修正

サブエージェントの調査結果をmain agentが検証してください。

新phase実装に必要なファイルがIssue #1877のAllowed Pathsに存在しない場合、コード変更より先にIssue本文を最小更新してください。

想定される追加候補には次が含まれますが、調査で不要と判明したパスを機械的に追加してはいけません。

.claude/skills/issue-refinement-loop/scripts/command_registry.py
.claude/skills/issue-refinement-loop/scripts/run_contract_update_phase.py
scripts/agent-guards/skill_runtime_command_policy.py
scripts/agent-guards/skill_runtime_exec.py
scripts/agent-guards/tests/

専用wrapperを新設せず、既存scriptの明確に分離されたphase modeで安全に実現できる場合は、その方が小さいことを証明した上で採用できます。ただし、preflight.run.with_anchor自体をmutation commandにしてはいけません。

Issue更新では次を明文化してください。

  • read-only preflightとmutation phaseの二段階境界
  • preflight artifactからcontract-update phaseへのcanonical handoff
  • main control-planeだけがmutation phaseを起動すること
  • registry/executor E2Eでtransaction requestまで到達すること
  • final readback後にfresh preflight/review/readinessへ接続すること
  • consumer resultを新規永続schemaへ保存しないこと
  • exact pathの追加
  • 対応するVerification Command

既存のAC1–AC12、Out of Scope、owner decisionを削除・弱体化しないでください。

Issue本文更新後は必ずfresh readbackし、更新したbodyのSHAまたは完全なbodyを保存してください。Issue更新を説明する短いコメントを#1877へ投稿してください。

Phase 2: 実装

既存PR #1884のbranchを使用してください。新しいPRを作成しないでください。

必須不変条件

preflight.run.with_anchorについて、次を維持してください。

network_effect: github_read_only
mutation: false
required_cwd: canonical_main_root
required_branch: default_branch

新しいcontract-update phaseは、最低限次を満たしてください。

explicit_command_id: true
main_control_plane_only: true
required_cwd: canonical_main_root
required_branch: default_branch
trusted_repo_binding: true
issue_anchor_context_binding: true
mutation: true

network_effectなどの値は、repository内で既に使われているregistry vocabularyを確認して選択してください。存在しない値を推測で追加しないでください。

Handoff

preflight phaseは、plannerが生成したtrusted contract patch planを後続phaseが取得できるようにしてください。

優先順位:

  1. 既存REFINEMENT_PREFLIGHT_RESULT_V1または既存artifact mapへの狭いoptional field
  2. 既存REFINEMENT_LOOP_PLAN_V1 artifactの利用
  3. transaction-local data

禁止:

  • 新規schema version
  • 新規artifact family
  • 新規receipt
  • 新規digest family
  • raw comment全文の無制限handoff
  • arbitrary user-supplied artifact path
  • hand-written shell command

後続phaseは、issue番号から導出されるcanonical artifact locationを使うか、既存の安全なrepo-relative-file placeholder validationを使ってください。path traversal、symlink escape、別Issue artifactの流用を拒否してください。

Contract-update phaseの処理順

次の順序を崩してはいけません。

load canonical preflight handoff
  -> validate schema and repo/issue/anchor binding
  -> fetch current Issue
  -> fetch current anchor comment
  -> revalidate comment id / author association / source body hash
  -> rebuild or validate section-aware desired state
  -> candidate static readiness
  -> if body drift: reapply desired state to fresh body, at most once
  -> build ISSUE_EDIT_TXN_INPUT_V1
  -> invoke existing edit_issue_txn.py
  -> fetch final Issue body
  -> verify expected section postconditions and contradictory-text removal
  -> run fresh preflight
  -> provide fresh review/readiness input
  -> return canonical bounded handoff to main orchestrator

次の場合のみmutation前にfail-closedしてください。

  • anchor削除または意味のある編集
  • trust/author association変化
  • repo/issue/comment context mismatch
  • semantic conflict
  • permission/security boundary
  • candidate static readiness failure
  • artifact schema/binding不正

Issue body SHA driftだけをhuman escalationにしてはいけません。一回だけdesired-state rebaseを試してください。

Consumer result

現在のように、成功したconsumer_resultをlocal variable内で破棄してはいけません。

次工程が少なくとも以下を判定できるbounded handoffを提供してください。

contract_update.status
final_readback status
fresh_preflight status/input
fresh_review status/input
fresh_readiness status/input
no_change / applied / rebased / failed

ただし、新規永続schemaを作らないでください。既存artifactの狭いoptional fieldまたはtransaction-local return dataを使用してください。

Phase 3: E2Eテスト

既存のtest_trusted_anchor_iteration_zero.pyにcallbackベースのテストを残しても構いませんが、それだけでAC3をPASSにしてはいけません。

新しい必須E2Eは、少なくとも次のboundaryを実際に通してください。

canonical command string
  -> skill_runtime_command_policy parser
  -> command_registry entry
  -> skill_runtime_exec
  -> contract-update phase process
  -> preflight handoff load
  -> controlled transaction request
  -> final readback
  -> fresh-check input

実GitHub Issueは変更しないでください。temporary git repository、fixture、fake gh、fake transaction executable、または既存のprocess-level test harnessを使用してください。

以下をassertしてください。

  • preflight.run.with_anchorにはmutation flagが入らない
  • 新phaseのcommand IDだけがmutation consumerへ到達する
  • root/default branch/trusted repoでのみ許可される
  • worktree/isolation subagentから直接起動できない
  • anchor URLのowner/repo/issue/commentが完全一致する
    -別Issueのartifactを拒否する
  • transaction inputが実際に生成される
  • final readbackが実行される
  • fresh preflight/review/readiness用入力へ到達する
  • replayはno-change、write 0
  • failure時に部分的な成功を返さない

Phase 4: 検証

最初にfocused testsを実行してください。

uv run --locked pytest \
  .claude/skills/issue-refinement-loop/tests/test_trusted_anchor_iteration_zero.py \
  -q

追加したregistry/policy/executor E2E testsを実行してください。

その後、Issue #1877のAC1–AC12のVerification Commandsを一件ずつ実行し、各ACについて次を記録してください。

AC番号
command
exit code
passed/failed count
current head SHA
証拠となるtest名

関連回帰を実行してください。

uv run --locked pytest \
  .claude/skills/issue-refinement-loop/tests \
  scripts/agent-guards/tests \
  -q

repositoryの実際のtoolingに従ってRuffを実行してください。

uv run --locked ruff check <changed-python-files>
git diff --check

変更したPythonファイルは、repositoryの既存方針に従ってsyntax verificationしてください。無断でsource treeへ__pycache__を残さないでください。

テスト失敗を既存失敗として無視する場合は、base commitでも同一failureが発生することを再現して証拠を残してください。

Phase 5: adversarial review

実装完了後、新しいread-onlyサブエージェントを起動してください。利用可能ならgpt-5.3-codex-sparkを使用します。

レビュー入力:

  • fresh Issue #1877本文
  • PR #1884のcurrent head
  • baseとのfull diff
  • OWNER anchor全文
  • PR停止コメント全文
  • AC1–AC12のtest evidence
  • command registry/policy/executorの変更
  • changed files一覧

レビュー観点:

  • canonical通常経路から本当に起動できるか
  • callback testだけで偽装していないか
  • preflightがmutation可能になっていないか
  • subagentからmutation phaseを直接起動できないか
  • handoffが失われないか
  • artifactやschemaを増やしすぎていないか
  • body driftとanchor driftを混同していないか
  • fresh review/readinessへ実際に到達するか
  • Issue Allowed Pathsを違反していないか
  • #1882を混載していないか

blockerがあれば修正してください。最大3反復とし、同一原因が再発した場合は停止して明示的に報告してください。

Phase 6: commit、push、PR本文更新

作業前後にremote headが動いていないことを確認してください。

commitは意図が分かる小さい単位にしてください。少なくとも、Issue contract更新とcode changeを混同した不透明なcommitにしないでください。

push後、current head SHAを再取得してください。

PR本文を全面的にfresh化してください。

必須項目:

  • Summary
  • canonical two-phase path
  • read-only preflight invariant
  • explicit contract-update phase
  • AC1–AC12個別証跡
  • 実際のcurrent-head changed files全件
  • focused test結果
  • related regression結果
  • current-head CI結果
  • Schema Change Applicability
  • Safety Claim Matrix
  • no new state store/schema/receipt/publisherの確認
  • Draft維持
  • auto merge未実行

変更ファイル一覧を手書きで推測しないでください。

gh pr diff 1884 \
  --repo squne121/loop-protocol \
  --name-only

この結果を正本としてPR本文へ反映してください。

必要であれば、停止コメント5145209579への対応結果をPR conversationへ一件だけ投稿してください。重複した進捗コメントを大量投稿しないでください。

禁止事項

  • preflight.run.with_anchorのmutation: true化
  • 通常preflight commandへのmutation flag混入
  • callback-only E2E
  • raw anchor全文を無制限にdownstreamへ渡すこと
  • Issue #1877のAllowed Pathsを無視した変更
  • #1882の実装混載
  • 新規state machine
  • 新規receipt/publisher/state store
  • 不要なschema/digest追加
  • unrelated refactor
  • force push
  • Draft解除
  • auto merge
  • merge
  • test failureの隠蔽
  • subagentによるnested delegation
  • subagentによるGitHub mutation

停止条件

次の場合だけ停止してください。

  • Issue #1877の最小contract更新では許可できない大規模scope拡張が必要
  • existing privileged executorで安全なmutation phaseを表現できず、新たな広範囲security architectureが必要
  • anchorのidentity、trust、source bodyが検証不能
  • actual Git conflict
  • permission/security boundaryにowner判断が必要
  • current PR branchに第三者の競合変更が入り、安全に統合できない
  • 3回の修正反復後も同一P0が残る

単なるテスト失敗、lint失敗、body SHA drift、PR本文不整合は自律修正してください。

最終報告形式

status:
current_head:
issue_1877_updated:
issue_body_readback:
subagents:
  - role:
    requested_model:
    actual_model:
    result:
implementation:
  canonical_preflight_command:
  canonical_contract_update_command:
  preflight_still_read_only:
  mutation_phase_main_control_plane_only:
  handoff:
  transaction_request_reached:
  final_readback_reached:
  fresh_preflight_reached:
  fresh_review_readiness_reached:
tests:
  focused:
  registry_executor_e2e:
  related_regression:
  lint:
  diff_check:
ac_evidence:
  AC1:
  AC2:
  AC3:
  AC4:
  AC5:
  AC6:
  AC7:
  AC8:
  AC9:
  AC10:
  AC11:
  AC12:
pr_body_updated:
draft_preserved:
auto_merge_enabled: false
merge_performed: false
remaining_blockers:

「CI成功」だけを理由にmerge-readyと判定しないでください。通常のSkill実行経路からcanonical mutation phaseへ到達することを、process-boundary E2Eとcurrent-headのfresh adversarial reviewで証明してください。

このプロンプトは、Issue本文のAllowed Paths修正から既存PRの修正・検証・PR本文更新までを一続きで実施する構成です。

@squne121

squne121 commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST_CHANGES

Evidence Check

  • current head: cae30cf34f5d48060971b5cfbdc3582cd0869bf2
  • required CI: CI_WAIT_RESULT_V1.status=passed。head SHA は一致しています。
  • Allowed Paths: live #1877本文を正本に再計算し、13ファイル・rename provenanceを含めて status: ok でした。
  • read-only invariant: preflight.run.with_anchor は mutation: false のままです。

Blockers

  • P0: AC3/AC6/AC10が要求するprocess-boundary E2Eは、productionの run_refinement_preflight.py を実行していません。現行 test_skill_runtime_exec_anchor.py はregistry・policy・executorを通るものの、phase wrapperを簡易fakeへ置換しています。canonical handoff load、anchor再検証、candidate readiness、controlled transaction request、final readback、fresh preflight/review/readiness inputまでを、実wrapperを含む同一E2Eで確認してください。

CIとAllowed Pathsは通過していますが、このP0が残るためAPPROVEはできません。Draft状態は維持します。

verdict: REQUEST_CHANGES
reviewed_head_sha: "cae30cf34f5d48060971b5cfbdc3582cd0869bf2"
blockers:
  - "P0: production run_refinement_preflight.py を含む単一process-boundary E2Eで、canonical handoffからfresh inputsまでを検証すること。"
warnings: []

@squne121

squne121 commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Evidence Check

  • review対象head: 6be9eb6b33a42053d035f81ea525af01946be4e9
  • required CI: CI_WAIT_RESULT_V1.status=passed、CI summaryはall_passです。
  • 実wrapper E2E: production registry → policy → executor → wrapper → transaction helperを通過し、初回apply/final/fresh inputsとreplay no_change / write 0を確認しました。
  • read-only invariant: preflight.run.with_anchor はmutation: falseのままです。
  • Allowed Paths: live #1877本文を正本にした13ファイルのgateはokです。

Blockers

  • なし

Non-blockers

  • PRはDraftを維持します。このAPPROVEはマージ、Draft解除、またはauto mergeの実行を意味しません。
verdict: APPROVE
reviewed_head_sha: "6be9eb6b33a42053d035f81ea525af01946be4e9"
blockers: []
warnings: []

squne121 added a commit that referenced this pull request Aug 9, 2026
…2057 OWNER REQUEST_CHANGES を解消する

PR #2057 (Closes #2048) の head 0710701 に対する OWNER REQUEST_CHANGES
(P0 3件・P1 3件・P2 1件) を反映する。

- P0-1: decide_rewrite_route.classify_scope_reframe_disposition() を
  patch/proven_no_change/full_rewrite_required/invalid の単一 pure function
  として新設。consume_trusted_anchor_contract_patch_plan() と
  plan_refinement_loop._compute_scope_reframe_rewrite_route() の両方が同一
  関数を呼び、malformed operations/allowed_path_deltas・anchor binding
  mismatch・parser 失敗を invalid として明示的に分離する(従来は no_change
  に吸収されていた)。planner 側の non-list operations coercion も廃止。
- P0-2: run_trusted_anchor_iteration_zero() の empty-operations no-op 分岐を
  fetch_current() 実行後に再分類するよう並べ替え、_bounded_contract_update_
  handoff() は legitimate な full_rewrite_required handoff を新しい
  status: handoff_required として表現する(従来の status: failed 上書きを
  廃止)。final_readback は実際の readback が発生した場合のみ verified。
- P0-3: scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py に
  registry -> policy -> privileged executor subprocess -> production
  run_refinement_preflight.py -> scope_signal_delta.py -> fake gh の
  真の process-boundary E2E テストを追加(PR #1884 の実装済み harness を
  再利用)。
- P1-4/P1-5: Allowed Paths reflected 判定を tri-state
  (present/absent/invalid_or_unavailable) にし、全文 substring fallback を
  除去。
- P1-2: should_post_comment/duplicate_comment を削除し comment_action:
  "none" に統一。
- P1-3: refinement_preflight_result_v1.schema.json の contract_update に
  disposition/reason_code を追加し handoff_required/not_applicable を
  enum に追加(既存 schema の狭い拡張)。
- P2: scope_delta_status を必須化(deltas 指定時は None だと fail-closed)、
  ルーター import 失敗を environment_failure/invalid として明示。

regression test: malformed matrix、false-positive resistance、
planner/consumer parity、full-rewrite side-effect 0、真の process-boundary
E2E を追加。既存 issue-refinement-loop 全 2492 test 回帰なし。ruff green。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
squne121 added a commit that referenced this pull request Aug 11, 2026
…d へ route (#2048) (#2057)

* fix: approved scope reframe の empty operations を issue_editor_required へ route (#2048)

#1877/PR #1884 の regression follow-up。approved scope reframe
(approved_by_trusted_anchor かつ allowed_path_deltas 有効)だが
operations[] が空で完全な body rewrite が必要なケースで、
decide_rewrite_route.py の decide_scope_reframe_contract_route() が
contract_update ではなく issue_editor_required
(reason_code: approved_scope_requires_full_contract_rewrite)を返すようにした。

- decide_rewrite_route.py: SCOPE_REFRAME_CONTRACT_ROUTE_STATE_V1 /
  decide_scope_reframe_contract_route() を追加。anchor comment URL +
  Issue body sha256 から empty_operations_fingerprint を導出し、
  同一 fingerprint の再発は no-progress な contract_update 再試行 (AC2) と
  scope reframe comment の重複投稿 (AC3) の両方を抑制する。
- route_after_rewrite.py: compute_implementation_allowed() を追加し、
  body/title readback と fresh review/preflight 完了が確認されるまで
  implementation_allowed=false を維持する (fail-closed)。CLI に
  --body-readback-confirmed / --title-readback-confirmed /
  --fresh-review-preflight-completed を追加。
- test_rewrite_router.py / test_route_after_rewrite.py に regression
  テストを追加、新規 test_scope_only_reframe_route.py で scope-only
  reframe fixture を検証。既存の #1835 fixture・#1877 regression
  fixture は変更なしで PASS を維持。

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: #2048 scope reframe route を production 経路(scope_signal_delta / plan_refinement_loop)へ配線

pr-reviewer REQUEST_CHANGES (PR #2057) への fix_delta。
decide_scope_reframe_contract_route() / compute_empty_operations_fingerprint()
がユニットテスト単体でしか呼ばれていなかった問題を解消する。

- scope_signal_delta.run_trusted_anchor_iteration_zero()(run_refinement_preflight.py
  の contract_update.run.with_anchor レーンが実際に呼ぶ production 経路)が
  operations[] 空の承認済み scope reframe を検出したら decide_scope_reframe_contract_route()
  を呼び出し、no_change 結果へ rewrite_route サイドカーとして付与する。
  allowed_path_deltas 未指定時は完全に no-op(既存呼び出し元は byte-identical)。
- plan_refinement_loop.py は known_context.scope_delta_decision.operations が
  渡された場合のみ同じ判定を計算し、decisions.scope_delta_decision.rewrite_route
  として echo する(additionalProperties: true のため既存 schema 変更不要、
  未指定時は既存 fixture と byte-identical)。
- route_after_rewrite.py の AC4 implementation_allowed(post-mutation readback gate)
  と scope_signal_delta.SCOPE_DELTA_AUTHORITY_V1 の route.implementation_allowed
  (trusted anchor directive 自体の許可)の名前衝突を避けるため、plan_refinement_loop.py
  からは compute_implementation_allowed を rewrite_router_implementation_allowed
  として echo する。
- SKILL.md / references/loop-state.md に production wiring と rewrite_route
  サイドカーの意味論を追記。
- test_scope_only_reframe_route.py に run_trusted_anchor_iteration_zero 経由の
  production wiring regression テスト3件を追加(到達可能性・replay抑制・後方互換性)。

全 1239 件 pytest PASS(.claude/skills/issue-refinement-loop/tests/)。ruff clean。

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: #2048 scope reframe route を consume_trusted_anchor_contract_patch_plan() から実際に到達可能にする

- run_refinement_preflight.py::consume_trusted_anchor_contract_patch_plan() が
  known_context["scope_delta_decision"] を fail-closed に再検証
  (_extract_validated_scope_delta_deltas: 型/binding/anchor一致) した上で
  allowed_path_deltas を scope_signal_delta.run_trusted_anchor_iteration_zero()
  へ実際に転送するようにした。従来は known_context 引数が定義済みなのに
  転送されておらず、decide_scope_reframe_contract_route() が
  production から到達不能だった(#2048 PR review blocker, iteration 1/2)。
- operations[] の producer が存在しない場合(freeform directiveにexact path
  literalがなくclassify_scope_delta_authority()がhuman_escalationへ倒れる場合等)
  でも、承認済みscope reframeを検出したら empty-operations の
  CONTRACT_PATCH_PLAN_V1 を合成してconsumerへ渡すようにした。これがない場合
  patch_planはNoneのままconsumerが一度も呼ばれなかった。
- proven_no_change disposition を追加: allowed_path_deltasが現在のIssue本文の
  Allowed Pathsに既に全反映済みならissue_editor_requiredへ昇格させない
  (_scope_reframe_deltas_already_reflected, baseline_vc_preflightの
  extract_allowed_pathsを再利用)。
- full_rewrite_required検出時、wrapperのnext_actionをissue_editor_requiredへ
  上書きしstdout/result artifactへ伝播。contract_update.statusはno_changeへ
  流用せずfailedとし、通常のBLOCKER_FAIL_CLOSED success/failure判定へは
  流さない。
- SKILL.mdにNEXT_ACTION: issue_editor_required受信時のcanonical orchestration
  手順(再実行しない/コメント再投稿しない/issue-editorへhandoff/fresh gate
  完了までimplementation禁止)を追記。
- process-boundary E2E(test_preflight_run_with_anchor.py)を追加:
  run_preflight()を通じた positive fixture 1件+replay 1件+proven_no_change 1件、
  consume_trusted_anchor_contract_patch_plan()直接呼び出しによるnegative
  regression 7件。全AC1-AC6検証・既存1239テスト無回帰。

* fix: #2048 scope reframe を単一 canonical disposition classifier に統合し PR #2057 OWNER REQUEST_CHANGES を解消する

PR #2057 (Closes #2048) の head 0710701 に対する OWNER REQUEST_CHANGES
(P0 3件・P1 3件・P2 1件) を反映する。

- P0-1: decide_rewrite_route.classify_scope_reframe_disposition() を
  patch/proven_no_change/full_rewrite_required/invalid の単一 pure function
  として新設。consume_trusted_anchor_contract_patch_plan() と
  plan_refinement_loop._compute_scope_reframe_rewrite_route() の両方が同一
  関数を呼び、malformed operations/allowed_path_deltas・anchor binding
  mismatch・parser 失敗を invalid として明示的に分離する(従来は no_change
  に吸収されていた)。planner 側の non-list operations coercion も廃止。
- P0-2: run_trusted_anchor_iteration_zero() の empty-operations no-op 分岐を
  fetch_current() 実行後に再分類するよう並べ替え、_bounded_contract_update_
  handoff() は legitimate な full_rewrite_required handoff を新しい
  status: handoff_required として表現する(従来の status: failed 上書きを
  廃止)。final_readback は実際の readback が発生した場合のみ verified。
- P0-3: scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py に
  registry -> policy -> privileged executor subprocess -> production
  run_refinement_preflight.py -> scope_signal_delta.py -> fake gh の
  真の process-boundary E2E テストを追加(PR #1884 の実装済み harness を
  再利用)。
- P1-4/P1-5: Allowed Paths reflected 判定を tri-state
  (present/absent/invalid_or_unavailable) にし、全文 substring fallback を
  除去。
- P1-2: should_post_comment/duplicate_comment を削除し comment_action:
  "none" に統一。
- P1-3: refinement_preflight_result_v1.schema.json の contract_update に
  disposition/reason_code を追加し handoff_required/not_applicable を
  enum に追加(既存 schema の狭い拡張)。
- P2: scope_delta_status を必須化(deltas 指定時は None だと fail-closed)、
  ルーター import 失敗を environment_failure/invalid として明示。

regression test: malformed matrix、false-positive resistance、
planner/consumer parity、full-rewrite side-effect 0、真の process-boundary
E2E を追加。既存 issue-refinement-loop 全 2492 test 回帰なし。ruff green。

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: #2048 PR #2057 iteration4 blocker3 -- patch-plan producer unavailable を production 到達可能にする

OWNER REQUEST_CHANGES (blocker3/P0-1残課題) 対応: classify_scope_reframe_disposition()
の patch_plan_producer_available 引数を、consume_trusted_anchor_contract_patch_plan()
-> run_trusted_anchor_iteration_zero() の production caller chain から実際に False で
呼べるよう配線した。

- run_refinement_preflight.py: empty-operations 合成箇所で、freeform
  SCOPE_DELTA_AUTHORITY_EVIDENCE_V1 の evidence builder(_build_scope_delta_authority_evidence())
  が同一 anchor に対して成功したか(known_context["scope_delta_authority_evidence"] の有無)を
  判定し、_patch_plan_producer_available として consume_trusted_anchor_contract_patch_plan()
  へ渡す。producer が明示的に human_escalation を返した既存の正当な full_rewrite_required
  ケース(構造化 ANCHOR_SCOPE_REFRAME_V1 のみで freeform directive を含まないケース、既存
  fixture)は従来どおり True のまま維持し、evidence builder 自体が失敗した(URL構造不正/
  repo・issue番号不一致/parser import failure)場合のみ False として invalid に fail closed する。
- scope_signal_delta.py: run_trusted_anchor_iteration_zero() に patch_plan_producer_available
  kwarg を追加し、classify_scope_reframe_disposition() へそのまま伝播する。
- test_preflight_run_with_anchor.py: producer unavailable -> invalid disposition が production
  consumer 経由で到達することを検証する回帰2件、および anchor / Issue body TOCTOU (fetch_current
  が異なる値を返すケース)を明示的に注入する回帰2件を追加。

検証: .claude/skills/issue-refinement-loop/tests/ + scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
= 1286 passed(既存1282 + 新規4)。ruff clean。

* fix: #2048 PR #2057 レビュー指摘のコード内コメントを実際の解決状態に合わせて更新する

run_refinement_preflight.py の P0-1 コメントが「partially addressed; see PR
description ... Known limitations」という古い記述のまま残っていた。
patch_plan_producer_available の配線(consume_trusted_anchor_contract_patch_plan()
経由)と対応する回帰テスト(test_producer_unavailable_reaches_invalid_disposition_via_production_consumer /
test_producer_available_default_true_preserves_full_rewrite_required)により
P0-1 は既に完全解決しており、PR 本文の SAFETY_CLAIMS_V1 でも該当 claim を
implemented: "yes" と記載済みだった。コメントを現状に整合させる。

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Test User <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: 修正: iteration 0 の trusted anchor を body-delta 非依存で contract update へ routing する

1 participant