lex-agentic-social 0.1.13 → 0.1.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f68ab7b55f1227a283fd1d658a83972249adf14c16c830f05484b7e7c4dbdd5
4
- data.tar.gz: e4c8b7b5d490ced1d15657a28a695a51ec2282f9dd3b3a6777502e4728ce3a33
3
+ metadata.gz: 785afcf396e852ec5c417d3ddd68f04dc62bb290f5687a9115156f98cf5f59d2
4
+ data.tar.gz: f6ee2703b49a5e2dcc331596f703dee60a8ddd8ea601425439e26cc4b2e00706
5
5
  SHA512:
6
- metadata.gz: 8a905ea7a1dd03b5bf61f3fece78f6add34b32830f843914857d115a9a44e708a01944e94a7310a2339c2ae674449f8cc11671823a3b06352c135a08ca4f8349
7
- data.tar.gz: 1a7f7af65cbba67a13d23f9aec91403f82081df517d3283fc2ad91827e8cdbdf73d2139f83333a881c3db3c27d1a8a6d9a8ffb7dcd95c1a970d26cbfd4de130b
6
+ metadata.gz: 687b70c4adafc0718c5634a83ad86353bc02f3b42782eae1d62b637081a4b69f9e4554942f8e9b2f09b28d78d6f4571a09d422259e160c69056bdd091f06d5bd
7
+ data.tar.gz: c6236731a1a0fae572ed1a36af0b7e7f8e842a95b64b1eac16331a2a366782d99a7313f82a7faa0f9f67b30668f25242a7a4ffd7573ede3105c6de1474b069e3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.14] - 2026-04-22
4
+ ### Added
5
+ - `Governance#review_transition` method — API expected by lex-extinction for containment governance gate
6
+ - Mirror::Actor::ResonanceDecay (120s) for `decay_resonances`
7
+ ### Fixed
8
+ - `Governance#validate_action` now logs the action parameter instead of ignoring it
9
+ - Documented Mirror vs MirrorSystem state isolation and ObservedBehavior class distinctions
10
+
3
11
  ## [0.1.13] - 2026-04-15
4
12
  ### Changed
5
13
  - Set `mcp_tools?`, `mcp_tools_deferred?`, and `transport_required?` to `false` — internal cognitive pipeline extension
data/README.md CHANGED
@@ -1,45 +1,52 @@
1
1
  # lex-agentic-social
2
2
 
3
- Domain consolidation gem for social cognition, governance, and multi-agent interaction. Bundles 17 source extensions into one loadable unit under `Legion::Extensions::Agentic::Social`.
3
+ Domain consolidation gem for social cognition, governance, and multi-agent interaction. Bundles 17 sub-modules into one loadable unit under `Legion::Extensions::Agentic::Social`.
4
4
 
5
5
  ## Overview
6
6
 
7
7
  **Gem**: `lex-agentic-social`
8
- **Version**: 0.1.13
8
+ **Version**: 0.1.14
9
9
  **Namespace**: `Legion::Extensions::Agentic::Social`
10
10
 
11
11
  ## Sub-Modules
12
12
 
