Repository navigation
Validate sizes, order, balance and threads of all trees like GLib's g_tree_node_check - #112
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #12
Implements validation logic from GNOME/glib/gtree.c for tree integrity checks including: - Balance factor validation (comparing calculated vs stored balance) - AVL property validation (balance factor must be -1, 0, or 1) - Height calculation for tree nodes - Recursive validation of subtrees - Integration with existing size validation The validation is enabled by ENABLE_TREE_AUTO_DEBUG_AND_VALIDATION and follows the same patterns as the GLib implementation. Includes comprehensive test coverage. Fixes issue #12 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
We need to double check we have full tests coverage and all tests and quality checks expected for trees and nothing is missing, so all our collection algorithms are fully covered with tests and checks, if we prove with any tests we have a bug - we fix it here. |
|
🤖 AI Work Session Started Started at 2026-12-04T01:55:17.284Z. Please wait for it to finish before giving feedback. Runtime: solve |
…e_node_check ValidateTree checks the sizes and the order of every tree, the size balanced tree properties of both size balanced trees, and the balances, the AVL property and the threads of the AVL tree. The validation mode runs it after every attach and detach, and the balance tests run it after every operation. The AVL tree prints its threads like g_tree_node_dump.
…ee_node_check ValidateTree checks sizes and order of every tree, the size balanced property of the size balanced trees, and balances and threads of the AVL tree. Attach and Detach run it under ENABLE_TREE_AUTO_DEBUG_AND_VALIDATION. TreeValidationTests mirror the C# tests, and the README describes the checks.
…k of an empty tree Codacy (SonarCSharp S3241) flagged the returned height that only the recursive calls use. An empty C# tree no longer reads node 0, as in C++.
# Conflicts: # cpp/Platform.Collections.Methods.Tests/InspectableTree.cpp # cpp/Platform.Collections.Methods/Platform.Collections.Methods.TemplateLibrary.nuspec # cpp/Platform.Collections.Methods/Trees/SizeBalancedTreeMethods.h # cpp/Platform.Collections.Methods/Trees/SizedAndThreadedAVLBalancedTreeMethods.h # csharp/Platform.Collections.Methods.Tests/InspectableSizedAndThreadedAVLBalancedTree.cs # csharp/Platform.Collections.Methods/Platform.Collections.Methods.csproj # csharp/Platform.Collections.Methods/Trees/SizeBalancedTreeMethods.cs # csharp/Platform.Collections.Methods/Trees/SizedBinaryTreeMethodsBase.cs
Main now checks with Doxygen that every public and protected C# and C++ element is documented, so ValidateTree, ValidateSizeBalance, the AVL test setters and the validation tests get bilingual summaries, parameters, returns and exceptions.
Working session summaryPR #112 is now mergeable with main again, and every CI check passes on the latest commit (
The PR is out of draft and ready to merge. This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
📊 Context and tokens usage:Claude Opus 5.5: (4 sub-sessions)
Total: (19.3K new + 373.3K cache writes + 12.1M cache reads) input tokens, 116.8K output tokens, $7.811167 cost 🤖 Models used:
📎 Log file uploaded as Gist (5642KB)This AI session has ended. Monitoring of this pull request continues. Feel free to review and add feedback while checks are running. |
🎉 Auto-mergedThis pull request has been automatically merged by hive-mind.
Linked issues
|
Summary
Adds the validation logic of
g_tree_node_checkandg_tree_node_dumpfrom GLib's gtree.c to all trees, in C# and in C++.ValidateTree(root)checks a whole tree. It throws the first broken rule (InvalidOperationExceptionin C#,std::runtime_errorin C++), with the same messages in both languages:ValidateSizes).g_tree_node_check, and is within -1..1.g_tree_node_check's check that the neighbours point back to the node.Like
g_tree_node_dump,PrintNodeof the C# AVL tree now prints the nonzero threads of a node (<left,>right).With
ENABLE_TREE_AUTO_DEBUG_AND_VALIDATION,AttachandDetachnow runValidateTreeafter the operation instead of onlyValidateSizes. Before the operation they still check only sizes, because the size balanced trees rebuild trees that older code built without the size balanced property.Tests and checks (per the review comment)
TreeValidationTests(C# and C++):AssertBalancedinTreeBalanceTestsnow runsValidateTreeafter every attach and detach of the existing workloads.ValidateTree,ValidateSizeBalance, the AVL test setters and the new tests have XML documentation in English and Russian, so the Doxygen documentation check of main passes after the merge.Local results:
-p:TreeValidation=true, with 100% line coverage.TREE_VALIDATION=1, with 100% line coverage of the headers (908/908, gcovr 8.8).The README Tests section, the release notes of the unreleased C# 1.0.1 and C++ 0.4.0 packages, and
dev/log/issues/12/pulls/112describe the checks.How to verify
Fixes #12