Skip to content

Add the TiledTree lifecycle wrapper#55

Draft
achamayou wants to merge 4 commits into
achamayou/tiles-proofsfrom
achamayou/tiled-tree
Draft

Add the TiledTree lifecycle wrapper#55
achamayou wants to merge 4 commits into
achamayou/tiles-proofsfrom
achamayou/tiled-tree

Conversation

@achamayou

Copy link
Copy Markdown
Member

Summary

Part 4 of the tiled-storage stack; depends on #54.

  • add TiledTreeT, combining an in-memory tree, durable tile store, writer, and mixed proof sources;
  • keep TiledTreeT fresh-only and reject adoption of an unrelated existing tile namespace;
  • track separate immutable and successfully flushed boundaries across interrupted writes;
  • make compaction opt-in with retention and exact rollback-boundary handling;
  • provide safe move semantics and explicit external-serialization/escape-hatch contracts;
  • cover lifecycle, compaction, rollback, recovery, mixed proofs, and SHA-384/SHA-512 variants.

Stack

  1. Add durable tlog-tiles storage primitives #52 — tile formats and durable storage
  2. Add incremental tile and entry-bundle writers #53 — incremental writers
  3. Add tile-backed proof generation #54 — proof generation and hash sources
  4. This PR: TiledTree lifecycle
  5. user documentation and performance coverage

Validation

  • tiles_tree
  • tiles_hashes with OPENSSL=ON
  • existing core regression suite
  • header clang-tidy

achamayou and others added 4 commits July 13, 2026 11:29
Introduce merklecpp_tiles.h with the tlog-tiles tile geometry constants,
tile index encoding, TileRef, and a hardened TileStoreT: strict full-tile
and entry-bundle codecs/I/O, atomic replacement, directory/file
durability, validation, and temp-file cleanup, with no internal
synchronization (callers must serialize access).

Add focused tiles_store tests covering path layout, atomic durable
writes, corruption/truncation handling, and concurrent same-tile
writes. Store durability-retry tests that exercise TileWriter are
deferred to the next branch, which also adds the entry-bundle writer.

Wire tiles_store into the test suite, add merklecpp_tiles.h to the
Doxygen input set, and run clang-tidy on it in CI.

Start the normative tiled-storage design doc with goals, background,
the tile/merklecpp mapping, file layout, architecture overview, the
header/TileStoreT API sections, and the entry-bundle format (its
writer arrives in the next branch).

Co-authored-by: Copilot <[email protected]>
Add TileWriterT (progressive full-tile writes with all-level rollups
and bounded contiguous-prefix recovery) and EntryBundleWriterT (mirrors
the writer for optional entry bundles). Both are incremental: existing
full tiles/bundles are immutable and never rewritten, resume is
idempotent, and recovery is caller-validated (the caller supplies the
tree/entry state and re-derives it consistently across restarts).

Add tiles_writer and tiles_entries tests covering exact full-tile/bundle
counts at several sizes, incremental/idempotent writes, interior-hole
repair on resume, and bounded recovery against sparse indices. Move the
store durability-retry tests that exercise TileWriter into tiles_store,
now that the writer exists.

Document the write path, compaction integration, and entry-bundle
writer in the design doc, and add the size-256/70000 worked examples.

Co-authored-by: Copilot <[email protected]>
Add HashSourceT (abstract subtree-root resolver), TileHashSourceT
(resolves from full tiles, with an LRU tile cache), ProofEngineT
(inclusion/consistency proofs and their verifiers, built on mth_range),
MemoryHashSourceT (resolves from a resident in-memory tree), and
CombinedHashSourceT (memory first, falling back to tiles).

Add the sole essential core change: TreeT::subtree_root(), a read-only,
non-hashing accessor that lets proofs be served from the resident tree,
plus the <limits> include it needs. No other merklecpp.h changes.

Add tiles_proofs tests, cross-checking tile-derived inclusion and
consistency proofs against merkle::TreeT as the oracle across a range
of sizes, including tile-boundary crossings. Move the memory-only
subtree_root proof coverage and the ProofEngineProbe hostile-arithmetic
edge cases here from tree coverage, since they exercise the proof
engine and core accessor rather than TiledTree lifecycle. Add
tiles_level2 for end-to-end coverage of the level-2 tile path.

Introduce the LONG_TESTS CMake option, gate tiles_level2 behind it, and
enable it in CI (and CodeQL) so long-running tile coverage runs on pull
requests.

Document the compatibility statement, the optional core accessor, and
the HashSource/ProofEngineT API and algorithms in the design doc.

Co-authored-by: Copilot <[email protected]>
Add TiledTreeT: a fresh-only tiled tree (rejects an existing tile
namespace rather than adopting it), append/flush/root, flushed/
immutable size tracking, interrupted-flush recovery (a failed flush
seals the attempted full-tile boundary without advancing flushed
size), optional compaction with configurable retention, a rollback
boundary that only ever permits retracting the un-tiled frontier,
noexcept move construction with no copy, mixed tile+memory proofs, and
an explicit no-internal-synchronization / external-serialization
contract for the store and tree it wraps.

Add tiles_tree tests covering the empty tree, move construction,
fresh-only rejection of an existing tile namespace, flush/compaction
(including exact-multiple and retention-margin cases), and rollback
(pre-flush, post-flush, exact-boundary, compacted, and interrupted-
flush recovery). The memory-only subtree_root/ProofEngineProbe cases
already moved to tiles_proofs are not duplicated here.

Add tiles_hashes, exercising the tiled tree, writer and proof engine
under SHA384/SHA512, and wire the OpenSSL 384/512 aliases for every
tiled-storage component.

Document the TiledTreeT API, the flush/compaction invariants and
progressive-production algorithm, pruning, and the consolidated
lifecycle/safety risks and edge cases in the design doc.

Co-authored-by: Copilot <[email protected]>
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.

1 participant