behavior_machines 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3f9dd7a3b8bfdafe5901e6746da50ba7e9285ec6571b324f556b4704b99d803
4
- data.tar.gz: 4d7a1f39ef4639851f1738fc8b55e669bf00afafb92561c59a419cd25beb2d97
3
+ metadata.gz: 38d7cc19f70e22ec58a58e07a0c371fbd0a300843e19fb0dbee69094cc6efb68
4
+ data.tar.gz: 7487daf6be135db2e1e26992e54c2214346858adaf5a7ae1a15b9d27f3bff186
5
5
  SHA512:
6
- metadata.gz: 9d0bd85acb71be758e4ae587b2689176be26501ca4d0129b4fe6828f03cbbc046511bb686b7dcfa6bb4c1bcd28ac293ce33a77eecf04505e5ed8439e7f64e4a6
7
- data.tar.gz: 2125275f724cecc1f485ea152a0dcbca5e1809fbdf5e0c58fbe6383a89554e92552e1055d2b3c7ff1263684f15be6c16a7b1ca5ae81bccc3c15ef314223442a0
6
+ metadata.gz: 5bc6d295f6da306f0b8b4b1e700892197a098c29da53937d2853c0d5cde9a6dd0d57c7ac53357c3c12601b8be6298d4530fe654465f7f880f5ca1a92625ffdf2
7
+ data.tar.gz: f99ca7e7c72327b5c6519428c17a98eb3d019f6063c4f77593cfbe78ff677d822a9a579e51dadcb022527ce423de89eb43e154a0c60e4225326e03eb3a482821
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.2](https://github.com/seuros/behavior_machines/compare/behavior_machines/v0.8.1...behavior_machines/v0.8.2) (2026-11-16)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * lower deep decorator chains without recursing in post_order ([345fb13](https://github.com/seuros/behavior_machines/commit/345fb138420843714ee77b12363a4c64f3341ecb))
9
+
3
10
  ## [0.8.1](https://github.com/seuros/behavior_machines/compare/behavior_machines/v0.8.0...behavior_machines/v0.8.1) (2026-11-16)
4
11
 
5
12
 
data/Cargo.lock CHANGED
@@ -13,7 +13,7 @@ dependencies = [
13
13
 
14
14
  [[package]]
15
15
  name = "behavior-machines"
16
- version = "0.4.0"
16
+ version = "0.4.1"
17
17
  dependencies = [
18
18
  "matryona-machines",
19
19
  "state-machines",
@@ -21,7 +21,7 @@ dependencies = [
21
21
 
22
22
  [[package]]
23
23
  name = "behavior-machines-circuit"
24
- version = "0.6.0"
24
+ version = "0.6.1"
25
25
  dependencies = [
26
26
  "behavior-machines",
27
27
  "matryona-machines",
@@ -29,7 +29,7 @@ dependencies = [
29
29
 
30
30
  [[package]]
31
31
  name = "behavior_machines_native"
32
- version = "0.1.5"
32
+ version = "0.1.6"
33
33
  dependencies = [
34
34
  "behavior-machines",
35
35
  "magnus",
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.1](https://github.com/seuros/behavior_machines/compare/behavior-machines-circuit-v0.6.0...behavior-machines-circuit-v0.6.1) (2026-11-16)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * lower deep decorator chains without recursing in post_order ([345fb13](https://github.com/seuros/behavior_machines/commit/345fb138420843714ee77b12363a4c64f3341ecb))
9
+
3
10
  ## [0.6.0](https://github.com/seuros/behavior_machines/compare/behavior-machines-circuit-v0.5.0...behavior-machines-circuit-v0.6.0) (2026-11-16)
4
11
 
5
12
 
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "behavior-machines-circuit"
3
- version = "0.6.0"
3
+ version = "0.6.1"
4
4
  edition.workspace = true
5
5
  rust-version.workspace = true
6
6
  license.workspace = true
@@ -56,7 +56,7 @@
56
56
  //!
57
57
  //! The depth does not grow with the number of children: every prefix test
58
58
  //! reads a sum of bits, and a sum is free. Measured, an ordered composite
59
- //! saturates at depth 4 reactive and 6 with memory from four children up to
59
+ //! saturates at depth 3 reactive and 6 with memory from four children up to
60
60
  //! any width, which `lower/tests.rs` pins.
61
61
  //!
62
62
  //! # Indexing
@@ -114,6 +114,7 @@ struct Arbitration {
114
114
  /// Per child: the walk reached it, so it was ticked.
115
115
  reach: Vec<Bit>,
116
116
  /// Per child: a stop strictly earlier, so a reactive composite halts it.
117
+ /// `NOT clear` for a reactive composite, constant zero for a memory one.
117
118
  after_stop: Vec<Bit>,
118
119
  /// The cursor to store for the next tick.
119
120
  next_cursor: Affine,
@@ -244,8 +245,7 @@ impl Lowered {
244
245
  pub fn new<L>(steps: impl IntoIterator<Item = Step<L>>) -> Result<Self, Refusal> {
245
246
  let (flat, leaves, cursors) = flatten(steps, Self::MAX_NODES)?;
246
247
 
247
- let mut report_order = Vec::with_capacity(flat.len());
248
- post_order(&flat, 0, &mut report_order);
248
+ let report_order = post_order(&flat);
249
249
  let plan = Plan::new(flat.len(), leaves, cursors, report_order);
250
250
  let mut builder = Builder::new(plan.cell_count());
251
251
  let (raw, arbitrations) = arbitrate(&flat, &plan, &mut builder)?;
@@ -259,22 +259,28 @@ impl Lowered {
259
259
  }
260
260
  }
261
261
 
262
- /// Appends the subtree rooted at `index` in post-order, children first.
262
+ /// The tree's nodes in post-order, children first.
263
263
  ///
264
264
  /// This is the order the engine's observer reports nodes in, because
265
265
  /// `Slot::tick` reports itself only after ticking its children.
266
+ ///
267
+ /// Nesting depth is caller-controlled and the node limit does not bound it,
268
+ /// so this walks with an explicit stack rather than recursing: it visits
269
+ /// root, then children right to left, which is post-order reversed.
266
270
  #[expect(clippy::indexing_slicing, reason = "see `# Indexing`")]
267
- fn post_order(flat: &[Flat], index: usize, order: &mut Vec<usize>) {
268
- match &flat[index] {
269
- Flat::Leaf { .. } | Flat::Constant(_) => {}
270
- Flat::Map { child, .. } => post_order(flat, *child, order),
271
- Flat::Ordered { children, .. } => {
272
- for child in children {
273
- post_order(flat, *child, order);
274
- }
271
+ fn post_order(flat: &[Flat]) -> Vec<usize> {
272
+ let mut order = Vec::with_capacity(flat.len());
273
+ let mut pending = vec![0];
274
+ while let Some(index) = pending.pop() {
275
+ order.push(index);
276
+ match &flat[index] {
277
+ Flat::Leaf { .. } | Flat::Constant(_) => {}
278
+ Flat::Map { child, .. } => pending.push(*child),
279
+ Flat::Ordered { children, .. } => pending.extend(children),
275
280
  }
276
281
  }
277
- order.push(index);
282
+ order.reverse();
283
+ order
278
284
  }
279
285
 
280
286
  /// Pass 2: each node's raw status, bottom-up.
@@ -364,12 +370,14 @@ fn lower_ordered(
364
370
  // `none_earlier` answers one bit per input, so all three hold one entry
365
371
  // per child.
366
372
  for ((passed, earlier), stuck) in all_passed.iter().zip(&before).zip(&blocked) {
367
- // `stop` is at-most-one-hot, so the running total of earlier stops is
368
- // itself a bit and costs nothing to form.
373
+ // A stop strictly earlier is exactly an earlier blocked child: the
374
+ // first one is where the walk stopped. So the total of earlier stops
375
+ // is `NOT passed`, one shared wire, rather than a sum re-formed over
376
+ // every earlier stop, which made a wide composite cubic to lower.
369
377
  after_stop.push(if cursor.is_some() {
370
378
  Bit::ZERO
371
379
  } else {
372
- Bit::or_disjoint(stop.iter().cloned())
380
+ !passed.clone()
373
381
  });
374
382
  reach.push(builder.and(passed, &!earlier.clone())?);
375
383
  stop.push(builder.and(passed, stuck)?);
@@ -91,7 +91,7 @@ impl StatusBits {
91
91
  }
92
92
 
93
93
  /// Swaps success and failure, leaving running alone. Free: the
94
- /// [`Inverter`](behavior_machines::Node::Inverter) decorator costs no
94
+ /// [`Inverter`](behavior_machines::Step::Inverter) decorator costs no
95
95
  /// operations at all, it relabels two wires.
96
96
  #[must_use]
97
97
  pub fn inverted(self) -> Self {
@@ -104,8 +104,8 @@ impl StatusBits {
104
104
 
105
105
  /// Reports any finished child as `forced`, leaving running alone. Free.
106
106
  ///
107
- /// This is [`ForceSuccess`](behavior_machines::Node::ForceSuccess) and
108
- /// [`ForceFailure`](behavior_machines::Node::ForceFailure): the two
107
+ /// This is [`ForceSuccess`](behavior_machines::Step::ForceSuccess) and
108
+ /// [`ForceFailure`](behavior_machines::Step::ForceFailure): the two
109
109
  /// finished bits merge into one, which is addition of disjoint bits.
110
110
  #[must_use]
111
111
  pub fn forced(self, forced: Status) -> Self {
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.1](https://github.com/seuros/behavior_machines/compare/behavior-machines-v0.4.0...behavior-machines-v0.4.1) (2026-11-16)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * lower deep decorator chains without recursing in post_order ([345fb13](https://github.com/seuros/behavior_machines/commit/345fb138420843714ee77b12363a4c64f3341ecb))
9
+
3
10
  ## [0.4.0](https://github.com/seuros/behavior_machines/compare/behavior-machines-v0.3.1...behavior-machines-v0.4.0) (2026-11-16)
4
11
 
5
12
 
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "behavior-machines"
3
- version = "0.4.0"
3
+ version = "0.4.1"
4
4
  edition.workspace = true
5
5
  rust-version.workspace = true
6
6
  license.workspace = true
@@ -1,7 +1,14 @@
1
1
  use crate::Status;
2
2
 
3
3
  /// Identifies a node within one compiled tree: its position in a depth-first,
4
- /// pre-order walk of the [`Node`](crate::Node) definition, with the root at 0.
4
+ #[cfg_attr(
5
+ feature = "alloc",
6
+ doc = " pre-order walk of the [`Node`](crate::Node) definition, with the root at 0."
7
+ )]
8
+ #[cfg_attr(
9
+ not(feature = "alloc"),
10
+ doc = " pre-order walk of the `Node` definition, with the root at 0."
11
+ )]
5
12
  ///
6
13
  /// Children are numbered in declaration order: for `IfThenElse` and
7
14
  /// `WhileDoElse` that is condition, then the branch it selects on success,
@@ -29,7 +29,10 @@ pub enum Step<L> {
29
29
  /// Fails immediately.
30
30
  AlwaysFailure,
31
31
  /// Runs until the duration has passed since it started, then succeeds.
32
- /// A zero duration succeeds immediately.
32
+ /// A zero duration succeeds immediately. The deadline is fixed when the
33
+ /// node starts; if the start plus the duration exceeds `Duration::MAX`,
34
+ /// that deadline never fires and the node stays running (the sum is
35
+ /// neither refused nor clamped).
33
36
  Sleep(Duration),
34
37
  /// Ticks this many children in order. Fails as soon as one fails and
35
38
  /// succeeds once all succeed. A running child is resumed on the next
@@ -79,7 +82,10 @@ pub enum Step<L> {
79
82
  /// Fails, halting the child, once the duration has passed since this node
80
83
  /// started. The child only ticks strictly before the deadline, so a zero
81
84
  /// duration fails without ticking it. To run without a limit, leave the
82
- /// decorator out.
85
+ /// decorator out. The deadline is fixed when the node starts; if the
86
+ /// start plus the duration exceeds `Duration::MAX`, it never fires and the
87
+ /// child is never failed for elapsed time (the sum is neither refused nor
88
+ /// clamped).
83
89
  Timeout(Duration),
84
90
  /// Runs the child again each time it succeeds, until it has succeeded
85
91
  /// `limit` times, then succeeds. Fails as soon as the child fails.
@@ -42,7 +42,14 @@ pub struct Tree<L, const N: usize> {
42
42
 
43
43
  impl<L, const N: usize> Tree<L, N> {
44
44
  /// Compiles a definition given as [`Step`]s in pre-order (a
45
- /// [`Node`](crate::Node) with feature `alloc` is such a sequence).
45
+ #[cfg_attr(
46
+ feature = "alloc",
47
+ doc = " [`Node`](crate::Node) with feature `alloc` is such a sequence)."
48
+ )]
49
+ #[cfg_attr(
50
+ not(feature = "alloc"),
51
+ doc = " `Node` with feature `alloc` is such a sequence)."
52
+ )]
46
53
  ///
47
54
  /// # Errors
48
55
  ///
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "behavior_machines_native"
3
- version = "0.1.5"
3
+ version = "0.1.6"
4
4
  edition.workspace = true
5
5
  rust-version.workspace = true
6
6
  license.workspace = true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BehaviorMachines
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: behavior_machines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih