| 106 | } |
| 107 | |
| 108 | static char *index_repo(void) { |
| 109 | char args[512]; |
| 110 | snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", g_repodir); |
| 111 | char *resp = cbm_mcp_handle_tool(g_srv, "index_repository", args); |
| 112 | /* Fail-closed at the source: every caller asserts resp != NULL, but an |
| 113 | * error response (e.g. a transient pre-publication abort that preserves |
| 114 | * the previous index) used to slip through and cascade into dozens of |
| 115 | * mysterious count/query failures downstream — a 99-test pile-up on the |
| 116 | * Windows leg traced back to exactly this. Surface the real cause once, |
| 117 | * here, and let the existing non-NULL asserts fail loudly. */ |
| 118 | if (resp && strstr(resp, "\"isError\":true")) { |
| 119 | fprintf(stderr, " index_repo: index_repository returned an error response:\n %.400s\n", |
| 120 | resp); |
| 121 | free(resp); |
| 122 | return NULL; |
| 123 | } |
| 124 | return resp; |
| 125 | } |
| 126 | |
| 127 | /* Timed index: returns response, sets *elapsed_ms and *peak_rss_mb */ |
| 128 | static char *index_repo_timed(double *elapsed_ms, size_t *peak_rss_mb) { |
no test coverage detected