Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds parent link tracking to all CRDT nodes by introducing a .parent property that references the parent node containing each child. This enables efficient tree traversal upward from any node to its root.
Changes:
- Added
parent: JsonNode | undefinedproperty to theJsonNodeinterface and all node implementations (VecNode, ValNode, StrNode, ObjNode, ConNode, BinNode, ArrNode, ExtNode) - Updated
Model.applyOperation()to set parent links when nodes are inserted into containers (InsObjOp, InsVecOp, InsValOp, InsArrOp, UpdArrOp) - Added
linkParents()method to rebuild all parent links recursively, called after fork/clone/reset operations - Updated garbage collection to clear parent links when nodes are deleted
- Modified all decoders to set parent links during deserialization
- Added comprehensive test suite for parent link tracking
Reviewed changes
Copilot reviewed 33 out of 34 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/json-joy/src/json-crdt/nodes/types.ts | Added parent property to JsonNode interface with documentation |
| packages/json-joy/src/json-crdt/nodes/vec/VecNode.ts | Added parent property implementation |
| packages/json-joy/src/json-crdt/nodes/val/ValNode.ts | Added parent property implementation |
| packages/json-joy/src/json-crdt/nodes/str/StrNode.ts | Added parent property implementation |
| packages/json-joy/src/json-crdt/nodes/obj/ObjNode.ts | Added parent property implementation |
| packages/json-joy/src/json-crdt/nodes/const/ConNode.ts | Added parent property implementation |
| packages/json-joy/src/json-crdt/nodes/bin/BinNode.ts | Added parent property implementation |
| packages/json-joy/src/json-crdt/nodes/arr/ArrNode.ts | Added parent property implementation |
| packages/json-joy/src/json-crdt/extensions/ExtNode.ts | Added parent property implementation |
| packages/json-joy/src/json-crdt/model/Model.ts | Updated operations to set parent links, added linkParents() method, updated fork/reset/GC |
| packages/json-joy/src/json-crdt/model/tests/util.ts | Added assertParents utility for testing parent links |
| packages/json-joy/src/json-crdt/model/tests/Model.parent.spec.ts | Comprehensive test suite for parent link functionality |
| packages/json-joy/src/json-crdt/codec/structural/verbose/Decoder.ts | Set parent links during node decoding |
| packages/json-joy/src/json-crdt/codec/structural/compact/Decoder.ts | Set parent links during node decoding |
| packages/json-joy/src/json-crdt/codec/structural/binary/Decoder.ts | Set parent links during node decoding |
| packages/json-joy/src/json-crdt/codec/sidecar/binary/Decoder.ts | Set parent links during node decoding |
| packages/json-joy/src/json-crdt/codec/indexed/binary/Decoder.ts | Call linkParents() after decoding |
| packages/json-joy/src/json-crdt/model/api/NodeEvents.ts | Reordered imports (cosmetic) |
| Various decoder test files | Added assertParents checks to existing tests |
| @@ -90,6 +101,8 @@ describe('logical', () => { | |||
| const doc2 = decoder.decode(encoded); | |||
| expect(doc1.view()).toEqual(json); | |||
| expect(doc2.view()).toEqual(json); | |||
There was a problem hiding this comment.
Missing newline between statements. The assertParents calls should be on a new line after the expect statement.
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.
No description provided.