lex-synapse 0.4.0 → 0.4.2

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: c62483ced1238be0da450c077108fa58541aa5964b27f3c6977ad11203202115
4
- data.tar.gz: c8c8a52ff8eb60ebd971a4eeae4ae0a53709629548a58c4409bbdd7c5d3cfebe
3
+ metadata.gz: 0fd3abbde7ec695013ddfe41801f8da65b8513f87fb6bc7e2648238728f5d19a
4
+ data.tar.gz: 67081b1e1ffb5b043f5c5123788d81289b01760a23626e220571fff8799a6c7f
5
5
  SHA512:
6
- metadata.gz: 50c4b74beca7a56c91953d34dd8179cd7f1c42af111ef05be4c9ec62f154135e93fac708c0270ed9c47ee73be987dd8386c5c47b638988982ff454980a4f2e0e
7
- data.tar.gz: 3b6683e9c804a465f47d5fde8471768896ea7c4554e597a8a26c03313fb32e3d30c97cfa9e071726997455a3a5d4ea4392e1d9d94a20ce9ccc03c74de6318a2a
6
+ metadata.gz: 3aa579de0a149d2c9e75725b8b444d387130e39c870d61bc6e6c5740ade2d55867f5642bd1da354d156db74f01f20e6ab8e5284fd565150c5eb227c34277d0e6
7
+ data.tar.gz: ce0f497bc6eb45c32a45ae1be1adb56feac5ac43574ae53ab0fa9b44546e6c336fd8dfe1b99fa330f98f265b920a70eef0d1d564cfb0eb147737779535846801
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.2] - 2026-03-22
4
+
5
+ ### Fixed
6
+ - Add `include Helpers::Lex` to Crystallize, Challenge, Evaluate, Pain, and Propose runners so methods are callable at module level by framework actor auto-dispatch
7
+
8
+ ## [0.4.1] - 2026-03-22
9
+
10
+ ### Fixed
11
+ - Challenge, Propose, and Crystallize actors now include their runner modules and override `runner_class` to return `self.class`, fixing `NoMethodError` at runtime
12
+ - Decay actor converted to self-contained pattern (like Homeostasis) — no `Runners::Decay` module existed
13
+
3
14
  ## [0.4.0] - 2026-03-22
4
15
 
5
16
  ### Added
data/CLAUDE.md CHANGED
@@ -10,7 +10,7 @@ Cognitive routing layer that wraps task chain relationships with observation, le
10
10
 
11
11
  **GitHub**: https://github.com/LegionIO/lex-synapse
12
12
  **License**: MIT
13
- **Version**: 0.3.2
13
+ **Version**: 0.4.0
14
14
 
15
15
  ## Architecture
16
16
 
@@ -22,7 +22,8 @@ Legion::Extensions::Synapse
22
22
  │ ├── Crystallize # Every 300s — emergent synapse detection
23
23
  │ ├── Homeostasis # Every 30s — spike/drought monitoring
24
24
  │ ├── Decay # Every 3600s — idle confidence decay
25
- └── Propose # Every 300s — proactive proposal analysis for AUTONOMOUS synapses
25
+ ├── Propose # Every 300s — proactive proposal analysis for AUTONOMOUS synapses
26
+ │ └── Challenge # Every 60s — adversarial challenge pipeline for pending proposals
26
27
  ├── Runners/
27
28
  │ ├── Evaluate # attention -> transform -> route -> record
28
29
  │ ├── Pain # failure recording, confidence hit, auto-revert
@@ -34,14 +35,16 @@ Legion::Extensions::Synapse
34
35
  │ ├── GaiaReport # GAIA tick hook: report confidence and health per synapse
35
36
  │ ├── Promote # Apollo integration: promote high-confidence synapse patterns to shared knowledge
36
37
  │ ├── Retrieve # Apollo integration: retrieve relevant synapse patterns from shared knowledge
37
- └── Propose # reactive (signal-driven) + proactive (periodic) proposal generation
38
+ ├── Propose # reactive (signal-driven) + proactive (periodic) proposal generation
39
+ │ └── Challenge # conflict detection, LLM challenge, weighted aggregation, outcome resolution
38
40
  ├── Helpers/
