Reject unrepresentable deserialised trees - #82
Closed
Amaury Chamayou (achamayou) wants to merge 2 commits into
Closed
Reject unrepresentable deserialised trees#82Amaury Chamayou (achamayou) wants to merge 2 commits into
Amaury Chamayou (achamayou) wants to merge 2 commits into
Conversation
Amaury Chamayou (achamayou)
force-pushed
the
achamayou-tree-deserialise-ownership
branch
from
August 24, 2026 14:53
a56a7d5 to
2a49f78
Compare
Amaury Chamayou (achamayou)
force-pushed
the
achamayou-tree-size-validation
branch
from
August 24, 2026 14:56
195a7f3 to
299b5c0
Compare
Own partially reconstructed nodes until the complete tree has been built, then transfer the final root and leaf metadata. Add a malformed flushed-tree regression that exercises cleanup after partial reconstruction. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Amaury Chamayou (achamayou)
force-pushed
the
achamayou-tree-deserialise-ownership
branch
from
August 24, 2026 20:31
2a49f78 to
5778593
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Amaury Chamayou (achamayou)
force-pushed
the
achamayou-tree-size-validation
branch
from
August 24, 2026 20:39
299b5c0 to
2deaf52
Compare
Amaury Chamayou (achamayou)
force-pushed
the
achamayou-tree-deserialise-ownership
branch
2 times, most recently
from
August 25, 2026 12:54
4a25c5b to
e3801e3
Compare
Member
Author
|
Folded the remaining no-retained-leaves validation and regression test into #78, then rebuilt the native stack without this layer. |
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
Rationale
The normal serializer cannot produce this count combination.
flush_to(index)removes leaves strictly before the flush boundary and retains the boundary leaf, so every non-empty serialised tree has at least one retained leaf hash. Accepting{retained leaves: 0, flushed leaves: > 0}constructs a flushed-only state that is outside the tree representation's invariants.The deserializer now reports this case as
serialised tree has no retained leavesbefore attempting reconstruction.Arithmetic limits
The lower stack layer in #78 now owns the size/count validation that this PR originally carried:
Llogical leaves,2 * L - 1must fit insize_t, so the maximum representable leaf count isSIZE_MAX / 2 + 1size_tbit widthThis PR deliberately does not duplicate those checks. Its remaining delta is only the orthogonal representability rule that a non-empty flushed prefix must have a retained boundary leaf.
Malformed-input cases
0, flushed0: valid empty tree> 0, flushed0: valid subject to the lower layer's size and byte-count checks> 0, flushed> 0: valid subject to the same checks0, flushed> 0: rejected because no valid serializer output has a flushed-only treeTests
TreeT rejects invalid serialised leaf datanow builds a complete{retained: 0, flushed: 1}payload, including its required flushed-subtree hash, and checks for the dedicatedstd::runtime_errormessage.Validated with the focused
unit_testsCTest target in a Debug build.Stacked immediately above #80 in native stack #85.