Hello
The one-shot identity preamble: the body of the first frame on a handshaking link.
Wire layout (v1)
One frame body. On a stream fabric it rides inside one framed() frame, so the wire carries a u32 big-endian length and then these bytes:
| Bytes | Field |
|---|---|
| 4 | magic 0x6B 0x75 0x69 0x6C (ASCII kuil) |
| 1 | version, u8, 0x01 |
| 2 | flags, u16 big-endian — v1 sends 0x0000 |
| 2 | idLen, u16 big-endian, 1..65535 |
idLen | the PeerId, UTF-8 |
The header before the id is 9 bytes. v1 is strict about length: idLen must equal the bytes left after the header exactly, so a body carrying trailing bytes is refused rather than read past.
Flags are must-ignore. A v1 sender writes 0x0000; a v1 receiver ignores every bit, set or not. That is what lets a later build add an optional capability without a version bump: an older peer skips the bit instead of refusing the link. Anything an older peer must not ignore needs a new version instead.
Why a magic and a version
Before v1 the preamble was the bare UTF-8 PeerId — no magic, no version. Any first frame decoded to some id, so a non-kuilt peer, a peer on a future layout, or a stray payload was silently misread as an identity, and the format had nowhere to evolve from. The magic says "this is a kuilt peer", and the version says which layout follows, so either mismatch is refused by name (HelloFormatException) instead of producing a fabricated peer.
This is a deliberate wire break: a pre-v1 peer's bare-id preamble is refused as HelloBadMagicException (unless its id happens to begin with kuil, in which case its fifth byte is read as a version and it is refused as HelloUnsupportedVersionException).
A separate wire from the mesh preamble, which has a similar [version][idLen][id] shape plus a nonce: the two share byte-order helpers, never a layout or a version constant.