Module: Legion::Extensions::Coldstart::Helpers::Imprint

Defined in:
lib/legion/extensions/coldstart/helpers/imprint.rb

Constant Summary collapse

LAYERS =

Three learning layers (spec: cold-start-spec.md)

%i[firmware imprint_window continuous_learning].freeze
IMPRINT_ENTROPY_BASELINE =

Interaction-denominated imprint parameters

50
IMPRINT_RAMP_LENGTH =

observations before window begins narrowing

50
IMPRINT_MAX_MULTIPLIER =

additional observations over which multiplier ramps down

3.0
IMPRINT_SAFETY_BOUND =

consolidation rate multiplier at full imprint

30 * 86_400
SELF_PLAY_ITERATIONS =

Self-play bootstrap parameters

100
BOOTSTRAP_TRACE_TYPES =
%i[identity semantic procedural].freeze

Class Method Summary collapse

Class Method Details

.current_layer(started_at:, observation_count:) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/legion/extensions/coldstart/helpers/imprint.rb', line 44

def current_layer(started_at:, observation_count:)
  return :continuous_learning unless started_at

  if observation_count < (IMPRINT_ENTROPY_BASELINE + IMPRINT_RAMP_LENGTH)
    :imprint_window
  else
    :continuous_learning
  end
end

.current_multiplier(started_at:, observation_count:) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/legion/extensions/coldstart/helpers/imprint.rb', line 36

def current_multiplier(started_at:, observation_count:)
  return 1.0 unless started_at
  return IMPRINT_MAX_MULTIPLIER if observation_count < IMPRINT_ENTROPY_BASELINE

  ramp_progress = [(observation_count - IMPRINT_ENTROPY_BASELINE).to_f / IMPRINT_RAMP_LENGTH, 1.0].min
  IMPRINT_MAX_MULTIPLIER - ((IMPRINT_MAX_MULTIPLIER - 1.0) * ramp_progress)
end

.imprint_active?(started_at:, observation_count:) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/legion/extensions/coldstart/helpers/imprint.rb', line 23

def imprint_active?(started_at:, observation_count:)
  return false unless started_at

  observation_count < (IMPRINT_ENTROPY_BASELINE + IMPRINT_RAMP_LENGTH)
end

.imprint_progress(started_at:, observation_count:) ⇒ Object



29
30
31
32
33
34
# File 'lib/legion/extensions/coldstart/helpers/imprint.rb', line 29

def imprint_progress(started_at:, observation_count:)
  return 1.0 unless started_at

  total = IMPRINT_ENTROPY_BASELINE + IMPRINT_RAMP_LENGTH
  [observation_count.to_f / total, 1.0].min
end

.safety_bound_exceeded?(started_at:) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
58
# File 'lib/legion/extensions/coldstart/helpers/imprint.rb', line 54

def safety_bound_exceeded?(started_at:)
  return false unless started_at

  (Time.now.utc - started_at) > IMPRINT_SAFETY_BOUND
end