Repository navigation
Description
Problem
The current doublets-rs lockfile resolves platform-trees to 0.3.4. The unit source and target indexes and the split tree indexes delegate insertion and deletion to that release's IterativeSizeBalancedTree. The default split store uses a linked list for internal sources. Its external source and target tree indexes still use the affected dependency, as does the internal source index of split::TreeStore. That implementation can leave a grandchild larger than its parent's sibling after either insertion or deletion. Source indexes order records with a shared source together, and target indexes do the analogous thing for a shared target. Interleaving shared-endpoint updates with unrelated updates can create the hot/cold key order below. Lockfile · Unit source index · Split source index
Reproduce with the exact locked dependency
The example isolates the tree operations delegated to the dependency and checks Chen's invariant after each operation.
cargo new --edition 2024 tree-index-repro
cd tree-index-repro
cargo add platform-trees@=0.3.4
mkdir -p examples tests/common
source_url=https://raw.githubusercontent.com/linksplatform/trees-rs/fd50f361be00111de53eea78a5b69907bf1fbbc5
curl -fsSL "$source_url/examples/tree_balance.rs" -o examples/tree_balance.rs
curl -fsSL "$source_url/tests/common/mod.rs" -o tests/common/mod.rs
cargo run --quiet --example tree_balance- Interleaving
1, 2049, 2, 2050, …first breaks the invariant at node 3 when the 11th operation inserts key 6. The final height is 17 for 4,096 keys, above the bound of 16. - Starting from a complete 31-node tree, delete
[2, 6, 27, 8, 16, 1, 14, 10, 5, 26, 13, 7, 4]. The final deletion breaks the invariant at node 17. - Both sequences preserve the invariant with the fixed dependency. The insertion workload ends at height 13.
Workaround and proposed fix
For a local test or deployment that can pin a Git dependency, replace the trees dependency in doublets/Cargo.toml with this override and validate source and target queries before deployment. cargo check --lib passes with this exact pin on doublets-rs commit 33c92430.
trees = { package = "platform-trees", git = "https://github.com/linksplatform/trees-rs", rev = "fd50f361be00111de53eea78a5b69907bf1fbbc5" }The unit store, default split store and split tree store also passed a public API smoke check at that pin. Each inserted, deleted and reinserted 1,024 links in an alternating shared-source, unrelated, shared-target and unrelated pattern, with assertions for exact searches and counts by both shared endpoints.
Until that is possible, batching unrelated and shared-endpoint writes can avoid the exact insertion order above. The dependency still has the deletion defect, so scheduling alone gives no balance guarantee.
Once a fixed version ships, update the dependency requirement and workspace lockfiles. Add an index-level regression that alternates shared-endpoint and unrelated writes, removes and reinserts records, and checks the size and height invariants and query results for both source and target indexes in unit and split stores. When opening data produced by older versions, consider a versioned, one-time rebuild_complete on each persisted index root with correct order and subtree sizes. The rebuild preserves record IDs and does not require a new node layout.
Activity