Mirror of the public Nokido wiki (source of truth: https://github.com/Nokido-labs/nokido/wiki/12-AMI-Cognitive-Stack). Edits belong there.
Updated: 2026-09-17
Nokido implements the Autonomous Machine Intelligence (AMI) loop
proposed by Yann LeCun in A Path Towards Autonomous Machine Intelligence
(2022). This stack is what makes Nokido a planning agent, not just a
prompt-response wrapper.
Perception
β
βββββββββββββββββ
β World Model β
βββββββββ¬ββββββββ
β
βββββββ΄ββββββ
β β
βββββββββββ βββββββββββ
β Cost β β Actor β
ββββββ¬βββββ ββββββ¬βββββ
β β
βββββββ¬ββββββ
β
βββββββββββ
β MPC β β planner over horizons
β Planner β
ββββββ¬βββββ
β
Action
β
(feed back to Perception)
Plus DeepMind-style policy and value networks for sampling
actions and estimating returns.
| LeCun component | Nokido module | Notes |
|---|---|---|
| Perception | app/forge_byte_router.py + sentinels |
13 sentinels filter the raw input stream. |
| World Model | app/forge_world_model.py |
Predicts next state given current + action. |
| Cost | app/forge_cost_net.py |
Scores outcomes (preference model). |
| Actor | app/forge_policy_net.py |
Proposes candidate actions. |
| MPC Planner | app/forge_mpc.py |
Model-Predictive Control over N-step horizons. |
| Policy / Value | app/forge_policy_net.py, app/forge_value_net.py |
DeepMind-style nets. |
| MCTS | app/forge_mcts_engine.py |
Monte-Carlo Tree Search over the world model. |
| Self-supervised pre-train | app/forge_jepa.py |
JEPA (Joint-Embedding Predictive Architecture, LeCun 2023). |
All modules built continual-learning ready (no batch retraining
required) β see app/forge_continual_backprop.py.
tools/forge_ami_strategist.py ties everything together :
CodePatchProposal (DSPycerebras > groqforge_scorecard.evaluate_symbolic() runs the 6close : score β₯ threshold β ship the patch.refine : score middling β spawn an EDITOR refine task.ban_and_retry : score below floor β ban this draft, try anotherforge_offline_trainer.py).This is the neuro-symbolic governance principle in practice : LLMs
generate, symbolic logic judges.
app/forge_active_inference_agent.py wraps pymdp (Heins, 2024) for
the cyber-defense agent.
Instead of maximizing a reward signal (RL paradigm), the agent minimizes
expected free energy :
F = E_q[log q(s) - log p(o, s)]
β KL(q(s)βp(s)) - E_q[log p(o|s)]
= complexity - accuracy
In plain terms : the agent has a generative model of what should
happen. When reality diverges (observed o doesn't match predicted o),
the KL divergence spikes β a "surprise" signal. An attack, by definition,
is something the system did not predict.
Implementation :
from forge_active_inference_agent import ActiveInferenceAgent
agent = ActiveInferenceAgent(num_states=10, num_observations=5)
agent.observe([2]) # observation index
surprise = agent.compute_surprise()
if surprise > THRESHOLD:
fire_alert()
6/6 tests pass (per memory forge_active_inference_agent).
app/forge_lnn_monitor.py wraps ncps (Hasani, MIT, 2022) β Closed-form
Continuous-time networks (CfC).
Used for CPU/RAM/NPU telemetry in continuous time. Why :
Train step / loss curves : 4/4 tests pass (memory forge_lnn_monitor).
app/forge_jepa.py implements LeCun's JEPA (2023) :
Nokido uses JEPA in forge_world_model : it predicts the next system-state
embedding from the current state + action (latent-space model-predictive
planning, gradient_refine_action), not raw text.
The stack couples two vector spaces that are not yet aligned :
forge_embed_router β NokidoLlamaEmbedforge_world_model JEPA + forge_value_net / policy_net /cost_net) = 384d (all-MiniLM, or nomic fallback) via forge_state_encoder.So the world-model can't directly consume RAG-indexed lessons (different dim).
Unification to 1024d is a non-breaking rail in progress :
forge_state_encoder.encode_state(text, dim=1024) routes via embed_routerdim = STATE_DIM (env LAFORGE_STATE_DIM,forge_state_encoder.STATE_DIMLAFORGE_STATE_DIM) β across forge_world_model + value/policy/cost netsCOGNITION_DIM imports it, no double env read). cost_module + active_inferenceforge_goap_intuition's value-net embedder isembed_router BGE-M3 (matches thetools/forge_cognition_dim_selftest.py (default-384 non-breaking + 1024get_current_state_text_rich() enriches state (tasks + mood + hormones) for thetasks:β¦ of the legacy 384d traces).tools/forge_embed_bridge.py β learned ridge projection 384β1024 (cos ~0.8),tools/forge_trace_collector_rich.py β accumulates fresh rich traces (traces_rich,--reencode via :8099) for the eventual retrainNokidoTraceCollectorRich,Until cutover, cognition stays 384d (untouched), memory is 1024d ; the bridge +
the dim=1024 opt-in let them interoperate.
app/forge_goap.py β symbolic planner. Used when :
generate_module,fix_failing_test, ingest_doc).plan MCP tool with a goal string.Algorithm : forward-chaining BFS over the action graph. Actions :
run_shell, run_python, ask_llm, ingest_url, search_rag,
run_tests. Each action has preconditions + effects.
Goals are defined in app/forge_goap.py::GOALS β extend as needed.
tools/forge_auto_evolution_loop.py β runs 24/7, daemon-managed :
lessons_learned.md for 3+ recurring errors βforge_scorecard on modified modules β flag drift.The output : entries in task_queue (forge_task_queue.py), which any
EDITOR-capable agent (Claude, Codexβ¦) can claim.
app/forge_skill_curator.py β picks execution_traces from past sessions,
distills them into reusable curated_skills (RAG domain). 11/11 tests
pass. Dry-run kept 18/19 traces (per memory).
This is continual learning at the system level : Nokido's behavior
yesterday becomes a skill it can recall today.
The AMI stack is the reason Nokido consumes 5β15Γ fewer tokens than
LLM-as-orchestrator setups (see MANIFESTO Β§3.5).
| Module | Test file | Coverage |
|---|---|---|
forge_scorecard |
tests/test_forge_scorecard.py |
51 tests |
forge_active_inference_agent |
tests/test_forge_active_inference.py |
6/6 |
forge_lnn_monitor |
tests/test_forge_lnn_monitor.py |
4/4 |
forge_jepa |
tests/test_forge_jepa.py |
TBD |
forge_goap |
tests/test_forge_goap.py |
partial |
forge_ami_strategist |
(E2E in tests/test_ami_e2e.py) |
E2E PASS |
If you want to dig deeper :
.npz. GOAP E2E PASS.offline_trainer / consolidator /self_patcher daemons (currently dormant β memory roadmap_ami_lecun).