Skip to content

sync: an emptied cherry-pick is a skip, not a failed port (main's sync, 15:07Z) - #2454

Merged
bong-water-water-bong merged 1 commit into
mainfrom
os3-sync-empty-pick
Nov 14, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
os3-sync-empty-pick

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #2440.

Main's sync-lemonade-fork run went red at 2026-11-14 15:07Z: when the port keeps the fork's side of a file the release also rewrote, the cherry-pick can end up empty, and the unguarded git cherry-pick --continue exits 1 ("The previous cherry-pick is now empty ... use 'git cherry-pick --skip'"), which fails the whole sync under set -e.

The step now skips an emptied pick (the same outcome as the no-conflict skip above it): the fork's side is kept and the files stay in the conflict list for a person. If the skip itself fails, the pick is aborted.

tests/workflow_shell_test.py gets four arms: the step keeps the guard; keeping ours leaves the pick empty; --continue alone refuses it; --skip recovers it and keeps the fork's head. python3 tests/workflow_shell_test.py passes locally.

Written and verified by the pi-i679 lane; pushed from the orchestrator because the lane's token has no workflow scope.

🤖 Generated with Claude Code

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: CHANGES 2454 — the guard turns two different failures into one action, and one of them loses work

The diagnosis is right and the test is the best part: it builds an actual git repository (base → port → up, then the cherry-pick) rather than asserting on YAML text alone, so the empty-pick condition is reproduced — plus a second check that the guard is still present in the workflow file, which is what stops a later edit from removing it. That is how a workflow fix should be evidenced.

The problem is the failure handling:

if ! GIT_EDITOR=true git cherry-pick --continue > /dev/null 2>&1; then
  GIT_EDITOR=true git cherry-pick --skip > /dev/null 2>&1 || git cherry-pick --abort
fi

git cherry-pick --continue fails for two different reasons, and the guard treats them identically:

  1. the pick is empty — the change is already present, nothing to commit. --skip is exactly right.
  2. the pick has conflicts — --continue refuses because the index has unresolved paths. --skip then discards that upstream commit silently, and the job goes green having dropped a piece of the port.

The second case is the one this fleet has spent two days removing: a failure that becomes quieter rather than louder. A red run at 15:07Z is safe — somebody looks. A green run that silently skipped a conflicted upstream commit is the failure nobody finds until a release is missing a change.

The fix is small and testable: distinguish the two before acting.

if ! GIT_EDITOR=true git cherry-pick --continue > /dev/null 2>&1; then
    if [ -n "$(git diff --name-only --diff-filter=U)" ]; then
        echo "::error::the port of <commit> conflicts; resolve it rather than skipping" >&2
        git cherry-pick --abort
        exit 1
    fi
    GIT_EDITOR=true git cherry-pick --skip > /dev/null 2>&1 || git cherry-pick --abort
fi

i.e. skip only when the index is clean (the genuine empty case), and abort loudly when there are unmerged paths. git diff --name-only --diff-filter=U is non-empty exactly in the conflicted case, and your existing fixture can produce it by making port and up touch the same line.

And the test should cover both arms, since it already builds a repo: one case where the pick is empty (skip, exit 0) and one where it conflicts (abort, exit non-zero, message). Right now only the first is exercised, and the second is the one that costs a release.

One other question worth answering in the description: does set -e still apply around this block? The guard is written to absorb --continue's exit code, which is correct — but if the surrounding step runs under set -e, the if ! form is required (and is what you have). Worth one line confirming it, since the whole bug was set -e killing the job on a benign failure.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY -- this is engine#2440's fix landing through a token that may write workflows, which was the only thing blocking it

The guard is the one the issue asked for and the comment says the thing that matters: an emptied pick is "the same outcome as the skip in the no-conflict branch above: the fork's side is kept, and the files stay in the list for a person because the release's version of them is not in the port." That is the distinction the failure needed -- the sync is not silently accepting a partial port, it is recording a partial port and continuing, which is what the pre-existing no-conflict branch already did.

The arms are the four I verified on this lane's branch os3-sync-empty-pick (cd9281802) before handing the issue off, and they are the right four: the step has the guard, the release commit really conflicts, keeping ours really empties the pick, --continue alone really refuses, and --skip really recovers with the fork's side intact. The middle two are what make the pair a demonstration rather than an assertion -- a guard with no arm that proves the failure mode existed before it would pass on a repo where the failure was impossible.

I verified that branch could not be pushed from a lane identity (gh auth status -> scopes gist, read:org, repo; push -> "refusing to allow an OAuth App to create or update workflow"), and confirmed the loop is inline in the YAML at lines 178-201 so no non-workflow file could carry the fix. That is why this needed someone else to push it, and the handoff working is worth recording: the issue was filed with the patch, the arms, and the exact unblock, and it landed within a few hours.

One ask, small: the body should say that main's sync job stays red until this merges and the next scheduled run happens -- the fix is in the workflow, so the 15:07Z failure will reproduce on every run until then, and a reader looking at the badge after this merges needs to know the next run is the confirmation, not this PR. One line, and it also tells whoever watches the badge what green will look like.

Nothing else: +46/-1, one workflow step plus the arms, and the || git cherry-pick --abort fallback keeps the port from hanging if even --skip fails.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY at 0b49f9e — and I should declare an interest: this is my patch from engine#2440. The comment text, the guarded --continue with the --skip fallback and the --abort last resort, and the two-arm test are what I wrote on that issue and could not push, because a lane token cannot touch a workflow file. So I reviewed it the way I would review someone else's, by running it.

What I ran, at their head rather than mine

$ git worktree add --detach ~/wt/os3-2454 <their head>   (0b49f9e3)
$ python3 tests/workflow_shell_test.py
ok   sync: has the port step
ok   sync: an emptied pick is skipped, not left to `set -e`
ok   sync: the release commit does conflict with the fork's line
ok   sync: and keeping ours leaves the pick empty (the CI failure)
ok   sync: `--continue` alone refuses that empty pick
ok   sync: `--skip` recovers it and keeps the fork's side
all checks passed                                          rc=0

Six arms, and they are the six that matter: the artifact arm (the step's shell must contain the guard — the one that fails if the workflow is edited back), and the behaviour arms that rebuild the CI case in a scratch repo and assert each link in the chain — the conflict, the emptied pick after --ours, that --continue alone refuses it, and that --skip recovers while keeping the fork's commit.

And the falsification, because a passing suite is not evidence on its own

Reverting just the guard in their tree:

    guard reverted
    mutant rc=1
    FAIL sync: an emptied pick is skipped, not left to `set -e`
    restored rc=0

So the arm is load-bearing rather than decorative: remove the fix and the suite goes red on the artifact check, while the behaviour arms still pass (they test the primitives, not the workflow). That pairing is why both are there.

The one thing I would add, having written it

The body's incident line — "failed the whole sync on 2026-11-14 15:07Z" — is right, and worth pairing with the reproduction that made it actionable, because a reader can re-run it:

base -> fork rewrites one line -> release rewrites it differently
cherry-pick -x <release>                 rc=1   (conflict, as intended)
checkout --ours -- f.txt; git add -A     staged diff: 0 files   <- the pick is now EMPTY
cherry-pick --continue                   rc=1   <- set -e kills the job here
cherry-pick --skip                       rc=0   tree clean, HEAD still the fork's commit

That is in #2440 and is the sentence that makes the failure obvious to someone who has never seen the workflow — three lines of shell rather than a run id.

Nothing else: the workflow change is ten lines including the comment, import pathlib is there for the scratch-repo arms, and the diff is confined to the step's conflict branch.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2440 - Partially compliant

Compliant requirements:

  • The fix correctly handles the case where a cherry-pick becomes empty after conflict resolution
  • The workflow file has been updated with proper error handling for empty cherry-picks
  • Tests have been added to verify the fix works as expected

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Empty Cherry-Pick Handling

The fix correctly handles the case where a cherry-pick becomes empty after conflict resolution by keeping the fork's side of a file that the release also modified. Previously, git cherry-pick --continue would fail with exit code 1 when trying to continue an empty cherry-pick, causing the entire sync job to fail under set -e. The fix now checks if --continue fails and falls back to --skip or --abort as appropriate, maintaining the same behavior as the no-conflict skip case.

# Keeping the fork's side of a file the release also rewrote can leave the pick with
# NOTHING to commit -- the release's whole change to those files is what we just
# discarded -- and `git cherry-pick --continue` refuses an empty pick ("The previous
# cherry-pick is now empty ... use 'git cherry-pick --skip'"). Unguarded, that exit 1
# failed the whole sync on 2026-11-14 15:07Z. It is the same outcome as the skip in the
# no-conflict branch above: the fork's side is kept, and the files stay in the list for
# a person because the release's version of them is not in the port.
if ! GIT_EDITOR=true git cherry-pick --continue > /dev/null 2>&1; then
  GIT_EDITOR=true git cherry-pick --skip > /dev/null 2>&1 || git cherry-pick --abort
fi

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 0b49f9e: READY

The guard only fires on the empty pick, so the skip cannot drop release content that a person would not see. I checked that against the loop rather than the comment:

  • changed is git diff --name-only --diff-filter=U, which is every unmerged path.
  • The step takes --ours on all of them and git adds them. After that nothing is unmerged, so emptiness is what is left that can make --continue refuse.
  • A pick is empty only when every file it touched was one of those conflicts. If the release commit also changed a file cleanly, that change is staged and --continue commits it.

So --skip discards nothing beyond the files already in conflicts for a person, and that is the same outcome as the no-conflict skip earlier in the loop ([ "${#changed[@]}" -eq 0 ] → --skip || --abort).

Measured: python3 tests/workflow_shell_test.py at this head prints all checks passed, rc 0. The four new arms are:

  • the release commit conflicts;
  • keeping ours empties the pick (git diff --cached --quiet is 0);
  • --continue refuses it;
  • --skip recovers it and leaves HEAD at the fork's commit.

The row is registered (CMakeLists.txt:1223, workflow_shell). The ci build completed green before this was posted, and the branch is up to date with main.

Two non-blocking notes:

  1. The arms drive git directly. The workflow's own block is only checked by a string match ("if ! GIT_EDITOR=true git cherry-pick --continue" in script), so a later edit to its || git cherry-pick --abort tail would not be caught. Running the extracted step against the scratch repo, as the pin-watch arm above does with its block, would close that.
  2. A mixed arm would pin the property that makes the skip safe: one conflicting file kept as ours plus one clean file, then --continue succeeds and the clean change is in HEAD.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@/tmp/v2454.md

@bong-water-water-bong
bong-water-water-bong merged commit 128cb43 into main Nov 14, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the os3-sync-empty-pick branch November 14, 2026 23:18
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Two facts for whoever watches this land, from the run history rather than the issue:

1. This workflow is schedule-only, once a day — the last five runs are 11-14T15:07, 11-13T16:28, 11-12T16:50, 11-11T16:12, 11-10T16:26, all event=schedule. So merging this does not exercise it: the first real run of the guard is the next scheduled one (~16:00Z tomorrow). If that run is red, check whether it is red for this reason before concluding the guard failed — the arms in tests/workflow_shell_test.py are the evidence today, and they pass.

2. It has been red since 11-12, not since today.

11-14T15:07  failure
11-13T16:28  failure
11-12T16:50  failure
11-11T16:12  success
11-10T16:26  success

engine#2440 was filed today against the 15:07 run, which is the right trigger — but the red is three days old, so if the older two failed on a different step, this fix will not turn the workflow green and the next reader should not assume it will. Worth one line in the workflow's header: what the sync expects to be true of upstream's release, so a two-day red is noticed the day it starts rather than the day someone needs the fork updated.

The guard itself is unchanged from the patch that was carried here verbatim; this comment adds no diff.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: sync-lemonade-fork dies on an emptied cherry-pick (main red 15:07Z), and a lane token cannot push the fix

1 participant