39
41
  │ ├── Confidence # scoring, adjustments, autonomy ranges, decay
40
42
  │ ├── Homeostasis # spike/drought detection, baseline tracking
41
- └── RelationshipWrapper # Layer 1 -> Layer 2 wrapping
43
+ ├── RelationshipWrapper # Layer 1 -> Layer 2 wrapping
44
+ │ └── Challenge # settings, constants, impact threshold helpers
42
45
  ├── Data/
43
- │ ├── Migrations/ # 001 synapses, 002 mutations, 003 signals
44
- │ └── Models/ # Synapse, SynapseMutation, SynapseSignal
46
+ │ ├── Migrations/ # 001 synapses, 002 mutations, 003 signals, 004 proposals, 005 challenges
47
+ │ └── Models/ # Synapse, SynapseMutation, SynapseSignal, SynapseProposal, SynapseChallenge
45
48
  ├── Transport/
46
49
  │ ├── Exchanges/Synapse
47
50
  │ ├── Queues/Evaluate, Pain
@@ -80,6 +83,8 @@ Legion::Extensions::Synapse
80
83
  - **synapses**: Core routing definition with confidence, status, version, baseline_throughput
81
84
  - **synapse_mutations**: Versioned change history with before/after JSON snapshots
82
85
  - **synapse_signals**: Per-signal outcome records (attention pass, transform success, latency, downstream outcome)
86
+ - **synapse_proposals**: Proposed changes with status lifecycle, challenge_state, challenge_score, impact_score
87
+ - **synapse_challenges**: Per-challenge verdicts (conflict/LLM), confidence tracking, outcome resolution
83
88
 
84
89
  ## Autonomous Observation Mode (v0.3.0)
85
90
 
@@ -91,6 +96,18 @@ Legion::Extensions::Synapse
91
96
  - **Data**: `synapse_proposals` table with status lifecycle (pending -> approved/rejected/applied/expired)
92
97
  - **Client methods**: `proposals(synapse_id:, status:)`, `review_proposal(proposal_id:, status:)`
93
98
 
99
+ ## Adversarial Challenge Phase (v0.4.0)
100
+
101
+ - **Challenge pipeline**: pending proposals go through conflict detection (mechanical) -> impact scoring -> LLM challenge (gated) -> weighted aggregation -> auto-accept/reject/await-review
102
+ - **Conflict detection**: queries sibling pending proposals on same synapse; conflicting types produce 'challenge' verdict
103
+ - **LLM challenge**: gated by `impact_score >= 0.3`; calls lex-transformer LLM engine; parses SUPPORT/CHALLENGE/ABSTAIN
104
+ - **Aggregation**: `support_weight / (support_weight + challenge_weight)`, abstains excluded; >= 0.85 auto-accepts, <= 0.15 auto-rejects
105
+ - **Challenger confidence**: starting 0.5, correct +0.05, incorrect -0.08, decay *0.998/hr; tracks via outcome resolution after observation window (50 signals post-application)
106
+ - **Settings**: `lex-synapse.challenge.*` — enabled, impact_threshold, auto_accept_threshold, auto_reject_threshold, llm_engine_options, outcome_observation_window, max_per_cycle
107
+ - **Data**: `synapse_challenges` table; `synapse_proposals` gains challenge_state, challenge_score, impact_score columns
108
+ - **Statuses**: `auto_accepted`, `auto_rejected` added to proposal lifecycle
109
+ - **Client methods**: `challenge_proposal(proposal_id:)`, `challenges(proposal_id:)`, `challenger_stats`
110
+
94
111
  ## GAIA / Apollo Integration (v0.2.2)
95
112
 
96
113
  - **GaiaReport runner**: Called during the GAIA tick cycle to report per-synapse confidence and health metrics.
@@ -110,11 +127,11 @@ Legion::Extensions::Synapse
110
127
 
111
128
  ```bash
112
129
  bundle install
113
- bundle exec rspec # 353 specs, 0 failures
130
+ bundle exec rspec # 412 specs, 0 failures
114
131
  bundle exec rubocop # 0 offenses
115
132
  ```
116
133
 
