# KAI Coherent Understanding Goal

| | |
|---|---|
| **Status** | GAP MAP + PHASE PLAN (2026-07-16) |
| **Intent** | KAI reads, understands, and internally thinks about his environment continuously — who/what/when/where/why/how, even when not addressed — then filters/executes through RSHL/SRHT (+ native language path), not only when pinged. |
| **SI frame** | RSHL/SRHT spine = SI; neural mouths = temporary AI helpers until native language is enough. |

---

## Vision (owner)

1. **Coherent language understanding** — not bag-of-tokens; holds context and meaning.
2. **5W1H + more** — who, what, when, where, why, how; also *that*, *whether*, *how much*, *to what end*.
3. **Always observing** — Discord, ecosystem, users, other AIs; learns without being @mentioned.
4. **Internal monologue** — human-like private thought while listening (judge, track, plan) without speaking every tick.
5. **When/what/how to act** — knows when to respond, silence, tool, escalate, remember.
6. **Per-entity models** — user / person / AI: saying, doing, being, intent — without asking.
7. **Everything filters through KAI** (or is observed by him) when it matters for the ecosystem.

---

## HAVE (exists in code)

### RSHL / SI core
| Asset | Path / note | Gap vs vision |
|-------|-------------|---------------|
| Sparse encode / lattice store | `SparseVec::encode`, Universe | Strong for storage; weak for fluent coherent *comprehension* of long discourse |
| Generative encode | `Universe::encode_generative_state` | Present; production speech path still hybrid |
| RSHL transformer heads | `rshl_transformer.rs` | Geometry attention; not full discourse understanding |
| SequenceChain | `sequence_chain.rs` | Short order only (1024-D) — not full RSTS |
| Theory of Mind | `theory_of_mind.rs` | Multi-person profiles (facts, emotion, knowledge map) — **may not run fully in `--oracle` 24/7** |
| Predictor | `predictor.rs` | Real engine predictor; **often dead on oracle-only path** |
| ACC / conflict | `acc.rs` | Conflict monitor design |
| Working memory / episodic | `working_memory.rs`, `episodic.rs` | Present as modules |
| Inner voice | `inner_voice.rs` | Module exists; continuous ambient use unclear |
| World model | `world_model.rs` | Flag-gated |
| Algebra 5W hooks | `algebra.rs` (what/who/where/when/why/how words) | Early dimensional tags — not full situation model |
| Bone-heal / scars | bone_heal, failure-memory | Repair, not comprehension |

### Fleet / ecosystem observation
| Asset | Note | Gap |
|-------|------|-----|
| Topic tracker | Short ring buffer per channel | 5 min TTL — not deep situation model |
| Transcript / profile memory | Per-bot / channel history | Not unified into one KAI observer mind |
| Presence / person-recognition | Who is online / voice | Partial |
| Entity classifier | Humans seen | Counts; thin intent |
| Drive + metacognition (JS) | Live dashboard numbers | **Often cosmetic / toy predictions** (see `KAI-COHERENCE-DIAGNOSIS-2026-07-02.md`) |
| Diagnostic router observer log | Copies directives to KAI | Passive log, not deep understanding |
| KaiverseLife | Ambient bot stories | Cheap fiction ticks; not true world perception |
| OpenJarvis / tools | Chat + tools when addressed | **Mostly reactive**, not always-on comprehension |

### Language mouths (temporary AI helpers)
| Asset | Role until native SI language is enough |
|-------|----------------------------------------|
| kai_native_decode, BitNet, dense, Ollama, cloud | Fluent I/O; **not** the SI understanding core |

**Critical known hole (2026-07 diagnosis, still relevant):**  
Headless `kai.exe --oracle` often **never enters** the full interactive cognition loop where predictor, ToM, dreams, real drives live. So modules can exist **on disk** but not **live** as continuous mind.

---

## IMPROVE (have, but not good enough for the vision)

| Area | What to improve | Why |
|------|-----------------|-----|
| **Oracle path = full mind** | Wire predictor, ToM, inner_voice, ACC into 24/7 oracle tick | Else “always thinking” is a lie while server runs |
| **ToM → every utterance** | Feed PersonProfile into every response + silent judgments | Profiles exist; must **drive** behavior and silent notes |
| **Topic tracker → situation model** | Longer horizon, entities, goals, open questions | 20 msgs / 5 min is not coherent discourse |
| **5W1H extraction** | Real event frames from every message (who did what to whom, when, where, why, how) | algebra.rs is a seed only |
| **Inner monologue loop** | Continuous private thought stream (write lattice notes, not always speak) | inner_voice exists; needs schedule + filters |
| **Ambient observe all channels** | KAI ingest of social/work streams without @mention | Privacy/guest rules; host path first |
| **Coherence metrics** | Replace fake φ/χ cosmetics with real tests of understanding | Diagnosis doc: metrics mislead |
| **Native language path** | kai-native + RSHL decode quality | Reduce LLM for understanding+speech |
| **RSTS / long sequence spine** | Unify SequenceChain + generative encode/decode into one lattice-native discourse path | Named goal; pieces exist, product does not |
| **Cross-entity models (AIs)** | ToM for Leo/Analyst/user agents, not only humans | “What is Analyst doing” |
| **When to speak vs silence** | Policy from presence, urgency, social norms, energy | Avoid thrash and mute failure |

