Skip to content

viable-systems/vsm-pattern-engine

Repository files navigation

vsm-pattern-engine

Elixir library for temporal pattern detection, correlation analysis, and anomaly detection. Designed for use within the Viable System Model (VSM) ecosystem but usable independently.

Status

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.

What it does

  • 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.

Repository structure

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)

Module count

24 .ex files under lib/. 1 test file.

Dependencies

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.

Quick start

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)

Configuration

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

Known limitations

  • The top-level VsmPatternEngine module is a stub (hello/0). Use VsmPatternEngine.Engine for actual functionality.
  • Only 1 test file; coverage is minimal.
  • Vector store client assumes vsm-vector-store is running locally; no fallback if unavailable.
  • No CI badge despite having a .github/workflows/ci.yml.
  • The statistics hex package handles basic stats; more advanced methods (isolation forest, LOF) are implemented from scratch with limited validation.

Related packages

License

MIT

About

VSM Pattern Recognition and Anomaly Detection Engine

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages