Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Merge origin/main into feat/shared-coordination-daemon
Martin Vogeldd8767686529
diff --cc src/store/store.cindex 2595adb25,efd56f531..810a5f41f--- a/src/store/store.c+++ b/src/store/store.c@@@ -1089,99 -1116,25 +1124,118 @@@ int cbm_store_checkpoint(cbm_store_t *sreturn exec_sql(s, "PRAGMA optimize;");}+static int prepare_sqlite_for_publish(sqlite3 *db) {+ if (!db) {+ return CBM_STORE_ERR;+ }+ int log_frames = -1;+ int checkpointed_frames = -1;+ int rc = sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_TRUNCATE, &log_frames,+ &checkpointed_frames);+ if (rc != SQLITE_OK || (log_frames >= 0 && checkpointed_frames != log_frames)) {+ return CBM_STORE_ERR;+ }++ sqlite3_stmt *stmt = NULL;+ rc = sqlite3_prepare_v2(db, "PRAGMA journal_mode=DELETE;", CBM_NOT_FOUND, &stmt, NULL);+ if (rc != SQLITE_OK) {+ return CBM_STORE_ERR;+ }+ bool delete_mode = false;+ if (sqlite3_step(stmt) == SQLITE_ROW) {+ const char *mode = (const char *)sqlite3_column_text(stmt, 0);+ delete_mode = mode && strcmp(mode, "delete") == 0;+ }+ sqlite3_finalize(stmt);+ return delete_mode ? CBM_STORE_OK : CBM_STORE_ERR;+}++int cbm_store_prepare_for_publish(cbm_store_t *s) {+ if (!s || !s->db) {+ return CBM_STORE_ERR;+ }+ return prepare_sqlite_for_publish(s->db);+}++int cbm_store_prepare_path_for_replace(const char *path) {+ if (!path) {+ return CBM_STORE_ERR;+ }+ sqlite3 *db = NULL;+ int rc = sqlite3_open_v2(path, &db, SQLITE_OPEN_READWRITE, NULL);+ if (rc != SQLITE_OK) {+ sqlite3_close(db);+ return CBM_STORE_ERR;+ }+ sqlite3_busy_timeout(db, 10000);+ int result = prepare_sqlite_for_publish(db);+ if (sqlite3_close(db) != SQLITE_OK) {+ result = CBM_STORE_ERR;+ }+ return result;+}++int cbm_store_backup_path(const char *source_path, const char *staging_path) {+ if (!source_path || !staging_path) {+ return CBM_STORE_ERR;+ }+ if (cbm_remove_db_sidecars(staging_path) != 0) {+ return CBM_STORE_ERR;+ }++ sqlite3 *source = NULL;+ sqlite3 *dest = NULL;+ int rc = sqlite3_open_v2(source_path, &source, SQLITE_OPEN_READONLY, NULL);+ if (rc != SQLITE_OK) {+ sqlite3_close(source);+ return CBM_STORE_ERR;+ }+ sqlite3_busy_timeout(source, 10000);+ rc = sqlite3_open_v2(staging_path, &dest, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);+ if (rc != SQLITE_OK) {+ sqlite3_close(dest);+ sqlite3_close(source);+ return CBM_STORE_ERR;+ }+ sqlite3_busy_timeout(dest, 10000);++ sqlite3_backup *backup = sqlite3_backup_init(dest, "main", source, "main");+ int result = CBM_STORE_ERR;+ if (backup) {+ int step_rc = sqlite3_backup_step(backup, CBM_NOT_FOUND);+ int finish_rc = sqlite3_backup_finish(backup);+ if (step_rc == SQLITE_DONE && finish_rc == SQLITE_OK) {+ result = CBM_STORE_OK;+ }+ }+ if (sqlite3_close(dest) != SQLITE_OK) {+ result = CBM_STORE_ERR;+ }+ if (sqlite3_close(source) != SQLITE_OK) {+ result = CBM_STORE_ERR;+ }+ return result;+}++ /* #1083: the WAL size limit configured on this (write) connection, in bytes.+ * -1 means unlimited (SQLite's default — the pre-fix behavior). Per-connection+ * and not persisted, so it can only be read on the connection that set it. */+ int64_t cbm_store_journal_size_limit(cbm_store_t *s) {+ if (!s || !s->db) {+ return -1;+ }+ sqlite3_stmt *stmt = NULL;+ if (sqlite3_prepare_v2(s->db, "PRAGMA journal_size_limit;", -1, &stmt, NULL) != SQLITE_OK) {+ return -1;+ }+ int64_t limit = -1;+ if (sqlite3_step(stmt) == SQLITE_ROW) {+ limit = sqlite3_column_int64(stmt, 0);+ }+ sqlite3_finalize(stmt);+ return limit;+ }+/* ── Dump ───────────────────────────────────────────────────────── *//* Dump entire in-memory database to a file via sqlite3_backup.