Skip to content

Fix ROOT blackboard export in Groot2 publisher#1168

Merged
facontidavide merged 1 commit into
masterfrom
fix/1130-root-blackboard-dump
Jul 15, 2026
Merged

Fix ROOT blackboard export in Groot2 publisher#1168
facontidavide merged 1 commit into
masterfrom
fix/1130-root-blackboard-dump

Conversation

@facontidavide

Copy link
Copy Markdown
Collaborator

Summary

Rebased and cleaned-up version of #1132 by @magic-alt (original authorship preserved on the commit).

When a subtree's blackboard is backed by a separate root blackboard — e.g. created via Blackboard::create(external_root) to expose @ globals — the Groot2 publisher never exported those root entries, so they were invisible in Groot2. This exports the root blackboard under the reserved name ROOT whenever a requested subtree resolves to a distinct root blackboard.

  • Deduplicate the ROOT payload when several subtrees share the same root blackboard.
  • Return the dump as Expected<> and send an error reply for ambiguous requests: a subtree literally named ROOT, or a request spanning multiple distinct root blackboards.
  • Enable /utf-8 for behaviortree_cpp_test on MSVC so the existing Unicode name-validation tests build on Windows.

Closes #1130.

What changed vs #1132

#1132 was written against an older master, before the Groot2 thread-safety refactor (#1165) reshaped serverLoop/generateBlackboardsDump. This branch:

  • Re-threads the new Expected<> return + error-reply path through the refactored serverLoop (the conflicting hunk).
  • Moves the new tests out of gtest_loggers.cpp and into gtest_groot2_publisher_integration.cpp, where the other real-ZMQ Groot2 tests live — so they are gated BTCPP_GROOT_INTERFACE AND NOT WIN32 like their siblings (real-ZMQ tests are intentionally not run on Windows, see the note in tests/CMakeLists.txt).
  • Reuses the shared Groot2Test::makePublisher / Client helpers instead of hand-rolling a ZMQ client, hardcoded ports, and a fixed sleep.

Design note

ROOT is exported for any requested subtree whose blackboard has a parent (every non-root subtree does, since Blackboard::create(parent) links the chain). So even plain multi-subtree trees with no external root now show a ROOT entry duplicating the main tree's blackboard. This matches the approach in #1130; if we'd rather expose ROOT only for genuinely external root blackboards, that's a small tweak to the needs_exported_root condition — happy to adjust.

Test plan

  • cmake -S . -B build -DBTCPP_GROOT_INTERFACE=ON && cmake --build build — clean, no warnings.
  • Full suite: 504/504 pass; Groot2PublisherIntegration.* 7/7 (2 existing + 5 new blackboard tests).
  • BTCPP_GROOT_INTERFACE=OFF build: compiles clean, Groot2 tests correctly excluded.
  • clang-format-21 clean on all touched files.

🤖 Generated with Claude Code

When a subtree's blackboard is backed by a separate root blackboard
(e.g. created via `Blackboard::create(external_root)` to expose `@`
globals), the Groot2 publisher never exported those root entries, so
they were invisible in Groot2. Export the root blackboard under the
reserved name `ROOT` whenever a requested subtree resolves to a
distinct root blackboard.

- Deduplicate the `ROOT` payload when several subtrees share the same
  root blackboard.
- Return the dump as `Expected<>` and send an error reply for
  ambiguous requests: a subtree literally named `ROOT`, or a request
  spanning multiple distinct root blackboards.
- Add functional coverage to gtest_groot2_publisher_integration.cpp
  using the shared Groot2Test helpers (makePublisher/Client).
- Enable `/utf-8` for behaviortree_cpp_test on MSVC so the Unicode
  name-validation tests build on Windows.

Closes #1130

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@facontidavide facontidavide merged commit ce95461 into master Jul 15, 2026
16 checks passed
@facontidavide facontidavide deleted the fix/1130-root-blackboard-dump branch July 15, 2026 12:57
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.

Root blackboard missing from generateBlackboardsDump

2 participants