Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(test): make three storage checks pass off Linux

lmlihengc051bfbe71c1
diff --git a/packages/core/test/storage.test.ts b/packages/core/test/storage.test.ts
index 2e7f9f04..2dfe54a3 100644
--- a/packages/core/test/storage.test.ts
+++ b/packages/core/test/storage.test.ts
@@ -343,9 +343,11 @@ describe("scanStorage", () => {
});
// A mode-000 directory is unreadable to the tests' own user but not to root, and CI runs as
- // an ordinary user while a developer's container often does not. Skipping beats a test that
- // passes for the wrong reason.
- it.skipIf(process.getuid?.() === 0)(
+ // an ordinary user while a developer's container often does not; on Windows the mode bits do
+ // not remove read access at all. Skipping beats a test that passes for the wrong reason.
+ // The expected path is the directory's realpath, because the scan walks the root's realpath
+ // (on macOS a temp dir reaches it through /var → /private/var).
+ it.skipIf(process.getuid?.() === 0 || process.platform === "win32")(
"reports a directory it cannot read instead of throwing or guessing",
async () => {
const root = await scaffold();
@@ -354,7 +356,7 @@ describe("scanStorage", () => {
await fs.chmod(sealed, 0o000);
try {
const ledger = await scanStorage(root, emptyLiveSet());
- expect(ledger.unreadable).toContain(sealed);
+ expect(ledger.unreadable).toContain(await fs.realpath(sealed));
expect(ledger.classes.find((c) => c.class === "session_drafts")?.entries).toBe(1);
} finally {
await fs.chmod(sealed, 0o755);
diff --git a/packages/server/test/admin-storage.test.ts b/packages/server/test/admin-storage.test.ts
index ce5af5ac..7fb2a7f5 100644
--- a/packages/server/test/admin-storage.test.ts
+++ b/packages/server/test/admin-storage.test.ts
@@ -95,7 +95,9 @@ describe("admin storage ledger", () => {
);
await fs.mkdir(workspace, { recursive: true });
await fs.writeFile(path.join(workspace, "scratch.txt"), "left behind\n");
- const relative = path.relative(t.root, workspace);
+ // The ledger's paths are `/`-separated on every platform (they are what a plan records),
+ // so the lookup normalizes the host's separator rather than assuming it.
+ const relative = path.relative(t.root, workspace).split(path.sep).join("/");
const candidate = (report: StorageReport) =>
report.candidates.find((entry) => entry.path === relative);
diff --git a/packages/ui-gallery/src/app/mock/fixtures.ts b/packages/ui-gallery/src/app/mock/fixtures.ts
index abb2730b..e2501a7a 100644
--- a/packages/ui-gallery/src/app/mock/fixtures.ts
+++ b/packages/ui-gallery/src/app/mock/fixtures.ts
@@ -31,6 +31,7 @@ import type {
ProjectSummary,
ProxyProbeTargetsResponse,
ServerSettings,
+ StorageReport,
SessionContextResponse,
SessionInfo,
SkillMetadataItem,
@@ -91,6 +92,8 @@ export interface DemoFixtures {
me: Omit<MeResponse, "user">;
prefs: UiPrefs;
serverSettings: ServerSettings;
+ /** The storage ledger the Settings page renders; read-only, so the mock only ever answers it. */
+ storageReport: StorageReport;
project: ProjectSummary;
members: MemberInfo[];
agents: AgentSummary[];
@@ -1459,6 +1462,106 @@ export function buildFixtures(lang: Lang, now: number): DemoFixtures {
attachmentTotalMb: 120,
companyMode: false,
},
+ // A ledger with one of everything the page has a branch for: a class that is never a
+ // candidate, three that are, a duplicate-looking environment pair, and one path the scan
+ // could not read (the page shows its gaps rather than rounding them away).
+ storageReport: {
+ root: "/home/demo/.adelie/data",
+ scannedAt: iso(ago(0)),
+ totalBytes: 5_819_900_000,
+ classes: [
+ {
+ class: "protected",
+ bytes: 19_700_000,
+ files: 1269,
+ entries: 43,
+ candidateEntries: 0,
+ candidateBytes: 0,
+ },
+ {
+ class: "tmp_workspaces",
+ bytes: 591_500_000,
+ files: 23_731,
+ entries: 83,
+ candidateEntries: 2,
+ candidateBytes: 1_448_000,
+ },
+ {
+ class: "session_drafts",
+ bytes: 1_500_000_000,
+ files: 56_181,
+ entries: 282,
+ candidateEntries: 1,
+ candidateBytes: 3_460_000,
+ },
+ {
+ class: "traces",
+ bytes: 462_300_000,
+ files: 3344,
+ entries: 51,
+ candidateEntries: 0,
+ candidateBytes: 0,
+ },
+ {
+ class: "shared_env",
+ bytes: 3_220_000_000,
+ files: 101_755,
+ entries: 28,
+ candidateEntries: 0,
+ candidateBytes: 0,
+ },
+ { class: "trash", bytes: 0, files: 0, entries: 0, candidateEntries: 0, candidateBytes: 0 },
+ {
+ class: "database",
+ bytes: 23_900_000,
+ files: 3,
+ entries: 3,
+ candidateEntries: 0,
+ candidateBytes: 0,
+ },
+ {
+ class: "other",
+ bytes: 2_500_000,
+ files: 13,
+ entries: 5,
+ candidateEntries: 0,
+ candidateBytes: 0,
+ },
+ ],
+ candidates: [
+ {
+ path: `${IDS.project}/agents/${IDS.agents.docs}/workspaces/tmp-8e8a3ace`,
+ class: "tmp_workspaces",
+ bytes: 1_442_000,
+ files: 12,
+ lastModifiedAt: iso(ago(2, 30)),
+ referenced: false,
+ rules: ["unreferenced"],
+ },
+ {
+ path: `${IDS.project}/agents/${IDS.agents.docs}/scratchpad/session-2026-09-30-10-00-00-1a2b3c4d`,
+ class: "session_drafts",
+ bytes: 3_460_000,
+ files: 5,
+ lastModifiedAt: null,
+ referenced: false,
+ rules: ["orphan"],
+ },
+ ],
+ sharedEnvGroups: [
+ {
+ kind: "name",
+ key: "playwright",
+ members: [
+ `${IDS.project}/agents/${IDS.agents.docs}/shared_env/playwright`,
+ `${IDS.project}/agents/${IDS.agents.notes}/shared_env/playwright`,
+ ],
+ bytes: 243_000_000,
+ },
+ ],
+ disk: { freeBytes: 8_100_000_000, totalBytes: 52_700_000_000 },
+ unreadable: [`${IDS.project}/agents/${IDS.agents.notes}/scratchpad/sealed`],
+ },
project,
members: [
{ userId: user.userId, role: "owner", createdAt: project.createdAt },
diff --git a/packages/ui-gallery/src/app/mock/routes.ts b/packages/ui-gallery/src/app/mock/routes.ts
index f3e2f70d..4d2b6550 100644
--- a/packages/ui-gallery/src/app/mock/routes.ts
+++ b/packages/ui-gallery/src/app/mock/routes.ts
@@ -85,6 +85,7 @@ import type {
SchedulesResponse,
SemanticIdSuggestResponse,
ServerSettingsResponse,
+ StorageReportResponse,
SessionCategory,
SessionCategoryCounts,
SessionContextResponse,
@@ -223,6 +224,11 @@ router
.get("/api/admin/settings", ({ store }): ServerSettingsResponse => ({
settings: store.f.serverSettings,
}))
+ // Read-only by contract: the gallery answers the ledger and nothing else, exactly as the
+ // server does — there is no route here a cleanup could ride on.
+ .get("/api/admin/storage", ({ store }): StorageReportResponse => ({
+ report: store.f.storageReport,
+ }))
.put("/api/admin/settings", ({ store, body }): ServerSettingsResponse => {
store.f.serverSettings = { ...store.f.serverSettings, ...record(body) };
return { settings: store.f.serverSettings };