Skip to content

feat(hiroz-py): add a buffer_group argument - #388

Merged
YuanYuYuan merged 9 commits into
mainfrom
feat/py-buffer-group
Oct 24, 2026
Merged

YuanYuYuan merged 9 commits into
mainfrom
feat/py-buffer-group

Conversation

@YuanYuYuan

@YuanYuYuan YuanYuYuan commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The Python create_subscriber cannot stay out of the CPU buffer group of rmw_zenoh_cpp. A subscriber that joins declares a second subscription and announces a buffer backend. On a topic that is known to carry no buffer, the extra subscription has no use. Python has no way to opt out. Under the default Auto of #384 a Python subscriber joins regardless of message type, except with transient-local QoS. The Python bindings build a subscriber with no message schema, so the message type cannot decide.

A joined subscriber subscribes to <topic key> (the base key) and to <topic key>/_buf_cpu (the group key), and its liveliness token ends with backends:cpu:. See ros2/rmw_zenoh#930. The interop guide gives the rules and the cases that never join.

Part of #370.

What changes

  • New keyword buffer_group='auto' | 'cpu' | 'off' on create_subscriber, in the queue form and the callback form. The default is 'auto'. A Python subscriber has no message schema, so 'auto' and 'cpu' do the same.
  • An unknown string raises ValueError. A non-string raises TypeError. Both name buffer_group.
  • The status subscriber of an action client now stays out (Off), because its message has no buffer. The feedback subscriber still joins and has no switch.

Before and after

A transient-local subscriber never joins, because its history comes from the base key, as in rmw_zenoh_cpp; the interop guide gives the details. The rows below assume volatile QoS.

case today with this PR
create_subscriber, default joins joins, same as today
buffer_group='cpu' no such argument joins
buffer_group='off' no such argument base key only. The token stays and omits backends:cpu:
buffer_group='other' no such argument raises ValueError
action client status subscriber joins stays out
action client feedback subscriber joins joins, same as today

Compatibility

change who is affected action
the status subscriber of Rust and Python action clients stops declaring the group subscription Rust and Python action clients none: status delivery is unchanged because the message has no buffer field

A default-deny router that allows only the base key starves a joined Python subscriber of a buffer-aware publisher, with no error. Allow both keys. buffer_group='off' needs no group key. A subscriber with no backends: field gets no buffer message from a buffer-aware publisher. This holds until a release carries ros2/rmw_zenoh#1078, so 'off' does not bring those messages back.

Tests

area test checks
validation test_create_subscriber_rejects_unknown_group, test_create_subscriber_rejects_a_non_string_group five wrong strings raise ValueError. A non-string raises TypeError
policy test_policy_takes_effect four values ('off', 'cpu', 'auto', omitted) in two forms (queue, callback): the token and the group-key delivery match the value. Positive controls show that a cpu twin joins and that a put on the base key arrives
status action_client_join_policy (buffer_cpu_group.rs) the status subscriber stays out, and the feedback subscriber of the default client joins

The Python tests are in crates/hiroz-py/tests.

Merge order: this PR depends on no open PR and merges on its own. #386 merges last, because it bumps the release.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-24 03:06 UTC

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
crates/hiroz/src/action/client.rs 74.81% <100.00%> (+0.09%) ⬆️
crates/hiroz/src/buffer_group.rs 98.07% <ø> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

create_subscriber takes buffer_group as 'auto', 'cpu' or 'off', default 'auto'. Any other string raises ValueError. The action client status subscriber now stays out of the buffer group, since its message has no buffer. The feedback subscriber still joins under Auto.
Python tests cover the accepted values, the errors and delivery. A second file reads the liveliness token and writes the group key from a plain Zenoh session, for off, cpu, auto and the omitted default in the queue and callback forms. The action client test now expects the status subscriber to stay out.
@YuanYuYuan
YuanYuYuan force-pushed the feat/py-buffer-group branch from 9fa2559 to 16eaff6 Compare October 23, 2026 17:59
The policy tests detect incorrect joining but cannot tell auto from cpu. An off subscriber keeps its token without the backends part. Two comments repeated their code or their name.
The private parser helper needs no doc comment, and the policy test docstring no longer lists failure variants.
Drop the duplicate quiet-put helper and the narrating comments, fold the stub default check into test_pep561, and give each fact in the interop guide its own bullet.
A transient-local subscriber reads its history from the base key, so it stays out of the group under every setting. The guide now states the rmw_zenoh_cpp behavior with pinned source links.
The sentence said an unreleased rmw_zenoh_cpp revision serves transient-local history on the group key. That revision predates the gate that keeps transient-local endpoints off buffer endpoints, so rolling no longer behaves that way.
@YuanYuYuan
YuanYuYuan merged commit 4d52b77 into main Oct 24, 2026
39 checks passed
@YuanYuYuan
YuanYuYuan deleted the feat/py-buffer-group branch October 24, 2026 03:06
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