Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: '#1408'
goal_ref: 'PR #1442(Issue #1408の実装)への人間の敵対的セキュリティレビュー(https://github.com/squne121/loop-protocol/pull/1442#issuecomment-4941989903、issuecomment-4942738266)で指摘されたP1 Blocker「新規branchの初回publishを安全なatomic create laneで実行できない」を、OWNER裁定(issuecomment-4942998354)に基づき解消する'
change_kind: code
supersedes:
- '#1443'Parent Issue
Parent Goal Ref
- Goal: Issue #1408のpublish lane approval bridgeが、検証済み証跡に基づいてrtk git pushを許可しつつ、危険・不一致なpushをdenyし続ける状態を確立する
- Desired Destination: PR #1442のmerge blockerとして指摘された「新規branch初回publishの状態表現欠如・atomic create機構欠如」を、OWNER裁定に基づくcompare-and-create primitiveとremote state 3値分類で解消する
Current Validated Scope
- scripts/agent-guards/git_mutation_command_policy.pyの_ls_remote_head()関数は、git ls-remote --exit-codeの非ゼロ終了コード(対象refが未存在の場合のstatus 2を含む)を区別できる形にPR #1442で拡張済みだが、初回作成専用のdecision pathは未実装
- ALLOWED_REMOTE_READBACK_SOURCESのうち実際にremoteを読み直すのはls_remoteのみであり、初回作成の根拠はls_remote直読みの結果のみとする(環境変数申告のabsent、github_branch_api、fetch_then_show_ref相当のラベルは根拠として認めない)
- Issue #1450とIssue #1468は、個人開発リポジトリの脅威モデルに対して過剰と判断されnot_plannedでクローズ済みである(Issue 実装: publish laneのauthorization code(policy/adapter)の信頼境界をhash pinningでcandidate worktree外に確立する #1450: closedAt 2026-07-11T14:27:03Z、Issue 実装: publish lane trust root(#1454 Phase A)にnonce runtime state分離・trusted publisher wrapper・atomic rotation・worktree cwd解決・deployment attestationを追加する #1468: closedAt 2026-07-11T14:26:48Z)。Issue 実装: 未配線の external trust root(scripts/trust-root/)を削除しリポジトリを実態に合わせる #1469/PR chore: 未配線の external trust root(scripts/trust-root/)を削除する #1471(merge commit b567c70)により、external trust root一式(scripts/trust-root/)は削除済みである。本Issueは、これらのhash pinning・external trust root・trusted main commit照合を実装前提としない
- 本Issueが依拠する信頼境界は、Issue 実装: PreToolUse remote_write_requires_approval を publish lane 証跡で通過可能にする #1408/PR #1442で実装済みのproject-local scripts/agent-guards/git_mutation_command_policy.pyとscripts/session-recording/codex-hook-adapter.mjs、Allowed Paths・head binding・canonical origin identity・default branch guard、および人間によるPRレビューとGitHub branch protectionのみである
- 本Issueの実行面(trusted execution boundary)は、この既存2ファイル内に実装する。新しいexecutor fileや新しいarchitecture layerは追加しない
Remaining Parent Gaps
- Codex hooks.managed_dirへの本格移行、bootstrap publish用のprivileged executorの実装は本Issueでは扱わない
- P2/P3指摘(originのpush先repository検証、main/master/trunk destination guard、Allowed Paths evidenceのhead/契約bind、実bare remoteを使うintegration test拡充)は本Issueの対象外で、必要なら別途follow-up Issueを起票する
Outcome
scripts/agent-guards/git_mutation_command_policy.pyのpublish laneが、remote branch状態を同一実行サイクルのlive git ls-remote --refs --exit-code からのみ present/absent/probe_error の排他的3状態として判定し、initial_branch_create lane(live probeがabsentの場合のみ候補、完全限定empty-expect lease git push --force-with-lease=refs/heads/<active-branch>: origin HEAD:refs/heads/<active-branch> をargv配列・shell=falseで実行)と existing_branch_update lane(既存のfast-forward/head binding/Allowed Paths binding/canonical origin identity/default branch guardを維持)を別decision pathとして実装し、canonical repository identity確認・branch確認・head確認・Allowed Paths gate確認・live probe・lease実行・post-push readback(同一refの再live読み直しとlocal headの完全一致確認)・structured result生成・fail-closedを一連の処理として同一trusted execution boundary(git_mutation_command_policy.py + codex-hook-adapter.mjsという既存のproject-local publish policy/adapter経路内)で担い、対応するpytestが全てPASSしている状態。
In Scope
- remote branch状態を
present/absent/probe_errorの3状態に限定し、判定元を同一実行サイクルのlivegit ls-remote --refs --exit-codeのみに限定する(環境変数申告・github_branch_api・fetch_then_show_ref相当のラベルは初回作成の根拠として使わない) probe_error(timeout、認証失敗、通信失敗、不正出力、その他非0)を必ずfail-closedにするinitial_branch_createlane をexisting_branch_updatelane とは別のdecision pathとして実装する。live probeがabsentの場合だけ候補になり、presentの場合はempty-expect leaseを試さずexisting_branch_updateへ送るか契約不一致としてdenyするinitial_branch_createlaneでは、git push --force-with-lease=refs/heads/<active-branch>: origin HEAD:refs/heads/<active-branch>(empty-expect lease、単一ref・複数refspec不可)という完全限定形argv配列のみを許可し、argvをshell文字列組立せずshell=Falseで実行する- push実行後、同じremote refに対して再度live
ls-remotereadbackを行い、readback headとlocal headの完全一致を確認する。不一致・通信失敗・競合時はfail-closedのstructured safety stopとする --force、-f、+refspec、引数なしの--force-with-lease、<refname>のみのlease、empty以外のexpected value、target branchと異なるlease ref、複数lease、複数refspec、tag、--tags、--all、--mirror、--delete、branch deletion refspec、default branchへのpush、rawgit push、git -C ... push、wrapper bypass、完全限定形への追加flagは、initial_branch_createlaneでも引き続き全てdenyする- 既存branch更新laneのfast-forward、head binding、Allowed Paths binding、canonical origin identity、default branch guardは変更しない
initial_branch_createlane、existing_branch_updatelaneそれぞれのpositive/negative pytestを追加する(一時bare remoteを使い、外部ネットワーク・実GitHub credential・ユーザーのglobal Git設定に依存させない)- race condition試験(probe後、push前に競合プロセスが同名branchを作成した場合、leaseが失敗し競合側refを上書きしないこと)を追加する
- 実PreToolUse entrypointでpositive/negative laneを検証するテストを追加する
Out of Scope
- 一般的なforce push許可
- 既存branchのnon-fast-forward更新許可
- GitHub REST APIによるref作成
- credential、OAuth、token scopeの変更
- Codex/Claude runtime本体のpermission model変更
- policy/adapter自体のhash pinning trust boundaryの新規実装(個人開発の脅威モデルに対して過剰と判断され採用しない。Issue 実装: publish laneのauthorization code(policy/adapter)の信頼境界をhash pinningでcandidate worktree外に確立する #1450/#1468はこの判断でnot_plannedクローズ済み)
- bootstrap privileged publisherの実装(本Issue自身の初回branch publicationは既存privileged publication経路の責務であり、本Issueの動作検証・AC達成には数えない)
- actual GitHub remoteを使う自動verification
- tag、delete、mirror、multi-ref publish
- existing update laneの再設計
- fetch_then_show_ref、github_branch_apiの証跡真正性改善(別途follow-up Issueが必要なら起票する)
Runtime Verification Applicability
decision: immediate
reason: >-
ローカルの一時bare Git repository(pytestの`tmp_path`等で完全分離、外部ネットワーク・実GitHub
credential・ユーザーのglobal Git設定に非依存)を使用し、実Git transport、ref作成、競合拒否、
post-push readbackをネットワークなしで検証できるため。実GitHub remoteへのpushはverificationに含めない。
applicable_acs:
- AC1
- AC2
- AC3
- AC4
- AC5
- AC6
- AC7
- AC8
- AC9
- AC10
- AC11
- AC12
- AC13
execution_environment:
cli_tools:
- python3
- uv
- pytest
- git
auth_required: false
network_required: false
skip_conditions:
- '一時bare Git repositoryの作成に失敗した場合はSKIPではなくenvironment blockedとして扱う'
fallback_policy:
fallback_success_is_pass: false
notes: '実GitHub remoteへの自動verificationにfallbackしない。fallback経由の成功をPASSに変換しない'
artifact_requirements:
- 'pytest output'
- 'contract_readiness_check.py JSON output'Acceptance Criteria
- AC1: remote branch状態が
present/absent/probe_errorの排他的3状態に分類され、absentが同一実行サイクルのlivegit ls-remote --refs --exit-codeからのみ生成されることをテストで確認できる - AC2:
initial_branch_createlaneが、完全限定empty-expect lease(git push --force-with-lease=refs/heads/<branch>: origin HEAD:refs/heads/<branch>)のみを生成・実行し、argv配列・shell=Falseで実行されることをテストで確認できる - AC3: 一時bare remoteで、ref不在状態からlocal HEADを使ったbranch初回作成が正常に完了することをテストで確認できる
- AC4: probe後・push前に競合プロセスが同名branchを作成した場合、
initial_branch_createlaneのleaseが失敗し、競合側の既存refを上書きしないことをテストで確認できる - AC5: remote branchが既にpresentの場合、
initial_branch_createlaneが使用されず、existing_branch_updatelaneへ送られるか契約不一致としてdenyされることをテストで確認できる - AC6: timeout・認証相当エラー・不正出力を
probe_errorとして分類し、fail-closed(deny)にすることをテストで確認できる - AC7: push成功後、同じremote refへのlive readbackがlocal headと一致した場合のみsuccessとして扱われることをテストで確認できる
- AC8: push成功後のreadback失敗、またはreadback headとlocal headの不一致がstructured safety stop(fail-closed)として扱われることをテストで確認できる
- AC9:
--force、-f、+refspec、引数なしの--force-with-lease、<refname>のみのlease、empty以外のexpected value、target branchと異なるlease ref、複数lease、複数refspec、tag、--all、--mirror、--deleteがinitial_branch_createlaneでも引き続きdenyされることをテストで確認できる - AC10: 既存branch更新lane(fast-forward、head binding、Allowed Paths binding、canonical origin identity、default branch guard)の既存pytestがregressionなくPASSする
- AC11: 実PreToolUse entrypointを通したpositive lane(absent状態からの初回作成)とnegative lane(present状態でのempty-expect lease拒否)が、実 hook 呼び出し経路で検証されることをテストで確認できる
- AC12:
initial_branch_createlaneのremote-write実行がargv配列で組み立てられ、shell文字列結合を経由しないことをテストで確認できる - AC13: scripts/agent-guards/tests/test_git_mutation_command_policy.py(新規追加分含む)の全テストがregressionなくPASSする
Verification Commands
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k remote_state_classification # AC1
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k empty_expect_lease_argv_shape # AC2
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k bare_remote_initial_create_succeeds # AC3
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k race_lease_rejects_conflicting_ref # AC4
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k present_state_routes_to_existing_update_lane # AC5
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k probe_error_is_fail_closed # AC6
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k readback_matches_local_head_succeeds # AC7
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k readback_mismatch_is_safety_stop # AC8
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k denied_force_and_lease_variants_still_denied # AC9
# baseline-expect: pass
$ uv run --locked pytest scripts/agent-guards/tests/test_git_mutation_command_policy.py -k test_publish_lane_allows_only_matching_remote_branch_and_heads # AC10
# baseline-expect: fail
$ uv run --locked pytest tests/session_recording/codex/test_initial_branch_create_lane.py::test_initial_branch_create_pretooluse_lane # AC11
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -k execution_uses_argv_list_not_shell # AC12
# baseline-expect: pass
$ uv run --locked pytest scripts/agent-guards/tests/test_git_mutation_command_policy.py # AC13Allowed Paths
- scripts/agent-guards/git_mutation_command_policy.py
- scripts/agent-guards/hook_repair_hints.py
- scripts/agent-guards/tests/test_git_mutation_command_policy.py
- scripts/agent-guards/tests/test_initial_branch_publish_policy.py(新規作成)
- scripts/session-recording/codex-hook-adapter.mjs
- tests/session_recording/codex/test_hook_adapter.py
- tests/session_recording/codex/test_initial_branch_create_lane.py(新規作成)
- docs/dev/session-recording-policy.md
- docs/dev/workflow.md
- docs/dev/hook-boundaries.md
- docs/dev/agent-runtime-ops.md
- .github/workflows/ci.yml
- .github/ci/python-test-plan.json
scripts/agent-guards/tests/test_initial_branch_publish_policy.py と tests/session_recording/codex/test_initial_branch_create_lane.py は新規作成対象である。新しいtop-level architecture layerや新しいexecutor fileは追加しない。必要性が判明した場合は本Issueのscope外として停止する。
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 既存branch更新laneのdeny方針(force、tag、all、delete、mirror pushのdeny等)を変更する必要が判明した場合
- OWNER裁定(issuecomment-4942998354)により、Stop Conditionsの「force deny policy変更禁止」は次の意味に置換される: initial_branch_create laneの完全限定empty-expect leaseだけを例外として認め、それ以外のforce/lease/強制更新形式のdenyを変更してはならない
- 新しいexecutor fileまたは新しいarchitecture layerが不可欠と判明した場合
Required Skills
- Python / pytest
- Git refspec、force-with-lease compare-and-create semantics
- JavaScript / Node.js hook adapter
- 一時bare Git repositoryを使ったintegration test設計
Required Design References
- docs/dev/session-recording-policy.md
- docs/dev/hook-boundaries.md
- docs/dev/agent-runtime-ops.md
- docs/dev/workflow.md
- Issue #1408の本文とPR #1442の敵対的レビューコメント(https://github.com/squne121/loop-protocol/pull/1442#issuecomment-4941989903)
- Issue #1449への敵対的レビュー(https://github.com/squne121/loop-protocol/issues/1449#issuecomment-4942738266)
- OWNER裁定(https://github.com/squne121/loop-protocol/issues/1449#issuecomment-4942998354)
- Issue 実装: PreToolUse remote_write_requires_approval を publish lane 証跡で通過可能にする #1408/PR feat: PreToolUse remote_write_requires_approval を publish lane 証跡で通過可能にする #1442(現行publish lane基盤の実装、merged)
- Issue 実装: 未配線の external trust root(scripts/trust-root/)を削除しリポジトリを実態に合わせる #1469/PR chore: 未配線の external trust root(scripts/trust-root/)を削除する #1471(scripts/trust-root/削除、merge commit b567c70、merged 2026-07-11T15:13:43Z)
Delivery Rule
- 1 Issue = 1 PR
- Dedicated worktreeを作成して実装する
- Draft PR既定
- 実装開始条件: (a) PR #1442のpublish lane基盤がmainへ反映済み (b) PR #1471のtrust-root削除がmainへ反映済み (c) 本Issueの実装branchは最新mainから作成する (d) OPENな重複Issue/PRとのcollision preflightを通過する
- 本Issue自身の初回branch publicationは既存privileged publication経路の責務であり、本Issueの実装スコープには含まない
Scope Delta(任意)
- 追加ファイル:
.github/workflows/ci.yml,.github/ci/python-test-plan.json - 理由: AC11で追加したテストファイル
tests/session_recording/codex/test_initial_branch_create_lane.pyがci_test_selection/v1のuncovered_changed_test_filesfail-closed gateで未検出となりCIを落としたため、CI設定への登録(dedicated_lanes登録・collect-only証跡コマンド更新)のみを追加。ロジック新設・新規architecture layerの追加ではない。 - 承認: PR 実装: publish laneに新規branch初回publish用のatomicなbranch作成laneを追加する #1479 レビュー時に判明したCI登録漏れの是正として、本Issue契約に事後反映。
Activity
squne121 commentedon Jul 11, 2026
Issue #1449 敵対的レビュー
判定
REQUEST_CHANGES — 現状の契約では実装着手不可
Issue は「remote ref の不在」と「通信失敗」を分離する必要性を正しく認識しています。しかし、題名と Outcome が主張する atomic branch creation を実現するサーバ側の排他条件、競合試験、実 push 経路が契約に含まれていません。
現状の AC を満たしても、実装できるのは「push 前に branch が存在しなかったと観測した」ことまでです。「push が実行された瞬間にも branch が存在せず、自分だけが作成した」ことは保証できません。
P1 Blocker 1: 「atomic create」が単なる事前確認になっている
現行 policy が生成する許可コマンドは、通常の次の push です。
evaluate_publish_lane()は expected/current head を比較した後、この通常 push を許可しています。remote ref が不在であることを push サーバへ条件として渡してはいません。この設計には典型的な TOCTOU があります。
Agent B が作成した commit が Agent A の commit の祖先だった場合、Agent A の通常 push は fast-forward として成功します。Git は branch の fast-forward update を通常許可するため、「初回作成専用 lane」ではなく、競合相手の branch を更新する lane になります。(Git)
ローカルの bare remote と Git 2.47.3 で再現した結果も以下でした。
必須修正
create lane の push 自体を、サーバ側 compare-and-create にする必要があります。
--force-with-lease=<ref>:の expected value を空にすると、Git は対象 ref がまだ存在しない場合にだけ更新します。push 直前に他 actor が ref を作成した場合、サーバ側で拒否されます。これは unrestricted force push ではなく、ref 不在を expected state とする明示的な lease です。([Git]2)なお、
git push --atomicは代替になりません。これは複数 ref を「全部更新するか、全部更新しないか」にする機能であり、対象 ref の事前不在を要求する機能ではありません。(Git)P1 Blocker 2: force deny 契約と安全な create primitive が矛盾する
Issue は「既存の force 系 deny 方針を変更しない」と固定しています。
しかし、安全な create-only push に必要な最小 primitive は、上記の exact
--force-with-lease=refs/heads/<branch>:です。現行 parser は push 引数をoriginと refspec の2個に限定しているため、このオプションを追加すると command shape で deny されます。したがって契約は、以下のように変更すべきです。
許可する唯一の lease
引き続き deny
現在の Stop Condition のままでは、安全な解決策が判明した時点で「既存 force deny 方針の変更」として実装停止になります。Issue 自身が解決策を禁止しています。
P1 Blocker 3: bare remote integration test を Out of Scope にしてはならない
Issue は Runtime Verification を
not_applicableとし、実 bare remote を使う integration test も明示的に除外しています。これは atomicity claim と両立しません。mock や unit test で確認できるのは、次だけです。
確認できないものは以下です。
ローカル bare repository は外部サービス、実 GitHub credential、ネットワーク権限を必要としません。決定論的な pytest fixture として実行できます。したがって Runtime Verification は以下に変更すべきです。
P1 Blocker 4: create lane が自己申告の「absent」を信用できる
PR #1442 の現在の positive hook test は、test repository に
originremoteを作成せず、環境変数へ同一 SHA とfetch_then_show_refを設定するだけで PreToolUse allow を得ています。つまり現時点では、実 remote がなくても自己申告 evidence だけで通過できます。Issue #1449 は
fetch_then_show_refとgithub_branch_apiの真正性を Out of Scope にしています。このまま absent field を追加すると、次の値を設定するだけで create lane を選択できる危険があります。
必須条件
create lane は当面、次のいずれかに限定すべきです。
ls_remoteの status 2fetch_then_show_refとgithub_branch_apiは、署名済みまたは改変不能な evidence producer が完成するまで create lane では許可してはいけません。P1 Blocker 5: 認可コードの trust boundary が先に必要
Issue #1450 は、candidate worktree 内の policy/adapter が自分自身の push を許可できる自己署名問題を hash pinning で解消する計画です。しかし現在は未実装です。
Issue #1449 の Delivery Rule は「#1450 と並行せず、先にマージされた側へ rebase」としか定めていません。これはマージ競合回避であって、セキュリティ依存関係ではありません。
推奨順序は固定すべきです。
少なくとも create lane の allow 経路は、trusted policy 検証が成立するまで feature-disabled/fail-closed にする必要があります。
P2 High: 状態型変更なのに schema/consumer 変更として管理されていない
現行
PublishGuardContextは expected/current/declared/verified をすべて必須 SHA 文字列として持ち、loader も4フィールドすべてに40桁 SHAを要求しています。Issue #1449 はこれを
present | absent | communication_failureに変更するとしています。これは単なる内部リファクタリングではなく、以下に影響する契約変更です。一方で Stop Conditions は「固定契約のキー集合・スキーマ・型定義変更が必要なら停止」としています。さらに Allowed Paths に以下がありません。
最低でも次が必要です。
また、adapter コード変更が不要でも、real PreToolUse entrypoint の positive/negative test は必須です。親 Issue #1408 の実装も、実 hook entrypoint 経由の試験を安全性証跡として使用しています。
P2 High: Issue #1443 と実質的に重複している
Issue #1443 はすでに、branch-absent sentinel、initial publish decision、unit test、実 remote push の除外を定義しています。
現在の #1449 は「sentinel」を「3状態の明示型」と言い換えていますが、実 push integration とサーバ側 CAS を除外しているため、#1443 との差分がほぼありません。
次のどちらかに整理すべきです。
推奨: 実装: 初回 branch publish の remote branch 不在を fail-closed に扱う #1443 を 実装: publish laneに新規branch初回publish用のatomicなbranch作成laneを追加する #1449 に superseded として closeし、実装: publish laneに新規branch初回publish用のatomicなbranch作成laneを追加する #1449 が state model と server-side CAS の両方を担当する。
分割する場合:
現状のまま両 Issue を実装すると、同じ policy、hint、docs を別の意味論で並行変更します。
P2 High: 「policyがallowを返す」だけで postconditionを保証していない
現行 decision object は
postcondition="remote branch head == local_head"という文字列を返しますが、実際にその readback を実行する処理はありません。PreToolUse hook は command 実行前の認可しかできません。push 成功、部分的な transport failure、push 後の remote head は確認できません。
より堅牢な設計は、認可と実行を一つの trusted executor に閉じ込めることです。
GitHub 固有実装を許容するなら、GitHub REST API の Create a reference も代替です。この endpoint は ref 作成専用で、成功時201、競合・検証失敗時に409または422を返します。ただし Contents write permission、repository identity、GitHub依存が増えるため、現在の Git transport を維持するなら empty-expect lease の方が変更範囲は小さいです。([GitHub Docs]3)
親 publish lane に残る未解決事項
#1449 を修正しても、PR #1442 全体を merge-ready にはできません。
特に以下が残ります。
originの実 push URL/repository identity 未検証fetch_then_show_ref/github_branch_apiの真正性未確立SSOT は #360 の destination guard が適用される前提で説明していますが、Issue #360 自体は依然 open です。現行 shared policy も
remote == "origin"と active branch一致までしか検査していません。したがって #1449 の
Remaining Parent Gapsは「必要なら別途起票」では弱すぎます。具体的な follow-up Issue 番号と PR #1442 の merge dependency にする必要があります。修正版 Acceptance Criteria 案
最低でも以下へ差し替えるべきです。
最終判断
#1449 の方向性自体は妥当です。特に
present / absent / probe_errorの明示型と、create/update lane の分離は必要です。しかし、現状は 状態表現の改善を atomic publication と誤って呼んでいる 状態です。実装前に、次の4点を契約へ入れる必要があります。
これらが入るまでは、Issue contract を
goにせず、実装を開始しない方が安全です。fix: harden publish lane approval bridge against adversarial review f…
squne121 commentedon Jul 11, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jul 11, 2026
OWNER 裁定(Issue #1449 human_escalation の解消)
本コメントは
squne121(OWNER)による明示的な契約判断であり、issuecomment-4942738266(敵対的レビュー)で指摘された6件の意味論的contract品質blockerに対する裁定である。以降のrefinement / issue-authorはこの裁定を追加の人間承認なしで適用してよい。1. atomic create 方式
初回branch作成は
git push --force-with-lease=refs/heads/<active-branch>: origin HEAD:refs/heads/<active-branch>(empty-expect lease)のみを許可する、initial_branch_createlane 専用の単一ref・empty-expect CAS primitiveとして採用する。一般的なforce push許可ではない。他のforce/lease/強制更新形式(--force/-f/+refspec/引数なしlease/<refname>のみのlease/non-empty lease/複数lease/複数refspec/tag/--all/--mirror/--delete等)は引き続きすべてdenyする。Stop Conditionsの「force deny policy変更禁止」は「initial_branch_create laneの完全限定empty-expect leaseだけを例外として認め、それ以外のforce/lease/強制更新形式のdenyを変更してはならない」に置換する。
2. remote state model
remote branch状態は同一実行サイクル内のauthoritativeな
git ls-remote --refs --exit-codeのみを判定元とし、present/absent/probe_errorの排他的3状態に限定する。exit0かつ妥当OID取得はpresent、exit2かつ一致refなしはabsent、timeout/認証失敗/通信失敗/不正出力/その他非0はprobe_error(必ずfail-closed)とする。環境変数申告のabsentやGitHub REST API由来のラベルは初回作成の根拠として認めない。3. lane分離
existing_branch_updateとinitial_branch_createを別契約として扱う。initial_branch_createはlive probeがabsentの場合だけ候補になる。presentの場合はempty-expect leaseを試さずexisting_branch_updateへ送るか契約不一致としてdenyする。既存laneのfast-forward/head binding/Allowed Paths binding/canonical origin identity/default branch guardは弱めない。4. trusted execution boundary
初回作成はtrusted execution surfaceが (1)canonical repository identity確認 (2)active/target branch確認 (3)local/verified/declared head確認 (4)Allowed Paths gate確認 (5)live ls-remote probe (6)absent時のみempty-expect leaseをargv配列・shell=falseで実行 (7)push後の同一ref readback (8)readback headとlocal headの完全一致確認 (9)structured result生成 (10)不一致/失敗/競合時のfail-closed、を一連の処理として担当する。新しいexecutor fileは追加せず、#1450がpin対象とする既存ファイル(
scripts/agent-guards/git_mutation_command_policy.py、scripts/session-recording/codex-hook-adapter.mjs)内に実行面を置く設計を採用する。単一argv shapeをIssue本文で固定する。5. #1450との依存関係
blocked_by: ["#1450"]を明記する。実装開始条件は (a) PR #1442相当のpublish lane基盤がmainへ反映済み (b) #1450完了・policy/adapterのtrust boundaryがmainへ反映済み (c) #1449の実装branchはそのmainから作成 (d) #1450と#1449を共有ファイル上で並行実装しない、とする。refinementと契約更新は#1450完了前でも進めてよい。#1449自身のbootstrap branch publicationは既存privileged publication経路の責務であり、AC達成には数えない。6. #1443との関係
設計分割は採用しない。#1449が#1443をsupersedeする。#1449本文に
supersedes: #1443を記載し、#1443には統合理由をコメントしたうえでnot_planned相当でcloseする。7. Runtime Verification Applicability
decision: immediate、reason: ローカル一時bare Git repositoryで実Git transport・ref作成・競合拒否・post-push readbackをネットワークなしで検証できるため。実GitHub remoteへのpushはverificationに含めない。8. 必須テスト契約
敵対的レビューが提示したRevised AC1〜AC10相当(状態分類・CAS・race・readback・deny維持・実PreToolUse検証等、詳細は本文Acceptance Criteria参照)を最低ラインとして採用する。
9. Allowed Paths
scripts/agent-guards/git_mutation_command_policy.py、scripts/agent-guards/hook_repair_hints.py、scripts/agent-guards/tests/test_git_mutation_command_policy.py、scripts/agent-guards/tests/test_initial_branch_publish_policy.py(新規)、scripts/session-recording/codex-hook-adapter.mjs、tests/session_recording/codex/test_hook_adapter.py、docs/dev/session-recording-policy.md、docs/dev/workflow.md、docs/dev/hook-boundaries.md、docs/dev/agent-runtime-ops.mdを候補とする。新しいtop-level architecture layerや新executor fileは追加しない。10. Out of Scope
一般的なforce push許可、既存branchのnon-fast-forward更新許可、GitHub REST APIによるref作成、credential/OAuth/token scope変更、Codex/Claude runtime本体のpermission model変更、#1450の実装、bootstrap privileged publisherの実装、実GitHub remoteを使う自動verification、tag/delete/mirror/multi-ref publish、existing update laneの再設計。
以上を確定した契約判断としてrefinement loopおよびissue-authorへ適用する。empty-expect leaseの採否・#1450のblocked_by追加・#1443のsupersedeは、いずれも本コメントで決定済みであり、再度未解決の人間判断として提示しないこと。
squne121 commentedon Jul 11, 2026
Contract Review Result
squne121 commentedon Jul 11, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedfeat: PreToolUse remote_write_requires_approval を publish lane 証跡で通過可…
実装: implement-issue の Allowed Paths 重複を contract-aware preflight で判定する (
squne121 commentedon Jul 11, 2026
OWNER裁定(2026-07-12): Issue #1450/#1468 not_planned closureに伴うIssue #1449契約の更新
本コメントは既存OWNER裁定(本Issue issuecomment-4942998354)のうち、Issue #1450への依存およびexternal trust boundaryを前提にした部分のみを上書きする。atomic create方式、remote state分類、race対策、post-push readback、deny維持、Issue #1443のsupersedeに関する既存裁定は維持する。
not plannedではクローズしない。not_plannedで閉じられた(Issue 実装: publish laneのauthorization code(policy/adapter)の信頼境界をhash pinningでcandidate worktree外に確立する #1450: closedAt 2026-07-11T14:27:03Z、Issue 実装: publish lane trust root(#1454 Phase A)にnonce runtime state分離・trusted publisher wrapper・atomic rotation・worktree cwd解決・deployment attestationを追加する #1468: closedAt 2026-07-11T14:26:48Z)ため、Issue #1449のdependency・blocker・実装前提から除外する。b567c709c5baa1663d06338c7637a5b60a9c02a1により、scripts/trust-root/は削除済みである。これを復活・再実装・再配線しない。git_mutation_command_policy.pyとcodex-hook-adapter.mjs参照: Issue #1450 (CLOSED, NOT_PLANNED, 2026-07-11T14:27:03Z) / Issue #1468 (CLOSED, NOT_PLANNED, 2026-07-11T14:26:48Z) / commit b567c70 (PR #1471, merged 2026-07-11T15:13:43Z)。
squne121 commentedon Jul 12, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 12, 2026
Contract Review Result
feat: publish laneに新規branch初回publish用のatomicなbranch作成laneを追加する (#1449)
fix: PR #1479 レビュー指摘を解消する (E501 折り返し + node-backed collect-only 除外リスト修正)
squne121 commentedon Jul 12, 2026
Contract Review Result
実装: publish laneに新規branch初回publish用のatomicなbranch作成laneを追加する (#1479)
実装: linked issue worktree の verified fast-forward を RTK guard で許可する (#…
実装: linked issue worktree の verified fast-forward を RTK guard で許可する (#…