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. */
| 7548 | * rather than dying. Precise skip-and-continue (quarantine the culprit, index the |
| 7549 | * rest) is layered on in the probe stage. */ |
| 7550 | static char *build_worker_failure_response(const char *args, cbm_proc_outcome_t outcome) { |
| 7551 | char *repo_path = cbm_mcp_get_string_arg(args, "repo_path"); |
| 7552 | yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL); |
| 7553 | yyjson_mut_val *root = yyjson_mut_obj(doc); |
| 7554 | yyjson_mut_doc_set_root(doc, root); |
| 7555 | yyjson_mut_obj_add_str(doc, root, "status", "error"); |
| 7556 | yyjson_mut_obj_add_str(doc, root, "outcome", cbm_proc_outcome_str(outcome)); |
| 7557 | const char *hint = NULL; |
| 7558 | if (outcome == CBM_PROC_SPAWN_FAILED) { |
| 7559 | hint = "Indexing worker could not be started. Supervision is mandatory in a CBM " |
| 7560 | "host, so no in-process fallback was attempted."; |
| 7561 | } else if (outcome == CBM_PROC_HANG) { |
| 7562 | hint = "Indexing worker timed out (a file made no progress). The worker was " |
| 7563 | "terminated and the server survived. Re-run to retry."; |
| 7564 | } else if (outcome == CBM_PROC_CRASH) { |
| 7565 | hint = "Indexing worker crashed on a file. The crash was contained (the server " |
| 7566 | "survived). Re-run to retry; a future release isolates the culprit file."; |
| 7567 | } else if (outcome == CBM_PROC_CLEAN) { |
| 7568 | hint = "Indexing worker exited without a valid response. No in-process fallback " |
| 7569 | "was attempted."; |
| 7570 | } else { |
| 7571 | hint = "Indexing worker did not complete successfully. The failure was contained " |
| 7572 | "and no in-process fallback was attempted."; |
| 7573 | } |
| 7574 | yyjson_mut_obj_add_str(doc, root, "hint", hint); |
| 7575 | if (repo_path) { |
| 7576 | yyjson_mut_obj_add_strcpy(doc, root, "repo_path", repo_path); |
| 7577 | } |
| 7578 | char *json = yy_doc_to_str(doc); |
| 7579 | yyjson_mut_doc_free(doc); |
| 7580 | free(repo_path); |
| 7581 | char *result = cbm_mcp_text_result(json, true); |
| 7582 | free(json); |
| 7583 | return result; |
| 7584 | } |
| 7585 | |
| 7586 | static char *build_worker_unsafe_terminal_response(const char *args, cbm_proc_outcome_t outcome, |
| 7587 | bool cancellation_requested) { |
no test coverage detected