Repository navigation
Graph: treat updater returning the same node instance as no edit - #6095
Closed
William Wong (compulim) with Copilot wants to merge 1 commit into
Closed
William Wong (compulim) with Copilot wants to merge 1 commit into
William Wong (compulim) with Copilot wants to merge 1 commit into
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.
In
packages/store-graph, anupsert()whose updater returns the node it received should leave that node unchanged. On insert, the updater receivesundefined, so returning it must still throw.Behavior
isPartOfis still auto-fixed instead of throwing.undefinedstill fails validation increateDraftNode(). This PR adds a test for it.A clean read never has pending
hasPart/isPartOflinks to confirm. Any link added by the other side during the transaction turns the node into a dirty read. So returning early on a clean read skips no conflict checks.Changes
Graph.ts: the updater call moves into arunUpdater()closure, which returnsundefinedon a clean-read no-op. This also keepsupsertunder ESLint's complexity limit of 20. Theupsert()JSDoc describes the new behavior.Graph.test.ts: tests for the no-op case (same snapshot, no notification), auto-fix after a no-op, and insert returningundefined.OPINIONS.md: documents the rule and the dirty-read exception.Open question
Should returning the same instance on a dirty read also be a no-op? That would mean freezing dirty reads, which breaks the current in-place-edit contract.