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

Function handle_atlas_trace

src/ui/http_server.c:2577–2604  ·  view source on GitHub ↗

GET /api/trace?project=X&from=QN|#id&to=QN|#id&mode=calls|data — A→B. */

Source from the content-addressed store, hash-verified

2575
2576/* GET /api/trace?project=X&from=QN|#id&to=QN|#id&mode=calls|data — A→B. */
2577static void handle_atlas_trace(cbm_http_conn_t *c, const cbm_http_req_t *req) {
2578 char project[256] = {0};
2579 cbm_store_t *store = atlas_open_project(c, req, project, sizeof(project));
2580 if (!store)
2581 return;
2582 char from_str[1024] = {0};
2583 char to_str[1024] = {0};
2584 char mode[16] = {0};
2585 cbm_http_query_param(req->query, "from", from_str, (int)sizeof(from_str));
2586 cbm_http_query_param(req->query, "to", to_str, (int)sizeof(to_str));
2587 cbm_http_query_param(req->query, "mode", mode, (int)sizeof(mode));
2588 if (!from_str[0] || !to_str[0]) {
2589 cbm_store_close(store);
2590 cbm_http_replyf(c, 400, g_cors_json, "{\"error\":\"missing from/to parameter\"}");
2591 return;
2592 }
2593 int64_t from_id = from_str[0] == '#' ? strtoll(from_str + 1, NULL, 10) : -1;
2594 int64_t to_id = to_str[0] == '#' ? strtoll(to_str + 1, NULL, 10) : -1;
2595 char *json = cbm_atlas_trace_json(store, project, from_id, from_id < 0 ? from_str : NULL, to_id,
2596 to_id < 0 ? to_str : NULL, mode[0] ? mode : "calls");
2597 char wantg[8] = {0};
2598 cbm_http_query_param(req->query, "guards", wantg, (int)sizeof(wantg));
2599 if (json && wantg[0] == '1')
2600 json = atlas_trace_attach_guards(store, project, json);
2601 json = cbm_atlas_attach_observed(store, project, json);
2602 cbm_store_close(store);
2603 atlas_reply_json(c, json, 500, "{\"error\":\"trace failed\"}");
2604}
2605
2606/* Attach runtime observation to a trace ("path") or flow-detail ("steps")
2607 * JSON: every hop whose (caller, callee) pair appears in observed_calls

Callers 1

dispatch_requestFunction · 0.85

Calls 8

atlas_open_projectFunction · 0.85
cbm_http_query_paramFunction · 0.85
cbm_store_closeFunction · 0.85
cbm_http_replyfFunction · 0.85
cbm_atlas_trace_jsonFunction · 0.85
atlas_reply_jsonFunction · 0.85

Tested by

no test coverage detected