Class: Legion::Extensions::Llm::Fleet::FleetEnvelope

Inherits:
Struct
  • Object
show all
Defined in:
lib/legion/extensions/llm/fleet/fleet_envelope.rb

Overview

The ONE fleet wire-normalization entry (10 U5): typed readers over the raw wire Hash. Every fleet boundary (responder, worker, token validator) reads envelopes through these readers. Data is kept RAW (no eager symbolization) so the worker can still detect duplicate String/Symbol param spellings (W5).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



15
16
17
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 15

def data
  @data
end

Class Method Details

.wrap(payload) ⇒ Object

Wrap a wire payload (Hash) or pass an existing envelope through. L12: a non-Hash payload is a typed ContractError at the wrap boundary — the module is total instead of relying on call-site discipline (an untyped NoMethodError at the first reader).

Raises:



20
21
22
23
24
25
26
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 20

def self.wrap(payload)
  return payload if payload.is_a?(FleetEnvelope)

  raise ContractError, "fleet envelope payload expected Hash, got #{payload.class}" unless payload.is_a?(::Hash)

  new(data: payload)
end

Instance Method Details

#[](key) ⇒ Object



28
29
30
31
32
33
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 28

def [](key)
  symbol_key = key.to_sym
  return data[symbol_key] if data.key?(symbol_key)

  data[key.to_s]
end

#correlation_idObject



49
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 49

def correlation_id = self[:correlation_id]

#execution_contractObject



59
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 59

def execution_contract = self[:execution_contract]

#fetch(key, default = nil) ⇒ Object



39
40
41
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 39

def fetch(key, default = nil)
  key?(key) ? self[key] : default
end

#idempotency_keyObject



50
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 50

def idempotency_key = self[:idempotency_key]

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 35

def key?(key)
  data.key?(key.to_sym) || data.key?(key.to_s)
end

#message_contextObject



57
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 57

def message_context = self[:message_context] || {}

#modelObject



54
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 54

def model = self[:model]

#offering_idObject



60
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 60

def offering_id = self[:offering_id]

#operationObject



51
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 51

def operation = self[:operation]

#paramsObject



55
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 55

def params = self[:params] || {}

#protocol_versionObject



47
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 47

def protocol_version = self[:protocol_version]

#providerObject



52
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 52

def provider = self[:provider]

#provider_instanceObject



53
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 53

def provider_instance = self[:provider_instance]

#reply_toObject



56
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 56

def reply_to = self[:reply_to]

#request_idObject



48
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 48

def request_id = self[:request_id]

#signed_tokenObject



61
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 61

def signed_token = self[:signed_token]

#to_hObject



43
44
45
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 43

def to_h
  Utils.deep_symbolize_keys(data)
end

#trace_contextObject



58
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 58

def trace_context = self[:trace_context] || {}