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.

test(daemon): skip the build-fingerprint hash in tests (root-cause fix)

Martin Vogel3325b31b3723
diff --git a/src/mcp/index_supervisor.c b/src/mcp/index_supervisor.c
index e5dd53d34..f3ca4dffe 100644
--- a/src/mcp/index_supervisor.c
+++ b/src/mcp/index_supervisor.c
@@ -84,11 +84,30 @@ size_t cbm_index_worker_memory_budget_bytes(void) {
return g_worker_memory_budget_bytes;
}
+static bool worker_fingerprint_valid(const char *fingerprint);
+
bool cbm_index_supervisor_capture_build_fingerprint(void) {
if (g_build_fingerprint_capture_attempted) {
return g_build_fingerprint[0] != '\0';
}
g_build_fingerprint_capture_attempted = true;
+#if defined(CBM_CLI_ENABLE_TEST_API)
+ /* Test-only seam: computing the real fingerprint hashes the ENTIRE
+ * executable image, which for the ASan test-runner (hundreds of MB) takes
+ * tens of seconds per spawned worker/daemon on constrained CI runners and
+ * is the sole cause of the daemon-family readiness-timeout flakes. When a
+ * valid stub is provided the hash is skipped; every process in the test
+ * (parent, forked children, re-exec'd workers) inherits the same stub via
+ * the environment, so exact-build match/mismatch behaviour is preserved
+ * while startup becomes instant. Never compiled into production. */
+ char test_fingerprint[CBM_INDEX_WORKER_BUILD_FINGERPRINT_SIZE];
+ const char *test_value = cbm_safe_getenv("CBM_TEST_BUILD_FINGERPRINT", test_fingerprint,
+ sizeof(test_fingerprint), NULL);
+ if (test_value && worker_fingerprint_valid(test_value)) {
+ (void)snprintf(g_build_fingerprint, sizeof(g_build_fingerprint), "%s", test_value);
+ return true;
+ }
+#endif
char captured[CBM_INDEX_WORKER_BUILD_FINGERPRINT_SIZE] = {0};
if (!cbm_daemon_runtime_process_build_fingerprint((uint64_t)worker_getpid(), captured)) {
return false;
diff --git a/tests/test_daemon_frontend.c b/tests/test_daemon_frontend.c
index 7fe74774b..8e14cb8d2 100644
--- a/tests/test_daemon_frontend.c
+++ b/tests/test_daemon_frontend.c
@@ -69,10 +69,10 @@ enum {
* seconds for frontend/daemon startup paths that finish instantly on a
* dev machine (see the index-supervisor calibration). */
FRONTEND_EOF_TEST_REQUEST_TIMEOUT_MS = 30000,
- FRONTEND_EOF_TEST_CATASTROPHIC_TIMEOUT_S = 30,
+ FRONTEND_EOF_TEST_CATASTROPHIC_TIMEOUT_S = 90,
FRONTEND_BACKPRESSURE_MESSAGE_BYTES = 2 * 1024 * 1024,
- FRONTEND_BACKPRESSURE_FRONTEND_TIMEOUT_S = 12,
- FRONTEND_BACKPRESSURE_DAEMON_TIMEOUT_S = 20,
+ FRONTEND_BACKPRESSURE_FRONTEND_TIMEOUT_S = 90,
+ FRONTEND_BACKPRESSURE_DAEMON_TIMEOUT_S = 90,
FRONTEND_BACKPRESSURE_RUNTIME_TIMEOUT_MS = 90000,
FRONTEND_BACKPRESSURE_CLEANUP_TIMEOUT_MS = 30000,
/* The production queue is deliberately bounded below this count. Keep the
diff --git a/tests/test_main.c b/tests/test_main.c
index 871ce4abd..c5f2cbd3e 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -648,6 +648,17 @@ extern void suite_dump_verify_io(void);
extern void cbm_kind_in_set_free_cache(void);
int main(int argc, char **argv) {
+ /* Skip the multi-hundred-MB executable-image hash that computes the exact
+ * build fingerprint: it is tens of seconds per spawned worker/daemon under
+ * ASan on constrained CI runners and the sole cause of the daemon-family
+ * readiness-timeout flakes. Set once here; every forked child and re-exec'd
+ * worker inherits it, so exact-build match/mismatch still works (a
+ * mismatch test still passes a DIFFERENT fingerprint via argv). Honoured
+ * only under CBM_CLI_ENABLE_TEST_API — never in a production binary. */
+ if (!getenv("CBM_TEST_BUILD_FINGERPRINT")) {
+ (void)cbm_setenv("CBM_TEST_BUILD_FINGERPRINT",
+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1);
+ }
int blocking_git_rc = tf_maybe_run_blocking_git_probe(argc, argv);
if (blocking_git_rc >= 0) {
return blocking_git_rc;