From 2776ec0a5c217abd515b554ce88d77efaabde676 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 3 Oct 2026 23:02:56 +0200 Subject: [PATCH 1/8] refactor(core): delete ManagedDeviceLifecycle.boot and readyProvisioned, which nothing calls Production makes devices ready only through bootForLease and readyProvisionedForLease. The non-lease pair and #makeReady were kept alive by their own tests. Their mode and post-commit cases are covered by the ForLease tests and by the registry's persist-before-emit test; setup that used them now goes through readyProvisionedForLease. --- src/contract/schemas.ts | 4 +- src/core/domain.ts | 4 +- src/core/managed-device-lifecycle.test.ts | 163 ++-------------------- src/core/managed-device-lifecycle.ts | 49 +------ 4 files changed, 20 insertions(+), 200 deletions(-) diff --git a/src/contract/schemas.ts b/src/contract/schemas.ts index f1f304ca0..7dd3b13cf 100644 --- a/src/contract/schemas.ts +++ b/src/contract/schemas.ts @@ -178,8 +178,8 @@ export const grantedDeviceSchema = z.object({ * last `ready` transition. Undefined for a device still `provisioning` (never made ready * yet) and, as an upgrade path, for a record written by a pre-address daemon -- `state.json` * from before this field existed loads without one rather than failing to start. It becomes - * defined the next time the device is made ready (`boot`/`readyProvisioned`); nothing here - * ever guesses at a value it wasn't told. + * defined the next time the device is made ready (`bootForLease`/`readyProvisionedForLease`); + * nothing here ever guesses at a value it wasn't told. */ address: z.string().optional(), /** The mode the device actually has (see `DeviceRecord.mode`). */ diff --git a/src/core/domain.ts b/src/core/domain.ts index e0c74437c..fea580b8a 100644 --- a/src/core/domain.ts +++ b/src/core/domain.ts @@ -84,8 +84,8 @@ export interface DeviceRecord { * last `ready` transition. Undefined for a device still `provisioning` (never made ready * yet) and, as an upgrade path, for a record written by a pre-address daemon -- `state.json` * from before this field existed loads without one rather than failing to start. It becomes - * defined the next time the device is made ready (`boot`/`readyProvisioned`); nothing here - * ever guesses at a value it wasn't told. + * defined the next time the device is made ready (`bootForLease`/`readyProvisionedForLease`); + * nothing here ever guesses at a value it wasn't told. */ readonly address?: string; /** diff --git a/src/core/managed-device-lifecycle.test.ts b/src/core/managed-device-lifecycle.test.ts index eac1c389c..fd0c886a2 100644 --- a/src/core/managed-device-lifecycle.test.ts +++ b/src/core/managed-device-lifecycle.test.ts @@ -83,29 +83,6 @@ async function shutdownDevice( } describe("ManagedDeviceLifecycle", () => { - it("boots a registered shutdown device and emits device.ready after its commit", async () => { - const harness = await createHarness(); - const ready = await readyDevice(harness); - await harness.driver.shutdown({ - address: ready.address ?? "", - deviceId: ready.driverDeviceId, - driverData: ready.driverData, - }); - const shutdown = await harness.registry.transitionDevice(ready.id, "shutdown", { - event: "device.shutdown", - payload: { deviceId: ready.id, initiator: "test" }, - }); - let stateAtEvent = "unknown"; - harness.eventBus.subscribe("device.ready", () => { - stateAtEvent = harness.registry.snapshot.devices[0]?.state ?? "missing"; - }); - - const booted = await harness.lifecycle.boot(shutdown); - - expect(booted).toMatchObject({ id: shutdown.id, state: "ready" }); - expect(stateAtEvent).toBe("ready"); - }); - it("replaces the stored address with the one makeReady re-read when booting a device for a lease", async () => { // The address a device is reachable at is a property of its current boot, not of the device: // an Android console port is assigned per boot, so a serial captured at provision goes stale @@ -388,43 +365,7 @@ describe("ManagedDeviceLifecycle", () => { }); }); - it("persists a driver's reported mode on boot (#makeReady path)", async () => { - const clock = new FakeClock(1_000); - const eventBus = new EventBus(clock); - const driver = new FakeDriver({ clock, mode: "slim", platform: "ios" }); - let nextId = 0; - const registry = await Registry.load({ - clock, - eventBus, - filesystem: new MemoryFilesystem(), - idGenerator: { generate: () => `${nextId++}` }, - statePath, - }); - const lifecycle = new ManagedDeviceLifecycle( - new DriverCatalog([driver]), - registry, - new SerializedDecision(), - new DeviceOperationClaims(), - clock, - ); - const driverDevice = await driver.provision({ - model: "iPhone 16", - osVersion: "26.5", - platform: "ios", - }); - const device = await registry.registerDevice({ - driverData: driverDevice.driverData, - driverDeviceId: driverDevice.deviceId, - provisionDuration: 0, - spec: { model: "iPhone 16", osVersion: "26.5", platform: "ios" }, - }); - - const ready = await lifecycle.readyProvisioned(device); - - expect(ready).toMatchObject({ mode: "slim" }); - }); - - it("persists a driver's reported mode via the bootForLease handoff path (#makeReadyForLease)", async () => { + it("persists a driver's reported mode via the readyProvisionedForLease handoff path (#makeReadyForLease)", async () => { const clock = new FakeClock(1_000); const eventBus = new EventBus(clock); const driver = new FakeDriver({ clock, mode: "slim", platform: "ios" }); @@ -461,7 +402,7 @@ describe("ManagedDeviceLifecycle", () => { expect(handoff?.device).toMatchObject({ mode: "slim" }); }); - it("boot stores full, replacing a stored slim, when the driver reports no mode (#makeReady, shutdown path)", async () => { + it("bootForLease stores full, replacing a stored slim, when the driver reports no mode (#makeReadyForLease, shutdown path)", async () => { // A driver that reports no mode must not leave a previously stored "slim" on the record, // or a device that is no longer slim keeps reporting `mode: "slim"`. const harness = await createHarness(); @@ -475,7 +416,6 @@ describe("ManagedDeviceLifecycle", () => { mode: "slim", }, ); - expect(ready.mode).toBe("slim"); await harness.driver.shutdown({ address: ready.address ?? "", deviceId: ready.driverDeviceId, @@ -486,98 +426,20 @@ describe("ManagedDeviceLifecycle", () => { payload: { deviceId: ready.id, initiator: "test" }, }); expect(shutdown.mode).toBe("slim"); - - // `harness.driver` (a plain `FakeDriver` with no `mode` option) reports no mode on this - // boot -- the driver-side equivalent of a boot that did not slim. - const booted = await harness.lifecycle.boot(shutdown); - - expect(booted?.mode).toBe("full"); - }); - - it("bootForLease stores full, replacing a stored slim, when the driver reports no mode (#makeReadyForLease, shutdown path)", async () => { - const harness = await createHarness(); - const ready = await harness.registry.transitionDevice( - harness.device.id, - "ready", - { event: "device.ready", payload: { bootDuration: 0, deviceId: harness.device.id } }, - { - address: harness.device.driverDeviceId, - driverData: harness.device.driverData, - mode: "slim", - }, - ); - await harness.driver.shutdown({ - address: ready.address ?? "", - deviceId: ready.driverDeviceId, - driverData: ready.driverData, - }); - const shutdown = await harness.registry.transitionDevice(ready.id, "shutdown", { - event: "device.shutdown", - payload: { deviceId: ready.id, initiator: "test" }, - }); const claim = harness.claims.tryClaim(shutdown.id, "boot"); if (claim === undefined) throw new Error("expected boot claim"); + // `harness.driver` (a plain `FakeDriver` with no `mode` option) reports no mode on this + // boot -- the driver-side equivalent of a boot that did not slim. const handoff = await harness.lifecycle.bootForLease(shutdown, claim); expect(handoff?.device.mode).toBe("full"); }); - it("readyProvisioned stores full, replacing a stored slim, when the driver reports no mode (#makeReady, provisioning path)", async () => { + it("readyProvisionedForLease stores full, replacing a stored slim, when the driver reports no mode (#makeReadyForLease, provisioning path)", async () => { // A device can't naturally re-enter "provisioning" once it leaves, so the persisted state is // seeded directly (as a restarted daemon would load it from disk) to exercise the same - // provisioning-branch code path the "shutdown" tests above cover for the other branch. - const clock = new FakeClock(1_000); - const eventBus = new EventBus(clock); - const driver = new FakeDriver({ clock, platform: "ios" }); - const driverDevice = await driver.provision({ - model: "iPhone 16", - osVersion: "26.5", - platform: "ios", - }); - const filesystem = new MemoryFilesystem(); - await filesystem.mkdirp("/home/agent/.simlock"); - await filesystem.writeFileAtomic( - statePath, - JSON.stringify({ - devices: [ - { - createdAt: 0, - driverData: driverDevice.driverData, - driverDeviceId: driverDevice.deviceId, - mode: "slim", - id: "dev_stale", - spec: { model: "iPhone 16", osVersion: "26.5", platform: "ios" }, - state: "provisioning", - }, - ], - leases: [], - }), - ); - const registry = await Registry.load({ - clock, - eventBus, - filesystem, - idGenerator: { generate: () => "unused" }, - statePath, - }); - const lifecycle = new ManagedDeviceLifecycle( - new DriverCatalog([driver]), - registry, - new SerializedDecision(), - new DeviceOperationClaims(), - clock, - ); - const device = registry.snapshot.devices[0]; - if (device === undefined) throw new Error("expected seeded device"); - expect(device.mode).toBe("slim"); - - const readyDevice = await lifecycle.readyProvisioned(device); - - expect(readyDevice?.mode).toBe("full"); - }); - - it("readyProvisionedForLease stores full, replacing a stored slim, when the driver reports no mode (#makeReadyForLease, provisioning path)", async () => { + // provisioning-branch code path the "shutdown" test above covers for the other branch. const clock = new FakeClock(1_000); const eventBus = new EventBus(clock); const driver = new FakeDriver({ clock, platform: "ios" }); @@ -621,6 +483,7 @@ describe("ManagedDeviceLifecycle", () => { ); const device = registry.snapshot.devices[0]; if (device === undefined) throw new Error("expected seeded device"); + expect(device.mode).toBe("slim"); const handoff = await lifecycle.readyProvisionedForLease(device); @@ -674,8 +537,10 @@ describe("ManagedDeviceLifecycle", () => { it("passes a slim spec's mode to makeReady on a prepare boot, from provisioning and from shutdown", async () => { const harness = await slimHarness(); - const ready = await harness.lifecycle.readyProvisioned(harness.device); - if (ready === undefined) throw new Error("expected a ready device"); + const provisioned = await harness.lifecycle.readyProvisionedForLease(harness.device); + if (provisioned === undefined) throw new Error("expected a ready device"); + provisioned.claim.release(); + const ready = provisioned.device; await harness.lifecycle.shutdown(ready, "test", "cleanup"); const shutdown = harness.registry.snapshot.devices[0]; if (shutdown === undefined) throw new Error("expected the device"); @@ -693,8 +558,10 @@ describe("ManagedDeviceLifecycle", () => { it("passes a slim spec's mode on a recovery boot too, under purpose recover", async () => { const harness = await slimHarness(); - const ready = await harness.lifecycle.readyProvisioned(harness.device); - if (ready === undefined) throw new Error("expected a ready device"); + const provisioned = await harness.lifecycle.readyProvisionedForLease(harness.device); + if (provisioned === undefined) throw new Error("expected a ready device"); + provisioned.claim.release(); + const ready = provisioned.device; const lease = await harness.registry.createLease({ deviceId: ready.id, ownerId: "agent", diff --git a/src/core/managed-device-lifecycle.ts b/src/core/managed-device-lifecycle.ts index e8b542587..884732800 100644 --- a/src/core/managed-device-lifecycle.ts +++ b/src/core/managed-device-lifecycle.ts @@ -65,18 +65,6 @@ export class ManagedDeviceLifecycle { private readonly clock: Clock, ) {} - // fallow-ignore-next-line unused-class-member -- no production caller: superseded by bootForLease, still covered by its own tests. - async boot( - target: DeviceRecord, - claim?: DeviceOperationClaim, - ): Promise { - return this.#makeReady(target, "shutdown", claim); - } - - async readyProvisioned(target: DeviceRecord): Promise { - return this.#makeReady(target, "provisioning"); - } - /** Makes a device ready while retaining its claim for an immediate lease handoff. */ // fallow-ignore-next-line unused-class-member -- reached through LeaseAcquisitionCoordinator's lifecycle port. async bootForLease( @@ -223,40 +211,6 @@ export class ManagedDeviceLifecycle { } } - async #makeReady( - target: DeviceRecord, - expectedState: "provisioning" | "shutdown", - existingClaim?: DeviceOperationClaim, - ): Promise { - const claimed = await this.#claim(target, [expectedState], "boot", existingClaim); - if (claimed === undefined) return undefined; - const startedAt = this.clock.now(); - - let ready: DriverDevice; - try { - ready = await this.catalog - .get(claimed.device.spec.platform) - .makeReady(toDriverDevice(claimed.device), { - mode: specMode(claimed.device.spec), - purpose: "prepare", - }); - } catch (error: unknown) { - await this.#release(claimed); - throw error; - } - - return this.#commit( - claimed, - [expectedState], - "ready", - { - event: "device.ready", - payload: { bootDuration: this.clock.now() - startedAt, deviceId: claimed.device.id }, - }, - readyTransitionUpdate(ready), - ); - } - async #makeReadyForLease( target: DeviceRecord, expectedState: "provisioning" | "shutdown", @@ -338,13 +292,12 @@ export class ManagedDeviceLifecycle { expectedStates: readonly DeviceState[], to: DeviceState, event: Parameters[2], - update?: DeviceTransitionUpdate, ): Promise { return this.decisions.run(async () => { try { const device = this.#registeredTarget(claimed.device, expectedStates); if (device === undefined) return undefined; - return await this.registry.transitionDevice(device.id, to, event, update); + return await this.registry.transitionDevice(device.id, to, event); } finally { claimed.release(); } From ea73029c0738fcc4f0292f6615606cb393484dbc Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 3 Oct 2026 23:03:57 +0200 Subject: [PATCH 2/8] refactor(core): delete WaitQueue.attachProgress and detachProgress, which nothing calls detachProgress lost its last caller in #185 and attachProgress never had a production caller. A waiter's progress callback is now fixed at create, so it is readonly. --- src/core/wait-queue.test.ts | 23 ----------------------- src/core/wait-queue.ts | 19 ++----------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/src/core/wait-queue.test.ts b/src/core/wait-queue.test.ts index 9f6364bfd..283fbcdf8 100644 --- a/src/core/wait-queue.test.ts +++ b/src/core/wait-queue.test.ts @@ -57,7 +57,6 @@ describe("WaitQueue", () => { expect(() => other.markProcessing(waiter)).toThrow(ForeignWaiterError); expect(() => other.markNew(waiter)).toThrow(ForeignWaiterError); expect(() => other.isQueued(waiter)).toThrow(ForeignWaiterError); - expect(() => other.attachProgress(waiter, () => undefined)).toThrow(ForeignWaiterError); expect(() => other.notifyProgress(waiter, { etaMs: 10, stage: "booting" })).toThrow( ForeignWaiterError, ); @@ -250,28 +249,6 @@ describe("WaitQueue", () => { expect(received).toEqual([]); }); - it("attaches and detaches queued progress without changing the request outcome", () => { - const received: LeaseProgress[] = []; - const reattached: LeaseProgress[] = []; - const { queue } = createQueue(); - const waiter = queue.create(request, { - onProgress: (progress) => received.push(progress), - requesterId: "agent", - ownerId: "agent", - }); - - queue.enqueue(waiter); - expect(queue.detachProgress("agent")).toBe(true); - queue.notifyProgress(waiter, { etaMs: 20, stage: "booting" }); - expect(queue.attachProgress(waiter, (progress) => reattached.push(progress))).toBe(true); - queue.notifyProgress(waiter, { etaMs: 20, stage: "booting" }); - - expect(received).toEqual([{ queuePosition: 1, stage: "queued" }]); - expect(reattached).toEqual([{ etaMs: 20, stage: "booting" }]); - expect(queue.resolve(waiter, grant())).toBe(true); - expect(waiter.state).toBe("granted"); - }); - it("settles waiters exactly once and cancels a settled waiter's timeout", async () => { const { clock, queue } = createQueue(); const waiter = createWaiter(queue, "agent", { timeoutMs: 10 }); diff --git a/src/core/wait-queue.ts b/src/core/wait-queue.ts index 8a33af686..766729e17 100644 --- a/src/core/wait-queue.ts +++ b/src/core/wait-queue.ts @@ -101,7 +101,7 @@ export interface Waiter { } interface MutableWaiter extends Waiter { - onProgress: ((progress: LeaseProgress) => void) | undefined; + readonly onProgress: ((progress: LeaseProgress) => void) | undefined; rejectPromise: (error: Error) => void; resolvePromise: (grant: LeaseGrant) => void; state: WaiterState; @@ -178,8 +178,7 @@ export class WaitQueue { /** * Finds a requester's waiter across every non-terminal state, not just the FIFO list -- a * waiter driven straight to `processing` on its first attempt never gets enqueued at all, so - * a caller deciding cancellability needs this broader membership, unlike `detachProgress` - * which only ever needs to reach an already-queued entry. + * a caller deciding cancellability needs this broader membership. */ findPendingWaiter(requesterId: string): Waiter | undefined { for (const waiter of this.#pendingWaiters) { @@ -273,20 +272,6 @@ export class WaitQueue { return this.#waiters.includes(this.#mutable(waiter)); } - detachProgress(requesterId: string): boolean { - const waiter = this.#waiters.find((candidate) => candidate.options.requesterId === requesterId); - if (waiter === undefined) return false; - waiter.onProgress = undefined; - return true; - } - - attachProgress(waiter: Waiter, onProgress: (progress: LeaseProgress) => void): boolean { - const mutable = this.#mutable(waiter); - if (isTerminal(mutable.state)) return false; - mutable.onProgress = onProgress; - return true; - } - /** * P3 (round 2 review): a terminal waiter never gets a push. Before this guard, `enqueue` * rejecting synchronously (the deadline-check branch above) left a caller free to keep calling From 5df96e26c1b4d5060df98fcaffd9b6cbe19780ca Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 3 Oct 2026 23:04:43 +0200 Subject: [PATCH 3/8] refactor(core): delete LeaseEngine.executeCleanup, which nothing calls The daemon wires leaseEngine.cleanup straight into the reaper. Tests now call that executor directly instead of the wrapper. --- src/core/lease-engine.test.ts | 4 ++-- src/core/lease-engine.ts | 10 ---------- src/core/reaper.test.ts | 5 +---- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/core/lease-engine.test.ts b/src/core/lease-engine.test.ts index f4d32990c..112877216 100644 --- a/src/core/lease-engine.test.ts +++ b/src/core/lease-engine.test.ts @@ -1401,7 +1401,7 @@ describe("LeaseEngine RAM budget by mode", () => { await before.engine.release(grant.lease.id, "explicit"); } await before.engine.settle(); - await before.engine.executeCleanup({ + await before.engine.cleanup.execute({ action: "shutdown", reason: "test", rule: "test", @@ -1459,7 +1459,7 @@ describe("LeaseEngine RAM budget by mode", () => { ["shutdown", idle.device.id], ["destroy", idle.device.id], ] as const) { - await after.engine.executeCleanup({ action, reason: "test", rule: "test", target }); + await after.engine.cleanup.execute({ action, reason: "test", rule: "test", target }); } expect(after.engine.ramBudget).toEqual({ limitBytes: 5 * gibibyte, diff --git a/src/core/lease-engine.ts b/src/core/lease-engine.ts index f2847a898..b7d6e00b9 100644 --- a/src/core/lease-engine.ts +++ b/src/core/lease-engine.ts @@ -6,7 +6,6 @@ import { CapacityCoordinator, capacityDevices, createCapacityStrategy } from "./ import { CleanupExecutor, type CleanupActionExecutor } from "./cleanup-executor.js"; import type { ComponentInstaller } from "./component-installer.js"; import type { Config } from "./config.js"; -import type { Proposal } from "./cleanup/types.js"; import { DeviceOperationClaims } from "./device-operation-claims.js"; import { DeviceProvisioner } from "./device-provisioner.js"; import type { @@ -403,15 +402,6 @@ export class LeaseEngine { return this.#releaseCoordinator.renew(leaseId, ttlMs); } - /** - * Runs one cleanup action through the same decision queue as leasing. The - * reservation prevents a concurrent lease decision from selecting the - * device while its driver operation is in progress. - */ - async executeCleanup(proposal: Proposal): Promise { - return this.cleanup.execute(proposal); - } - #capacityDevices(): readonly CapacityDevice[] { return capacityDevices(this.options.registry.snapshot.devices); } diff --git a/src/core/reaper.test.ts b/src/core/reaper.test.ts index 2025c6e56..452eacfa9 100644 --- a/src/core/reaper.test.ts +++ b/src/core/reaper.test.ts @@ -157,10 +157,7 @@ async function createHarness( }), }); const executor = options.useLeaseEngineExecutor - ? { - execute: (proposal: Parameters[0]) => - engine.executeCleanup(proposal), - } + ? engine.cleanup : (() => { const claims = new DeviceOperationClaims(); const decisions = new SerializedDecision(); From d083ba7b8efc79cc9037e8465ed5f7af3915597c Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 3 Oct 2026 23:05:51 +0200 Subject: [PATCH 4/8] refactor(core): delete assertDiskSpace, superseded by DiskSpaceGuard Nothing has called it since component installs moved to DiskSpaceGuard in #225. The guard's over-limit test now also checks the error names the required and available bytes, which only the deleted test asserted. --- src/core/driver.test.ts | 47 +++++++++++------------------------------ src/core/driver.ts | 34 +++++++---------------------- 2 files changed, 20 insertions(+), 61 deletions(-) diff --git a/src/core/driver.test.ts b/src/core/driver.test.ts index 904af8821..c269704d7 100644 --- a/src/core/driver.test.ts +++ b/src/core/driver.test.ts @@ -1,40 +1,10 @@ import { describe, expect, it } from "vitest"; import { MemoryFilesystem } from "../ports/index.js"; -import { - assertDiskSpace, - DiskSpaceGuard, - InsufficientDiskSpaceError, - sameReceipt, -} from "./driver.js"; +import { DiskSpaceGuard, InsufficientDiskSpaceError, sameReceipt } from "./driver.js"; const gibibyte = 1024 ** 3; -describe("assertDiskSpace", () => { - it("resolves when free space covers the requirement", async () => { - const filesystem = new MemoryFilesystem(10 * gibibyte); - - await expect( - assertDiskSpace(filesystem, "ios", 6 * gibibyte, "/volume"), - ).resolves.toBeUndefined(); - }); - - it("throws InsufficientDiskSpaceError naming required and available bytes when it doesn't", async () => { - const filesystem = new MemoryFilesystem(4 * gibibyte); - - const error = await assertDiskSpace(filesystem, "android", 6 * gibibyte, "/volume").catch( - (caught: unknown) => caught, - ); - - expect(error).toBeInstanceOf(InsufficientDiskSpaceError); - expect(error).toMatchObject({ - availableBytes: 4 * gibibyte, - platform: "android", - requiredBytes: 6 * gibibyte, - }); - }); -}); - describe("DiskSpaceGuard", () => { it("lets a single reservation through when it fits free space", async () => { const filesystem = new MemoryFilesystem(10 * gibibyte); @@ -45,13 +15,20 @@ describe("DiskSpaceGuard", () => { ); }); - it("rejects a reservation that alone exceeds free space, with InsufficientDiskSpaceError", async () => { + it("rejects a reservation that alone exceeds free space with InsufficientDiskSpaceError naming required and available bytes", async () => { const filesystem = new MemoryFilesystem(4 * gibibyte); const guard = new DiskSpaceGuard(); - await expect(guard.reserve(filesystem, "ios", 6 * gibibyte, "/volume")).rejects.toBeInstanceOf( - InsufficientDiskSpaceError, - ); + const error = await guard + .reserve(filesystem, "android", 6 * gibibyte, "/volume") + .catch((caught: unknown) => caught); + + expect(error).toBeInstanceOf(InsufficientDiskSpaceError); + expect(error).toMatchObject({ + availableBytes: 4 * gibibyte, + platform: "android", + requiredBytes: 6 * gibibyte, + }); }); it("rejects a second concurrent reservation that would overfill the volume alongside the first", async () => { diff --git a/src/core/driver.ts b/src/core/driver.ts index 4bea9d3e9..62634cbf8 100644 --- a/src/core/driver.ts +++ b/src/core/driver.ts @@ -788,10 +788,13 @@ export class LicenseNotAcceptedError extends Error { /** * Serializes disk-space preflight across concurrent component installs sharing a volume. - * `assertDiskSpace` alone only ever sees the disk's free space at the instant it is called: two - * installs racing the same preflight (an iOS runtime download and an Android system-image - * install, or two of either) can each observe enough free space and both proceed, jointly - * overfilling the volume neither alone would have. A single shared `DiskSpaceGuard` instance, + * Checked before any multi-GB component download/install, so a full disk fails fast with a + * clear message instead of filling up mid-download (see safety rule 4's spirit -- downloads + * must never surprise the machine they run on). A check of free space alone only ever sees the + * disk at the instant it runs: two installs racing the same preflight (an iOS runtime download + * and an Android system-image install, or two of either) can each observe enough free space and + * both proceed, jointly overfilling the volume neither alone would have. A single shared + * `DiskSpaceGuard` instance, * held by `ComponentInstaller` (wired once in `src/daemon/main.ts`; drivers never see it), * fixes that by tracking bytes reserved but not yet released, keyed per path, and checking free * space *minus* those outstanding reservations rather than free space alone. @@ -807,8 +810,7 @@ export class DiskSpaceGuard { /** * Reserves `requiredBytes` against `path`'s free space, minus whatever this guard already has - * outstanding there. Throws `InsufficientDiskSpaceError` (same shape `assertDiskSpace` throws) - * when the reservation would not fit. On success, returns a release function the caller must + * outstanding there. Throws `InsufficientDiskSpaceError` when the reservation would not fit. On success, returns a release function the caller must * invoke exactly once (typically in a `finally`) once the install this reservation was made * for has settled, freeing the bytes for the next reservation. */ @@ -843,23 +845,3 @@ export class DiskSpaceGuard { }; } } - -/** - * Checked before a driver starts any multi-GB component download/install, so a full disk fails - * fast with a clear message instead of filling up mid-download (see safety rule 4's spirit -- - * downloads must never surprise the machine they run on). `path` defaults to `"."`, the same - * convention `CleanupReaper` uses for its own disk-pressure check (`src/core/reaper.ts`): the - * daemon process's own working-directory volume. Single-shot: does not account for another - * concurrent install's own in-flight reservation -- see `DiskSpaceGuard` for that. - */ -export async function assertDiskSpace( - filesystem: Pick, - platform: Platform, - requiredBytes: number, - path = ".", -): Promise { - const availableBytes = await filesystem.diskFree(path); - if (availableBytes < requiredBytes) { - throw new InsufficientDiskSpaceError(platform, requiredBytes, availableBytes); - } -} From e5c42c6bf40b37ff8a8180884012bd416bdc42ff Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 3 Oct 2026 23:06:35 +0200 Subject: [PATCH 5/8] refactor(ports): drop SystemStats.freeRamBytes, which nothing reads The resource capacity strategy reads only cpuCount and totalRamBytes. The fake's own value-echo test goes with it, and every test fixture stops setting the field. --- docs/internal/ARCHITECTURE.md | 2 +- src/cli/index.test.ts | 5 ----- src/core/acquisition-planner.test.ts | 5 +---- src/core/capacity/contract.test.ts | 1 - src/core/capacity/coordinator.test.ts | 3 --- .../capacity/strategies/fixed/index.test.ts | 8 +++----- .../capacity/strategies/resource/index.test.ts | 9 ++------- src/core/config.test.ts | 1 - src/core/doctor.test.ts | 2 +- src/core/lease-acquisition-coordinator.test.ts | 1 - src/core/lease-engine.test.ts | 5 +---- src/core/nuke.test.ts | 2 -- src/core/reaper.test.ts | 1 - src/core/warm-pool-coordinator.test.ts | 2 -- src/daemon/dispatcher.test.ts | 1 - src/daemon/server.test.ts | 1 - src/mcp/main.test.ts | 2 +- src/ports/system-stats.test.ts | 17 ----------------- src/ports/system-stats.ts | 12 +----------- 19 files changed, 11 insertions(+), 69 deletions(-) delete mode 100644 src/ports/system-stats.test.ts diff --git a/docs/internal/ARCHITECTURE.md b/docs/internal/ARCHITECTURE.md index 7f26be381..c648e19d3 100644 --- a/docs/internal/ARCHITECTURE.md +++ b/docs/internal/ARCHITECTURE.md @@ -1702,7 +1702,7 @@ stats (CPU/RAM/disk), and watching another process for exit: Filesystem — read/write/delete/stat/disk-free ProcessRunner — spawn/exec/kill, capture stdout/stderr Clock — now(), timers (no direct Date/setTimeout in logic) -SystemStats — cpu count, total/free RAM, disk free +SystemStats — cpu count, total RAM HostInfo — operating system, its version, CPU architecture (`sw_vers` on macOS) IpcConnector / IpcListenerFactory — connect to and host daemon IPC endpoints DaemonLauncher — detached daemon startup with append-only combined logs diff --git a/src/cli/index.test.ts b/src/cli/index.test.ts index 140878324..68410d4d0 100644 --- a/src/cli/index.test.ts +++ b/src/cli/index.test.ts @@ -1161,7 +1161,6 @@ describe("CLI: admin credential resolution (ADR 0003 §5)", () => { clock: new FakeClock(0), systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), ipc: ipcTransport, @@ -1198,7 +1197,6 @@ describe("CLI: admin credential resolution (ADR 0003 §5)", () => { clock: new FakeClock(0), systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), ipc: ipcTransport, @@ -4711,7 +4709,6 @@ async function startTestDaemon(): Promise<{ socketPath: string; daemon: DaemonSe registry, systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), }); @@ -4776,7 +4773,6 @@ function realCliEnvironmentPorts( clock: new FakeClock(0), systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), ipc: new MemoryIpcTransport(), @@ -4826,7 +4822,6 @@ async function startInMemoryDaemon(options: { registry, systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), }); diff --git a/src/core/acquisition-planner.test.ts b/src/core/acquisition-planner.test.ts index 46733d4dd..771d24df2 100644 --- a/src/core/acquisition-planner.test.ts +++ b/src/core/acquisition-planner.test.ts @@ -87,10 +87,7 @@ function planner( ) { const claims = new DeviceOperationClaims(); const capacity = new CapacityCoordinator( - createCapacityStrategy( - capacityConfig, - new FakeSystemStats({ cpuCount: 8, freeRamBytes: totalRamBytes, totalRamBytes }), - ), + createCapacityStrategy(capacityConfig, new FakeSystemStats({ cpuCount: 8, totalRamBytes })), ); return { claims, planner: new AcquisitionPlanner(capacity, claims) }; } diff --git a/src/core/capacity/contract.test.ts b/src/core/capacity/contract.test.ts index f337cb931..e48cdfd43 100644 --- a/src/core/capacity/contract.test.ts +++ b/src/core/capacity/contract.test.ts @@ -13,7 +13,6 @@ const gibibyte = 1024 ** 3; function build(name: CapacityStrategyName): CapacityStrategy { const systemStats = new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }); const definition = capacityStrategies[name]; diff --git a/src/core/capacity/coordinator.test.ts b/src/core/capacity/coordinator.test.ts index 38d3b9fec..81dd3fc5b 100644 --- a/src/core/capacity/coordinator.test.ts +++ b/src/core/capacity/coordinator.test.ts @@ -22,7 +22,6 @@ function coordinator(): CapacityCoordinator { }, new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), ), @@ -47,7 +46,6 @@ function sizedCoordinator(): CapacityCoordinator { }, new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 12 * gibibyte, totalRamBytes: 12 * gibibyte, }), ), @@ -160,7 +158,6 @@ describe("CapacityCoordinator", () => { }, new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 12 * gibibyte, totalRamBytes: 12 * gibibyte, }), ), diff --git a/src/core/capacity/strategies/fixed/index.test.ts b/src/core/capacity/strategies/fixed/index.test.ts index 332e69e17..63345cea3 100644 --- a/src/core/capacity/strategies/fixed/index.test.ts +++ b/src/core/capacity/strategies/fixed/index.test.ts @@ -10,7 +10,7 @@ function strategy(options: FixedStrategyOptions) { return fixedStrategy.create( options, // Passed for interface parity only: nothing in this strategy reads it. - new FakeSystemStats({ cpuCount: 1, freeRamBytes: gibibyte, totalRamBytes: gibibyte }), + new FakeSystemStats({ cpuCount: 1, totalRamBytes: gibibyte }), ); } @@ -70,7 +70,7 @@ describe("fixed strategy", () => { it("never refuses on RAM, however little the machine has", () => { const fixed = fixedStrategy.create( { maxRunning: 8 }, - new FakeSystemStats({ cpuCount: 1, freeRamBytes: 0, totalRamBytes: 0 }), + new FakeSystemStats({ cpuCount: 1, totalRamBytes: 0 }), ); expect(fixed.canProvision({ mode: "full", platform: "android" }, ready("android", 7))).toEqual({ @@ -112,9 +112,7 @@ describe("fixed strategy", () => { it("defaults to a machine-independent pin", () => { expect( - fixedStrategy.defaults( - new FakeSystemStats({ cpuCount: 64, freeRamBytes: 0, totalRamBytes: 512 * gibibyte }), - ), + fixedStrategy.defaults(new FakeSystemStats({ cpuCount: 64, totalRamBytes: 512 * gibibyte })), ).toEqual({ maxRunning: 2 }); }); }); diff --git a/src/core/capacity/strategies/resource/index.test.ts b/src/core/capacity/strategies/resource/index.test.ts index f7ba1e1d9..4beefa369 100644 --- a/src/core/capacity/strategies/resource/index.test.ts +++ b/src/core/capacity/strategies/resource/index.test.ts @@ -16,10 +16,7 @@ const options: ResourceStrategyOptions = { }; function withRam(totalRamBytes: number): CapacityStrategy { - return resourceStrategy.create( - options, - new FakeSystemStats({ cpuCount: 8, freeRamBytes: totalRamBytes, totalRamBytes }), - ); + return resourceStrategy.create(options, new FakeSystemStats({ cpuCount: 8, totalRamBytes })); } describe("resource strategy defaults", () => { @@ -27,7 +24,6 @@ describe("resource strategy defaults", () => { const defaults = resourceStrategy.defaults( new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 16 * gibibyte, totalRamBytes: 32 * gibibyte, }), ); @@ -45,7 +41,7 @@ describe("resource strategy defaults", () => { it("keeps at least one device per platform on a small machine", () => { const defaults = resourceStrategy.defaults( - new FakeSystemStats({ cpuCount: 1, freeRamBytes: gibibyte, totalRamBytes: 2 * gibibyte }), + new FakeSystemStats({ cpuCount: 1, totalRamBytes: 2 * gibibyte }), ); expect(defaults.limits.ios.maxDevices).toBe(1); @@ -172,7 +168,6 @@ describe("resource strategy RAM budget by mode", () => { { limits: roomy, ramBudget }, new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 12 * gibibyte, totalRamBytes: 12 * gibibyte, }), ); diff --git a/src/core/config.test.ts b/src/core/config.test.ts index b533ec74e..dab1e9d00 100644 --- a/src/core/config.test.ts +++ b/src/core/config.test.ts @@ -50,7 +50,6 @@ const gibibyte = 1024 ** 3; function createStats(): FakeSystemStats { return new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 16 * gibibyte, totalRamBytes: 32 * gibibyte, }); } diff --git a/src/core/doctor.test.ts b/src/core/doctor.test.ts index 6ea58316c..e9ec4f6f1 100644 --- a/src/core/doctor.test.ts +++ b/src/core/doctor.test.ts @@ -432,7 +432,7 @@ describe("Doctor", () => { eventBus, idGenerator: sequence(), registry, - systemStats: new FakeSystemStats({ cpuCount: 8, freeRamBytes: 32, totalRamBytes: 32 }), + systemStats: new FakeSystemStats({ cpuCount: 8, totalRamBytes: 32 }), }); await new Doctor({ diff --git a/src/core/lease-acquisition-coordinator.test.ts b/src/core/lease-acquisition-coordinator.test.ts index 8677cd67b..bc92a10db 100644 --- a/src/core/lease-acquisition-coordinator.test.ts +++ b/src/core/lease-acquisition-coordinator.test.ts @@ -142,7 +142,6 @@ async function createHarness( config(options.maxDevices, options.maxRunning).capacity, new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), ), diff --git a/src/core/lease-engine.test.ts b/src/core/lease-engine.test.ts index 112877216..7d2d7a74e 100644 --- a/src/core/lease-engine.test.ts +++ b/src/core/lease-engine.test.ts @@ -161,7 +161,7 @@ async function createHarness( idGenerator: { generate: () => `request-${nextId++}` }, ...(options.logger === undefined ? {} : { logger: options.logger }), registry, - systemStats: new FakeSystemStats({ cpuCount: 8, freeRamBytes: totalRamBytes, totalRamBytes }), + systemStats: new FakeSystemStats({ cpuCount: 8, totalRamBytes }), }); return { bus, clock, driver, engine, filesystem, registry }; @@ -1637,7 +1637,6 @@ describe("LeaseEngine startup reclaim backgrounding (#43)", () => { const systemStats = () => new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }); // The physical device survives a daemon restart even though the daemon's @@ -1897,7 +1896,6 @@ describe("LeaseEngine fresh lease identity (#75)", () => { const driver = new FakeDriver({ availableOsVersions: ["26.5"], clock, platform: "ios" }); const systemStats = new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }); const beforeRegistry = await Registry.load({ @@ -2047,7 +2045,6 @@ describe("LeaseEngine fresh lease identity (#75)", () => { registry, systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), }); diff --git a/src/core/nuke.test.ts b/src/core/nuke.test.ts index 536ae4868..da1aad3d7 100644 --- a/src/core/nuke.test.ts +++ b/src/core/nuke.test.ts @@ -63,7 +63,6 @@ describe("Nuke", () => { registry, systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * 1024 ** 3, totalRamBytes: 32 * 1024 ** 3, }), }); @@ -110,7 +109,6 @@ describe("Nuke", () => { registry, systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * 1024 ** 3, totalRamBytes: 32 * 1024 ** 3, }), }); diff --git a/src/core/reaper.test.ts b/src/core/reaper.test.ts index 452eacfa9..dcfaca5ec 100644 --- a/src/core/reaper.test.ts +++ b/src/core/reaper.test.ts @@ -152,7 +152,6 @@ async function createHarness( registry, systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), }); diff --git a/src/core/warm-pool-coordinator.test.ts b/src/core/warm-pool-coordinator.test.ts index 64c61025a..686728b7f 100644 --- a/src/core/warm-pool-coordinator.test.ts +++ b/src/core/warm-pool-coordinator.test.ts @@ -136,7 +136,6 @@ function capacity(): CapacityCoordinator { config.capacity, new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), ), @@ -342,7 +341,6 @@ describe("WarmPoolCoordinator", () => { }, new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 12 * gibibyte, totalRamBytes: 12 * gibibyte, }), ), diff --git a/src/daemon/dispatcher.test.ts b/src/daemon/dispatcher.test.ts index e88122e1b..cb8fcf9b9 100644 --- a/src/daemon/dispatcher.test.ts +++ b/src/daemon/dispatcher.test.ts @@ -254,7 +254,6 @@ async function buildDispatcher( registry, systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), }); diff --git a/src/daemon/server.test.ts b/src/daemon/server.test.ts index bebb7656f..3b004dbcd 100644 --- a/src/daemon/server.test.ts +++ b/src/daemon/server.test.ts @@ -2997,7 +2997,6 @@ async function createHarness( registry, systemStats: new FakeSystemStats({ cpuCount: 8, - freeRamBytes: 32 * gibibyte, totalRamBytes: 32 * gibibyte, }), }); diff --git a/src/mcp/main.test.ts b/src/mcp/main.test.ts index e5dd82949..6b27f2cef 100644 --- a/src/mcp/main.test.ts +++ b/src/mcp/main.test.ts @@ -230,7 +230,7 @@ describe("MCP stdio lifecycle", () => { filesystem: new MemoryFilesystem(), ipc: new MemoryIpcTransport(), launcher: new FakeDaemonLauncher(), - systemStats: new FakeSystemStats({ cpuCount: 1, freeRamBytes: 1, totalRamBytes: 1 }), + systemStats: new FakeSystemStats({ cpuCount: 1, totalRamBytes: 1 }), }, env, ); diff --git a/src/ports/system-stats.test.ts b/src/ports/system-stats.test.ts deleted file mode 100644 index 517cf9b1e..000000000 --- a/src/ports/system-stats.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { describe, expect, it } from "vitest"; - -import { FakeSystemStats } from "./index.js"; - -describe("FakeSystemStats", () => { - it("returns its configured system capacity values", () => { - const stats = new FakeSystemStats({ - cpuCount: 12, - freeRamBytes: 16_000, - totalRamBytes: 32_000, - }); - - expect(stats.cpuCount()).toBe(12); - expect(stats.totalRamBytes()).toBe(32_000); - expect(stats.freeRamBytes()).toBe(16_000); - }); -}); diff --git a/src/ports/system-stats.ts b/src/ports/system-stats.ts index 19b68c9fc..6a2d876a3 100644 --- a/src/ports/system-stats.ts +++ b/src/ports/system-stats.ts @@ -1,9 +1,8 @@ -import { availableParallelism, freemem, totalmem } from "node:os"; +import { availableParallelism, totalmem } from "node:os"; export interface SystemStats { cpuCount(): number; totalRamBytes(): number; - freeRamBytes(): number; } export class NodeSystemStats implements SystemStats { @@ -14,16 +13,11 @@ export class NodeSystemStats implements SystemStats { totalRamBytes(): number { return totalmem(); } - - freeRamBytes(): number { - return freemem(); - } } export interface SystemStatsValues { readonly cpuCount: number; readonly totalRamBytes: number; - readonly freeRamBytes: number; } export class FakeSystemStats implements SystemStats { @@ -36,8 +30,4 @@ export class FakeSystemStats implements SystemStats { totalRamBytes(): number { return this.values.totalRamBytes; } - - freeRamBytes(): number { - return this.values.freeRamBytes; - } } From fcfa0b265ca2b2840612402388171f5b4c218595 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 3 Oct 2026 23:07:11 +0200 Subject: [PATCH 6/8] chore: delete src/index.ts, which nothing imports It exported only projectName. The package publishes ./client and ./admin and the simlock bin, so this file shipped as an unreachable module; fallow no longer lists it as an entry. --- .fallowrc.json | 1 - src/index.test.ts | 9 --------- src/index.ts | 1 - 3 files changed, 11 deletions(-) delete mode 100644 src/index.test.ts delete mode 100644 src/index.ts diff --git a/.fallowrc.json b/.fallowrc.json index f1878ee31..fc8f1a517 100644 --- a/.fallowrc.json +++ b/.fallowrc.json @@ -8,7 +8,6 @@ // The web console is its own entry: Vite loads ui/index.html, which loads ui/src/main.tsx. The // browser lane's specs are Playwright entry points, as the e2e tests are vitest's. "entry": [ - "src/index.ts", "src/cli/main.ts", "src/daemon/main.ts", "e2e/**/*.test.ts", diff --git a/src/index.test.ts b/src/index.test.ts deleted file mode 100644 index 11b27f631..000000000 --- a/src/index.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { describe, expect, it } from "vitest"; - -import { projectName } from "./index.js"; - -describe("projectName", () => { - it("identifies the project", () => { - expect(projectName).toBe("simlock"); - }); -}); diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 67aeae2a6..000000000 --- a/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export const projectName = "simlock"; From d5a01da7aefb5fc2d06dbd291b0370dc5929cf19 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 3 Oct 2026 23:07:33 +0200 Subject: [PATCH 7/8] refactor(ios): delete SLIM_CATEGORY_NAMES, which nothing uses It never had a production caller; its only test compared it to the expression that defines it. --- src/drivers/ios/slim-labels.test.ts | 12 +----------- src/drivers/ios/slim-labels.ts | 2 -- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/drivers/ios/slim-labels.test.ts b/src/drivers/ios/slim-labels.test.ts index 7ebf8dc21..fac323e3c 100644 --- a/src/drivers/ios/slim-labels.test.ts +++ b/src/drivers/ios/slim-labels.test.ts @@ -1,12 +1,6 @@ import { describe, expect, it } from "vitest"; -import { - labelsFor, - resolveSlimCategories, - SLIM_CATEGORIES, - SLIM_CATEGORY_NAMES, - slimSignature, -} from "./slim-labels.js"; +import { labelsFor, resolveSlimCategories, SLIM_CATEGORIES, slimSignature } from "./slim-labels.js"; describe("SLIM_CATEGORIES", () => { it("every category has at least one label", () => { @@ -22,10 +16,6 @@ describe("SLIM_CATEGORIES", () => { } } }); - - it("SLIM_CATEGORY_NAMES matches the category list", () => { - expect(SLIM_CATEGORY_NAMES).toEqual(SLIM_CATEGORIES.map((c) => c.name)); - }); }); describe("resolveSlimCategories", () => { diff --git a/src/drivers/ios/slim-labels.ts b/src/drivers/ios/slim-labels.ts index d46afbe6a..33dfc1e50 100644 --- a/src/drivers/ios/slim-labels.ts +++ b/src/drivers/ios/slim-labels.ts @@ -285,8 +285,6 @@ export const SLIM_CATEGORIES: readonly SlimCategory[] = [ }, ]; -export const SLIM_CATEGORY_NAMES: readonly string[] = SLIM_CATEGORIES.map((c) => c.name); - /** * Resolves a set of requested category names to their {@link SlimCategory} * definitions. `undefined` (no filter given) resolves to every category. From 64cb3affe970b24bd5ad631feda718dfe9be2edb Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 3 Oct 2026 23:09:08 +0200 Subject: [PATCH 8/8] docs(core): reflow the DiskSpaceGuard comments after assertDiskSpace went --- src/core/driver.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/core/driver.ts b/src/core/driver.ts index 62634cbf8..856ba8982 100644 --- a/src/core/driver.ts +++ b/src/core/driver.ts @@ -794,10 +794,10 @@ export class LicenseNotAcceptedError extends Error { * disk at the instant it runs: two installs racing the same preflight (an iOS runtime download * and an Android system-image install, or two of either) can each observe enough free space and * both proceed, jointly overfilling the volume neither alone would have. A single shared - * `DiskSpaceGuard` instance, - * held by `ComponentInstaller` (wired once in `src/daemon/main.ts`; drivers never see it), - * fixes that by tracking bytes reserved but not yet released, keyed per path, and checking free - * space *minus* those outstanding reservations rather than free space alone. + * `DiskSpaceGuard` instance, held by `ComponentInstaller` (wired once in `src/daemon/main.ts`; + * drivers never see it), fixes that by tracking bytes reserved but not yet released, keyed per + * path, and checking free space *minus* those outstanding reservations rather than free space + * alone. * * `reserve` resolves or throws synchronously with respect to any other in-flight `reserve` call: * the only `await` is `filesystem.diskFree`, and the check-then-record step immediately after it @@ -810,9 +810,10 @@ export class DiskSpaceGuard { /** * Reserves `requiredBytes` against `path`'s free space, minus whatever this guard already has - * outstanding there. Throws `InsufficientDiskSpaceError` when the reservation would not fit. On success, returns a release function the caller must - * invoke exactly once (typically in a `finally`) once the install this reservation was made - * for has settled, freeing the bytes for the next reservation. + * outstanding there. Throws `InsufficientDiskSpaceError` when the reservation would not fit. + * On success, returns a release function the caller must invoke exactly once (typically in a + * `finally`) once the install this reservation was made for has settled, freeing the bytes for + * the next reservation. */ async reserve( filesystem: Pick,