fix(app): performance stage switches survive failures, reconnects and late signals

- the normal stage reads other programs' memory afresh (the card after the LLM stopped, less the
  STT worker's model) and keeps it; the game stage counts from the latest normal reading, so the
  game is not counted against its own reserve
- a restart that fails brings back the stage that ran before and tells the brain ready; the
  failed stage is tried again after 60 s, three times at most; when nothing comes back the brain
  is told paused so requests fail at once
- the worker client keeps the latest llm state and sends it first on every connection
- switches are numbered: llm switching carries an id, llm_idle names it, and a late idle of an
  earlier switch no longer lets a new one through
- a request that waited 180 s for a switch fails without calling the brain
- the dashboard shows the stage that runs also on a fallback placement without experts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-14 10:34:24 +09:00
parent 7e096b449e
commit aa6d950af6
10 changed files with 374 additions and 87 deletions

View File

@@ -353,15 +353,23 @@ between the normal placement and the game placement as games come and go (not wi
- A change: the brain is told the LLM switches, with a notice for the first spoken request that
waits ("잠깐만요, 게임 모드로 바꾸는 중이에요", or "잠깐만요, 평소 모드로 돌아가는 중이에요" on the way
back; `voice_worker.spec.md`, "LLM switches"); the app waits until the brain has written the
answers in progress (at most 2 minutes), restarts the LLM in the new stage and tells the brain
it is ready (or paused). A restart that fails leaves the LLM `failed` on the dashboard and the
brain ready (its calls then fail); the stage is not tried again until the wanted stage changes.
answers in progress (at most 2 minutes; the switch is numbered, so an idle report for an earlier
switch that came late does not count), restarts the LLM in the new stage and tells the brain it
is ready (or paused). The worker client keeps that latest state and sends it again on every
connection. A restart that fails brings back the stage that ran before and tells the brain
ready; the failed stage is tried again after 60 s, three times at most, then not until the
wanted stage changes. When the stage before does not come back either, the LLM shows `failed`
and the brain is told paused (requests fail at once instead of waiting).
- The game stage: context 16,384 (or the settings' smaller one), one request at a time, half the
engine's CPU threads (read from its log at the normal start, else a quarter of the logical CPUs),
and the game placement (`placement.rs`: the reserve beside more than 2 GiB of experts, else
2 GiB, else 0 GiB, else pause), measured once at that context like the normal one. Every
placement of a run counts other programs' memory as it was when the services started (before
the LLM and the STT worker), not from a card that then also holds the worker and the game.
2 GiB, else 0 GiB, else pause), measured once at that context like the normal one. Other
programs' memory is what the card holds after the LLM stopped, less the STT worker's model while
it is loaded (1300 MiB); the normal stage reads it afresh each time (programs opened since
count) and keeps it; the game stage takes the one kept at the latest normal placement, as the
card then also holds the game, which its reserve is for (a game already running when the
services start is counted in it, which only leaves the LLM less). The dashboard shows the stage
that runs, also on a fallback placement without experts.
- Pause: the LLM stops (`llm` off, "게임 중 일시정지"); the brain answers nothing until the stage
changes.
- The foreground program is a game, in this order: in `notGames`: no; in `games`: yes
@@ -598,8 +606,12 @@ a path with non-ASCII letters) or from a Battle.net game's install folder (a tes
turns game mode on with its name and off once it ends. Performance stages (on every system, with a fake
Strata and card): a game moves the LLM to the game placement (measured once at 16K and one request,
2 GiB on the game PC's numbers, half the 16 engine threads) and back after the wait, pause stops
it, a card with no room for a game pauses, and the stage loop tells the brain switching (with the
notice), waits, restarts and tells it ready, also on the way back. On every system: game detection's rules
it, a card with no room for a game pauses, the normal stage counts a program opened since and the
game stage does not count the game twice, a fallback game placement still shows as the game
stage, and the stage loop tells the brain switching (with the notice), waits, restarts and tells
it ready, also on the way back; a game stage that cannot start goes back to normal each time and
is tried three times. The worker client ignores a late idle of an earlier switch and sends the
latest LLM state first when a worker connects again. On every system: game detection's rules
(a borderless game, a maximised program, a browser's full-screen video, exclusive full screen,
launcher folders and their own windows, Battle.net games by install folder and their uninstall
entries, non-ASCII paths, the person's lists first, staying on until the game ends,