Repository navigation
fix: stop the local models on quit, uninstall and setup; process hygiene (0.1.4 F) - #238
oldwinter53 wants to merge 8 commits into
Conversation
0.1.0.dev40 replaces a Pi that cannot load extensions when the stack is applied again, reports it in setup binding as pi-extensions-unavailable, fails harness apply with RUNTIME_ACTION_FAILED or RUNTIME_EXTENSIONS_FAILED instead of exiting 0 after an incomplete install, refuses an unusable SIMPLEX_PI_PATH and a too-long Windows runtime root at plan time, reports GPU and free-memory shortfalls with byte figures, and stops the library Bifrost on stack down. - Pin 0.1.0.dev40 in the three desktop distributions and in scripts/installs/stack.sh and stack.ps1, copied from the published launchers; the three tool archives and both launchers were checked against the release's SHA256 and size. - Point the run-without-cloning URLs in scripts/installs/README.md at the pinned version, and sync the stack pins in scripts/install with scripts/sync-install-stack-pin.mjs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aves behind A start whose lease identity could not be proved left its supervisor and service running with no record, so PostgreSQL kept postmaster.pid and every Try Again failed until the processes were killed by hand. - When a start fails before its record is kept and the lease cannot be proved, end the process group of the supervisor it spawned and has not reaped yet; that PID cannot belong to another program. - On macOS and Linux, reclaimNativeOrphans now also ends a supervisor whose command line names a job file in the instance's process directory under a lease no record holds, once its environment proves the lease; the services step runs it before PostgreSQL starts, so a state an earlier release left heals on the next attempt. - Split the POSIX stop of one lease out of stopNativeProcess to share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en the stack is not ready A launch that found the local model stack not ready failed with LOCAL_MODELS_RECOVERY_REQUIRED and asked to review an updated plan, which the start failure page cannot do; Try Again failed the same way and Set Up Again was the only way out. A 0.1.3 Pi installed without extension support reports pi-extensions-unavailable from localmodels 0.1.0.dev40 the same way. - When the saved binding for the approved plan is not ready and the saved plan inputs still match, apply that plan again and bind once it verifies; changed inputs still need a new review. The binding's reason codes go out in details.reasons and to the installer log. - The desktop's start failure words the first known reason code and names the action that works for LOCAL_MODELS_RECOVERY_REQUIRED (Try Again) and LOCAL_MODELS_APPROVAL_REQUIRED (Set Up Again). - Map localmodels harness errors to structured failures: a refused harness plan (unusable SIMPLEX_PI_PATH, a Windows runtime root too long for Pi without long paths) is RUNTIME_PLAN_REFUSED, and RUNTIME_ACTION_FAILED and RUNTIME_EXTENSIONS_FAILED keep their codes through dependency preparation and into the failed job's errorCode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…all and setup A Bifrost gateway the localmodels model library started, and the engines of the models it loaded, survived a quit, an uninstall and a cleanup of the Linger folders: the stop the uninstaller runs asked only for `foundations stop` and `stack down`, which leaves library-loaded models running, and a quit stopped nothing. - stopLocalmodels first unloads every model `library status` reports loaded (`library unload <id> --base-dir <home models>`), then stops the controller and runs `stack down`, which with localmodels 0.1.0.dev40 also stops the library's Bifrost. Every step runs even when an earlier one fails; the error names each failed step by the library's error code. - The installer's new `--stop-local-models` mode does the same in every installation home for a quit, keeping the model controller that the still-running services use. - On a quit the person chose, LocalServer starts that mode detached under ELECTRON_RUN_AS_NODE with its output in <home>/installer/ local-models-stop.log and does not wait. Updates, relaunches and the `--quit` of setup or the uninstaller skip it: they stop the models themselves right after, and a second `stack down` would race theirs for the stack lock. The next launch's resume applies the approved plan again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… reason
computer_daemon.exited kept the daemon's last stderr line as its reason,
and the start failure showed it. After a kill or a crash that was usually a
log record from minutes earlier ("2026/11/17 20:29:38 INFO
runtime.diagnostic ...") or the last frame of a Go stack trace.
The reason is now the last line outside the daemon's log records, which
carry Go's log prefix and a level, and a Go runtime crash keeps its
panic or fatal error line. A daemon that printed nothing else has no
reason, and the failure falls back to its exit code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…private path check fails After Linger ran elevated once, files it wrote there (config.json, native.env.*.tmp) belong to Administrators, and the next normal start failed with "Windows private path validation failed" without naming the file or the cause. The ACL program now throws fixed UPPER_SNAKE reason codes and prints only such a code when it fails, never a system message. The error names the resolved path and words the reason, and carries code WINDOWS_PRIVATE_PATH_UNSAFE with reason and path; an output that is not one of the codes is UNCHECKED. The Windows-only native tests now assert the reason for a junction, a junction ancestor and shared access. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…is damaged Resume unpacks the source package when the recorded folder is not one the installer accepts, but a folder with this package's hash and its marker file counted as already unpacked even with package.json or other files gone. Every start then failed with "Source checkout must be a Linger checkout with scripts/source-native.mjs." and Try Again did the same. The folder now counts as unpacked only when the installer's own check accepts it; otherwise it is removed and the package unpacked again in its place, logged as local_server.source_damaged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ocalized start time Linger 0.1.2 recorded each macOS service's birth from ps lstart in the locale it ran in. Since 0.1.3 every check reads lstart in the C locale, so on a Mac with, for example, a German region format the services 0.1.2 left running never matched their records again, and the upgraded app reported their identity as unverifiable until they ended. A darwin record whose birth is not in the C-locale shape is now checked once more with ps in the installer's own locale. When that prints the recorded birth for the live group leader holding the record's lease, the record takes the C-locale birth, once; otherwise it is left as it is and proves nothing, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approve with nits (1 P2, 1 P3)
Scope: base main, merge base 080cbcf9; 8 commits / 39 files in range, focused on the last five (the first three are #236's, which is still open). Loaded ponytail-review (sections 1–3); coderbook and karpathy-guidelines were not loaded and their checks were applied from the review brief. Reviewed head 37e3f207 in a separate session.
Findings
P2
apps/desktop/src/main/local-server.ts:532 (#stopLocalModels): the detached quit stop is not coordinated with the next launch or with a running install job
- On quit, a detached
installer.js --stop-local-modelsrunslibrary status, then alibrary unloadfor each loaded model (each with a 30 s timeout), thenstack down. Nothing stops it from overlapping with the next launch. - Failure scenario: the person quits, then reopens Linger within a few seconds.
#resumeruns--resume. InprepareLocalModels(packages/local-installation/src/local-models.ts, thedeployedbranch),observe()still sees the binding asreadybecause the old stop has not reachedstack downyet. The resume therefore returns without applying the plan. The old process then runsstack down, so the local models and the Bifrost gateway stay down for the whole session, with no error shown. The PR says the next launch "applies the approved plan again", but that only holds if the stop has already finished. - A second case: the installer manager keeps running a started job after the app quits (the comment in
stop()). If that job is instack applywhen the person quits, the quit stop unloads models and runsstack downat the same time. - Fix: make the two exclusive. One option is a lock or marker file under
<home>/installerthat the stop holds and that--resume/apply waits on (or that the resume treats as "not ready, apply again"). Another is to skip the quit stop when the manager reports a running job. At the least, document the window as a known shortcut.
P3
packages/local-installation/src/windows-private.ts:107,121: exported error code and reason type have no consumer
WINDOWS_PRIVATE_PATH_UNSAFE,WindowsPrivateReason, and thecode/reason/pathfields set on the error are not read anywhere outside tests (git grep). Only the message text reaches the user.- Fix: keep the reason map private and throw a plain
Errorwith the worded reason. Add the structured fields when a caller actually branches on them.
Verified as fine
stopLocalmodels: every step runs even after an earlier failure. An abort still throws. Model ids fromlibrary statusare filtered with a strict pattern before they go to argv. A missing or invalid model list is reported, not ignored.keepControllerskips onlyfoundations stop.stopDesktopLocalModelsreuses the extractedattemptshelper, so there is no duplicate try/record loop.--stop-local-modelsis correctly excluded from the legacy migration and from the--source-reporequirement.index.ts: a--quitfrom a second instance (setup or the uninstaller) maps to the"update"stop reason, so the quit stop does not race their--stop. Updates and relaunches skip it as well.- The log fd is opened
0o600and closed after spawn.windowsHide,detachedandunrefare set. The stop is skipped when there is no local-server record or no installer script. computer-daemon.ts:LOG_RECORDmatches the daemon's defaultslogoutput (logLstdFlags prefix plus level). The daemon sets no other default handler. After apanic:/fatal error:line, the trace no longer overwrites the reason.windows-private.ts: only an exact match against the known reason codes is printed, so no system message leaks. Unknown output maps toUNCHECKED.#ensureSource: a damaged package folder is removed and extracted again. A valid one keeps the old fast path. Both callers (install and resume) benefit.adoptLegacyDarwinBirth: it converts only when the C-locale identity is live (leader holding the lease) and inherited-localepsprints exactly the recorded birth. The write is atomic and idempotent across concurrent readers. It only runs on darwin for records whose birth is not in C format.- Tests cover each item (unload loop, partial failures, quit spawn and skip reasons, damaged source, log or panic reason, Windows reason codes, legacy darwin adopt plus two negative cases). AGENTS.md files for desktop, installer and local-installation are updated.
Process notes
- This PR is stacked on #236, which is still open. Merge #236 first, then rebase this branch down to its five commits.
- No merge commits and no fixup commits in the range.
CI
Still running at review time: check (desktop), check (installer), check (packages), check (teamhub-cli), repository-gate, web-static, web tests. changes and CodeQL pass. Merge state is BLOCKED (checks pending, and #236 is a dependency). No tests were run locally; none were needed to confirm the findings, which come from the code.
Automated review by Claude Code
Automated review of 37e3f20 by Claude Code.
0.1.4 fix list group F: process hygiene, and P2-6 (Linger part). When the person quits Linger, uninstalls it, or cleans up after a quit, the Bifrost gateway the localmodels model library started is stopped, and so are the engines of the models it loaded. Until now both kept running.
Depends on #236 (pins localmodels 0.1.0.dev40, and on a launch that finds the stack not ready, applies the approved plan again). This branch is based on
oldwinter/014-bc2, so its first three commits are #236's. Review only the last five. Once #236 merges, this rebases to just those five.What changes
library status, thenlibrary unload <id>for everyloadedmodel, thenfoundations stop(uninstall and setup only), thenstack down. With dev40,stack downalso stops the library's Bifrost. Every step runs even when an earlier one fails, and failures are reported by the library's error code.packages/local-installation/src/localmodels-tool.tsstopLocalmodels--stop-local-modelsfor a quit: it unloads the library's models and stops the stack in every installation home. The model controller keeps running, because the services that use it keep running too.apps/linger-installer/src/server/stop.tsstopDesktopLocalModels,src/main.tsLocalServerstarts that mode detached (ELECTRON_RUN_AS_NODE), writes its output to<home>/installer/local-models-stop.log(already in the diagnostics zip), and does not wait for it. It runs only whenlocal-server.jsonnames an installation. It is skipped for updates, relaunches, and the--quitthat setup or the uninstaller sends, because they run--stopright after and a secondstack downwould race theirs for the stack lock.apps/desktop/src/main/local-server.ts#stopLocalModels,index.tspanic:line. If no other line was printed, there is no reason and the failure shows the exit code.apps/desktop/src/main/computer-daemon.tscode: WINDOWS_PRIVATE_PATH_UNSAFEwithreasonandpath.packages/local-installation/src/windows-private.tslocal_server.source_damaged).apps/desktop/src/main/local-server.ts#ensureSourcelstartis converted once to the C-locale birth. The conversion happens only whenpsin the installer's own locale prints exactly the recorded birth for the live group leader holding the lease. Otherwise the record stays as it is and proves nothing, as before.packages/local-installation/src/native-process.tsadoptLegacyDarwinBirth,native-process-identity.tsDeferred:
close_rangeon Linux, a handle list on Windows) in front of every service start. Too risky for 0.1.4.library cancel), onlyloadedones are unloaded.User wait / critical path
This doesn't touch the user message →
provider_readypath. A quit adds one detached process start and does not wait for it. The uninstall stop addslibrary statusplus onelibrary unloadper loaded model (about 2–3 s in the runs below).Verification
Tests were written first and failed before each fix:
localmodels-tool.test.ts(4 failing),stop.test.ts,local-server.test.ts(quit stop, damaged source),computer-daemon.test.ts(3 failing: an INFO line after a kill, a log record after the error line, a panic trace),windows-private.test.ts(4 failing), andnative-process-darwin-legacy.test.ts(adopt fails before the fix; the two negative cases keep the record).make check BASE=origin/main: check-repository, check-docs, check-packages, check-teamhub-cli, check-installer, check-desktop, check-scripts-fast and check-web all pass.make check-repository-gate BASE=origin/main: passes.windows-private.native.test.tsnow asserts the reasons for a junction, a junction ancestor and shared access. It runs only on Windows and was not run here.Real machines (real processes)
Each run used the built
installer.jswith the dev40 pin from this branch'sdistribution/<target>.json, in an isolated home. The kit came from the real dev40 download. A model was loaded through the localmodels library inLOCALMODELS_DEBUG=simulatemode, which runs the real Bifrost binary (on an isolated free port) in front of a stub engine. That way no GPU was needed and nobody's running stack was touched.foundations stopthenstack down, dev40)stack downreports "models the library loaded keep running without the gateway". The engine is left running.--stop-local-models(quit)--instance desktop --stop(uninstall)--stop-local-modelson the pinned Node 26.5Linger.exewithELECTRON_RUN_AS_NODE:--instance desktop --stop(uninstall), then load again and--stop-local-models(quit)bifrost-http.exe+ engine, both timesNot checked on a real machine:
local-server.test.ts, which spawns a real child process.For the 0.1.4 RC pass:
pgrep -fl "bifrost|llama-server"should then be empty. Relaunch: the stack comes back.bifrost-http.exeshould be left.pkill bifrost/pkill llama-serverlines in it should find nothing.🤖 Generated with Claude Code