MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / host_state_prepare

Function host_state_prepare

src/daemon/host.c:568–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566}
567
568static bool host_state_prepare(host_state_t *host, const cbm_daemon_ipc_endpoint_t *endpoint) {
569 host->http_ops = &g_host_http_default_ops;
570 host->http_assets_available = CBM_EMBEDDED_FILE_COUNT > 0;
571 if (!cbm_secure_random(host->ui_readiness_secret, sizeof(host->ui_readiness_secret))) {
572 cbm_log_error("daemon.readiness_secret_failed", "reason", "system_rng_unavailable");
573 return false;
574 }
575 size_t aggregate_memory_budget_bytes = cbm_mem_budget();
576 const char *cache = cbm_resolve_cache_dir();
577 if (!cache || !cache[0]) {
578 cbm_log_error("daemon.runtime_config_open_failed", "reason", "cache_dir_unavailable");
579 return false;
580 }
581 host->runtime_config = cbm_config_open(cache);
582 if (!host->runtime_config) {
583 cbm_log_error("daemon.runtime_config_open_failed", "reason", "config_db_unavailable");
584 return false;
585 }
586 host->watch_store = cbm_store_open_memory();
587 host->project_locks = cbm_project_lock_manager_new(endpoint);
588 host->watcher = cbm_watcher_new(host->watch_store, host_watcher_index, host);
589 cbm_daemon_application_config_t application_config = {
590 .watcher = host->watcher,
591 .config = host->runtime_config,
592 .aggregate_memory_budget_bytes = aggregate_memory_budget_bytes,
593 .project_locks = host->project_locks,
594 .ui_readiness_secret = host->ui_readiness_secret,
595 .ui_readiness_secret_length = sizeof(host->ui_readiness_secret),
596 };
597 host->application = cbm_daemon_application_new(&application_config);
598 if (host->application && host->permanent) {
599 cbm_daemon_application_set_permanent(host->application, true);
600 }
601 if (!host->watch_store || !host->watcher || !host->project_locks || !host->application) {
602 return false;
603 }
604 return true;
605}
606
607bool cbm_daemon_host_state_prepare_for_test(const cbm_daemon_ipc_endpoint_t *endpoint) {
608 if (!endpoint) {

Callers 2

cbm_daemon_host_runFunction · 0.85

Calls 9

cbm_secure_randomFunction · 0.85
cbm_mem_budgetFunction · 0.85
cbm_resolve_cache_dirFunction · 0.85
cbm_config_openFunction · 0.85
cbm_store_open_memoryFunction · 0.85
cbm_watcher_newFunction · 0.85

Tested by

no test coverage detected