Add tiled tree recovery API - #77
Merged
Amaury Chamayou (achamayou) merged 8 commits intoSep 3, 2026
Merged
Conversation
Restore TiledTree from serialized tree state and a caller-validated tile boundary. Harden tree deserialization and replace untrusted suffix tiles during resumed growth. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 455a0fc3-10c9-4831-bf66-f06ff952f607
Restore logical tree state before tiles are ready, populate or repair the namespace with a detached writer, and adopt a quiesced durable prefix without trusting stale suffix files. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 455a0fc3-10c9-4831-bf66-f06ff952f607
Make the traversal child invariant explicit and satisfy the public-header lint rules for deserialization and writer rebinding. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 455a0fc3-10c9-4831-bf66-f06ff952f607
Validate every required tile and roll-up against the serialized frontier, and restore distinct flushed and immutable boundaries after interrupted flushes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve deserialization conflicts by retaining the newer exception-safe bounds checks and fuzz coverage from main. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Allow consensus-driven callers to write and seal only complete tiles within a committed leaf-count prefix while retaining a rollbackable logical suffix. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Amaury Chamayou (achamayou)
marked this pull request as ready for review
September 2, 2026 11:05
Copilot started reviewing on behalf of
Amaury Chamayou (achamayou)
September 2, 2026 11:06
View session
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Durable recovery and crash-consistency behavior warrant final human review despite comprehensive coverage.
Pull request overview
Adds durable tiled-tree recovery, detached repair/adoption, and committed-prefix flushing.
Changes:
- Adds resume, frontier restoration, repair, adoption, and dual-boundary recovery APIs.
- Adds
flush_up_to()and immutable-boundary tracking. - Expands lifecycle tests and recovery documentation.
File summaries
| File | Description |
|---|---|
merklecpp_tiles.h |
Implements recovery and committed-prefix APIs. |
test/tiles_resume.cpp |
Tests restoration, repair, adoption, and interrupted flushes. |
test/tiles_writer.cpp |
Tests trusted-prefix repair behavior. |
test/tiles_geometry.cpp |
Tests committed-prefix flushing. |
test/CMakeLists.txt |
Registers the recovery test. |
README.md |
Introduces recovery workflows. |
doc/tiles-guide.rst |
Documents lifecycle and durability contracts. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Eddy Ashton (eddyashton)
approved these changes
Sep 3, 2026
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
TiledTreeT::resumefor an existing namespace, serialized tree state, and a caller-validated full-tile boundaryresumeoverload andimmutable_size()so interrupted flush recovery distinguishes the last verified prefix from the rollback sealTiledTreeT::from_frontierso logical recovery can complete before any tile namespace is readyTileWriterT::repairfor detached/background namespace population or repair after an explicit trusted prefixadopt_tile_prefixafter the detached writer is quiescedflush_up_toto publish and seal only a committed full-tile prefix while preserving a speculative suffixTileWriterscan/repair behaviorAPIs
Resume a complete, durable tile prefix:
auto resumed = TiledTree::resume( config, hash_algorithm_short_name, serialised_tree, full_tile_boundary);After an interrupted flush, restore the last fully successful prefix separately from the possibly larger rollback seal:
auto resumed = TiledTree::resume( config, hash_algorithm_short_name, serialised_tree, flushed_tile_boundary, immutable_boundary);The caller establishes namespace ownership. Recovery verifies every required tile and higher-level roll-up against the serialized tree. Proof reads are capped at
flushed_tile_boundary; tiles throughimmutable_boundaryremain sealed against rollback, while the unverified suffix is replaced when flushing resumes.Restore logical state before tiles are ready, repair independently, then adopt the completed prefix:
from_frontierperforms no namespace I/O and trusts no tile files. Root computation and appends are available immediately. If old leaves are non-resident, tile-dependent proofs and live flushing fail until a complete repaired prefix overlaps the resident frontier.For a tree with a speculative suffix, publish only its committed prefix:
Only complete tiles wholly within that leaf count are written and sealed. A failed write may advance
immutable_size()without advancingflushed_size(); applications should checkpoint the serialized frontier and both boundaries together.The detached writer may run on a background thread; merklecpp does not create or manage threads. The application must serialize writers sharing the namespace and quiesce repair before adoption. Adoption exhaustively verifies the prefix, updates flushed and immutable boundaries together, and continues to distrust the suffix.
Validation
tiles_resume,tiles_writer, andtiles_treetiles_resumeandtiles_writer