13
- | Sub-Module | Source Gem | Purpose |
14
- |---|---|---|
15
- | `Social::Social` | `lex-social` | Group membership, multi-dimensional reputation, reciprocity, norm violations |
16
- | `Social::TheoryOfMind` | `lex-theory-of-mind` | BDI model — belief/desire/intention tracking, false-belief detection |
17
- | `Social::Mentalizing` | `lex-mentalizing` | Mentalizing network — tracking of mentalizing capacity |
18
- | `Social::SocialLearning` | `lex-social-learning` | Learning by observation — vicarious reinforcement |
19
- | `Social::PerspectiveShifting` | `lex-perspective-shifting` | Deliberate perspective adoption |
20
- | `Social::Trust` | `lex-trust` | Domain-scoped trust scores — asymmetric reinforcement and decay |
21
- | `Social::Conflict` | `lex-conflict` | Conflict registration, severity-based posture, optional LLM resolution |
22
- | `Social::Conscience` | `lex-conscience` | Internalized moral compass — guilt/pride signal generation |
23
- | `Social::Consent` | `lex-consent` | Four-tier consent gradient with earned autonomy, HITL gate |
24
- | `Social::MoralReasoning` | `lex-moral-reasoning` | Six Haidt foundations, six Kohlberg stages, six ethical frameworks |
25
- | `Social::Governance` | `lex-governance` | Four-layer governance — council proposals, quorum voting, action validation |
26
- | `Social::JointAttention` | `lex-joint-attention` | Shared attention between agents — coordinating focus |
27
- | `Social::Mirror` | `lex-mirror` | Mirror neuron analog — action observation and imitation |
28
- | `Social::MirrorSystem` | `lex-mirror` | Extended mirror system |
29
- | `Social::Entrainment` | `lex-cognitive-entrainment` | Rhythmic synchronization between agents |
30
- | `Social::Symbiosis` | `lex-cognitive-symbiosis` | Mutually beneficial cognitive partnerships |
31
- | `Social::Apprenticeship` | `lex-cognitive-apprenticeship` | Expert-novice learning relationships |
13
+ | Sub-Module | Purpose |
14
+ |---|---|
15
+ | `Social::Social` | Group membership, multi-dimensional reputation, reciprocity, norm violations |
16
+ | `Social::TheoryOfMind` | BDI model — belief/desire/intention tracking, false-belief detection |
17
+ | `Social::Mentalizing` | Mentalizing network — tracking of mentalizing capacity |
18
+ | `Social::SocialLearning` | Learning by observation — vicarious reinforcement |
19
+ | `Social::PerspectiveShifting` | Deliberate perspective adoption |
20
+ | `Social::Trust` | Domain-scoped trust scores — asymmetric reinforcement and decay |
21
+ | `Social::Conflict` | Conflict registration, severity-based posture, optional LLM resolution |
22
+ | `Social::Conscience` | Internalized moral compass — guilt/pride signal generation |
23
+ | `Social::Consent` | Four-tier consent gradient with earned autonomy, HITL gate |
24
+ | `Social::MoralReasoning` | Six Haidt foundations, six Kohlberg stages, six ethical frameworks |
25
+ | `Social::Governance` | Four-layer governance — council proposals, quorum voting, action validation |
26
+ | `Social::JointAttention` | Shared attention between agents — coordinating focus |
27
+ | `Social::Mirror` | Mirror neuron analog — action observation, simulation, and resonance decay |
28
+ | `Social::MirrorSystem` | Extended mirror system with resonance-based familiarity tracking |
29
+ | `Social::Entrainment` | Rhythmic synchronization between agents |
30
+ | `Social::Symbiosis` | Mutually beneficial cognitive partnerships |
31
+ | `Social::Apprenticeship` | Expert-novice learning relationships |
32
32
 
33
33
  ## Actors
34
34
 
35
- - `Social::Conflict::Actors::StaleCheck` runs every 3600s, checks for stale conflicts
36
- - `Social::Consent::Actors::TierEvaluation` — runs every 3600s, evaluates and applies consent tiers
35
+ 9 actors handle autonomous background processing:
36
+
37
+ - `Social::Conflict::Actors::StaleCheck` — every 3600s, checks for stale conflicts
38
+ - `Social::Consent::Actors::TierEvaluation` — every 3600s, evaluates and applies consent tiers
37
39
  - `Social::Governance::Actors::ShadowAiScan` — interval actor, scans for shadow AI activity
38
- - `Social::Governance::Actors::VoteTimeout` — runs every 300s, times out expired proposals
40
+ - `Social::Governance::Actors::VoteTimeout` — every 300s, times out expired proposals
39
41
  - `Social::JointAttention::Actors::Decay` — interval actor, decays joint attention focus
