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/index-resource-worker
Martin Vogel140e2998a1dd
diff --cc src/daemon/application.cindex 207735e04,a5216846b..5266a03b5--- a/src/daemon/application.c+++ b/src/daemon/application.c@@@ -159,11 -174,7 +174,12 @@@ struct cbm_daemon_application_job* job outlives the request and session that started it. */bool async_owned;bool worker_started;+ application_index_watch_owner_t *watch_owners;+ uint64_t request_started_ms;+ /* What a worker resource failure of this job is reported against; set+ * before the first attempt, folded over every attempt (mcp_internal.h). */+ bool request_facts_begun;+ cbm_mcp_index_request_facts_t request_facts;cbm_daemon_application_job_t *next;};diff --cc src/mcp/mcp.cindex 3dc5e72ee,29685e4c8..ddaba7e9d--- a/src/mcp/mcp.c+++ b/src/mcp/mcp.c@@@ -12537,13 -13185,12 +13300,17 @@@ static char *handle_index_repository(cbreturn cbm_mcp_text_result("invalid project name", true);}free(name_override);+ /* Headroom follows the final project name, decided before artifact+ * bootstrap can create the first local copy of this index. */+ cbm_pipeline_set_background(p, background &&+ project_has_committed_index(cbm_pipeline_project_name(p)));cbm_pipeline_set_persistence(p, persistence);cbm_pipeline_set_resource_policy(p, &resource_policy);+ if (cbm_index_worker_publish_fence()) {+ /* Supervised worker with a worker limit: claim publication from the+ * supervisor before the serving database is replaced. */+ cbm_pipeline_set_publish_gate(p, index_worker_publish_gate, NULL);+ }index_doc_candidates_apply(p, doc_candidates);char *project_name = heap_strdup(cbm_pipeline_project_name(p));diff --cc tests/test_daemon_application.cindex 5641ecbac,ad8d98441..efbaee590--- a/tests/test_daemon_application.c+++ b/tests/test_daemon_application.c@@@ -2912,86 -3056,37 +3083,118 @@@ TEST(daemon_application_programmatic_inPASS();}+TEST(daemon_application_worker_resource_failure_is_structured_and_not_retried) {+ char *cache = th_mktempdir("cbm_app_worker_resource_cache");+ cbm_config_t *stored_config = cache ? cbm_config_open(cache) : NULL;+ app_fake_worker_context_t fake;+ app_fake_worker_context_init(&fake);+ atomic_store(&fake.scripted, true);+ fake.outcomes[0] = CBM_PROC_KILLED;+ fake.resource_violations[0] = (cbm_index_resource_violation_t){+ .resource = CBM_INDEX_RESOURCE_DURATION_MS, .observed = 7001, .limit = 7000};+ cbm_daemon_application_worker_ops_t worker_ops = {+ .context = &fake,+ .start = app_fake_worker_start,+ .poll = app_fake_worker_poll,+ .cancel = app_fake_worker_cancel,+ .log_path = app_fake_worker_log_path,+ .destroy = app_fake_worker_destroy,+ };+ cbm_daemon_application_config_t config = {+ .config = stored_config,+ .worker_ops = &worker_ops,+ };+ cbm_daemon_application_t *application =+ stored_config ? cbm_daemon_application_new(&config) : NULL;+ cbm_daemon_runtime_application_callbacks_t callbacks =+ cbm_daemon_application_runtime_callbacks(application);+ cbm_daemon_runtime_application_session_t *session = app_test_open(&callbacks, 4188);+ char *root = th_mktempdir("cbm_app_worker_resource");+ uint8_t *context = NULL;+ uint32_t context_length = 0;+ uint8_t *tool = NULL;+ uint32_t tool_length = 0;+ char args[APP_TEST_PATH_CAP + 96];+ (void)snprintf(args, sizeof(args),+ "{\"repo_path\":\"%s\",\"name\":\"DaemonWorkerResourceFixture\"}",+ root ? root : "");+ bool setup = cache && stored_config && application && session && root &&+ app_test_context_request(root, root, &context, &context_length) &&+ app_test_tool_request("index_repository", args, &tool, &tool_length);+ uint8_t *response = NULL;+ uint32_t response_length = 0;+ if (setup) {+ uint8_t *context_response = NULL;+ uint32_t context_response_length = 0;+ setup = app_test_request(&callbacks, session, context, context_length, &context_response,+ &context_response_length) == CBM_DAEMON_RUNTIME_APPLICATION_OK;+ free(context_response);+ }+ cbm_daemon_runtime_application_status_t status =+ setup+ ? app_test_request(&callbacks, session, tool, tool_length, &response, &response_length)+ : CBM_DAEMON_RUNTIME_APPLICATION_TRANSPORT_ERROR;+ bool structured = response && strstr((char *)response, "resource_limit_exceeded") &&+ strstr((char *)response, "\\\"stage\\\":\\\"worker\\\"") &&+ strstr((char *)response, "\\\"resource\\\":\\\"duration_ms\\\"") &&+ strstr((char *)response, "\\\"observed\\\":7001") &&+ strstr((char *)response, "\\\"limit\\\":7000") &&+ strstr((char *)response, "\\\"unit\\\":\\\"milliseconds\\\"");+ if (session) {+ callbacks.session_close(callbacks.context, session);+ }+ bool stopped = application && cbm_daemon_application_shutdown(application, APP_TEST_TIMEOUT_MS);+ int starts = atomic_load(&fake.starts);+ int destroys = atomic_load(&fake.destroys);+ cbm_daemon_application_free(application);+ cbm_config_close(stored_config);+ free(response);+ free(context);+ free(tool);+ th_cleanup(root);+ th_cleanup(cache);++ ASSERT_TRUE(setup);+ ASSERT_EQ(status, CBM_DAEMON_RUNTIME_APPLICATION_OK);+ ASSERT_TRUE(structured);+ ASSERT_EQ(starts, 1);+ ASSERT_EQ(destroys, 1);+ ASSERT_TRUE(stopped);+ PASS();+}++++ /* #1818: the daemon.autoindex.skipped warning must name the effective limit,+ * like the MCP autoindex.skip event does (#1466). The warning is emitted on the+ * background-initialize thread, before the release increment of the+ * background-initialize counter that the test waits for, so the captured line+ * is complete once that wait returns. */+ static char app_autoindex_skipped_line[1024];+ static atomic_bool app_autoindex_skipped_seen = ATOMIC_VAR_INIT(false);++ static void app_autoindex_skipped_sink(const char *line) {+ if (!line || !strstr(line, "msg=daemon.autoindex.skipped") ||+ atomic_load_explicit(&app_autoindex_skipped_seen, memory_order_acquire)) {+ return;+ }+ (void)snprintf(app_autoindex_skipped_line, sizeof(app_autoindex_skipped_line), "%s", line);+ atomic_store_explicit(&app_autoindex_skipped_seen, true, memory_order_release);+ }++ /* True when `line` carries the whole key=value field `field` (not a prefix of+ * a longer value such as limit=00). */+ static bool app_log_line_has_field(const char *line, const char *field) {+ size_t length = strlen(field);+ for (const char *at = strstr(line, field); at; at = strstr(at + 1, field)) {+ bool starts = at == line || at[-1] == ' ';+ char next = at[length];+ if (starts && (next == '\0' || next == ' ' || next == '\n' || next == '\r')) {+ return true;+ }+ }+ return false;+ }+TEST(daemon_application_auto_index_honors_tracked_file_limit) {app_env_backup_t cache_environment;bool cache_saved = app_env_backup_capture(&cache_environment, "CBM_CACHE_DIR");