Privilege split 7/11: launch the LLM servers as plain child processes

- kurgan/ai/launcher.py: the app is unelevated now, so the servers are
  started with CreateProcessW, still suspended into their own kill-on-close
  job object and with an explicit handle list (only the log and NUL are
  inherited). Gone: the copy of Explorer's token (CreateProcessWithTokenW),
  the Safer "normal user" token and CreateProcessAsUserW, and with them the
  AI service's wait for the desktop at logon.
- launch() refuses (PermissionError) if The Kurgan itself is elevated, rather
  than pass admin rights on to a model server; this also covers opening the
  browser.
- Tests: the handle list is checked for real (an inheritable, unlisted handle
  doesn't reach the child; a control run without the list leaks it), and an
  elevated app starts nothing. The launch tests skip when the suite itself
  runs elevated.
- The UI's server token label and the README's launcher paragraph follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
paulandClaude Opus 5.5 committed 2026-12-05 19:44:47 +13:00
1 parent eb771656fb
commit e583e25346
5 files changed
+76 -168

No files matched your search

-6
View File
@@ -121,7 +121,6 @@ class AiService:
self.action: str | None = None # "Loading model..." while a load/unload request runs
self.message: str | None = None
self._stop: threading.Event | None = None
self._born = time.monotonic()
def set_public_url(self, url: str) -> None:
"""The Kurgan's web server, which the links in the UI point to."""
@@ -356,11 +355,6 @@ class AiService:
return
if time.monotonic() < slot.hold_until:
return
# At logon The Kurgan can be up before Explorer; give the desktop up to 2 minutes so the
# server gets the desktop's own token (see launcher.py) rather than the fallback.
if time.monotonic() - self._born < 120 and not launcher.desktop_ready():
self.transition = f"Waiting for the desktop to start {slot.backend.label}"
return
problem = slot.backend.check_files()
if problem:
slot.error = problem