feat(app): performance stages move the LLM between the normal and the game placement

- while the services run, game mode decides the stage (perf.rs): a game means the game stage at
  once (or pause with game.pauseInGame); its end brings the normal stage back after
  game.revertSeconds (default 30)
- a change tells the voice worker the LLM switches (llm switching, with a notice), waits until
  the brain has written the answers in progress (llm_idle, at most 2 minutes), restarts the LLM in
  the stage and tells the worker it is ready or paused
- the game stage runs at 16K context, one request at a time, half the engine's CPU threads and
  the game placement (reserve game.reserveGb, default 8, else 2 GiB, else 0 GiB, else pause),
  measured once at that context; every placement of a run counts other programs' memory as it
  was when the services started
- the voice worker gates every LLM use: on switching new work waits (at most 180 s), the first
  spoken request that waits hears the notice once under its own id, on ready all go on, on
  paused nothing is answered
- dashboard: "성능 단계: 게임 중 · 게임에 X GB" / 일시정지; game mode screen: game VRAM, revert
  wait, pause in game

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-14 10:23:21 +09:00
parent b6bd1be6fb
commit 7e096b449e
18 changed files with 746 additions and 68 deletions

View File

@@ -348,6 +348,29 @@ still deleted (below).
- Each run is a `notice` line (category `voice_worker`): the target's name and how many new items, or
a `Warning` with the error's type. Never a URL, words or collected text.
### LLM switches (M7)
The app restarts the LLM with another placement when a game starts or ends (app/src/admin.spec.md,
"Performance stages"). It tells the worker first and waits for the brain to be idle:
```
-> {"type": "llm", "state": "switching", "notice": "잠깐만요, 게임 모드로 바꾸는 중이에요"} // notice optional
<- {"type": "llm_idle"} // nothing that uses the LLM runs any more
-> {"type": "llm", "state": "ready"} // the LLM answers again
-> {"type": "llm", "state": "paused"} // the LLM is stopped (a game runs)
```
- Brain work that uses the LLM (`reply`, `prepare`, `addressed`, `rank`) counts as running from its
start to its end. On `switching` new work waits; `llm_idle` goes to the connection that sent
`switching` once nothing runs (at once when nothing does). On `ready` what waited goes on.
- The first spoken `reply` that waits during one switch hears the notice under its own id (its
answer follows in the same speech when ready); later ones wait without it. A notice ends with a
newline, so it is spoken at once and never joined to the answer. A request waits at most 180 s,
then goes on (its LLM call fails on its own if the LLM is still away).
- On `paused` brain work answers nothing at once (`reply_text` `failed`, judgements failed) until
`ready`; what waited for a switch stops waiting the same way.
- Any other `state`, or a notice that is not a string, is `bad_message`.
### Errors
`{"type": "error", "code": "...", "message": "...", "id": "..."}`. Codes: `bad_message` (unknown type,