silo_events (faber_neuroevolution v1.2.4)

View Source

Silo Event Publishing for Liquid Conglomerate.

Part of the Liquid Conglomerate v2 event-driven architecture. This module provides topic definitions and publishing helpers for cross-silo communication.

Event-Driven Architecture

Instead of direct lc_cross_silo:emit() calls (imperative push), silos now publish events to topics. Interested parties subscribe and react.

Topic Hierarchy

silo.SILONAME.signals - Cross-silo signals from a specific silo silo.SILONAME.lifecycle - Silo lifecycle events (activated, deactivated) silo.aggregated.signals - Aggregated view from lc_cross_silo

Summary

Functions

Get all silo names in the Liquid Conglomerate.

Get the lifecycle topic for a silo.

Publish a silo lifecycle event.

Publish recommendations from a silo.

Publish a single signal from a silo.

Publish multiple signals from a silo.

Get the recommendations topic for a silo.

Get the signal topic for a silo.

Subscribe the calling process to signals from all silos.

Subscribe a specific process to signals from all silos.

Subscribe the calling process to recommendations from a specific silo.

Subscribe a specific process to recommendations from a silo.

Subscribe the calling process to signals from a specific silo.

Subscribe a specific process to signals from a silo.

Unsubscribe from a specific silo's recommendations.

Unsubscribe from a specific silo's signals.

Types

lifecycle_event/0

-type lifecycle_event() :: activated | deactivated | config_changed.

signal_name/0

-type signal_name() :: atom().

signal_value/0

-type signal_value() :: number().

silo_name/0

-type silo_name() ::
          task | resource | distribution | temporal | competitive | social | cultural | ecological |
          morphological | developmental | regulatory | economic | communication.

Functions

all_silo_names()

-spec all_silo_names() -> [silo_name()].

Get all silo names in the Liquid Conglomerate.

lifecycle_topic(SiloName)

-spec lifecycle_topic(silo_name()) -> binary().

Get the lifecycle topic for a silo.

Returns: binary "silo.NAME.lifecycle"

publish_lifecycle(SiloName, LifecycleEvent)

-spec publish_lifecycle(silo_name(), lifecycle_event()) -> ok.

Publish a silo lifecycle event.

Used for silo activation, deactivation, and configuration changes.

publish_recommendations(SiloName, Recommendations)

-spec publish_recommendations(silo_name(), map()) -> ok.

Publish recommendations from a silo.

Used for event-driven read models. Silos publish their recommendations whenever they change, and consumers cache the latest values locally. This replaces blocking get_recommendations() calls with cached lookups.

Event format (map with keys): event_type - binary "silo_recommendations" timestamp - millisecond timestamp silo - silo name atom recommendations - map of recommendation data

Silo usage: Call publish_recommendations/2 when recommendations change.

Consumer usage: Subscribe via subscribe_to_recommendations/1, then handle {silo_recommendations, SiloName, Recs} messages in handle_info.

publish_signal(FromSilo, SignalName, Value)

-spec publish_signal(silo_name(), signal_name(), signal_value()) -> ok.

Publish a single signal from a silo.

Event format (map with keys): event_type - binary "silo_signal" timestamp - millisecond timestamp from - source silo name signal - signal name atom value - numeric signal value

publish_signals(FromSilo, Signals)

-spec publish_signals(silo_name(), #{signal_name() => signal_value()}) -> ok.

Publish multiple signals from a silo.

More efficient than multiple single publishes. Event format (map with keys): event_type - binary "silo_signals" timestamp - millisecond timestamp from - source silo name signals - map of signal_name to value

recommendations_topic(SiloName)

-spec recommendations_topic(silo_name()) -> binary().

Get the recommendations topic for a silo.

Returns: binary "silo.NAME.recommendations"

signal_topic(SiloName)

-spec signal_topic(silo_name()) -> binary().

Get the signal topic for a silo.

Returns: binary "silo.NAME.signals"

subscribe_to_all_silos()

-spec subscribe_to_all_silos() -> ok.

Subscribe the calling process to signals from all silos.

subscribe_to_all_silos(Pid)

-spec subscribe_to_all_silos(pid()) -> ok.

Subscribe a specific process to signals from all silos.

subscribe_to_recommendations(SiloName)

-spec subscribe_to_recommendations(silo_name()) -> ok.

Subscribe the calling process to recommendations from a specific silo.

Events are delivered as: {silo_recommendations, SiloName, RecommendationsMap}

subscribe_to_recommendations(SiloName, Pid)

-spec subscribe_to_recommendations(silo_name(), pid()) -> ok.

Subscribe a specific process to recommendations from a silo.

subscribe_to_silo(SiloName)

-spec subscribe_to_silo(silo_name()) -> ok.

Subscribe the calling process to signals from a specific silo.

subscribe_to_silo(SiloName, Pid)

-spec subscribe_to_silo(silo_name(), pid()) -> ok.

Subscribe a specific process to signals from a silo.

unsubscribe_from_recommendations(SiloName)

-spec unsubscribe_from_recommendations(silo_name()) -> ok.

Unsubscribe from a specific silo's recommendations.

unsubscribe_from_silo(SiloName)

-spec unsubscribe_from_silo(silo_name()) -> ok.

Unsubscribe from a specific silo's signals.