40
42
  - `Social::Mentalizing::Actors::Decay` — interval actor, decays mentalizing model confidence
43
+ - `Social::Mirror::Actor::ResonanceDecay` — every 120s, decays resonance on observed actions
41
44
  - `Social::MirrorSystem::Actors::Decay` — interval actor, decays mirror system activation
42
- - `Social::Trust::Actors::Decay` — runs every 300s, decays all trust scores
45
+ - `Social::Trust::Actors::Decay` — every 300s, decays all trust scores
46
+
47
+ ## Safety Notes
48
+
49
+ `Social::Consent` governs whether actions require human approval — the HITL gate must not be bypassed. `Social::Governance` provides the council approval mechanism used by `Defense::Extinction` for containment escalation.
43
50
 
44
51
  ## Installation
45
52
 
@@ -51,8 +58,8 @@ gem 'lex-agentic-social'
51
58
 
52
59
  ```bash
53
60
  bundle install
54
- bundle exec rspec # 1673 examples, 0 failures
55
- bundle exec rubocop # 0 offenses
61
+ bundle exec rspec
62
+ bundle exec rubocop
56
63
  ```
57
64
 
58
65
  ## License
@@ -8,6 +8,11 @@ module Legion
8
8
  module Social
9
9
  module Governance
10
10
  module Helpers
11
+ # NOTE: Proposal state is stored in-memory only (@proposals hash).
12
+ # This is a safety-critical system (controls consent and containment approval).
13
+ # Persistence to a durable store (e.g. legion-data) is required so that
14
+ # proposals survive process restarts. Implementing persistence is tracked
15
+ # as a separate task.
11
16
  class Proposal
12
17
  attr_reader :proposals
13
18
 
@@ -56,9 +56,15 @@ module Legion
56
56
  { checked: open.size, timed_out: timed.size, timed_out_ids: timed_ids }
57
57
  end
58
58
 
59
- def validate_action(layer:, action: nil, _context: {}, **) # rubocop:disable Lint/UnusedMethodArgument
59
+ def review_transition(action:, authority: nil, context: {}, **)
60
+ log.info "[governance] review_transition: action=#{action} authority=#{authority}"
61
+ validate_action(layer: :agent_validation, action: action, _context: context)
62
+ end
63
+
64
+ def validate_action(layer:, action: nil, _context: {}, **)
60
65
  return { error: :invalid_layer } unless Helpers::Layers.valid_layer?(layer)
61
66
 
67
+ log.info "[governance] validating action=#{action} layer=#{layer}"
62
68
  result = case layer
63
69
  when :agent_validation
64
70
  { allowed: true, layer: layer, reason: :self_validated }
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'legion/extensions/actors/every'
4
+
5
+ module Legion
6
+ module Extensions
7
+ module Agentic
8
+ module Social
9
+ module Mirror
10
+ module Actor
11
+ class ResonanceDecay < Legion::Extensions::Actors::Every
12
+ def runner_class
13
+ Legion::Extensions::Agentic::Social::Mirror::Client
14
+ end
15
+
16
+ def runner_function
17
+ 'decay_resonances'
18
+ end
19
+
20
+ def time
21
+ 120
22
+ end
23
+
24
+ def run_now?
25
+ false
26
+ end
27
+
28
+ def use_runner?
29
+ false
30
+ end
31
+
32
+ def check_subtask?
33
+ false
34
+ end
35
+
36
+ def generate_task?
37
+ false
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -40,6 +40,11 @@ module Legion
40
40
 
41
41
  private
42
42
 
43
+ # mirror_engine is provided by Mirror::Client, which initializes
44
+ # @mirror_engine once in its constructor and exposes it via attr_reader.
45
+ # All three runner modules (Observe, Simulate, Resonance) share that
46
+ # single engine instance through the Client, ensuring observations in
47
+ # Observe are visible to Resonance and Simulate.
43
48
  def mirror_engine
44
49
  @mirror_engine ||= Helpers::MirrorEngine.new
45
50
  end
@@ -67,6 +67,10 @@ module Legion
67
67
 
68
68
  private
69
69
 
70
+ # mirror_engine is provided by Mirror::Client, which initializes
71
+ # @mirror_engine once in its constructor and exposes it via attr_reader.
72
+ # All three runner modules (Observe, Simulate, Resonance) share that
73
+ # single engine instance through the Client, ensuring state is not isolated.
70
74
  def mirror_engine
71
75
  @mirror_engine ||= Helpers::MirrorEngine.new
72
76
  end
@@ -51,6 +51,10 @@ module Legion
51
51
 
52
52
  private
53
53
 
54
+ # mirror_engine is provided by Mirror::Client, which initializes
55
+ # @mirror_engine once in its constructor and exposes it via attr_reader.
56
+ # All three runner modules (Observe, Simulate, Resonance) share that
57
+ # single engine instance through the Client, ensuring state is not isolated.
54
58
  def mirror_engine
55
59
  @mirror_engine ||= Helpers::MirrorEngine.new
56
60
  end
@@ -8,6 +8,7 @@ require 'legion/extensions/agentic/social/mirror/helpers/mirror_engine'
8
8
  require 'legion/extensions/agentic/social/mirror/runners/observe'
9
9
  require 'legion/extensions/agentic/social/mirror/runners/simulate'
10
10
  require 'legion/extensions/agentic/social/mirror/runners/resonance'
11
+ require 'legion/extensions/agentic/social/mirror/actors/resonance_decay'
11
12
  require 'legion/extensions/agentic/social/mirror/client'
12
13
 
13
14
  module Legion
@@ -1,5 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # MirrorSystem::Helpers::ObservedBehavior models an ongoing observation of a
4
+ # specific agent's behavior pattern, keyed by (agent_id, action, domain). It
5
+ # tracks resonance (familiarity strength) that increases with repeated
6
+ # observations (observe_again) or explicit simulation boosts (boost_familiarity)
7
+ # and decays over time. Fidelity of imitation is tracked via observation_count.
8
+ #
9
+ # Distinct from SocialLearning::Helpers::ObservedBehavior, which is a one-shot
10
+ # snapshot of a behavior modeled from another agent, with retention (recall)
11
+ # mechanics and a reproduction flag. The SocialLearning variant focuses on
12
+ # whether the observer can reproduce what it saw; the MirrorSystem variant
13
+ # focuses on resonance-based familiarity and imitation fidelity over time.
14
+
3
15
  module Legion
4
16
  module Extensions
5
17
  module Agentic
@@ -1,5 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # SocialLearning::Helpers::ObservedBehavior models a behavior that one agent
4
+ # observed from a *model agent* (social learning / imitation theory). It tracks
5
+ # retention and reproduction: whether the observer can still recall and replicate
6
+ # what it saw. Retention decays over time via decay_retention!.
7
+ #
8
+ # Distinct from MirrorSystem::Helpers::ObservedBehavior, which models an
9
+ # ongoing observation stream for a specific agent keyed by (action, domain) with
10
+ # resonance-based familiarity boosting and fidelity tracking. The MirrorSystem
11
+ # variant supports repeated observations of the same behavior; the SocialLearning
12
+ # variant is a one-shot snapshot of a modeled behavior with retention mechanics.
13
+
3
14
  require 'securerandom'
4
15
 
5
16
  module Legion
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Agentic
6
6
  module Social
7
- VERSION = '0.1.13'
7
+ VERSION = '0.1.14'
8
8
  end
9
9
  end
10
10
  end
@@ -40,6 +40,18 @@ RSpec.describe Legion::Extensions::Agentic::Social::Governance::Runners::Governa
40
40
  end
41
41
  end
42
42
 
