module documentation

The recipes: curating a ROS2 type is writing data, not code.

A Projection is three pure functions (opensmi.ros2.server.projection). A curation is a plain data literal from a closed set, so which Projections exist is a list somebody reads:

Default("nav_msgs/msg/Odometry")  # walk it; curate nothing
Scalar("std_msgs/msg/Float64")  # one value, one variable
Enum("sensor_msgs/msg/BatteryState", fields={"power_supply_status": {0: "Unknown"}})
Blob("nav_msgs/msg/OccupancyGrid", field="data")  # one bulk byte string
Drop("nav_msgs/msg/Odometry", fields=("pose/covariance",), override=True)

Functions is the escape hatch for a type that fits none of them. There is no Object recipe: a message is already a browsable complex Variable, and the mutation chokepoint refuses the Object verb by name.

Three rules hold for every class. Entries are keyed by type name alone: type_hash= records the RIHS01 the entry was authored against so CI can report that a type moved, but it never selects an entry. Registration is explicit, through ~opensmi.ros2.server.projection.ProjectionRegistry.extended, and a second entry for one type is fatal unless it says override=True. There is no entry-point discovery. Invertibility is derived from the recipe, never a keyword: the walk always inverts, and the escape hatch inverts only if given encode=. Default(type_name, override=True) turns curation off for that type only; a Projection nested inside still applies.

Class Blob One fixed-width primitive array carried as a single byte string.
Class Default The generic field-walk, as an ordinary entry.
Class Drop The generic walk with some fields taken out of it.
Class Enum A message walked as usual, with named integer fields rendered as enumerations.
Class Functions The escape hatch: a Projection written as the functions themselves.
Class Scalar A message that carries one value, rendered as that one variable.
Constant GENERIC The generic field-walk, as the entry that matches last.
Constant GENERIC_REGISTRY A registry that curates nothing. opensmi.ros2.server.projections.DEFAULT_REGISTRY extends it.
Function _capped Return a bulk payload cut down to the transport's ceiling.
Function _element_name Return the .msg spelling of what a container holds, or "" for anything else.
Function _pack Return one array field as the bytes its elements are.
Function _require_known_paths Refuse a named path a type does not have, which is a typo rather than a choice.
Function _scalar_name Return the .msg spelling of a single primitive field, or "" for anything else.
Function _unpack Return the elements a byte string holds, in the shape the payload wants them.
Function _written Return what a client wrote to one variable of a plan, refusing a payload with a hole.
Constant _INTEGERS Which field types can carry an enumeration: one whole number, of any ROS2 width.
Constant _LITTLE_ENDIAN Byte order, fixed because a client is not necessarily on this host.
Constant _PACKED The struct code of each fixed-width ROS2 primitive.
Constant _SIGNED Which element types make a packed buffer a SignedByteString rather than a ByteString.
GENERIC =

The generic field-walk, as the entry that matches last.

Value
Default(ANY_TYPE)
GENERIC_REGISTRY =

A registry that curates nothing. opensmi.ros2.server.projections.DEFAULT_REGISTRY extends it.

Value
ProjectionRegistry(entries=(GENERIC))
def _capped(data: bytes, ceiling: int) -> bytes:

Return a bulk payload cut down to the transport's ceiling.

A byte string past the ceiling makes the write fail and the variable stop updating for every client, so it is cut here instead. A client can compare the length against the capability variable (opensmi.ros2.server.limits).

def _element_name(field_type: FieldType) -> str:

Return the .msg spelling of what a container holds, or "" for anything else.

def _pack(value: object, field_type: FieldType) -> bytes:

Return one array field as the bytes its elements are.

A byte container already crossed as bytes, so packing it is the identity.

def _require_known_paths(recipe: str, message_type: type[Message], paths: Collection[str]):

Refuse a named path a type does not have, which is a typo rather than a choice.

Raises
UnprojectableFieldErrorWhen a named path is not a path of this type.
def _scalar_name(field_type: FieldType) -> str:

Return the .msg spelling of a single primitive field, or "" for anything else.

def _unpack(data: bytes, field_type: FieldType) -> object:

Return the elements a byte string holds, in the shape the payload wants them.

Raises
ValueErrorWhen the byte string is not a whole number of elements. This is a client's write, so it is refused per write and never fatal at init.
def _written(values: Mapping[str, object], name: str, message_type: type[Message]) -> object:

Return what a client wrote to one variable of a plan, refusing a payload with a hole.

Raises
NotInvertibleErrorWhen the name carries no value, as in the walk: a field filled from a default is a value nobody sent.
_INTEGERS =

Which field types can carry an enumeration: one whole number, of any ROS2 width.

Value
frozenset(INTEGER_RANGES)
_LITTLE_ENDIAN: str =

Byte order, fixed because a client is not necessarily on this host.

Value
'<'
_PACKED: Mapping[str, str] =

The struct code of each fixed-width ROS2 primitive.

char and wchar are absent: they cross as Python str and have no packable width.

Value
{'bool': '?',
 'byte': 'B',
 'uint8': 'B',
 'int8': 'b',
 'int16': 'h',
 'uint16': 'H',
 'int32': 'i',
...
_SIGNED: frozenset[str] =

Which element types make a packed buffer a SignedByteString rather than a ByteString.

Two's-complement integers only. A float buffer keeps the plain ByteString.

Value
frozenset(set(['int8', 'int16', 'int32', 'int64']))