Populate type hashes in graph cache names_and_types (#356)#89
Open
tisomi wants to merge 1 commit into
Open
Conversation
Populates the new type_hashes field on rmw_names_and_types_t from the entries in GraphCache. The internal map is widened from std::set<std::string> to std::map<std::string, rosidl_type_hash_t> so each (topic, type) pair carries its hash through to the rmw caller, covering both the global get_names_and_types and per-node paths. When the same (topic, type) pair carries different hashes across endpoints, the conflict is detected and a WARN-level log is emitted; the stored hash is replaced with a zero hash so the caller sees an unambiguous "no consensus" value, matching the rmw_zenoh behavior. Adds graph-cache tests covering the populated hashes for both paths. Related: ros2/rmw#356 Signed-off-by: tisomi <titus090404@gmail.com>
|
Tick the box to add this pull request to the merge queue (same as
|
This was referenced Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR populates the new
type_hashesfield onrmw_names_and_types_tfrom the discoverydata held in
GraphCache, so DDS-based rmw implementations (rmw_fastrtps, rmw_cyclonedds,rmw_connextdds) report the type hash of each name/type pair through the graph query APIs.
It is the middleware counterpart to the interface change in ros2/rmw#356.
Key changes:
std::map<std::string, std::set<std::string>>tostd::map<std::string, std::map<std::string, rosidl_type_hash_t>>— i.e. the per-topiccontainer changes from a set of type names to a map from each type name to its hash.
So every type under a topic now carries its hash through to the caller. The type name
stays the (inner) map key, preserving the existing de-duplication.
get_names_and_typesand the per-nodeget_reader_names_and_types_by_node/get_writer_names_and_types_by_node.topic pair, so a service endpoint has both a per-direction message hash (
topic_type_hash,which differs between server and client side) and the service descriptor hash
(
service_type_hash, identical on both sides and the value the user expects)._select_hash_for_entityreturns the service-level hash when the entity is registered as aservice (present in
data_services_) and falls back to the topic-level hash otherwise.data_services_is threaded through the internal helpers so this also works on theby-node paths.
endpoints, a WARN is logged and a zero-initialized hash is stored so the caller sees an
unambiguous "no consensus" value (matching the rmw_zenoh behavior). See Additional Information
for why this can occur.
__populate_rmw_names_and_typesallocates the per-name hash array (ornullptrwhen aname has no types) and copies each hash alongside the corresponding type name. Its error
handling was refactored to a single
goto cleanuppath that finalizes the partially-builtstruct via
rmw_names_and_types_fini.Adds graph-cache tests covering the populated hashes for both the global and per-node paths.
Related: ros2/rmw#356
Is this user-facing behavior change?
Yes.
rmw_get_topic_names_and_types,rmw_get_service_names_and_types,and the per-node variants) now report the type hash of each name/type pair via the new
type_hashesarray.a zero hash and a WARN is logged.
requires the ABI-breaking struct change from Extend
names_and_typesto contain type hashes rmw#356.Did you use Generative AI?
Yes. Claude (claude-sonnet-4-6) via GitHub Copilot was used to explore the codebase and
create an initial prototype.
Additional Information
type_hashesfield and hardensrmw_names_and_types_init/rmw_names_and_types_fini. Thegoto cleanuppath here relieson
finicleaning up partially-populated structs without leaking.topic_type_hashand thedata_services_map already existed in thecache; this PR wires them into the
names_and_typesoutput.On the hash-conflict case. A single topic name can appear with more than one type in
the ROS graph, which is why
rmw_names_and_types_tstores an array of types per name.Beyond that, two entries can share the same type name while the type definitions behind
them differ structurally — different versions of the same interface — and therefore produce
different hashes. This "version drift" arises when nodes on the graph are built against
different versions of the same type definition. When it happens, the graph query reports a
zero hash for that type and logs a WARN. In a version-consistent system this should not
occur, but the graph layer has to surface it rather than hand the caller one endpoint's
hash as if it were authoritative.
Testing
container; all pass.
path through the graph query APIs.
This is a SIEMENS activity and was initialized by @gramss