From f5673418a092a1fd6320cfed3220845ed768d3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Magyar?= Date: Sun, 4 Oct 2026 07:39:27 +0000 Subject: [PATCH] test(recovery): seed interrupted native checkpoints (#3463) Plant the complete interrupted-checkpoint state, including the checkpoint WAL and both lock files, for native source-preservation tests. --- .../fixtures/staged-embedding-recovery/seed.mjs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gitnexus/test/fixtures/staged-embedding-recovery/seed.mjs b/gitnexus/test/fixtures/staged-embedding-recovery/seed.mjs index 37d61ebb6..68401a4b8 100644 --- a/gitnexus/test/fixtures/staged-embedding-recovery/seed.mjs +++ b/gitnexus/test/fixtures/staged-embedding-recovery/seed.mjs @@ -1,4 +1,5 @@ import lbug from '@ladybugdb/core'; +import fs from 'node:fs'; import { createLbugDatabase } from '../../../src/core/lbug/lbug-config.ts'; const [dbPath, mode] = process.argv.slice(2); @@ -19,7 +20,20 @@ await row('complete-0', 'complete', 0); await row('complete-1', 'complete', 1); await row('other', 'other', 0); await query('CHECKPOINT'); -if (mode === 'hard-kill') { +if (mode === 'interrupted-checkpoint') { + await row('checkpoint-only', 'checkpoint-only', 0); + const main = fs.readFileSync(dbPath); + const wal = fs.readFileSync(`${dbPath}.wal`); + await conn.close(); + await db.close(); + // Restore the pre-close bytes: writable close has already checkpointed them. + fs.writeFileSync(dbPath, main); + fs.writeFileSync(`${dbPath}.wal.checkpoint`, wal); + fs.writeFileSync(`${dbPath}.wal`, ''); + fs.writeFileSync(`${dbPath}.shadow`, ''); + fs.writeFileSync(`${dbPath}.checkpoint.intent.lock`, ''); + fs.writeFileSync(`${dbPath}.checkpoint.apply.lock`, ''); +} else if (mode === 'hard-kill') { await row('unsafe', 'unsafe-prefix', 0); process.kill(process.pid, 'SIGKILL'); } else {