Class: Legion::Extensions::Agentic::Integration::PhenomenalBinding::Helpers::Stream

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb

Constant Summary

Constants included from Constants

Constants::BINDING_BOOST, Constants::BINDING_DECAY, Constants::BINDING_TYPES, Constants::COHERENCE_LABELS, Constants::COHERENCE_THRESHOLD, Constants::DEFAULT_SALIENCE, Constants::MAX_BINDINGS, Constants::MAX_STREAMS, Constants::STREAM_TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream_type:, content:, salience: DEFAULT_SALIENCE, domain: nil, timestamp: nil) ⇒ Stream

Returns a new instance of Stream.



16
17
18
19
20
21
22
23
24
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 16

def initialize(stream_type:, content:, salience: DEFAULT_SALIENCE, domain: nil, timestamp: nil)
  @id          = ::SecureRandom.uuid
  @stream_type = stream_type
  @content     = content
  @salience    = salience.clamp(0.0, 1.0)
  @domain      = domain
  @timestamp   = timestamp || Time.now.utc
  @created_at  = Time.now.utc
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



14
15
16
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 14

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



14
15
16
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 14

def created_at
  @created_at
end

#domainObject (readonly)

Returns the value of attribute domain.



14
15
16
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 14

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 14

def id
  @id
end

#salienceObject (readonly)

Returns the value of attribute salience.



14
15
16
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 14

def salience
  @salience
end

#stream_typeObject (readonly)

Returns the value of attribute stream_type.



14
15
16
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 14

def stream_type
  @stream_type
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



14
15
16
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 14

def timestamp
  @timestamp
end

Instance Method Details

#fresh?(window: 30) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 30

def fresh?(window: 30)
  (Time.now.utc - created_at) <= window
end

#salient?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 26

def salient?
  @salience >= DEFAULT_SALIENCE
end

#to_hObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb', line 34

def to_h
  {
    id:          @id,
    stream_type: @stream_type,
    content:     @content,
    salience:    @salience.round(10),
    domain:      @domain,
    timestamp:   @timestamp,
    created_at:  @created_at
  }
end