From f5f40e07c4b45219b45cb33a0d83f26d30b8e2b4 Mon Sep 17 00:00:00 2001 From: Koosha Pari Date: Sun, 13 Sep 2026 02:31:11 -0700 Subject: [PATCH 1/3] fix(tests): add DISABLE_IOREG_STRATEGY env var for macOS test compatibility (fixes #13467) On macOS, Strategy 2 (ioreg IOPlatformUUID) resolves before Strategy 4 (os.hostname()), causing tests that mock os.hostname() to fail. - Add DISABLE_IOREG_STRATEGY env var check in machineId.ts Strategy 2 - Set env var in the test helper to skip ioreg on all platforms - Both tests now pass on macOS, Linux, and Windows --- src/shared/utils/machineId.ts | 5 +++-- tests/unit/shared/machineId.test.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/shared/utils/machineId.ts b/src/shared/utils/machineId.ts index db0dfad80e5..1b4837aad4b 100644 --- a/src/shared/utils/machineId.ts +++ b/src/shared/utils/machineId.ts @@ -57,9 +57,10 @@ function getMachineIdRaw(): string { } // Strategy 2: macOS — ioreg IOPlatformUUID + // Skip when DISABLE_IOREG_STRATEGY=1 so tests can reach Strategy 4/5 on darwin. try { - if (process.platform !== "darwin") { - throw new Error("Not macOS"); + if (process.platform !== "darwin" || process.env.DISABLE_IOREG_STRATEGY === "1") { + throw new Error("Not macOS or ioreg disabled"); } const output = execSync("ioreg -rd1 -c IOPlatformExpertDevice", { encoding: "utf8", diff --git a/tests/unit/shared/machineId.test.ts b/tests/unit/shared/machineId.test.ts index cde9b9a4f6e..97cc7b7b055 100644 --- a/tests/unit/shared/machineId.test.ts +++ b/tests/unit/shared/machineId.test.ts @@ -30,6 +30,10 @@ function disableWindowsRegistryStrategy(): () => void { process.env.SystemRoot = "Z:\\NonExistent"; process.env.windir = "Z:\\NonExistent"; + // Also disable macOS ioreg strategy so Strategy 4/5 can be reached on darwin. + const origDisableIoreg = process.env.DISABLE_IOREG_STRATEGY; + process.env.DISABLE_IOREG_STRATEGY = "1"; + const origReadFileSync = fs.readFileSync; fs.readFileSync = (filePath: string, encoding: string) => { if (filePath === "/etc/machine-id" || filePath === "/var/lib/dbus/machine-id") { @@ -57,6 +61,11 @@ function disableWindowsRegistryStrategy(): () => void { } else { delete process.env.windir; } + if (origDisableIoreg !== undefined) { + process.env.DISABLE_IOREG_STRATEGY = origDisableIoreg; + } else { + delete process.env.DISABLE_IOREG_STRATEGY; + } fs.readFileSync = origReadFileSync; childProcess.execSync = origExecSync; }; From 328d775a2e2aaf73e0b1f6be3a710e435f50be31 Mon Sep 17 00:00:00 2001 From: Koosha Pari Date: Sun, 13 Sep 2026 02:32:36 -0700 Subject: [PATCH 2/3] fix(eval): force passed=false when upstream call failed (fixes #13137) An eval case whose upstream call failed was graded as passed because the error string happened to match the expected pattern. Now when metrics.error is set, result.passed is forced to false so failed upstream calls never inflate the pass rate. --- src/lib/evals/evalRunner.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/evals/evalRunner.ts b/src/lib/evals/evalRunner.ts index d0b92800136..97e1fff08a4 100644 --- a/src/lib/evals/evalRunner.ts +++ b/src/lib/evals/evalRunner.ts @@ -241,6 +241,7 @@ export function runSuite( if (metrics?.error && !result.error) { result.error = metrics.error; + result.passed = false; // #13137 — an upstream failure must not grade as passed } return result; From ce0aea38b25d1d35929a8bf084a6408671edd638 Mon Sep 17 00:00:00 2001 From: Koosha Pari Date: Sun, 13 Sep 2026 02:33:34 -0700 Subject: [PATCH 3/3] fix(db): prune backups after health-check-repair snapshot (fixes #13308) The managed backup path (VACUUM INTO) creates a full database snapshot on every startup but never calls the existing retention helper, causing db_backups/ to grow without bound. On one observed install this produced 10.3 GB across 18 snapshots in 8 days. Call cleanupDbBackups() after a successful snapshot so the operator's maxFiles / retentionDays settings apply uniformly to all backup paths. Dynamic import avoids a circular dependency with backup.ts. --- src/lib/db/core.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/db/core.ts b/src/lib/db/core.ts index b0febbef2dc..827fdd22faa 100644 --- a/src/lib/db/core.ts +++ b/src/lib/db/core.ts @@ -883,6 +883,15 @@ function createManagedDbBackup(db: SqliteDatabase, reason: string): boolean { db.exec(`VACUUM INTO '${escapedBackupPath}'`); console.log(`[DB] Backup created (${reason}): ${backupPath}`); + + // #13308: prune old backups after creating a new one so db_backups/ does not + // grow without bound. The health-check-repair path creates a snapshot on every + // startup even for a healthy database, and without pruning each restart adds a + // full-sized copy. Dynamic import avoids a circular dependency with backup.ts. + import("./backup") + .then(({ cleanupDbBackups }) => cleanupDbBackups({ backupDir })) + .catch(() => {}); + return true; } catch (error: unknown) { const message = error instanceof Error ? error.message : String(error);