Elixir library for temporal pattern detection, correlation analysis, and anomaly detection. Designed for use within the Viable System Model (VSM) ecosystem but usable independently.
Version 0.1.0. Not published to Hex. The main module (VsmPatternEngine) still contains the default hello/0 stub, but the subsystem modules under lib/vsm_pattern_engine/ are implemented.
- Temporal detection -- identifies periodic, trend, burst, decay, and cyclic patterns in time-series data using sliding windows.
- Correlation analysis -- computes Pearson, Spearman, Kendall, and mutual information correlations between pattern sets. Includes a basic causal analysis pass.
- Anomaly detection -- statistical (z-score/IQR), isolation forest, and a VSM-specific method that factors in variety ratios and recursion levels.
- Vector store integration -- optional client for persisting and querying patterns against
vsm-vector-store.
| Path | Contents |
|---|---|
lib/vsm_pattern_engine/engine.ex |
Core dispatch: analyze_pattern, detect_anomaly, correlate_patterns |
lib/vsm_pattern_engine/temporal/ |
Detector, analyzer, window, stream processor, pattern struct, cache (7 files) |
lib/vsm_pattern_engine/correlation/ |
Analyzer, matrix, matrix processor, statistics, relationship, cache (7 files) |
lib/vsm_pattern_engine/anomaly/ |
Detector, alert manager, baseline manager (4 files) |
lib/vsm_pattern_engine/vector_store/ |
Client, connection, encoder (3 files) |
lib/vsm_pattern_engine/telemetry.ex |
Telemetry event definitions |
test/ |
1 test file (basic) |
24 .ex files under lib/. 1 test file.
| Category | Packages |
|---|---|
| HTTP | tesla, mint, finch |
| Math/stats | statistics |
| Time | timex |
| Concurrency | flow, gen_stage |
| Telemetry | telemetry, telemetry_metrics, telemetry_poller |
| Serialization | jason |
| Dev | ex_doc, credo, dialyxir |
Requires Elixir >= 1.14.
git clone https://github.com/viable-systems/vsm-pattern-engine.git
cd vsm-pattern-engine
mix deps.get
mix test{:ok, _} = VsmPatternEngine.Application.start(:normal, [])
data = [1.0, 2.1, 3.0, 3.9, 5.1, 6.0, 7.1, 8.0]
{:ok, result} = VsmPatternEngine.Engine.analyze_pattern(data)
baseline = [1.0, 1.1, 0.9, 1.0, 1.2, 0.8, 1.1]
new_data = [1.0, 1.1, 5.0, 1.0]
{:ok, anomaly} = VsmPatternEngine.Engine.detect_anomaly(new_data, baseline)config :vsm_pattern_engine,
vector_store_url: "http://localhost:4000/api",
detection_interval: 5000,
anomaly_threshold: 0.8,
correlation_threshold: 0.7
config :vsm_pattern_engine, :vsm,
recursion_levels: 5,
variety_management: :requisite,
algedonic_signals: true- The top-level
VsmPatternEnginemodule is a stub (hello/0). UseVsmPatternEngine.Enginefor actual functionality. - Only 1 test file; coverage is minimal.
- Vector store client assumes
vsm-vector-storeis running locally; no fallback if unavailable. - No CI badge despite having a
.github/workflows/ci.yml. - The
statisticshex package handles basic stats; more advanced methods (isolation forest, LOF) are implemented from scratch with limited validation.
- vsm-vector-store -- vector persistence backend
- vsm-event-bus -- event coordination
- vsm-mcp -- top-level VSM orchestrator
- vsm-external-interfaces -- HTTP/WS/gRPC adapters
MIT