feat(#106): integrate BlockState machine into PersistMemoryManager#107
Merged
netkeep80 merged 4 commits intonetkeep80:mainfrom Mar 7, 2026
Merged
feat(#106): integrate BlockState machine into PersistMemoryManager#107netkeep80 merged 4 commits intonetkeep80:mainfrom
netkeep80 merged 4 commits intonetkeep80:mainfrom
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: netkeep80#106
…anager
Migrate all allocator internals from legacy BlockHeader layout to Block<A>
(LinkedListNode<A> + TreeNode<A>) layout, and use BlockState machine
methods from block_state.h throughout:
- allocator_policy.h: Complete rewrite using state machine transitions:
* allocate_from_block: FreeBlock → remove_from_avl → FreeBlockRemovedAVL
→ begin_splitting/finalize_split or mark_as_allocated → AllocatedBlock
* coalesce: FreeBlockNotInAVL → begin_coalescing → CoalescingBlock
→ coalesce_with_next/coalesce_with_prev → finalize_coalesce → FreeBlock
* rebuild_free_tree: uses recover_block_state<A>() per block
* recompute_counters/repair_linked_list: use Block<A> field names (weight)
- free_block_tree.h: Rewrite AvlFreeTree to use Block<A>* (BlockT) instead
of BlockHeader*, updating all field accesses to Block<A> byte positions
- types.h: Add Block<A>* utilities alongside legacy BlockHeader* ones:
* block_at_block(), block_idx(Block<A>*), block_total_granules(Block<A>*)
* is_valid_block(): use weight (byte 24) instead of size (byte 0)
* header_from_ptr(): returns Block<A>*, checks weight == 0
* user_ptr(Block<A>*) overload
- abstract_pmm.h: Update to new API:
* allocate(): pass idx (uint32_t) to allocate_from_block instead of BlockHeader*
* deallocate(): use AllocatedBlock::mark_as_free() state transition
* init_layout(), do_expand(): use Block<A> fields throughout
* Add #include block.h and block_state.h
- tests/test_issue106_block_state_integration.cpp: New integration test
verifying state machine transitions in full PMM lifecycle (10 test suites)
- docs/atomic_writes.md: Update to reflect Block<A> layout, weight field,
and BlockState machine API in state transition diagrams
All 29 tests pass (28 original + 1 new).
Acceptance criteria met:
- No direct assignments to legacy size/root_offset fields in allocator_policy.h
- All existing tests pass
- New state machine integration tests added
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit 05a619c.
Contributor
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
Contributor
Author
🔄 Auto-restart triggered (attempt 1)Reason: CI failures detected Starting new session to address the issues. Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable. |
Fix clang-format violations in files added as part of issue netkeep80#106 implementation. The CI clang-format check was failing due to misaligned consecutive declarations and assignments in include/pmm/*.h and tests/test_issue106_block_state_integration.cpp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
🔄 Auto-restart-until-mergeable Log (iteration 1)This log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
Contributor
Author
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #106: Integration of BlockState Machine and full migration to its use in PersistMemoryManager.
What changed
allocator_policy.h(v0.3): Complete rewrite using BlockState machine transitions fromblock_state.hinstead of direct field assignments toBlockHeader:allocate_from_block():FreeBlock → remove_from_avl → FreeBlockRemovedAVL → [split] SplittingBlock/finalize_split or mark_as_allocated → AllocatedBlockcoalesce():FreeBlockNotInAVL → begin_coalescing → CoalescingBlock → coalesce_with_next/prev → finalize_coalesce → FreeBlockrebuild_free_tree(): callsrecover_block_state<A>()per block (Issue интеграция BlockState Machine и полный переход на её использование в PersistMemoryManager #106 requirement)recompute_counters()/repair_linked_list(): useBlock<A>field names (weightinstead ofsize)allocate_from_block(base, hdr, uint32_t blk_idx, user_size)andcoalesce(base, hdr, uint32_t blk_idx)now accept granule index instead ofBlockHeader*free_block_tree.h(v1.1): RewriteAvlFreeTreeto useBlock<AddressTraitsT>*(BlockT) instead ofBlockHeader*, updating all AVL field accesses toBlock<A>byte positions (next_offsetat byte 4,left_offsetat byte 8, etc.)types.h(v2.1): AddedBlock<A>*utilities:block_at_block(),block_idx(Block<A>*),block_total_granules(Block<A>*)is_valid_block(): usesweight(byte 24) instead ofsize(byte 0)header_from_ptr(): returnsBlock<A>*, checksweight == 0user_ptr(Block<A>*)overloadabstract_pmm.h(v0.4): Updated to new API:allocate(): passesidx(uint32_t) toallocate_from_blockinstead ofBlockHeader*deallocate(): usesAllocatedBlock::mark_as_free()state transitioninit_layout(),do_expand(): useBlock<A>fields throughout (no moreBlockHeader*direct access)tests/test_issue106_block_state_integration.cpp(new): 10 integration test suites verifying state machine transitions in full PMM lifecycle (weight field, allocate/deallocate transitions, coalescing, recover_block_state, detect_block_state, split path)docs/atomic_writes.md: Updated to reflectBlock<A>layout (weight field), BlockState machine API in state transition diagramsBinary layout change
The internal block format changed from
BlockHeader(size at byte 0) toBlock<A>(weight at byte 24). Both are 32 bytes. This is not backward-compatible with existing PMM images created with older versions.Acceptance criteria
sizeandroot_offsetfields inallocator_policy.h(uses state machine methods)test_issue106_block_state_integration(10 test suites)Test plan
test_issue106_block_state_integration) passes with 10 test suites:🤖 Generated with Claude Code