Skip to content

実装: 回帰テスト: CLOSED native predecessor の候補外 hydration/readback 経路を固定する #1766

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
change_kind: test

Parent Issue

なし(#1677 実装中に発見した独立の回帰テスト follow-up)

Parent Goal Ref

  • Goal: current native blockedBy predecessor の CLOSED 本文 hydration/readback 経路を、候補プール外のケースを含めて回帰テストで固定する。

Current Validated Scope

  • .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py のみ。

Remaining Parent Gaps

  • なし(production script の変更は本 Issue の対象外)。

Outcome

current native blockedBy の CLOSED predecessor が初期 candidate pool 外でも個別 fetch され、exact ## Outcome / ## In Scope の本文を readback し、C2a 証跡で継続可能な proceed_with_collision_evidence route になる回帰を、単一の恒久 pytest で固定する。

In Scope

  • .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py に、候補プール外の CLOSED native predecessor を fetch_predecessor_issue() で hydration し、本文 readback と C2a route を検証する回帰テストを追加する。

Out of Scope

  • production script、schema、hook、runner、permission profile の変更。
  • overlap route semantics、native dependency parser、既存 fixture の変更。
  • supersedes / depends_on の関係追加または変更。

Acceptance Criteria

  • AC1: 作成予定 nodeid test_check_implementation_overlap_native_dependencies.py::test_given_closed_native_predecessor_outside_candidate_pool_when_fetched_then_readback_is_complete が、初期 candidate pool 外の CLOSED native predecessor を入力に含め、fetch_predecessor_issue() の呼出しを経て個別 hydration することを固定する。
  • AC2: 同 nodeid の検証で readback_complete: true、reasons closed_predecessor_via_blocked_by と readback_confirmed_disjoint、missing reason なし、route proceed_with_collision_evidence、exit code 0 を確認すること。
  • AC3: 作成予定テストの実装で production script/schema/hook/runner/permission profile を変更せず、許可されたテストファイルだけを変更すること。

Verification Commands

# AC1
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py -q

# AC2
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py -q

# AC3
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py -q

Allowed Paths

  • .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • production script/schema/hook/runner/permission profile の変更、または route semantics の変更が必要になった場合

Required Skills

なし

Required Design References

  • .claude/skills/implement-issue/SKILL.md(overlap preflight と回帰テストの契約)
  • .claude/skills/create-issue/scripts/check_issue_overlap.py

Scope Delta(任意)

N/A(production 実装から test-only 回帰契約へ再定義)。

Runtime Verification Applicability

decision: not_applicable
reason: "pytest regression test only; no runtime game behavior changed."

Delivery Rule

  • 1 Issue = 1 PR
  • 作業は isolation worktree で行う
  • Draft PR を既定とする

Notes for Reviewer

  • Owner approved degraded mode: scope_rollup の runner_unavailable / deferred は記録のみとし、実装準備を停止しない。ただし marker / evidence / profile / hook は変更しない。
  • CLOSED native predecessor の candidate-pool 外 hydration/readback を online mock fetch 経路で固定する test-only 契約であり、production readback 追加を前提にしない。

Activity

  1. added
    enhancement
    phase/implementation
    on Jul 25, 2026
  2. squne121 commented on Jul 26, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — 現状の Issue #1766 は、そのまま実装へ渡せません。

    主な理由は、「不足している」とされる処理が現在の main には既に存在することと、根拠に使われた #666 / #667 の読解が誤っていることです。現在の契約のまま実装すると、既存処理を無意味に再構成するか、depends_on・supersedes の意味まで誤って拡張する可能性があります。

    実行可能な失敗再現が得られない限り、Issue は not planned で閉じるか、実装 Issue ではなく再現・回帰テスト Issue に書き換えるべきです。

    P0 — 実装着手を阻害する問題

    P0-1. Issue が要求する経路は、ソース上すでに実装されている

    現在の処理は次の流れになっています。

    1. OPEN implementation Issue を候補として取得する。
    2. current Issue の dependency が候補プールに存在しなければ、fetch_predecessor_issue() で個別取得する。
    3. 取得した predecessor を candidates_raw に追加する。
    4. CLOSED predecessor を readback_targets に追加する。
    5. 通常の overlap candidate と同じ _readback_candidate() に渡す。

    implement-issue/SKILL.md 自体も、OPEN 一覧にない predecessor は個別 readback し、その後 ## Outcome / ## In Scope を読む契約だと明記しています。

    実装本体でも、候補プールにない dependency に対して fetch_predecessor_issue() を呼び、返された本文を candidates_raw に追加しています。 その後、CLOSED predecessor を readback 対象に加え、通常候補と同じ _readback_candidate() を実行しています。

    したがって、AC1とAC2は現在のソースを修正前後で区別できません。PR #1455 の実装履歴にも、候補プール外の CLOSED predecessor を readback 対象にする処理が既に導入されたと記録されています。

    必要なのは「この経路を追加すること」ではなく、まず以下のいずれかを証明することです。

    • 現在の main でも個別 fetch が実行されない
    • fetch は成功するが candidates_raw への反映が失われる
    • 本文は存在するが、後段で空文字へ置換される
    • 観測時に古いブランチまたは古いスクリプトが実行されていた

    P0-2. #666 / #667 に関する根拠が事実と一致しない

    Issue #1766 の Notes は、#666 / #667 が実際には ## Outcome を持つため incomplete 判定が誤りだとしています。

    しかし、両 Issue の見出しは次の形です。

    • ## 達成目標(Outcome)
    • ## 受け入れ条件
    • ## Allowed Paths

    厳密な ## Outcome はなく、## In Scope もありません。

    現在の _extract_section() は完全一致する ## Outcome / ## In Scope を要求し、どちらかが空なら readback incomplete を返します。

    したがって、#666 / #667 の incomplete 判定は取得漏れではなく、現在の見出し契約どおりの正しい結果です。この2件を根本原因の証拠として扱うことはできません。

    #1675 は正確な ## Outcome / ## In Scope を持つため、こちらだけは有効な再現候補です。

    P0-3. 現在の main に対する red reproducer がない

    Issue本文には次がありません。

    Issueコメントもありません。

    一方、PR #1767 は同じ診断を根拠に hard gate を手動迂回しています。 しかし、その診断を再現できる機械可読artifactが #1766 に移されていません。再現不能な診断に基づいて安全ゲートを変更するのは危険です。

    最低限、修正前の現在の main で次が失敗するテストが必要です。

    native blockedBy:
      current: OPEN #1677相当
      predecessor: CLOSED #1675相当
      predecessor body:
        ## Outcome
        ...
        ## In Scope
        ...
    expected:
      readback_complete: true
    actual before fix:
      readback_complete: false
    

    この red test が作れない場合、Issueの前提が誤っています。

    P0-4. blocked_by、depends_on、supersedes の意味が混同されている

    Issueは「blocked_by / depends_on / supersedes の native/legacy 解析で発見した Issue」を同一の dependency 解決経路として扱っています。

    しかし現実の実装は異なります。

    • native dependencyとして統合されるのは blockedBy

    • legacy本文から読むのは Depends on #N

    • depends_on / supersedes はMachine-Readable Contract内の値

    • predecessorのOPEN/CLOSED解決に渡されるのは、実質的に _merge_dependency_refs(..., "blocked_by") の結果

    • supersedes は主にcollision/supersession signalであり、OPEN/CLOSED predecessorの待機判定ではない

    このまま実装すると、supersedes を「完了待ちdependency」として扱うなど、Out of Scope としている route semantics の実質変更につながり得ます。

    Issue本文は少なくとも次に限定すべきです。

    current Issue の blocked_by、legacy Depends on #N、またはGitHub native blockedBy から特定された同一repositoryのpredecessor

    P1 — 設計上の重大問題

    P1-1. 修正対象は「readback関数」ではなく「Issue snapshot hydration」である

    通常候補とCLOSED predecessorは、すでに同じ _readback_candidate() を通ります。したがって「同一のreadback関数に統合する」という解決策は根本原因と一致しません。

    再現する場合、疑うべき境界は以下です。

    • dependency recordからIssue番号を抽出する段階
    • 個別Issue取得
    • REST/CLIレスポンスの正規化
    • candidates_raw への追加
    • candidate_bodies / candidate_contracts 構築
    • 2回目のnative dependency hydration後の再分類

    推奨する抽象は、取得元に依存しない正規化snapshotです。

    @dataclass(frozen=True)
    class IssueSnapshot:
        repository: str
        number: int
        state: str
        title: str
        body: str
        updated_at: str
        url: str
        labels: tuple[str, ...]
        source: str  # graphql_candidate | dependency_rest | issue_get

    GraphQL候補、dependency REST、個別Issue取得をこの形へ正規化してから、schema validationとreadbackへ一度だけ渡すべきです。

    P1-2. dependency APIレスポンスの情報を捨てて再取得している

    GitHubのIssue Dependencies REST APIは、dependency先のIssue情報を返し、公式レスポンス例には本文を含むIssue snapshotが示されています。([GitHub Docs]1)

    現在のコードはdependencyレスポンスを {repository, number, state} に縮退させ、その後 gh issue view で本文を再取得します。

    これは以下を増やします。

    • 追加API呼び出し
    • rate limit消費
    • 1回目と2回目の間のTOCTOU
    • dependency endpoint成功後に個別fetchだけ失敗する可能性
    • 取得元によるフィールド名差異

    改善案は次のいずれかです。

    1. dependency RESTレスポンスのbodyを正規化snapshotへ保持する
    2. bodyが欠落する場合だけ、versioned RESTのGet issueへfallbackする
    3. fallbackの発生理由をevidenceへ残す

    RESTレスポンスの updated_at / html_url と、現在の内部形である updatedAt / url の差異は、専用normalizerで吸収する必要があります。

    P1-3. 取得失敗の原因が None に潰される

    fetch_predecessor_issue() は、タイムアウト、認証失敗、CLI失敗、不正JSONなどをすべて捕捉して None を返します。

    結果として、次が区別できません。

    • Issueが存在しない
    • repository移転
    • 権限不足
    • rate limit
    • network timeout
    • JSON破損
    • body欠落

    最終的にはfail-closedになるものの、今回のような誤診断を誘発します。少なくとも次のtyped resultが必要です。

    IssueFetchResult(
        snapshot=None,
        status="not_found | permission_denied | timeout | malformed | body_missing",
    )

    または OverlapRuntimeError を保持したまま、dependency_resolution.fetch_errors に構造化して出力すべきです。

    P1-4. GitHub CLIに関するコードコメントとテストが現在の仕様からずれている

    現在のGitHub CLIマニュアルでは、gh issue view --json と gh issue list --json の利用可能フィールドに blockedBy / blocking が掲載されています。(GitHub CLI)

    一方、既存テストはこれらを「未対応フィールド」として扱っています。

    ただし、ここから直ちにREST経路をCLI経路へ置き換えるべきではありません。versioned REST APIは X-GitHub-Api-Version により契約を固定でき、現在コードが指定する 2026-03-10 はGitHubが提供しているAPI versionです。([GitHub Docs]3)

    妥当な対応は次です。

    • production経路はversioned RESTのまま維持
    • 「CLIでは取得不能」という誤ったコメントを修正
    • static testを「productionコードがCLIフィールドへ依存しない」に改める
    • CLI経路を使う場合は最低対応バージョンを明記する

    P2 — テスト・契約の不足

    P2-1. 見出し互換性と取得不具合を分離すべき

    #666 / #667 のような ## 達成目標(Outcome) を ## Outcome と同一視するかは、fetchの問題ではなくIssue contract migration policyです。

    本Issueでは見出しaliasを追加してはいけません。追加すると、本当に ## In Scope を欠くlegacy Issueまでcomplete扱いする危険があります。

    必要なnegative testは以下です。

    • exact ## Outcome + exact ## In Scope → complete
    • localized Outcomeだけ → incomplete
    • OutcomeだけでIn Scopeなし → incomplete
    • 空セクション → incomplete
    • HTML commentだけのセクション → incomplete

    P2-2. Verification Commandsが狭すぎる

    提示されているVerification Commandは新規テストファイル1本だけです。

    この変更はnative dependency、candidate collection、evidence digest、open-pr hard gateに影響するため、最低でも以下が必要です。

    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap_dependency_readback.py \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap.py \
      -q
    
    uv run --locked pytest \
      .claude/skills/open-pr/scripts/tests/test_open_pr_overlap_gate.py \
      .claude/skills/open-pr/scripts/tests/test_open_pr_contract_bound_waiver.py \
      -q
    
    uv run --locked ruff check \
      .claude/skills/implement-issue/scripts/check_implementation_overlap.py \
      .claude/skills/implement-issue/tests/

    推奨するIssue再定義

    推奨タイトル

    調査・回帰: native CLOSED predecessor のIssue snapshot hydrationを現在のmainで再現し、取得元間の正規化を統一する

    必須Acceptance Criteria

    AC0 — red reproducer

    現在の main、固定fixture、記録されたツールバージョンで、#1675相当のCLOSED native predecessorが誤ってincompleteになることを修正前に再現する。再現しない場合は not planned で終了する。

    AC1 — snapshot normalization

    GraphQL candidate、dependency REST、個別Issue fetchが同一の正規化Issue snapshotを生成する。

    AC2 — positive regression

    CLOSED predecessor本文に正確な ## Outcome / ## In Scope がある場合、以下を満たす。

    readback_complete: true
    reasons:
      - closed_predecessor_via_blocked_by
      - readback_confirmed_disjoint

    AC3 — negative regression

    本文に正確な見出しが欠ける場合、従来どおり以下を維持する。

    readback_complete: false
    reasons:
      - readback_incomplete_missing_outcome_or_in_scope
    route: human_review_required

    AC4 — fetch failure taxonomy

    404、権限不足、timeout、不正JSON、body欠落を区別し、いずれもfail-closedかつ原因をevidenceに残す。

    AC5 — repository binding

    取得したsnapshotのrepositoryとIssue番号をcanonical targetへ束縛し、cross-repository dependencyをローカルIssueへ誤結合しない。

    AC6 — no semantic expansion

    supersedes やsuccessor relationをpredecessor完了待ちへ変換せず、既存route tableを変更しない。

    最終提言

    現時点の最善策は次です。

    1. Issue #1766を実装開始しない
    2. 実装: plan_refinement_loop の _extract_missing_contract_keys を PyYAML 不在時に fail-closed にする(#661 follow-up) #666 / 実装: plan_refinement_loop の fail_closed reason code exhaustiveness invariant をテストする(#661 follow-up) #667 に関する誤った根拠を削除する
    3. PR #1767実行時の完全なpreflight evidenceと実行commitを回収する
    4. 現在のmainに対する固定fixtureのred testを先に作る
    5. 再現できなければ not planned で閉じる
    6. 再現できた場合だけ、対象を「readback追加」ではなく「snapshot hydration/normalization修正」に限定する

    今回の確認はGitHub上の現在のソース、Issue、PR、コメント、公式仕様に基づく静的レビューです。ローカルcheckout上でpreflightやpytestを実行した再現確認は行っていません。

  3. squne121 commented on Jul 26, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "scope_rollup.run の runner が利用不可: pinned Codex session の effective permission profile が loop-protocol-scope-rollup ではない"
    
    "scope-rollup runtime evidence が SKIP のため、現行 Issue body と anchor comment の executor binding を検証できない"
    
    "ISSUE_EXECUTION_DECISION_V1 が scope rollup evidence incomplete により deferred であり、下流での semantic reclassification は禁止される"
    
  4. squne121 commented on Jul 26, 2026

    @squne121
    OwnerAuthor

    判定

    現状の Issue #1766 は、production code の修正 Issue としては REQUEST_CHANGES です。
    ただし、停止理由は scope-rollup の permission profile 不足ではありません。そこは回避可能です。真の問題は、Issue が要求している処理が現在の main に既に存在し、修正前に失敗する再現テストがないことです。

    runner_unavailable の意味

    scope-rollup-runner は、関連 Issue・PR の統合候補を調べる読み取り専用の補助 runnerです。loop-protocol-scope-rollup は、この専用 runner に設定されたリポジトリ独自の permission profile であり、実装対象コードを編集するための権限ではありません。

    さらに impl-review-loop の手順では、正しく形成された runner_unavailable は decision: deferred として扱えます。そして、その決定を記録した後は Step 3 の worktree 作成へ進むと明記されています。前回のエージェントは、ここを必要以上に強く解釈して停止しています。

    リポジトリ自身も、hook と permission profile を「fail-closed なローカルガードレール」であり、セキュリティ境界ではないと定義しています。個人趣味開発でこの runner のために新しい permission profile、hook、capture sidecar、専用実行基盤を実装する必要はありません。

    敵対的レビュー

    P0-1: Issue が要求する処理は既に存在する

    現在のコードは、OPEN candidate 一覧に predecessor が存在しない場合に、fetch_predecessor_issue() で本文を含む Issue を取得し、candidates_raw に追加しています。

    fetch_predecessor_issue() 自体も body を含む gh issue view の結果を返します。

    追加された predecessor は、他の candidate と同じ _readback_candidate() を通り、厳密な ## Outcome と ## In Scope が検査されます。

    したがって、現行 AC1・AC2 は修正前後を区別できません。

    P0-2: #666 / #667 の根拠が誤っている

    Issue #1766 は、#666 / #667 に ## Outcome が存在するとしています。しかし実際の見出しは、両方とも ## 達成目標(Outcome) です。また、## In Scope はありません。厳密な見出し契約では incomplete 判定が正しい挙動です。

    #1675 は正確な ## Outcome と ## In Scope を持つため、再現対象として使えるのはこちらだけです。

    P0-3: red reproducer がない

    現在の Verification Commands はすべて baseline-expect: pass です。既存テストが通ることを確認しているだけで、「修正前は失敗し、修正後に成功する」という証拠になっていません。Issue contract review が go になったことも、バグの存在を証明しません。

    P0-4: PR #1767 の診断は現在のコードと矛盾する

    PR #1767 は「CLOSED native predecessor の本文取得経路がない」と説明して #1766 を起票しました。

    しかし現在の main にはその取得経路があります。考えられるのは、PR #1767 実装時に古い branch、古い blob、別 worktree、または古いスクリプトを実行していたことです。

    P1: 実在するが別 Issue にすべき技術的改善

    現在の GitHub CLI では、gh issue view --json と gh issue list --json の両方が blockedBy と blocking をサポートしています。そのため、既存テスト内の「未対応フィールド」という説明は現在の仕様と一致しません。(GitHub CLI)

    また、GitHub の Issue Dependencies REST API は、標準レスポンスで raw Markdown の body を返せます。現在のコードは dependency レスポンスを {repository, number, state} に縮退させてから本文を再取得しており、追加 API 呼び出しが発生します。これは改善候補ですが、#1766 のバグが再現しない限り、本 Issue に混ぜるべきではありません。([GitHub Docs]2)

    推奨方針

    最小で有用な着地点は次のどちらかです。

    1. 現在の main で一時的な end-to-end reproducer が成功する場合
      → production code は変更せず、欠けている回帰テストだけを追加する。既に同等テストがあれば 実装: 回帰テスト: CLOSED native predecessor の候補外 hydration/readback 経路を固定する #1766 を not planned で閉じる。

    2. reproducer が本当に失敗する場合
      → 失敗地点だけを最小修正する。新しい snapshot abstraction、permission profile、scope-rollup runner、schema、hook は作らない。

    以下を Claude Code / Codex CLI にそのまま渡してください。

    リポジトリ squne121/loop-protocol の Issue #1766 を対象に、以下の owner 指示に従って、調査・必要最小限の実装・テスト・Draft PR 作成または Issue クローズまで人間承認なしで進めてください。

    目的

    Issue #1766 の「CLOSED native predecessor の本文が readback されず、readback_incomplete_missing_outcome_or_in_scope になる」という前提を、現在の main に固定した再現テストで検証する。

    重い商用品質向けの制御基盤を追加することが目的ではない。個人趣味開発として、既存コードと小規模な pytest で検証できる最小解を採用する。

    owner による degraded-mode 承認

    今回の作業に限り、scope-rollup-runner が以下の理由で利用できなくても実装準備を停止しない。

    • effective permission profile が loop-protocol-scope-rollup ではない
    • scope_rollup.run が runner_unavailable
    • scope rollup decision が deferred

    この状態については、次のように処理する。

    1. marker や permission evidence を捏造しない。
    2. permission profile、hook、SubagentStop capture、scope-rollup runner、execution-decision schemaを変更しない。
    3. runner_unavailable を deferred として作業ログへ記録する。
    4. .claude/skills/impl-review-loop/steps/preparation.md の deferred handling に従い、軽量な代替衝突確認後に worktree 作成へ進む。
    5. runner_unavailable だけを理由に human escalation しない。

    これは secret、認証、破壊的操作、外部課金、GitHub 書込み権限不足を無視する指示ではない。

    最初に読むもの

    最低限、次を確認する。

    古い作業ログの診断を事実として採用せず、現在の main の blob と実行結果を正本にする。

    軽量な衝突確認

    enterprise-grade な scope-rollup の代わりに、次だけを read-only で確認する。

    対象パス:

    • .claude/skills/implement-issue/scripts/check_implementation_overlap.py
    • .claude/skills/implement-issue/tests/

    可能ならリポジトリ既存の git_ref_probe.py / git_worktree_probe.py を使う。

    同一ファイルを実際に変更中の OPEN PR または active worktree が存在する場合だけ停止する。単に同じ skill family、同じ語彙、同じ Allowed Paths を持つ Issue が存在するだけでは停止しない。

    検証仮説

    現在の main には、次の処理が既に存在する可能性が高い。

    1. current Issue の native blockedBy から CLOSED predecessor を特定する。
    2. OPEN candidate pool にない predecessor を fetch_predecessor_issue() で取得する。
      3.取得結果を candidates_raw に追加する。
    3. predecessor の本文を _readback_candidate() に渡す。
    4. exact ## Outcome と exact ## In Scope が存在すれば readback complete とする。

    この仮説をコード読解だけで確定せず、実行可能なテストで検証する。

    一時 reproducer

    tracked file を変更する前に、tmp/issue-1766-reproducer/ 配下へ一時 pytest を作成する。

    次の fixture を完全に mock し、ネットワークには依存させない。

    current Issue

    • OPEN
    • blockedBy に同一 repository の CLOSED predecessor を1件持つ
    • predecessor と重複する Allowed Path を持つ
    • exact ## Outcome
    • exact ## In Scope

    predecessor

    • CLOSED
    • initial OPEN candidate list には含めない
    • fetch_predecessor_issue() から本文付きで返す
    • exact ## Outcome
    • exact ## In Scope
    • current と Allowed Paths は重複する
    • Outcome と In Scope の意味は current と明確に disjoint にする
    • inline-code edit target、AC ID、output schema、goal_ref が current と衝突しないようにする

    期待値

    • fetch_predecessor_issue() が CLOSED predecessor 番号で呼ばれる
    • predecessor が readback candidate になる
    • readback_complete == true
    • reasons に closed_predecessor_via_blocked_by が含まれる
    • reasons に readback_confirmed_disjoint が含まれる
    • reasons に readback_incomplete_missing_outcome_or_in_scope が含まれない
    • route が proceed_with_collision_evidence
    • exit code が 0

    現在の main そのままで一時 reproducer を実行し、結果と対象 SHA を保存する。

    分岐 A: reproducer が修正前から PASS

    この場合、Issue #1766 の production bug 前提は否定されたものとして扱う。

    1. production script を変更しない。

    2. .claude/skills/implement-issue/tests/ 内に同等の end-to-end 回帰テストが既に存在するか検索する。

    3. 同等テストが存在しない場合:

    4. 同等の end-to-end テストが既に存在する場合:

    5. PRを作らない経路でも、判断根拠を機械的に再実行可能な形で残す。

    分岐 B: reproducer が修正前に FAIL

    失敗地点を特定し、次の制約で最小修正する。

    • Allowed Paths 内のみ変更する。
      -既存の fetch_predecessor_issue()、candidates_raw、readback_targets、_readback_candidate() を再利用する。
    • 新しい大規模 abstraction や汎用 framework を導入しない。
    • IssueSnapshot 階層、追加 schema、permission profile、runner、hook、subagent、control-plane artifact chainを新設しない。
    • blocked_by、legacy Depends on #N、GitHub native blockedBy の current predecessor 経路だけを対象とする。
    • supersedes を完了待ち dependency として扱わない。
    • localized heading alias を追加しない。
    • exact ## Outcome / exact ## In Scope の fail-closed 契約を維持する。
    • route enumやopen-pr waiver semanticsを変更しない。

    最初に失敗する tracked regression test を追加し、その後、テストを通すために必要な最小コードだけを変更する。

    GitHub API / CLI に関する境界

    現在の GitHub CLI が blockedBy / blocking JSON field をサポートするか、ローカルの gh --version と公式マニュアルで確認する。

    ただし、確認できても本 Issue 内で REST 経路をCLI経路へ全面移行しない。

    Issue Dependencies REST response の body を直接保持する最適化も、reproducer の修正に必要でない限り実装しない。追加 API 呼び出し削減や typed fetch error は別の小規模 follow-up 候補として報告するだけにする。

    既存テストに「CLIでは blockedBy / blocking が未対応」と断定する古いコメントがあり、現在の仕様と矛盾する場合は、production経路を変更せず、コメントまたはテスト名を「productionコードがCLI固有fieldへ依存しないことの確認」へ修正してよい。

    検証

    最低限、以下を実行する。

    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py \
      -q
    
    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap.py \
      -q
    
    uv run --locked ruff check \
      .claude/skills/implement-issue/scripts/check_implementation_overlap.py \
      .claude/skills/implement-issue/tests/

    変更が test-only なら、ゲームの pnpm build、全リポジトリ pytest、ブラウザplaytestは実行不要。

    production script を変更した場合だけ、影響する open-pr overlap gate の狭いテストを追加実行する。無関係な全スイート実行を完了条件にしない。

    Git / PR

    変更が必要な場合:

    1. isolation worktree と専用 branch を使う。
      2.対象 Issue の Allowed Paths 内だけを commit する。

    2. Draft PR を作成する。

    3. PR本文に以下を記載する。

      • pinned base SHA
      • temporary reproducer の修正前結果
      • production code変更の有無
      • scope-rollup runner_unavailable を owner-approved deferred として処理したこと
        -実行したテストと結果
      • Closes #1766
    4. CI、review comment、requested changes があれば、同じ最小スコープで対応する。

    5. merge は要求しない。Draft PR 作成とCI結果確認まで行う。

    禁止事項

    ##停止条件

    次の場合だけ停止し、具体的証拠を提示する。

    -秘密情報へのアクセスが必要
    -破壊的操作が必要
    -外部課金が必要
    -GitHubまたはrepositoryの必須権限がない
    -対象ファイルを実際に変更中のOPEN PR / active worktreeとの競合がある
    -最小修正がAllowed Paths外のproduction fileを必須とする
    -再現結果がroute semanticsまたはsecurity/secret policy変更を要求する
    -リモートのIssue本文やhead SHAが作業中に変化し、判断根拠がstaleになった

    scope-rollup runner_unavailable、permission profile名の不一致、専用SubAgentを起動できないことだけでは停止しない。

    ##最終報告

    次を簡潔に報告する。

    • pinned main SHA
    • reproducer の修正前結果
    • Issue前提が成立したか
    • production code変更の有無
      -追加・変更したテスト
    • Issueを再定義したか、not plannedで閉じたか、Draft PRを作成したか
    • PR番号
      -検証コマンドと結果
      -残る技術的負債
      -停止条件の発生有無

    このプロンプトは、専用 runner を弱体化したり偽装したりせず、その runner を今回の実装開始条件から外す構成です。Claude Code と Codex CLI の両方で使用できます。

  5. changed the title [-]実装: check_implementation_overlap.py が dependency 解決経路の CLOSED predecessor 本文を readback 対象に含めるようにする[/-] [+]回帰テスト: CLOSED native predecessor の候補外 hydration/readback 経路を固定する[/+] on Jul 26, 2026
  6. squne121 commented on Jul 26, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-26T23:23:36Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1766
      body_sha256: "sha256:812e18f5a52097c1b2263aab422962559528bc951c7af0214b74879eb799091a"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:812e18f5a52097c1b2263aab422962559528bc951c7af0214b74879eb799091a","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":3,"raw_command":"uv run --locked pytest .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py -q","command_hash":"sha256:e6bda61e188ee94989e1f6e4d01fe08aee64e88055c8a204ec4f0ca4e1cf12e4","execution_key_hash":"sha256:1f815a6441b70fcaa7ef98f6fe17ca38b7629eded8a2f1714536f6ec539b5266","runner":"exec","exit_code":0,"classification":"expected_pass","category":"baseline_expect_pass","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["...............................................                          [100%]","47 passed in 4.58s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":4758,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"pass","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: pass"},"strict":null,"repair":null},{"ac":"AC2","line":7,"raw_command":"uv run --locked pytest .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py -q","command_hash":"sha256:e6bda61e188ee94989e1f6e4d01fe08aee64e88055c8a204ec4f0ca4e1cf12e4","execution_key_hash":"sha256:a855f168ec331f49b690f6a76c0748cbd6d416648c4bc4e0e4d004737438bd24","runner":"exec","exit_code":0,"classification":"expected_pass","category":"baseline_expect_pass","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["...............................................                          [100%]","47 passed in 4.43s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":4603,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"pass","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":6,"raw":"# baseline-expect: pass"},"strict":null,"repair":null},{"ac":"AC3","line":11,"raw_command":"uv run --locked pytest .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py -q","command_hash":"sha256:e6bda61e188ee94989e1f6e4d01fe08aee64e88055c8a204ec4f0ca4e1cf12e4","execution_key_hash":"sha256:e084ea84054fa1ed18a537fa1da6d959cd511e16e7d84a63ee598b151e669565","runner":"exec","exit_code":0,"classification":"expected_pass","category":"baseline_expect_pass","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["...............................................                          [100%]","47 passed in 4.61s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":4785,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"pass","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":10,"raw":"# baseline-expect: pass"},"strict":null,"repair":null}]
        declared_path_overlap: {"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"ea93bcd0fd358a033cbee96278f5e7bd3d882319","draft_policy":"include_drafts","prs":[{"number":1528,"title":"feat(cleanup): 同一実行内の branch-only fallback を追加","base_ref_name":"main","head_ref_name":"worktree-issue-1403-post-merge-cleanup-dedicated-branch-forc","head_ref_oid":"b29007580ae225eb9676c7f32c878ee2bb9ccaa9","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1528","changed_files_count_graphql":4},{"number":1813,"title":"実装: VRT CI evidence matrix と artifact validator を capture 単位に拡張する (#1387)","base_ref_name":"main","head_ref_name":"worktree-issue-1387-vrt-active-capture-evidence-matrix","head_ref_oid":"ca26eecf93673f01db00a9a41ec19961047bbbca","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1813","changed_files_count_graphql":5}],"fetched_count":2,"totalCount":2,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:d76c48ebd77bb47518e141b4b2ff411c03987ad0e671a1b102cb36439a9c0018","errors":[]},"inventory_digest_extended":"sha256:5d2ff26fb9eeadfbe4c4c5af8bc4b6dfd9a093dc34b7505d9ca4e03a1ac0e8d6","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: {"issue_number":1766,"contract_source_kind":"issue_comment","contract_source_id":"5085894589","contract_body_sha256":"sha256:812e18f5a52097c1b2263aab422962559528bc951c7af0214b74879eb799091a","allowed_paths_normalized_sha256":"ea18c804ffbac8acd19cdaef88c2c1580c3eedb5a393a4f5347e8a0ec4b624ad","base_ref":"main","base_sha_at_snapshot":"ea93bcd0fd358a033cbee96278f5e7bd3d882319"}
  7. squne121 commented on Jul 27, 2026

    @squne121
    OwnerAuthor

    結論

    remote_write_requires_approval は、Codex CLI が標準で返している固有エラー名ではありません。loop-protocol の scripts/session-recording/codex-hook-adapter.mjs が生成しているリポジトリ固有の reason_code です。

    Codex CLI 本体が提供しているのは PreToolUse、PermissionRequest、承認ポリシーなどの仕組みです。リポジトリ側は、その仕組みに独自の publish 制約を実装しています。公式仕様上、PermissionRequest が判断しなければ通常の承認フローへ戻りますが、PreToolUse はツール呼び出し自体を deny できます。 ([OpenAI Developers]1)

    このリポジトリでは、remote write を検出すると一旦 no_decision / remote_write_requires_approval を生成し、PreToolUse では no_decision も含めて deny に変換しています。一方、PermissionRequest では何も返さず通常の承認フローへ委譲します。つまり今回のケースは、PermissionRequest に到達する前に PreToolUse で止まっています。

    責任境界

    • Codex CLI仕様:Hook と承認フローを提供する。
    • リポジトリ制約:remote write を分類し、専用 publish lane 以外を PreToolUse で拒否する。
    • GitHub権限:今回のログだけでは未検証。実際の push が GitHub に到達して、認証エラーや403を返した証拠はありません。

    したがって、作業ログの「GitHub branch 公開権限の gate」という診断は不正確です。正しくは、リポジトリの publish-lane classifier が専用経路へ分類できず、generic remote-write deny にフォールバックした可能性が高い、です。

    敵対的レビュー

    P0-1:GitHub権限不足という結論は証拠不足

    ログでは commit af55232f010610a9ce9d29d66c59a119d602c61d まで作成されていますが、その後は PreToolUse hook で止まっています。GitHubへの実 push、GitHubの拒否応答、gh auth status の失敗は記録されていません。

    認証確認には gh auth status --active --hostname github.com が使えますが、これは今回実行されていません。 ([GitHub CLI]2)

    P0-2:初回 branch publish の専用経路に入っていない

    PR #1479 では、新規 branch の初回 publish は次のように実装済みです。

    1. branch、HEAD、remote、Allowed Paths を検証する。
    2. remote ref が存在しないことを probe する。
    3. empty-expect lease で push する。
    4. remote ref を readback する。
    5. raw shell command は必ず deny し、二重 push を防ぐ。

    PR #1479 は merge 済みです。

    現在の production code も、実際の push は execute_initial_branch_create_transaction() 内で行い、処理後は initial_branch_create_transaction_result を返す設計です。

    今回返ったのはそれではなく generic remote_write_requires_approval です。したがって、以下のどれかです。

    • command shape が専用 lane と一致していない。
    • active branch、HEAD、Allowed Paths の context が hook に渡っていない。
    • policy subprocess が失敗、または不正JSONを返した。
    • classifyRtkGitPushPublishLane() が null を返し、generic denyへフォールバックした。

    P0-3:inline環境変数は承認contextにならない

    ログの再試行コマンドは、概ね次の形です。

    LOOP_PUBLISH_DECLARED_PUBLISH_HEAD=... LOOP_... rtk git push ...
    

    しかし PreToolUse hook は、そのshell commandが実行される前に別プロセスとして動きます。コマンド文字列先頭の環境変数代入は、hookプロセスの process.env/os.environ には入りません。

    さらに open Issue #1688 は、terminal command の env VAR=... prefixだけでは context injection を模倣できないことを明示的に要求しています。

    したがって、inline環境変数を増やして再試行しても解除にはなりません。必要なのは、リポジトリが認可した wrapper または runtime context injection です。

    P1-1:#1766の実装作業自体はほぼ完了

    最新main上でも一時 reproducer は PASSし、production bug の前提は否定されています。恒久回帰テスト追加後は、48件・56件のpytestとRuffがPASSし、許可されたテストファイルだけを含むcommitも作成済みです。

    次のセッションで再実装するべきではありません。まず既存worktreeとcommitを回収し、必要なら新mainへ移植するべきです。

    P1-2:#1766にhook修正を混ぜてはいけない

    現在の #1766 は test-only 契約で、Allowed Paths はテストファイル1件だけです。production script、hook、permission profile の変更は明確にOut of Scopeです。

    publish laneの不具合を直す場合は、別Issue・別worktree・別PRが必要です。

    P1-3:Verification Commandsが弱い

    #1766 のAC1〜AC3は同じテストファイル全体を3回実行しています。変更後には通りますが、新規nodeidの存在と挙動を直接証明するVCではありません。

    PR本文では少なくとも、新規nodeidを指定したテストも追加実行すべきです。

    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py \
      -k test_given_closed_native_predecessor_outside_candidate_pool_when_fetched_then_readback_is_complete \
      -q

    解除・解消方法

    推奨:専用publish laneを正常に通す

    .codex/config.toml は既に approval_policy = "on-request" で、GitHubへのネットワークも許可されています。.codex/rules/default.rules も rtk git push origin ... を静的にはallowしています。

    したがって変更すべきなのはapproval policyではなく、次のいずれかです。

    1. 正しいcontrolled publisher/context injectorを使う。
    2. initial-branch classifierがgeneric fallbackする原因を修正する。
    3. 成功時に initial_branch_create_transaction_result とremote readbackを確認する。

    手動承認では解消しにくい

    今回のdenyはPermissionRequestではなくPreToolUseです。approval_policy を変更したり、ユーザーが承認意思をプロンプトに書いたりしても、PreToolUseのdeny自体は解除されません。

    Hookを無効化する方法はあるが非推奨

    公式には、非managed hookは /hooks から無効化でき、[features] hooks = false でも全hookを停止できます。managed hookはユーザー側から無効化できません。また、--dangerously-bypass-hook-trust はhookの信頼確認を省略するだけで、hookの判定を無効化するものではありません。 ([OpenAI Developers]1)

    このリポジトリではhookがAllowed Paths、HEAD、remote、secret境界を担っているため、無効化は修正ではなくguard bypassです。

    人間による直接push

    人間が通常のshellから直接pushすればCodexのPreToolUse hookは介在しません。ただし、これはagent publish laneの問題を残したまま迂回するだけです。恒久解決は専用laneの修正です。

    Codex CLI実行プロンプト

    Sparkは高速・小規模な反復向けで、デフォルトではテストまで自動実行しない軽量な作業スタイルです。そのため、Sparkをread-only調査サブエージェントとして優先し、親エージェントが状態統合・mutation・検証を担当する構成にしています。リポジトリ設定もsubagentの深さを1に制限しています。 ([OpenAI]3)

    リポジトリ squne121/loop-protocol の Issue #1766 を再開し、既存commitの回収、publish-lane障害の根本原因特定、可能ならbranch公開とDraft PR作成まで進めてください。

    Owner authorization

    リポジトリ所有者は、Issue #1766専用branchについて、以下を明示的に許可します。

    • read-onlyのGit/GitHub調査
    • isolation worktree内での必要最小限の修正
      -指定テスト・lintの実行
    • controlled executorによるcommit
    • repository-approved publish laneによるIssue専用branchの初回push
    • Draft PRの作成
    • CI・レビューコメントへの対応

    merge、force push、default branchへのpush、hook無効化、secret参照、外部課金、破壊的操作は許可しません。

    サブエージェント方針

    最初に、read-onlyサブエージェントを最大3体、並列で起動してください。nested delegationは禁止します。

    利用可能なら全て gpt-5.3-codex-spark を指定してください。利用不能なら、利用不能理由と実際に使用したモデルを明示し、無言で置換しないでください。

    Subagent A: publish-lane factcheck

    次をread-onlyで調査する。

    出力は以下に限定する。

    • initial branch publishの正規command shape
    • 必須contextの生成元
    • remote_write_requires_approvalへフォールバックする条件
    • 実際のpushがpolicy内で実行される条件
    • 最小再現方法
    • 推奨修正箇所

    Subagent B: GitHub state audit

    次をread-onlyで確認する。

    • Issue #1766の現行本文、全コメント、updatedAt、body hash
    • commit af55232f010610a9ce9d29d66c59a119d602c61d を含むremote branch/PRの有無
    • #1766の対象ファイルを変更するOPEN PR
    • initial branch publishのgeneric fallbackを扱うOPEN Issue
    • #1688が今回のinitial branch pathを包含するか
    • mainの現在SHA

    古いログの状態を現在の事実として採用しない。

    Subagent C: local artifact audit

    次をread-onlyで確認する。

    • worktree
      .claude/worktrees/issue-1766-closed-native-predecessor-regression-v2
    • branch
      worktree-issue-1766-closed-native-predecessor-regression-v2
    • commit
      af55232f010610a9ce9d29d66c59a119d602c61d
    • commitの親SHA
    • changed paths
    • dirty status
    • 新規テストnodeid
    • 過去のpytest/Ruff結果が現在のcheckoutで再現するか

    既存worktreeやcommitを削除、reset、上書きしない。

    親エージェントの初期確認

    サブエージェントの結果を採用する前に、親エージェント自身が次を再確認してください。

    uv run --locked python3 scripts/agent-ops/git_ref_probe.py \
      --branch main --remote origin --json
    
    uv run --locked python3 scripts/agent-ops/git_worktree_probe.py --json
    
    git -C .claude/worktrees/issue-1766-closed-native-predecessor-regression-v2 \
      status --short
    
    git -C .claude/worktrees/issue-1766-closed-native-predecessor-regression-v2 \
      show --stat --oneline af55232f010610a9ce9d29d66c59a119d602c61d
    
    git -C .claude/worktrees/issue-1766-closed-native-predecessor-regression-v2 \
      diff af55232f010610a9ce9d29d66c59a119d602c61d^ \
           af55232f010610a9ce9d29d66c59a119d602c61d \
      --name-only

    commitが存在し、変更が次の1ファイルだけであることを確認する。

    .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py
    

    mainが進んでいる場合は、新しいmain専用worktreeへcherry-pickまたは同等の移植を行う。旧worktreeを破壊しない。競合がある場合は停止し、具体的なconflict pathを報告する。

    publish-lane診断

    remote_write_requires_approvalをGitHub権限不足と決めつけないでください。次の4状態を区別してください。

    1. controlled initial-branch transactionが既に成功し、remote refが存在する
    2. classifierがstructured publish_lane_safety_stopを返す
    3. classifierがnull/不正出力となりgeneric remote_write_requires_approvalへfallbackする
    4. transactionが実際にGitHubへ到達し、認証・権限エラーを返す

    次を確認する。

    gh auth status --active --hostname github.com
    git remote get-url --push --all origin
    git ls-remote --refs origin \
      refs/heads/worktree-issue-1766-closed-native-predecessor-regression-v2

    --show-tokenは使用しない。token、credential、remote URL内の秘密情報をログへ出さない。

    Codexの現在の以下も記録する。

    • Codex CLI version
    • active model
    • permission mode
    • approval policy
    • active hook sources
    • project hookのtrust状態
    • effective permission profile

    可能なら /hooks またはCodexのdeveloper diagnosticsを使う。

    重要な禁止事項

    shell command先頭に次のようなinline環境変数を付けても、trusted hook contextとして扱わない。

    LOOP_PUBLISH_...=... rtk git push ...
    env LOOP_PUBLISH_...=... rtk git push ...
    

    PreToolUseはshell実行前に動くため、command文字列上の環境変数代入をhook processのtrusted contextとして使用してはならない。

    正規のcontrolled wrapper/executorが見つからない場合、raw git push、git -C ... push、hook disable、[features] hooks=false、--no-verify、bypassPermissionsへフォールバックしない。

    local reproducer

    actual GitHub remoteを変更する前に、一時bare remoteを使って次を再現する。

    • canonical initial-branch-create command
    • complete trusted context
    • codex-hook-adapter.mjs の実PreToolUse entrypoint
    • policy subprocessのstdout、stderr、exit status
    • transaction result
    • raw commandが二度実行されないこと
    • remote refが期待SHAと一致すること

    次のいずれかを必ず出力する。

    initial_branch_create_transaction_result
    publish_lane_safety_stop
    publish_lane_classifier_unavailable
    remote_write_requires_approval
    

    generic fallbackになった場合は、policy CLI unavailable、timeout、JSON parse failure、command shape mismatch、context injection欠落を区別する。

    分岐A:正規publish laneが利用可能

    remote branchが未作成で、正規のcontrolled publisherが利用可能な場合のみ、そのpublisherを実行する。

    成功条件:

    • transaction statusが created_and_verified
      または明示的に成功扱い可能な既存enum
    • remote ref readbackがpublish対象commitと完全一致
    • raw commandの二重pushなし
    • default branchへのmutationなし

    remote branchが既に同じcommitを指している場合はpushを再実行しない。

    その後、repositoryの open-pr skillを使ってDraft PRを作成する。PR本文には必ず以下を記載する。

    • Closes #1766
    • pinned base SHA
    • temporary reproducerが修正前からPASSしたこと
    • production code変更なし
    • test-only regression追加
    • scope-rollup runner_unavailable/deferred はowner-approved degraded modeとして扱ったこと
    • commit SHA
    • remote ref readback SHA
    • 実行した全検証
    • publish-lane診断結果

    分岐B:generic fallbackが再現する

    正規commandとcomplete contextでも
    remote_write_requires_approvalへfallbackする場合:

    1. hookを無効化しない。
    2. #1766へhook変更を混ぜない。
    3. 実装: PreToolUse remote_write_requires_approval を publish lane 証跡で通過可能にする #1408、実装: publish laneに新規branch初回publish用のatomicなbranch作成laneを追加する #1449、実装: existing-branch publish guard の実行ホスト context 注入を復旧する #1688、およびOPEN Issueを再検索する。
    4. initial branch pathの同一問題を扱うOPEN Issueがある場合、そのIssueへ再現証拠をコメントする。
    5. 同一Issueがない場合、別Issueを作成する。
    6. Issueにはtemporary bare remoteの再現、actual hook payload、classifier結果、expected/actualを記録する。
    7. #1766のworktreeとcommitを保持したまま終了する。

    新規Issueの主題は次とする。

    回帰: initial_branch_create publish lane が
    remote_write_requires_approval へgeneric fallbackする
    

    #1688はexisting-branch専用契約なので、無断でinitial-branch scopeを統合しない。

    分岐C:実GitHub認証エラー

    policy内のtransactionが実際にGitHubへ到達した後でのみ、GitHub認証・権限不足と判定してよい。

    その場合は次を報告する。

    • failure phase
    • sanitised stderr category
    • active GitHub account
    • remote protocol
    • remote refの有無
      -必要な権限またはcredential修復
    • pushが部分成功していないことのreadback結果

    秘密情報、token、credential内容は表示しない。

    検証

    #1766の差分について最低限、次を実行する。

    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py \
      -k test_given_closed_native_predecessor_outside_candidate_pool_when_fetched_then_readback_is_complete \
      -q
    
    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py \
      -q
    
    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap.py \
      -q
    
    uv run --locked ruff check \
      .claude/skills/implement-issue/scripts/check_implementation_overlap.py \
      .claude/skills/implement-issue/tests/

    publish-laneを変更した場合は、別Issue/別worktreeで次も実行する。

    uv run --locked pytest \
      scripts/agent-guards/tests/test_initial_branch_publish_policy.py \
      -q
    
    uv run --locked pytest \
      tests/session_recording/codex/test_initial_branch_create_lane.py \
      tests/session_recording/codex/test_hook_adapter.py \
      -q
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_git_mutation_command_policy.py \
      -q
    
    node --check scripts/session-recording/codex-hook-adapter.mjs

    CIとレビュー

    Draft PRを作成できた場合:

    • CIの必須checkを確認する。
    • requested changesとinline reviewを取得する。
    • #1766のAllowed Paths内の修正だけで解消できる指摘は対応する。
    • hook/publish laneの指摘は別Issueへ分離する。
    • mergeは行わない。
    • Draft PR、CI結果、未解決blockerまでを最終状態とする。

    停止条件

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

    • secretへのアクセスが必要
      -破壊的操作が必要
      -外部課金が必要
      -実際のGitHub認証・権限不足が確認された
      -対象ファイルを変更中のOPEN PR/active worktree競合
    • #1766の修正にAllowed Paths外の変更が必要
    • remote mainまたはIssue本文が作業中に変化した
    • controlled publisherが存在せず、別Issue作成後も安全なpublish経路がない

    remote_write_requires_approvalという文字列だけでは、GitHub権限不足として停止しない。

    最終報告

    次を簡潔に報告する。

    改善Issue草案

    今回の検索では、existing branch向けの #1688 はopenですが、initial branchのgeneric fallbackを直接扱うopen Issueは確認できませんでした。したがって、正規commandとtrusted contextでも再現した場合に限り、次の草案が適切です。

    回帰: initial_branch_create publish lane が remote_write_requires_approval へgeneric fallbackする

    Machine-Readable Contract

    contract_schema_version: v1
    issue_kind: implementation
    change_kind: code
    parent_issue: none
    related_issues:
      - "#1408"
      - "#1449"
      - "#1688"
    observed_in:
      - "#1766"
    goal_ref: >-
      canonical initial_branch_create publish commandとtrusted publish contextが
      揃っている場合に、PreToolUse hookがgeneric
      remote_write_requires_approvalへfallbackせず、既存のcontrolled
      probe/push/readback transactionを実行して構造化結果を返す

    Current Validated Scope

    • PR #1479で、初回branch作成は
      execute_initial_branch_create_transaction() 内の
      probe → empty-expect lease push → readbackとして実装済み。
    • codex-hook-adapter.mjs は
      command_class == rtk_git_initial_branch_create の場合、
      raw shell commandを再実行させずtransaction結果を返す契約。
    • Issue #1766のbranch公開時、canonical laneを意図したコマンドが
      remote_write_requires_approvalへgeneric fallbackし、
      transaction resultが得られなかった。
    • inline LOOP_PUBLISH_*=... command prefixは、PreToolUse hook processの
      trusted contextにはならない。
    • #1688はexisting-branch context injection専用であり、
      initial-branch modeは契約外。

    Outcome

    canonical initial-branch-create requestが、complete trusted contextを
    controlled wrapperから受け取った場合に、実PreToolUse entrypointから
    既存のinitial-branch transactionを一度だけ実行する。

    成功・競合・probe失敗・context不備・classifier内部失敗は、それぞれ
    構造化reason codeで区別する。classifier内部失敗を
    remote_write_requires_approvalへ偽装しない。

    In Scope

    • codex-hook-adapter.mjs からpublish policyへのcommand/context転送の確認と最小修正。
    • initial-branch用trusted context injector/既存controlled wrapperの確認と最小修正。
    • policy CLI unavailable、timeout、invalid JSON、command-shape mismatchを
      publish_lane_classifier_unavailable系の構造化reasonへ分類する。
    • canonical initial-branch commandが
      _classify_initial_branch_create_push()へ到達することを固定する。
    • complete contextではtransactionを1回だけ実行し、
      raw commandを二重実行しないことを固定する。
    • missing/invalid contextはpublish_lane_safety_stopとし、
      generic approval reasonへ縮退させない。
    • temporary bare remoteを使う実hook subprocess test。
    • docsへのdiagnostic手順追加。

    Out of Scope

    • raw git pushの許可。
    • hookの無効化またはbest-effort化。
    • force push一般の許可。
    • default branchへのpush。
    • GitHub credential/token scopeの変更。
    • approval_policyやCodex runtime本体の変更。
    • #1766のテスト差分。
    • #1688のexisting-branch contractの無断拡張。
    • live GitHub remoteを使う自動テスト。

    Acceptance Criteria

    • AC1: canonical initial-branch-create commandとcomplete trusted contextが、実PreToolUse entrypointからrtk_git_initial_branch_createへ分類される。
    • AC2: temporary bare remoteで、transactionがremote refを一度だけ作成し、readback SHAがverified SHAと一致する。
    • AC3: transaction実行後のraw shell commandはdenyされ、二重pushされない。
    • AC4: complete contextでclassifierがnull、timeout、不正JSONとなった場合、publish_lane_classifier_unavailable系reasonを返し、remote_write_requires_approvalへ縮退しない。
    • AC5: missing/invalid contextはpublish_lane_safety_stopと、具体的なcontext reasonを返す。
    • AC6: inline VAR=value command/env VAR=value commandはtrusted contextとしてallowされない。
    • AC7: raw、force、tag、delete、mirror、multi-ref、default-branch pushは従来どおりdenyされる。
    • AC8: existing-branch publish testsとinitial-branch transaction testsがregressionなくPASSする。
    • AC9: docsが、PreToolUse deny、PermissionRequest no-decision、controlled context injectionの責任境界を説明する。

    Verification Commands

    uv run --locked pytest \
      scripts/agent-guards/tests/test_initial_branch_publish_policy.py \
      -q
    
    uv run --locked pytest \
      tests/session_recording/codex/test_initial_branch_create_lane.py \
      tests/session_recording/codex/test_hook_adapter.py \
      -q
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_git_mutation_command_policy.py \
      -q
    
    node --check scripts/session-recording/codex-hook-adapter.mjs
    
    uv run --locked ruff check \
      scripts/agent-guards/git_mutation_command_policy.py \
      scripts/agent-guards/tests/

    Allowed Paths

    • scripts/session-recording/codex-hook-adapter.mjs
    • scripts/agent-guards/git_mutation_command_policy.py
    • scripts/agent-guards/tests/test_initial_branch_publish_policy.py
    • scripts/agent-guards/tests/test_git_mutation_command_policy.py
    • tests/session_recording/codex/test_initial_branch_create_lane.py
    • tests/session_recording/codex/test_hook_adapter.py
    • docs/dev/hook-boundaries.md
    • docs/dev/session-recording-policy.md

    Stop Conditions

    • Allowed Paths外の変更が必要。
    • managed hook/MDM/Codex runtime本体の変更が必要。
    • raw pushまたはhook disableでなければ実現できない。
    • secret、credential内容、外部課金が必要。
    • live GitHub remoteでなければ検証不能。
    • existing-branch/initial-branch契約を一つの曖昧なlaneへ統合する必要がある。

    Delivery Rule

    • 1 Issue = 1 PR
    • dedicated worktree
    • Draft PR
    • temporary bare remoteによるruntime verification
    • mergeは別判断

    上の実行プロンプトで正規contextを使った再現を先に確定し、再現した場合だけ改善Issueを起票する順序が適切です。

  8. squne121 commented on Jul 27, 2026

    @squne121
    OwnerAuthor

    結論

    remote_write_requires_approval は、Codex CLI が標準で返している固有エラー名ではありません。loop-protocol の scripts/session-recording/codex-hook-adapter.mjs が生成しているリポジトリ固有の reason_code です。

    Codex CLI 本体が提供しているのは PreToolUse、PermissionRequest、承認ポリシーなどの仕組みです。リポジトリ側は、その仕組みに独自の publish 制約を実装しています。公式仕様上、PermissionRequest が判断しなければ通常の承認フローへ戻りますが、PreToolUse はツール呼び出し自体を deny できます。 ([OpenAI Developers]1)

    このリポジトリでは、remote write を検出すると一旦 no_decision / remote_write_requires_approval を生成し、PreToolUse では no_decision も含めて deny に変換しています。一方、PermissionRequest では何も返さず通常の承認フローへ委譲します。つまり今回のケースは、PermissionRequest に到達する前に PreToolUse で止まっています。

    責任境界

    • Codex CLI仕様:Hook と承認フローを提供する。
    • リポジトリ制約:remote write を分類し、専用 publish lane 以外を PreToolUse で拒否する。
    • GitHub権限:今回のログだけでは未検証。実際の push が GitHub に到達して、認証エラーや403を返した証拠はありません。

    したがって、作業ログの「GitHub branch 公開権限の gate」という診断は不正確です。正しくは、リポジトリの publish-lane classifier が専用経路へ分類できず、generic remote-write deny にフォールバックした可能性が高い、です。

    敵対的レビュー

    P0-1:GitHub権限不足という結論は証拠不足

    ログでは commit af55232f010610a9ce9d29d66c59a119d602c61d まで作成されていますが、その後は PreToolUse hook で止まっています。GitHubへの実 push、GitHubの拒否応答、gh auth status の失敗は記録されていません。

    認証確認には gh auth status --active --hostname github.com が使えますが、これは今回実行されていません。 ([GitHub CLI]2)

    P0-2:初回 branch publish の専用経路に入っていない

    PR #1479 では、新規 branch の初回 publish は次のように実装済みです。

    1. branch、HEAD、remote、Allowed Paths を検証する。
    2. remote ref が存在しないことを probe する。
    3. empty-expect lease で push する。
    4. remote ref を readback する。
    5. raw shell command は必ず deny し、二重 push を防ぐ。

    PR #1479 は merge 済みです。

    現在の production code も、実際の push は execute_initial_branch_create_transaction() 内で行い、処理後は initial_branch_create_transaction_result を返す設計です。

    今回返ったのはそれではなく generic remote_write_requires_approval です。したがって、以下のどれかです。

    • command shape が専用 lane と一致していない。
    • active branch、HEAD、Allowed Paths の context が hook に渡っていない。
    • policy subprocess が失敗、または不正JSONを返した。
    • classifyRtkGitPushPublishLane() が null を返し、generic denyへフォールバックした。

    P0-3:inline環境変数は承認contextにならない

    ログの再試行コマンドは、概ね次の形です。

    LOOP_PUBLISH_DECLARED_PUBLISH_HEAD=... LOOP_... rtk git push ...
    

    しかし PreToolUse hook は、そのshell commandが実行される前に別プロセスとして動きます。コマンド文字列先頭の環境変数代入は、hookプロセスの process.env/os.environ には入りません。

    さらに open Issue #1688 は、terminal command の env VAR=... prefixだけでは context injection を模倣できないことを明示的に要求しています。

    したがって、inline環境変数を増やして再試行しても解除にはなりません。必要なのは、リポジトリが認可した wrapper または runtime context injection です。

    P1-1:#1766の実装作業自体はほぼ完了

    最新main上でも一時 reproducer は PASSし、production bug の前提は否定されています。恒久回帰テスト追加後は、48件・56件のpytestとRuffがPASSし、許可されたテストファイルだけを含むcommitも作成済みです。

    次のセッションで再実装するべきではありません。まず既存worktreeとcommitを回収し、必要なら新mainへ移植するべきです。

    P1-2:#1766にhook修正を混ぜてはいけない

    現在の #1766 は test-only 契約で、Allowed Paths はテストファイル1件だけです。production script、hook、permission profile の変更は明確にOut of Scopeです。

    publish laneの不具合を直す場合は、別Issue・別worktree・別PRが必要です。

    P1-3:Verification Commandsが弱い

    #1766 のAC1〜AC3は同じテストファイル全体を3回実行しています。変更後には通りますが、新規nodeidの存在と挙動を直接証明するVCではありません。

    PR本文では少なくとも、新規nodeidを指定したテストも追加実行すべきです。

    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py \
      -k test_given_closed_native_predecessor_outside_candidate_pool_when_fetched_then_readback_is_complete \
      -q

    解除・解消方法

    推奨:専用publish laneを正常に通す

    .codex/config.toml は既に approval_policy = "on-request" で、GitHubへのネットワークも許可されています。.codex/rules/default.rules も rtk git push origin ... を静的にはallowしています。

    したがって変更すべきなのはapproval policyではなく、次のいずれかです。

    1. 正しいcontrolled publisher/context injectorを使う。
    2. initial-branch classifierがgeneric fallbackする原因を修正する。
    3. 成功時に initial_branch_create_transaction_result とremote readbackを確認する。

    手動承認では解消しにくい

    今回のdenyはPermissionRequestではなくPreToolUseです。approval_policy を変更したり、ユーザーが承認意思をプロンプトに書いたりしても、PreToolUseのdeny自体は解除されません。

    Hookを無効化する方法はあるが非推奨

    公式には、非managed hookは /hooks から無効化でき、[features] hooks = false でも全hookを停止できます。managed hookはユーザー側から無効化できません。また、--dangerously-bypass-hook-trust はhookの信頼確認を省略するだけで、hookの判定を無効化するものではありません。 ([OpenAI Developers]1)

    このリポジトリではhookがAllowed Paths、HEAD、remote、secret境界を担っているため、無効化は修正ではなくguard bypassです。

    人間による直接push

    人間が通常のshellから直接pushすればCodexのPreToolUse hookは介在しません。ただし、これはagent publish laneの問題を残したまま迂回するだけです。恒久解決は専用laneの修正です。

    Codex CLI実行プロンプト

    Sparkは高速・小規模な反復向けで、デフォルトではテストまで自動実行しない軽量な作業スタイルです。そのため、Sparkをread-only調査サブエージェントとして優先し、親エージェントが状態統合・mutation・検証を担当する構成にしています。リポジトリ設定もsubagentの深さを1に制限しています。 ([OpenAI]3)

    リポジトリ squne121/loop-protocol の Issue #1766 を再開し、既存commitの回収、publish-lane障害の根本原因特定、可能ならbranch公開とDraft PR作成まで進めてください。

    Owner authorization

    リポジトリ所有者は、Issue #1766専用branchについて、以下を明示的に許可します。

    • read-onlyのGit/GitHub調査
    • isolation worktree内での必要最小限の修正
      -指定テスト・lintの実行
    • controlled executorによるcommit
    • repository-approved publish laneによるIssue専用branchの初回push
    • Draft PRの作成
    • CI・レビューコメントへの対応

    merge、force push、default branchへのpush、hook無効化、secret参照、外部課金、破壊的操作は許可しません。

    サブエージェント方針

    最初に、read-onlyサブエージェントを最大3体、並列で起動してください。nested delegationは禁止します。

    利用可能なら全て gpt-5.3-codex-spark を指定してください。利用不能なら、利用不能理由と実際に使用したモデルを明示し、無言で置換しないでください。

    Subagent A: publish-lane factcheck

    次をread-onlyで調査する。

    出力は以下に限定する。

    • initial branch publishの正規command shape
    • 必須contextの生成元
    • remote_write_requires_approvalへフォールバックする条件
    • 実際のpushがpolicy内で実行される条件
    • 最小再現方法
    • 推奨修正箇所

    Subagent B: GitHub state audit

    次をread-onlyで確認する。

    • Issue #1766の現行本文、全コメント、updatedAt、body hash
    • commit af55232f010610a9ce9d29d66c59a119d602c61d を含むremote branch/PRの有無
    • #1766の対象ファイルを変更するOPEN PR
    • initial branch publishのgeneric fallbackを扱うOPEN Issue
    • #1688が今回のinitial branch pathを包含するか
    • mainの現在SHA

    古いログの状態を現在の事実として採用しない。

    Subagent C: local artifact audit

    次をread-onlyで確認する。

    • worktree
      .claude/worktrees/issue-1766-closed-native-predecessor-regression-v2
    • branch
      worktree-issue-1766-closed-native-predecessor-regression-v2
    • commit
      af55232f010610a9ce9d29d66c59a119d602c61d
    • commitの親SHA
    • changed paths
    • dirty status
    • 新規テストnodeid
    • 過去のpytest/Ruff結果が現在のcheckoutで再現するか

    既存worktreeやcommitを削除、reset、上書きしない。

    親エージェントの初期確認

    サブエージェントの結果を採用する前に、親エージェント自身が次を再確認してください。

    uv run --locked python3 scripts/agent-ops/git_ref_probe.py \
      --branch main --remote origin --json
    
    uv run --locked python3 scripts/agent-ops/git_worktree_probe.py --json
    
    git -C .claude/worktrees/issue-1766-closed-native-predecessor-regression-v2 \
      status --short
    
    git -C .claude/worktrees/issue-1766-closed-native-predecessor-regression-v2 \
      show --stat --oneline af55232f010610a9ce9d29d66c59a119d602c61d
    
    git -C .claude/worktrees/issue-1766-closed-native-predecessor-regression-v2 \
      diff af55232f010610a9ce9d29d66c59a119d602c61d^ \
           af55232f010610a9ce9d29d66c59a119d602c61d \
      --name-only

    commitが存在し、変更が次の1ファイルだけであることを確認する。

    .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py
    

    mainが進んでいる場合は、新しいmain専用worktreeへcherry-pickまたは同等の移植を行う。旧worktreeを破壊しない。競合がある場合は停止し、具体的なconflict pathを報告する。

    publish-lane診断

    remote_write_requires_approvalをGitHub権限不足と決めつけないでください。次の4状態を区別してください。

    1. controlled initial-branch transactionが既に成功し、remote refが存在する
    2. classifierがstructured publish_lane_safety_stopを返す
    3. classifierがnull/不正出力となりgeneric remote_write_requires_approvalへfallbackする
    4. transactionが実際にGitHubへ到達し、認証・権限エラーを返す

    次を確認する。

    gh auth status --active --hostname github.com
    git remote get-url --push --all origin
    git ls-remote --refs origin \
      refs/heads/worktree-issue-1766-closed-native-predecessor-regression-v2

    --show-tokenは使用しない。token、credential、remote URL内の秘密情報をログへ出さない。

    Codexの現在の以下も記録する。

    • Codex CLI version
    • active model
    • permission mode
    • approval policy
    • active hook sources
    • project hookのtrust状態
    • effective permission profile

    可能なら /hooks またはCodexのdeveloper diagnosticsを使う。

    重要な禁止事項

    shell command先頭に次のようなinline環境変数を付けても、trusted hook contextとして扱わない。

    LOOP_PUBLISH_...=... rtk git push ...
    env LOOP_PUBLISH_...=... rtk git push ...
    

    PreToolUseはshell実行前に動くため、command文字列上の環境変数代入をhook processのtrusted contextとして使用してはならない。

    正規のcontrolled wrapper/executorが見つからない場合、raw git push、git -C ... push、hook disable、[features] hooks=false、--no-verify、bypassPermissionsへフォールバックしない。

    local reproducer

    actual GitHub remoteを変更する前に、一時bare remoteを使って次を再現する。

    • canonical initial-branch-create command
    • complete trusted context
    • codex-hook-adapter.mjs の実PreToolUse entrypoint
    • policy subprocessのstdout、stderr、exit status
    • transaction result
    • raw commandが二度実行されないこと
    • remote refが期待SHAと一致すること

    次のいずれかを必ず出力する。

    initial_branch_create_transaction_result
    publish_lane_safety_stop
    publish_lane_classifier_unavailable
    remote_write_requires_approval
    

    generic fallbackになった場合は、policy CLI unavailable、timeout、JSON parse failure、command shape mismatch、context injection欠落を区別する。

    分岐A:正規publish laneが利用可能

    remote branchが未作成で、正規のcontrolled publisherが利用可能な場合のみ、そのpublisherを実行する。

    成功条件:

    • transaction statusが created_and_verified
      または明示的に成功扱い可能な既存enum
    • remote ref readbackがpublish対象commitと完全一致
    • raw commandの二重pushなし
    • default branchへのmutationなし

    remote branchが既に同じcommitを指している場合はpushを再実行しない。

    その後、repositoryの open-pr skillを使ってDraft PRを作成する。PR本文には必ず以下を記載する。

    • Closes #1766
    • pinned base SHA
    • temporary reproducerが修正前からPASSしたこと
    • production code変更なし
    • test-only regression追加
    • scope-rollup runner_unavailable/deferred はowner-approved degraded modeとして扱ったこと
    • commit SHA
    • remote ref readback SHA
    • 実行した全検証
    • publish-lane診断結果

    分岐B:generic fallbackが再現する

    正規commandとcomplete contextでも
    remote_write_requires_approvalへfallbackする場合:

    1. hookを無効化しない。
    2. #1766へhook変更を混ぜない。
    3. 実装: PreToolUse remote_write_requires_approval を publish lane 証跡で通過可能にする #1408、実装: publish laneに新規branch初回publish用のatomicなbranch作成laneを追加する #1449、実装: existing-branch publish guard の実行ホスト context 注入を復旧する #1688、およびOPEN Issueを再検索する。
    4. initial branch pathの同一問題を扱うOPEN Issueがある場合、そのIssueへ再現証拠をコメントする。
    5. 同一Issueがない場合、別Issueを作成する。
    6. Issueにはtemporary bare remoteの再現、actual hook payload、classifier結果、expected/actualを記録する。
    7. #1766のworktreeとcommitを保持したまま終了する。

    新規Issueの主題は次とする。

    回帰: initial_branch_create publish lane が
    remote_write_requires_approval へgeneric fallbackする
    

    #1688はexisting-branch専用契約なので、無断でinitial-branch scopeを統合しない。

    分岐C:実GitHub認証エラー

    policy内のtransactionが実際にGitHubへ到達した後でのみ、GitHub認証・権限不足と判定してよい。

    その場合は次を報告する。

    • failure phase
    • sanitised stderr category
    • active GitHub account
    • remote protocol
    • remote refの有無
      -必要な権限またはcredential修復
    • pushが部分成功していないことのreadback結果

    秘密情報、token、credential内容は表示しない。

    検証

    #1766の差分について最低限、次を実行する。

    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py \
      -k test_given_closed_native_predecessor_outside_candidate_pool_when_fetched_then_readback_is_complete \
      -q
    
    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap_native_dependencies.py \
      -q
    
    uv run --locked pytest \
      .claude/skills/implement-issue/tests/test_check_implementation_overlap.py \
      -q
    
    uv run --locked ruff check \
      .claude/skills/implement-issue/scripts/check_implementation_overlap.py \
      .claude/skills/implement-issue/tests/

    publish-laneを変更した場合は、別Issue/別worktreeで次も実行する。

    uv run --locked pytest \
      scripts/agent-guards/tests/test_initial_branch_publish_policy.py \
      -q
    
    uv run --locked pytest \
      tests/session_recording/codex/test_initial_branch_create_lane.py \
      tests/session_recording/codex/test_hook_adapter.py \
      -q
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_git_mutation_command_policy.py \
      -q
    
    node --check scripts/session-recording/codex-hook-adapter.mjs

    CIとレビュー

    Draft PRを作成できた場合:

    • CIの必須checkを確認する。
    • requested changesとinline reviewを取得する。
    • #1766のAllowed Paths内の修正だけで解消できる指摘は対応する。
    • hook/publish laneの指摘は別Issueへ分離する。
    • mergeは行わない。
    • Draft PR、CI結果、未解決blockerまでを最終状態とする。

    停止条件

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

    • secretへのアクセスが必要
      -破壊的操作が必要
      -外部課金が必要
      -実際のGitHub認証・権限不足が確認された
      -対象ファイルを変更中のOPEN PR/active worktree競合
    • #1766の修正にAllowed Paths外の変更が必要
    • remote mainまたはIssue本文が作業中に変化した
    • controlled publisherが存在せず、別Issue作成後も安全なpublish経路がない

    remote_write_requires_approvalという文字列だけでは、GitHub権限不足として停止しない。

    最終報告

    次を簡潔に報告する。

    改善Issue草案

    今回の検索では、existing branch向けの #1688 はopenですが、initial branchのgeneric fallbackを直接扱うopen Issueは確認できませんでした。したがって、正規commandとtrusted contextでも再現した場合に限り、次の草案が適切です。

    回帰: initial_branch_create publish lane が remote_write_requires_approval へgeneric fallbackする

    Machine-Readable Contract

    contract_schema_version: v1
    issue_kind: implementation
    change_kind: code
    parent_issue: none
    related_issues:
      - "#1408"
      - "#1449"
      - "#1688"
    observed_in:
      - "#1766"
    goal_ref: >-
      canonical initial_branch_create publish commandとtrusted publish contextが
      揃っている場合に、PreToolUse hookがgeneric
      remote_write_requires_approvalへfallbackせず、既存のcontrolled
      probe/push/readback transactionを実行して構造化結果を返す

    Current Validated Scope

    • PR #1479で、初回branch作成は
      execute_initial_branch_create_transaction() 内の
      probe → empty-expect lease push → readbackとして実装済み。
    • codex-hook-adapter.mjs は
      command_class == rtk_git_initial_branch_create の場合、
      raw shell commandを再実行させずtransaction結果を返す契約。
    • Issue #1766のbranch公開時、canonical laneを意図したコマンドが
      remote_write_requires_approvalへgeneric fallbackし、
      transaction resultが得られなかった。
    • inline LOOP_PUBLISH_*=... command prefixは、PreToolUse hook processの
      trusted contextにはならない。
    • #1688はexisting-branch context injection専用であり、
      initial-branch modeは契約外。

    Outcome

    canonical initial-branch-create requestが、complete trusted contextを
    controlled wrapperから受け取った場合に、実PreToolUse entrypointから
    既存のinitial-branch transactionを一度だけ実行する。

    成功・競合・probe失敗・context不備・classifier内部失敗は、それぞれ
    構造化reason codeで区別する。classifier内部失敗を
    remote_write_requires_approvalへ偽装しない。

    In Scope

    • codex-hook-adapter.mjs からpublish policyへのcommand/context転送の確認と最小修正。
    • initial-branch用trusted context injector/既存controlled wrapperの確認と最小修正。
    • policy CLI unavailable、timeout、invalid JSON、command-shape mismatchを
      publish_lane_classifier_unavailable系の構造化reasonへ分類する。
    • canonical initial-branch commandが
      _classify_initial_branch_create_push()へ到達することを固定する。
    • complete contextではtransactionを1回だけ実行し、
      raw commandを二重実行しないことを固定する。
    • missing/invalid contextはpublish_lane_safety_stopとし、
      generic approval reasonへ縮退させない。
    • temporary bare remoteを使う実hook subprocess test。
    • docsへのdiagnostic手順追加。

    Out of Scope

    • raw git pushの許可。
    • hookの無効化またはbest-effort化。
    • force push一般の許可。
    • default branchへのpush。
    • GitHub credential/token scopeの変更。
    • approval_policyやCodex runtime本体の変更。
    • #1766のテスト差分。
    • #1688のexisting-branch contractの無断拡張。
    • live GitHub remoteを使う自動テスト。

    Acceptance Criteria

    • AC1: canonical initial-branch-create commandとcomplete trusted contextが、実PreToolUse entrypointからrtk_git_initial_branch_createへ分類される。
    • AC2: temporary bare remoteで、transactionがremote refを一度だけ作成し、readback SHAがverified SHAと一致する。
    • AC3: transaction実行後のraw shell commandはdenyされ、二重pushされない。
    • AC4: complete contextでclassifierがnull、timeout、不正JSONとなった場合、publish_lane_classifier_unavailable系reasonを返し、remote_write_requires_approvalへ縮退しない。
    • AC5: missing/invalid contextはpublish_lane_safety_stopと、具体的なcontext reasonを返す。
    • AC6: inline VAR=value command/env VAR=value commandはtrusted contextとしてallowされない。
    • AC7: raw、force、tag、delete、mirror、multi-ref、default-branch pushは従来どおりdenyされる。
    • AC8: existing-branch publish testsとinitial-branch transaction testsがregressionなくPASSする。
    • AC9: docsが、PreToolUse deny、PermissionRequest no-decision、controlled context injectionの責任境界を説明する。

    Verification Commands

    uv run --locked pytest \
      scripts/agent-guards/tests/test_initial_branch_publish_policy.py \
      -q
    
    uv run --locked pytest \
      tests/session_recording/codex/test_initial_branch_create_lane.py \
      tests/session_recording/codex/test_hook_adapter.py \
      -q
    
    uv run --locked pytest \
      scripts/agent-guards/tests/test_git_mutation_command_policy.py \
      -q
    
    node --check scripts/session-recording/codex-hook-adapter.mjs
    
    uv run --locked ruff check \
      scripts/agent-guards/git_mutation_command_policy.py \
      scripts/agent-guards/tests/

    Allowed Paths

    • scripts/session-recording/codex-hook-adapter.mjs
    • scripts/agent-guards/git_mutation_command_policy.py
    • scripts/agent-guards/tests/test_initial_branch_publish_policy.py
    • scripts/agent-guards/tests/test_git_mutation_command_policy.py
    • tests/session_recording/codex/test_initial_branch_create_lane.py
    • tests/session_recording/codex/test_hook_adapter.py
    • docs/dev/hook-boundaries.md
    • docs/dev/session-recording-policy.md

    Stop Conditions

    • Allowed Paths外の変更が必要。
    • managed hook/MDM/Codex runtime本体の変更が必要。
    • raw pushまたはhook disableでなければ実現できない。
    • secret、credential内容、外部課金が必要。
    • live GitHub remoteでなければ検証不能。
    • existing-branch/initial-branch契約を一つの曖昧なlaneへ統合する必要がある。

    Delivery Rule

    • 1 Issue = 1 PR
    • dedicated worktree
    • Draft PR
    • temporary bare remoteによるruntime verification
    • mergeは別判断

    上の実行プロンプトで正規contextを使った再現を先に確定し、再現した場合だけ改善Issueを起票する順序が適切です。

  9. changed the title [-]回帰テスト: CLOSED native predecessor の候補外 hydration/readback 経路を固定する[/-] [+]実装: 回帰テスト: CLOSED native predecessor の候補外 hydration/readback 経路を固定する[/+] on Jul 27, 2026
  10. squne121 commented on Jul 27, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 人間判断要請

    • 発生 step: verification
    • PR: test: CLOSED predecessor の候補外 readback を固定 (#1766) #1817
    • current head: 5e39ca27825d76873b285de39a195a8d8f2311fd
    • pytest: AC1–AC3 は 48 passed(exit 0)
    • 停止理由: sanctioned CI artifact には current head のCI集約しかなく、VC_ADJUDICATION_RESULT_V1 の non-blocking 判定に必須な per-AC coverage、contract body SHA、diff、Allowed Paths、current/baseline の束縛証跡がない。
    • 対応: 手製証跡、schema/CI/workflow変更、fail-open 判定は行わず、blocking: true として停止した。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions