Skip to content

Restore Chen balancing for recursive and iterative size-balanced trees - #33

Merged
konard merged 5 commits into
mainfrom
issue-32-a9d8fedbb6a8
Nov 30, 2026
Merged

konard merged 5 commits into
mainfrom
issue-32-a9d8fedbb6a8

Conversation

@konard

@konard konard commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #32

Changes

  • Use Chen's bottom-up maintenance for recursive and iterative tree updates. Both variants apply the same rotations and preserve the same shape. The iterative variant tracks the insertion direction to skip unnecessary grandchild reads.
  • Rebuild legacy trees in place with Day–Stout–Warren. A successful edit that encounters a path beyond the AVL height bound rebuilds before retrying. An explicit rebuild on open also covers violations on shorter paths.
  • Preserve the storage layout and node IDs, reject missing or mismatched nodes before mutation, and keep inspection in the tests and examples.
  • Enforce 100% library line coverage in CI, keep the three-OS test matrix, and add a manual benchmark mode. Include timings, allocation measurements, and capacity limits for both tree variants and both circular list variants in the crate README.
  • Prepare crates.io trusted publishing with the existing token fallback and a minor-release changelog fragment.

Reproduce and verify

cargo run --locked --example tree_balance checks the invariant after each edit. The same example on crates.io platform-trees 0.3.4 first fails at node 3 on the 11th hot/cold insertion, and ends at height 17 for 4,096 keys (bound 16). An independent complete-tree deletion sequence fails at node 17. The fixed release candidate preserves the invariant on both workloads and finishes the insertion workload at height 13. Before · After

The automated checks interleaved_attachments_keep_every_subtree_balanced and deleting_from_a_complete_tree_preserves_balance reproduce those failures. The broader suite compares rotations and node layouts for the two algorithms and checks 40,320 insertion orders, 322,560 first deletions, and recovery from a 4,096-node legacy chain. The local verification reports 131 unit and integration tests, four doctests, and 700/700 covered library lines. Regression tests · Coverage

cargo run --locked --release --example benchmark_collections prints the comparison. Choose benchmarks in the workflow dispatch to record the release-mode report and upload it as an artifact. README measurements · Hosted benchmark run · 32-row report

The final commit passed on Linux, macOS, and Windows. Its hosted coverage gate measured 656/656 instrumented lines on Rust 1.100.1, and the package check confirmed the README includes the benchmark table. Final CI run

Investigation and downstream report

The case study includes the complete requirement map, archived GitHub data and benchmark artifacts, and the migration analysis. The downstream library builds against the pinned Git fix. In-memory unit and split stores also passed 1,024 interleaved shared-endpoint inserts, deletions, and reinserts, with assertions for searches and endpoint counts. Its issue tracks the dependency update and persisted-index validation. Case study · doublets-rs #99

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #32
@konard konard self-assigned this Nov 30, 2026
@konard konard changed the title [WIP] We must apply here in Rust version all the same fixes for trees, so they perform in a best possible way Restore Chen balancing for recursive and iterative size-balanced trees Nov 30, 2026
@konard
konard marked this pull request as ready for review November 30, 2026 05:33
@konard

konard commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Working session summary

PR #33 is ready for review. It restores Chen balancing for recursive and iterative updates, adds in-place recovery for legacy trees, and prepares crates.io trusted publishing with the existing token fallback. Case study and evidence

The 4,096-key regression now preserves balance after every insertion and finishes at 13 levels, down from 17. The independent deletion regression also passes. All PR checks passed on Linux, macOS, and Windows with 100% library line coverage. The hosted benchmark produced all 32 results, and the 15-minute review window closed with no findings. CI · Benchmarks

I reported the affected Rust consumer and verified the pinned fix with insert, delete, reinsert, and query checks in its unit and split stores. doublets-rs #99


This summary was automatically extracted from the AI working session output.

@konard

konard commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-6.2 Sol
  • Provider: OpenAI
  • Public pricing estimate: $5.269474

📊 Context and tokens usage:

  • 289.3K input tokens across requests (cumulative, larger than the 272K context window, so not one request's context), 91.7K / 128K (72%) output tokens

Total: (289.3K + 13.7M cached) input tokens, 91.7K output tokens, $5.269474 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-6.2-sol
  • Thinking level: xhigh (~31999 tokens)
  • Model: GPT-6.2 Sol (gpt-6.2-sol)

📎 Log file uploaded as Gist (1181KB)


This AI session has ended. Monitoring of this pull request continues. Feel free to review and add feedback while checks are running.

@konard

konard commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No uncommitted changes

@konard
konard merged commit 0b814ae into main Nov 30, 2026
27 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.

We must apply here in Rust version all the same fixes for trees, so they perform in a best possible way

1 participant