Repository navigation
fix(pm-git-sync): move empty rebuild markers aside instead of stalling - #12515
Conversation
A system rebuild leaves an empty "<host> <generation>" commit on the laptop clone's main and does not push it. Once origin has moved too, main is ahead and behind at once and the fast-forward-only sync can never pull again: on 2026-11-22 the laptop sat two hours and 28 merges behind with nothing deployed. When every commit only the clone has is empty and not a merge, each is kept under a tag rebuild-marker/<subject> and main is moved to origin/main. A local commit that changes a file, or a merge, still fails loudly and nothing is tagged or moved. A marker that blocks nothing (origin unmoved) is left for the hourly keeper to push. Seven planted faults in the new branch are each caught by the new suite. Takes effect at the next system rebuild: the unit runs the packaged copy. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c37256b495
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| echo "pm-git-sync: kept empty commit $(git log -1 --format='%h "%s"' "$commit") under tag $tag" | ||
| done < <(git rev-list --reverse origin/main..HEAD) | ||
| # --keep refuses to touch a file with local changes; there are none. | ||
| if ! git reset --quiet --keep origin/main || [ "$(git rev-parse HEAD)" != "$remote" ]; then |
There was a problem hiding this comment.
Guard the reset against a concurrently changed HEAD
If a rebuild commits to this checkout after the validation and tagging snapshots, this reset removes the new commit from main without checking or preserving it. This can overlap with normal operation: nixos/services/pm-stack/default.nix:597–602 schedules sync every 30 seconds, while lib/rebuild-simple-script.sh:31 commits in the checkout without coordination. A completed commit leaves clean files, so --keep does not protect it (git reset -h describes it as “reset HEAD but keep local changes”); the previous pull --ff-only would instead refuse the divergence. Coordinate with writers or atomically ensure that the branch being replaced still points to the validated commit before moving it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real, and worth closing even though the window is short. Fixed in the next commit: main is moved only if it is still where it was when its commits were examined (otherwise nothing is moved and the next run looks again), and a commit that lands between that look and the move is kept under rebuild-marker/unexpected-<hash> with a loud failure, so it is never left reachable only from the reflog. Both windows are tested with a stand-in git that commits mid-run; three planted faults in the guard are each caught.
Generated by Claude Code
A rebuild commits in the checkout without coordinating with the sync. Main is now moved only if it is still where it was when its commits were examined, and a commit that lands in the instant between that look and the move is kept under a tag and reported, instead of being left reachable only from the reflog. Both windows are tested with a stand-in git that commits mid-run. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
Why
On 2026-11-22 the laptop's checkout stopped following
mainfor two hours: 28 merges were not deployed, and nothing said so. A system rebuild had left an empty marker commit (amd 569) on the clone'smain;origin/mainhad moved as well, so the clone was ahead and behind at once, andpm-git-synconly ever fast-forwards. It was unstuck by hand (the marker kept under a tag,mainmoved toorigin/main), the same repair as #2496.Every rebuild leaves such a marker (
lib/rebuild-*.sh), and with merges landing all day the clone is almost always behind by the time it does. So this recurs.What changes
pm-git-syncnow does that repair itself, only in the case where nothing can be lost:rebuild-marker/<subject>(its own short hash if that name is taken by another commit) andmainis moved toorigin/mainwithgit reset --keep.Checks
pm-git-sync-markers.test.sh(added topm-stack-tests.yml): ahead only; two markers with origin moved; a name already taken; a subject that is not a valid ref name; a commit with a file change beside an empty one; a local merge.shfmt,shellcheckclean.Takes effect
At the next system rebuild: the unit runs the packaged copy (
pkgs/pm-git-sync, now 0.3.0). That rebuild's own marker is the first one the new copy will meet.Generated by Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit