lex-agentic-learning 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +13 -0
- data/lex-agentic-learning.gemspec +30 -0
- data/lib/legion/extensions/agentic/learning/anchoring/client.rb +26 -0
- data/lib/legion/extensions/agentic/learning/anchoring/helpers/anchor.rb +65 -0
- data/lib/legion/extensions/agentic/learning/anchoring/helpers/anchor_store.rb +132 -0
- data/lib/legion/extensions/agentic/learning/anchoring/helpers/constants.rb +31 -0
- data/lib/legion/extensions/agentic/learning/anchoring/runners/anchoring.rb +100 -0
- data/lib/legion/extensions/agentic/learning/anchoring/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/anchoring.rb +19 -0
- data/lib/legion/extensions/agentic/learning/catalyst/client.rb +15 -0
- data/lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb +87 -0
- data/lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst_engine.rb +153 -0
- data/lib/legion/extensions/agentic/learning/catalyst/helpers/constants.rb +55 -0
- data/lib/legion/extensions/agentic/learning/catalyst/helpers/reaction.rb +87 -0
- data/lib/legion/extensions/agentic/learning/catalyst/runners/cognitive_catalyst.rb +103 -0
- data/lib/legion/extensions/agentic/learning/catalyst/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/catalyst.rb +22 -0
- data/lib/legion/extensions/agentic/learning/chrysalis/client.rb +22 -0
- data/lib/legion/extensions/agentic/learning/chrysalis/helpers/chrysalis.rb +137 -0
- data/lib/legion/extensions/agentic/learning/chrysalis/helpers/cocoon.rb +89 -0
- data/lib/legion/extensions/agentic/learning/chrysalis/helpers/constants.rb +49 -0
- data/lib/legion/extensions/agentic/learning/chrysalis/helpers/metamorphosis_engine.rb +157 -0
- data/lib/legion/extensions/agentic/learning/chrysalis/runners/cognitive_chrysalis.rb +129 -0
- data/lib/legion/extensions/agentic/learning/chrysalis/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/chrysalis.rb +21 -0
- data/lib/legion/extensions/agentic/learning/curiosity/client.rb +28 -0
- data/lib/legion/extensions/agentic/learning/curiosity/helpers/constants.rb +30 -0
- data/lib/legion/extensions/agentic/learning/curiosity/helpers/gap_detector.rb +167 -0
- data/lib/legion/extensions/agentic/learning/curiosity/helpers/wonder.rb +73 -0
- data/lib/legion/extensions/agentic/learning/curiosity/helpers/wonder_store.rb +149 -0
- data/lib/legion/extensions/agentic/learning/curiosity/runners/curiosity.rb +163 -0
- data/lib/legion/extensions/agentic/learning/curiosity/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/curiosity.rb +21 -0
- data/lib/legion/extensions/agentic/learning/epistemic_curiosity/client.rb +28 -0
- data/lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/constants.rb +31 -0
- data/lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/curiosity_engine.rb +122 -0
- data/lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb +70 -0
- data/lib/legion/extensions/agentic/learning/epistemic_curiosity/runners/epistemic_curiosity.rb +106 -0
- data/lib/legion/extensions/agentic/learning/epistemic_curiosity/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/epistemic_curiosity.rb +19 -0
- data/lib/legion/extensions/agentic/learning/fermentation/client.rb +19 -0
- data/lib/legion/extensions/agentic/learning/fermentation/helpers/batch.rb +75 -0
- data/lib/legion/extensions/agentic/learning/fermentation/helpers/constants.rb +78 -0
- data/lib/legion/extensions/agentic/learning/fermentation/helpers/fermentation_engine.rb +147 -0
- data/lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb +108 -0
- data/lib/legion/extensions/agentic/learning/fermentation/runners/cognitive_fermentation.rb +60 -0
- data/lib/legion/extensions/agentic/learning/fermentation/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/fermentation.rb +22 -0
- data/lib/legion/extensions/agentic/learning/habit/client.rb +26 -0
- data/lib/legion/extensions/agentic/learning/habit/helpers/action_sequence.rb +120 -0
- data/lib/legion/extensions/agentic/learning/habit/helpers/constants.rb +44 -0
- data/lib/legion/extensions/agentic/learning/habit/helpers/habit_store.rb +148 -0
- data/lib/legion/extensions/agentic/learning/habit/runners/habit.rb +86 -0
- data/lib/legion/extensions/agentic/learning/habit/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/habit.rb +19 -0
- data/lib/legion/extensions/agentic/learning/hebbian/actors/decay.rb +45 -0
- data/lib/legion/extensions/agentic/learning/hebbian/client.rb +29 -0
- data/lib/legion/extensions/agentic/learning/hebbian/helpers/assembly.rb +82 -0
- data/lib/legion/extensions/agentic/learning/hebbian/helpers/assembly_network.rb +190 -0
- data/lib/legion/extensions/agentic/learning/hebbian/helpers/constants.rb +50 -0
- data/lib/legion/extensions/agentic/learning/hebbian/helpers/unit.rb +94 -0
- data/lib/legion/extensions/agentic/learning/hebbian/runners/hebbian_assembly.rb +94 -0
- data/lib/legion/extensions/agentic/learning/hebbian/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/hebbian.rb +20 -0
- data/lib/legion/extensions/agentic/learning/learning_rate/client.rb +25 -0
- data/lib/legion/extensions/agentic/learning/learning_rate/helpers/constants.rb +35 -0
- data/lib/legion/extensions/agentic/learning/learning_rate/helpers/rate_model.rb +133 -0
- data/lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb +85 -0
- data/lib/legion/extensions/agentic/learning/learning_rate/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/learning_rate.rb +18 -0
- data/lib/legion/extensions/agentic/learning/meta_learning/client.rb +27 -0
- data/lib/legion/extensions/agentic/learning/meta_learning/helpers/constants.rb +46 -0
- data/lib/legion/extensions/agentic/learning/meta_learning/helpers/learning_domain.rb +85 -0
- data/lib/legion/extensions/agentic/learning/meta_learning/helpers/meta_learning_engine.rb +202 -0
- data/lib/legion/extensions/agentic/learning/meta_learning/helpers/strategy.rb +62 -0
- data/lib/legion/extensions/agentic/learning/meta_learning/runners/meta_learning.rb +118 -0
- data/lib/legion/extensions/agentic/learning/meta_learning/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/meta_learning.rb +20 -0
- data/lib/legion/extensions/agentic/learning/plasticity/client.rb +15 -0
- data/lib/legion/extensions/agentic/learning/plasticity/helpers/constants.rb +45 -0
- data/lib/legion/extensions/agentic/learning/plasticity/helpers/neural_pathway.rb +85 -0
- data/lib/legion/extensions/agentic/learning/plasticity/helpers/plasticity_engine.rb +130 -0
- data/lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb +85 -0
- data/lib/legion/extensions/agentic/learning/plasticity/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/plasticity.rb +19 -0
- data/lib/legion/extensions/agentic/learning/preference_learning/actors/decay.rb +45 -0
- data/lib/legion/extensions/agentic/learning/preference_learning/client.rb +28 -0
- data/lib/legion/extensions/agentic/learning/preference_learning/helpers/constants.rb +35 -0
- data/lib/legion/extensions/agentic/learning/preference_learning/helpers/option.rb +78 -0
- data/lib/legion/extensions/agentic/learning/preference_learning/helpers/preference_engine.rb +121 -0
- data/lib/legion/extensions/agentic/learning/preference_learning/runners/preference_learning.rb +84 -0
- data/lib/legion/extensions/agentic/learning/preference_learning/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/preference_learning.rb +19 -0
- data/lib/legion/extensions/agentic/learning/procedural/client.rb +19 -0
- data/lib/legion/extensions/agentic/learning/procedural/helpers/constants.rb +46 -0
- data/lib/legion/extensions/agentic/learning/procedural/helpers/learning_engine.rb +160 -0
- data/lib/legion/extensions/agentic/learning/procedural/helpers/production.rb +66 -0
- data/lib/legion/extensions/agentic/learning/procedural/helpers/skill.rb +101 -0
- data/lib/legion/extensions/agentic/learning/procedural/runners/procedural_learning.rb +96 -0
- data/lib/legion/extensions/agentic/learning/procedural/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/procedural.rb +20 -0
- data/lib/legion/extensions/agentic/learning/scaffolding/client.rb +26 -0
- data/lib/legion/extensions/agentic/learning/scaffolding/helpers/constants.rb +42 -0
- data/lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb +136 -0
- data/lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffolding_engine.rb +112 -0
- data/lib/legion/extensions/agentic/learning/scaffolding/runners/cognitive_scaffolding.rb +107 -0
- data/lib/legion/extensions/agentic/learning/scaffolding/version.rb +13 -0
- data/lib/legion/extensions/agentic/learning/scaffolding.rb +19 -0
- data/lib/legion/extensions/agentic/learning/version.rb +11 -0
- data/lib/legion/extensions/agentic/learning.rb +31 -0
- data/spec/legion/extensions/agentic/learning/anchoring/client_spec.rb +32 -0
- data/spec/legion/extensions/agentic/learning/anchoring/helpers/anchor_spec.rb +130 -0
- data/spec/legion/extensions/agentic/learning/anchoring/helpers/anchor_store_spec.rb +201 -0
- data/spec/legion/extensions/agentic/learning/anchoring/helpers/constants_spec.rb +63 -0
- data/spec/legion/extensions/agentic/learning/anchoring/runners/anchoring_spec.rb +199 -0
- data/spec/legion/extensions/agentic/learning/catalyst/client_spec.rb +58 -0
- data/spec/legion/extensions/agentic/learning/catalyst/cognitive_catalyst_spec.rb +49 -0
- data/spec/legion/extensions/agentic/learning/catalyst/helpers/catalyst_engine_spec.rb +263 -0
- data/spec/legion/extensions/agentic/learning/catalyst/helpers/catalyst_spec.rb +214 -0
- data/spec/legion/extensions/agentic/learning/catalyst/helpers/reaction_spec.rb +223 -0
- data/spec/legion/extensions/agentic/learning/catalyst/runners/cognitive_catalyst_spec.rb +217 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/client_spec.rb +83 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/cognitive_chrysalis_spec.rb +15 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/helpers/chrysalis_engine_spec.rb +57 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/helpers/chrysalis_spec.rb +305 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/helpers/cocoon_spec.rb +206 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/helpers/constants_spec.rb +109 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/helpers/metamorphic_cycle_spec.rb +76 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/helpers/metamorphosis_engine_spec.rb +247 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/helpers/transformation_phase_spec.rb +98 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/runners/cognitive_chrysalis_spec.rb +180 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/runners/reporting_spec.rb +81 -0
- data/spec/legion/extensions/agentic/learning/chrysalis/runners/transformation_spec.rb +74 -0
- data/spec/legion/extensions/agentic/learning/curiosity/client_spec.rb +27 -0
- data/spec/legion/extensions/agentic/learning/curiosity/helpers/gap_detector_spec.rb +118 -0
- data/spec/legion/extensions/agentic/learning/curiosity/helpers/wonder_spec.rb +130 -0
- data/spec/legion/extensions/agentic/learning/curiosity/helpers/wonder_store_spec.rb +136 -0
- data/spec/legion/extensions/agentic/learning/curiosity/runners/curiosity_spec.rb +159 -0
- data/spec/legion/extensions/agentic/learning/epistemic_curiosity/client_spec.rb +47 -0
- data/spec/legion/extensions/agentic/learning/epistemic_curiosity/helpers/constants_spec.rb +45 -0
- data/spec/legion/extensions/agentic/learning/epistemic_curiosity/helpers/curiosity_engine_spec.rb +229 -0
- data/spec/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap_spec.rb +188 -0
- data/spec/legion/extensions/agentic/learning/epistemic_curiosity/runners/epistemic_curiosity_spec.rb +175 -0
- data/spec/legion/extensions/agentic/learning/fermentation/client_spec.rb +36 -0
- data/spec/legion/extensions/agentic/learning/fermentation/helpers/batch_spec.rb +72 -0
- data/spec/legion/extensions/agentic/learning/fermentation/helpers/fermentation_engine_spec.rb +138 -0
- data/spec/legion/extensions/agentic/learning/fermentation/helpers/substrate_spec.rb +146 -0
- data/spec/legion/extensions/agentic/learning/habit/client_spec.rb +50 -0
- data/spec/legion/extensions/agentic/learning/habit/helpers/action_sequence_spec.rb +276 -0
- data/spec/legion/extensions/agentic/learning/habit/helpers/constants_spec.rb +115 -0
- data/spec/legion/extensions/agentic/learning/habit/helpers/habit_store_spec.rb +274 -0
- data/spec/legion/extensions/agentic/learning/habit/runners/habit_spec.rb +228 -0
- data/spec/legion/extensions/agentic/learning/hebbian/client_spec.rb +38 -0
- data/spec/legion/extensions/agentic/learning/hebbian/helpers/assembly_network_spec.rb +142 -0
- data/spec/legion/extensions/agentic/learning/hebbian/helpers/assembly_spec.rb +89 -0
- data/spec/legion/extensions/agentic/learning/hebbian/helpers/unit_spec.rb +119 -0
- data/spec/legion/extensions/agentic/learning/hebbian/runners/hebbian_assembly_spec.rb +109 -0
- data/spec/legion/extensions/agentic/learning/learning_rate/client_spec.rb +51 -0
- data/spec/legion/extensions/agentic/learning/learning_rate/helpers/constants_spec.rb +29 -0
- data/spec/legion/extensions/agentic/learning/learning_rate/helpers/rate_model_spec.rb +151 -0
- data/spec/legion/extensions/agentic/learning/learning_rate/runners/learning_rate_spec.rb +92 -0
- data/spec/legion/extensions/agentic/learning/meta_learning/client_spec.rb +27 -0
- data/spec/legion/extensions/agentic/learning/meta_learning/helpers/constants_spec.rb +43 -0
- data/spec/legion/extensions/agentic/learning/meta_learning/helpers/learning_domain_spec.rb +146 -0
- data/spec/legion/extensions/agentic/learning/meta_learning/helpers/meta_learning_engine_spec.rb +309 -0
- data/spec/legion/extensions/agentic/learning/meta_learning/helpers/strategy_spec.rb +82 -0
- data/spec/legion/extensions/agentic/learning/meta_learning/runners/meta_learning_spec.rb +185 -0
- data/spec/legion/extensions/agentic/learning/plasticity/helpers/constants_spec.rb +54 -0
- data/spec/legion/extensions/agentic/learning/plasticity/helpers/neural_pathway_spec.rb +136 -0
- data/spec/legion/extensions/agentic/learning/plasticity/helpers/plasticity_engine_spec.rb +157 -0
- data/spec/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity_spec.rb +83 -0
- data/spec/legion/extensions/agentic/learning/preference_learning/client_spec.rb +17 -0
- data/spec/legion/extensions/agentic/learning/preference_learning/helpers/constants_spec.rb +67 -0
- data/spec/legion/extensions/agentic/learning/preference_learning/helpers/option_spec.rb +104 -0
- data/spec/legion/extensions/agentic/learning/preference_learning/helpers/preference_engine_spec.rb +151 -0
- data/spec/legion/extensions/agentic/learning/preference_learning/runners/preference_learning_spec.rb +86 -0
- data/spec/legion/extensions/agentic/learning/procedural/client_spec.rb +22 -0
- data/spec/legion/extensions/agentic/learning/procedural/helpers/learning_engine_spec.rb +135 -0
- data/spec/legion/extensions/agentic/learning/procedural/helpers/production_spec.rb +66 -0
- data/spec/legion/extensions/agentic/learning/procedural/helpers/skill_spec.rb +102 -0
- data/spec/legion/extensions/agentic/learning/procedural/runners/procedural_learning_spec.rb +94 -0
- data/spec/legion/extensions/agentic/learning/scaffolding/client_spec.rb +20 -0
- data/spec/legion/extensions/agentic/learning/scaffolding/helpers/constants_spec.rb +36 -0
- data/spec/legion/extensions/agentic/learning/scaffolding/helpers/scaffold_spec.rb +187 -0
- data/spec/legion/extensions/agentic/learning/scaffolding/helpers/scaffolding_engine_spec.rb +159 -0
- data/spec/legion/extensions/agentic/learning/scaffolding/runners/cognitive_scaffolding_spec.rb +163 -0
- data/spec/spec_helper.rb +46 -0
- metadata +277 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 14ead87d8b9aba4266580c17d9f8ece03e76d64f15375e8ef3b89f078aa1eb20
|
|
4
|
+
data.tar.gz: b9ca7ce1d976b330e1f66ed9bf8dc00cd2d4cedc7bd1adf45f161b356a5c87f9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ff8f094be6c42376441676ae52450b091b42cfbd44ea39ff15631ce0a17cdc9b8e9a49e62b538c06813bf0712f6da9f902fd38305491384069dd196fee7220f5
|
|
7
|
+
data.tar.gz: 1e1d0819d02c30a65b1c59de7c4822592eb6047b64fda08ccbb60782c836a3a35a444fd4afbccd430ac86346ceb1cd9be47f21ba4f9cfea1aaedbc203eabad02
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-03-18
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Initial release as domain consolidation gem
|
|
9
|
+
- Consolidated source extensions into unified domain gem under `Legion::Extensions::Agentic::<Domain>`
|
|
10
|
+
- All sub-modules loaded from single entry point
|
|
11
|
+
- Full spec suite with zero failures
|
|
12
|
+
- RuboCop compliance across all files
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matthew Iverson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/legion/extensions/agentic/learning/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'lex-agentic-learning'
|
|
7
|
+
spec.version = Legion::Extensions::Agentic::Learning::VERSION
|
|
8
|
+
spec.authors = ['Esity']
|
|
9
|
+
spec.email = ['matthewdiverson@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'LEX Agentic Learning'
|
|
12
|
+
spec.description = 'LEX agentic learning domain: adaptation, memory consolidation, skill acquisition'
|
|
13
|
+
spec.homepage = 'https://github.com/LegionIO/lex-agentic-learning'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = '>= 3.4'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
19
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
21
|
+
|
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
|
23
|
+
Dir.glob('{lib,spec}/**/*.rb') + %w[lex-agentic-learning.gemspec Gemfile LICENSE README.md CHANGELOG.md]
|
|
24
|
+
end
|
|
25
|
+
spec.require_paths = ['lib']
|
|
26
|
+
|
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.13'
|
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 1.60'
|
|
29
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.26'
|
|
30
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/learning/anchoring/helpers/constants'
|
|
4
|
+
require 'legion/extensions/agentic/learning/anchoring/helpers/anchor'
|
|
5
|
+
require 'legion/extensions/agentic/learning/anchoring/helpers/anchor_store'
|
|
6
|
+
require 'legion/extensions/agentic/learning/anchoring/runners/anchoring'
|
|
7
|
+
|
|
8
|
+
module Legion
|
|
9
|
+
module Extensions
|
|
10
|
+
module Agentic
|
|
11
|
+
module Learning
|
|
12
|
+
module Anchoring
|
|
13
|
+
class Client
|
|
14
|
+
include Runners::Anchoring
|
|
15
|
+
|
|
16
|
+
attr_reader :anchor_store
|
|
17
|
+
|
|
18
|
+
def initialize(anchor_store: nil, **)
|
|
19
|
+
@anchor_store = anchor_store || Helpers::AnchorStore.new
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Agentic
|
|
8
|
+
module Learning
|
|
9
|
+
module Anchoring
|
|
10
|
+
module Helpers
|
|
11
|
+
class Anchor
|
|
12
|
+
include Constants
|
|
13
|
+
|
|
14
|
+
attr_reader :id, :value, :domain, :strength, :created_at, :last_accessed
|
|
15
|
+
|
|
16
|
+
def initialize(value:, domain: :general)
|
|
17
|
+
@id = SecureRandom.uuid
|
|
18
|
+
@value = value.to_f
|
|
19
|
+
@domain = domain.to_sym
|
|
20
|
+
@strength = 1.0
|
|
21
|
+
@created_at = Time.now.utc
|
|
22
|
+
@last_accessed = Time.now.utc
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def decay
|
|
26
|
+
@strength = [(@strength - Constants::ANCHOR_DECAY), 0.0].max
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def reinforce(observed_value:)
|
|
30
|
+
@last_accessed = Time.now.utc
|
|
31
|
+
alpha = Constants::ADJUSTMENT_RATE
|
|
32
|
+
@value = ((1.0 - alpha) * @value) + (alpha * observed_value.to_f)
|
|
33
|
+
@strength = [@strength + 0.1, 1.0].min
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def pull(estimate:)
|
|
37
|
+
weight = @strength * Constants::DEFAULT_ANCHOR_WEIGHT
|
|
38
|
+
(weight * @value) + ((1.0 - weight) * estimate.to_f)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def label
|
|
42
|
+
Constants::ANCHOR_LABELS.each do |range, lbl|
|
|
43
|
+
return lbl if range.cover?(@strength)
|
|
44
|
+
end
|
|
45
|
+
:fading
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def to_h
|
|
49
|
+
{
|
|
50
|
+
id: @id,
|
|
51
|
+
value: @value,
|
|
52
|
+
domain: @domain,
|
|
53
|
+
strength: @strength,
|
|
54
|
+
label: label,
|
|
55
|
+
created_at: @created_at,
|
|
56
|
+
last_accessed: @last_accessed
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Learning
|
|
7
|
+
module Anchoring
|
|
8
|
+
module Helpers
|
|
9
|
+
class AnchorStore
|
|
10
|
+
include Constants
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@anchors = {} # domain (Symbol) -> Array<Anchor>
|
|
14
|
+
@references = {} # domain (Symbol) -> Float (explicit reference point)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def add(value:, domain: :general)
|
|
18
|
+
domain = domain.to_sym
|
|
19
|
+
@anchors[domain] ||= []
|
|
20
|
+
|
|
21
|
+
anchor = Anchor.new(value: value, domain: domain)
|
|
22
|
+
@anchors[domain] << anchor
|
|
23
|
+
|
|
24
|
+
if @anchors[domain].size > Constants::MAX_ANCHORS_PER_DOMAIN
|
|
25
|
+
@anchors[domain] = @anchors[domain].sort_by(&:strength).last(Constants::MAX_ANCHORS_PER_DOMAIN)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
prune_domains
|
|
29
|
+
anchor
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def strongest(domain: :general)
|
|
33
|
+
domain = domain.to_sym
|
|
34
|
+
anchors = @anchors[domain]
|
|
35
|
+
return nil if anchors.nil? || anchors.empty?
|
|
36
|
+
|
|
37
|
+
anchors.max_by(&:strength)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def find(id:)
|
|
41
|
+
@anchors.each_value do |arr|
|
|
42
|
+
arr.each { |a| return a if a.id == id }
|
|
43
|
+
end
|
|
44
|
+
nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def evaluate(estimate:, domain: :general)
|
|
48
|
+
domain = domain.to_sym
|
|
49
|
+
anchor = strongest(domain: domain)
|
|
50
|
+
return { anchored_estimate: estimate.to_f, pull_strength: 0.0, anchor_value: nil, correction: 0.0 } if anchor.nil?
|
|
51
|
+
|
|
52
|
+
anchored = anchor.pull(estimate: estimate)
|
|
53
|
+
pull_str = anchor.strength * Constants::DEFAULT_ANCHOR_WEIGHT
|
|
54
|
+
correction = estimate.to_f - anchored
|
|
55
|
+
|
|
56
|
+
anchor.reinforce(observed_value: estimate)
|
|
57
|
+
|
|
58
|
+
{
|
|
59
|
+
anchored_estimate: anchored,
|
|
60
|
+
pull_strength: pull_str,
|
|
61
|
+
anchor_value: anchor.value,
|
|
62
|
+
correction: correction
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def reference_frame(value:, domain: :general)
|
|
67
|
+
domain = domain.to_sym
|
|
68
|
+
reference = @references[domain] || strongest(domain: domain)&.value
|
|
69
|
+
return { perceived_value: value.to_f, gain_or_loss: :neutral, magnitude: 0.0 } if reference.nil?
|
|
70
|
+
|
|
71
|
+
diff = value.to_f - reference
|
|
72
|
+
gain_loss = diff >= 0 ? :gain : :loss
|
|
73
|
+
raw_mag = diff.abs
|
|
74
|
+
magnitude = gain_loss == :loss ? raw_mag * Constants::LOSS_AVERSION_FACTOR : raw_mag
|
|
75
|
+
|
|
76
|
+
{ perceived_value: value.to_f, gain_or_loss: gain_loss, magnitude: magnitude, reference: reference, raw_diff: diff }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def decay_all
|
|
80
|
+
pruned = 0
|
|
81
|
+
@anchors.each_value do |arr|
|
|
82
|
+
arr.each(&:decay)
|
|
83
|
+
before = arr.size
|
|
84
|
+
arr.reject! { |a| a.strength < Constants::ANCHOR_FLOOR }
|
|
85
|
+
pruned += (before - arr.size)
|
|
86
|
+
end
|
|
87
|
+
@anchors.reject! { |_, arr| arr.empty? }
|
|
88
|
+
pruned
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def shift_reference(domain:, new_reference:)
|
|
92
|
+
domain = domain.to_sym
|
|
93
|
+
old = @references[domain]
|
|
94
|
+
@references[domain] = new_reference.to_f
|
|
95
|
+
|
|
96
|
+
diff = (new_reference.to_f - old.to_f).abs
|
|
97
|
+
significant = diff >= Constants::REFERENCE_SHIFT_THRESHOLD
|
|
98
|
+
|
|
99
|
+
{ domain: domain, old_reference: old, new_reference: new_reference.to_f, significant: significant }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def domains
|
|
103
|
+
@anchors.keys.select { |d| @anchors[d]&.any? }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def to_h
|
|
107
|
+
total_anchors = @anchors.values.flatten.size
|
|
108
|
+
domain_count = domains.size
|
|
109
|
+
|
|
110
|
+
{
|
|
111
|
+
total_anchors: total_anchors,
|
|
112
|
+
domain_count: domain_count,
|
|
113
|
+
domains: domains,
|
|
114
|
+
references: @references.dup
|
|
115
|
+
}
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
|
|
120
|
+
def prune_domains
|
|
121
|
+
return unless @anchors.size > Constants::MAX_DOMAINS
|
|
122
|
+
|
|
123
|
+
oldest_domain = @anchors.min_by { |_, arr| arr.map(&:last_accessed).min }&.first
|
|
124
|
+
@anchors.delete(oldest_domain) if oldest_domain
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Learning
|
|
7
|
+
module Anchoring
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
DEFAULT_ANCHOR_WEIGHT = 0.6 # How much the anchor pulls toward itself
|
|
11
|
+
ADJUSTMENT_RATE = 0.1 # EMA alpha for updating anchors
|
|
12
|
+
ANCHOR_DECAY = 0.02 # Per-tick decay of anchor strength
|
|
13
|
+
ANCHOR_FLOOR = 0.05 # Minimum anchor strength before pruning
|
|
14
|
+
MAX_ANCHORS_PER_DOMAIN = 20 # Cap per domain
|
|
15
|
+
MAX_DOMAINS = 50 # Cap total domains
|
|
16
|
+
REFERENCE_SHIFT_THRESHOLD = 0.3 # Gap needed to shift reference point
|
|
17
|
+
LOSS_AVERSION_FACTOR = 2.25 # Losses weighted 2.25x vs gains (prospect theory)
|
|
18
|
+
|
|
19
|
+
ANCHOR_LABELS = {
|
|
20
|
+
(0.8..) => :strong,
|
|
21
|
+
(0.5...0.8) => :moderate,
|
|
22
|
+
(0.2...0.5) => :weak,
|
|
23
|
+
(..0.2) => :fading
|
|
24
|
+
}.freeze
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Learning
|
|
7
|
+
module Anchoring
|
|
8
|
+
module Runners
|
|
9
|
+
module Anchoring
|
|
10
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
11
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
12
|
+
|
|
13
|
+
def record_anchor(value:, domain: :general, **)
|
|
14
|
+
anchor = anchor_store.add(value: value, domain: domain)
|
|
15
|
+
Legion::Logging.debug "[anchoring] record_anchor domain=#{domain} value=#{value} id=#{anchor.id}"
|
|
16
|
+
{ success: true, anchor: anchor.to_h }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def evaluate_estimate(estimate:, domain: :general, **)
|
|
20
|
+
result = anchor_store.evaluate(estimate: estimate, domain: domain)
|
|
21
|
+
Legion::Logging.debug "[anchoring] evaluate_estimate domain=#{domain} estimate=#{estimate} " \
|
|
22
|
+
"anchored=#{result[:anchored_estimate].round(4)} pull=#{result[:pull_strength].round(4)}"
|
|
23
|
+
{ success: true }.merge(result)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def reference_frame(value:, domain: :general, **)
|
|
27
|
+
result = anchor_store.reference_frame(value: value, domain: domain)
|
|
28
|
+
Legion::Logging.debug "[anchoring] reference_frame domain=#{domain} value=#{value} " \
|
|
29
|
+
"gain_or_loss=#{result[:gain_or_loss]}"
|
|
30
|
+
{ success: true }.merge(result)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def de_anchor(estimate:, domain: :general, **)
|
|
34
|
+
anchor = anchor_store.strongest(domain: domain)
|
|
35
|
+
if anchor.nil?
|
|
36
|
+
Legion::Logging.debug "[anchoring] de_anchor domain=#{domain} no anchor found"
|
|
37
|
+
return { success: true, corrected_estimate: estimate.to_f, anchor_bias: 0.0, domain: domain }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
biased = anchor.pull(estimate: estimate)
|
|
41
|
+
bias = biased - estimate.to_f
|
|
42
|
+
corrected = estimate.to_f - bias
|
|
43
|
+
|
|
44
|
+
Legion::Logging.debug "[anchoring] de_anchor domain=#{domain} estimate=#{estimate} " \
|
|
45
|
+
"corrected=#{corrected.round(4)} bias=#{bias.round(4)}"
|
|
46
|
+
|
|
47
|
+
{
|
|
48
|
+
success: true,
|
|
49
|
+
corrected_estimate: corrected,
|
|
50
|
+
original_estimate: estimate.to_f,
|
|
51
|
+
anchor_bias: bias,
|
|
52
|
+
anchor_value: anchor.value,
|
|
53
|
+
domain: domain
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def shift_reference(domain:, new_reference:, **)
|
|
58
|
+
result = anchor_store.shift_reference(domain: domain, new_reference: new_reference)
|
|
59
|
+
Legion::Logging.info "[anchoring] shift_reference domain=#{domain} new=#{new_reference} significant=#{result[:significant]}"
|
|
60
|
+
{ success: true }.merge(result)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def update_anchoring(**)
|
|
64
|
+
pruned = anchor_store.decay_all
|
|
65
|
+
Legion::Logging.debug "[anchoring] update_anchoring pruned=#{pruned}"
|
|
66
|
+
{ success: true, pruned: pruned }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def domain_anchors(domain:, **)
|
|
70
|
+
domain = domain.to_sym
|
|
71
|
+
anchor = anchor_store.strongest(domain: domain)
|
|
72
|
+
all_list = anchor_store.instance_variable_get(:@anchors)[domain] || []
|
|
73
|
+
Legion::Logging.debug "[anchoring] domain_anchors domain=#{domain} count=#{all_list.size}"
|
|
74
|
+
{
|
|
75
|
+
success: true,
|
|
76
|
+
domain: domain,
|
|
77
|
+
count: all_list.size,
|
|
78
|
+
strongest: anchor&.to_h,
|
|
79
|
+
anchors: all_list.map(&:to_h)
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def anchoring_stats(**)
|
|
84
|
+
stats = anchor_store.to_h
|
|
85
|
+
Legion::Logging.debug "[anchoring] stats domains=#{stats[:domain_count]} total=#{stats[:total_anchors]}"
|
|
86
|
+
{ success: true }.merge(stats)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
private
|
|
90
|
+
|
|
91
|
+
def anchor_store
|
|
92
|
+
@anchor_store ||= Helpers::AnchorStore.new
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/learning/anchoring/version'
|
|
4
|
+
require 'legion/extensions/agentic/learning/anchoring/helpers/constants'
|
|
5
|
+
require 'legion/extensions/agentic/learning/anchoring/helpers/anchor'
|
|
6
|
+
require 'legion/extensions/agentic/learning/anchoring/helpers/anchor_store'
|
|
7
|
+
require 'legion/extensions/agentic/learning/anchoring/runners/anchoring'
|
|
8
|
+
require 'legion/extensions/agentic/learning/anchoring/client'
|
|
9
|
+
|
|
10
|
+
module Legion
|
|
11
|
+
module Extensions
|
|
12
|
+
module Agentic
|
|
13
|
+
module Learning
|
|
14
|
+
module Anchoring
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Agentic
|
|
8
|
+
module Learning
|
|
9
|
+
module Catalyst
|
|
10
|
+
module Helpers
|
|
11
|
+
class Catalyst
|
|
12
|
+
include Constants
|
|
13
|
+
|
|
14
|
+
attr_reader :id, :catalyst_type, :domain, :potency, :specificity,
|
|
15
|
+
:uses_count, :created_at
|
|
16
|
+
|
|
17
|
+
def initialize(catalyst_type:, domain:, potency: 0.5, specificity: 0.5)
|
|
18
|
+
@id = SecureRandom.uuid
|
|
19
|
+
@catalyst_type = catalyst_type
|
|
20
|
+
@domain = domain
|
|
21
|
+
@potency = potency.clamp(0.0, 1.0)
|
|
22
|
+
@specificity = specificity.clamp(0.0, 1.0)
|
|
23
|
+
@uses_count = 0
|
|
24
|
+
@created_at = Time.now.utc
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Apply this catalyst to a reaction — increments uses_count but does NOT reduce potency
|
|
28
|
+
# Catalysts are not consumed by use; they are reusable accelerators
|
|
29
|
+
# Returns activation_reduction = potency * specificity
|
|
30
|
+
def catalyze!(_reaction_type)
|
|
31
|
+
@uses_count += 1
|
|
32
|
+
(@potency * @specificity).round(10)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Degrade from environmental wear (not from use)
|
|
36
|
+
def degrade!
|
|
37
|
+
@potency = (@potency - POTENCY_DECAY).clamp(0.0, 1.0).round(10)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Recharge by increasing potency
|
|
41
|
+
def recharge!(amount)
|
|
42
|
+
@potency = (@potency + amount).clamp(0.0, 1.0).round(10)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def powerful?
|
|
46
|
+
@potency >= 0.8
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def inert?
|
|
50
|
+
@potency < 0.2
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def specific?
|
|
54
|
+
@specificity >= 0.7
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def broad?
|
|
58
|
+
@specificity < 0.3
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def potency_label
|
|
62
|
+
POTENCY_LABELS.find { |range, _| range.cover?(@potency) }&.last || :inert
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def to_h
|
|
66
|
+
{
|
|
67
|
+
id: @id,
|
|
68
|
+
catalyst_type: @catalyst_type,
|
|
69
|
+
domain: @domain,
|
|
70
|
+
potency: @potency,
|
|
71
|
+
specificity: @specificity,
|
|
72
|
+
uses_count: @uses_count,
|
|
73
|
+
potency_label: potency_label,
|
|
74
|
+
powerful: powerful?,
|
|
75
|
+
inert: inert?,
|
|
76
|
+
specific: specific?,
|
|
77
|
+
broad: broad?,
|
|
78
|
+
created_at: @created_at
|
|
79
|
+
}
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|