From cdc3f93449312fad6fdd9e9d471d0c94f4e80f6d Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Sun, 21 Jun 2026 13:18:08 +0000 Subject: [PATCH] test(lbug): assert temp-conn deleteNodesForFile skips withConnLock (negative gate, #2264) The positive case (singleton deleteNodesForFile locks each per-table count) was covered, but not the negative branch of the targetConn === conn gate: a per-file/temp connection (dbPath provided) must NOT take the singleton lock, or temp-conn callers would needlessly contend with it. Add the negative-gate assertion so a regression that unconditionally locks is caught. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01JBJomjoTdBV2eveDVq4JMm --- .../lbug-conn-serialization.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gitnexus/test/integration/lbug-conn-serialization.test.ts b/gitnexus/test/integration/lbug-conn-serialization.test.ts index f825b9737..3f0d68364 100644 --- a/gitnexus/test/integration/lbug-conn-serialization.test.ts +++ b/gitnexus/test/integration/lbug-conn-serialization.test.ts @@ -106,6 +106,24 @@ withTestLbugDB('conn-serialization', () => { expect(lockSpy).toHaveBeenCalled(); expect(result).toMatchObject({ edgesDeleted: 0 }); }); + + it('U5: deleteNodesForFile on a temp dbPath does NOT take the lock (negative gate)', async () => { + // The targetConn === conn gate's negative branch: a per-file/temp connection + // (dbPath provided) must NOT take the singleton lock, so temp-conn callers + // can't contend with the singleton. Mirrors the positive U3 case above so a + // regression that unconditionally locks is caught. (#2264) + const { createTempDir } = await import('../helpers/test-db.js'); + const { deleteNodesForFile } = await import('../../src/core/lbug/lbug-adapter.js'); + const temp = await createTempDir('gn-negative-gate-'); + try { + lockSpy.mockClear(); + const result = await deleteNodesForFile('any/path.ts', temp.dbPath); + expect(lockSpy).not.toHaveBeenCalled(); + expect(result).toMatchObject({ deletedNodes: 0 }); + } finally { + await temp.cleanup(); + } + }); }); });