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

Function idxpar_recovery_check

tests/test_mcp.c:10054–10109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10052
10053#ifndef _WIN32
10054static int idxpar_recovery_check(const char *repo_dir) {
10055 cbm_index_supervisor_mark_host();
10056 cbm_unsetenv("CBM_INDEX_SUPERVISOR");
10057 /* Rounds needed: fail+record, fail+quarantine, clean. Generous cap. */
10058 cbm_setenv("CBM_INDEX_MAX_RESTARTS", "5", 1);
10059 cbm_setenv("CBM_INDEX_WORKER_TIMEOUT_S", "30", 1);
10060 cbm_setenv("CBM_TEST_CRASH_ON", "idxpar_crasher", 1);
10061
10062 int st_before = cbm_index_supervisor_spawn_st_count();
10063 char *resp = cbm_mcp_index_run_supervised_path(repo_dir);
10064 int st_after = cbm_index_supervisor_spawn_st_count();
10065 cbm_unsetenv("CBM_TEST_CRASH_ON");
10066
10067 if (st_after != st_before) {
10068 free(resp);
10069 return IDXPAR_ST_SPAWN; /* discriminating assertion: RED on the old loop */
10070 }
10071 if (!resp) {
10072 return IDXPAR_NULL_RESP;
10073 }
10074 bool indexed = response_contains_json_fragment(resp, "\"status\":\"indexed\"");
10075 bool crasher_skipped = strstr(resp, "idxpar_crasher.py") != NULL;
10076 bool innocent_hit =
10077 strstr(resp, "idxpar_good_a.py") != NULL || strstr(resp, "idxpar_good_b.py") != NULL;
10078 free(resp);
10079 if (!indexed) {
10080 return IDXPAR_NOT_INDEXED;
10081 }
10082 if (!crasher_skipped) {
10083 return IDXPAR_NO_QUARANTINE;
10084 }
10085 if (innocent_hit) {
10086 return IDXPAR_INNOCENT_HIT;
10087 }
10088
10089 /* Store proof: an innocent's Function node exists. */
10090 char *project = cbm_project_name_from_path(repo_dir);
10091 cbm_mcp_server_t *srv = cbm_mcp_server_new(NULL);
10092 int code = IDXPAR_OK;
10093 if (srv && project) {
10094 char q[512];
10095 snprintf(q, sizeof(q),
10096 "{\"project\":\"%s\",\"name_pattern\":\"idxpar_good_fn\",\"label\":\"Function\"}",
10097 project);
10098 char *sr = cbm_mcp_handle_tool(srv, "search_graph", q);
10099 if (!sr || !strstr(sr, "idxpar_good_fn")) {
10100 code = IDXPAR_GOOD_MISSING;
10101 }
10102 free(sr);
10103 }
10104 if (srv) {
10105 cbm_mcp_server_free(srv);
10106 }
10107 free(project);
10108 return code;
10109}
10110#endif /* !_WIN32 */
10111

Callers 1

test_mcp.cFile · 0.85

Calls 10

cbm_unsetenvFunction · 0.85
cbm_setenvFunction · 0.85
cbm_mcp_server_newFunction · 0.85
cbm_mcp_handle_toolFunction · 0.85
cbm_mcp_server_freeFunction · 0.85

Tested by

no test coverage detected