Module component_source
Expand description
Single source-of-truth for the per-ComponentId read/encode logic and
the byte-level apply.
Centralizes everything the rest of the MLS pipeline needs to know about
a well-known ComponentId: its logical ComponentType, where its
current bytes live (OpenMLS AppData dictionary vs. legacy group context
extensions), and how to encode/apply AppDataUpdate payloads.
The helpers are pub so xmtp_mls can call them. They read and write
raw component bytes; xmtp_mls owns the intent and commit paths that
decide when a write is allowed.
§Two apply paths
apply_app_data_update_payload decodes, applies, and re-encodes the
whole component for each update. The
WorkingSet applies the same updates
to components it decodes once per commit, and applies a collection by
its ComponentType rather than through its Component impl. Members
must reach one verdict on every input, so a change to how a component
applies changes both paths. The differential test in
working_set/tests/differential.rs compares them.
§Field bounds
apply_app_data_update_payload rejects a new value of an application
component, USER_DISPLAY_NAME, or GROUP_IMAGE whose scalar,
collection key, or collection value exceeds MAX_FIELD_ELEMENT_BYTES,
or whose serialized collection exceeds MAX_FIELD_SNAPSHOT_BYTES.
[check_update_payload_bounds] applies the element bound to every
element an update payload names, without the state it applies to.
§Inbox-id encoding
The legacy GMM extension stores inbox ids as 64-character hex strings.
Anything serialized through the new AppDataUpdate path uses the
versioned InboxId newtype.
See crate::inbox_id for the full wire-format contract;
the short version is varint(version) || 32-byte payload, with
version 0 producing a 33-byte encoding.
§Secret values
GROUP_ROOT_KEY holds the group root, and COMMIT_LOG_SIGNER the
commit-log private key of a legacy group, so every component value these
helpers copy is a secret candidate. Reads borrow
the dictionary’s bytes, and computed values come back in Zeroizing,
which wipes them on drop whatever the component.
Structs§
- Group
Metadata Return - Intermediate proto-shaped result of
read_group_metadata_from_extensions. Caller converts to the finalcrate::group_metadata::GroupMetadata.
Enums§
- Component
Source Error - Errors surfaced by the component_source layer.
Constants§
- MAX_
FIELD_ ELEMENT_ BYTES - Longest scalar, collection key, or collection value that an application
component,
USER_DISPLAY_NAME,GROUP_IMAGE, orCOMPONENT_REGISTRYmay hold. - MAX_
FIELD_ SNAPSHOT_ BYTES - Longest serialized collection snapshot that an application component,
USER_DISPLAY_NAME,GROUP_IMAGE, orCOMPONENT_REGISTRYmay hold.
Functions§
- apply_
app_ data_ update_ payload - Decode an incoming
AppDataUpdateOperation::Update(bytes)payload and produce the new full bytes of the component, given the prior stored bytes (if any).Update-only —Removecarries no payload and is handled directly by the caller. - apply_
app_ data_ update_ payload_ with_ validator apply_app_data_update_payload, resolving the component’s type from the registry entry thatvalidatordecodes once.- component_
id_ to_ metadata_ field - Map a
ComponentIdback to theMetadataFieldattribute name that stores it in the legacyGroupMutableMetadataextension. - component_
type - Hardcoded logical type of a well-known component. Returns
Nonefor app-range components (0xC000-0xFEFF) and for any well-known id that is not yet wired into this match. - expand_
app_ data_ update_ to_ changes - Expand an
AppDataUpdateproposal payload into the per-element changes that should be checked against the component registry. - expand_
app_ data_ update_ to_ changes_ with_ validator expand_app_data_update_to_changes, resolving an unknown component’s type from the registry entry thatvalidatordecodes once.- extract_
group_ mutable_ metadata_ capability_ aware - Extract
GroupMutableMetadatafrom the AppData dictionary. - extract_
group_ mutable_ metadata_ capability_ aware_ from_ extensions - Same as
extract_group_mutable_metadata_capability_aware, but driven from the group’sGroupContextextensions alone — no fullOpenMlsGroup::load. The mutable metadata lives entirely in the context extensions, so a singleStorageProvider::group_contextread (one KV round-trip, no ratchet tree) is all this needs. - inbox_
id_ str_ to_ bytes - Decode a hex-string inbox id into an
InboxId. - merge_
app_ data_ into_ mutable_ metadata - Overlay AppData-dict component values onto a base
GroupMutableMetadata. - merge_
app_ data_ into_ mutable_ metadata_ from_ extensions - Extensions-only variant of
merge_app_data_into_mutable_metadata. - metadata_
field_ to_ component_ id - Map a
MetadataFieldstring to its correspondingComponentId. - read_
component_ bytes - Read the component’s current bytes from the OpenMLS AppData dictionary.
- read_
from_ app_ data_ dict - Look up the component’s bytes in the OpenMLS AppData dictionary.
- read_
from_ app_ data_ dict_ from_ extensions - Extensions-only counterpart of
read_from_app_data_dict— reads the component’s bytes straight from a group’sGroupContextextensions, with no fullOpenMlsGroup. openmls keys the dictionary by its ownComponentId, which is just au16alias, soid.as_u16()unwraps our newtype to the key. - read_
group_ membership_ from_ dict - Read the
GROUP_MEMBERSHIPdict entry and decode it into the legacyGroupMembershipproto shape. Used byextract_group_membershipon the receive-side validator to bridge the dict-stored membership back into the existingGroupMembershipRust type without rewriting every caller. - read_
group_ metadata_ from_ dict - Synthesize a [
GroupMetadata] from the AppData dictionary. ReturnsOk(None)if the critical immutable seeds are absent. - read_
group_ metadata_ from_ extensions - Extensions-only variant of
read_group_metadata_from_dict. Same rationale for the split asread_super_admin_list_from_extensions. - read_
post_ commit_ component_ bytes - The value component
idholds afterstaged_commit’sAppDataUpdateproposals, as commit validation judges them: eachUpdateinstaged_commit.app_data_update_proposals()applied in order to the pre-commit dictionary ofmls_group, aRemoveleavingNone. - read_
super_ admin_ list_ from_ dict - Read the super-admin list from the AppData dictionary.
- read_
super_ admin_ list_ from_ extensions - Extensions-only variant of
read_super_admin_list_from_dict. Use the shim above when anOpenMlsGroupis at hand; this form is available primarily for unit testing and for commit-validation paths that only carry anExtensionsreference.