Class: Legion::Extensions::Llm::Inventory::ValueEvidence

Inherits:
Data
  • Object
show all
Defined in:
lib/legion/extensions/llm/inventory/evidence.rb

Overview

Evidence carrying a known scalar value (context limit, maximum output, embedding dimensions, tokenizer/estimator, immutable model revision) or an explicit :unknown. Each field uses a separate instance so one known field cannot make another field authoritative.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, source:, value: nil, observed_at: nil, metadata: {}) ⇒ ValueEvidence

Returns a new instance of ValueEvidence.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 105

def initialize(status:, source:, value: nil, observed_at: nil, metadata: {})
  Evidence.validate_evidence_status(status: status, allowed: Taxonomies::VALUE_EVIDENCE_STATES)
  Evidence.validate_evidence_source(source: source)
  Evidence.enforce_unknown_only_source!(status: status, source: source)

  case status
  when :known
    raise Errors::ValidationError, 'known ValueEvidence requires a non-nil value' if value.nil?
  when :unknown
    raise Errors::ValidationError, 'unknown ValueEvidence requires value: nil' unless value.nil?
  end

  copied_value = value.nil? ? nil : ImmutableValue.copy_and_freeze(value: value, field: :value)

  super(
    status: status,
    value: copied_value,
    source: source,
    observed_at: Evidence.normalize_observed_at(observed_at),
    metadata: ImmutableValue.copy_and_freeze(value: , field: :metadata)
  )
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



104
105
106
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 104

def 
  @metadata
end

#observed_atObject (readonly)

Returns the value of attribute observed_at

Returns:

  • (Object)

    the current value of observed_at



104
105
106
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 104

def observed_at
  @observed_at
end

#sourceObject (readonly)

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



104
105
106
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 104

def source
  @source
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



104
105
106
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 104

def status
  @status
end

#valueObject (readonly)

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



104
105
106
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 104

def value
  @value
end

Instance Method Details

#known?Boolean

Returns:

  • (Boolean)


128
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 128

def known? = status == :known

#unknown?Boolean

Returns:

  • (Boolean)


129
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 129

def unknown? = status == :unknown