mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-23 17:56:34 +08:00
Three code paths install a brand-new DB file where a previous generation lived without removing the destination's -wal/-shm: the pipeline page writer (cbm_writer_open), artifact import (which cleaned the TMP file's sidecars but not the destination's), and cbm_store_dump_to_file (whose comment wrongly asserted stale sidecars 'become stale and get recreated'). SQLite validates a WAL against the sidecar's own header/checksums — not the main file — so a crashed session's leftover WAL is replayed ON TOP of the freshly installed file at the next open, splicing old-generation pages into it. New shared helper cbm_remove_db_sidecars (compat_fs, wide-path safe on Windows) called at all three install points. Reproduce-first: dump_install_ignores_stale_wal_sidecar follows the issue's recipe (hot-copy a live WAL, clean close, restore the copy, install generation 2, reopen). RED on the unguarded code — the replay clobbered the fresh generation entirely (fresh row unqueryable); GREEN with the cleanup. Non-vacuous: asserts the hot WAL is non-empty before the copy. Closes #897 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>