Skip to content

fix: abort conflicted upstream-sync merge so update never leaves a broken tree#136

Merged
OmarB97 merged 1 commit into
mainfrom
fix/fork-sync-abort-conflicted-merge
Jun 10, 2026
Merged

fix: abort conflicted upstream-sync merge so update never leaves a broken tree#136
OmarB97 merged 1 commit into
mainfrom
fix/fork-sync-abort-conflicted-merge

Conversation

@OmarB97

@OmarB97 OmarB97 commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Why

The 2026-06-10 in-app update on this fork failed at the rebuild stage with "Update didn't finish". Root cause: the fork upstream sync in _sync_with_upstream_if_needed merged upstream/main into local main, hit conflicts (fork is 57 ahead / 85 behind), printed "Skipping upstream sync" — and returned without aborting the merge. The tree was left mid-merge with conflict markers in 25 files, including hermes_cli/main.py (SyntaxError at line 471 on <<<<<<< HEAD, making hermes itself unbootable) and apps/desktop/package.json (npm EJSONPARSE), so npm install, the web UI build, and the desktop rebuild all failed.

The existing post-pull syntax guard only protects the git pull step; the upstream-sync merge runs after it, unguarded.

What changed

  • hermes_cli/main.py: on merge failure, verify a merge actually started (git rev-parse -q --verify MERGE_HEAD) and run git merge --abort to restore a clean tree before skipping the sync. The message now reports whether the tree was restored, or warns with a git status hint if the abort itself failed.
  • tests/hermes_cli/test_update_fork_sync_conflict_abort.py (new): scripted-git tests covering conflicted-merge-aborts-and-restores, failed-abort-warns, and merge-error-without-MERGE_HEAD-skips-abort.

Evidence

  • PYTHONPATH=$PWD venv/python -m pytest tests/hermes_cli/test_update_fork_sync_conflict_abort.py tests/hermes_cli/test_update_post_pull_syntax_guard.py tests/hermes_cli/test_cmd_update.py -q36 passed (3 new + 33 existing).
  • Incident log (~/.hermes/logs/bootstrap-installer.log): ✗ Merge failed (conflict). Skipping upstream sync. followed by SyntaxError: invalid syntax at main.py:471 <<<<<<< HEAD and npm error code EJSONPARSE in apps/desktop/package.json.
  • Live recovery on the affected install was the same operation this patch automates: git merge --abort returned the tree to fork main and py_compile + JSON.parse both pass again.

Risks

  • Scope is the conflict branch only; successful merges and the push path are untouched.
  • git merge --abort is skipped when no MERGE_HEAD exists (e.g. merge refused before starting), so the warning can't fire spuriously.
  • Upstream does not carry this code path (it skips sync entirely on divergence, fork commit 6d74667 added the merge), so no upstream mirror PR applies.

…oken tree

When the fork upstream sync in _sync_with_upstream_if_needed hit a merge
conflict it printed 'Skipping upstream sync' but returned with the merge
still in progress. The working tree kept conflict markers in critical
files (hermes_cli/main.py, apps/desktop/package.json), making the CLI
unbootable and failing every later update stage: npm install, web UI
build, and the desktop rebuild — surfacing as the desktop 'Update didn't
finish' screen (2026-06-10 incident).

Now a failed merge is aborted (when MERGE_HEAD confirms one started)
before the sync is skipped, and the user-facing message reports whether
the tree was restored.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@OmarB97 OmarB97 merged commit 603c8e1 into main Jun 10, 2026
16 of 22 checks passed
@OmarB97 OmarB97 deleted the fix/fork-sync-abort-conflicted-merge branch June 10, 2026 15:27
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