Repository navigation
State move: keep running holders after clock corrections; refuse a foreign unfinished move - #873
Merged
Merged
Conversation
ualtinok
force-pushed
the
fix/state-move-fence
branch
2 times, most recently
from
November 23, 2026 17:33
8295127 to
b0ebf28
Compare
…move while another state folder's move is unfinished
ualtinok
force-pushed
the
fix/state-move-fence
branch
from
November 23, 2026 17:48
b0ebf28 to
5fea617
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two defects in the shared state-move code (used by OpenCode since 2.9.0), found by an Athena audit of the pending Pi move.
A running older plugin could be treated as gone after a clock correction.
holderEntryIsLiveapplied the before-this-boot rule (which reads the wall clock) before the pid and incarnation check. A process that registered while the clock was slow, then saw the clock corrected forward, looked older than this boot, so the move fence skipped it and a later registration could prune it. Now a dead pid is stale; a known incarnation decides (equal = live, different = reused pid); only when the incarnation can't settle it does the boot rule apply.A crashed move could be taken over by a start with another
XDG_STATE_HOME. If a move stopped right after setting the journal aside, a start under a different state root saw no record of its own, moved without the journal and retired the old files, leaving neither attempt able to serve local accounts. Under the old folder's holder lock, before snapshotting, the mover now looks for another attempt's set-aside journal and refuses (move-unfinished-elsewhere), naming the journal and telling the user to start again with the setting used then. Nothing is adopted or removed.Tests (red on main, green here): a wall-clock step forward with a matching incarnation keeps the holder and the next registration doesn't prune it; a foreign unfinished move refuses with the old folder byte-identical, and the original start still rolls back and finishes; a start's own crashed move under another state root still recovers.
Known residual: the check for artifacts of plugin releases older than 2.4.0 (
preNArtifactBlockers) still compares a process's start time with a wall-clock timestamp, so a clock step can make a live pre-2.4.0 process look like a reused pid. Those releases register nothing; not changed here.

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issue was found.Summary
Keeps live holders after a forward clock correction and stops a new move when another state folder owns a set-aside journal.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Start under layout lock] --> B{Own unfinished move?} B -- Yes --> C[Roll back own move] C --> A B -- No --> D[Take holder locks] D --> E{Can list journal folder?} E -- No --> F[Recheck pointers and stay legacy] E -- Yes --> G{Set-aside journal exists?} G -- Yes --> H[Refuse and request original state setting] G -- No --> I[Check holders and move preconditions] I --> J[Move only when safe]Reviews (3) · Last reviewed commit: "Changelog: under Unreleased" · Reviewed by Greptile