Class: Legion::Extensions::Llm::Anthropic::Actor::DiscoveryRefresh

Inherits:
Actors::Every
  • Object
show all
Includes:
Helpers::Lex, Logging::Helper
Defined in:
lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb

Overview

SSOT v3 periodic discovery actor for Anthropic provider instances. Claims instances, discovers models via GET /v1/models (safe — no inference), probes readiness via GET /v1/models, and publishes complete OfferingDraft snapshots through Inventory::Publisher. Supports coalesced reactive probes after dispatch-triggered instance_unavailable transitions.

Per-instance runtime state (publisher token, ProbeCoordinator, sequence, last offerings) lives in process-local memory behind a mutex — never in Legion::Settings. The only settings writes are the plain-data health display hash and capabilities list written after each registry commit.

Constant Summary collapse

INSTANCE_CAPABILITIES =

Per-instance capabilities advertised in the settings health display, mirroring the legacy discover_instances output.

%i[completion streaming vision tools].freeze
SCALAR_EVIDENCE_FIELDS =
%i[
  context_evidence max_output_evidence embedding_dimensions_evidence
  model_revision_evidence tokenizer_evidence
].freeze

Instance Method Summary collapse

Instance Method Details

#check_subtask?Boolean

Returns:

  • (Boolean)


64
# File 'lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb', line 64

def check_subtask?  = false

#generate_task?Boolean

Returns:

  • (Boolean)


65
# File 'lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb', line 65

def generate_task?  = false

#manualObject



76
77
78
79
80
81
82
83
84
85
# File 'lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb', line 76

def manual
  if @initialized
    tick_refresh
  else
    initial_discovery
    @initialized = true
  end
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'anthropic.actor.discovery_refresh')
end

#run_now?Boolean

Returns:

  • (Boolean)


62
# File 'lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb', line 62

def run_now?        = true

#runner_classObject



60
# File 'lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb', line 60

def runner_class    = self.class

#runner_functionObject



61
# File 'lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb', line 61

def runner_function = 'manual'

#shutdownObject



87
88
89
90
91
# File 'lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb', line 87

def shutdown
  remove_all_instances
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'anthropic.actor.discovery_refresh.shutdown')
end

#timeObject

Registered per-instance discovery cadence (nested under instances.default by provider_settings). Never nil: the live setting is registered with a default, and the registered default is the floor if an operator nulls the live value.



71
72
73
74
# File 'lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb', line 71

def time
  settings.dig(:instances, :default, :discovery_interval) ||
    Legion::Extensions::Llm::Anthropic.default_settings.dig(:instances, :default, :discovery_interval)
end

#use_runner?Boolean

Returns:

  • (Boolean)


63
# File 'lib/legion/extensions/llm/anthropic/actors/discovery_refresh.rb', line 63

def use_runner?     = false