From 92cb70e3362c3aa6ccc3218a47259537002400c9 Mon Sep 17 00:00:00 2001 From: dinq Date: Wed, 30 Sep 2026 03:44:54 -0400 Subject: [PATCH 1/3] test: drop assertions that cannot fail Remove pure self-comparisons, a help-flag probe that passes if the predicate is always false, and cases already owned at a stronger boundary. --- apps/app/src/lib/session-ref.test.ts | 1 - packages/pi-loop/tests/cron.test.ts | 9 +-------- packages/server/test/http/handshake.test.ts | 4 ---- packages/server/test/schedule/cron.test.ts | 18 +----------------- packages/server/test/worktree.test.ts | 11 +---------- packages/ssh/src/target.test.ts | 1 - tools/verify/src/runtime/browser.test.ts | 3 +-- tools/verify/src/surfaces/cli-run.test.ts | 10 ---------- 8 files changed, 4 insertions(+), 53 deletions(-) delete mode 100644 tools/verify/src/surfaces/cli-run.test.ts diff --git a/apps/app/src/lib/session-ref.test.ts b/apps/app/src/lib/session-ref.test.ts index b3e4cd0cc..ccef46184 100644 --- a/apps/app/src/lib/session-ref.test.ts +++ b/apps/app/src/lib/session-ref.test.ts @@ -33,7 +33,6 @@ describe("EnvironmentSessionRef identity", () => { }); it("keys the same session on different Environments apart", () => { - expect(sessionRefKey(ref())).toBe(sessionRefKey(ref())); expect(sessionRefKey(ref())).not.toBe(sessionRefKey(ref({ environmentId: "env-2" }))); }); diff --git a/packages/pi-loop/tests/cron.test.ts b/packages/pi-loop/tests/cron.test.ts index 302c48d37..61af21dae 100644 --- a/packages/pi-loop/tests/cron.test.ts +++ b/packages/pi-loop/tests/cron.test.ts @@ -12,7 +12,6 @@ import { parseLeadingInterval, parseRunAt, previousOccurrence, - stableHash, } from "../src/cron"; describe("leading interval", () => { @@ -107,11 +106,9 @@ describe("run_at", () => { }); describe("jitter", () => { - it("is stable for the same task id and stays within bounds", () => { + it("stays within bounds", () => { const after = Date.parse("2026-08-24T10:00:00+08:00"); const a = applyRecurringJitter("*/5 * * * *", "abcd1234", after); - const b = applyRecurringJitter("*/5 * * * *", "abcd1234", after); - expect(a).toBe(b); const nominal = nextOccurrence("*/5 * * * *", after); expect(a - nominal).toBeGreaterThanOrEqual(0); expect(a - nominal).toBeLessThanOrEqual(2.5 * 60_000); @@ -127,8 +124,4 @@ describe("jitter", () => { expect(onHour - jittered).toBeLessThanOrEqual(90_000); expect(jittered).toBeGreaterThan(created); }); - - it("hashes the same id to the same number", () => { - expect(stableHash("a1b2c3d4")).toBe(stableHash("a1b2c3d4")); - }); }); diff --git a/packages/server/test/http/handshake.test.ts b/packages/server/test/http/handshake.test.ts index af1c15694..94057b1ba 100644 --- a/packages/server/test/http/handshake.test.ts +++ b/packages/server/test/http/handshake.test.ts @@ -8,10 +8,6 @@ describe("ready line", () => { expect(parseReadyLine(line)).toEqual({ port: 41234 }); }); - it("is prefixed so it can be picked out of ordinary stdout", () => { - expect(formatReadyLine({ port: 1 }).startsWith(READY_PREFIX)).toBe(true); - }); - it("ignores an unrelated log line", () => { expect(parseReadyLine("pie listening on http://127.0.0.1:4000")).toBeNull(); }); diff --git a/packages/server/test/schedule/cron.test.ts b/packages/server/test/schedule/cron.test.ts index 7d6579b5e..69e968482 100644 --- a/packages/server/test/schedule/cron.test.ts +++ b/packages/server/test/schedule/cron.test.ts @@ -1,12 +1,6 @@ import { describe, expect, it } from "vitest"; -import { - applyRecurringJitter, - CronError, - nextOccurrence, - parseCron, - parseRunAt, -} from "../../src/schedule/cron"; +import { CronError, nextOccurrence, parseCron, parseRunAt } from "../../src/schedule/cron"; describe("parseCron", () => { it("accepts a 5-field expression", () => { @@ -18,7 +12,6 @@ describe("parseCron", () => { expect(() => parseCron("* * * * * *")).toThrow(CronError); }); }); - describe("nextOccurrence", () => { it("returns the next minute for * * * * *", () => { const after = Date.parse("2026-08-27T12:00:30.000Z"); @@ -39,12 +32,3 @@ describe("parseRunAt", () => { expect(parseRunAt("2026-08-27T09:00:00Z")).toBe(Date.parse("2026-08-27T09:00:00Z")); }); }); - -describe("applyRecurringJitter", () => { - it("is deterministic for a given id", () => { - const after = Date.parse("2026-08-27T00:00:00.000Z"); - expect(applyRecurringJitter("0 9 * * *", "aaaaaaaa", after)).toBe( - applyRecurringJitter("0 9 * * *", "aaaaaaaa", after), - ); - }); -}); diff --git a/packages/server/test/worktree.test.ts b/packages/server/test/worktree.test.ts index bf0a70323..63d093808 100644 --- a/packages/server/test/worktree.test.ts +++ b/packages/server/test/worktree.test.ts @@ -2,12 +2,7 @@ import path from "node:path"; import { describe, expect, it } from "vitest"; -import { - generateWorktreeBranchName, - isValidWorktreeKey, - repoWorktreeGroupKey, - worktreeDirectory, -} from "../src/git/worktree"; +import { isValidWorktreeKey, repoWorktreeGroupKey, worktreeDirectory } from "../src/git/worktree"; describe("worktree paths", () => { it("matches Cursor-style layout under PIE_HOME", () => { @@ -21,10 +16,6 @@ describe("worktree paths", () => { ); }); - it("builds pie/ branch names from a hex suffix", () => { - expect(generateWorktreeBranchName("a50b231d")).toBe("pie/a50b231d"); - }); - it("validates worktree directory keys", () => { expect(isValidWorktreeKey("mv98")).toBe(true); expect(isValidWorktreeKey("MV98")).toBe(false); diff --git a/packages/ssh/src/target.test.ts b/packages/ssh/src/target.test.ts index b563c0360..987222c10 100644 --- a/packages/ssh/src/target.test.ts +++ b/packages/ssh/src/target.test.ts @@ -81,7 +81,6 @@ describe("connection identity", () => { it("derives a stable 16-hex state key", () => { const target = parseSshInput("alice@example.com"); expect(remoteStateKey(target)).toMatch(/^[0-9a-f]{16}$/u); - expect(remoteStateKey(target)).toBe(remoteStateKey(target)); expect(targetConnectionKey(target)).toContain("example.com"); }); diff --git a/tools/verify/src/runtime/browser.test.ts b/tools/verify/src/runtime/browser.test.ts index d48b522b5..d6a5184c8 100644 --- a/tools/verify/src/runtime/browser.test.ts +++ b/tools/verify/src/runtime/browser.test.ts @@ -195,9 +195,8 @@ describe("shortAgentBrowserSocketDir", () => { ).toBeLessThanOrEqual(AGENT_BROWSER_UNIX_SOCKET_MAX); }); - it("is stable for the same run dir and honors VERIFY_PIE_AGENT_BROWSER_SOCKET_DIR", () => { + it("differs by run dir and honors VERIFY_PIE_AGENT_BROWSER_SOCKET_DIR", () => { const runDir = "/tmp/pie-verify-web/runs/run-1"; - expect(shortAgentBrowserSocketDir(runDir)).toBe(shortAgentBrowserSocketDir(runDir)); expect(shortAgentBrowserSocketDir(runDir)).not.toBe( shortAgentBrowserSocketDir("/tmp/pie-verify-desktop/runs/run-1"), ); diff --git a/tools/verify/src/surfaces/cli-run.test.ts b/tools/verify/src/surfaces/cli-run.test.ts deleted file mode 100644 index fbcd4f3c5..000000000 --- a/tools/verify/src/surfaces/cli-run.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { describe, expect, it } from "vitest"; - -import { isHelpOrVersion } from "./cli.ts"; - -describe("isHelpOrVersion", () => { - it("requires a current run for real CLI argv", () => { - expect(isHelpOrVersion([])).toBe(false); - expect(isHelpOrVersion(["daemon", "status"])).toBe(false); - }); -}); From 0193d9ee2f91f142bd0a471d1a638a8b50120ed1 Mon Sep 17 00:00:00 2001 From: dinq Date: Wed, 30 Sep 2026 13:32:08 -0400 Subject: [PATCH 2/3] test(verify): retain CLI isolation guard coverage --- tools/verify/src/surfaces/cli-run.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tools/verify/src/surfaces/cli-run.test.ts diff --git a/tools/verify/src/surfaces/cli-run.test.ts b/tools/verify/src/surfaces/cli-run.test.ts new file mode 100644 index 000000000..9afc0ead1 --- /dev/null +++ b/tools/verify/src/surfaces/cli-run.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, it } from "vitest"; + +import { isHelpOrVersion } from "./cli.ts"; + +describe("isHelpOrVersion", () => { + it("requires a current run for real CLI argv", () => { + expect(isHelpOrVersion([])).toBe(false); + expect(isHelpOrVersion(["daemon", "status"])).toBe(false); + }); + + it("allows help and version requests without a current run", () => { + for (const flag of ["--help", "-h", "--version", "-v"]) { + expect(isHelpOrVersion([flag])).toBe(true); + } + expect(isHelpOrVersion(["daemon", "--help"])).toBe(true); + }); +}); From 92b025b74f05a5c5a68a282e3b840f1cd2e6e347 Mon Sep 17 00:00:00 2001 From: dinq Date: Wed, 30 Sep 2026 13:55:22 -0400 Subject: [PATCH 3/3] test: preserve stable identity and jitter contracts --- packages/pi-loop/tests/cron.test.ts | 4 +++- packages/server/test/schedule/cron.test.ts | 18 +++++++++++++++++- packages/ssh/src/target.test.ts | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/pi-loop/tests/cron.test.ts b/packages/pi-loop/tests/cron.test.ts index 61af21dae..8aad82aa7 100644 --- a/packages/pi-loop/tests/cron.test.ts +++ b/packages/pi-loop/tests/cron.test.ts @@ -106,9 +106,11 @@ describe("run_at", () => { }); describe("jitter", () => { - it("stays within bounds", () => { + it("is stable for the same task id and stays within bounds", () => { const after = Date.parse("2026-08-24T10:00:00+08:00"); const a = applyRecurringJitter("*/5 * * * *", "abcd1234", after); + const b = applyRecurringJitter("*/5 * * * *", "abcd1234", after); + expect(a).toBe(b); const nominal = nextOccurrence("*/5 * * * *", after); expect(a - nominal).toBeGreaterThanOrEqual(0); expect(a - nominal).toBeLessThanOrEqual(2.5 * 60_000); diff --git a/packages/server/test/schedule/cron.test.ts b/packages/server/test/schedule/cron.test.ts index 69e968482..7d6579b5e 100644 --- a/packages/server/test/schedule/cron.test.ts +++ b/packages/server/test/schedule/cron.test.ts @@ -1,6 +1,12 @@ import { describe, expect, it } from "vitest"; -import { CronError, nextOccurrence, parseCron, parseRunAt } from "../../src/schedule/cron"; +import { + applyRecurringJitter, + CronError, + nextOccurrence, + parseCron, + parseRunAt, +} from "../../src/schedule/cron"; describe("parseCron", () => { it("accepts a 5-field expression", () => { @@ -12,6 +18,7 @@ describe("parseCron", () => { expect(() => parseCron("* * * * * *")).toThrow(CronError); }); }); + describe("nextOccurrence", () => { it("returns the next minute for * * * * *", () => { const after = Date.parse("2026-08-27T12:00:30.000Z"); @@ -32,3 +39,12 @@ describe("parseRunAt", () => { expect(parseRunAt("2026-08-27T09:00:00Z")).toBe(Date.parse("2026-08-27T09:00:00Z")); }); }); + +describe("applyRecurringJitter", () => { + it("is deterministic for a given id", () => { + const after = Date.parse("2026-08-27T00:00:00.000Z"); + expect(applyRecurringJitter("0 9 * * *", "aaaaaaaa", after)).toBe( + applyRecurringJitter("0 9 * * *", "aaaaaaaa", after), + ); + }); +}); diff --git a/packages/ssh/src/target.test.ts b/packages/ssh/src/target.test.ts index 987222c10..b563c0360 100644 --- a/packages/ssh/src/target.test.ts +++ b/packages/ssh/src/target.test.ts @@ -81,6 +81,7 @@ describe("connection identity", () => { it("derives a stable 16-hex state key", () => { const target = parseSshInput("alice@example.com"); expect(remoteStateKey(target)).toMatch(/^[0-9a-f]{16}$/u); + expect(remoteStateKey(target)).toBe(remoteStateKey(target)); expect(targetConnectionKey(target)).toContain("example.com"); });