Class: Legion::Extensions::Llm::Fleet::FleetEnvelope
- Inherits:
-
Struct
- Object
- Struct
- Legion::Extensions::Llm::Fleet::FleetEnvelope
- 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
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
-
.wrap(payload) ⇒ Object
Wrap a wire payload (Hash) or pass an existing envelope through.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #correlation_id ⇒ Object
- #execution_contract ⇒ Object
- #fetch(key, default = nil) ⇒ Object
- #idempotency_key ⇒ Object
- #key?(key) ⇒ Boolean
- #message_context ⇒ Object
- #model ⇒ Object
- #offering_id ⇒ Object
- #operation ⇒ Object
- #params ⇒ Object
- #protocol_version ⇒ Object
- #provider ⇒ Object
- #provider_instance ⇒ Object
- #reply_to ⇒ Object
- #request_id ⇒ Object
- #signed_token ⇒ Object
- #to_h ⇒ Object
- #trace_context ⇒ Object
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute 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).
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_id ⇒ Object
49 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 49 def correlation_id = self[:correlation_id] |
#execution_contract ⇒ Object
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_key ⇒ Object
50 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 50 def idempotency_key = self[:idempotency_key] |
#key?(key) ⇒ 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_context ⇒ Object
57 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 57 def = self[:message_context] || {} |
#model ⇒ Object
54 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 54 def model = self[:model] |
#offering_id ⇒ Object
60 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 60 def offering_id = self[:offering_id] |
#operation ⇒ Object
51 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 51 def operation = self[:operation] |
#params ⇒ Object
55 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 55 def params = self[:params] || {} |
#protocol_version ⇒ Object
47 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 47 def protocol_version = self[:protocol_version] |
#provider ⇒ Object
52 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 52 def provider = self[:provider] |
#provider_instance ⇒ Object
53 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 53 def provider_instance = self[:provider_instance] |
#reply_to ⇒ Object
56 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 56 def reply_to = self[:reply_to] |
#request_id ⇒ Object
48 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 48 def request_id = self[:request_id] |
#signed_token ⇒ Object
61 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 61 def signed_token = self[:signed_token] |
#to_h ⇒ Object
43 44 45 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 43 def to_h Utils.deep_symbolize_keys(data) end |
#trace_context ⇒ Object
58 |
# File 'lib/legion/extensions/llm/fleet/fleet_envelope.rb', line 58 def trace_context = self[:trace_context] || {} |