Skip to content

feat(hiroz): embed the bundled message definitions - #314

Merged
YuanYuYuan merged 3 commits into
mainfrom
feat/hu-embedded-msgs
Aug 21, 2026
Merged

YuanYuYuan merged 3 commits into
mainfrom
feat/hu-embedded-msgs

Conversation

@YuanYuYuan

@YuanYuYuan YuanYuYuan commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Closes G2 of the release-usability gaps. This now targets main. The five slices that split the original #311 are merged: #317, #318, #319, #320 and #311.

What fails without this

A downloaded hu could not decode a topic, even when a publisher was live. A release ships no message definitions, so the .msg fallback had nowhere to look.

Measured against a real talker on /chatter, with HIROZ_MSG_PATH unset:

before after
hu meter echo /chatter exit 1, no .msg for std_msgs/msg/String (advertised by /chatter) was found on HIROZ_MSG_PATH decodes: [/chatter] {"data":"Hello hiroz - #11"} — 17 messages in an 18 s window
hu meter echo on a topic nobody publishes exit 1, names that nothing advertises a type unchanged — still exit 1, same message

That second row is the control. Embedding must not turn a genuine failure into silence.

What this does

build.rs embeds every bundled .msg file as source text. The schema loader reads that table when HIROZ_MSG_PATH yields nothing.

  • Disk still wins. A user who sets HIROZ_MSG_PATH means it. A stale embedded copy must not beat the definitions that the publisher was built from. A test pins this with a sentinel field.
  • Both paths use one parser. parse_msg_string reads the embedded text and the file text, so the two cannot diverge.
  • The table holds everything. The bundled set is 122 KB of text and 198 definitions. A subset would trade a fraction of a percent of binary size against "why is my type missing?".
  • A test asserts that the table is non-empty and sorted. An empty table would be a silent no-op that reproduces today's behaviour.

A latent defect that embedding made reachable

hu meter pub --msg-type std_msgs/msg/String failed against a topic with a live endpoint:

topic /pub_target carries std_msgs::msg::dds_::String_, not the requested std_msgs/msg/String

The graph reports a DDS-mangled name. --msg-type takes the ROS form. The guard compared the two raw.

That guard needs a resolvable schema and a live endpoint before it runs. The one test that resolves from disk publishes to an empty topic. Nothing therefore exercised the combination until a schema could resolve without a live node.

This branch fixes it with ros_type_name_from_dds, the helper that #320 exported. A second copy of the mangling rules would drift from the first.

Breaking changes

None. This adds a fallback, and the host consults it only after the existing path fails.

@YuanYuYuan
YuanYuYuan force-pushed the feat/hu-embedded-msgs branch from df248a6 to 11ae23a Compare August 21, 2026 06:41
@YuanYuYuan
YuanYuYuan changed the base branch from main to fix/hu-schema-discovery August 21, 2026 06:41
@YuanYuYuan
YuanYuYuan force-pushed the fix/hu-schema-discovery branch from 030a7dd to 237914d Compare August 21, 2026 10:42
@YuanYuYuan
YuanYuYuan force-pushed the feat/hu-embedded-msgs branch from 11ae23a to bc4c506 Compare August 21, 2026 10:48
@YuanYuYuan
YuanYuYuan force-pushed the fix/hu-schema-discovery branch from 237914d to d3b55c7 Compare August 21, 2026 12:17
@YuanYuYuan
YuanYuYuan force-pushed the feat/hu-embedded-msgs branch from bc4c506 to e28fd80 Compare August 21, 2026 12:17
@YuanYuYuan
YuanYuYuan force-pushed the fix/hu-schema-discovery branch from d3b55c7 to bd2615d Compare August 21, 2026 13:27
@YuanYuYuan
YuanYuYuan force-pushed the feat/hu-embedded-msgs branch from e28fd80 to 3d70c4f Compare August 21, 2026 13:27
@YuanYuYuan
YuanYuYuan force-pushed the fix/hu-schema-discovery branch from bd2615d to 862d9ed Compare August 21, 2026 14:12
@YuanYuYuan
YuanYuYuan force-pushed the feat/hu-embedded-msgs branch from 3d70c4f to c939356 Compare August 21, 2026 14:12
@YuanYuYuan
YuanYuYuan force-pushed the fix/hu-schema-discovery branch from 862d9ed to 1040021 Compare August 21, 2026 15:08
@YuanYuYuan
YuanYuYuan force-pushed the feat/hu-embedded-msgs branch from c939356 to 9a2f3bc Compare August 21, 2026 15:08
Base automatically changed from fix/hu-schema-discovery to main August 21, 2026 16:13
A downloaded hu could not decode a topic even when a publisher was live.
Measured against a running talker on /chatter: discovery fell through and
the .msg fallback had nowhere to look, so echo reported

  no .msg for std_msgs/msg/String (advertised by /chatter) was found on
  HIROZ_MSG_PATH

and exited 1. A release ships no message definitions, so that is the
default outcome, not an edge case.

build.rs now embeds every bundled .msg as source text and the schema
loader consults it when HIROZ_MSG_PATH yields nothing. Disk still wins:
a user who sets that variable means it, and a stale embedded copy must
not beat the definitions their publisher was built from.

The whole jazzy set is ~122 KB of text, so nothing is subsetted. Embedded
text goes through the same parser as a file, via parse_msg_string, so the
two cannot diverge.
Local `cargo fmt --all --check` passed and CI's failed on the same commit.
The repo's rustfmt.toml sets nightly-only keys including skip_children; a
nightly local toolchain honours it and skips child modules, while CI's
stable rustfmt ignores it and formats them. Local fmt-green is therefore
weaker evidence than it looks.
`hu meter pub --msg-type std_msgs/msg/String` to a topic with a live
endpoint failed with

  topic /pub_target carries std_msgs::msg::dds_::String_,
  not the requested std_msgs/msg/String

The graph reports a DDS-mangled name; --msg-type is the ROS form. The
guard compared them raw, so a correct publish was rejected.

The branch was unreachable until a schema could resolve without a live
node: it needs both a resolvable schema and a live endpoint, and the one
test that resolves from disk publishes to an empty topic, where there is
no live type to compare against. Embedding the definitions made the
combination reachable and the latent defect fired.

Normalises with the same helper the discovery branch's names already come
in as, rather than adding a second copy of the mangling rules.
@YuanYuYuan
YuanYuYuan force-pushed the feat/hu-embedded-msgs branch from 9a2f3bc to e2c5d6d Compare August 21, 2026 16:15
@YuanYuYuan
YuanYuYuan merged commit 07aba92 into main Aug 21, 2026
29 checks passed
@YuanYuYuan
YuanYuYuan deleted the feat/hu-embedded-msgs branch August 21, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant