Skip to content

feat: add input port update subscriptions - #1247

Open
kVinsom wants to merge 1 commit into
BehaviorTree:masterfrom
kVinsom:feat/872-input-port-callbacks
Open

kVinsom wants to merge 1 commit into
BehaviorTree:masterfrom
kVinsom:feat/872-input-port-callbacks

Conversation

@kVinsom

@kVinsom kVinsom commented Oct 23, 2026 •

Copy link
Copy Markdown

Input-port consumers currently have to poll during a tick to discover blackboard writes. This draft adds instance-level TreeNode::subscribeToInputPort() so a node can react before its next tick, without putting instance callbacks into static providedPorts() declarations.

Related to #872. Design proposal for BT.CPP 5: this adds storage to Blackboard, so it changes its binary layout and requires rebuilding clients. The draft targets master for discussion because there is no public v5 branch. Please advise on the preferred target/API before merging.

Behavior

  • Subscriptions resolve explicit/automatic subtree remapping, root keys, {=}, and blackboard-backed defaults. Constant inputs return an empty handle.
  • Notifications cover set(), setOutput(), script assignments, JSON import, and snapshot restoration. Subscribe-before-first-write does not create or type-lock an entry; subscriptions survive removal and recreation of the key.
  • Callbacks run synchronously outside blackboard locks. Handles unsubscribe on destruction; reentrant notification and subscription changes are supported. The existing status-change Signal is unchanged.
  • Documentation and 15 regression tests cover remapping, defaults, invalid ports, failed writes, reentrancy, concurrent writers/subscribers, and lifetime behavior.

Contract to review

This observes successful writes, including equal values, rather than comparing arbitrary Any values. Callbacks read the latest value; concurrent writers can overlap callbacks and do not guarantee delivery order. Resetting a handle does not wait for callbacks already selected for invocation: callers must stop writers before destroying captured targets. Exceptions propagate after the write commits and stop the remaining callbacks in that notification.

Raw Entry/AnyPtrLocked writes require an explicit notifyEntryUpdated() after unlocking. Remapping is resolved at registration; changing it requires a new subscription. Subscription records remain associated with keys for the blackboard lifetime.

Validation

  • Debug build, including examples and tools: passed.
  • Full serial CTest run: 565/565 passed, no skips.
  • New regression suite under ThreadSanitizer: 15/15 passed without suppressions.
  • Pre-commit hooks on all changed files: passed.
  • Full ./run_clang_tidy.sh: passed.
  • Full-repository pre-commit: all hooks except clang-tidy passed. Clang-tidy reports three existing findings in unchanged tests/test_helper.hpp (member initialization and special members) and tests/gtest_loggers.cpp (reinterpret cast).
  • Full ASan/UBSan suite with leak detection: 565/565 passed, no skips.
  • Full TSan suite with the project's existing suppressions: 569/569 passed, no skips.

Tests are run serially because the existing logger tests share and delete /tmp/bt_logger_test; a parallel trial produced file/database collisions. macOS, Windows and ROS builds have not been run locally.

Developed with assistance from OpenAI Codex.

@kVinsom
kVinsom marked this pull request as ready for review October 23, 2026 15:11
@kVinsom

kVinsom commented Oct 23, 2026

Copy link
Copy Markdown
Author

Could a maintainer please re-run the failed Linux/Pixi job in this workflow run? The build was interrupted with exit code 143 and "The runner has received a shutdown signal." The Windows/Pixi job passed. I tried to re-run the failed job, but GitHub rejected the request because I do not have the required repository permissions. Thank you!

This branch has not been deployed

No deployments
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