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

Function build_worker_failure_response

src/mcp/mcp.c:7417–7451  ·  view source on GitHub ↗

Build the response for a worker that crashed/hung/failed without producing a * result. The crash is already contained (this process survived); we report it * rather than dying. Precise skip-and-continue (quarantine the culprit, index the * rest) is layered on in the probe stage. */

Source from the content-addressed store, hash-verified

7415 * rather than dying. Precise skip-and-continue (quarantine the culprit, index the
7416 * rest) is layered on in the probe stage. */
7417static char *build_worker_failure_response(const char *args, cbm_proc_outcome_t outcome) {
7418 char *repo_path = cbm_mcp_get_string_arg(args, "repo_path");
7419 yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL);
7420 yyjson_mut_val *root = yyjson_mut_obj(doc);
7421 yyjson_mut_doc_set_root(doc, root);
7422 yyjson_mut_obj_add_str(doc, root, "status", "error");
7423 yyjson_mut_obj_add_str(doc, root, "outcome", cbm_proc_outcome_str(outcome));
7424 const char *hint = NULL;
7425 if (outcome == CBM_PROC_SPAWN_FAILED) {
7426 hint = "Indexing worker could not be started. Supervision is mandatory in a CBM "
7427 "host, so no in-process fallback was attempted.";
7428 } else if (outcome == CBM_PROC_HANG) {
7429 hint = "Indexing worker timed out (a file made no progress). The worker was "
7430 "terminated and the server survived. Re-run to retry.";
7431 } else if (outcome == CBM_PROC_CRASH) {
7432 hint = "Indexing worker crashed on a file. The crash was contained (the server "
7433 "survived). Re-run to retry; a future release isolates the culprit file.";
7434 } else if (outcome == CBM_PROC_CLEAN) {
7435 hint = "Indexing worker exited without a valid response. No in-process fallback "
7436 "was attempted.";
7437 } else {
7438 hint = "Indexing worker did not complete successfully. The failure was contained "
7439 "and no in-process fallback was attempted.";
7440 }
7441 yyjson_mut_obj_add_str(doc, root, "hint", hint);
7442 if (repo_path) {
7443 yyjson_mut_obj_add_strcpy(doc, root, "repo_path", repo_path);
7444 }
7445 char *json = yy_doc_to_str(doc);
7446 yyjson_mut_doc_free(doc);
7447 free(repo_path);
7448 char *result = cbm_mcp_text_result(json, true);
7449 free(json);
7450 return result;
7451}
7452
7453static char *build_worker_unsafe_terminal_response(const char *args, cbm_proc_outcome_t outcome,
7454 bool cancellation_requested) {

Callers 1

index_run_supervisedFunction · 0.85

Calls 4

cbm_mcp_get_string_argFunction · 0.85
cbm_proc_outcome_strFunction · 0.85
yy_doc_to_strFunction · 0.85
cbm_mcp_text_resultFunction · 0.85

Tested by

no test coverage detected