behavior_machines 0.1.0-x86_64-linux → 0.4.0-x86_64-linux

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: 134e54a8ebd1aefb7d6d84207b6f10529f630b61cb768258f80400fd6fd8dc67
4
- data.tar.gz: 3626e2e61bf9d323f5fed1187a3e7fcf38b5bdbc01754ad9b8dcfca5ba015417
3
+ metadata.gz: 5faf419b0e7eb2cd5b61e93fca27cae2385b97a83b425c75fafe8fb369fb24eb
4
+ data.tar.gz: 467bc7defaa3850905cfd957bd3c40b4ced6bdb4710560501727330b1eac2ab8
5
5
  SHA512:
6
- metadata.gz: 21202c8f5ded592c893d3938440e6582aaced3c13472c66b383df87b547fb898d29e368aec2248244a10dcd594210dd120b1717f242b82770ba3cdf671c771a1
7
- data.tar.gz: 8f2559e78626f2b46e1be63472a06e7afe890f971997880950b8752d12bb66088c224f8e721e0a3247f1cd7d64b0b82191b2a90b3e39c12f5843e032512d74d5
6
+ metadata.gz: 5d2e6cb7f8e7173abd25c7817fab926adb8eac9a532ce5daff9f9774e79a631daca33e26aed531c6996184244665e4262a77b87ecb142ab87e0cae849d9120cc
7
+ data.tar.gz: 247d82661219bf715710aa2cbfd97c5ee328e41203a81b2a771403f7ce4ba555c79a7aedb35650ee609c74c1fbefd52b861b25bf6e16b2250f1397fbf7418823
data/README.md CHANGED
@@ -68,7 +68,8 @@ compiles them.
68
68
  Durations are seconds. The clock is an Integer count of nanoseconds, passed as
69
69
  `now:` and defaulting to `BehaviorMachines.now` (monotonic).
70
70
  `tree.next_deadline` returns when a running `sleep` or `timeout` next needs a
71
- tick, so a host can sleep until then.
71
+ tick, so a host can sleep until then. A looping decorator that finished a run
72
+ reports that tick's time, so its next run is due at once.
72
73
 
73
74
  ## Errors
74
75
 
@@ -121,6 +122,24 @@ $ BEHAVIOR_MACHINES_NATIVE=1 ruby app.rb
121
122
  Leaves stay Ruby, so the gain is limited to the tree walk itself. The test
122
123
  suite runs against both backends (`bundle exec rake test:both`).
123
124
 
125
+ ## Releases
126
+
127
+ Release Please manages the Ruby gem and both publishable Rust crates. Use
128
+ conventional commits and merge its release PR to update versions, changelogs,
129
+ the release manifest, and workspace dependency requirements. Do not push
130
+ hand-written version bumps or changelog entries.
131
+
132
+ The release manifest records the last released version of each package, not
133
+ the next planned version. Circuit is registered at its published `0.1.0`;
134
+ its one-time `release-as` override requests `0.3.0` in the next release PR.
135
+ Remove that override from `release-please-config.json` after the release so
136
+ later versions are calculated from conventional commits.
137
+
138
+ Crate-only releases do not trigger Ruby gem publishing. The workflow creates
139
+ GitHub releases for the crates but does not upload them to crates.io. After
140
+ merging the release PR and checking out its release tag, run the Rust tests
141
+ and a `cargo publish --dry-run` for the relevant crate before publishing.
142
+
124
143
  ## License
125
144
 
126
145
  BSD-3-Clause. See [LICENSE](LICENSE).
@@ -441,7 +441,7 @@ module BehaviorMachines
441
441
  end
442
442
 
443
443
  # Repeat, RetryUntilSuccessful, and KeepRunningUntilFailure: at most one
444
- # finished child run per tick.
444
+ # finished child run per tick; the next run is due at once.
445
445
  class LoopSlot < Slot
446
446
  def initialize(id, child, again_on, limit)
447
447
  super(id)
@@ -449,20 +449,28 @@ module BehaviorMachines
449
449
  @again_on = again_on
450
450
  @limit = limit
451
451
  @runs = 0
452
+ @due = nil
452
453
  end
453
454
 
454
455
  private
455
456
 
456
457
  def step(run, now, _starting)
458
+ @due = nil
457
459
  return @again_on if @limit&.zero?
