Skip to main content

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 KONTINUUM 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) · kontinuum-AI-anomaly (anomaly / novelty monitor for agent action streams, built on this engine)

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 26 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), an interval-timing stopwatch for recurring cadences (e.g. "every few weeks"), 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.

Documentation

Full reference in docs/: MODULES.md (all 26 brain modules) · PIPELINE.md (the observe() flow, EngineSnapshot.extra fields, the reward loop, persistence).

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.

Built on top of core

The engine is designed for smart-home event streams, but it is a general sequence-learner. kontinuum-AI-anomaly (PyPI: ai-kontinuum-monitor) points it at an AI agent's action log instead and adds the monitor layer core deliberately leaves out — robust scoring, anomaly history, alerting (escalation / snooze), a dashboard, multi-agent cross-stream correlation, strategy presets and an LLM-feedback loop. Core stays untouched there; it is a thin, additive layer, which is what keeps this engine equally usable from the Home Assistant integrations and from an agent-monitoring context.

pip install ai-kontinuum-monitor   # pulls in kontinuum-core

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kontinuum_core-0.6.2.tar.gz (135.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kontinuum_core-0.6.2-py3-none-any.whl (97.3 kB view details)

Uploaded Python 3

File details

Details for the file kontinuum_core-0.6.2.tar.gz.

File metadata

  • Download URL: kontinuum_core-0.6.2.tar.gz
  • Upload date:
  • Size: 135.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for kontinuum_core-0.6.2.tar.gz
Algorithm Hash digest
SHA256 1e3044d8afbc7939687ebb204be7ac496d85699e81ed8d576b2ca998445b2d83
MD5 25eab9ef50b9ad92be4e8af591ef76bb
BLAKE2b-256 7d52f88e38000f802da9ebcee10618f341aac252ecbb0150b5308bd8735e26c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for kontinuum_core-0.6.2.tar.gz:

Publisher: publish.yaml on Chance-Konstruktion/kontinuum-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kontinuum_core-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: kontinuum_core-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 97.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for kontinuum_core-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ed784546e163fbe80f5f501c76f1e5f056ad1e3577a5847398b6a3d1d3d80755
MD5 910d28d95a9f0b75a6299ff110f3cf11
BLAKE2b-256 d2d00138aa5fd0a2b6578ad074b6b6c9540129e5a9eeab27a6d6261aa310a941

See more details on using hashes here.

Provenance

The following attestation bundles were made for kontinuum_core-0.6.2-py3-none-any.whl:

Publisher: publish.yaml on Chance-Konstruktion/kontinuum-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page