Recover a Cloud machine graph stuck on an equal-cursor conflict
Summary
A Cloud or SSH machine's graph can wedge for the life of the app. A full snapshot and the graph the deltas built can disagree at the same cursor. When they do, installSnapshotIfNewer refuses the snapshot as an "equal-cursor conflict", and no later read at that cursor ever succeeds. refreshCurrentGraph never becomes current, and opens on that machine fail until relaunch. #15205 fixes one known cause (exited terminals' tab fields). Any other strictly compared field that differs at the same revision still wedges: cwd, lifecycle, or keys the model doesn't include.
Now:
- The first conflict from a current full refresh keeps the installed graph, records the cursor, and schedules the existing bounded state-recovery read.
- A second conflict at the same cursor adopts the daemon's full snapshot and leaves a
cloud.state.equalCursorConflictAdoptedbreadcrumb. A full read at the current cursor is the daemon's own answer. So a wedge always breaks, and a single race never discards the graph. - Only a current full refresh can arm or adopt. Event-feed snapshots and reads that started before a newer install keep today's behavior (refused).
- Which side wins: adoption replaces the whole graph, like any fresh install. A field or key the daemon does not send is absent afterwards rather than kept from the delta-built graph. App-side overlays (pending renames, pending creations) live outside
cloudStateand are reapplied on publish. A pending rename's predecessor is still refused outright and never arms recovery. - Recovery budget: a successful adoption resets the recovery count, so it does not use up the budget event-feed barriers rely on.
Composes with #15205 and #15283: git merge-tree shows no source conflict with either. The only overlap with #15283 is both PRs adding a test file to project.pbxproj, which catch-up regenerates.
Testing
- New
cmuxTests/CloudEqualCursorConflictRecoveryTests.swift, committed failing before the fix:- the first full-refresh conflict keeps the graph and arms recovery, and a second adopts
- an event-feed conflict never adopts
- a stale read never adopts
- a newer install clears an armed conflict, and a conflict at the new cursor starts over
scripts/sync-test-wiringfor the pbxproj.scripts/verify-local.pypasses. No local native build; CI runs the tests.- No fleet dogfood. Reproducing needs a daemon whose full snapshot and deltas disagree at one revision (the #15205 bug is one such case). The unit tests drive the exact install path the refresh uses.
Changelog
Fixed: a Cloud or SSH machine whose state got out of sync no longer stays stuck until relaunch; the next refresh recovers it.
🤖 Generated with Claude Code
Summary by cubic
Recovers a Cloud or SSH machine's graph that was permanently stuck when a full snapshot disagreed with the delta-built graph at the same cursor. The first such conflict from a full refresh keeps the installed graph and schedules the bounded state-recovery read; a second conflict at the same cursor adopts the daemon's full snapshot, so the wedge always breaks.
- Only the full refresh that armed it schedules that recovery read, so stale or rename-fenced reads can't spend the budget.
- A delta advancing the cursor, a newer or equal-content install, and a feature-flag suspend clear the armed conflict; a successful adoption resets the recovery count.
- Event-feed snapshots and stale reads never arm or adopt; a pending rename's predecessor is still refused outright.
- Adds
CloudEqualCursorConflictRecoveryTestscovering the arming, adoption, fence, suspend, and clearing paths.