458
460
 
459
461
  status = @child.tick(run, now)
460
462
  return status if status == :running
461
463
  return finish(status) unless status == @again_on
462
- return :running if @limit.nil?
464
+ return again(now) if @limit.nil?
463
465
  return finish(status) if @runs + 1 == @limit
464
466
 
465
467
  @runs += 1
468
+ again(now)
469
+ end
470
+
471
+ # A run finished and the next waits for a tick: due at once.
472
+ def again(now)
473
+ @due = now
466
474
  :running
467
475
  end
468
476
 
@@ -476,7 +484,7 @@ module BehaviorMachines
476
484
  @runs = 0
477
485
  end
478
486
 
479
- def running_deadline = @child.next_deadline
487
+ def running_deadline = earliest([@due, @child.next_deadline])
480
488
  end
481
489
  end
482
490
  end
@@ -37,6 +37,7 @@ module BehaviorMachines
37
37
  # `ticked(node_id, status)` and `halted(node_id)`; node ids number the
38
38
  # definition in pre-order, and children report before their parent.
39
39
  def tick(ctx = nil, now: BehaviorMachines.now, observer: nil)
40
+ DeadlineMachines.check!
40
41
  now = BehaviorMachines.check_time(now)
41
42
  exclusive { @engine.tick(ctx, now, Observers.wrap(observer)) }
42
43
  end
@@ -53,7 +54,8 @@ module BehaviorMachines
53
54
  @engine.running?
54
55
  end
55
56
 
56
- # The earliest time, in nanoseconds, a running Sleep or Timeout will fire.
57
+ # The earliest time, in nanoseconds, a running Sleep or Timeout will fire,
58
+ # or a looping decorator wants its next run (already due).
57
59
  def next_deadline
58
60
  check_idle
59
61
  @engine.next_deadline
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BehaviorMachines
4
- VERSION = '0.1.0'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -7,6 +7,8 @@ require_relative 'behavior_machines/definition'
7
7
  require_relative 'behavior_machines/engine'
8
8
  require_relative 'behavior_machines/tree'
9
9
  require_relative 'behavior_machines/machine'
10
+ require 'deadline_machines'
11
+
10
12
  require_relative 'behavior_machines/native_extension'
11
13
 
12
14
  # Behavior trees with explicit halt semantics, following the behavior-tree
@@ -15,8 +17,8 @@ module BehaviorMachines
15
17
  STATUSES = %i[success failure running].freeze
16
18
 
17
19
  class << self
18
- # The current monotonic time in nanoseconds.
19
- def now = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
20
+ # The current monotonic time in nanoseconds, from the family's clock.
21
+ def now = DeadlineMachines.clock.now_ns
20
22
 
21
23
  # Whether the native backend is loaded (opt-in, see NativeExtension).
22
24
  def native_available? = NativeExtension.loaded?
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: behavior_machines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Abdelkader Boudih
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-14 00:00:00.000000000 Z
11
+ date: 2026-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: deadline_machines
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: state_machines
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -17,7 +31,7 @@ dependencies:
17
31
  - - ">="
18
32
  - !ruby/object:Gem::Version
19
33
  version: '0.202'
20
- type: :runtime
34
+ type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
@@ -90,13 +104,13 @@ files:
90
104
  - lib/behavior_machines/tree.rb
91
105
  - lib/behavior_machines/version.rb
92
106
  - lib/behavior_machines_native/behavior_machines_native.so
93
- homepage: https://github.com/seuros/behavior-machines
107
+ homepage: https://github.com/seuros/behavior_machines
94
108
  licenses:
95
109
  - BSD-3-Clause
96
110
  metadata:
97
- homepage_uri: https://github.com/seuros/behavior-machines
98
- source_code_uri: https://github.com/seuros/behavior-machines
99
- bug_tracker_uri: https://github.com/seuros/behavior-machines/issues
111
+ homepage_uri: https://github.com/seuros/behavior_machines
112
+ source_code_uri: https://github.com/seuros/behavior_machines
113
+ bug_tracker_uri: https://github.com/seuros/behavior_machines/issues
100
114
  rubygems_mfa_required: 'true'
101
115
  cargo_crate_name: behavior_machines_native
102
116
  cargo_manifest_path: ext/behavior_machines_native/ffi/Cargo.toml