A local-first multi-agent app development platform, built on PenguinHarness
test(server,ci): 跨机的 per-machine lane 在 Windows 上也真跑,未测到的三处写下来
lmlihengd5ee09f4f962
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 1d8d7f14..ac106603 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -256,7 +256,17 @@ jobs:# shards. The runner ships Git-Bash on PATH, so core's exec_command tests exercise# the shell resolver's bash pick; genuinely POSIX-only tests skip themselves via# process.platform guards rather than CI filters, so a local Windows dev sees the same- # behaviour. Every package's tests still run exactly once across the shards. Line+ # behaviour. What those guards leave unmeasured on Windows is listed here, and is not+ # guaranteed there:+ # - server test/machines-transport-session.test.ts: its stub `ssh` is a shell script,+ # which execFile cannot run without a shell, so the session is measured on POSIX+ # only; spawning the real Windows OpenSSH client is not measured.+ # - server test/terminal-stream.test.ts: real ptys only. Headless ConPTY loses its+ # console ("AttachConsole failed") and node-pty leaks IPC rejections; the pure+ # terminal suites in terminal.test.ts run here.+ # - plugins/sandbox-dsh test/live.test.ts: what its live suite runs on Windows, and what+ # it leaves unmeasured there, is stated at the TODO(win32) in that file.+ # Every package's tests still run exactly once across the shards. Line# endings come from .gitattributes (LF working tree), keeping build# outputs and fixtures byte-identical. No format:check, no typecheck, no e2e — see the# macOS note above.diff --git a/packages/server/test/machines-transport-lane.test.ts b/packages/server/test/machines-transport-lane.test.tsindex 4f184930..f5fa178c 100644--- a/packages/server/test/machines-transport-lane.test.ts+++ b/packages/server/test/machines-transport-lane.test.ts@@ -1,41 +1,40 @@/*** One thing at a time per machine, by structure: two commands to the same machine run one- * after the other, two to different machines together. Measured against a stub `ssh` on- * PATH that only sleeps.+ * after the other, two to different machines together. Measured with a child that only+ * sleeps: the lane never looks at what it runs, so the child is Node itself rather than a+ * stub `ssh` — a shell-script stub cannot be executed without a shell on Windows, and the+ * lane is the same code there.*/-import fs from "node:fs";-import os from "node:os";-import path from "node:path";-import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { describe, expect, it } from "vitest";import { run } from "../src/machines/transport/exec.js";import { inLane } from "../src/machines/transport/lane.js";-const posixOnly = process.platform === "win32" ? describe.skip : describe;--posixOnly("the per-machine lane", () => {- let stubBin: string;- let originalPath: string | undefined;- beforeEach(() => {- stubBin = fs.mkdtempSync(path.join(os.tmpdir(), "penguin-lane-"));- fs.writeFileSync(path.join(stubBin, "ssh"), "#!/bin/sh\nsleep 0.2\n");- fs.chmodSync(path.join(stubBin, "ssh"), 0o755);- originalPath = process.env.PATH;- process.env.PATH = `${stubBin}:${process.env.PATH ?? ""}`;- });- afterEach(() => {- process.env.PATH = originalPath;- fs.rmSync(stubBin, { recursive: true, force: true });- });-+describe("the per-machine lane", () => {it("serialises commands to one machine and lets different machines proceed together", async () => {- const ssh = (address: string) => inLane(address, () => run("ssh", ["host", "true"]));+ const sleep = (address: string) =>+ inLane(address, () => run(process.execPath, ["-e", "setTimeout(() => {}, 200)"]));+ // Warm the child's start-up, so the bounds below measure the lane rather than a cold+ // Node on a slow runner.+ await sleep("ssh:warm-up");++ // Both bounds are relative to one child's measured time, so a slow runner's start-up+ // moves them together instead of failing an absolute floor.let started = Date.now();- await Promise.all([ssh("ssh:nas"), ssh("ssh:nas")]);- expect(Date.now() - started).toBeGreaterThanOrEqual(380);+ await sleep("ssh:nas");+ const alone = Date.now() - started;++ started = Date.now();+ await Promise.all([sleep("ssh:nas"), sleep("ssh:nas")]);+ const serial = Date.now() - started;+ // Serialised means a second child's time after the first: at least its 200 ms sleep on top+ // of one child's, less scheduling noise.+ expect(serial).toBeGreaterThanOrEqual(alone + 150);started = Date.now();- await Promise.all([ssh("ssh:nas"), ssh("ssh:build-box")]);- expect(Date.now() - started).toBeLessThan(380);+ await Promise.all([sleep("ssh:nas"), sleep("ssh:build-box")]);+ const together = Date.now() - started;+ // Together means one child's time plus scheduling noise, not two children's time.+ expect(together).toBeLessThan(alone + 180);});it("a failure does not stall the lane behind it", async () => {diff --git a/packages/server/test/machines-transport-session.test.ts b/packages/server/test/machines-transport-session.test.tsindex 98a243c2..a534790f 100644--- a/packages/server/test/machines-transport-session.test.ts+++ b/packages/server/test/machines-transport-session.test.ts@@ -19,6 +19,8 @@ import path from "node:path";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { closeConnectionTo, connectionTo, sessionOf } from "../src/machines/transport/index.js";+// The stub `ssh` below is a shell script, which execFile cannot run on Windows; what stays+// unmeasured on Windows is listed in ci.yml's test-windows note.const posixOnly = process.platform === "win32" ? describe.skip : describe;posixOnly("the session", () => {