From ba10aaf52ed14073509573950927c8f8714236e3 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Thu, 3 Sep 2026 09:32:17 -0700 Subject: [PATCH] test(hygiene): close two more brains found by a broadened rescan A second, structural pass of the honest scan (any local helper that constructs a Brainy directly, not just ones named like openBrain/makeBrain, plus support for new Brainy(...) generics) surfaced two more real leaks outside the first 93-file list: writer-lock-fencing.test.ts's `second` (a rejected-init() brain never pushed into the file's own tracked array) and plugin-version-coupling.test.ts's last case (a rejected-init() brain with no close at all). --- tests/integration/writer-lock-fencing.test.ts | 1 + tests/unit/plugin-version-coupling.test.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/integration/writer-lock-fencing.test.ts b/tests/integration/writer-lock-fencing.test.ts index e9f98dac..d5b82c30 100644 --- a/tests/integration/writer-lock-fencing.test.ts +++ b/tests/integration/writer-lock-fencing.test.ts @@ -61,6 +61,7 @@ describe('writer-lock fencing', () => { // Old rule: heartbeat-age eviction → silent takeover → split brain. // New rule: live PID = live writer; the second opener throws typed. const second = new Brainy({ storage: { type: 'filesystem', path: dir }, requireSubtype: false }) + brains.push(second) await expect(second.init()).rejects.toMatchObject({ code: 'BRAINY_WRITER_LOCKED' }) }, 120000) diff --git a/tests/unit/plugin-version-coupling.test.ts b/tests/unit/plugin-version-coupling.test.ts index ffcc2a88..d4685ae2 100644 --- a/tests/unit/plugin-version-coupling.test.ts +++ b/tests/unit/plugin-version-coupling.test.ts @@ -143,5 +143,6 @@ describe('version coupling at init() — no silent fallback', () => { plugins: ['@soulcraft/this-package-does-not-exist-xyz'] }) await expect(brain.init()).rejects.toThrow(/could not be loaded|config\.plugins/) + await brain.close().catch(() => {}) }) })