Module: Legion::LLM::Call::CanonicalResponseCompat

Defined in:
lib/legion/llm/call/dispatch.rb

Overview

DEPRECATED(P6): Hash-key compatibility adapters for Canonical types. These exist ONLY to avoid wholesale rewrites in the P4a batch. They are deleted in Phase 6 — do NOT build new code against hash-key access on Canonical::Response, Canonical::ToolCall, or Canonical::Usage. Each access logs a deprecation breadcrumb so P6 can find survivors.

Constant Summary collapse

KEY_MAP =
{ content: :text, result: :text, text: :text }.freeze

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/legion/llm/call/dispatch.rb', line 22

def [](key)
  Legion::Logging.log.debug do
    "[llm][DEPRECATED(P6)] canonical_hash_access key=#{key} caller=#{caller_locations(1, 1)&.first}"
  end
  sym = key.to_sym
  sym = KEY_MAP[sym] || sym
  public_send(sym) if respond_to?(sym)
end

#dig(key, *rest) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/legion/llm/call/dispatch.rb', line 40

def dig(key, *rest)
  Legion::Logging.log.debug do
    "[llm][DEPRECATED(P6)] canonical_dig key=#{key} caller=#{caller_locations(1, 1)&.first}"
  end
  val = self[key]
  return val if rest.empty?
  return nil unless val.respond_to?(:dig)

  val.dig(*rest)
end

#has_key?(key) ⇒ Boolean

rubocop:disable Naming/PredicatePrefix – Hash API compat requires this name

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
# File 'lib/legion/llm/call/dispatch.rb', line 31

def has_key?(key) # rubocop:disable Naming/PredicatePrefix -- Hash API compat requires this name
  Legion::Logging.log.debug do
    "[llm][DEPRECATED(P6)] canonical_has_key? key=#{key} caller=#{caller_locations(1, 1)&.first}"
  end
  sym = key.respond_to?(:to_sym) ? key.to_sym : key.to_s.to_sym
  sym = KEY_MAP[sym] || sym
  respond_to?(sym)
end