Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/lib/db/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/lib/evals/evalRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/shared/utils/machineId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/shared/machineId.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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;
};
Expand Down
Loading