Neuro-inspired learning engine for anomaly detection
Project description
KONTINUUM Core
Pure-Python, neuro-inspired learning engine extracted from KONTINUUM. No Home Assistant dependency — usable from any Python project. Zero runtime dependencies (standard library only), Python 3.9+.
Part of the 3-repo family: kontinuum-core (this repo, HA-free Python package on PyPI) ·
ha-kontinuum(full HA Pro integration with UI) ·ha-kontinuum-lite(slim HA integration, no UI)
Installation
pip install kontinuum-core
Usage
from kontinuum_core import KontinuumEngine
engine = KontinuumEngine()
engine.register_entity("binary_sensor.motion_kitchen", ha_area="kitchen", domain="binary_sensor")
snap = engine.observe({"entity_id": "binary_sensor.motion_kitchen", "new_state": "on"})
print(snap.surprise, snap.anomaly) # 0..1 surprise, bool anomaly flag
What it does
One observe() pipeline drives 25 brain-region modules: thalamic tokenization,
hippocampal n-gram memory, predictive surprise with a robust (median + MAD)
adaptive anomaly threshold, cerebellar reflexes, basal-ganglia habits, an
attention (reticular) burst filter for noise, and sleep consolidation
(replay / prune / dream-recombine / synaptic homeostasis during quiet spells).
Since 0.5.0 the set also models the missing slow signals — a lateral habenula (anti-reward: stop re-proposing rejected actions), a subthalamic nucleus ("hold your horses" under conflict), a learned circadian clock (suprachiasmatic), and the cortisol / acetylcholine / serotonin modulators plus BDNF use-dependent protection. All are scalar EMAs or tiny bounded maps, start neutral, and add ~0 ms/event.
State is persistent and bounded: engine.to_dict() / from_dict()
round-trip the full learned brain (with a schema_version guard), and the
learned maps are capped — safe to run for years on a Raspberry Pi.
Every observe() returns an EngineSnapshot with the live observability
signals — surprise (0–1 prediction error) and the adaptive anomaly flag —
which the HA integrations surface directly as entities (sensor.kontinuum_surprise,
binary_sensor.kontinuum_anomaly, …). The engine stands on its own; any LLM is
strictly an optional layer on top.
LLM integration contract (kontinuum_core.llm)
The engine is the sub-symbolic brain; an LLM is the optional language / reasoning layer on top.
build_llm_context(engine_or_brain)/render_llm_context(ctx)— export the state (anomaly signal, expected-next events, learning maturity) with explicit 0–1 scales so a model can reason over it reliably.extract_json(reply)/normalize_proposal(reply)— turn a model's (often sloppy: code-fenced, prose-wrapped, stringly-typed) reply into a strict, validated action proposal.
Day-1 priors (kontinuum_core.priors)
parse_home_prior(llm_reply) + seed_engine_from_prior(engine, prior) let an
LLM describe the home at setup, so the engine starts already expecting the
household routine instead of from a blank slate.
Benchmark
python benchmarks/replay.py
A replay benchmark + concept-drift stress test (also runs as a CI quality gate): the surprise signal separates anomalies from routine at AUC ≈ 0.99 and re-adapts after a routine change.
License
AGPL-3.0 – see LICENSE file.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kontinuum_core-0.5.0.tar.gz.
File metadata
- Download URL: kontinuum_core-0.5.0.tar.gz
- Upload date:
- Size: 105.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ad194af2802eb67319633f0f86adb1ba538302f8660e51e95aca6884e7917e5
|
|
| MD5 |
87159200bacd02895642ae28e3605717
|
|
| BLAKE2b-256 |
6e199e0b5fe7f9c2f2e0712ae24a7eb38c92ecc2da91a0bdf91bedb75bffb905
|
Provenance
The following attestation bundles were made for kontinuum_core-0.5.0.tar.gz:
Publisher:
publish.yaml on Chance-Konstruktion/kontinuum-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kontinuum_core-0.5.0.tar.gz -
Subject digest:
9ad194af2802eb67319633f0f86adb1ba538302f8660e51e95aca6884e7917e5 - Sigstore transparency entry: 1825138831
- Sigstore integration time:
-
Permalink:
Chance-Konstruktion/kontinuum-core@24affc7a1361166d4249f5725d74050ffd851ffc -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Chance-Konstruktion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@24affc7a1361166d4249f5725d74050ffd851ffc -
Trigger Event:
release
-
Statement type:
File details
Details for the file kontinuum_core-0.5.0-py3-none-any.whl.
File metadata
- Download URL: kontinuum_core-0.5.0-py3-none-any.whl
- Upload date:
- Size: 90.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82739ee5612d558709171f84734a138c94ead387f3ec4314a69f40ab52f85945
|
|
| MD5 |
e564c0a0cb96ff47324960306c4154a5
|
|
| BLAKE2b-256 |
9a8c0781916126499a5fbb68f7c26649b292dfb327a475f9fab565ee35ad40c5
|
Provenance
The following attestation bundles were made for kontinuum_core-0.5.0-py3-none-any.whl:
Publisher:
publish.yaml on Chance-Konstruktion/kontinuum-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kontinuum_core-0.5.0-py3-none-any.whl -
Subject digest:
82739ee5612d558709171f84734a138c94ead387f3ec4314a69f40ab52f85945 - Sigstore transparency entry: 1825138864
- Sigstore integration time:
-
Permalink:
Chance-Konstruktion/kontinuum-core@24affc7a1361166d4249f5725d74050ffd851ffc -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Chance-Konstruktion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@24affc7a1361166d4249f5725d74050ffd851ffc -
Trigger Event:
release
-
Statement type: