gstack icon indicating copy to clipboard operation
gstack copied to clipboard

fix: /ship Steps 7-8 not idempotent — re-run after partial failure corrupts VERSION and CHANGELOG

Open LarHope opened this issue 8 months ago • 2 comments

Problem

/ship executes a multi-step sequence: version bump → changelog → commit → push → PR create. If Step 7 (git push) succeeds but Step 8 (gh pr create) fails (GitHub API outage, auth token expiry, rate limiting), re-running /ship corrupts state:

  • VERSION gets double-bumped (e.g., 0.13.5 → 0.13.6 on first run, then 0.13.6 → 0.13.7 on re-run)
  • CHANGELOG gets duplicate entries (same changes listed under two versions)
  • No way to safely resume from where it left off

The dangerous window is narrow (one step) but the blast radius is real — manual cleanup is required.

Why this matters

/land-and-deploy already handles partial failure well (Step 6 offers revert, Step 8 has full revert procedure with branch protection awareness). /ship doesn't apply the same rigor despite being the more frequently used skill.

Suggested fix

Make the critical section idempotent rather than building a rollback framework:

  1. Before push: check if branch is already pushed (git rev-parse @{u} or git ls-remote)
  2. Before PR create: check if a PR already exists for the branch (gh pr list --head <branch>)
  3. Before version bump: check if VERSION was already bumped in a prior run (compare against base branch)

This is ~10 lines of shell, not a new subsystem.

Reproduction

# 1. Run /ship on a feature branch
# 2. Simulate gh failure: revoke token or disconnect network after push
# 3. Re-run /ship
# 4. Observe: VERSION bumped again, CHANGELOG has duplicate section

Context

  • /land-and-deploy already handles this pattern (Steps 6, 7, 8 all have failure recovery)
  • Issue #341 covers cross-session resume but not within-session partial failure
  • The agent IS the resume mechanism — but it can't safely resume if the steps aren't idempotent

LarHope avatar Mar 30 '26 04:03 LarHope

@16francej Please close this issue as resolved. Ship reruns after partial failures are now handled safely by #693 and the newer version-state checks, so rerunning no longer corrupts VERSION or CHANGELOG.

time-attack avatar Jul 15 '26 10:07 time-attack

Resolved on current main. The original idempotency work landed in #693; the current workflow retains version-state classification (ALREADY_BUMPED keeps the existing version), remote-head equality checks, and existing-PR/MR updates rather than duplicate creation. The changelog workflow replaces overlapping branch entries with one unified entry. Merged #2970 further clarifies recovery without weakening verification. Closing as completed; the superseded alternate PR #684 is also closed.

capy-ai[bot] avatar Sep 24 '26 21:09 capy-ai[bot]