Skip to content

fix(dx): batch bot — push rollup objects instead of refs-API update, fix add-then-list race (dev) - #13535

Open
ntindle wants to merge 2 commits into
devfrom
fix/batch-bot-rollup-push-dev
Open

fix(dx): batch bot — push rollup objects instead of refs-API update, fix add-then-list race (dev)#13535
ntindle wants to merge 2 commits into
devfrom
fix/batch-bot-rollup-push-dev

Conversation

@ntindle

@ntindle ntindle commented Jul 11, 2026

Copy link
Copy Markdown
Member

Why / What / How

Forward-port of #13534 to dev (the bot executes master's copy — see that PR for the full analysis of the two live failures: refs-API 422 on unpushed objects, and the label-index race making the first /batch build nothing). Same two fixes applied to dev's copy of batch.mjs, preserving dev's #13521 hardening (exact-match ref check becomes moot — the whole refs-API block is replaced by the force-push).

Changes 🏗️

  • .github/batch-bot/batch.mjs: force-push rollup branch; union just-added PR into the rebuild

Checklist 📋

For code changes:

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jm3mCG9okfdGtAXtFaDF9A


Note

Medium Risk
Changes core batch/rollup publishing and membership logic used in CI; misconfiguration could break previews or duplicate rollup PRs, but scope is limited to the bot script with documented GitHub API behavior.

Overview
Fixes two production failures in the batch bot’s rollup flow by changing how the ephemeral batch/rollup branch is published and how members are collected right after /batch.

Rollup branch update: After assembling merges locally, the bot now force-pushes HEAD to refs/heads/batch/rollup instead of using the GitHub git refs API. Merge objects only exist in the Actions runner clone, so pointing a ref at them via API returned 422 “Object does not exist”; push uploads objects and moves the branch in one step.

Rollup PR lookup: gh pr list --head now uses the plain branch name (batch/rollup), not owner:branch. The qualified form is ignored by pr list, so later rebuilds failed to find the existing rollup PR and tried to create duplicates.

First /batch race: rebuildAndReport accepts an optional PR number; when /batch just added a label, that PR is fetched with pr view and unioned into the member list if the label index hasn’t caught up yet—avoiding an empty first rebuild.

Reviewed by Cursor Bugbot for commit fe12708. Bugbot is set up for automated code reviews on this repo. Configure here.

…-then-list race

Forward-port of the master hotfix (#13534) so the copies stay in sync;
preserves dev's exact-match ref-check hardening context by replacing the
whole refs-API block with the force-push.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jm3mCG9okfdGtAXtFaDF9A
@ntindle
ntindle requested a review from a team as a code owner July 11, 2026 02:12
@ntindle
ntindle requested review from 0ubbe and Swiftyos and removed request for a team July 11, 2026 02:12
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Jul 11, 2026
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The batch bot now ensures the just-batched PR is included even when the member index lags, and publishes the assembled rollup branch through a direct forced Git push.

Changes

Batch rollup flow

Layer / File(s) Summary
Ensure requested PR enters rollup
.github/batch-bot/batch.mjs
rebuildAndReport fetches a specified missing PR, while /batch passes the current PR number and excludes opt-out PRs.
Publish rollup branch directly
.github/batch-bot/batch.mjs
Rollup publishing uses git push --force to update the target branch instead of GitHub refs API calls.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: Pwuts, kcze, Swiftyos

Poem

A rabbit packed the PR in tight,
Though labels lagged beyond the night.
The rollup hopped onto its branch,
With one strong push and ears held prance.
Batch leaves the burrow neat and bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the main batch bot fixes: force-pushing rollup objects and handling the add-then-list race.
Description check ✅ Passed The description is clearly related to the changeset and accurately describes the forward-ported batch bot fixes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/batch-bot-rollup-push-dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Overlap Detection

This check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early.

🟡 Medium Risk — Some Line Overlap

These PRs have some overlapping changes:

Summary: 0 conflict(s), 1 medium risk, 0 low risk (out of 1 PRs with file overlap)


Auto-generated on push. Ignores: openapi.json, lock files.

ntindle added a commit that referenced this pull request Jul 11, 2026
…fix add-then-list race (#13536)

Replaces #13534 (auto-repointed to dev by the base-branch enforcer — the
branch needed a `hotfix/*` name to target master). Same commit. Dev
forward-port: #13535.

### Why / What / How

**Why:** The batch bot's first live runs failed at the final step both
times it got there:
1. `buildRollup` merges member branches into a **local** commit in the
runner, then points the remote `batch/rollup` ref at that SHA via the
git refs API — which 422s ("Object does not exist") because the server
never received the merge objects. Hard blocker; the whole /batch flow
dies here (live evidence: run 29135797524).
2. The first `/batch` on a PR reports "Current batch (0): none" —
`cmdBatch` adds the label then immediately lists members, but GitHub's
label index lags `pr edit --add-label` (live evidence: run 29135796249).

**What/How:**
- Replace the refs-API PATCH/POST dance with a single `git push --force
origin HEAD:refs/heads/batch/rollup` — uploads objects and
creates/force-moves the branch in one step under the bot's checkout
token (array-arg `execFileSync`, no shell).
- `rebuildAndReport` takes an optional `ensureNumber`: the just-labeled
PR is fetched directly and unioned into the member list so the first
/batch builds immediately.

Targets `master` because issue_comment/repository_dispatch workflows
execute the default branch's copy of the bot — a dev-only fix wouldn't
take effect until the next release merge.

### Changes 🏗️
- `.github/batch-bot/batch.mjs`: force-push rollup branch; union
just-added PR into the rebuild

### Checklist 📋
#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
- [x] `node --check` clean; both failure modes reproduced from live run
logs
- [ ] Real e2e: re-trigger `/batch` after merge (batch labels already on
#13533/#13526/#13530/#13532)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Jm3mCG9okfdGtAXtFaDF9A

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes how the bot-owned rollup branch is updated (force-push) and
batch membership is assembled; limited to CI/batch-bot infrastructure
but affects preview deploy and batch-merge flows.
> 
> **Overview**
> Fixes two production failures in the batch bot’s rollup publish and
member listing.
> 
> **Rollup publish:** After local merges, the bot no longer updates
`batch/rollup` via the Git refs API (which 422’d because the server
never had the merge objects). It now **`git push --force`** to
`HEAD:refs/heads/batch/rollup`, uploading objects and moving the branch
in one step under the checkout token.
> 
> **First `/batch` race:** `rebuildAndReport` accepts an optional
**`ensureNumber`**. When `/batch` adds a label, the just-labeled PR is
fetched with `pr view` and merged into the member list if GitHub’s label
index hasn’t caught up yet, so the first add doesn’t report “batch (0):
none”.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
0f357bf. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fe12708. Configure here.

"--json", "number,title,headRefName,headRefOid,url,labels,reviewDecision,mergeable,isDraft",
]);
if (!row.labels.some((l) => l.name === NEVER)) list.push(row);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale index drops prior members

Medium Severity

When members() is still empty after label-index lag, rebuildAndReport only unions the PR passed as ensureNumber, not other PRs that already have the batch label. A second /batch can force-push a rollup that omits earlier members while those PRs keep the label, so the preview and rollup body no longer match the real batch.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fe12708. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts Automatically applied to PRs with merge conflicts size/m

Projects

Status: 🆕 Needs initial review

Development

Successfully merging this pull request may close these issues.

1 participant