From cf3f0fa90a8f5ac88ede37f78b5262b97f4b5721 Mon Sep 17 00:00:00 2001 From: Resham Joshi <65915470+iamtoruk@users.noreply.github.com> Date: Fri, 6 Nov 2026 05:54:36 -0800 Subject: [PATCH] test(grokbot): a removed import's rows go while the mirror's rows stay --- tests/providers/grokbot.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/providers/grokbot.test.ts b/tests/providers/grokbot.test.ts index 563c3eaa..c9305955 100644 --- a/tests/providers/grokbot.test.ts +++ b/tests/providers/grokbot.test.ts @@ -306,3 +306,30 @@ describe('grokbot sliding mirror', () => { } }) }) + +describe('grokbot durable mirror beside an import', () => { + it('evicts a removed import\'s rows while the mirror\'s rows stay', async () => { + const originalCacheDir = process.env['CODEBURN_CACHE_DIR'] + process.env['CODEBURN_CACHE_DIR'] = join(dir, 'cb-cache') + try { + const { CURSOR_CSV_HEADER, importCursorCsvText, removeCursorImport } = await import('../../src/cursor-import.js') + const { clearSessionCache, parseAllSessions } = await import('../../src/parser.js') + await writeTranscript(BOT_A, [userMessage('u1', 'r1', 'question', T0), botMessage('b1', 'r1', 'answer'.repeat(20), T0 + 1000)]) + // Ten days after the mirror's request, so the import's coverage never + // replaces it. + const row = [new Date(T0 + 10 * 86_400_000).toISOString(), '', '', 'Included', 'grok-bot-automation', 'No', 0, 40, 70000, 7, 70047, 'Included'] + await importCursorCsvText([CURSOR_CSV_HEADER.join(','), row.map(v => `"${v}"`).join(',')].join('\n') + '\n', T0 + 11 * 86_400_000) + const projects = async () => { + clearSessionCache() + return (await parseAllSessions(undefined, 'grokbot')).map(p => [p.project, p.totalApiCalls]).sort() + } + expect(await projects()).toEqual([[BOT_A, 1], ['Grok Bot (imported)', 1]]) + + await removeCursorImport() + expect(await projects()).toEqual([[BOT_A, 1]]) + } finally { + if (originalCacheDir === undefined) delete process.env['CODEBURN_CACHE_DIR'] + else process.env['CODEBURN_CACHE_DIR'] = originalCacheDir + } + }) +})