Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

test(projects): isolate count and deadline continuation budgets

Rahmanf3c9bfd7bc48
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 5ada18ed..e3f2363b 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -10,6 +10,10 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
- `store` import portable connected app manifests
+**Tests**
+
+- `projects` isolate count and deadline continuation budgets
+
## 2026-09-27
**Added**
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index eef330c2..91b29dc6 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -2,6 +2,8 @@
Added a bounded connected-app manifest profile and Store file/paste → review → connect journey. Portable publisher/version/presentation metadata stays separate from per-instance IDs and endpoints; one definition can connect several instances. The shared validator rejects unsupported fields/versions and executable payloads in both client and server. Import uses existing Owner authority, revision locking, cookie isolation and atomic registry storage. Connection edits preserve the original manifest and disconnect never touches service data. The starter JSON and current contract document what works; the full feature loader, verified remote manef.dev catalog and generic installers remain pending. No dependency on unrelated manef-ui/manef-db is introduced.
+The full coverage gate exposed an existing count-cap continuation test racing the independent four-second scan budget under load. Count-cap fixtures now use a controlled clock; an additional deterministic deadline case verifies that timed-out scans resume without losing or duplicating projects. Production scan limits and assertions remain unchanged.
+
## 2026-09-27 — External feature contract and registry audit
## 2026-09-27 — Readable Settings action labels
diff --git a/lib/host/project-continuation.test.ts b/lib/host/project-continuation.test.ts
index eb0f0692..06018fec 100644
--- a/lib/host/project-continuation.test.ts
+++ b/lib/host/project-continuation.test.ts
@@ -1,4 +1,4 @@
-import { afterAll, describe, expect, it } from "vitest";
+import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { promises as fs } from "fs";
import os from "os";
import path from "path";
@@ -12,6 +12,12 @@ const { listProjects } = await import("./project-list");
const { PROJECT_LIMITS } = await import("./project-roots");
const setRoots = (...roots: string[]) => { process.env.OS_FS_READ_ROOTS = roots.join(":"); };
+// Count-cap cases must not accidentally exercise the independent wall-clock budget
+// when coverage workers saturate the host. The deadline case below advances this clock.
+const epoch = 1_800_000_000_000;
+beforeEach(() => { vi.spyOn(Date, "now").mockReturnValue(epoch); });
+afterEach(() => { vi.restoreAllMocks(); });
+
afterAll(async () => {
if (previous === undefined) delete process.env.OS_FS_READ_ROOTS;
else process.env.OS_FS_READ_ROOTS = previous;
@@ -125,3 +131,23 @@ describe("a complete scan still reports no continuation", () => {
expect(projects.map((p) => p.name)).toEqual(["one"]);
});
});
+
+describe("deadline continuation", () => {
+ it("resumes the timed-out scan without dropping or duplicating processed entries", async () => {
+ const root = path.join(base, "deadline");
+ const count = 12;
+ await Promise.all(Array.from({ length: count }, (_, i) => fs.mkdir(path.join(root, `p${i}`), { recursive: true })));
+ setRoots(root);
+ let ticks = 0;
+ vi.mocked(Date.now).mockImplementation(() => epoch + (++ticks < 6 ? 0 : PROJECT_LIMITS.maxScanMs + 1));
+ const first = await listProjects({ limit: PROJECT_LIMITS.maxPageSize });
+ expect(first.scan.truncationReasons).toContain("deadline");
+ expect(first.projects.length).toBeGreaterThan(0);
+ expect(first.projects.length).toBeLessThan(count);
+ expect(first.scan.continuation?.cursor).toBeTruthy();
+ vi.mocked(Date.now).mockReturnValue(epoch + PROJECT_LIMITS.maxScanMs + 1);
+ const remaining = await drain(first.scan.continuation!.cursor);
+ expect(first.projects.every(project => !remaining.has(project.path))).toBe(true);
+ expect(first.projects.length + remaining.size).toBe(count);
+ });
+});