117
- 353 specs, 95%+ coverage. Uses in-memory SQLite for model/runner tests.
134
+ 412 specs, 94%+ coverage. Uses in-memory SQLite for model/runner tests.
118
135
 
119
136
  ---
120
137
 
@@ -1,10 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../runners/challenge'
4
+
3
5
  module Legion
4
6
  module Extensions
5
7
  module Synapse
6
8
  module Actor
7
9
  class Challenge < Legion::Extensions::Actors::Every
10
+ include Legion::Extensions::Synapse::Runners::Challenge
11
+
12
+ def runner_class = self.class
13
+
8
14
  def runner_function
9
15
  'run_challenge_cycle'
10
16
  end
@@ -1,10 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../runners/crystallize'
4
+
3
5
  module Legion
4
6
  module Extensions
5
7
  module Synapse
6
8
  module Actor
7
9
  class Crystallize < Legion::Extensions::Actors::Every
10
+ include Legion::Extensions::Synapse::Runners::Crystallize
11
+
12
+ def runner_class = self.class
13
+
8
14
  def runner_function
9
15
  'crystallize'
10
16
  end
@@ -5,24 +5,27 @@ module Legion
5
5
  module Synapse
6
6
  module Actor
7
7
  class Decay < Legion::Extensions::Actors::Every
8
- def runner_function
9
- 'apply_decay'
10
- end
8
+ def runner_class = self.class
9
+ def time = 3600
10
+ def use_runner? = false
11
+ def check_subtask? = false
12
+ def generate_task? = false
11
13
 
12
- def time
13
- 3600
14
- end
14
+ def action(**_opts)
15
+ return { status: :skipped, reason: :no_data } unless defined?(Legion::Data)
15
16
 
16
- def use_runner?
17
- false
18
- end
17
+ Data::Model.define_synapse_model
18
+ decayed = 0
19
19
 
20
- def check_subtask?
21
- false
22
- end
20
+ Data::Model::Synapse.where(status: 'active').each do |synapse|
21
+ new_conf = Helpers::Confidence.decay(synapse.confidence, hours: 1)
22
+ next if new_conf == synapse.confidence
23
+
24
+ synapse.update(confidence: new_conf)
25
+ decayed += 1
26
+ end
23
27
 
24
- def generate_task?
25
- false
28
+ { decayed: decayed }
26
29
  end
27
30
  end
28
31
  end
@@ -1,10 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../runners/propose'
4
+
3
5
  module Legion
4
6
  module Extensions
5
7
  module Synapse
6
8
  module Actor
7
9
  class Propose < Legion::Extensions::Actors::Every
10
+ include Legion::Extensions::Synapse::Runners::Propose
11
+
12
+ def runner_class = self.class
13
+
8
14
  def runner_function
9
15
  'propose_proactive'
10
16
  end
@@ -242,6 +242,8 @@ module Legion
242
242
 
243
243
  recent.first.challenger_confidence
244
244
  end
245
+
246
+ include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
245
247
  end
246
248
  end
247
249
  end
@@ -39,6 +39,8 @@ module Legion
39
39
  target_function_id: target_id
40
40
  ).any?
41
41
  end
42
+
43
+ include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
42
44
  end
43
45
  end
44
46
  end
@@ -112,6 +112,8 @@ module Legion
112
112
  latency_ms: latency_ms.to_i
113
113
  )
114
114
  end
115
+
116
+ include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
115
117
  end
116
118
  end
117
119
  end
@@ -73,6 +73,8 @@ module Legion
73
73
  baseline_signals = [synapse.baseline_throughput * 5, 5].max
74
74
  recent > (baseline_signals * 2)
75
75
  end
76
+
77
+ include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
76
78
  end
77
79
  end
78
80
  end
@@ -246,6 +246,8 @@ module Legion
246
246
  "There have been #{recent_failures.size} downstream failures despite attention passing. " \
247
247
  'Suggest refined attention rules as a JSON condition object. Return only JSON.'
248
248
  end
249
+
250
+ include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
249
251
  end
250
252
  end
251
253
  end
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Synapse
6
- VERSION = '0.4.0'
6
+ VERSION = '0.4.2'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-synapse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity