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

Function cli_update_activate_binary

src/cli/cli.c:13178–13224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13176} cli_update_activation_t;
13177
13178static int cli_update_activate_binary(void *opaque) {
13179 cli_update_activation_t *activation = opaque;
13180 if (!activation || !activation->bin_dest || !activation->binary_transaction) {
13181 return CLI_TRUE;
13182 }
13183 char previous_managed_binary[CLI_BUF_1K] = {0};
13184 bool previous_managed_binary_exact = cbm_detect_self_path(
13185 previous_managed_binary, sizeof(previous_managed_binary), activation->home);
13186 if (cli_activation_transaction_commit_validated(activation->binary_transaction,
13187 &activation->binary_validator,
13188 CLI_OCTAL_PERM) != CLI_OK) {
13189 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
13190 "update_transaction_publish_recovery");
13191 (void)fprintf(stderr, "error: cannot publish staged update to %s\n", activation->bin_dest);
13192 return CLI_TRUE;
13193 }
13194 /* Agent configs must never observe a replacement binary outside the same
13195 * exact-build activation window. Otherwise another CBM process can start
13196 * after the binary swap but before its MCP/hook entries are refreshed. */
13197 printf("Refreshing agent configurations...\n");
13198 if (cbm_install_agent_configs_with_previous(
13199 activation->home, activation->bin_dest,
13200 previous_managed_binary_exact ? previous_managed_binary : NULL, true,
13201 false) != CLI_OK) {
13202 cli_activation_transaction_finalize_committed_or_fail_stop(
13203 &activation->binary_transaction, "update_transaction_config_failure_finalize");
13204 (void)fprintf(stderr, "error: one or more agent configurations failed; the "
13205 "published update was kept. Review the errors above and "
13206 "rerun update\n");
13207 return CLI_ACTIVATION_PARTIAL;
13208 }
13209 if (activation->delete_indexes) {
13210 int expected = count_db_indexes(activation->home);
13211 int removed = cbm_remove_indexes(activation->home);
13212 printf("Removed %d index(es).\n\n", removed);
13213 if (removed != expected) {
13214 cli_activation_transaction_finalize_committed_or_fail_stop(
13215 &activation->binary_transaction, "update_transaction_index_failure_finalize");
13216 (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", removed,
13217 expected);
13218 return CLI_ACTIVATION_PARTIAL;
13219 }
13220 }
13221 cli_activation_transaction_finalize_committed_or_fail_stop(&activation->binary_transaction,
13222 "update_transaction_finalize");
13223 return CLI_OK;
13224}
13225
13226#ifdef __APPLE__
13227/* The first step of the signed-candidate preparation that failed. One boolean

Callers

nothing calls this directly

Tested by

no test coverage detected