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>:
allora.concat_text→allora_core::patterns::aggregator::ConcatTextallora.json_array→allora_core::patterns::aggregator::JsonArrayallora.emit_signal→allora_core::patterns::aggregator::EmitSignal
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§
- Pattern
Registry - Resolver from YAML names → concrete pattern-component impls.
Constants§
- STRATEGY_
CONCAT_ TEXT - Registry name for Allora’s built-in
ConcatTextstrategy. - STRATEGY_
EMIT_ SIGNAL - Registry name for Allora’s built-in
EmitSignalstrategy. - STRATEGY_
JSON_ ARRAY - Registry name for Allora’s built-in
JsonArraystrategy.