brute 6.0.0 → 6.0.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: fec1b76713fc59a69f9f826eec8ed9cdaa79a7c5cebbb82087ce00f15dccb138
4
- data.tar.gz: 54f48b286b30e133c59bfebdbf4689f57d09b84d7c3eaf3512ddb17dbcfa81c4
3
+ metadata.gz: 4197c46dd001a197da4f187e2729c21dc462355def0d458deb3a6341196fec67
4
+ data.tar.gz: 27453e69fbeff9fa2958502ea366843466c9347335127f593b76f2cd60ea1629
5
5
  SHA512:
6
- metadata.gz: bff875db4f34842415b8e31e50d9fabffa92867d278549a44e36e85bc00f31ad6b23543a780b85158f702e3b35a2130403a2a391f655b7bfcfaef0ccee85809d
7
- data.tar.gz: 105b8f5e04fd82ac2af37451cfccd5f086b3da1bb35681f7ab36fd0620e12d2cd391ce372381c7633aa133b2f7fd51f58355c2afa576339ec09845c475979795
6
+ metadata.gz: bcb85717124bd3b7f4272eb7809a51d240adbcb1ad27aff3e5b67de53b4b1088ba14d7becdeb658b349f350f5247c82119c6e024799ab36ffc38f7fd74630ddf
7
+ data.tar.gz: 46dbd653dbde8e6edea254440b6b793d99766567402164181e7c4b9b780ed28aa85602a6ae8033febedb5858a75659278b69878782beab0a10d30ee9d8ec7668
@@ -60,7 +60,7 @@ module Brute
60
60
  if @env[:messages].nil?
61
61
  ""
62
62
  else
63
- @env.extend(Brute::Env).reply&.content.to_s
63
+ @env.reply&.content.to_s
64
64
  end
65
65
  end
66
66
 
data/lib/brute/hooks.rb CHANGED
@@ -46,7 +46,10 @@ module Brute
46
46
  TOOL_FAILURE_EVENT = :tool_failure
47
47
 
48
48
  # The env, wrapped, for as long as one call lasts. Everything emitted
49
- # through it carries that call's id, and a call opened inside another
49
+ # through it carries the trace itself as its last argument -- so a
50
+ # subscriber that wants the call's identity asks it for an id, and one
51
+ # that wants anything else about the call has it -- and a call opened
52
+ # inside another
50
53
  # delegates to it -- so the wrapper is the parent and unwrapping ends the
51
54
  # call. It is still the env: SimpleDelegator forwards the rest.
52
55
  class Trace < SimpleDelegator
@@ -64,11 +67,17 @@ module Brute
64
67
 
65
68
  def current_trace = self
66
69
 
70
+ # The trace this one was opened inside, if any: emit_trace wraps, so the
71
+ # thing wrapped is the call that was already running.
72
+ def parent
73
+ __getobj__ if __getobj__.is_a?(Trace)
74
+ end
75
+
67
76
  def emit(event, *extras, &work) = @hooks.emit(
68
77
  event,
69
78
  self,
70
79
  *extras,
71
- @id,
80
+ self,
72
81
  &work
73
82
  )
74
83
 
@@ -58,7 +58,7 @@ module Brute
58
58
  metadata: {},
59
59
  current_iteration: 1,
60
60
  commands: @commands || [],
61
- }.tap do |turn|
61
+ }.extend(Brute::Env).tap do |turn|
62
62
  Brute::Hooks::Trace.new(turn, hooks: hooks).emit_trace do |env|
63
63
  env.emit(TURN_START_EVENT)
64
64
  begin
@@ -180,15 +180,21 @@ describe "brute/turn/pipeline" do
180
180
  end
181
181
 
182
182
  pipeline = Brute::Turn::Pipeline.new
183
- pipeline.on(:ping) { |env, extra, id| seen << [env[:said], extra, id] }
183
+ pipeline.on(:ping) { |env, extra, trace| seen << [env, extra, trace] }
184
184
  pipeline.use quiet
185
185
  pipeline.run Object.new.tap { |o| o.define_singleton_method(:call) { |env| env } }
186
186
  pipeline.call({ said: "hello" })
187
187
 
188
- said, extra, id = seen.first
189
- said.should == "hello"
188
+ env, extra, trace = seen.first
189
+ env[:said].should == "hello"
190
190
  extra.should == :from_layer
191
- id.should.not.be.nil
191
+
192
+ # The trace itself comes last, not just its id: a subscriber that wants
193
+ # the call's identity asks it for one, and everything else about the call
194
+ # is on the same object -- which is the env it was handed first.
195
+ trace.id.should.not.be.nil
196
+ trace.__getobj__.should == { said: "hello" }
197
+ trace.__id__.should == env.__id__
192
198
 
193
199
  # A lambda is a layer like any other now: it is handed the trace as its env.
194
200
  answered = []
data/lib/brute/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Brute
4
- VERSION = "6.0.0"
4
+ VERSION = "6.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brute
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brute Contributors