fix(app): arm the LLM cancel when a start is accepted; confirm stops by refusal

A stop right after a background start set the LLM's cancel flag, but the
start task then cleared it in Llm::start and went on to download and load
the model. The cancel is now armed in the controller's begin_start, under
its lock (Host::prepare_start -> Llm::arm), and Llm::start never clears
it; a start that finds it set returns before running anything.

wait_gone counted a timeout, a 503 (a server still loading) or an
unreadable answer as stopped, so a failed `launch --stop` could still mark
a live engine off. Only a refused connection confirms the stop now; the
rest keeps checking until the deadline and then reports failed.

Tests: a stop right after a background start runs no launch (and the next
start is not cancelled); a failed stop with a silent or 503 server leaves
the LLM and the services failed through the controller. Fixed-port tests
use an unused port.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 17:55:40 +09:00
parent 41026a1eff
commit 81ba5e3521
3 changed files with 155 additions and 26 deletions

View File

@@ -187,10 +187,13 @@ start it first, so nothing answers before the brain can, and stop it last.
on a 16 GB card, M0) and 2 when a chat channel answers every message, so its answers do not wait
behind voice answers. Pictures are off until something in v2 sends one. Stopping the services
runs `strata launch --stop` (ended after 2 minutes, with everything it started) and then checks
that the port no longer lists a model; so does a failed or cancelled start, so nothing
half-started keeps graphics memory. Stopped means nothing answers any more (a stop command that
fails while nothing answers counts as stopped); a server still answering makes the LLM `failed`
with the reason, and the stop or the start reports it. Not installed: the start fails and says to
that the port refuses connections; so does a failed or cancelled start, so nothing half-started
keeps graphics memory. Stopped means the port refuses connections (a stop command that fails
while it does counts as stopped); a timeout, an error status (a server still loading answers
503) or an answer that cannot be read is not a confirmed stop: the LLM is `failed` with the
reason, and the stop or the start reports it. The start's cancel is armed when the controller
accepts the start (`Host::prepare_start`), never by the start itself, so a stop between accepting
and running the start cancels it before Strata runs anything. Not installed: the start fails and says to
run the install.
- **A server the app does not start**: with `llm.url` (an OpenAI-compatible `/v1` address, in the
settings file only) the app starts nothing; that server must list a model within 30 seconds.
@@ -265,8 +268,9 @@ service starter, a stop while starting (cancelled, or finished and stopped again
channel answering everything, the download percentage, the brain's settings file, a given server
used without Strata, Strata missing, a fake Strata that reports progress, returns, serves and is
stopped, is cancelled during its download and cleared, or fails with its last line, a stop that
fails or hangs while the server still answers (failed, not off) and one that fails while nothing
answers (off); a background start that is starting at once, so a stop right after it cancels it
fails or hangs while the server still answers, holds connections silently or answers 503 (failed,
not off, also through the controller) and one that fails while the port refuses connections (off);
a stop right after a background start running no launch at all, and the next start not cancelled; a background start that is starting at once, so a stop right after it cancels it
and a second start is refused, also through the admin commands; a failed stop reported as failed; the brain's
config loaded without writing to the home folder, `tests/test_config_db_path.py`); the dashboard from made-up events (captions replaced and cleared, latency stages
and medians, an answer matched to its asker's final, missed requests without text); the admin