Module: Legion::Extensions::Llm::Inventory::Evidence

Defined in:
lib/legion/extensions/llm/inventory/evidence.rb

Overview

Immutable operation, capability, and value evidence with authoritative/unknown semantics. See phase-1-lex-llm-additive.md section 9.

For every evidence record observed_at is nil or a duplicated frozen Time used only for telemetry. It never participates in authority, ordering, freshness, recovery, or selection.

Class Method Summary collapse

Class Method Details

.enforce_unknown_only_source!(status:, source:) ⇒ Object



41
42
43
44
45
46
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 41

def enforce_unknown_only_source!(status:, source:)
  return unless Taxonomies::UNKNOWN_ONLY_EVIDENCE_SOURCES.include?(source)
  return if status == :unknown

  raise Errors::ValidationError, "source #{source} requires status :unknown"
end

.normalize_observed_at(observed_at) ⇒ Object



22
23
24
25
26
27
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 22

def normalize_observed_at(observed_at)
  return nil if observed_at.nil?
  raise Errors::ValidationError, 'observed_at must be a Time' unless observed_at.is_a?(::Time)

  observed_at.dup.freeze
end

.validate_evidence_source(source:) ⇒ Object



35
36
37
38
39
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 35

def validate_evidence_source(source:)
  raise Errors::ValidationError, 'source is not one of Taxonomies::EVIDENCE_SOURCES' unless Taxonomies::EVIDENCE_SOURCES.include?(source)

  source
end

.validate_evidence_status(status:, allowed:) ⇒ Object



29
30
31
32
33
# File 'lib/legion/extensions/llm/inventory/evidence.rb', line 29

def validate_evidence_status(status:, allowed:)
  raise Errors::ValidationError, "status must be one of #{allowed.inspect}" unless allowed.include?(status)

  status
end