A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
[RSI, bug] Classify Windows worker pipes correctly in daemon ps (#2410)
Seth Karten7572880fe033
diff --git a/packages/coding-agent/.changes/fix-daemon-ps-worker-pipes.md b/packages/coding-agent/.changes/fix-daemon-ps-worker-pipes.mdnew file mode 100644index 0000000000..3a8eaa3b17--- /dev/null+++ b/packages/coding-agent/.changes/fix-daemon-ps-worker-pipes.md@@ -0,0 +1 @@+- Classified Windows worker named pipes as worker sockets in `prime-agent ps`, so worker pipes are no longer listed as daemons.diff --git a/packages/coding-agent/src/cli/daemon-ps.ts b/packages/coding-agent/src/cli/daemon-ps.tsindex 7cf588bff8..8672070d18 100644--- a/packages/coding-agent/src/cli/daemon-ps.ts+++ b/packages/coding-agent/src/cli/daemon-ps.ts@@ -900,9 +900,19 @@ function recordShutdownFailure(failed.push({ socketPath, reason });}+// Windows worker named pipes live in the `\\.\pipe\` namespace instead of the+// default daemon socket dir, and their names carry no `.sock` suffix+// (`\\.\pipe\prime-agent-worker-<key>-<workerId12>`; see workerSocketPath in+// daemon-supervisor.ts), so the default-dir + `.sock` checks below never match+// them. Match the exact pipe name instead: pure string matching, so the+// predicate stays testable and correct on every platform.+const WORKER_NAMED_PIPE_PATTERN = /^\\\\\.\\pipe\\prime-agent-worker-[0-9a-f]+-[0-9a-f]{12}$/;+export function isWorkerSocketPath(socketPath: string): boolean {+ if (WORKER_NAMED_PIPE_PATTERN.test(socketPath)) {+ return true;+ }return (- process.platform !== "win32" &&resolve(dirname(socketPath)) === resolve(defaultDaemonSocketDir()) &&basename(socketPath).startsWith("worker-") &&basename(socketPath).endsWith(".sock")diff --git a/packages/coding-agent/test/daemon-ps.test.ts b/packages/coding-agent/test/daemon-ps.test.tsindex 6b8f6ef43e..dbd4c20feb 100644--- a/packages/coding-agent/test/daemon-ps.test.ts+++ b/packages/coding-agent/test/daemon-ps.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";import {type DaemonInfo,evaluateShutdownQuietPeriod,+ isWorkerSocketPath,planReap,planShutdownAll,planShutdownConfirmation,@@ -9,6 +10,11 @@ import {} from "../src/cli/daemon-ps.js";import { getProcessStartId } from "../src/core/session-lease.js";+it("recognizes Windows worker named pipes on every platform", () => {+ expect(isWorkerSocketPath("\\\\.\\pipe\\prime-agent-worker-98ed5cb228d2-5b1d3aeb91ee")).toBe(true);+ expect(isWorkerSocketPath("\\\\.\\pipe\\prime-agent-daemon")).toBe(false);+});+describe("evaluateShutdownQuietPeriod", () => {it("requires a full quiet period independently of the convergence window", () => {expect(evaluateShutdownQuietPeriod(10_500, 10_000)).toBe("waiting");@@ -49,16 +55,12 @@ describe("planReap", () => {expect(plan.map((action) => action.kind)).toEqual(["shutdown", "remove-file"]);});- it("removes a stale default socket file but never stops a live default daemon", () => {+ it("removes a stale default socket file", () => {const plan = planReap(- [- makeDaemon({ socketPath: "/tmp/default.sock", status: "orphan-file", isDefault: true }),- makeDaemon({ socketPath: "/tmp/live-default.sock", status: "current", isDefault: true, sessionCount: 0 }),- ],+ [makeDaemon({ socketPath: "/tmp/default.sock", status: "orphan-file", isDefault: true })],true,);expect(plan[0]!.kind).toBe("remove-file");- expect(plan[1]!.kind).toBe("skip");});it("only kills unreachable daemons with --force", () => {