43
+ describe '#review_transition' do
44
+ it 'delegates to validate_action and returns allowed: true' do
45
+ result = client.review_transition(action: 'terminate', authority: 'admin')
46
+ expect(result[:allowed]).to be true
47
+ end
48
+
49
+ it 'accepts context keyword argument' do
50
+ result = client.review_transition(action: 'pause', context: { reason: 'maintenance' })
51
+ expect(result).to have_key(:allowed)
52
+ end
53
+ end
54
+
43
55
  describe '#validate_action' do
44
56
  it 'allows agent_validation' do
45
57
  result = client.validate_action(layer: :agent_validation, action: 'test')
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Stub the framework actor base class since legionio gem is not available in test
4
+ unless defined?(Legion::Extensions::Actors::Every)
5
+ module Legion
6
+ module Extensions
7
+ module Actors
8
+ class Every # rubocop:disable Lint/EmptyClass
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ # Intercept the require in the actor file so it doesn't fail
16
+ $LOADED_FEATURES << 'legion/extensions/actors/every' unless $LOADED_FEATURES.include?('legion/extensions/actors/every')
17
+
18
+ require 'legion/extensions/agentic/social/mirror/actors/resonance_decay'
19
+
20
+ RSpec.describe Legion::Extensions::Agentic::Social::Mirror::Actor::ResonanceDecay do
21
+ subject(:actor) { described_class.new }
22
+
23
+ describe '#runner_class' do
24
+ it 'returns Mirror::Client' do
25
+ expect(actor.runner_class).to eq(Legion::Extensions::Agentic::Social::Mirror::Client)
26
+ end
27
+ end
28
+
29
+ describe '#runner_function' do
30
+ it 'returns decay_resonances' do
31
+ expect(actor.runner_function).to eq('decay_resonances')
32
+ end
33
+ end
34
+
35
+ describe '#time' do
36
+ it 'returns 120 seconds' do
37
+ expect(actor.time).to eq(120)
38
+ end
39
+ end
40
+
41
+ describe '#run_now?' do
42
+ it 'returns false' do
43
+ expect(actor.run_now?).to be false
44
+ end
45
+ end
46
+
47
+ describe '#use_runner?' do
48
+ it 'returns false' do
49
+ expect(actor.use_runner?).to be false
50
+ end
51
+ end
52
+
53
+ describe '#check_subtask?' do
54
+ it 'returns false' do
55
+ expect(actor.check_subtask?).to be false
56
+ end
57
+ end
58
+
59
+ describe '#generate_task?' do
60
+ it 'returns false' do
61
+ expect(actor.generate_task?).to be false
62
+ end
63
+ end
64
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-agentic-social
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -251,6 +251,7 @@ files:
251
251
  - lib/legion/extensions/agentic/social/mentalizing/runners/mentalizing.rb
252
252
  - lib/legion/extensions/agentic/social/mentalizing/version.rb
253
253
  - lib/legion/extensions/agentic/social/mirror.rb
254
+ - lib/legion/extensions/agentic/social/mirror/actors/resonance_decay.rb
254
255
  - lib/legion/extensions/agentic/social/mirror/client.rb
255
256
  - lib/legion/extensions/agentic/social/mirror/helpers/constants.rb
256
257
  - lib/legion/extensions/agentic/social/mirror/helpers/mirror_engine.rb
@@ -370,6 +371,7 @@ files:
370
371
  - spec/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution_spec.rb
371
372
  - spec/legion/extensions/agentic/social/mentalizing/helpers/mental_model_spec.rb
372
373
  - spec/legion/extensions/agentic/social/mentalizing/runners/mentalizing_spec.rb
374
+ - spec/legion/extensions/agentic/social/mirror/actors/resonance_decay_spec.rb
373
375
  - spec/legion/extensions/agentic/social/mirror/client_spec.rb
374
376
  - spec/legion/extensions/agentic/social/mirror/helpers/constants_spec.rb
375
377
  - spec/legion/extensions/agentic/social/mirror/helpers/mirror_engine_spec.rb