Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(local-installation): replace a service left running by a killed supervisor
claude-opus-5-5-medium70c3b7c8dfc2
diff --git a/packages/local-installation/AGENTS.md b/packages/local-installation/AGENTS.mdindex 5f71874b..fc628bc0 100644--- a/packages/local-installation/AGENTS.md+++ b/packages/local-installation/AGENTS.md@@ -104,6 +104,11 @@ earlier release's TeamHub or web still on the port would otherwise pass thehealth check for a service that could not bind, and a port held by anotherprogram fails the start after 15 seconds instead of at the deadline.+On POSIX, a start that finds the recorded supervisor gone but processes+still carrying its lease (the app was killed with it) ends them as a stop+does and starts the service again. A live recorded PID or process group+without the lease proves nothing and is refused, never signalled.+Move a freshly downloaded or unpacked file or folder into place with`renameRetrying` from `fs-retry.ts`: on Windows antivirus and indexing holdnew files for a moment, and a plain rename then fails with EPERM.diff --git a/packages/local-installation/src/native-process.test.ts b/packages/local-installation/src/native-process.test.tsindex e89e8335..341440f2 100644--- a/packages/local-installation/src/native-process.test.ts+++ b/packages/local-installation/src/native-process.test.ts@@ -99,6 +99,7 @@ test("refuses to signal a PID whose recorded lease differs", async () => {await writeFile(file, JSON.stringify(altered), { mode: 0o600 });expect((await inspectNativeProcess(root, "web")).running).toBe(false);await expect(stopNativeProcess(root, "web")).rejects.toThrow(/identity/i);+ await expect(startNativeProcess(options)).rejects.toThrow(/identity/i);expect(() => process.kill(processState.pid!, 0)).not.toThrow();await writeFile(file, original, { mode: 0o600 });});@@ -187,6 +188,43 @@ test("stops descendants that ignore SIGINT after the service leader exits", asynawait expect.poll(() => exited(pid)).toBe(true);}, 20_000);+test.skipIf(process.platform === "win32")(+ "replaces a service whose supervisor was killed with the app",+ async () => {+ const root = await fixture();+ const options = {+ root,+ name: "web" as const,+ executable: process.execPath,+ args: [+ "-e",+ "require('node:fs').writeFileSync('service.pid',String(process.pid));setInterval(()=>{},1000)",+ ],+ cwd: root,+ env: process.env,+ };+ const first = await startNativeProcess(options);+ await expect+ .poll(async () =>+ readFile(path.join(root, "service.pid"), "utf8").catch(() => ""),+ )+ .not.toBe("");+ const orphan = Number(+ await readFile(path.join(root, "service.pid"), "utf8"),+ );+ await rm(path.join(root, "service.pid"));+ process.kill(first.pid!, "SIGKILL");+ await expect.poll(() => exited(first.pid!)).toBe(true);+ expect(exited(orphan)).toBe(false);++ const second = await startNativeProcess(options);+ expect(second.pid).not.toBe(first.pid);+ await expect.poll(() => exited(orphan)).toBe(true);+ expect((await inspectNativeProcess(root, "web")).running).toBe(true);+ },+ 20_000,+);+test("cleans the launched owned group when identity persistence fails", async () => {const root = await fixture();failure.file = path.join(root, "native/processes/web.json");diff --git a/packages/local-installation/src/native-process.ts b/packages/local-installation/src/native-process.tsindex 66faa460..709c3b7c 100644--- a/packages/local-installation/src/native-process.ts+++ b/packages/local-installation/src/native-process.ts@@ -249,11 +249,14 @@ export async function startNativeProcess(options: {// which reuses PIDs quickly.await stopNativeProcess(options.root, options.name);} else if (existing) {- if (- (await stillLive(existing.pid)) ||- (await groupLive(existing.pid)) ||- (await nativeLeaseProcesses(existing.lease)).length- )+ // A supervisor killed with the app (a forced quit, a crash) leaves its+ // service running without it. The unguessable lease in their+ // environment proves those processes are this service's own, so they+ // are ended the way a stop ends them; a PID or group without the lease+ // proves nothing and is never signalled.+ if ((await nativeLeaseProcesses(existing.lease)).length)+ await stopNativeProcess(options.root, options.name);+ else if ((await stillLive(existing.pid)) || (await groupLive(existing.pid)))throw new Error(`Native ${options.name} process identity cannot be verified; refusing to replace it.`,);