ReviewOS

stacks/buddy

pantry/pkgx dep updates leave orphan branches when no file changes are generated

#1360
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Symptom

For pantry/pkgx-style dependency updates (curl.se, gnu.org/gcc/libstdcxx, gnu.org/gmp, gnu.org/mpc, gnu.org/mpfr, etc.), every buddy-bot run cycles through:

  1. Detects branch already exists with no open PR
  2. Deletes the branch (cleanup path)
  3. Re-creates the branch from main
  4. File-update generator returns "no file changes"
  5. Skips PR creation
  6. Branch stays → next run finds it as orphan → loop

Example from stacksjs/bun-query-builder (run):

Creating PR for group: Major Update - curl.se (1 updates)
🔄 Branch buddy-bot/update-major-update-curlse already exists, checking for associated PR...
🧹 Branch buddy-bot/update-major-update-curlse exists but has no open PR, cleaning up...
✅ Created branch buddy-bot/update-major-update-curlse from main  (this is in a later log, after deletion)
ℹ️ No file changes generated for group Major Update - curl.se, skipping PR creation

Net result: a stale branch with an empty commit, deleted and re-created on every scheduled run. No PR is ever opened. Cleanup eventually deletes it but the cycle repeats.

Root cause

The order of operations in createPullRequests (src/buddy.ts around line 478) is:

  1. deleteBranch(branchName) ← happens unconditionally when no open PR
  2. generateAllFileUpdates(group.updates)
  3. If empty: skip PR creation
  4. (Branch already deleted, but next run re-creates it on a fresh attempt)

For pantry/pkgx deps, the file-update generator legitimately produces no JS file changes (the dep is satisfied by deps.yaml or pantry.lock, which buddy-bot may not be writing for these dep types). So the "skip" path triggers every time.

Fix suggestions

In rough priority:

  1. Generate file updates BEFORE deleting the existing branch. If the generator returns empty, don't touch the branch — leave it alone. Saves the create/delete churn.
  2. For groups that can never produce file changes (pantry dep updates with no corresponding lock/yaml writer), don't put them through the PR pipeline at all. Surface them on the dashboard instead.
  3. At minimum, log it clearly so the orphan/recreate loop is visible.

Blast radius

Every stacksjs repo with pantry/pkgx deps in its dependency graph accumulates these orphan branches. We've now seen 5–8 such orphans accumulate per repo per week.

Sign in to comment on this issue.