Skip to content

Comments

.parent link tracking in CRDT nodes#982

Merged
streamich merged 6 commits intomasterfrom
parent-links
Feb 4, 2026
Merged

.parent link tracking in CRDT nodes#982
streamich merged 6 commits intomasterfrom
parent-links

Conversation

@streamich
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 4, 2026 13:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | undefined property to the JsonNode interface 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);
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline between statements. The assertParents calls should be on a new line after the expect statement.

Copilot uses AI. Check for mistakes.
@streamich streamich added this to the Peritext editor integration milestone Feb 4, 2026
@streamich streamich merged commit 1166d0f into master Feb 4, 2026
9 checks passed
@streamich streamich deleted the parent-links branch February 4, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant