Record Class BoNode

java.lang.Object
java.lang.Record
ai.badmonkey.agentspaces.pdt.kinds.BoNode
Record Components:
size - the bytes the node covers
parents - the parent pairs, PARENT_BYTES each, in pre-order
children - the child bo nodes, empty on a leaf

public record BoNode(long size, byte[] parents, List<Link> children) extends Record
A node of a blob's Bao outboard, kind bo (PDT 2 phase 0, P2-B-02; srad/agentspaces-pdt2.md §3.5): { k:"bo", g: 4, n: size, p: parent chaining values, c: [links to child bo nodes] }, over chunk groups of 2^g BLAKE3 chunks (16 KiB, decision 10). A bo tree is reached only through the attribute pdt.bao (§6.10.3, rule 5).

The build pins the split rule of §3.5, so every port cuts the same tree. The owner ruled on 2026-11-09 that a leaf covers 8 MiB, about 32 KiB of outboard, so a 2 MiB verified window pays at most two leaves (PDT 2 phase 4 measures, P2-Q-PRF-05, §10.14); the phase 0 rule cut leaves of 256 MiB.

  • p is one byte string, the concatenated parent pairs (left CV then right CV, 64 bytes) in pre-order, as a Bao outboard stores them. A list of 64-byte strings would spend two bytes of header per parent.
  • A node over at most LEAF_GROUPS groups (8 MiB) is a leaf: p holds every parent of its BLAKE3 subtree, groups - 1 of them, and c is empty. A full leaf encodes to 32,728 bytes.
  • A larger node over G groups takes the smallest j >= 1 with G <= LEAF_GROUPS x FANOUT^j, cuts its subtree into aligned blocks of LEAF_GROUPS x FANOUT^(j-1) groups, links one child bo node per block in order, and holds in p the parents above the cut, one fewer than its children. BLAKE3's tree puts every left subtree on a power of two, so each block is a whole subtree. An upper node of 16 children encodes to about 1.6 KiB, so the path above a window's leaves stays short.
The shape is a function of n alone, which the constructor checks.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The most children an upper node links: 16, well under NodeCodec.MAX_LINKS.
    static final int
    The bytes in one chunk group.
    static final int
    log2 of the BLAKE3 chunks in one group: 16 chunks of 1 KiB (decision 10).
    static final int
    The most groups a leaf covers: 2^9, 8 MiB of content in 511 parents (PDT 2 phase 4 measures, §10.14).
    static final int
    The bytes of one parent pair: two 32-byte chaining values.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BoNode(long size, byte[] parents, List<Link> children)
    Checks that the parents and children are the ones the size implies.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the children record component.
    static List<Long>
    childSizes(long size)
    The sizes, in bytes, of the child blocks of a node over size bytes; empty for a leaf.
    static BoNode
    decode(String cid, byte[] bytes)
    Reads a bo node.
    byte[]
    The canonical node bytes.
    boolean
    Indicates whether some other object is "equal to" this one.
    static long
    groups(long size)
    The chunk groups a blob of size bytes holds: at least one, since an empty blob is one empty chunk.
    int
    Returns a hash code value for this object.
    byte[]
    The parent pairs, copied.
    long
    Returns the value of the size record component.
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • GROUP_LOG

      public static final int GROUP_LOG
      log2 of the BLAKE3 chunks in one group: 16 chunks of 1 KiB (decision 10).
      See Also:
    • GROUP_BYTES

      public static final int GROUP_BYTES
      The bytes in one chunk group.
      See Also:
    • PARENT_BYTES

      public static final int PARENT_BYTES
      The bytes of one parent pair: two 32-byte chaining values.
      See Also:
    • LEAF_GROUPS

      public static final int LEAF_GROUPS
      The most groups a leaf covers: 2^9, 8 MiB of content in 511 parents (PDT 2 phase 4 measures, §10.14).
      See Also:
    • FANOUT

      public static final int FANOUT
      The most children an upper node links: 16, well under NodeCodec.MAX_LINKS.
      See Also:
  • Constructor Details

    • BoNode

      public BoNode(long size, byte[] parents, List<Link> children)
      Checks that the parents and children are the ones the size implies.
  • Method Details

    • groups

      public static long groups(long size)
      The chunk groups a blob of size bytes holds: at least one, since an empty blob is one empty chunk.
    • childSizes

      public static List<Long> childSizes(long size)
      The sizes, in bytes, of the child blocks of a node over size bytes; empty for a leaf.
      Parameters:
      size - the bytes the node covers
      Returns:
      the byte count of each child in order
    • encode

      public byte[] encode()
      The canonical node bytes.
    • decode

      public static BoNode decode(String cid, byte[] bytes)
      Reads a bo node.
      Parameters:
      cid - the CID, named in a refusal; may be null
      bytes - the node bytes
      Returns:
      the node
      Throws:
      NodeFormatException - on another kind, another group size, a missing key, or parents and children the size does not imply
    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • parents

      public byte[] parents()
      The parent pairs, copied.
    • size

      public long size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • children

      public List<Link> children()
      Returns the value of the children record component.
      Returns:
      the value of the children record component