Purpose: Bring the LIVE running KAI up to date with all the built-but-not-deployed work, without wiping the in-RAM brain.
Written: 2026-07-05 (verification pass, read-only). Target version: 9.10.167.
Who runs it: Ryan (owner/tester). This doc is the exact ordered sequence — do the steps in order.
> Bottom line up front: The risky part of this deploy is NOT the code — it's the engine restart. The on-disk kai.exe is *already built* with every fix (verified below), and the brain-safety net + a full brain backup are in place. So the job is: gracefully stop the running engine (so it flushes its brain), relaunch, and watch the first boot load the brain instead of resetting. Everything else (fleet, dashboard) is a normal restart + hard-refresh.
---
The on-disk binary target/release/kai.exe already embeds version 9.10.167 and every staged fix. Verified by reading the binary's own embedded strings (content evidence — mtimes on this mount are unreliable and were ignored per project rule):
kai.exe? |KAI BRAIN-SAFETY ABORT | ✓ engine.rs 388–418, main.rs 10813–10852 | ✓ (2×) |Brain flushed on shutdown | ✓ oracle_server.rs 523 | ✓ (2×) |activation_entropy | ✓ oracle_server.rs 5394–5521 | ✓ |LIVE predictor ENABLED on headless heartbeat / KAI_COGNITION_LIVE | ✓ oracle_server.rs 4297–4340 | ✓ |rho / valence | ✓ oracle_server.rs 184–185, 4407–4427 | ✓ |9.10.167 | ✓ Cargo.toml | ✓ (5×) |Interpretation: The working .rs files differ from the last git commit (v9.10.65) — those uncommitted edits ARE the staged P0/P4/P5a work — and they have already been compiled into the current on-disk kai.exe (v9.10.167). What is stale is the running process, which was launched from an older binary before this build. A cargo build will therefore be a near no-op, but it is kept in the sequence (Step 2) as a cheap correctness-confirm. The action that actually deploys the fixes is the graceful restart in Steps 1 & 3.
src/core/engine.rs (~Engine::new, lines 388–418) ✓--oracle path in src/main.rs (lines 10813–10852; KAI BRAIN-SAFETY ABORT banner at 10831) ✓src/bridge/oracle_server.rs (line 523, Brain flushed on shutdown) ✓C:\KAI\data\_brain-backup-20260702-221450\ containing kai-cells.bin.zst (~18.5 MB), kai-meta.json, kai-mind.backup.json, identity.json, cells-manifest.json ✓This is the safety net: if the first post-restart boot cannot load the brain, the guard aborts loudly instead of silently resetting, and you restore from this folder.
.mjs) — needs a fleet restart (Start-KAI.ps1)tools/oracle-discord/bots/leo.mjs — embodiment (LEO_EMBODIED_VOICE), brevity (LEO_BREVITY), voice-v2 scaffold (LEO_VOICE_V2), voice-debug (LEO_VOICE_DEBUG)tools/oracle-discord/shared/drive-system.mjs — coherence: killed rigged prediction (P1)tools/oracle-discord/shared/metacognition.mjs — coherence: symmetric scoring (P2), prompt de-doom (P3)tools/oracle-discord/shared/simulation.mjs — agent movementtools/oracle-discord/command-center-server.mjs — role-separation + KAIVERSE worlds endpoint (line 78) + audit-log/voice-debug quietCtrl+Shift+R), no restartC:\KAI\oracle.html — Oracle-restore + popup fix + role-sep + everythingC:\KAI\kaiverse.js — moons + movementLEO_EMBODIED_VOICE | ON (=0 disables) | Leave on |LEO_BREVITY | ON (=0 disables) | Leave on |LEO_VOICE_V2 | OFF (=1 enables) | Leave OFF — opt in later |LEO_VOICE_DEBUG | OFF (quiet) | Leave off |KAI_COGNITION_LIVE | OFF (=1 enables live predictor) | Leave OFF on first boot — opt in later |KAI_ALLOW_MIND_RESET | unset | NEVER set this during this deploy |---
1. Confirm the safety-net backup is present:
C:\KAI\data\_brain-backup-20260702-221450\ (should contain kai-cells.bin.zst, kai-meta.json, kai-mind.backup.json).
2. Optional but recommended — take a fresh timestamped copy of the live data dir *before* touching the engine (PowerShell):
$ts = Get-Date -Format 'yyyyMMdd-HHmmss' Copy-Item -Recurse "C:\KAI\data" "C:\KAI\data\_predeploy-backup-$ts"
(Skips nothing; a few GB of disk for a guaranteed rollback point.)
kai.exe console window and press Ctrl+C once. Do NOT use taskkill, the window X, or End Task — those skip the shutdown-flush and are exactly how the brain was lost before.Brain flushed on shutdown (ok=true, cells=…)
ok=true with a sane cell count → the live brain was written cleanly. Proceed.ok=false, or the process dies without flushing → STOP. Do not rebuild or relaunch yet. Restore data\ from the backup (Step 0) before doing anything else, then investigate.cd C:\KAI cargo build --release --bin kai
9.10.167). It should finish clean and leave target\release\kai.exe at version 9.10.167.apply-hotfix.ps1. apply-hotfix may hard-kill the engine (bypassing the graceful flush from Step 1). Only the manual graceful-Ctrl-C → build order guarantees the brain was flushed first.cd C:\KAI .\Start-KAI.ps1
loaded compact format (N cells) with N at roughly the pre-restart cell count → the brain loaded. Continue.KAI BRAIN-SAFETY ABORT banner fires → that is the safety net doing its job (it refused to silently start with an empty/failed brain). Do NOT set KAI_ALLOW_MIND_RESET. Instead: stop, restore data\ from the backup (Step 0 or _brain-backup-20260702-221450), and investigate the load failure before retrying.Start-KAI.ps1 also launches the Node fleet + dashboard, which picks up all the staged .mjs changes (Leo embodiment/brevity, drive-system, metacognition, simulation, command-center role-sep + worlds endpoint).LEO_VOICE_V2 or KAI_COGNITION_LIVE yet.Ctrl+Shift+R. This loads the new oracle.html + kaiverse.js. No server restart needed for these.Confirm each, in the dashboard/logs:
rho and valence are non-zero and move over time (heartbeat is running).0–1 number (the P4 activation_entropy metric), not a placeholder.Opt-ins — only after the above is green, and one at a time:
KAI_COGNITION_LIVE=1 and restart the engine; watch for [KAI/Cognition] LIVE predictor ENABLED on headless heartbeat.LEO_VOICE_V2=1 and restart the fleet.Do these separately so you can attribute any change to the right switch.
---
BRAIN-SAFETY ABORT fires | Stop the engine. Restore C:\KAI\data\ from _brain-backup-20260702-221450\ (or the Step-0 _predeploy-backup-*). Relaunch and confirm loaded compact format (N cells). Never set KAI_ALLOW_MIND_RESET. |cargo build from the last known-good commit (git stash the working edits → cargo build → relaunch) if you must revert code. Brain data is independent of the binary. |.bak snapshots exist beside each file (e.g. bots/leo.mjs.bak-voicev2-20260704-013936, .bak-embodiment-…, .bak-brevity-…). Restore the relevant .bak, re-run Start-KAI.ps1. Or just flip the offending flag off (LEO_EMBODIED_VOICE=0, LEO_BREVITY=0) — no code revert needed. |.\Start-Dashboard.ps1 restarts :3001 alone (leaves engine + bots + pipeline running). |git checkout HEAD -- oracle.html kaiverse.js (note: this reverts to v9.10.65 committed state, losing the staged browser edits). |---
Back up first (Step 0 — the _brain-backup-20260702-221450 net already exists; take a fresh copy too). Ctrl+C the kai.exe window and confirm Brain flushed on shutdown (ok=true, cells=…) — if that line doesn't appear, stop and restore. Run cargo build --release --bin kai (confirm-build; the on-disk exe is already 9.10.167 with every fix). Relaunch with Start-KAI.ps1 and watch the first boot load loaded compact format (N cells) — if the BRAIN-SAFETY ABORT banner fires instead, that's the net catching a bad load: restore from backup, don't set KAI_ALLOW_MIND_RESET. The same Start-KAI.ps1 brings the fleet + dashboard up with all .mjs changes; finish by hard-refreshing the dashboard (Ctrl+Shift+R) for oracle.html + kaiverse.js. Verify vitals/coherence/Oracle/KAIVERSE/Leo/logs, then opt into KAI_COGNITION_LIVE=1 and LEO_VOICE_V2=1 later, one at a time.