Skip to content

fix(ops): the cron rebased whatever branch the shared checkout was on - #120

Merged
cryptolir merged 1 commit into
mainfrom
fix/cron-no-rebase-off-main
Aug 11, 2026
Merged

cryptolir merged 1 commit into
mainfrom
fix/cron-no-rebase-off-main

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

What happened today

diagnostic-cron.sh pulls $REPO unconditionally with --rebase --autostash. The dashboard checkout immediately below it is already guarded — "only touch it on main — never yank someone's feature branch out from under them". The checkout the cron runs from had no such guard, where the consequence is worse: a --rebase there doesn't merely fail, it rewrites whoever's branch is checked out.

The 06:00 run found /root/AgentGlob_Apps/openclaw on a local feature branch (docs/status-2026-08-10-session, unpushed, 2 commits), rebased it onto main, hit a STATUS.md conflict, and left the repo detached mid-rebase with an unmerged path. The || echo WARN swallowed it, so the run still looked successful.

Every later git pull there failed with needs merge — for ~9 hours, until aborted by hand. The scripts kept running from a half-rebased tree the whole time. I only found it because a verification git pull refused.

Recovery was non-destructive this time (git rebase --abort restored the branch with both commits; its STATUS.md turned out identical to main, the work having already landed as #115) — but nothing about the failure mode guarantees that. The same conflict on genuinely unmerged work is a much worse morning.

The fix

Checkout state Before After
on main pull pull (unchanged)
on a feature branch rebases it skip + warn which branch blocked it
detached / mid-rebase rebases into a wedge loud ERROR + the exact recovery command

The detached/mid-rebase arm is deliberately an ERROR, not a warning: in that state every script below is running from an unknown tree, so "success" is meaningless.

Verified all three arms, including that an off-main checkout skips rather than rewrites.

Relation to OB-32

This is OB-32's mechanism one level worse than that entry describes. OB-32 records the cron silently skipping work when a shared checkout is off main. This is the cron actively corrupting the checkout — and then reporting success.

🤖 Generated with Claude Code

diagnostic-cron.sh pulled $REPO unconditionally with --rebase --autostash.
The dashboard checkout immediately below it is already guarded, with the
comment "only touch it on main — never yank someone's feature branch out
from under them". The checkout the cron RUNS FROM had no such guard, where
the consequence is worse: a --rebase there does not merely fail, it rewrites
whoever's branch is checked out.

Measured today. The 06:00 run found /root/AgentGlob_Apps/openclaw on a local
feature branch (docs/status-2026-08-10-session, unpushed, 2 commits), rebased
it onto main, hit a STATUS.md conflict, and left the repo detached mid-rebase
with an unmerged path. The `|| echo WARN` swallowed it, so the run still
looked successful. Every later `git pull` there failed with "needs merge" —
about 9 hours, until it was aborted by hand. The scripts kept running from a
half-rebased tree the whole time.

Recovery was non-destructive (git rebase --abort restored the branch with
both commits; its STATUS.md turned out to be identical to main, the work
having already landed as #115), but nothing about the failure mode guarantees
that — the same conflict on genuinely unmerged work is a worse morning.

Now: pull only on main; if detached or mid-rebase, print a loud ERROR with
the exact recovery command, because that state means every script below is
running from an unknown tree; otherwise skip the pull and say which branch
blocked it. Verified all three arms, including that an off-main checkout
skips rather than rewrites.

This is OB-32's mechanism, one level worse than that entry describes: OB-32
records the cron silently SKIPPING work when a shared checkout is off main.
This is the cron actively CORRUPTING the checkout, then reporting success.

Co-Authored-By: Claude Opus 5 <[email protected]>
@cryptolir
cryptolir merged commit d734fc7 into main Aug 11, 2026
15 of 20 checks passed
@cryptolir
cryptolir deleted the fix/cron-no-rebase-off-main branch August 11, 2026 11:55
cryptolir added a commit that referenced this pull request Aug 11, 2026
…n it's stale (#122)

#120 stopped this cron from rebasing whoever's branch was checked out in the
shared repo. That was the bleeding, not the wound: the cron was still RUNNING
from a checkout people work in, so it stayed exposed in both directions.

The cure was already in this file, 20 lines lower. $DASH_REPO has been a
cron-owned detached worktree since the 53-silent-skip incident, precisely so no
human action can disable it. The checkout the cron runs from never got the same
treatment. So it now points at .openclaw-autoscan, a worktree nobody edits,
re-pinned to origin/main by its own 05:40 crontab line — while nothing is
executing from it, because rewriting a script under a running bash is its own
bug.

That leaves this script read-only against git: fetch to learn where main is,
never pull, never branch-switch.

And the second half of 2026-08-11 — nobody knew for ~9 hours. #120's guard
printed to stdout, so the loud ERROR went to /var/log/agentglob-diag.log and
the email still looked normal. Identical silence, new wording. This file has
had the right mechanism all along: warn_sync() puts a warning in the email body
AND the subject (⚠ SYNC FAILED), built after 53 skipped runs went unread in
that same log. The guard now calls it, which meant hoisting warn_sync above the
check instead of leaving it defined 15 lines below.

Also fixes a bug in #120's guard that would have made it useless in the very
worktree it protects: `-d .git/rebase-merge` can never be true there, because
`.git` is a FILE in a worktree and rebase state lives under
.git/worktrees/<name>/. This file already warns about that trap for $DASH_REPO.
Now asks git via `rev-parse --git-path`; confirmed resolving to
.git/worktrees/wt-dbg/rebase-merge.

Verified all three arms in a real worktree, each checked for the warning
reaching SYNC_WARNINGS and not just stdout:
  - detached at origin/main            -> clean
  - one commit behind (pin died)       -> stale WARN with both short SHAs
  - genuine conflicted rebase          -> MID-REBASE WARN + recovery command

Co-authored-by: Liran Peretz <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
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.

1 participant