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(security): drain lock contenders before fixture cleanup

Rahman1bd3698aa3fe
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 914b5a2f..3a1b07fd 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -40,6 +40,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Tests**
+- `security` drain lock contenders before fixture cleanup
- `gateway` reap lock holder fixtures without orphan processes
- `workflows` stabilize repeated artifact inspection journeys
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index b3966cc1..5546ebe9 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -6,6 +6,12 @@ and GitHub Actions entries. A regression checks every configured ecosystem, so a
another updater cannot silently omit the policy. Scanner rules and severity gates are
unchanged; this corrects update configuration without changing the application runtime.
+The full gate also exposed a scheduler-sensitive 24-contender lock fixture: its four-second
+acquisition budget could expire under parallel coverage while the isolated test passed.
+The fixture retains every contender and all mutual-exclusion assertions, waits for all
+outcomes before removing its files, and uses a bounded ten-second test-only budget.
+Production lock deadlines and the short fail-closed denial tests are unchanged.
+
## 2026-09-17 — Lock the native build bootstrap without touching the runtime tree
The complete PR/branch audit found open Scorecard finding #136 in the user-local
diff --git a/lib/security-store-lock.test.ts b/lib/security-store-lock.test.ts
index 39493a08..857f3926 100644
--- a/lib/security-store-lock.test.ts
+++ b/lib/security-store-lock.test.ts
@@ -22,18 +22,19 @@ describe("security-store stale recovery", () => {
let active = 0;
let maxActive = 0;
const entered: number[] = [];
- await Promise.all(Array.from({ length: 24 }, (_, index) =>
+ const results = await Promise.allSettled(Array.from({ length: 24 }, (_, index) =>
withSecurityStoreLock(store, async () => {
active += 1;
maxActive = Math.max(maxActive, active);
entered.push(index);
await new Promise((resolve) => setTimeout(resolve, 2));
active -= 1;
- // Coverage runs instrument hundreds of files in parallel and can delay fsync-heavy
- // contenders beyond 2s without changing mutual exclusion. Keep the test budget
- // below Vitest's outer timeout while avoiding a scheduler-dependent false failure.
- }, { waitMs: 1, busyTimeoutMs: 4_000, staleMs: 1 }),
+ // This checks 24-way mutual exclusion, not throughput under parallel coverage.
+ // Retain all contenders, allow their fsyncs to drain, and await every outcome
+ // before fixture cleanup. Production and fail-closed timeout tests stay unchanged.
+ }, { waitMs: 1, busyTimeoutMs: 10_000, staleMs: 1 }),
));
+ expect(results.filter(result => result.status === "rejected")).toEqual([]);
expect(maxActive).toBe(1);
expect(entered).toHaveLength(24);
await expect(fs.stat(lock)).rejects.toMatchObject({ code: "ENOENT" });