Repository navigation
fix(coding-agent): a re-run move import accepts a landed session file even after a lost accepted write - #3998
Merged
Merged
Conversation
… even after a lost accepted write
…nd a re-run import accepts it
…ccept overrides only receiving
…tion leaves a landed move receiving
…, even from an overlapping import
…ords nothing once that commit lands the move
…eued failure never lands beside a landed move
code-yeongyu
added a commit
that referenced
this pull request
Oct 22, 2026
…review) beginReceive fences any accepted record, revoked or not: re-importing the move's own file still returns early before it, and #3998's lost-write path ('receiving') is unchanged, but an import into another folder is refused move_fenced and writes nothing. rpc.md: the import rule, and repeat a revoke that did not succeed before acting on any status.
code-yeongyu
added a commit
that referenced
this pull request
Oct 22, 2026
beginReceive records the session file the first import lands as; an import for another target is fenced while the move is receiving or accepted, and commit renames only into the recorded target (concurrent imports, and an import after a lost accepted write, can no longer land a second copy). The same-file early return goes through confirmLanded, keeping #3998's lost-write path; a deleted copy re-lands at its own target unless the move was revoked.
code-yeongyu
added a commit
that referenced
this pull request
Oct 22, 2026
Conflicts with #3998 (move import file authority) in session-move/import.ts and move-ledger.ts: keep main's landed() guard (fail/decline unlessLanded) and the settle/settleLocked split, call this PR's confirmLanded for an already landed file (it covers main's accept: fences ready/declined/failed, plus the target fence and revoke mark), and keep the committing guard inside settleLocked. main's two #3998 tests are ported to commit(moveId, target, rename, prepare); a failed pre-rename commit stays committing until the sender's status path settles it failed, so that assertion reads through answerMoveStatus.
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.
Part of desktop app item 3137, tracked internally (desktop#4008 handover).
Bug
When a move's session file already carries
session_moved_in,importMovedSessiontreats the file as the authority, but it calledledger.commit, which refuses afailedrecord. If theacceptedwrite failed after the rename, the import's catch recordedfailed{import_failed}, and every re-run of the idempotent import then threwmove_fenced, although the session file was landed and writable.Fix
fail(moveId, reason, { unlessLanded })evaluates the landed check under the move's lock, right before writing, so a failure queued behind an overlapping commit cannot writefailedbeside the file that commit just landed. This covers the commit catch and theverifyBundlecatch. The repository decline is skipped once the file has landed. A lostacceptedwrite therefore leaves the movereceiving, so astatuscall withoutsessionPathnever reportsfailedfor a landed move.MoveLedger.accept(moveId)is used by the file-authority branch. It overrides onlyreceiving; a missing record (lost ledger) and an existingacceptedare also accepted. It refusesready,declinedandfailed, so an answer a sender may have heard never changes.acceptedonly if the import is re-run before anyone asks: astatuscall withoutsessionPathfences a missing record asdeclined/no_recordfirst.Evidence (fresh clone on a second machine,
bun install --frozen-lockfile --ignore-scripts)RED: two tests-only commits, each run before its fix.
5d7969e: the lost-
accepted-write case readsexpected { state: 'failed', ... } to deeply equal { state: 'receiving' }, andaccepton afailedrecord failed with "promise resolved undefined instead of rejecting".4e9af89: the first overlapping-imports case (B lands the file and loses
acceptedbetween A's landed check and A'sverifyBundle) readsexpected { state: 'failed', ... } to deeply equal { state: 'receiving' }.92297b0: A's
failis queued behind B's commit lock and B lands the file then losesaccepted(deterministic gates, no sleeps):expected { state: 'failed', ... } to deeply equal { state: 'receiving' }at the then-head code.GREEN at fc36c4e:
session-move*,rpc-move-session*andno-sync-in-session-path: 19 test files passed.tsc --noEmit,bun run check,bun run build,scripts/check-pr-changelog.mjs --base 2faff41b45and the conflict-marker grep all exited 0.