lex-synapse 0.4.12 → 0.4.13

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: 868277c8084e7cd4e50c660e65cf93d3bd3554c183f8c7852bddf7ae28ff91dd
4
- data.tar.gz: c588730afaa91b1842f35eb3e20584445ebb6f62d2e1042831de6942f9b712e7
3
+ metadata.gz: 140dd32d856f6a661d423c72a6f7fcc2424a789342e72d656c25302903d7eda9
4
+ data.tar.gz: 89651542649d74fc871576b608172a4d941cb6b25322a073a54a947458eb369e
5
5
  SHA512:
6
- metadata.gz: 63aa10dd7948c59e7f3f603748a2bfa5bca217aad2dd99d05e898cdf9b102358c21f66b73d4eb258f81fed54b1c90dca23ce6569f942fa9db632fd269c564a8b
7
- data.tar.gz: dc9a028d79dca386c03672a46237d1190c8001ee35c9704630ed9b8f310ba38322983176d02d178ab979b2695699cbd0178addb4f890d5fe03b498bce4c1008b
6
+ metadata.gz: c852c9b3dad49309789b63563244983b075a5d13711efd46d3c83118bd0ec49058d7b7a1a9e4279ea0a9445ec3c3184845701b3389e70676960f3fad7fb74f5a
7
+ data.tar.gz: bd6602b930def1ccac2ef61933c659844f959bd219d06267c696143f04802058eda62ccebaa988a45707424b73fd4c2ccdace4207809dabe173c5e61150e11ad
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.13] - 2026-05-07
4
+ ### Fixed
5
+ - `Homeostasis` actor: replace per-synapse `signals_dataset.count` with a single batched `GROUP BY` query to eliminate N+1 pool contention that caused `Sequel::PoolTimeout` on Postgres
6
+
3
7
  ## [0.4.12] - 2026-05-07
4
8
  ### Fixed
5
9
  - Added challenge proposal application through the mutate runner so auto-accepted proposals can advance to `applied` and later resolve challenger outcomes.
@@ -17,13 +17,24 @@ module Legion
17
17
  results = { spikes: 0, droughts: 0, updated: 0 }
18
18
  return results unless defined?(Legion::Extensions::Synapse::Data::Model::Synapse)
19
19
 
20
- Legion::Extensions::Synapse::Data::Model::Synapse
21
- .where(status: 'active')
22
- .where { baseline_throughput > 0 } # rubocop:disable Style/NumericPredicate
23
- .each do |synapse|
20
+ cutoff = Time.now - 60
21
+
22
+ active_synapses = Legion::Extensions::Synapse::Data::Model::Synapse
23
+ .where(status: 'active')
24
+ .where { baseline_throughput > 0 } # rubocop:disable Style/NumericPredicate
25
+ .all
26
+
27
+ return results if active_synapses.empty?
28
+
29
+ signal_counts = Legion::Extensions::Synapse::Data::Model::SynapseSignal
30
+ .where(synapse_id: active_synapses.map(&:id))
31
+ .where { created_at > cutoff }
32
+ .group_and_count(:synapse_id)
33
+ .as_hash(:synapse_id, :count)
34
+
35
+ active_synapses.each do |synapse|
24
36
  baseline = synapse.baseline_throughput
25
- signals = synapse.signals_dataset.where { created_at > (Time.now - 60) }.count
26
- current = signals.to_f
37
+ current = signal_counts.fetch(synapse.id, 0).to_f
27
38
 
28
39
  if Helpers::Homeostasis.spike?(current, baseline, duration_seconds: 60)
29
40
  results[:spikes] += 1
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Synapse
6
- VERSION = '0.4.12'
6
+ VERSION = '0.4.13'
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.12
4
+ version: 0.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity