Skip to content

feat(automation): merge stable core bumps that change no proto - #60

Merged
rhuss merged 5 commits into
mainfrom
feat/core-auto-merge
Nov 27, 2026
Merged

rhuss merged 5 commits into
mainfrom
feat/core-auto-merge

Conversation

@rhuss

@rhuss rhuss commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A stable core release whose regenerated bindings are identical needs no SDK work. core-watch can then merge its bump proposal without review, and release-tag.yml tags the lockstep SDK release right away. A release that changes anything under proto/ keeps waiting for review, so the SDK release may lag until the new features are wrapped and usable (see #59 for the coverage issues).

How it works

core-watch gets a second job, merge, that runs after watch only when the repository variable CORE_AUTO_MERGE is on. It runs hack/automation/merge-bump-pr.sh (mise task core:merge) with the token of a separate merge-only App, and runs no generator or other code from core. On each run it checks every open stable core-bump proposal again and merges only when all of these hold:

  • open, not a draft, branch core/vX.Y.Z of this repository into main, no hold label
  • exactly one commit since main, with a successful core-bump/provenance check from the bump App for the exact head SHA
  • the commit's tree is exactly the tree pin_bump_tree (hack/automation/pin-bump.sh) rebuilds from the merge base: the pin in buf.gen.yaml and the README line changed, nothing else. Nothing under proto/ and no conformance fixture can change, and no other edit inside buf.gen.yaml (such as a plugin) is allowed. open-bump-pr.sh makes the same edits through the shared pin_bump_edit.
  • ci, e2e / e2e, and DCO passed, and no other check failed or is pending

With auto-merge enabled, the bump App records the check on the local commit SHA it generated. A different head, missing check, or check from another App sends the proposal to human review. CI also publishes e2e-gate on every PR so the repository can require a stable check name and still allow intentional E2E skips.

It merges with --squash --match-head-commit <sha>, so a push after the checks blocks the merge, and it comments on the PR why it merged without review.

Rollout

Off by default. Before an admin sets CORE_AUTO_MERGE=on, in this order:

  1. Merge fix(automation): fill the bump PR body in a single pass #77 (the PR body renderer fix).
  2. Add a ruleset on core/* that lets only the ai-openshell-sdk-go App and maintainers create, update, or delete those branches.
  3. After e2e-gate is visible on a PR targeting main, add a ruleset that requires it and ci from GitHub Actions with no bypass actors. Keep the separate DCO rule in force.
  4. Grant the bump App Checks: write. core-watch requests that permission only when CORE_AUTO_MERGE is on.
  5. Create the merge App with contents and pull requests write, checks and statuses read, and issues write. Install it on this repository and store SDK_MERGE_CLIENT_ID and SDK_MERGE_PRIVATE_KEY in the sdk-bot environment.
  6. Grant only the merge App the PR-only main-integrity bypass for SDK Go. Keep CORE_AUTO_MERGE off until the rollout is ready.

Testing

  • Local actionlint, ShellCheck, offline zizmor, and existing RPC automation tests pass.
  • The E2E gate passes with an E2E success or an intentional skip, and fails on change-detection errors or unsuccessful required E2E.
  • Local dry-run with Git fixtures and stubbed GitHub responses accepts the App’s check on the exact SHA. It rejects a maintainer replacement with the same tree and bot email, a check from another App, and missing or failed checks. The live merge path still needs the rollout settings.

@rhuss
rhuss requested review from a team as code owners November 19, 2026 08:38

@SDAChess SDAChess left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I’d keep auto-merge off and hold off on granting the App a main-integrity bypass until we can verify who produced the exact commit and what it changes.

The bump commits are unsigned today. The script checks the author and committer emails, which anyone who can push to the branch can set. A simpler option than adding commit signing would be a dedicated ruleset for core/* in sdk-go that lets only the App create, update, or delete those branches. We could limit auto-merge to branches created under that rule and keep --match-head-commit so the merge uses the SHA we checked. If we want to preserve the ability for humans to push fixes directly to bump branches, bot-signed commits would give us that flexibility.

I’d also compare the full patch against the expected pin and README edits. Buf can execute a local plugin without changing proto/, so checking the tag field and changed filenames leaves a gap.

Before granting bypass, I’d fix the PR-body renderer so upstream diff text can’t expand environment variables, and enforce CI and E2E in a separate ruleset the merge identity can’t bypass. The branch ruleset would establish who controls the bump branch. A merge-only App would separately limit which workflows can bypass review on main.

@rhuss

rhuss commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, these are good points, and I agree with all of them. Auto-merge stays off (it defaults to off anyway), and we don't grant the bypass until the pieces below are in place.

Plan:

  1. PR body renderer: you're right, and this affects open-bump-pr.sh on main today, independent of this PR. I'll fix it first in a separate PR so the template is filled in a single pass with a fixed set of keys.
  2. Who controls core/*: I'd go with a dedicated ruleset that lets only the App (and maintainers, who can merge to main anyway) create, update or delete core/* branches. Humans can then still push SDK fixes to proposals that change protos, and those never auto-merge. If we'd rather not allow human pushes there at all, I can switch the bot to signed commits and check the signature instead of the emails.
  3. Full patch comparison: I'll replace the file name check. The script will rebuild the expected change on main (pin line in buf.gen.yaml, version line in README.md) and require the bump commit's diff to match it exactly, so a changed plugin entry or any other edit sends the proposal back to review.
  4. Required checks and merge identity: agreed on a separate ruleset that enforces ci, e2e / e2e and DCO with no bypass for the merge identity, and on a merge-only App that holds the main-integrity bypass. I'll update the rollout section to list these admin steps.

I'll ping you again once the renderer fix is merged and this PR is updated.

A stable core release whose regenerated bindings are identical needs no SDK
work, so core-watch can merge its proposal and release-tag.yml tags the SDK
release right away. merge-bump-pr.sh merges such a proposal only when it is
still one bot commit touching nothing but buf.gen.yaml and README.md, its
required checks are green, and no one added the hold label. A release that
changes anything under proto/ always waits for review, so the SDK release
may lag until the new features are wrapped.

Off by default: the CORE_AUTO_MERGE repository variable switches it on, and
the bot needs a pull-request bypass on the main-integrity ruleset.

Signed-off-by: Roland Huß <rhuss@redhat.com>
Compare the bump commit's tree with the tree pin_bump_tree rebuilds
from the merge base (pin in buf.gen.yaml, README line, nothing else),
instead of allowing any change to buf.gen.yaml and README.md. Another
edit inside buf.gen.yaml, such as a local Buf plugin, now sends the
proposal to review. open-bump-pr.sh makes the same edits through the
shared pin_bump_edit, so producer and checker cannot drift apart.

Move the merge into a separate core-watch job that mints its token
from a merge-only App (SDK_MERGE_CLIENT_ID, SDK_MERGE_PRIVATE_KEY).
Only that App needs the main-integrity bypass, the bump App that
pushes core/* branches does not get it, and the job runs no generator
or other code from core. The watch job passes the bump bot's email,
which merge-bump-pr.sh now reads from BUMP_BOT_EMAIL.

Document the rulesets an admin sets up before turning auto-merge on.

Signed-off-by: Roland Huß <rhuss@redhat.com>
@rhuss
rhuss force-pushed the feat/core-auto-merge branch from 62de893 to 89d1bd8 Compare November 25, 2026 08:11
@rhuss

rhuss commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@SDAChess updated, and rebased on main:

  • Exact patch: merge-bump-pr.sh now rebuilds the expected tree from the merge base (pin and README line only) and requires the bump commit's tree to match it, so a plugin entry or any other edit in buf.gen.yaml sends the proposal to review. open-bump-pr.sh and the check share the same edit function.
  • Merge identity: the merge runs in its own core-watch job with a separate merge-only App. Only that App would get the main-integrity bypass, and the job runs nothing from core.
  • Renderer: fixed in fix(automation): fill the bump PR body in a single pass #77.
  • The rulesets for core/* and for the required checks are listed in the Rollout section as admin steps before CORE_AUTO_MERGE is turned on.

Could you take another look?

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
@rhuss

rhuss commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@SDAChess thanks for pushing this yourself. A provenance check run from the bump App is a much better anchor than the commit emails: only the App can create it, the app ID filter rules out look-alikes from other Apps, and any other push produces a new SHA without it. e2e-gate also solves the problem of requiring E2E without blocking PRs that rightly skip it, and the grep change in the changes job fixes a real pipefail trap.

One small thing to watch after merge: with auto-merge off, permission-checks gets an empty string. I'd expect create-github-app-token to treat that as unset, but core-watch doesn't run on PRs, so the first scheduled run after merge is where we'd see it.

If the PR looks good to you now, could you re-review and lift the change request? Step 1 of the rollout, #77, also needs an infra review, if you have a moment.

When two stable proposals were open from the same base, the second one
still passed every check after the first merged, failed with a conflict
on the pin line, and set -e ended the run. It failed the same way every
hour, and the 'Merged without review' comment was already posted before
the refused merge. Nothing checked that the tag was newer than the pin
either, so a dispatched older tag could land a downgrade unreviewed.

merge-bump-pr.sh now fetches main for each proposal and leaves it for
review unless main still pins the tag the proposal was cut from and the
proposal's tag is newer. It merges first and comments only after the
merge succeeded. A refused merge leaves that proposal for review, the run
goes on with the others, and the script exits non-zero at the end so the
failure is reported. older moves to pin-bump.sh so both scripts share it.

Signed-off-by: Roland Huß <rhuss@redhat.com>
merge-bump-pr-test.sh checks pin_bump_tree and older in a scratch Git
repository and runs merge-bump-pr.sh against scratch repositories with a
gh stub that serves PR lists, check runs and checks from files and
squash-merges into a local bare origin. The cases cover two proposals
from the same base, a refused merge, a downgrade, provenance from another
App, a failed run or another SHA, a plugin or proto change, missing,
skipped, pending and failed checks, and the hold, draft, fork and
pre-release filters. workflows:check runs it in CI.

The rollout list gains a dry run against the real proposals before an
admin turns auto-merge on.

Signed-off-by: Roland Huß <rhuss@redhat.com>
@rhuss

rhuss commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@SDAChess Your provenance commit looks good; a full re-review found nothing there. It did find two problems in my merge loop, fixed in c4f0c00:

  1. A second stable proposal from the same base failed every hour. After the first one merged, the second still passed every check and then conflicted on the pin. The script now leaves a proposal for review unless main still has the pin it was cut from and its tag is newer. That also blocks unreviewed downgrades.
  2. The "Merged without review" comment came before the merge. A refused merge left a false claim. The script now comments only after a successful merge, and a refused merge no longer stops the other proposals.

59159cf adds merge-bump-pr-test.sh (in workflows:check), with offline tests for the tree check, the provenance, checks and label filters, and both fixes. It also adds a dry run as the last rollout step.

Could you take another look?

@SDAChess SDAChess left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-reviewed at 59159cf. The exact-head provenance check, full-tree comparison, and separate merge App address my earlier change request. Approved with CORE_AUTO_MERGE off. The preview-mode gap and the batch stopping on a missing branch can be follow-ups. Keep auto-merge off until #77 and the rollout protections are in place.

@rhuss
rhuss merged commit d669d68 into main Nov 27, 2026
10 checks passed
@rhuss
rhuss deleted the feat/core-auto-merge branch November 27, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants