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

Function cli_update_activate_binary

src/cli/cli.c:11766–11812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11764} cli_update_activation_t;
11765
11766static int cli_update_activate_binary(void *opaque) {
11767 cli_update_activation_t *activation = opaque;
11768 if (!activation || !activation->bin_dest || !activation->binary_transaction) {
11769 return CLI_TRUE;
11770 }
11771 char previous_managed_binary[CLI_BUF_1K] = {0};
11772 bool previous_managed_binary_exact = cbm_detect_self_path(
11773 previous_managed_binary, sizeof(previous_managed_binary), activation->home);
11774 if (cli_activation_transaction_commit_validated(activation->binary_transaction,
11775 &activation->binary_validator,
11776 CLI_OCTAL_PERM) != CLI_OK) {
11777 cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction,
11778 "update_transaction_publish_recovery");
11779 (void)fprintf(stderr, "error: cannot publish staged update to %s\n", activation->bin_dest);
11780 return CLI_TRUE;
11781 }
11782 /* Agent configs must never observe a replacement binary outside the same
11783 * exact-build activation window. Otherwise another CBM process can start
11784 * after the binary swap but before its MCP/hook entries are refreshed. */
11785 printf("Refreshing agent configurations...\n");
11786 if (cbm_install_agent_configs_with_previous(
11787 activation->home, activation->bin_dest,
11788 previous_managed_binary_exact ? previous_managed_binary : NULL, true,
11789 false) != CLI_OK) {
11790 cli_activation_transaction_finalize_committed_or_fail_stop(
11791 &activation->binary_transaction, "update_transaction_config_failure_finalize");
11792 (void)fprintf(stderr, "error: one or more agent configurations failed; the "
11793 "published update was kept. Review the errors above and "
11794 "rerun update\n");
11795 return CLI_ACTIVATION_PARTIAL;
11796 }
11797 if (activation->delete_indexes) {
11798 int expected = count_db_indexes(activation->home);
11799 int removed = cbm_remove_indexes(activation->home);
11800 printf("Removed %d index(es).\n\n", removed);
11801 if (removed != expected) {
11802 cli_activation_transaction_finalize_committed_or_fail_stop(
11803 &activation->binary_transaction, "update_transaction_index_failure_finalize");
11804 (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", removed,
11805 expected);
11806 return CLI_ACTIVATION_PARTIAL;
11807 }
11808 }
11809 cli_activation_transaction_finalize_committed_or_fail_stop(&activation->binary_transaction,
11810 "update_transaction_finalize");
11811 return CLI_OK;
11812}
11813
11814static int extract_and_install_binary(extract_install_args_t args) {
11815 const char *tmp_archive = args.tmp_archive;

Callers

nothing calls this directly

Tested by

no test coverage detected