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

Function main_client_bootstrap_with_upgrade

src/main.c:1490–1518  ·  view source on GitHub ↗

Client bootstrap with the upgrade policy: a CONFLICT against a PERMANENT * daemon of a strictly OLDER release is resolved by draining that daemon * (the same authenticated path install/update use) and retrying once. A * manual binary swap therefore self-heals exactly like the ephemeral * lifecycle used to, instead of deadlocking behind the pinned daemon. Same- * or newer-build daemons and dev

Source from the content-addressed store, hash-verified

1488 * lifecycle used to, instead of deadlocking behind the pinned daemon. Same-
1489 * or newer-build daemons and dev builds are never auto-drained. */
1490static cbm_daemon_bootstrap_status_t main_client_bootstrap_with_upgrade(
1491 const cbm_daemon_bootstrap_config_t *config, cbm_daemon_bootstrap_result_t *result) {
1492 cbm_daemon_bootstrap_status_t status = cbm_daemon_bootstrap_execute(config, result);
1493 if (status != CBM_DAEMON_BOOTSTRAP_CONFLICT) {
1494 return status;
1495 }
1496 cbm_daemon_runtime_status_t active;
1497 if (!cbm_daemon_runtime_request_status(config->endpoint, config->identity,
1498 MAIN_CONNECT_TIMEOUT_MS, &active) ||
1499 !active.permanent ||
1500 !main_semver_newer(config->identity->semantic_version, active.semantic_version)) {
1501 return status;
1502 }
1503 (void)fprintf(stderr,
1504 "codebase-memory-mcp: retiring the active permanent daemon (%s, pid %lu) for "
1505 "this newer build (%s)\n",
1506 active.semantic_version, (unsigned long)active.daemon_pid,
1507 config->identity->semantic_version);
1508 cbm_daemon_runtime_activation_result_t drain;
1509 if (!cbm_daemon_runtime_request_activation_shutdown(config->endpoint, config->identity,
1510 CBM_DAEMON_RUNTIME_ACTIVATION_UPDATE,
1511 MAIN_MCP_STARTUP_TIMEOUT_MS, &drain) ||
1512 !drain.accepted) {
1513 (void)fprintf(stderr, "codebase-memory-mcp: the active daemon did not accept the "
1514 "upgrade drain; run `codebase-memory-mcp daemon stop`\n");
1515 return status;
1516 }
1517 return cbm_daemon_bootstrap_execute(config, result);
1518}
1519
1520/* One-shot CLI commands execute through the shared daemon, exactly like MCP
1521 * sessions and hooks: an active daemon (any starter) is recycled, an absent

Callers 3

main_run_daemon_ctlFunction · 0.85
mainFunction · 0.85

Tested by

no test coverage detected