Build a minimal {"repo_path": " "} args object (path safely escaped) and * run it through index_run_supervised. Shared by the session auto-index (srv * present → its cached store is invalidated) and the watcher re-index (srv NULL). * Returns the worker's response string (caller frees) or NULL to degrade. */
| 11802 | * present → its cached store is invalidated) and the watcher re-index (srv NULL). |
| 11803 | * Returns the worker's response string (caller frees) or NULL to degrade. */ |
| 11804 | static char *index_run_supervised_path(cbm_mcp_server_t *srv, const char *root_path) { |
| 11805 | if (!root_path || !root_path[0]) { |
| 11806 | return NULL; |
| 11807 | } |
| 11808 | cbm_index_resource_policy_t policy; |
| 11809 | char policy_error[CBM_SZ_256] = {0}; |
| 11810 | if (!load_index_policy(srv, NULL, &policy, policy_error, sizeof(policy_error))) { |
| 11811 | cbm_log_error("index.policy", "error", policy_error); |
| 11812 | return NULL; |
| 11813 | } |
| 11814 | yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL); |
| 11815 | yyjson_mut_val *root = yyjson_mut_obj(doc); |
| 11816 | yyjson_mut_doc_set_root(doc, root); |
| 11817 | /* A doc_candidates setting the user set travels with the request (the |
| 11818 | * worker reads no config); unset, the worker's index mode decides. */ |
| 11819 | if (!yyjson_mut_obj_add_strcpy(doc, root, "repo_path", root_path) || |
| 11820 | !cbm_mcp_index_policy_add_to_args(doc, root, &policy) || |
| 11821 | !cbm_mcp_index_doc_candidates_add_to_args(doc, root, srv ? srv->config : NULL)) { |
| 11822 | yyjson_mut_doc_free(doc); |
| 11823 | return NULL; |
| 11824 | } |
| 11825 | char *args = yy_doc_to_str(doc); |
| 11826 | yyjson_mut_doc_free(doc); |
| 11827 | if (!args) { |
| 11828 | return NULL; |
| 11829 | } |
| 11830 | char *resp = index_run_supervised(srv, args); |
| 11831 | free(args); |
| 11832 | return resp; |
| 11833 | } |
| 11834 | |
| 11835 | /* Public entry (see mcp.h): the watcher re-index in main.c has no MCP server, so |
| 11836 | * it reaches the supervised runner through this srv-less wrapper. */ |
no test coverage detected