A desktop coding agent with free access to frontier models.
TypeScript
fix: raise the pending project archive budget to 2 GiB
ogsamratf2b2e2f012cc
diff --git a/apps/server/src/session-archive/index.test.ts b/apps/server/src/session-archive/index.test.tsindex 04198bef..b331075b 100644--- a/apps/server/src/session-archive/index.test.ts+++ b/apps/server/src/session-archive/index.test.ts@@ -1,13 +1,13 @@import { afterEach, describe, expect, test } from "bun:test";import { execFile } from "node:child_process";import { createHash, randomBytes } from "node:crypto";-import { mkdir, readdir, readFile, rm, symlink, writeFile } from "node:fs/promises";+import { mkdir, readdir, readFile, rm, symlink, truncate, writeFile } from "node:fs/promises";import { basename, join } from "node:path";import { promisify } from "node:util";import { gitMarkerDetector, gitParentDetector } from "./detect.js";import { FakeArchiveServer, slowPartTwo } from "./fake-archive-server.js";-import { ARCHIVE_STATE_DIRECTORY, POLICY_TTL_MS, SessionArchiver, type SessionArchiverOptions } from "./index.js";+import { ARCHIVE_STATE_DIRECTORY, DEFAULT_PENDING_BYTE_BUDGET, POLICY_TTL_MS, SessionArchiver, type SessionArchiverOptions } from "./index.js";import { cleanupTempDirs, manifestOf, openArchive, tempDir } from "./test-helpers.js";/** A capture result without its `detail` (the reason it was skipped, more precisely). */@@ -1381,3 +1381,70 @@ test("concurrent archive packing stays inside the shared pending byte budget", aexpect(queue).toHaveLength(1);expect(results.reduce((sum, result) => sum + (result.status === "queued" ? result.size : 0), 0)).toBeLessThanOrEqual(budget);});++test("the default pending archive budget is 2 GiB", () => {+ expect(DEFAULT_PENDING_BYTE_BUDGET).toBe(2 * 1024 ** 3);+});++test("a project over the old 256 MiB budget is archived by default", async () => {+ const server = new FakeArchiveServer();+ const { root } = await project();+ const state = await tempDir("budget-default");+ // A sparse 300 MiB file: the estimate counts it at its full size.+ await writeFile(join(root, "assets/big.bin"), "");+ await truncate(join(root, "assets/big.bin"), 300 * 1024 * 1024);+ const subject = archiver(server, state, { freeDiskBytes: async () => 100 * 1024 ** 3 });+ expect(await subject.captureBase("ses_budget_default", root)).toMatchObject({ status: "queued", kind: "base" });+}, 60_000);++test("a project over the budget is skipped as disk_budget with the bytes it needs", async () => {+ const server = new FakeArchiveServer();+ const { root } = await project();+ const state = await tempDir("budget-over");+ const subject = archiver(server, state, { pendingByteBudget: 64 * 1024, freeDiskBytes: async () => 100 * 1024 ** 3 });+ const result = await subject.captureBase("ses_budget_over", root);+ expect(result).toMatchObject({ status: "paused", reason: "disk_budget" });+ // The estimate counts the raw sizes: the 300 KiB asset alone is over the budget.+ expect(result.status === "paused" && result.requiredBytes).toBeGreaterThan(300 * 1024);+ expect(await readdir(join(state, ARCHIVE_STATE_DIRECTORY, "queue"))).toEqual([]);+ expect(server.objects()).toEqual([]);+});++test("an archive leaves at least its own size free on the disk, above the floor", async () => {+ const server = new FakeArchiveServer();+ const { root } = await project();+ const state = await tempDir("budget-floor");+ let free = 0;+ const subject = archiver(server, state, { minimumFreeDiskBytes: 1024, freeDiskBytes: async () => free });+ const probe = await subject.captureBase("ses_budget_floor", root);+ expect(probe).toMatchObject({ status: "paused", reason: "disk_budget" });+ const required = probe.status === "paused" ? probe.requiredBytes : 0;+ expect(required).toBeGreaterThan(300 * 1024);++ // The fixed floor plus the archive fits; the archive's own size beside it does not.+ free = Math.floor(required * 1.5);+ expect(await subject.captureBase("ses_budget_floor", root)).toMatchObject({ status: "paused", reason: "disk_budget", freeBytes: free });++ free = required * 2 + 1024 * 1024;+ expect(await subject.captureBase("ses_budget_floor", root)).toMatchObject({ status: "queued", sequence: 0 });+});++test("the 512 MiB floor still holds for a small archive", async () => {+ const server = new FakeArchiveServer();+ const { root } = await project();+ const state = await tempDir("budget-min-floor");+ const MiB = 1024 * 1024;+ let free = 512 * MiB;+ const subject = archiver(server, state, { freeDiskBytes: async () => free });+ expect(await subject.captureBase("ses_budget_min_floor", root)).toMatchObject({ status: "paused", reason: "disk_budget" });+ free = 520 * MiB;+ expect(await subject.captureBase("ses_budget_min_floor", root)).toMatchObject({ status: "queued" });+});++test("a free-space floor of 0 turns the free-space check off", async () => {+ const server = new FakeArchiveServer();+ const { root } = await project();+ const state = await tempDir("budget-floor-off");+ const subject = archiver(server, state, { minimumFreeDiskBytes: 0, freeDiskBytes: async () => 4 * 1024 * 1024 });+ expect(await subject.captureBase("ses_budget_floor_off", root)).toMatchObject({ status: "queued" });+});diff --git a/apps/server/src/session-archive/index.ts b/apps/server/src/session-archive/index.tsindex 247e55f3..507c36d3 100644--- a/apps/server/src/session-archive/index.ts+++ b/apps/server/src/session-archive/index.ts@@ -168,7 +168,15 @@ const SIGN_OUT_ABORT_TIMEOUT_MS = 5_000;const START_FINAL_WINDOW_MS = 7 * 24 * 60 * 60_000;/** At most this many sessions are scanned for a final archive at app start. */const MAX_START_FINALS = 10;-const DEFAULT_PENDING_BYTE_BUDGET = 256 * 1024 * 1024;+/**+ * Queued plus packing archive bytes, estimated from the raw file sizes (see+ * estimateArchiveOutput): a project over it is skipped as disk_budget.+ */+export const DEFAULT_PENDING_BYTE_BUDGET = 2 * 1024 * 1024 * 1024;+/**+ * Free space an archive leaves on its disk: this much at least, and as much+ * as the archive itself when that is more (a 2 GiB archive needs 4 GiB free).+ */const DEFAULT_MIN_FREE_DISK_BYTES = 512 * 1024 * 1024;const ARCHIVE_PACK_RESERVE_BYTES = 1024 * 1024;/**@@ -1417,6 +1425,11 @@ export class SessionArchiver {return Math.ceil(tarBytes * 1.01);}+ /** The free space to keep beside an archive of `archiveBytes` (none when the floor is set to 0). */+ private freeDiskFloor(archiveBytes: number): number {+ return this.minimumFreeDiskBytes === 0 ? 0 : Math.max(this.minimumFreeDiskBytes, archiveBytes);+ }+private reserveDiskBudget(requiredBytes: number): Promise<{ bytes: number; release(): void } | null> {return this.budgetLocked(async () => {const records = await this.listQueue();@@ -1424,7 +1437,7 @@ export class SessionArchiver {const freeBytes = await this.freeDiskBytes(this.dir).catch(() => null);if (freeBytes === null|| pendingBytes + this.packingReservedBytes + requiredBytes > this.pendingByteBudget- || freeBytes < this.minimumFreeDiskBytes + requiredBytes) return null;+ || freeBytes < this.freeDiskFloor(requiredBytes) + requiredBytes) return null;this.packingReservedBytes += requiredBytes;let released = false;const reservation = {@@ -1448,7 +1461,7 @@ export class SessionArchiver {const extra = Math.max(0, boundedOutput - reservation.bytes);if (freeBytes === null|| pendingBytes + this.packingReservedBytes + extra > this.pendingByteBudget- || freeBytes < this.minimumFreeDiskBytes + Math.max(ARCHIVE_PACK_RESERVE_BYTES, reservation.bytes + extra - boundedOutput)) {+ || freeBytes < this.freeDiskFloor(reservation.bytes + extra) + Math.max(ARCHIVE_PACK_RESERVE_BYTES, reservation.bytes + extra - boundedOutput)) {throw new DiskBudgetPause(reservation.bytes + extra, pendingBytes, freeBytes);}this.packingReservedBytes += extra;diff --git a/docs/capture-efficiency-staging.md b/docs/capture-efficiency-staging.mdindex d83232cb..5e265f1d 100644--- a/docs/capture-efficiency-staging.md+++ b/docs/capture-efficiency-staging.md@@ -74,7 +74,8 @@ Archive recovery tests on staging passed four cases: base pause/restart,delta pause/restart with correct parent, disk exhaustion during packing, andconcurrent packing under one pending budget. Restored binary bytes match.-Defaults are a 256 MiB pending archive budget and 512 MiB free disk floor,+Defaults are a 2 GiB pending archive budget (raw file sizes) and a free disk+floor of 512 MiB or the archive's size, whichever is larger,configurable with OMNIRUSH_ARCHIVE_PENDING_BYTE_BUDGET andOMNIRUSH_ARCHIVE_MIN_FREE_DISK_BYTES. Reservation estimates are conservative;large bases can pause until the budget or available space increases.