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.

fix(pipeline): delete the old generation only when rebuilding it

Martin Vogelbccd22907f31
diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.c
index eabd6ff84..a34b45eb9 100644
--- a/src/pipeline/pass_parallel.c
+++ b/src/pipeline/pass_parallel.c
@@ -2613,7 +2613,13 @@ static void resolve_file_usages(resolve_ctx_t *rc, resolve_worker_state_t *ws,
if (!tgt || src->id == tgt->id) {
continue;
}
- char uprops[CBM_SZ_256];
+ /* 512, matching the sequential twin in pass_usages.c. esc_ref holds up
+ * to 255 bytes and the {"callee":"..."} wrapper adds 13, so a 256-byte
+ * uprops truncates a long callable identifier mid-string -- cutting the
+ * closing quote-brace and persisting MALFORMED JSON. The two paths must
+ * also agree: the same repo indexed in parallel and sequentially has to
+ * produce byte-identical edge properties. */
+ char uprops[CBM_SZ_512];
char esc_ref[CBM_SZ_256]; /* sliced source text: escape quotes/newlines */
cbm_json_escape(esc_ref, sizeof(esc_ref), usage->ref_name);
snprintf(uprops, sizeof(uprops), "{\"callee\":\"%s\"}", esc_ref);
diff --git a/src/pipeline/pipeline.c b/src/pipeline/pipeline.c
index 99ba265a8..30386269e 100644
--- a/src/pipeline/pipeline.c
+++ b/src/pipeline/pipeline.c
@@ -1316,14 +1316,20 @@ static int try_incremental_or_delete_db(cbm_pipeline_t *p, cbm_file_info_t *file
cbm_log_info("pipeline.route", "path", "incremental_manifest");
int rc = cbm_pipeline_run_incremental(p, db_path, files, file_count, baseline_manifest,
baseline_count);
+ /* Delete the existing generation ONLY when we are about to rebuild it.
+ * On main this was guarded by an early `return rc` for the incremental
+ * path; this function has no such early return, so the delete must be
+ * conditional. Unconditionally removing it destroys the database on the
+ * no-op and successful-incremental routes -- the pipeline reports success
+ * while every later reader finds no store. */
if (rc == CBM_PIPELINE_FORCE_FULL_REINDEX) {
int adr_rc = capture_existing_adr(p, db_path);
if (adr_rc != 0) {
rc = adr_rc;
}
+ (void)cbm_unlink(db_path);
+ (void)cbm_remove_db_sidecars(db_path);
}
- (void)cbm_unlink(db_path);
- (void)cbm_remove_db_sidecars(db_path);
free(db_path);
return rc;
}