The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(cli): settled agents stop holding their disk reservation (#2028)
harness-for-autonomous[bot]1df3f7f8d521
diff --git a/cli/src/superTabs/reservations.spec.ts b/cli/src/superTabs/reservations.spec.tsindex 077f01f01..89974d289 100644--- a/cli/src/superTabs/reservations.spec.ts+++ b/cli/src/superTabs/reservations.spec.ts@@ -212,6 +212,41 @@ it('reserves disk on its destination volume and keeps separate volumes independeexpect(f.deps.disk).toHaveBeenLastCalledWith('/second-volume', true)})+// Diego's Mac, 2026-10-28: free disk is measured, so it already counts each running agent's worktree; holding its 10 GiB+// past launch counted that space twice. 15 settled agents held 150 GiB on a disk with 140 GiB free and every start was refused.+const diskInput = (n: number) => input(n, 0, 10 * GiB)+const freeDisk = (f: ReturnType<typeof setup>, bytes: number) => f.deps.disk.mockResolvedValue({ freeBytes: bytes, volume: 'first', path: '/fixture/repo' })++it('counts a start\'s disk only during its start window, so settled agents do not block more starts', async () => {+ const f = setup(), book = f.open()+ freeDisk(f, 1000 * GiB)+ for (let n = 1; n <= 15; n++) { expect(await book.reserve(diskInput(n))).toMatchObject({ ok: true }); f.launch(n) }+ f.clock.now += 5 * MINUTE+ freeDisk(f, 15 * GiB)+ expect(await book.reserve(diskInput(16))).toMatchObject({ ok: true })+})++it('keeps holding disk for a start inside its window and for one that has not launched', async () => {+ const f = setup(), book = f.open()+ freeDisk(f, 15 * GiB)+ expect(await book.reserve(diskInput(1))).toMatchObject({ ok: true })+ f.clock.now += 60 * MINUTE+ expect(await book.reserve(diskInput(2))).toMatchObject({ error: 'CAPACITY_UNAVAILABLE', detail: expect.stringContaining('disk') })+ f.launch(1)+ f.clock.now += 5 * MINUTE - 1+ expect(await book.reserve(diskInput(2))).toMatchObject({ error: 'CAPACITY_UNAVAILABLE', detail: expect.stringContaining('disk') })+ f.clock.now += 1+ expect(await book.reserve(diskInput(2))).toMatchObject({ ok: true })+})++it('lets only one of two simultaneous starts take the last free disk', async () => {+ const f = setup(), a = f.open(), b = f.open()+ freeDisk(f, 15 * GiB)+ const answers = await Promise.all([a.reserve(diskInput(1)), b.reserve(diskInput(2))])+ expect(answers.filter(r => r.ok)).toHaveLength(1)+ expect(answers.filter(r => r.error)).toEqual([expect.objectContaining({ error: 'CAPACITY_UNAVAILABLE', detail: expect.stringContaining('disk') })])+})+it('refuses to reuse a reservation when an unmount moves the same path to a different volume', async () => {const f = setup(), book = f.open()await book.reserve(input())diff --git a/cli/src/superTabs/reservations.ts b/cli/src/superTabs/reservations.tsindex c362c1c58..564de42bb 100644--- a/cli/src/superTabs/reservations.ts+++ b/cli/src/superTabs/reservations.ts@@ -167,13 +167,18 @@ export class CapacityReservations implements ReservationBook {}}- /** What a reservation still holds: all of it until its agent launched, then until its window closes or the agent measures- * as much itself. A launched agent the core no longer lists is timed from its reservation. */- private held(row: Reservation, measured: Map<string, number> | null, now: number): number {- if (!row.harness_id) return row.memory_bytes+ /** Whether a reservation is still in its start window: until its agent launched, then START_WINDOW_MS. A launched agent+ * the core no longer lists is timed from its reservation. */+ private starting(row: Reservation, now: number): boolean {+ if (!row.harness_id) return trueconst started = this.core.agents.byAgent(row.harness_id)?.registeredAt- if (now - (finite(started) ? started : row.created_at) >= START_WINDOW_MS) return 0- return (measured?.get(row.harness_id) ?? 0) >= row.memory_bytes ? 0 : row.memory_bytes+ return now - (finite(started) ? started : row.created_at) < START_WINDOW_MS+ }++ /** What a reservation still holds of memory: all of it in its start window, unless the agent already measures as much itself. */+ private held(row: Reservation, measured: Map<string, number> | null, now: number): number {+ if (!this.starting(row, now)) return 0+ return row.harness_id && (measured?.get(row.harness_id) ?? 0) >= row.memory_bytes ? 0 : row.memory_bytes}async observe(creationId: unknown, closed?: AbortSignal): Promise<Json> {@@ -235,7 +240,9 @@ export class CapacityReservations implements ReservationBook {const active = this.rows()if (active.length >= MAX_ACTIVE) return unavailable('Reconcile pending starts on this machine before starting more agents.')const now = this.now(), memoryHeld = active.reduce((sum, row) => sum + this.held(row, measured, now), 0)- const diskHeld = active.filter(row => row.volume === destination.volume).reduce((sum, row) => sum + row.disk_bytes, 0)+ // Free disk is measured too, so it already counts a settled agent's worktree. On Diego's Mac (2026-10-28) 15 settled+ // agents held 150 GiB against 140 GiB free and every start was refused; only starts still in their window hold disk.+ const diskHeld = active.filter(row => row.volume === destination.volume && this.starting(row, now)).reduce((sum, row) => sum + row.disk_bytes, 0)if (memory > 0 && !finite(freeMemory)) return unavailable('The free memory on this machine could not be read.')if (memory > 0 && memory > freeMemory! - memoryHeld) return unavailable(memoryShort(freeMemory! - memoryHeld, memory)+ (memoryHeld > 0 ? ` ${gibibytes(memoryHeld)} more is set aside for agents still starting.` : ''))