Antaḥkaraṇa 2.0 — the same mind, now running the loop
pip install antahkarana==2.0.0
Antaḥkaraṇa is a trainable continual-learning architecture you wrap around your own model and your own data. Four organs — manas (perception / novelty), buddhi (discrimination / plasticity & abstention), ahaṃkāra (the self / boundaries), citta (memory / consolidation) — plus a control ring that governs how the system acts. The mind is the same for every domain; only a thin adapter changes.
2.0 turns that mind outward. The same organs that learn a stream of tasks without forgetting now run as a governed loop engine over live observations: watch → learn what's normal → self-improve → orchestrate many loops, with every action passing an audited control ring.
2.0 is fully additive. Every 1.x symbol and default is unchanged — code written against 1.x runs on 2.0 untouched. The major bump marks a new product line (the loop engine), not a breaking change.
The arc — it was always a loop engine
Most agent loops are built the same way: poll a source, compare to a hard-coded rule, fire an action. That breaks when the world drifts (the rule that meant "normal" stops meaning it), and it's dangerous the moment a loop can touch money, security, or a customer.
Antaḥkaraṇa already had the parts a good loop needs — they were just pointed at training tasks. 2.0 points them at live observations instead. Each loop primitive maps 1:1 to an organ:
| Loop needs… | …which organ provides it |
|---|---|
| detect change | manas — avidya(), OneClassNovelty (novelty / drift) |
| "is this actually new?" | ahaṃkāra — boundary() (spike vs running baseline) |
| don't re-handle the same thing | citta / smṛti — dedup + memory |
| decide what to do | buddhi — judgment & abstention |
| ask a human on anything risky | control ring — RiskRouter → ALLOW / NOTIFY / SOFT_BLOCK / HARD_BLOCK, audited |
| keep getting better | the continual-learning loop itself |
The loop engine — four composing phases
🛰️ Watch — Loop
A governed sentinel. Loop(sense, change, category, signature, gate, …). Each step: sense an observation, score
its novelty, fire only on a genuine spike vs the running baseline (ahaṃkāra), route the action through the
control ring, and dedup what it has already handled (smṛti). A hard-blocked category (purchase, deploy,
delete) escalates to a human and never auto-acts. Everything is written to a jsonl audit trail.
from antahkarana import Loop, Policy
watch = Loop(
sense=check_product_page,
change=lambda o, mem: 1.0 if (o["in_stock"] and o["price"] <= 175) else 0.0,
category=lambda o: "purchase",
signature=lambda o: f"{o['in_stock']}:{o['price']}", # smṛti dedup
gate=Policy(name="shopper", hard_block=["purchase"]), # never auto-buy
on_escalate=lambda obs, iv: notify_me(obs),
)
watch.run(max_steps=1000)
📈 Learn — OneClassChange
A learned change() for Loop: a Normal-only autoencoder that refits on a sliding window with held-out
calibration (no train-on-test bias) and adapts to drift. The differentiator vs a static rule:
| baseline | false-alarm rate under drift (3 seeds) |
|---|---|
| static / frozen rule | 45–98% as "normal" drifts under it |
learned (OneClassChange) |
held at the ~5% budget (mean 1.7–3.0%), every seed |
Honest tradeoff: recall ~52–80% — tuned to the false-alarm budget, not maximum sensitivity. (First implementation was a clean negative: calibrating on the AE's own training errors + self-supervised filtering created a vicious cycle. Fixed with held-out calibration and accumulating all recent observations — documented, not buried.)
🔧 Improve — ImproveLoop
build → critique → fix → repeat until a learned standard is met, then gate the ship. manas is both the
critic (the quality gap) and the fix direction (OneClassNovelty.reconstruct). Validated (3 seeds): monotone
convergence in 3–4 rounds — and it never auto-ships. The terminal ship category is hard-blocked, so the
finished draft is escalated for human sign-off. Autonomy to improve; a human to commit.
🧭 Orchestrate — Orchestrator
buddhi fans out N specialist Loops in parallel under ONE control ring and ONE audit log, then ranks what
surfaced by severity so the human sees the critical thing first. Validated: 3 specialists (security / stock /
inbox), correct tiers from one policy (intrusion → soft-block, purchase → hard-block, important → notify), and
per-loop dedup isolation — one noisy loop neither floods nor suppresses another. This is the software spine of
the air-gapped Box.
Why it's different from a generic agent loop
- Learns the baseline — fewer false alarms over time, instead of a rule that rots.
- Remembers without forgetting — the same no-forgetting stack from 1.x.
- Governs by construction — the gate is the architecture, not a prompt you can talk it out of; every action is audited.
- Abstains when unsure —
pramāṇa/NOTIFYrather than a confident wrong action.
Honest scope
The loop engine is a thin governed runtime around your backbone — it supplies memory + calibrated novelty + the audited gate + the learning baseline. The reasoning/action inside each loop is still yours to provide. The learning edge only appears when there's a learnable signal (drift / anomaly / relevance), not when the answer is a hard rule. Orchestrator synthesis ranks per tick (real-time triage); a whole-run global ranking is a trivial sort.
Everything from 1.x is still here (unchanged)
- Four no-forgetting mechanisms — saṃskāra (EWC) · DER++ ·
OrthoLoRAstructural isolation · forgetting-curve replay (nidrā). MatraLAMBscale-stable optimization (mātrā, the rightly-measured step) — one lr stable across any parameter scale; at the lr that used to collapse O-LoRA, forgetting +0.167 → +0.003.- Adaptive guṇa — closed-loop plasticity on measured forgetting.
- Novelty — energy · feature-space (
FeatureOOD) · one-class (OneClassNovelty); calibrated abstention.
Validation
Core architecture gates green: G1 20/20 · G2 12/12 · G3.5 5/5, plus a new G6 loop engine 12/12 covering all four phases (governed watch + dedup, learned-novelty warmup, monotone improve + no-auto-ship, orchestrator one-ring / correct-tiers / dedup-isolation). Loop engine claims validated multi-seed on drifting streams; full scripts and per-phase reports accompany the release.
License & status
Apache-2.0. The published package (antahkarana) is the open architecture; trained domain models and the
appliance tooling are separate. New behaviour is opt-in.
pip install antahkarana==2.0.0 · PyPI ·
changelog & API
