Repository navigation
fix(installer,desktop): surface localmodels kit errors on resume and preserve upgrade retry (WHI-1299) - #1197
oldwinter53 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Approve with nits (4 P2, 1 P3) · merge base 9ef0028 · 1 commit, 6 files
Findings
P2
-
apps/desktop/src/main/local-server.ts:5446—#cancelBackgroundReconcile()leaves#reconcileHasPendingRuntimeRefreshstucktrue.#reconcileAfterFastReadysets#reconcileHasPendingRuntimeRefresh = trueat line 5562 and only clears it insideif (this.#reconcileAbort === controller)infinally(lines 5630–5633). Because#cancelBackgroundReconcile()clearsthis.#reconcileAbort = undefinedbefore the aborted task reachesfinally, that guard always evaluates tofalseon cancellation. If an in-flight runtime-refresh reconcile is cancelled viasuspendRecovery(),server.changed,#reset(),begin(), or#resumeInner()and the installation then becomes healthy without another uncancelled background reconcile (for example via unreachable#resumeInner()recovery or reset + fresh install, or after switching to a remote server where#phaseremains"ready"), every subsequentsuspendRecovery()/release()cycle sees#reconcileHasPendingRuntimeRefresh === true(line 3337) and schedules a spurious#scheduleRuntimeRefreshRetry(1)(line 3386). Fix: setthis.#reconcileHasPendingRuntimeRefresh = false;inside#cancelBackgroundReconcile()(everysuspendRecovery()call site already reads the flag before cancelling). -
apps/desktop/src/main/local-server.ts:6912—canonicalDirectoryduplicatescanonicalPathin the same file. Lines 6912–6918 implementrealpath(directory)with apath.resolve(directory)fallback, which is identical tocanonicalPathat line 7213. Fix: deletecanonicalDirectoryand callcanonicalPathat lines 6213, 6215, and 6225. -
apps/linger-installer/src/main.ts:359— URL query/fragment stripping + redaction is duplicated across two apps. Lines 359–363 copy the exact two regexes andredact()call fromapps/desktop/src/main/local-server.ts:6559–6565, while both apps already importredactfrom@linger/local-installation/redaction(packages/local-installation/src/redaction.ts:2). Fix: extract a shared helper inpackages/local-installation/src/redaction.tsand call it from bothapps/linger-installer/src/main.tsandLocalServerModule.#formatResumeError. -
apps/desktop/src/main/local-server-resume.test.ts:3759— Timer race and sleep assertion in thesuspendRecoverypause/resume test. Line 3759 setsruntimeRefreshRetryDelaysMs: [60], then lines 3769–3776 poll forlocal_server.runtime_refresh_retry_scheduledviawaitForInstaller(apps/desktop/src/main/test-support.ts:87, which uses Vitest's default 50 msvi.waitForpolling interval) before callingsuspendRecoveryat line 3777 and sleeping 120 ms at line 3779. Under minor CI or Windows scheduling jitter (> 10 ms past a 50 ms poll tick), retry 1 fires beforesuspendRecoveryruns and flakes thecounterFile === 1assertion. Fix: increase the retry delay (or triggersuspendRecoverydirectly on the scheduled log event / poll with a small interval) sosuspendRecoverydeterministically runs before the timer can fire.
P3
apps/desktop/src/main/local-server.ts:6183—#expectedLocalmodelsKitignoresprocess.env.LINGER_APP_VERSIONoverrides.#daemonEnv()(line 2238) preserves an existingLINGER_APP_VERSIONinenvfor theinstaller.js --resumesubprocess, whereas#expectedLocalmodelsKitalways passesawait this.#resolveAppVersion(). IfLINGER_APP_VERSIONis overridden in the environment to a version that makesactive.jsoncompatible for the child while#resolveAppVersion()considers it incompatible, Desktop flags a falsekit_mismatchon every retry. Fix: passeffectiveLingerAppVersion(env)from theenvalready constructed in#runResume(line 6273) into#expectedLocalmodelsKit.
Checked: read-only active.json resolution (packages/local-installation/src/localmodels-active.ts:1721) · finally timings on lookup throw (apps/linger-installer/src/server/instance-runtime.ts:116) · daemon idle restart on computer.runtime (apps/desktop/src/main/computer-daemon.ts:427)
Process: needs rebase onto main (1 commit behind)
CI: passed (7/7 required checks)
Automated review of 7142b9f by Antigravity.
7142b9f to
04c306c
Compare
|
Addressed all 5 findings from the automated review and rebased onto
|
There was a problem hiding this comment.
Approve with nits (1 P3) · follow-up on 7142b9f · merge base 13ebbbe · 2 commits, 8 files
Resolved: clear pending reconcile flag (local-server.ts:5452) · reuse canonicalPath (local-server.ts:6219) · shared redactWithUrlStrip (redaction.ts:20) · deterministic suspendRecovery retry test (local-server-resume.test.ts:3780) · honor LINGER_APP_VERSION override (local-server.ts:6511)
Findings
P3
apps/desktop/src/main/local-server-resume.test.ts:3890— The newLINGER_APP_VERSIONoverride test duplicates ~115 lines of signedactive.jsonandtool.jsonfixture setup verbatim from lines 3440–3554 (differing only inkeyIdandminLingerVersion), so futureACTIVE_KIT_RECORD_SCHEMAor manifest schema updates must be edited in two places. Fix: extract a localwriteSignedActiveKitFixture(home, { minLingerVersion })helper shared by both tests.
Checked: installer distribution.json loading (apps/linger-installer/src/main.ts:901,924) · manifest safeRelative path depth (packages/local-installation/src/localmodels-tool.ts:120,246) · suspendRecovery retry handoff (apps/desktop/src/main/local-server.ts:3333,5473,5520)
Process: squash the review-fixup commit 04c306c into 70b58af before rebase-merging onto main
CI: passed (9/9 checks)
Automated review of 04c306c by Antigravity.
…preserve upgrade retry Surface instanceRuntime() rejections during headless --resume as a redacted runtimeError field (via shared redactWithUrlStrip) with resume.log and stderr logging while keeping exit 0 so resumed services stay usable. In LocalServerModule, log local_server.resume_runtime_failed with expected vs active localmodels kit hashes (resolved read-only via resolveEffectiveToolSource with effectiveLingerAppVersion so newer signed active.json kits are never downgraded), persist runtimeRefreshPending in desktop/local-server.json until adoption succeeds, and run bounded background retries without blocking startup. Fixes WHI-1299
04c306c to
cf26cfe
Compare
|
Extracted the shared |
There was a problem hiding this comment.
Approve · follow-up on 04c306c · merge base 13ebbbe · 1 commit, 8 files
Resolved: duplicated signed kit fixture setup (local-server-resume.test.ts:3067,3580,3922)
Checked: read-only active.json resolution (packages/local-installation/src/localmodels-active.ts:1701,1721) · timings on instanceRuntime throw (apps/linger-installer/src/server/instance-runtime.ts:116) · suspendRecovery retry handoff (apps/desktop/src/main/local-server.ts:3333,5473,5520)
CI: passed (9/9 checks)
Automated review of cf26cfe by Antigravity.
Fixes WHI-1299
What and why
On macOS (
darwin-arm64), desktop bundles do not embedbundled-localmodels-kit.tgzbecause of Apple notarization rules, so upgrades rely oninstaller.js --resume --external-computer(instanceRuntime()) to download and verify the newly pinnedlocalmodelskit when pre-download did not run or failed.Previously,
--resumeswallowedinstanceRuntime()rejections with.catch(() => undefined)(logging nothing toresume.logorstderrand omitting any error from stdout JSON), whileLocalServerModulesilently leftconfig.jsonon the stalelocalmodelskit and moveddesktop/local-server.jsonforward without warning or retry.Changes
apps/linger-installer/src/main.ts(--resumepath):.catch(() => undefined)oninstanceRuntime(...).Runtime lookup failed: <error>to bothresume.logandprocess.stderr, and emitsruntimeErrorin the stdout JSON outcome alongsideruntimeLookupTimingsandresumeTimingswhile still exiting0so resumed services stay usable.apps/desktop/src/main/local-server.ts(LocalServerModule):runtimeErrorfrom--resumestdout JSON and compares the active kit inconfig.runtimeEnvironmentagainst the expected kit resolved read-only viaresolveEffectiveToolSource(..., { retireStale: false })(respecting newer verified signed<home>/tools/localmodels/active.jsonkits so independently upgraded kits are never downgraded, and skipping kit checks underLINGER_LOCALMODELS_DEV_*overrides).local_server.resume_runtime_failednaming the redacted error and expected vs active kit hashes/version/origin wheneverruntimeErroris present or the expected kit was not adopted.runtimeRefreshPending: trueindesktop/local-server.json(backward compatible; omitted on healthy records) so subsequent launches keep retrying via non-blocking fast-ready background reconciliation or cold resume until adoption succeeds, then clears it and logslocal_server.runtime_refresh_recovered.30s,120s,300s) that are aborted cleanly onstop(),#reset(),server.changed,begin(),blockForManualRecovery(), and paused/resumed acrosssuspendRecovery().How it was verified
apps/linger-installer/src/main.test.ts(27 passed, including redactedruntimeErrorlogging/stdout and empty-message fallback)apps/desktop/src/main/local-server-resume.test.ts(68 passed, including upgraderuntimeError+ bounded retry recovery, retry exhaustion + cross-launch non-blocking fast-ready recovery, older installer silent kit mismatch detection, newer signedactive.jsonpreservation without downgrade, normal bundled kit adoption,LINGER_LOCALMODELS_DEV_*bypass, andsuspendRecoverypause/resume)make check-repository BASE=origin/main(env inventory, Prettier formatting, English-only check)make check-docs BASE=origin/main(131 Markdown files, changelog valid)make check-installer BASE=origin/main(typecheck, eslint--max-warnings=0, 31 test files)make check-desktop BASE=origin/main(typecheck, eslint--max-warnings=0, 79 test files / 1266 tests, 41 Python packaging tests,build-daemon.mjs --all)commitlint --from origin/main --to HEADcontracts/openapi/changed (N/A — no OpenAPI contract files changed)Boundary
apps/linger-installer/AGENTS.mdandapps/desktop/AGENTS.mdto document--resume'sruntimeErrorcontract,local_server.resume_runtime_failed,runtimeRefreshPending, and bounded background retries.apps/computer/(Go daemon).provider_readypath and adds no network round trip or file walk on the desktop fast-ready critical path (expected-kit checks and retries run only after--resumecompletes or asynchronously in the background).