Skip to content

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.

Detect fast→full mode change + auto-enable UI for ui-variant binary

Martin Vogel87ccb82b8d34
diff --git a/src/pipeline/pipeline.c b/src/pipeline/pipeline.c
index 16ada455a..66f47eacd 100644
--- a/src/pipeline/pipeline.c
+++ b/src/pipeline/pipeline.c
@@ -382,12 +382,23 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {
cbm_store_close(check_store);
if (hash_count > 0) {
- cbm_log_info("pipeline.route", "path", "incremental", "stored_hashes",
- itoa_buf(hash_count));
- rc = cbm_pipeline_run_incremental(p, db_path, files, file_count);
- cbm_discover_free(files, file_count);
- free(db_path);
- return rc;
+ /* Detect mode change (e.g. fast→full): if discovered files
+ * outnumber stored hashes by >50%, the DB was built with a
+ * narrower file set. Delete and reindex fresh instead of
+ * single-threading ~thousands of "new" files incrementally. */
+ if (file_count > hash_count + (hash_count / 2)) {
+ cbm_log_info("pipeline.route", "path", "mode_change_reindex",
+ "stored_hashes", itoa_buf(hash_count), "discovered",
+ itoa_buf(file_count));
+ /* Falls through to delete-and-reindex below */
+ } else {
+ cbm_log_info("pipeline.route", "path", "incremental", "stored_hashes",
+ itoa_buf(hash_count));
+ rc = cbm_pipeline_run_incremental(p, db_path, files, file_count);
+ cbm_discover_free(files, file_count);
+ free(db_path);
+ return rc;
+ }
}
} else if (check_store) {
cbm_store_close(check_store);
diff --git a/src/ui/config.c b/src/ui/config.c
index 7ac5b41c0..7bd95871c 100644
--- a/src/ui/config.c
+++ b/src/ui/config.c
@@ -5,6 +5,7 @@
* Format: {"ui_enabled": false, "ui_port": 9749}
*/
#include "ui/config.h"
+#include "ui/embedded_assets.h"
#include "foundation/log.h"
#include "foundation/platform.h"
#include "foundation/compat_fs.h"
@@ -37,7 +38,11 @@ void cbm_ui_config_load(cbm_ui_config_t *cfg) {
FILE *f = fopen(path, "rb");
if (!f) {
- return; /* no config file → defaults */
+ /* No config file — auto-enable UI if binary has embedded assets */
+ if (CBM_EMBEDDED_FILE_COUNT > 0) {
+ cfg->ui_enabled = true;
+ }
+ return;
}
fseek(f, 0, SEEK_END);