Skip to content

実装: 初回 branch publish の remote branch 不在を fail-closed に扱う #1443

Closed as not planned

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "初回 branch publish で remote branch 不在を検証可能な状態として扱い、head と Allowed Paths の整合が取れた場合だけ bounded branch publication を許可する"
change_kind: workflow

Parent Issue

なし

Parent Goal Ref

  • Goal: impl-review-loop が初回 branch publish で安全ゲートを保ったまま Draft PR 作成まで進められるようにする。
  • Desired Destination: 初回 publish を既存 remote head の欠落だけで停止せず、不在を明示検証する専用の fail-closed 判定を提供する。

Current Validated Scope

  • scripts/agent-guards/git_mutation_command_policy.py は remote_readback_source: ls_remote で remote branch が存在しないと publish_guard_context_invalid を返す。
  • そのため、新規 branch の初回 publish は PUBLISH_LANE_DECISION_V1 status: allow_retry を生成できない。
  • Issue 実装: root preflight の bytecode cache 誤検知を防止する #1439 の実装済み branch がこの経路で停止した。既存 remote branch の更新規則と direct/force/tag/all/delete の deny は維持する必要がある。

Remaining Parent Gaps

なし。

Outcome

初回 branch 用の structured publish decision と回帰テストが追加され、remote branch 不在を証明でき、local/verified/declared head と Allowed Paths gate が一致する場合だけ bounded branch publication を許可できる状態。

In Scope

  • 初回 branch 不在を表す closed な remote-readback 状態を policy に追加する。
  • 初回 publish では expected/current remote head がともに branch-absent sentinel であり、local/verified/declared head と Allowed Paths gate が一致する場合だけ allow する。
  • 既存 branch、head 不一致、remote readback 失敗、unknown sentinel、direct/force/tag/all/delete/mirror の deny は維持する。
  • policy と failure hint、および関連 SSOT に初回 publish と通常 retry の差分を記録する。
  • dedicated pytest regression を追加する。

Out of Scope

Runtime Verification Applicability

  • decision: not_applicable
  • reason: deterministic policy unit test と documentation check だけで完結し、実 GitHub remote への branch publication は検証として実行しない。

Acceptance Criteria

  • AC1: remote branch 不在を表す closed sentinel と ls_remote readback を持つ初回 publish context で、expected/current が同じ sentinel、local/verified/declared head が一致し、Allowed Paths gate が ok の場合だけ policy が allow_retry を返す。
  • AC2: expected/current sentinel の片方だけが不在、unknown sentinel、remote readback failure、または head/Allowed Paths の不一致では safety_stop と機械可読 reason を返す。
  • AC3: 既存 remote branch の publish retry と direct/force/tag/all/delete/mirror の deny regression を維持する。
  • AC4: initial publish と normal retry の input contract、postcondition、許可されない remote write を SSOT に記録する。

Verification Commands

# AC1
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -v
# AC2
# baseline-expect: fail
$ uv run --locked pytest scripts/agent-guards/tests/test_initial_branch_publish_policy.py -v
# AC3
# baseline-expect: pass
$ uv run --locked pytest scripts/agent-guards/tests/test_git_mutation_command_policy.py -v
# AC4
$ rg -n "initial branch publish" docs/dev/workflow.md docs/dev/hook-boundaries.md

Allowed Paths

  • scripts/agent-guards/git_mutation_command_policy.py
  • scripts/agent-guards/hook_repair_hints.py
  • scripts/agent-guards/tests/test_initial_branch_publish_policy.py
  • docs/dev/workflow.md
  • docs/dev/hook-boundaries.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • remote branch 不在以外の remote state を初回 publish として許可する必要が生じた場合
  • 実 GitHub remote への branch publication を automated verification として実行する必要が生じた場合

Required Skills

  • Python / pytest
  • Git refspec と remote ref safety policy

Required Design References

Delivery Rule

  • 1 Issue = 1 PR
  • dedicated worktree を使用する
  • Draft PR を既定とする
  • 実 GitHub remote への branch publication は verification command に含めない

Scope Delta

N/A

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    triage-required
    on Jul 11, 2026
  2. squne121 commented on Jul 11, 2026

    @squne121
    OwnerAuthor

    OWNER裁定(#1449 issuecomment-4942998354)に基づき、本 Issue を #1449 にsupersedeします。

    理由: remote branch状態のclassification(present/absent/probe_error)だけでは、新規branch初回作成を安全に完結できません。競合試験(race test)、compare-and-create primitive(empty-expect force-with-lease)、post-push readbackを一体で扱う必要があり、これらはすべて #1449 に統合されました。設計分割(本Issueと#1449への分離)は採用せず、#1449 が単一の実装契約として本Issueのscopeを包含します。

    close reason: not planned(#1449 へ統合済み)

    参照:

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

    agent/implementerenhancementphase/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions