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

Function rh_open_indexed

tests/repro/repro_harness.h:54–91  ·  view source on GitHub ↗

Index lp->tmpdir (already populated) via the production index_repository flow * and open the resulting graph DB (NULL on failure). */

Source from the content-addressed store, hash-verified

52/* Index lp->tmpdir (already populated) via the production index_repository flow
53 * and open the resulting graph DB (NULL on failure). */
54static inline cbm_store_t *rh_open_indexed(RProj *lp) {
55 lp->project = cbm_project_name_from_path(lp->tmpdir);
56 if (!lp->project)
57 return NULL;
58 if (!lp->cachedir[0]) {
59 snprintf(lp->cachedir, sizeof(lp->cachedir), "/tmp/cbm_repro_cache_XXXXXX");
60 if (!cbm_mkdtemp(lp->cachedir))
61 return NULL;
62 rh_to_fwd_slashes(lp->cachedir);
63 }
64 snprintf(lp->dbpath, sizeof(lp->dbpath), "%s/%s.db", lp->cachedir, lp->project);
65 unlink(lp->dbpath);
66
67 const char *prior_cache_dir = getenv("CBM_CACHE_DIR");
68 char *saved_cache_dir = prior_cache_dir ? cbm_strdup(prior_cache_dir) : NULL;
69 cbm_setenv("CBM_CACHE_DIR", lp->cachedir, 1);
70
71 cbm_store_t *store = NULL;
72 lp->srv = cbm_mcp_server_new(NULL);
73 if (lp->srv) {
74 char args[700];
75 snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", lp->tmpdir);
76 char *resp = cbm_mcp_handle_tool(lp->srv, "index_repository", args);
77 if (resp)
78 free(resp);
79 /* Repro consumers only inspect the graph. Keep this connection query-only
80 * so the harness does not mutate the publisher's sealed journal mode. */
81 store = cbm_store_open_path_query(lp->dbpath);
82 }
83
84 if (saved_cache_dir) {
85 cbm_setenv("CBM_CACHE_DIR", saved_cache_dir, 1);
86 free(saved_cache_dir);
87 } else {
88 cbm_unsetenv("CBM_CACHE_DIR");
89 }
90 return store;
91}
92
93static inline void rh_cleanup(RProj *lp, cbm_store_t *store);
94

Callers 1

rh_index_filesFunction · 0.85

Calls 8

cbm_mkdtempFunction · 0.85
rh_to_fwd_slashesFunction · 0.85
cbm_setenvFunction · 0.85
cbm_mcp_server_newFunction · 0.85
cbm_mcp_handle_toolFunction · 0.85
cbm_unsetenvFunction · 0.85

Tested by

no test coverage detected