Merge origin/main (v1.2.0: Projects, modules, in-app updates)

Reconciles 17 commits of this session's work (self-alteration tools,
vendored Curry, slash-command dispatch, Windows toolchain/gate fixes)
against origin/main's v1.2.0 sync (Projects/RAG scoping, a new modules/
system for mail and network, in-app updates, the standalone memory
microservice folded into an in-process curator, KDE desktop theme
overhaul). Nine real conflicts, each resolved by hand after reading both
sides' actual diffs rather than picking one side wholesale:

- synapse/tools.py, tests/test_tools.py: origin/main's diff here was
  small and clean (read_file/list_files, two new tests) despite git's
  diff3 flagging the whole file as one conflict blob -- reset to this
  branch's version and hand-spliced their addition in at the same
  points they used, rather than trying to reconcile a false 800-line
  conflict. Found and fixed a real bug while verifying: _list_files
  returned backslash-separated paths on Windows, which don't match the
  forward-slash glob patterns the tool's own schema documents.
- synapse/main.py: kept this branch's cue-based standing advertisement
  of render_preview/run_snippet (independent of any playbook granting
  them) AND adopted origin/main's fix for routed reference playbooks
  not bringing their own tools along -- dropping either would have been
  a real regression, not just a style difference. Also: the standalone
  memory service (port 8001) is gone upstream, so its dead CORS/kill-
  target entries were removed; NEXUS_BACKEND_PORT parameterization and
  the manage_ollama-conditional kill logic (this branch's remote-Ollama
  support) were kept over origin/main's hardcoded equivalents.
- synapse/memory/store.py: kept this branch's _delete_message_vectors
  helper (already reused elsewhere, batches to stay under SQLite's
  variable limit) over origin/main's inline duplicate of the same fix.
- synapse/nexus_config.py, nexusos_cli/ncp.py: dropped the now-dead
  memory-service port/service entries; kept NEXUS_BACKEND_PORT env
  override and the manage_ollama-conditional kill-target list.
- CLAUDE.md, README.md: merged both sides' additions, no real conflict.

Found and fixed three more issues while independently verifying the
merged tree, none of them mine or origin/main's alone -- only visible
once both sides actually ran together:

- modules/ (the new mail+network package) was never added to
  pyproject.toml's wheel `packages` list OR the sdist's `include`
  allowlist, so `from modules.registry import ROUTERS` in main.py would
  ImportError on any wheel install. Fixed both; bin/check.sh's
  packaging gate now asserts modules/ actually ships. tests/
  test_packaging_deps.py's FIRST_PARTY/SHIPPED_PACKAGES sets were
  updated to recognize the new package.
- tests/test_mail_creds.py's 0600-mode assertions are POSIX-only --
  NTFS has no equivalent permission bits, so os.open(path, 0o600) on
  Windows just creates a normal file and stat.S_IMODE reports 0o666
  regardless. Made the assertions platform-aware rather than skip real
  coverage (the temp-file-cleanup and password round-trip checks in the
  same test still run on Windows) or paper over a genuine OS
  limitation with a fake pass.
- tests/test_kde_theme.py used bare Path.read_text() in fifteen places;
  Windows' default locale encoding (cp1252, not UTF-8) can't decode a
  real UTF-8 byte in the QML it reads, and did fail on one of the
  fifteen. Fixed all fifteen, not just the one that happened to trip
  today, since the other fourteen were equally fragile.

Verified: full bin/check.sh reports OK end-to-end on this Windows
checkout -- pytest (tests + management): 295 passed, 0 failed, 9
skipped; eslint clean; frontend node:test 57/57; PowerShell/shell
parse clean; wheel + sdist pass twine check and now correctly carry
modules/ (60 files, up from 52 pre-merge). synapse.main:app builds
with 74 routes (up from 54 pre-merge, matching the new Projects/mail/
network endpoints).
This commit is contained in:
2026-08-26 02:09:23 -05:00
91 changed files with 4293 additions and 1896 deletions
+6
View File
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Plank (Nexus primary-follow)
Exec=/home/jon/.local/bin/plank-primary-watch.sh
Hidden=false
X-XFCE-Autostart-Override=true
+15 -89
View File
@@ -1,4 +1,3 @@
# /home/jon/nexus-core/management/controlpanel.py
import time
import tkinter as tk
@@ -20,7 +19,9 @@ try:
except Exception:
VERSION = "0.0.0"
# Force 0.0.0.0 to ensure the Windows Host bridge works for Project Nexus
# Loopback by default -- the REST APIs are unauthenticated, so 0.0.0.0 exposed
# the whole admin+data plane to the LAN. Same knob management/ncp.py uses.
BIND_HOST = os.environ.get("NEXUS_BIND_HOST", "127.0.0.1")
FRONTEND_DIR = PROJECT_ROOT / "interface" / "web"
def _find_npm():
"""Prefer nvm's newest node. When the panel is launched from the desktop
@@ -51,28 +52,15 @@ BACKEND_CMD = [
str(PROJECT_ROOT / "Promethean" / "bin" / "python"),
"-m", "uvicorn",
"synapse.main:sio_app",
"--host", "0.0.0.0",
"--host", BIND_HOST,
"--port", "8000",
"--reload",
"--reload-dir", str(PROJECT_ROOT / "synapse"),
"--log-level", "info"
]
MEMORY_DIR = PROJECT_ROOT
MEMORY_CMD = [
str(PROJECT_ROOT / "Promethean" / "bin" / "python"),
"-m", "uvicorn",
"synapse.memory.service:app",
"--host", "0.0.0.0",
"--port", "8001",
"--reload",
"--reload-dir", str(PROJECT_ROOT / "synapse"),
"--log-level", "info"
]
FRONTEND_PID = PROJECT_ROOT / "runtime" / "pids" / "frontend.pid"
BACKEND_PID = PROJECT_ROOT / "runtime" / "pids" / "backend.pid"
MEMORY_PID = PROJECT_ROOT / "runtime" / "pids" / "memory.pid"
CHAT_LOG = PROJECT_ROOT / "runtime" / "logs" / "chat.log"
class NexusControlPanel:
@@ -109,10 +97,8 @@ class NexusControlPanel:
self.frontend_process = None
self.backend_process = None
self.memory_process = None
self._frontend_starting = False
self._backend_starting = False
self._memory_starting = False
self._closing = False
self._setup_custom_titlebar()
@@ -132,9 +118,6 @@ class NexusControlPanel:
if self._is_running(frontend_pid):
threading.Thread(target=self._monitor_frontend, daemon=True).start()
if self._is_running(MEMORY_PID):
threading.Thread(target=self._monitor_memory, daemon=True).start()
threading.Thread(target=self._monitor_synapses, daemon=True).start()
self.update_master_ui()
@@ -167,12 +150,11 @@ class NexusControlPanel:
def _init_log_tags(self):
for console in [self.sys_console, self.front_console, self.back_console, self.mind_console, self.mem_console]:
for console in [self.sys_console, self.front_console, self.back_console, self.mind_console]:
console.tag_config("SYSTEM", foreground="#ff00ea")
console.tag_config("FRONTEND", foreground="#61dbfb")
console.tag_config("BACKEND", foreground="#ffd43b")
console.tag_config("MINDTRACE", foreground="#cc88ff")
console.tag_config("MEMORY", foreground="#78e08f")
console.tag_config("ERROR", foreground="#ff0000")
console.tag_config("GPU_NVIDIA", foreground="#76b900")
console.tag_config("GPU_AMD", foreground="#ed1c24")
@@ -193,7 +175,7 @@ class NexusControlPanel:
self.root.geometry(f"+{self.root.winfo_x() + (event.x - self.x)}+{self.root.winfo_y() + (event.y - self.y)}")
def _clear_all_logs(self):
for console in [self.sys_console, self.front_console, self.back_console, self.mem_console, self.mind_console]:
for console in [self.sys_console, self.front_console, self.back_console, self.mind_console]:
console.delete("1.0", tk.END)
def _copy_selection(self, widget):
@@ -260,19 +242,13 @@ class NexusControlPanel:
self.btn_back_stop = tk.Button(controls, text="OFF", **STOP_STYLE, command=self.stop_backend)
self.btn_back_stop.pack(side=tk.LEFT, padx=2)
# Memory Service Controls
self.btn_mem_start = tk.Button(controls, text="MEMORY", fg="#78e08f", **START_STYLE, command=self.start_memory)
self.btn_mem_start.pack(side=tk.LEFT, padx=(8, 2))
self.btn_mem_stop = tk.Button(controls, text="OFF", **STOP_STYLE, command=self.stop_memory)
self.btn_mem_stop.pack(side=tk.LEFT, padx=2)
# Terminal Displays
sys_f, self.sys_console = self._create_terminal(self.root, " >> SYSTEM STATUS", height=5, text_color="#ff00ea")
sys_f.pack(fill=tk.X, padx=10, pady=(0, 8))
bottom_f = tk.Frame(self.root, bg="#1e1e1e")
bottom_f.pack(fill=tk.BOTH, expand=True, padx=10, pady=(0, 8))
for col in range(4):
for col in range(3):
bottom_f.columnconfigure(col, weight=1, uniform="term")
bottom_f.rowconfigure(0, weight=1)
@@ -280,10 +256,8 @@ class NexusControlPanel:
f_f.grid(row=0, column=0, sticky="nsew", padx=(0, 4))
b_f, self.back_console = self._create_terminal(bottom_f, " >> SYNAPSE (UVICORN)", text_color="#ffd43b")
b_f.grid(row=0, column=1, sticky="nsew", padx=4)
mm_f, self.mem_console = self._create_terminal(bottom_f, " >> MEMORY SERVICE", text_color="#78e08f")
mm_f.grid(row=0, column=2, sticky="nsew", padx=4)
m_f, self.mind_console = self._create_terminal(bottom_f, " >> MINDTRACE", text_color="#cc88ff")
m_f.grid(row=0, column=3, sticky="nsew", padx=(4, 0))
m_f.grid(row=0, column=2, sticky="nsew", padx=(4, 0))
def _safe_after(self, delay, func):
"""Schedule a Tk callback without ever raising.
@@ -305,7 +279,6 @@ class NexusControlPanel:
con = self.sys_console
if tag == "FRONTEND": con = self.front_console
elif tag == "BACKEND": con = self.back_console
elif tag == "MEMORY": con = self.mem_console
elif tag == "MINDTRACE": con = self.mind_console
con.insert(tk.END, f"[{tag}] {message}\n", tag)
con.see(tk.END)
@@ -358,16 +331,14 @@ class NexusControlPanel:
def update_master_ui(self):
if self._closing: # window may be destroyed; stop_* still calls this
return
f, b, m = self._frontend_is_active(), self._backend_is_active(), self._memory_is_active()
self.btn_master_start.config(state=tk.DISABLED if (f and b and m) else tk.NORMAL)
self.btn_master_stop.config(state=tk.NORMAL if (f or b or m) else tk.DISABLED)
f, b = self._frontend_is_active(), self._backend_is_active()
self.btn_master_start.config(state=tk.DISABLED if (f and b) else tk.NORMAL)
self.btn_master_stop.config(state=tk.NORMAL if (f or b) else tk.DISABLED)
self.btn_front_start.config(state=tk.DISABLED if f else tk.NORMAL, bg="#0b3d0b" if f else "#2d2d2d")
self.btn_back_start.config(state=tk.DISABLED if b else tk.NORMAL, bg="#3d3d0b" if b else "#2d2d2d")
self.btn_mem_start.config(state=tk.DISABLED if m else tk.NORMAL, bg="#0b2d14" if m else "#2d2d2d")
self.btn_front_stop.config(state=tk.NORMAL if f else tk.DISABLED)
self.btn_front_view.config(state=tk.NORMAL if f else tk.DISABLED)
self.btn_back_stop.config(state=tk.NORMAL if b else tk.DISABLED)
self.btn_mem_stop.config(state=tk.NORMAL if m else tk.DISABLED)
def open_frontend_view(self):
webbrowser.open_new_tab(FRONTEND_URL)
@@ -426,10 +397,6 @@ class NexusControlPanel:
self._frontend_starting = False
self.frontend_process = p
self._write_pid(FRONTEND_PID, p.pid)
elif name == "MEMORY":
self._memory_starting = False
self.memory_process = p
self._write_pid(MEMORY_PID, p.pid)
else:
self._backend_starting = False
self.backend_process = p
@@ -472,10 +439,6 @@ class NexusControlPanel:
self._frontend_starting = False
self.frontend_process = None
FRONTEND_PID.unlink(missing_ok=True)
elif name == "MEMORY":
self._memory_starting = False
self.memory_process = None
MEMORY_PID.unlink(missing_ok=True)
else:
self._backend_starting = False
self.backend_process = None
@@ -576,47 +539,13 @@ class NexusControlPanel:
self._terminate_pid_file(BACKEND_PID)
self.update_master_ui()
def start_memory(self):
if self._memory_is_active():
return
self._memory_starting = True
self.update_master_ui()
self.log("SYSTEM", "Starting MEMORY SERVICE...")
threading.Thread(target=self._worker, args=("MEMORY", MEMORY_CMD, MEMORY_DIR), daemon=True).start()
def stop_memory(self):
if self.memory_process:
self._terminate_process(self.memory_process)
self.memory_process = None
elif self._is_running(MEMORY_PID):
self._terminate_pid_file(MEMORY_PID)
self.update_master_ui()
def _memory_is_active(self):
return self._memory_starting or self.memory_process is not None or self._is_running(MEMORY_PID)
def _monitor_memory(self):
log_path = PROJECT_ROOT / "runtime/memory.log"
try:
with open(log_path, "r") as f:
f.seek(0, os.SEEK_END)
while self._is_running(MEMORY_PID):
line = f.readline()
if line:
self.log("MEMORY", line.rstrip())
else:
time.sleep(0.1)
except Exception as e:
self.log("ERROR", f"MEMORY monitor fault: {e}")
def start_all(self):
self.start_memory()
self.start_frontend()
self.start_backend()
def kill_all(self):
self.log("SYSTEM", "FORCE KILL — terminating all Nexus processes by port...")
ports = {8000: "SYNAPSE", 8001: "MEMORY", 5173: "INTERFACE"}
ports = {8000: "SYNAPSE", 5173: "INTERFACE"}
for port, name in ports.items():
try:
r = subprocess.run(["fuser", "-k", f"{port}/tcp"], capture_output=True, timeout=5)
@@ -628,21 +557,18 @@ class NexusControlPanel:
subprocess.run(["pkill", "-9", "-f", pat], capture_output=True, timeout=5)
except Exception:
pass
for pid_file in [FRONTEND_PID, BACKEND_PID, MEMORY_PID]:
for pid_file in [FRONTEND_PID, BACKEND_PID]:
pid_file.unlink(missing_ok=True)
self.frontend_process = None
self.backend_process = None
self.memory_process = None
self._frontend_starting = False
self._backend_starting = False
self._memory_starting = False
self._safe_after(0, self.update_master_ui)
self.log("SYSTEM", "Force kill complete.")
def stop_all(self):
self.stop_frontend()
self.stop_backend()
self.stop_memory()
def on_close(self):
if self._closing:
@@ -675,13 +601,13 @@ class NexusControlPanel:
except Exception:
pass
# Services the panel spawned itself (each in its own setsid group):
for proc in (self.frontend_process, self.backend_process, self.memory_process):
for proc in (self.frontend_process, self.backend_process):
if proc:
self._terminate_process(proc)
# Services attached via pid file (ncp-started, one shared group);
# _terminate_pid_file verifies ownership and unlinks. Guarantee the
# unlink even for a pid that's already dead so no stale files remain.
for pf in (FRONTEND_PID, BACKEND_PID, MEMORY_PID):
for pf in (FRONTEND_PID, BACKEND_PID):
if self._is_running(pf):
self._terminate_pid_file(pf)
else:
+2 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Launch NexusOS as a standalone Edge app window. Single-process mode: the
# backend on :8000 serves the built web UI itself (no separate Vite), so this
# only starts the memory service + backend. The AI (Ollama) does NOT auto-start
# only starts the backend. The AI (Ollama) does NOT auto-start
# — turn it on from the UI's Start AI button. Closing the app window shuts the
# services back down (matches the launcher's "closing the window shuts it down").
NEXUS_ROOT="$(cd "$(dirname "$(realpath "$0")")/.." && pwd)"
@@ -22,7 +22,7 @@ if curl -s --max-time 1 "$APP_URL/" >/dev/null 2>&1; then
OWN_SERVICES=0
else
OWN_SERVICES=1
# Single-process app: memory + backend only. Backend serves the built UI at
# Single-process app: backend only. Backend serves the built UI at
# :8000; no frontend/Vite process, no AI auto-start.
"$NEXUS_ROOT/management/nexus-cli.sh" start -m
"$NEXUS_ROOT/management/nexus-cli.sh" start -b