Skip to content

Port main-picknik to upstream 4.11.1 - #48

Draft
dvadovsz wants to merge 125 commits into
main-picknikfrom
port/23870-main-picknik-4.11.1
Draft

dvadovsz wants to merge 125 commits into
main-picknikfrom
port/23870-main-picknik-4.11.1

Conversation

@dvadovsz

@dvadovsz dvadovsz commented Dec 3, 2026

Copy link
Copy Markdown
Member

[written by AI]

Moves main-picknik from the 4.9.0 fork to the 4.11.1 port without a force-push, for MoveIt Pro 11.0 (PickNikRobotics/moveit_pro#23870).

What changes

The branch head is one merge commit, 2fc8d7cd. Its first parent is the current main-picknik (183a3909), its second parent is port/23870-btcpp-4.11.1 (baad4671), and its tree is exactly baad4671's tree. After it lands, main-picknik holds upstream 4.11.1 plus five commits:

Every other 4.9.0 fork patch is gone: vector<Any> storage, PortError and getInputWithDiagnostic, tagged JSON export, SubTree port directions, vector toStr, the 4.7.2 name rules, duplicate SubTree names, double-quoted script strings and mixed-type arithmetic. MoveIt Pro replaces each of them in its own code or by migrating Objective XML, as the plan in moveit_pro docs_nonpublic/design/behaviortree-cpp-fork-delta.md (PickNikRobotics/moveit_pro#23870) describes.

The 4.9.0 line stays available in three places: as this merge's first parent, as tag archive/main-picknik-4.9.0, and as branch main-picknik-4.9 for 10.x fixes. Every SHA apt_build_farm has packaged is reachable from it.

Merge order

This must land as a merge commit; the repo now allows merge commits only. Do not move apt_build_farm's git_sha to the new main-picknik until the MoveIt Pro side is ready to merge, because MoveIt Pro main does not build against 4.11.1 until then.

How it was tested

  • Reviewed git diff 4.11.1 baad4671, and checked that the merge's tree and parents are the ones above.
  • gcc 15 and clang 21 on the host build it, and all 706 ctest tests pass. With gcc 13 in the MoveIt Pro dev image, 703 gtests pass.
  • Each fix's test fails when only that fix's source change is reverted.
  • An ament install shares no path with ros-jazzy-behaviortree-cpp 4.9.0. Its exported target carries no compile options.
  • MoveIt Pro built against it with its new extension layer. The full workspace builds, and the behavior, behavior_interface, agent and REST unit tests pass, apart from two licensing launch tests that also need a license server the dev container lacks. The core Objective integration test passes.
  • Known: with clang 18 and libstdc++ 13, the tests and examples fail on upstream's always-on -Werror (std::result_of from nullary std::bind in sample_nodes/dummy_nodes.h and examples/t04_reactive_sequence.cpp). Unmodified 4.11.1 fails the same way. The library itself and the apt build (gcc 13) are unaffected. The fix goes upstream.

This PR is a draft so its CI runs on 2fc8d7cd, including the Windows, macOS and ROS jobs that were not run locally.

L4co77 and others added 30 commits March 12, 2026 14:56
When literal values are passed to SubTree ports (not blackboard remapping),
detect numeric types (int64_t, double) before storing them in the child
blackboard. Previously all literals were stored as std::string, which caused
type-mismatch errors in Script expressions that tried to do arithmetic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bumps [prefix-dev/setup-pixi](https://github.com/prefix-dev/setup-pixi) from 0.9.4 to 0.9.5.
- [Release notes](https://github.com/prefix-dev/setup-pixi/releases)
- [Commits](prefix-dev/setup-pixi@v0.9.4...v0.9.5)

---
updated-dependencies:
- dependency-name: prefix-dev/setup-pixi
  dependency-version: 0.9.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Tony Najjar <tony.najjar@dexory.com>
Signed-off-by: Tony Najjar <tony.najjar@dexory.com>
Signed-off-by: Tony Najjar <tony.najjar@dexory.com>
…-literal-numeric-types

Preserve numeric types for literal subtree port values
…hub_actions/prefix-dev/setup-pixi-0.9.5

Bump prefix-dev/setup-pixi from 0.9.4 to 0.9.5
Rename header guard for shared_library.h
Signed-off-by: mini-1235 <mauricepurnawan@gmail.com>
Fix -Wfree-nonheap-object and -Wunused-result
…aviorTree#1152)

Replace hardcoded `set()` with `set(... CACHE STRING ...)` defaulting to
GNUInstallDirs values. This allows Debian/Ubuntu packagers to override
installation directories (e.g. `-DBTCPP_LIB_DESTINATION=lib/x86_64-linux-gnu`)
for multiarch support while preserving backward compatibility.

Fixes BehaviorTree#1120
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…viorTree#1157)

industrial_ci maps ROS_DISTRO=rolling to ubuntu:resolute (26.04), but
rolling debs are not published for resolute yet, so setup_rosdep fails
with "Unable to locate package ros-rolling-ros-environment". Pin the job
to noble (24.04), which industrial_ci supports for rolling. Revert once
rolling is published for resolute.
…ilds) (BehaviorTree#1156)

GitHub's `windows-latest` image now ships Visual Studio 2026 (MSVC 19.5),
which breaks both Windows CI jobs:

- `cmake Windows`: `conan profile detect` selects msvc 195, so Conan asks
  CMake for the "Visual Studio 18 2026" generator, which the installed
  CMake cannot create. The vendored foonathan-lexy dependency fails to
  build with "Could not create named generator Visual Studio 18 2026".

- `Pixi (conda)`: `cmake ..` defaults to the "Visual Studio 17 2022"
  generator, which is no longer present ("could not find any instance of
  Visual Studio").

Pin both jobs to windows-2022 (VS 2022 / MSVC 19.3x) to restore green CI.
Also set fail-fast: false on the pixi matrix so the ubuntu leg is no
longer masked by a Windows failure.

Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
…BehaviorTree#1137)

* Fix LoopNode does not reload dynamic vector input on second execution

I've implemented the suggestion from
BehaviorTree#1124
This seems to have fixed the issue I had with LoopNode not reloading the
input vector on second execution.

* Add unittest for restarting LoopNode with a vector from the blackboard
* Remove tinyxml2 vendor on rolling

Signed-off-by: Maurice <mauricepurnawan@gmail.com>

* Make tinyxml2_vendor quiet

Signed-off-by: Maurice <mauricepurnawan@gmail.com>

* Simplify: keep tinyxml2 dependency unconditional

The tinyxml2 rosdep key resolves on every supported distro, and the
previous package.xml already declared it directly. Only tinyxml2_vendor
needs to be conditional on the distros that still ship it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Signed-off-by: Maurice <mauricepurnawan@gmail.com>
Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Bumps [prefix-dev/setup-pixi](https://github.com/prefix-dev/setup-pixi) from 0.9.5 to 0.10.0.
- [Release notes](https://github.com/prefix-dev/setup-pixi/releases)
- [Commits](prefix-dev/setup-pixi@v0.9.5...v0.10.0)

---
updated-dependencies:
- dependency-name: prefix-dev/setup-pixi
  dependency-version: 0.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
The `WakeUp.BasicTest` previously used `system_clock`, which is not monotonic and can be affected by system time adjustments (NTP, DST). This made the test susceptible to flaky failures.

This change switches to `steady_clock` for robust, monotonic time measurement. Additionally, the assertion threshold is increased from `25ms` to `100ms` to provide adequate headroom for scheduler jitter, especially on loaded CI environments.
* Fix package share path API for newer ament_index_cpp

* Style: format package share path update

---------

Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
…orTree#1161)

Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
* Fix Groot2 publisher thread safety

* Simplify Groot2 publisher thread-safety machinery

Apply code-review cleanups to the thread-safety fix:

- Extract the duplicated callback drain-gate (CallbackState/CallbackGuard
  and HookCallbackState/HookCallbackGuard were byte-identical) into a
  single shared BT::details::CallbackGate in utils/callback_gate.h.
  notify_all() now fires only when a drain is actually waiting.
- Replace the 69-line injected hook lambda and its immediately-invoked
  inner lambda with PImpl::runHook(). The BREAKPOINT_REACHED message is
  now built and sent without holding hook->mutex, and only the ZMQ send
  holds publisher_mutex.
- Drop the Hook::removed tombstone from the public protocol header:
  with the single lock order established (hooks_map_mutex before
  hook->mutex), enableAllHooks() and HOOKS_DUMP traverse the maps under
  hooks_map_mutex, so no stale snapshot can resurrect an erased hook and
  'enabled = false' suffices for stale callback copies.
- GET_TRANSITIONS: swap the transitions buffer out under status_mutex
  and serialize outside the lock the status callback contends on.
- Call unsubscribeFromTreeChanges() in the destructors of the five other
  StatusChangeLogger subclasses; the base-class destructor call runs too
  late to protect derived state, so each dtor must drain callbacks first.
- Deduplicate the hook-JSON literals in the Groot2 tests into
  Groot2Test::makeHook(); use make_unique for PImpl; rely on CTAD for
  lock guards in touched code.

Verified: 495/495 tests (Release), 499/499 under TSan with the CI
suppressions file, zero ThreadSanitizer warnings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Extend TSan suppressions to statically linked ZeroMQ

CI builds zmq from source with Conan and links it statically, so the
module-based rule 'race:libzmq.so' does not match and zmq-internal
false positives (encoder_base_t::encode, msg_t::close) fail the
Groot2 hook tests. Match the zmq namespace instead, which works
regardless of how the library is linked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Move StatusChangeLogger state behind a PImpl

StatusChangeLogger is the base class of a public extension point: every
logger, including user-defined ones, embeds its layout. The thread-safety
fix already changes that layout (and, being header-only, the old inlined
implementation survives in consumer binaries even after a library
upgrade), so take the opportunity to pay the ABI break only once:

- all data members move into a PImpl defined in the new
  src/loggers/abstract_logger.cpp
- the member functions are no longer inline, so future behavior fixes in
  this class can ship as an ABI-compatible library update

Adding or changing state in StatusChangeLogger no longer affects the
layout derived classes compile against. Note that changing its virtual
interface would still break ABI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* Add macOS build to CI

Add a Conan + CMake workflow running on macos-latest (Apple Silicon,
AppleClang + libc++). This exercises the Apple standard-library toolchain
that other CI jobs (Ubuntu/GCC, Windows/MSVC, conda/Clang) do not, catching
Apple-specific breakage such as the missing floating-point std::from_chars.

The job mirrors the existing cmake_ubuntu.yml Conan flow (conan install ->
cmake --preset conan-release -> ctest), pinning compiler.cppstd=17 as the
Windows job does.

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

* Fix Apple libc++ build: guard floating-point std::from_chars

Apple's libc++ deletes the floating-point std::from_chars overload (and
undefines __cpp_lib_to_chars), so the unguarded double parse in
recursivelyCreateSubtree fails to compile on macOS. This is the same code
path the new cmake_macos.yml CI job exercises, so guard it here to keep that
job green.

Introduce parseDoubleStrict(), which uses std::from_chars where available and,
where it is not (Apple libc++), falls back to strtod_l with a "C" locale
created once. Unlike setlocale(), this does not mutate process-global state,
so it is thread-safe. A small guard rejects the inputs strtod would accept but
std::from_chars(general) rejects -- leading whitespace, a leading '+', and hex
floats -- so the parsed blackboard-entry type is identical on every platform.
Verified byte-for-byte against std::from_chars over a battery of inputs
(including "+1.5", " 1.5", "0x1p4", "1.", ".5", inf/nan, overflow/underflow).

The integer std::from_chars just above is available on Apple libc++ and is
left unchanged.

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

* CI: install Conan via Homebrew on macOS

turtlebrowser/get-conan runs `pip3 install`, which fails on macOS runners with
PEP 668 (externally-managed-environment). Use `brew install conan` instead,
which provides Conan 2.x without touching the system Python.

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

* Fix convertFromString<double/float> error type on Apple libc++

On platforms without floating-point std::from_chars (Apple libc++), the
fallback used std::stod but let its std::invalid_argument/out_of_range escape,
whereas the from_chars path throws BT::RuntimeError. This made
BasicTypes.ConvertFromString_Double fail on macOS (it expects RuntimeError for
"not_a_number"). The throw also skipped the setlocale restore, leaking the "C"
locale process-wide. Wrap stod in try/catch: restore the locale and rethrow as
RuntimeError on both success and failure paths.

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

* CI: macOS diagnostics for remaining test failures (temporary)

Add --output-on-failure and an lldb backtrace step (on failure) to capture
assertion messages and stack traces for the macOS-only segfaults/timeouts.
To be removed once those are fixed.

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

* Fix macOS segfault: don't touch child in DelayNode destructor

~DelayNode called halt(), which via DecoratorNode::halt() -> resetChild()
dereferences the child node (child_node_->status()). During Tree destruction
nodes are owned by a flat std::vector<TreeNode::Ptr> whose element-destruction
order is unspecified: libstdc++ tears down front-to-back (child outlives the
decorator) but libc++ back-to-front (child destroyed first). On libc++ (macOS)
the child is already gone, so status() locks a mutex through a null PImpl and
segfaults. This crashed every tree containing a <Delay> node on macOS
(Decorator.DelayWithXML and the Substitution Issue930 tests).

Only cancel the timer in the destructor, mirroring TimeoutNode's destructor,
which already does exactly this. The halt() method is unchanged for normal
(non-destruction) halting.

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

* CI: retry timing-flaky tests on macOS (--repeat until-pass:3)

The shared macOS runners cannot reliably meet several tests' tight wall-clock
tolerances (e.g. elapsed 222 vs 200 ms), and the failing set varies run to run.
Retry to absorb the flakiness without loosening assertions on other platforms.

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

* tests: widen timing tolerances on macOS (platform-gated)

The shared macOS CI runners are much slower/noisier than Linux/Windows, so a
few tests with tight wall-clock tolerances fail there (not library bugs). Gate
the tolerances behind __APPLE__ so other platforms keep the strict values:

- gtest_coroutines: scale the sub-50ms action/timeout durations by 5x on macOS
  (only relative ordering matters), so the timeout reliably fires between the
  short and long actions instead of racing scheduling jitter.
- gtest_parallel PauseWithRetry: widen margin_msec 80 -> 250 on macOS
  (observed overshoot was 130-150ms).

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

* CI: bump macOS test retries to until-pass:5

A couple of timing tests (Parallel.Issue819, SwitchTest.CaseSwitchToDefault)
are flaky under runner load rather than consistently over a single tolerance,
so retry a bit more to absorb that.

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

* CI: exclude timing-flaky tests on macOS; drop lldb diagnostic

The shared macOS runners are too slow/noisy to reliably meet the tight
wall-clock tolerances in ~11 tests (a rotating subset fails each run). They are
not macOS-specific logic and keep running on Linux and Windows, so exclude them
on macOS with ctest -E to make the job deterministic. --repeat until-pass:3
absorbs residual flakiness in the rest. The __APPLE__-gated tolerances added
earlier (gtest_coroutines, gtest_parallel) remain so these can be re-enabled
here later.

Also remove the temporary lldb backtrace step now that the DelayNode
destruction segfault is fixed.

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

* Revert macOS timing-margin edits; rely on exclusion only

Since the timing-sensitive tests are excluded on macOS (ctest -E), there is no
reason to also widen their wall-clock tolerances. Restore gtest_coroutines.cpp
and gtest_parallel.cpp to their original values so the shared tests stay
pristine for every platform, and drop the stale workflow comment that mentioned
the __APPLE__-gated tolerances.

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

* Simplify: dedup convertFromString double/float Apple fallback

/simplify cleanup. The macOS (no floating-point std::from_chars) fallback was
duplicated between convertFromString<double> and <float>, each restoring the
locale twice (catch + fall-through). Extract a single guarded file-local helper
stodClassicLocale() with an RAII locale-restore, so the fallback lives in one
place and the restore happens on every path without the duplicated try/catch.
Behavior is unchanged (still stod under a temporary "C" locale, still throws
RuntimeError on bad input).

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

* Unify double parsing into a single BT::parseDouble primitive

Previously the "parse a double locale-independently" logic existed in two
divergent forms: xml_parsing.cpp's parseDoubleStrict (from_chars, or strtod_l +
"C" locale on Apple libc++ -- thread-safe, strict) and basic_types.cpp's
convertFromString<double>/<float> Apple fallback (stod + global setlocale --
thread-unsafe, lenient). They also disagreed on Apple: convertFromString
accepted leading '+'/whitespace/hex that std::from_chars (and thus the other
platforms) reject.

Extract one shared BT::parseDouble(str, out, require_full_consumption) that both
build on:
- xml_parsing passes require_full_consumption=true (strict full-string check,
  so compound values like "2.2;2.4" stay strings).
- convertFromString<double>/<float> pass false (lenient, matching the previous
  from_chars behavior of accepting trailing characters).

The single implementation uses std::from_chars where available and the
thread-safe strtod_l + static "C" locale fallback otherwise, reproducing
from_chars(general) semantics exactly (verified against std::from_chars over a
battery of inputs, both modes). This removes the duplicated fallback and the
thread-unsafe setlocale path from basic_types.cpp. On Apple, convertFromString
now rejects '+'/whitespace/hex, matching Linux/Windows.

convertFromString<float> keeps std::from_chars<float> on platforms that have it
(preserving float-range semantics) and uses parseDouble only on the fallback.

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…ehaviorTree#1168)

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 BehaviorTree#1130

Co-authored-by: magic-alt <zaqwerss@outlook.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
aysha-afrah26 and others added 29 commits November 7, 2026 17:54
…ree#1269)

* fix: bad_expected_access::what() returns the error message (BehaviorTree#1263)

what() returned a fixed "bad_expected_access", so the actual error of a
failed Expected<T> was lost. When the error type converts to std::string,
the message is now returned instead. It is stored in a shared_ptr so that
copying the exception does not allocate.

* simplify bad_expected_access::what(): reuse m_error instead of a second copy

Return m_error.c_str() through an overload on std::string, with a generic
fallback for other error types. No extra member, so the class layout is
unchanged, and copying the exception no longer copies the message twice.

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

---------

Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…1277)

* OSS-Fuzz: Add new fuzzer/corpus/dict targets tree exec

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>

* Fix fromatting

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>

* bt_tree_exec_fuzzer: drop references to files that are not in the repo

Remove the "btcpp-1" / findings/ / coverage-pipeline references and the
unused wakeup_aware variable, and flatten the nested anonymous namespace.
No change in what the fuzzer generates or consumes.

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

---------

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ld (BehaviorTree#1273)

* reset a child's status when its halt() throws in ControlNode::haltChild

Previously the child stayed RUNNING, so the next halt of the parent halted
it again and threw a second time. When that happened inside ~Tree(), the
process terminated. Callers still see the exception.

This covers haltChild() and haltChildren(), which calls it.
ControlNode::resetChildren() and DecoratorNode::resetChild() have the same
pattern and are left for a follow-up.

* move the throwing-halt status reset into TreeNode::haltNode()

The previous commit reset a child's status in ControlNode::haltChild() when
its halt() threw, so the next reset does not halt it again. But built-in
nodes halt their children through ControlNode::resetChildren() and
DecoratorNode::resetChild()/haltChild(), and Tree::haltTree() halts the root
directly: all of them go through TreeNode::haltNode() and kept the bug (the
node stays RUNNING, is halted a second time, and ~Tree() -> haltTree() throws
again from a destructor, i.e. std::terminate).

Put the guard in the single choke point, TreeNode::haltNode():
try { halt(); } catch(...) { resetStatus(); throw; }, and drop the
now-redundant try/catch in ControlNode::haltChild(). The exception still
propagates. The existing _onHalted post-condition code is unchanged.

Add tests with built-in parents (Sequence, RetryUntilSuccessful): haltTree()
throws once, every node is IDLE afterwards, a second haltTree() does not
throw and onHalted() is not called again. No ABI change.

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

---------

Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Bound the AST height of script expressions to kMaxNestingDepth (256), so that evaluating or destroying a long flat chain like 1+1+1+... cannot overflow the stack (1 MB default on Windows).

Behavior change: a single script expression with more than ~255 chained operators is now rejected when the tree is created.
…ehaviorTree#1272)

Fix BehaviorTree#1271: with _autoremap="true", SubTree model input_port defaults were never applied.

Behavior change: for a modelled input port with a literal default that is not explicitly remapped, the default is now set in the SubTree blackboard if no entry with that name exists in the parent blackboard when the tree is created (creation-time rule, documented in PORT_CONNECTION_RULES.md). A parent key created only at runtime (e.g. by a Script) is shadowed by the default.
…andlers (BehaviorTree#1283)

Restore the 4.10.0 member layout of SleepNode, DelayNode and TimeoutNode (broken by BehaviorTree#1180, 9b63b50: timer_ was moved last, changing every member offset while ctors/dtors are inline in the headers), keeping BehaviorTree#1180's use-after-free fix: the destructors now call the new inline TimerQueue::stop() first, so every pending handler finishes while the node mutexes are alive. Layout verified identical to 4.10.0 with a sizeof/offsetof probe.

Also ignore stale timer handlers: a handler already popped by the TimerQueue worker when the node was halted could act on the restarted node (Sleep returning early, Delay skipping its delay, Timeout halting its new child). Each handler now checks the timer id it was created for under the node mutex; halt() resets timer_id_.

ABI: compatible with 4.10.0 (no header layout, vtable or signature change).
…ehaviorTree#1284)

* null-check the entry in ImportBlackboardFromJSON after createEntry

After createEntry() the entry was re-fetched with getEntry() and dereferenced
unchecked; a concurrent Blackboard::unset() from another thread in that window
returned nullptr and crashed. Skip that key instead.

No test: the window is a few instructions wide, so a deterministic reproduction
is not possible. The same createEntry->getEntry->deref pattern elsewhere
(SetBlackboardNode, script assignment operator) is already null-checked.

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

* reduce nesting of the null check (Sonar S134)

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…1285)

The test asserted at least 5 ticks while a 100 ms Sleep runs, i.e. that each
10 ms wait of tickWhileRunning() returns on time. A loaded macOS runner took
~33 ms per wait and failed with 3 ticks (master run 42389941988, 6b8e68c).
The test checks that the observer counts match the tick count; the only
guaranteed minimum is 2 ticks (one RUNNING, the final SUCCESS).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…e#895) (BehaviorTree#1261)

* Add _onlyIf and _onStart preconditions (BehaviorTree#820, BehaviorTree#895)

- `_onlyIf="<script>"`: if false when the node is IDLE, return SKIPPED
  (the opposite of `_skipIf`, more readable in most cases).
- `_onStart="<script>"`: execute a script right before the first tick() of
  the node, i.e. only if no other precondition returned a status. Useful
  to initialize or reset blackboard entries.

Both are evaluated only when the node is IDLE/SKIPPED, like `_skipIf`.

ONLY_IF and ON_START are appended at the end of PreCond, so the values of
the existing ones don't change. Appending ONLY_IF after WHILE_TRUE keeps
the semantics: SKIP_IF, WHILE_TRUE and ONLY_IF all return SKIPPED.

Behavior change: the attribute names `_onlyIf` and `_onStart` are now
reserved. Before, they were stored silently as non-port attributes and
did nothing.

Supersedes BehaviorTree#821 and BehaviorTree#932.

Co-Authored-By: Darko Lukic <2135826+lukicdarkoo@users.noreply.github.com>
Co-Authored-By: Aglargil <34728006+Aglargil@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Preconditions: static_assert on name arrays, fix _onStart comment, document _onStart/_onlyIf caveats

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

* test: cover _onlyIf/_onStart edge cases (while-interrupt, SubTree, ReactiveSequence, WriteTreeToXML)

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

---------

Co-authored-by: Darko Lukic <2135826+lukicdarkoo@users.noreply.github.com>
Co-authored-by: Aglargil <34728006+Aglargil@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* reset a child's status when its halt() throws in ControlNode::haltChild

Previously the child stayed RUNNING, so the next halt of the parent halted
it again and threw a second time. When that happened inside ~Tree(), the
process terminated. Callers still see the exception.

This covers haltChild() and haltChildren(), which calls it.
ControlNode::resetChildren() and DecoratorNode::resetChild() have the same
pattern and are left for a follow-up.

* add Finally control node for guaranteed cleanup

* Finally: guard concurrent halt(), noexcept halt, document blocking halt

- A halt() that arrives while another one runs (e.g. Tree::haltTree() from
  another thread while the tick thread is in the halt_timeout_msec loop)
  returns at once, so cleanup is never ticked concurrently. An atomic
  halting_ flag is set with compare_exchange and cleared by RAII.
- halt() is noexcept. The status reset at its end notifies observers that
  may throw, so it is wrapped and reported like the rest.
- A pending main exception dropped by a halt is now printed.
- Document that halt_timeout_msec > 10 blocks the halting parent and any
  enclosing Timeout, adds up across nested Finally nodes, and gives
  foreign-thread halts a single tick; that the default single tick cuts an
  asynchronous cleanup short; and "10 or less" means a single tick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ME1hnSFSzibU5phxboGsjk

---------

Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Add 'generic' parameter to writeTreeXSD()

When generic=true, oneNodeGroup uses xs:any processContents="lax" instead
of a closed xs:choice, allowing unknown custom node elements to pass
validation. Top-level xs:element declarations are also emitted so that lax
processing can still resolve and validate the known built-in node types by name.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add generate_xsd tool

Generates the generic XSD schema from the default factory (built-in nodes
only) and prints it to stdout, suitable for use as a generic static validator
that stays in sync with the built-in node inventory.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix non-deterministic port attribute order in writeTreeXSD()

PortsList is an unordered_map so iterating it directly produced XSD
attributes in hash-table order, which varies across runs and platforms.
Sort ports into a std::map before emitting xs:attribute elements.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add writeTreeSchematron() for cross-reference validation of BT XML files

XSD alone cannot express constraints like "every custom node element used
in a BehaviorTree body must have a matching TreeNodesModel entry"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add generate_schematron tool

Generates an ISO Schematron schema (btcpp4.sch) complementing the generic XSD

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add generated XSD and Schematron schemas

* Add validate_xml.py - XSD and Schematron validation tool

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Only built-ins should go into generic xsd file

* Add tests for writeTreeXSD() and writeTreeSchematron()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix implicit conversion

* Also handle inout_port in XSD

* Fix reconfiguration after editing src/btcpp4_schematron.sch

* Fix writeTreeXSD() signature not to break ABI

* Change placeholder replacement logic for Schematron

* Add more test cases for InsideXmlComment()

* Add xsd and schematron checks to CI (intentionally broken)

* Fix clang-format issues

* Regenerate schemas to pass CI

* Add guard for --no-xsd --no-sch together

to validate_xml.py

* Remove rule checking explicit notation against TreeNodeModel

* Regenerate Schematron file

* Add Schematron Rule B: explicit-notation node structure constraints

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Regenerate Schematron file

* Drop insideXmlComment(): keep the placeholder out of the template comment

insideXmlComment() was added to the public xml_parsing.h only so that
writeTreeSchematron() could skip the ##BUILTIN_PIPE## placeholder where
the template comment mentions it. Rewording the comment so it no longer
contains the placeholder makes a plain replace-all enough, removes the
helper from the public API, and also fixes the generated bt4.sch, whose
comment still described an unexpanded placeholder.

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

* Regenerate tools/generated/bt4.xsd for _onlyIf, _onStart, BTCPP_version

Master gained the _onlyIf/_onStart preconditions (BehaviorTree#1261) and the
BTCPP_version root attribute (BehaviorTree#1264); the checked-in XSD was stale and
the new 'generated schemas are up to date' CI step would fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ME1hnSFSzibU5phxboGsjk

* Regenerate bt4.xsd and bt4.sch for the Finally node (BehaviorTree#1229)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ME1hnSFSzibU5phxboGsjk

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ME1hnSFSzibU5phxboGsjk
…error (BehaviorTree#1290)

Downstream packages (Nav2, ROS Lyrical) compile our public headers with
-Werror; GCC 15 at -O2 reported -Wnull-dereference in ThreadSafeSignal::notify()
(false positive in vector<weak_ptr> copy-assignment) and in the JsonExporter
converters (unchecked *castPtr<T>(), now a LogicError instead of UB).

To keep this from regressing, the library and every in-tree consumer of its
headers now always build with -Wall -Wextra -Wpedantic -Wnull-dereference
-Werror (MSVC: /W4 /WX /permissive- /wd4702), and the GCC 15 ros2-lyrical job
builds in Release. Existing warnings across GCC 11/13/15, Clang, AppleClang and
MSVC are fixed.

Fixes BehaviorTree#1288. Supersedes BehaviorTree#1287.

Co-authored-by: Marco Matteo Bassa <bassamarco91@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from throwing (BehaviorTree#1289)

* Roll back a rejected XML load as a whole, not per document

BehaviorTree#1266 dropped a document that failed to load, but the rollback stopped at the
document boundary. If main.xml includes sub.xml and then fails, sub.xml has
already registered its trees and they stay behind, and sub.xml becomes the
first document, so instantiateTree() reads main_tree_to_execute from it.

Take a snapshot before the call and restore it on failure. That also puts back
a tree this call redefined, whose element lives in the document about to be
erased.

Fixes BehaviorTree#1282

* Don't let an exception escape Tree's destructor

Tree::~Tree() calls haltTree(), and halting may throw: a TryCatch with
catch_on_halt="true" ticks its catch child, and a tick is allowed to throw.
An exception leaving a destructor calls std::terminate, so destroying such a
tree aborted the process.

Mark the destructor noexcept and swallow the exception. There is no caller
left to report to.

Fixes BehaviorTree#1281

* Apply pre-commit (clang-format)

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

* Roll back a rejected load once, at the top-level call; simplify tests

- loadLastDocImpl is now only the top-level rollback point: <include> calls
  loadDocImpl directly, and on failure the call drops every document it
  opened (erase(doc_it, end())), so a valid included document no longer stays
  the "first document" whose main_tree_to_execute instantiateTree() reads.
  The snapshot also covers subtree_models and current_path, as listed in
  BehaviorTree#1282, and is restored by move.
- ~Tree(): drop the redundant noexcept (destructors are implicitly noexcept)
  and report a throwing halt on stderr, as FinallyNode does, instead of
  swallowing it silently (also fixes bugprone-empty-catch).
- Tests: share TempSubdir/writeFile through test_helper.hpp (no getpid, which
  broke MSVC); move the destructor test next to the other catch_on_halt tests
  using lambda nodes and assert the catch child ran; add a first-document
  test; make the redefinition test go through a valid include of a rejected
  file (the old one passed on master); drop HaltStillRuns and
  RollbackKeepsEarlierTrees, which asserted nothing new.

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

* Cover a non-std exception thrown while halting in Tree::~Tree()

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

---------

Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Port of 88197ab from the 4.9.0 line onto 4.11.1. Keeps the coexistence invariants from docs_nonpublic/design/behaviortree-cpp-fork-coexistence.md: package, library and include root scoped to behaviortree_cpp_picknik, soname .so.4.11, bt4_picknik_* tool names, and the BTCPP_PICKNIK_FORK sentinel in basic_types.h.

New on 4.11 and not covered by the 4.9.0 commit:
- upstream installs bt4_generate_xsd and bt4_generate_schematron. Both are renamed to bt4_picknik_*, and the cmake_ubuntu.yml step that runs them uses the new paths.
- tests/cmake/subproject_version reads the library target by name, so it reads behaviortree_cpp_picknik.
- the ros2-lyrical job asserts the install path of libbehaviortree_cpp.so, so it asserts libbehaviortree_cpp_picknik.so.
- the pixi Linux test task runs the test binary by path, so it runs behaviortree_cpp_picknik_test.

Dropped as on the 4.9.0 commit: the conanfile.py foonathan-lexy requirement and USE_VENDORED_LEXY, which nothing reads since lexy was removed.

Refs PickNikRobotics/moveit_pro#20928, PickNikRobotics/moveit_pro#23870

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream's workflows push-trigger on master only, so the fork's shipping branch got no post-merge CI. Add main-picknik to each workflow that triggers on master, except doxygen-gh-pages, which publishes docs. The jobs themselves stay upstream's (moveit_pro#23870).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…check

VerifyXML's ReactiveSequence async-child scan read the child's tag name, so a generic <Action ID="Foo"/> looked up "Action" and was rejected as "Unknown node type: Action". Resolve the ID the way the recursive validation below already does. SubTree keeps its own node type, and a missing or empty ID keeps the old error.

Upstream: issue BehaviorTree#1298, PR BehaviorTree#1299. Drop this commit once a release carries it.

Co-Authored-By: Noah Wardlow <noah.wardlow.0@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from dvadovsz/BehaviorTree.CPP@0f7fa11)
A SubTree model port declared with an empty default, default="", was treated as mandatory, so a parent that did not remap it failed with "is defining a mandatory port called [...], but you are not remapping it". The check tested the default's string form rather than whether a default was declared, so "defaults to empty" and "no default" became the same case. Gate on the Any instead, as writeTreeNodesModelXML and the XSD generator already do.

Upstream: issue BehaviorTree#1300, PR BehaviorTree#1301. Drop this commit once a release carries it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from dvadovsz/BehaviorTree.CPP@124d366)
getEntry() and set() resolve a key through SubTree remapping, _autoremap and the '@' root prefix, but unset() only looked at local storage. An UnsetBlackboard inside a SubTree on a remapped key, or on "@key", did nothing and still returned SUCCESS. Resolve the key in unset() the same way getEntry() does. A missing entry is still a no-op, and private keys starting with '_' are not autoremapped.

Upstream: issue BehaviorTree#1302, PR BehaviorTree#1303. Drop this commit once a release carries it.

Co-Authored-By: David Vadovszki <david.vadovszki@picknik.ai>
(cherry picked from dvadovsz/BehaviorTree.CPP@9bbfb83)
main-picknik was upstream 4.9.0 plus PickNik's fork patches. This merge takes the tree of port/23870-btcpp-4.11.1 exactly: upstream 4.11.1 plus the behaviortree_cpp_picknik packaging, CI on main-picknik pushes, and three fixes pending upstream (BehaviorTree#1299, BehaviorTree#1301, BehaviorTree#1303). Every other fork patch moves into MoveIt Pro (PickNikRobotics/moveit_pro#23870). The 4.9.0 line stays reachable as this merge's first parent and as tag archive/main-picknik-4.9.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.