6161 changed : ${{ steps.snapshot.outputs.changed }}
6262 main_sha : ${{ steps.prepare.outputs.main_sha }}
6363 update_sha : ${{ steps.prepare.outputs.update_sha }}
64+ rebased : ${{ steps.prepare.outputs.rebased }}
65+ agent_base_tree : ${{ steps.prepare.outputs.agent_base_tree }}
6466 env :
6567 SDK_VERSION : ${{ needs.sdk-version.outputs.version }}
6668 SDK_SHA : ${{ needs.sdk-version.outputs.sha }}
@@ -126,10 +128,16 @@ jobs:
126128 fi
127129 echo "::warning::$UPDATE_BRANCH conflicts with main; regenerating it from main."
128130 git switch -C "$UPDATE_BRANCH" origin/main
131+ else
132+ echo "rebased=true" >> "$GITHUB_OUTPUT"
129133 fi
130134 else
131135 git switch -c "$UPDATE_BRANCH" origin/main
132136 fi
137+ # The agent's changes are published on top of this head, so human
138+ # commits on the update branch keep their content and authorship.
139+ echo "agent_base=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
140+ echo "agent_base_tree=$(git rev-parse 'HEAD^{tree}')" >> "$GITHUB_OUTPUT"
133141
134142 old_version=$(jq -er '.dependencies["@onkernel/sdk"]' package.json)
135143 if [[ "$old_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] &&
@@ -221,9 +229,9 @@ jobs:
221229 id : snapshot
222230 working-directory : mcp
223231 env :
224- MAIN_SHA : ${{ steps.prepare.outputs.main_sha }}
232+ AGENT_BASE : ${{ steps.prepare.outputs.agent_base }}
225233 run : |
226- git reset -q --soft "$MAIN_SHA "
234+ git reset -q --soft "$AGENT_BASE "
227235 git add -A
228236 git diff --cached --name-only --no-renames -z \
229237 | bash ../.github/scripts/mcp-update-disallowed-paths.sh > "$RUNNER_TEMP/excluded-paths"
@@ -276,6 +284,8 @@ jobs:
276284 SDK_VERSION : ${{ needs.sdk-version.outputs.version }}
277285 MAIN_SHA : ${{ needs.generate.outputs.main_sha }}
278286 UPDATE_SHA : ${{ needs.generate.outputs.update_sha }}
287+ REBASED : ${{ needs.generate.outputs.rebased }}
288+ AGENT_BASE_TREE : ${{ needs.generate.outputs.agent_base_tree }}
279289 UPDATE_BRANCH : mcp-coverage-update
280290 steps :
281291 - name : Checkout updater scripts
@@ -302,7 +312,16 @@ jobs:
302312 run : |
303313 git config user.name 'kernel-internal[bot]'
304314 git config user.email '260533166+kernel-internal[bot]@users.noreply.github.com'
305- git switch -c "$UPDATE_BRANCH" "$MAIN_SHA"
315+ if [[ "$REBASED" == true ]]; then
316+ git switch -c "$UPDATE_BRANCH" "$UPDATE_SHA"
317+ git rebase -q "$MAIN_SHA"
318+ else
319+ git switch -c "$UPDATE_BRANCH" "$MAIN_SHA"
320+ fi
321+ if [[ "$(git rev-parse 'HEAD^{tree}')" != "$AGENT_BASE_TREE" ]]; then
322+ echo "::error::The rebuilt update branch differs from the one the changes were validated on."
323+ exit 1
324+ fi
306325 git apply --index "$RUNNER_TEMP/mcp-coverage-update/changes.patch"
307326 git diff --cached --name-only --no-renames -z \
308327 | bash ../.github/scripts/mcp-update-disallowed-paths.sh > "$RUNNER_TEMP/disallowed-paths"
0 commit comments