Skip to main content

Module pattern_registry

Module pattern_registry 

Source
Expand description

PatternRegistry: runtime resolver from YAML-declared names to consumer-supplied impls of Allora’s pattern traits (CompletionCondition, AggregationStrategy, GroupStore).

§Motivation

The chain’s quorum logic (validator registry lookups, dynamic threshold over a changing validator set, etc.) cannot be expressed in pure YAML — it needs Rust code. The same is true for any non-trivial completion condition, custom aggregation, or alternative storage backend. The crate::spec::AggregatorSpec therefore refers to names — and those names resolve here at build time. Mirrors how processor_registry works downstream (Fialucci chain) for HTTP-route processor lookup.

§Default Registrations

PatternRegistry::with_defaults pre-populates Allora’s three built-in strategies, keyed by allora.<name>:

No default completions or stores are registered — those are inherently consumer-specific (the chain registers chain.validator_quorum, etc.).

§Example

use std::sync::Arc;
use allora_core::Message;
use allora_core::patterns::aggregator::CompletionCondition;
use allora_runtime::dsl::PatternRegistry;

struct MyQuorum;
impl CompletionCondition for MyQuorum {
    fn is_complete(&self, group: &[Message], _: std::time::Instant) -> bool {
        group.len() >= 2
    }
}

let mut registry = PatternRegistry::with_defaults();
registry.register_completion("chain.my_quorum", Arc::new(MyQuorum));
assert!(registry.completion("chain.my_quorum").is_some());
assert!(registry.strategy("allora.emit_signal").is_some());

Structs§

PatternRegistry
Resolver from YAML names → concrete pattern-component impls.

Constants§

STRATEGY_CONCAT_TEXT
Registry name for Allora’s built-in ConcatText strategy.
STRATEGY_EMIT_SIGNAL
Registry name for Allora’s built-in EmitSignal strategy.
STRATEGY_JSON_ARRAY
Registry name for Allora’s built-in JsonArray strategy.