Skip to content

refactor: unify/cleanup methods of treecrdt in core package#124

Merged
Antonov548 merged 5 commits intomainfrom
refactor/tree
Apr 21, 2026
Merged

refactor: unify/cleanup methods of treecrdt in core package#124
Antonov548 merged 5 commits intomainfrom
refactor/tree

Conversation

@Antonov548
Copy link
Copy Markdown
Collaborator

Refactor: unify apply_remote and simplify TreeCrdt API

Reduces API surface of treecrdt-core by merging three remote-apply methods into one unified apply_remote, removing dead code, and extracting helpers into dedicated modules.

Key changes

  • Unified apply_remote: merged apply_remote(), apply_remote_with_delta(), and apply_remote_with_materialization_seq() into a single apply_remote() -> Result<Option<ApplyDelta>>. Materialization behavior is driven by a new ParentOpIndex type parameter on TreeCrdt (defaults to NoopParentOpIndex — compiles to no-ops for in-memory/WASM usage).
  • Simplified finalize_local: removed external &mut index parameter; uses the embedded index.
  • Single local-op method per type: consolidated duplicated base/with_plan variants of local_insert, local_move, local_delete, local_payload.
  • Extracted helper modules: moved types to types.rs, affected-node helpers to affected.rs, validation to validation.rstree.rs reduced from 1200 to 780 lines.
  • Removed dead code: unused methods, redundant constructors, excess visibility.
  • Replaced PersistedRemoteStores with MaterializationStores struct used by both materialize_persisted_remote_ops_with_delta and catch_up_materialized_state.

Adapter impact

  • WASM: no type signature change (defaults apply); both appendOp/appendOpWithDelta call unified apply_remote.
  • SQLite/Postgres: session TreeCrdt now constructed with the real ParentOpIndex impl; finalize_local calls simplified.

@Antonov548 Antonov548 marked this pull request as ready for review April 19, 2026 16:53
@Antonov548 Antonov548 merged commit 921fbca into main Apr 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants