Skip to content

feat(graph): add EndpointKind::ActionServer and typed wait_for_action_server#194

Open
YuanYuYuan wants to merge 3 commits into
mainfrom
dev/action-graph-kind
Open

feat(graph): add EndpointKind::ActionServer and typed wait_for_action_server#194
YuanYuYuan wants to merge 3 commits into
mainfrom
dev/action-graph-kind

Conversation

@YuanYuYuan
Copy link
Copy Markdown
Collaborator

Summary

  • Adds EndpointKind::ActionServer and ActionClient synthetic variants to hiroz-protocol, with centralised action sub-topic suffix constants and an action_name_from_topic() helper
  • Extends GraphData with a by_action index populated during liveliness parsing — action server sub-endpoints (three services + two publishers) are keyed by action name
  • Adds Graph::has_action_server() that checks all five sub-endpoints are present, and exposes count(EndpointKind::ActionServer, …) for consistency
  • Replaces the five hard-coded _action/send_goal / _action/feedback etc. string checks in wait_for_action_server with a single typed has_action_server() call
  • Updates exhaustive match arms in event.rs, bridge.rs, and ros2dds.rs
  • Adds a negative test: wait_for_server returns false when no server is present

Key Changes

  • crates/hiroz-protocol/src/entity.rs — new ActionServer/ActionClient variants, suffix constants, action_name_from_topic()
  • crates/hiroz/src/graph.rsby_action index, visit_by_action(), has_action_server(), count(ActionServer, …)
  • crates/hiroz/src/graph.rswait_for_action_server simplified to one call
  • crates/hiroz/tests/action/client.rs — new test_action_client_wait_for_server_no_server

Breaking Changes

None. EndpointKind grows two new variants; all existing match arms that were _ / wildcard-terminated are unaffected. The two new arms added to exhaustive matches (bridge.rs, event.rs, ros2dds.rs) preserve existing behaviour.

…_server

Previously `wait_for_action_server` matched action server readiness by
constructing five hard-coded `_action/send_goal` / `_action/feedback` /
etc. strings and querying the graph individually. This breaks silently if
the sub-topic naming convention ever changes, and it conflates "a service
named X exists" with "an action server for X is ready".

Changes:
- Add `ActionServer` and `ActionClient` synthetic variants to `EndpointKind`
  in hiroz-protocol; add centralised `ACTION_SERVER_*_SUFFIXES` constants
  and `action_name_from_topic()` helper
- Extend `GraphData` with a `by_action` index; during `parse()`, action
  sub-endpoints (send_goal/get_result/cancel_goal services + feedback/status
  publishers) are additionally keyed by action name
- Add `Graph::has_action_server()` that checks all five sub-endpoints are
  present using the index, and `count(ActionServer, …)` for consistency
- Replace the five-string heuristic in `wait_for_action_server` with a
  single call to `has_action_server()`
- Update exhaustive match arms in event.rs, bridge.rs, and ros2dds.rs
- Add negative test: `wait_for_server` returns false when no server exists
…ulate by_action in add_local_entity

Two correctness issues found in code review:

1. EndpointKind::FromStr accepted "AS"/"AC" despite ActionServer/ActionClient
   being synthetic graph-level kinds that never appear on the wire. A peer
   emitting these codes would produce a phantom entity stored in `parsed` but
   indexed nowhere, invisible to all graph queries. Removed the "AS"/"AC" arms
   so the parser returns Err, consistent with the doc comment.

2. add_local_entity did not populate by_action, so a same-process action server
   was invisible to has_action_server until the Zenoh liveliness echo arrived.
   The old wait_for_action_server queried by_service/by_topic directly (both
   populated by add_local_entity), so this was a silent regression. Mirrored
   the is_action_server_endpoint indexing block from parse() into
   add_local_entity to make same-process detection immediate.
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