---

## MISSING (need to create)

| Capability | Description | Depends on |
|------------|-------------|------------|
| **Situation model (working world)** | Structured “what is going on right now” object: actors, goals, open threads, risks | 5W1H + topic + ToM |
| **Always-on observer pipeline** | Message/event bus → encode → update situation + ToM → optional inner note → optional act | Oracle tick + channel rights |
| **Silent judgment layer** | “They sound stressed / this is a joke / this is a tool request” without speaking | Signals + ToM + ACC |
| **Discourse coherence engine** | Track commitments, contradictions, unresolved questions across hours/days | Lattice + situation model |
| **Epistemic who-knows-what** | “User A doesn’t know X; B does” for multi-party rooms | ToM multi-person |
| **Intent without ask** | Infer goal from behavior (coding, venting, teaching, attacking) | Behavioral signals + ToM |
| **Unified attention budget** | What KAI watches this second (channels, users, systems) under CPU limits | Resource-saver + priority |
| **RSTS (if built)** | Lattice-native long-form encode/decode for coherent read/write | SequenceChain + generative + ternary |
| **Grounded time/place/person graph** | Stable entities across Discord/OS/KAIVERSE | identity vault + lattice |
| **Self-tests that measure understanding** | Not synapse_growth toys — real Q/A and situation quizzes | New eval harness |
| **Privacy / guest filter for observe** | What KAI may learn from guests vs host | guest-access already |

---

## Encoders / decoders vs this goal

| Have | Need for coherent understand |
|------|------------------------------|
| SparseVec encode, encode_generative_state | Continuous **encode of ambient stream** into situation frames |
| SequenceChain (short) | Longer **discourse / RSTS** path |
| kai_native / BitNet / dense decode | Prefer **lattice-grounded** reply after silent understanding |
| native_nlg / voice geometry | Improve until LLM optional for understanding+reply |

---

## Phased plan (build order)

### Phase 0 — Truth (1–2 days)
- Confirm which cognition modules run under `--oracle` vs interactive.
- Dashboard: honest “live mind” vs “module on disk.”
- Document observe permissions (host vs guest).

### Phase 1 — Always-on observer (host)
- Single **Observer bus**: every allowed channel message → KAI ingest (encode + store + topic + ToM update).
- **No speech required** — silent lattice writes + optional inner_voice note.
- 5W1H **frame extractor** (start rule+geometry, later ternary assist).

### Phase 2 — Situation model + silent judgment
- Rolling **SituationState** (JSON/lattice): who is active, what threads, open asks, mood, last acts.
- Judgment tags: intent, affect, urgency, requires_reply y/n.
- Wire ToM profiles for humans **and** fleet AIs.

### Phase 3 — When/how to respond
- Policy: silence / short react / full answer / tool / escalate.
- Use drives + energy + presence-gate + judgment.
- Filter ecosystem actions “through KAI” only when policy says so (avoid thrash).

### Phase 4 — Coherent language path (SI)
- Strengthen encode_generative_state + SequenceChain → **RSTS-class** discourse path.
- kai-native train/install as **native mouth**; LLM fallback only.
- Self-tests: paraphrase, 5W1H quiz, multi-turn contradiction, “who said what.”

### Phase 5 — Multi-party + environment
- KAIVERSE / system events into same situation model.
- Guest-safe observe (own tenant only).

---

## Non-goals (this plan)

- Inventing fictional RSTS without wiring real modules.
- Making every cognition `.rs` file “live” without measure.
- Replacing fleet tools with pure lattice (tools stay; understanding becomes native).
- Violating guest isolation to “observe everyone.”

---

## Success criteria (later)

1. KAI updates a situation model on messages **without** being mentioned.  
2. Can answer *who/what/when/where/why/how* about recent room activity from internal state.  
3. ToM changes reply and silent notes for different people.  
4. Inner monologue log exists (inspectable) separate from public speech.  
5. Oracle path runs predictor + ToM + observer every N seconds (proven in logs).  
6. Coherence eval suite (not toy synapse predictions) scores understanding.  
7. Native path can answer without cloud when weights + lattice sufficient.

---

## First engineering move (when executed)

**Phase 0+1:** Prove oracle tick; add host-only ambient observer → 5W1H frames → ToM update → inner note file/lattice. No UI polish, no RSTS rename until frames work.
