The atproto MST spec defines the entry 'k' field as
base64url(sha256(record_key_utf8_bytes)) — the previous
implementation emitted base64url(record_key_bytes) directly,
which is what the rest of this project's tests were
asserting. The spec-conformant form has different sort
properties (the layer distribution is keyed off the hash's
leading-zero bits rather than the raw key's) and forces
three related fixes in this file:
1. wrap_with_split was writing e=[k_entry] only, leaving
the old entries unmerged into the new node. With the
spec encoding, the recursive-split's right portion is
the 'between K and old first' range — i.e. the new
key's .tree — and the old entries need to be appended
after the new key. Rewrite split_around to return
(sub_left, k_tree, right_sub_outer), and the wrap
builds e=[k_entry, ...old_entries] in one write_node.
2. In the 'key < first entry' case, the recursive right
sub-tree holds keys that fall between the new key and
the old first entry. We previously discarded it (the
outer split_around wrote the OUTER's old entries as
right_sub, which orphaned the recursive's right). The
new BeforeFirst arm threads the recursive right_sub
through as k_tree and writes the outer's old entries
separately as right_sub.
3. Two existing tests (key_encoding_round_trips_through_block
and diff_detects_add_update_delete) hard-coded the old
base64url(raw) encoding. Update their assertions to
compare against base64url(sha256(raw)).
All 27 at-mst tests pass. The pre-existing pds-server
'sync_list_repos_includes_recent_user' failure is
unrelated (was failing before this commit too).