Repository navigation
shared-node-store: fix updateTaskNode()'s success-path field clobber via shared-reference mutation - #2096
Merged
Conversation
…via shared-reference mutation updateTaskNode()'s success handler read this.nodes.get(nodeId) at the moment a write's RPC resolved and unconditionally Object.assign'd ALL six type-specific fields (status, priority, dueDate, assignee, startedAt, completedAt) from that write's own response onto it. If a second updateTaskNode() call for the same node applied its own optimistic update to a DIFFERENT field while the first was still executing, the first write's response — which reflects the server's view as of its own request, frozen for every field it never touched — clobbered the second write's still-in-flight optimistic value for that other field. Confirmed with a repro before applying any fix: write A changes priority, write B (submitted while A is executing) changes status; once A's RPC resolves, the store's status reverted to A's stale pre-B value, discarding B's optimistic status change, even though B's own write hadn't been sent to the server yet. Fixed by limiting each write's applied patch to only the fields that write's own request actually asked to change (mirroring what localChanges already does for the optimistic apply earlier in the same method) — a field a write didn't touch is left exactly as the store currently has it, however it got there. version is still always applied unconditionally: PersistenceCoordinator serializes real RPCs per node, so the version a response carries is always the latest authoritative one. Added updatetasknode-success-clobber-regression.test.ts: the primary test is verified to fail against the pre-fix code (write B's still-in-flight optimistic field survives write A's unrelated-field success response); a second test checks the fix doesn't break normal eventual consistency once both writes' real persist attempts complete. Closes #2090 Co-Authored-By: Claude <[email protected]>
Contributor
Author
|
APPROVE Independently re-verified:
Merging. |
This was referenced Aug 14, 2026
shared-node-store: fix updateTaskNode() surfacing zero notification on a non-OCC write failure
#2098
Merged
mstomar125
added a commit
that referenced
this pull request
Aug 17, 2026
… clobber window (#2099) * Close updateTaskNode() same-field concurrent-write clobber window Field-scoping (from #2096) stops a write's response from clobbering a concurrently-resolving write's DIFFERENT field, but a write's own confirmed value for a field it DID change can still transiently overwrite a newer optimistic write for that SAME field, since the response reflects the server's state as of this write's own request and predates the newer write. Add a per-node, per-field write-sequence counter: updateTaskNode() bumps it for each field at optimistic-apply time and captures the number; when its RPC resolves, it only applies its confirmed value for a field if the sequence hasn't moved on since (no newer same- field write raced in). The newer write's own RPC still applies its own confirmed value when it resolves, so the store converges either way - this just closes the transient wrong-value window in between. Co-Authored-By: Claude <[email protected]> * Restore taskFieldWriteSeq on subtree-access-denied delete refusal Address review finding on #2099: deleteNode()'s optimistic removal wipes a node's per-field write-sequence map, but the subtree-access-denied refusal path only restored versions/persistedNodeIds, not this map - leaving a resurrected node's field sequences silently reset to zero. Not currently reachable (updateTaskNode() no-ops on a missing node, and the success handler already gates on the node still being present), but it broke the restore symmetry with versions/persistedNodeIds and would become a live gap under a future change to either guard. Capture and restore the map the same way removedVersion is handled. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
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.
Summary
updateTaskNode()'s success handler readthis.nodes.get(nodeId)at the moment a write's RPC resolved and unconditionallyObject.assign'd ALL six type-specific fields (status,priority,dueDate,assignee,startedAt,completedAt) from that write's own response onto it. If a secondupdateTaskNode()call for the same node applied its own optimistic update to a DIFFERENT field while the first was still executing, the first write's response — which reflects the server's view as of its own request, frozen for every field it never touched — clobbered the second write's still-in-flight optimistic value for that other field.This issue was filed as an unverified out-of-scope observation during #2089's review. I reproduced it concretely before writing any fix: write A changes
priority, write B (submitted while A is executing) changesstatus. Once A's RPC resolves, the store'sstatusreverted to A's stale pre-B value, discarding B's optimistic status change — even though B's own write hadn't been sent to the server yet.Fix
Limited each write's applied patch to only the fields that write's own request actually asked to change (mirroring what
localChangesalready does for the optimistic apply earlier in the same method). A field a write didn't touch is left exactly as the store currently has it, however it got there.versionis still always applied unconditionally:PersistenceCoordinatorserializes real RPCs per node, so the version a response carries is always the latest authoritative one.Tests
updatetasknode-success-clobber-regression.test.ts:git stash): write B's still-in-flight optimistic field survives write A's unrelated-field success response.Full suite run cold (cache cleared) — all 210 files / 4656 tests green except one flaky, unrelated pre-existing test (
architecture-benchmarks.test.ts's scaling-factor timing assertion) that reproduces independently of this change and passes in isolation and on repeat full runs — consistent with the same load-sensitive flakiness pattern seen in #2088's PR.Closes #2090
🤖 Generated with Claude Code