Skip to content

msgpack@2: name-keyed structs #16

Open

Description

@Kinflou

Deferred follow-up from the compatibility-rules discussion (tracking issue in core).

msgpack@1 (today's MsgPack, rmp_serde default config) encodes a struct as a positional array, and generated Rust has no #[serde(default)]. So:

  • extra trailing elements fail decoding (LengthMismatch);
  • missing ones fail too, even for Option fields;
  • adding, removing or reordering any field breaks peers.

JSON tolerates all of these.

Proposal: a msgpack@2 that encodes structs as name-keyed maps (rmp_serde struct-map mode), decodes a missing optional field as absent, and ignores unknown fields. One rule set then holds across formats. The trade is size: field names on the wire.

Needs: the runtime format, conformance vectors for a new format-msgpack@2 feature, generated #[serde(default)] on optionals in comline-rust, and a TS MessagePack codec, which doesn't exist yet.

Activity

  1. Kinflou commented on Oct 19, 2026

    @Kinflou
    MemberAuthor

    A possible shape for this, from core#127: key structs by field id rather than field name. Explicit field ids would be assigned on build and written into the source, as for function ids. An id-keyed MessagePack would tolerate added and removed fields like JSON, while staying nearly as compact as today's positional msgpack@1, as Cap'n Proto and FlatBuffers do.

  2. Kinflou commented on Oct 20, 2026

    @Kinflou
    MemberAuthor

    Decided 2026-10-20 (recorded in ComlineProject/docs#64): msgpack@2 takes a parameter keys = "name" | "id" (default name). name: a map keyed by field name; renaming a field is major. id: a map keyed by field id, nearly as compact as positional; renames are free; every field needs @id (the field-id follow-up of core#127). Adding or removing an optional field is minor under both; each value sets its own profile facts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlaterParkedwireFormats, framings, handshakes

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions