fix(local-model): ask the launch guard before every start of an agent on the managed endpoint

Only the two session routes asked launchRefusalMessage(). The attach that
finds no pane, the respawn of a dead pane (a click on the tab, a respawn
start, the boot recovery), restartCli() and the reboot-restore rebuild
started an agent on the endpoint unasked. Session gains setLaunchGuard(),
asked right before a NEW agent process is started and never for an attach to
an agent that runs; WebServer.setupSessionListeners() sets it for every
session; a refusal is a LaunchRefusedError that never falls back to a direct
PTY. The reboot-restore route asks before it builds and skips the entry with
its own reason, left on offer.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-11-06 23:54:46 +01:00
1 parent fa978008d2
commit 3c4bb91d6f
7 files changed
+380 -2

No files matched your search

+7 -2
View File
@@ -1,6 +1,7 @@
/**
* @fileoverview The launch guard of the endpoint the local model install manages: both ways a
* session gets onto a custom model endpoint ask the install service first.
* @fileoverview The launch guard of the endpoint the local model install manages, at the two
* routes that put a session onto a custom model endpoint: they ask the install service before
* anything is written.
*
* - `POST /api/sessions/:id/custom-model` (a running session switches to the endpoint), and
* - `POST /api/quick-start` with `customModel` (a session is created on it)
@@ -11,6 +12,10 @@
* model whose digest is no longer the one stored at install time is not launched, and how
* nothing is launched against a port our runtime is not on.
*
* Every OTHER way a new agent process comes to be on the endpoint (the attach that finds no
* pane, the respawn of a dead pane, a restart in place, the rebuild after a reboot) is
* covered below the routes, by `Session`'s launch guard: test/local-model-session-launch-guard.test.ts.
*
* The service is replaced by a fake for most cases, and is the REAL one (over the real state
* file, with no runtime running) for the cases that pin the default wiring.
*