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

Function cli_activation_guard_scoped

src/cli/cli.c:915–979  ·  view source on GitHub ↗

quiesce_required: false when the activation publishes no binary and resets * no index (a config-only install) — nothing running is then replaced, and * no session is stopped for it. */

Source from the content-addressed store, hash-verified

913 * no index (a config-only install) — nothing running is then replaced, and
914 * no session is stopped for it. */
915static int cli_activation_guard_scoped(cbm_daemon_runtime_activation_action_t action,
916 const char *target_version, const char *target_build,
917 bool quiesce_required,
918 cbm_cli_activation_mutation_fn mutation,
919 void *mutation_context) {
920 if (g_cli_activation_test_ops_set) {
921 return cbm_cli_activation_guard_with_ops(&g_cli_activation_test_ops, mutation,
922 mutation_context);
923 }
924
925 cli_activation_production_context_t context;
926 if (!cli_activation_production_context_init(&context, action, target_version, target_build,
927 quiesce_required)) {
928 cli_activation_production_context_close(&context);
929 /* #1856: this refusal used to print the generic text BARE. Every other
930 * emitter routes through cli_activation_diagnostic, which appends the
931 * transaction refusal note or cbm_daemon_ipc_validation_detail() and so
932 * names the check that actually refused. Here the reader got "Check the
933 * errors above" with nothing above -- exactly the dead end #1537/#1416
934 * fixed on the other paths and missed on this one. Context init is
935 * where the cache, rendezvous and log directories are validated, so it
936 * is the emitter MOST likely to hold a detail worth showing. */
937 cli_activation_diagnostic(NULL, CLI_ACTIVATION_REFUSED_MESSAGE);
938 return CLI_TRUE;
939 }
940 if (!cli_activation_log_event(&context, "requested", NULL)) {
941 cli_activation_production_context_close(&context);
942 (void)fprintf(stderr, "error: activation request could not be recorded safely; "
943 "no activation was committed.\n");
944 return CLI_TRUE;
945 }
946
947 cbm_cli_activation_ops_t ops = {
948 .context = &context,
949 .reserve_for_mutation = cli_activation_production_reserve,
950 .mutation_lease_release = cli_activation_production_release,
951 .visible_diagnostic = cli_activation_production_diagnostic,
952 };
953 int rc = cbm_cli_activation_guard_with_ops(&ops, mutation, mutation_context);
954 if (rc == CLI_OK) {
955 if (!cli_activation_log_event(&context, "completed",
956 "activation mutation completed; configuration APIs do not "
957 "provide an aggregate rollback status")) {
958 (void)fprintf(stderr, "warning: activation completed, but its final log "
959 "record could not be written.\n");
960 }
961 } else {
962 (void)cli_activation_log_event(
963 &context, "failed",
964 context.mutation_authorized
965 ? (rc == CLI_ACTIVATION_PARTIAL
966 ? "published/current binary retained; agent "
967 "configuration refresh or cleanup incomplete"
968 : "activation mutation failed; filesystem writes may "
969 "have completed")
970 : "cohort drain or coordination failed");
971 }
972 cli_activation_production_context_close(&context);

Callers 2

cli_activation_guardFunction · 0.85
cbm_cmd_installFunction · 0.85

Tested by

no test coverage detected