Skip to content

Robust MST validation #2

@DavidBuchanan314

Description

@DavidBuchanan314

This check should already handle duplicate or out-of-order keys within a particular node:

atmst/src/atmst/mst/node.py

Lines 105 to 106 in 421a274

if this_key <= prev_key:
raise ValueError("invalid MST key sort order")

But if there was a tree like this:

         (. "b", h=1 .) 
         /            \ 
(. "a", h=0 .) (. "a", h=0 .) 

I'm not sure if my NodeWalker class would actually catch it. Need to enforce key ordering when traversing down subtrees, likely here: (in addition to the key height checks)

if not self.trusted: # if we "trust" the source we can elide this check
# the "None" case occurs for empty intermediate nodes
if subtree_node.maybe_height is not None and subtree_node.maybe_height != self.height - 1:
raise ValueError(f"inconsistent subtree height ({subtree_node.maybe_height}, expected {self.height - 1})")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions