Module: Legion::Extensions::Agentic::Self::Identity::Helpers::Dimensions
- Defined in:
- lib/legion/extensions/agentic/self/identity/helpers/dimensions.rb
Constant Summary collapse
- IDENTITY_DIMENSIONS =
The 6 behavioral dimensions that constitute identity
%i[ communication_cadence vocabulary_patterns emotional_response decision_patterns contextual_consistency temporal_patterns ].freeze
- HIGH_ENTROPY_THRESHOLD =
Entropy thresholds (from tick-loop-spec Phase 4)
0.70- LOW_ENTROPY_THRESHOLD =
0.20- OPTIMAL_ENTROPY_RANGE =
(0.20..0.70)
- OBSERVATION_ALPHA =
EMA alpha for dimension updates
0.1
Class Method Summary collapse
- .clamp(value, min = 0.0, max = 1.0) ⇒ Object
- .classify_entropy(entropy) ⇒ Object
- .compute_entropy(observations, model) ⇒ Object
- .new_identity_model ⇒ Object
Class Method Details
.clamp(value, min = 0.0, max = 1.0) ⇒ Object
66 67 68 |
# File 'lib/legion/extensions/agentic/self/identity/helpers/dimensions.rb', line 66 def clamp(value, min = 0.0, max = 1.0) value.clamp(min, max) end |
.classify_entropy(entropy) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/legion/extensions/agentic/self/identity/helpers/dimensions.rb', line 56 def classify_entropy(entropy) if entropy > HIGH_ENTROPY_THRESHOLD :high_entropy elsif entropy < LOW_ENTROPY_THRESHOLD :low_entropy else :normal end end |
.compute_entropy(observations, model) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/legion/extensions/agentic/self/identity/helpers/dimensions.rb', line 36 def compute_entropy(observations, model) return 0.5 if observations.empty? divergences = IDENTITY_DIMENSIONS.filter_map do |dim| obs = observations[dim] next unless obs baseline = model[dim] next 0.0 unless baseline && baseline[:observations].positive? # Weighted divergence from established baseline (obs - baseline[:mean]).abs / [baseline[:variance].to_f, 0.1].max end return 0.5 if divergences.empty? raw = divergences.sum / divergences.size clamp(raw / 3.0) # normalize: divergence of 3.0 stddevs = entropy 1.0 end |
.new_identity_model ⇒ Object
30 31 32 33 34 |
# File 'lib/legion/extensions/agentic/self/identity/helpers/dimensions.rb', line 30 def new_identity_model IDENTITY_DIMENSIONS.to_h do |dim| [dim, { mean: 0.5, variance: 0.1, observations: 0, last_observed: nil }] end end |