Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(ui): cap graph rendering and index spawn

Martin Vogeld9d70656b4c2
diff --git a/graph-ui/src/components/GraphScene.test.ts b/graph-ui/src/components/GraphScene.test.ts
new file mode 100644
index 000000000..75fcb2154
--- /dev/null
+++ b/graph-ui/src/components/GraphScene.test.ts
@@ -0,0 +1,9 @@
+import { describe, expect, it } from "vitest";
+import { GRAPH_CANVAS_DPR } from "./GraphScene";
+
+describe("GraphScene render limits", () => {
+ it("caps the high-DPI WebGL backing store below the MSAA failure range", () => {
+ expect(GRAPH_CANVAS_DPR[0]).toBe(1);
+ expect(GRAPH_CANVAS_DPR[1]).toBeLessThanOrEqual(1.5);
+ });
+});
diff --git a/graph-ui/src/components/GraphScene.tsx b/graph-ui/src/components/GraphScene.tsx
index fa150be36..6aeceb6b2 100644
--- a/graph-ui/src/components/GraphScene.tsx
+++ b/graph-ui/src/components/GraphScene.tsx
@@ -45,6 +45,8 @@ function CameraAnimator({ target }: { target: CameraTarget | null }) {
/* ── Idle auto-rotation ──────────────────────────────────── */
const IDLE_TIMEOUT_MS = 60_000;
+export const GRAPH_CANVAS_DPR: [number, number] = [1, 1.5];
+export const GRAPH_COMPOSER_MULTISAMPLING = 0;
function IdleAutoRotate({
controlsRef,
@@ -108,8 +110,12 @@ export function GraphScene({
<Canvas
camera={{ position: [0, 0, 800], fov: 50, near: 0.1, far: 100000 }}
style={{ background: "#06090f" }}
- dpr={[1, 2]}
- gl={{ antialias: true, alpha: false }}
+ dpr={GRAPH_CANVAS_DPR}
+ gl={{
+ antialias: false,
+ alpha: false,
+ powerPreference: "high-performance",
+ }}
>
<color attach="background" args={["#06090f"]} />
<ambientLight intensity={0.5} />
@@ -176,7 +182,7 @@ export function GraphScene({
<CameraAnimator target={cameraTarget} />
<IdleAutoRotate controlsRef={controlsRef} />
- <EffectComposer>
+ <EffectComposer multisampling={GRAPH_COMPOSER_MULTISAMPLING}>
<Bloom
luminanceThreshold={0.3}
luminanceSmoothing={0.7}
diff --git a/graph-ui/src/components/GraphTab.test.ts b/graph-ui/src/components/GraphTab.test.ts
new file mode 100644
index 000000000..6056eeef0
--- /dev/null
+++ b/graph-ui/src/components/GraphTab.test.ts
@@ -0,0 +1,36 @@
+import { describe, expect, it } from "vitest";
+import { formatGraphLimitNotice } from "./GraphTab";
+import type { GraphData } from "../lib/types";
+
+describe("formatGraphLimitNotice", () => {
+ it("reports when the graph response is truncated for render safety", () => {
+ const data = {
+ nodes: Array.from({ length: 2000 }, (_, id) => ({
+ id,
+ x: 0,
+ y: 0,
+ z: 0,
+ label: "Function",
+ name: `fn${id}`,
+ size: 1,
+ color: "#ffffff",
+ })),
+ edges: [],
+ total_nodes: 43729,
+ } satisfies GraphData;
+
+ expect(formatGraphLimitNotice(data)).toBe(
+ "Showing 2,000 of 43,729 nodes. Use filters to narrow.",
+ );
+ });
+
+ it("stays quiet when the full graph is rendered", () => {
+ const data = {
+ nodes: [],
+ edges: [],
+ total_nodes: 0,
+ } satisfies GraphData;
+
+ expect(formatGraphLimitNotice(data)).toBeNull();
+ });
+});
diff --git a/graph-ui/src/components/GraphTab.tsx b/graph-ui/src/components/GraphTab.tsx
index ea9b7bb5b..0e6c8fb08 100644
--- a/graph-ui/src/components/GraphTab.tsx
+++ b/graph-ui/src/components/GraphTab.tsx
@@ -29,6 +29,11 @@ interface GraphTabProps {
project: string | null;
}
+export function formatGraphLimitNotice(data: GraphData | null): string | null {
+ if (!data || data.total_nodes <= data.nodes.length) return null;
+ return `Showing ${data.nodes.length.toLocaleString()} of ${data.total_nodes.toLocaleString()} nodes. Use filters to narrow.`;
+}
+
export function GraphTab({ project }: GraphTabProps) {
const { data, loading, error, fetchOverview } = useGraphData();
const [highlightedIds, setHighlightedIds] = useState<Set<number> | null>(null);
@@ -38,6 +43,7 @@ export function GraphTab({ project }: GraphTabProps) {
const [showLabels, setShowLabels] = useState(true);
const [leftWidth, setLeftWidth] = useState(() => loadWidth("cbm-left-w", 260));
const [rightWidth, setRightWidth] = useState(() => loadWidth("cbm-right-w", 280));
+ const limitNotice = formatGraphLimitNotice(data);
/* Filter state — all enabled by default */
const [enabledLabels, setEnabledLabels] = useState<Set<string>>(new Set());
@@ -282,6 +288,9 @@ export function GraphTab({ project }: GraphTabProps) {
filtered from {data.nodes.length.toLocaleString()}
</p>
)}
+ {limitNotice && (
+ <p className="text-amber-300/80 mt-0.5">{limitNotice}</p>
+ )}
{highlightedIds && highlightedIds.size > 0 && (
<p className="text-cyan-400/50 mt-0.5">
{highlightedIds.size} selected
diff --git a/graph-ui/src/hooks/useGraphData.test.ts b/graph-ui/src/hooks/useGraphData.test.ts
new file mode 100644
index 000000000..7edb76248
--- /dev/null
+++ b/graph-ui/src/hooks/useGraphData.test.ts
@@ -0,0 +1,26 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { fetchLayout, GRAPH_RENDER_NODE_LIMIT } from "./useGraphData";
+
+describe("fetchLayout", () => {
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
+ it("uses the safe graph render cap by default", async () => {
+ const fetchMock = vi.fn(async () => ({
+ ok: true,
+ json: async () => ({ nodes: [], edges: [], total_nodes: 0 }),
+ }));
+ vi.stubGlobal("fetch", fetchMock);
+
+ await fetchLayout("large-project");
+
+ expect(GRAPH_RENDER_NODE_LIMIT).toBe(2000);
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ const calls = fetchMock.mock.calls as unknown as Array<[string]>;
+ const [url] = calls[0];
+ expect(url).toBe(
+ "/api/layout?project=large-project&max_nodes=2000",
+ );
+ });
+});
diff --git a/graph-ui/src/hooks/useGraphData.ts b/graph-ui/src/hooks/useGraphData.ts
index 36048bcac..5705555fa 100644
--- a/graph-ui/src/hooks/useGraphData.ts
+++ b/graph-ui/src/hooks/useGraphData.ts
@@ -9,9 +9,11 @@ interface UseGraphDataResult {
fetchDetail: (project: string, centerNode: string) => void;
}
-async function fetchLayout(
+export const GRAPH_RENDER_NODE_LIMIT = 2000;
+
+export async function fetchLayout(
project: string,
- maxNodes = 50000,
+ maxNodes = GRAPH_RENDER_NODE_LIMIT,
): Promise<GraphData> {
const params = new URLSearchParams({ project, max_nodes: String(maxNodes) });
const res = await fetch(`/api/layout?${params}`);
@@ -33,7 +35,7 @@ export function useGraphData(): UseGraphDataResult {
setLoading(true);
setError(null);
try {
- const result = await fetchLayout(project, 50000);
+ const result = await fetchLayout(project);
setData(result);
} catch (e) {
setError(e instanceof Error ? e.message : "Failed to fetch layout");
@@ -48,7 +50,7 @@ export function useGraphData(): UseGraphDataResult {
setError(null);
try {
/* TODO: detail level with center_node filtering */
- const result = await fetchLayout(project, 50000);
+ const result = await fetchLayout(project);
setData(result);
} catch (e) {
setError(e instanceof Error ? e.message : "Failed to fetch layout");
diff --git a/graph-ui/tsconfig.tsbuildinfo b/graph-ui/tsconfig.tsbuildinfo
index e1401cf36..90f6612f2 100644
--- a/graph-ui/tsconfig.tsbuildinfo
+++ b/graph-ui/tsconfig.tsbuildinfo
@@ -1 +1 @@
-{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/rpc.ts","./src/components/controltab.tsx","./src/components/edgelines.tsx","./src/components/errorboundary.tsx","./src/components/filterpanel.tsx","./src/components/graphscene.tsx","./src/components/graphtab.tsx","./src/components/nodecloud.tsx","./src/components/nodedetailpanel.tsx","./src/components/nodelabels.tsx","./src/components/nodetooltip.tsx","./src/components/projectcard.tsx","./src/components/resizehandle.tsx","./src/components/sidebar.tsx","./src/components/statstab.tsx","./src/components/tabbar.tsx","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/input.tsx","./src/components/ui/scroll-area.tsx","./src/components/ui/separator.tsx","./src/hooks/usegraphdata.ts","./src/hooks/useprojects.ts","./src/lib/colors.ts","./src/lib/types.ts","./src/lib/utils.ts"],"version":"5.9.3"}
\ No newline at end of file
+{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/rpc.ts","./src/components/controltab.tsx","./src/components/edgelines.tsx","./src/components/errorboundary.tsx","./src/components/filterpanel.tsx","./src/components/graphscene.test.ts","./src/components/graphscene.tsx","./src/components/graphtab.test.ts","./src/components/graphtab.tsx","./src/components/nodecloud.tsx","./src/components/nodedetailpanel.tsx","./src/components/nodelabels.tsx","./src/components/nodetooltip.tsx","./src/components/projectcard.tsx","./src/components/resizehandle.tsx","./src/components/sidebar.tsx","./src/components/statstab.tsx","./src/components/tabbar.tsx","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/input.tsx","./src/components/ui/scroll-area.tsx","./src/components/ui/separator.tsx","./src/hooks/usegraphdata.test.ts","./src/hooks/usegraphdata.ts","./src/hooks/useprojects.ts","./src/lib/colors.ts","./src/lib/types.ts","./src/lib/utils.ts"],"version":"5.9.3"}
\ No newline at end of file
diff --git a/src/ui/http_server.c b/src/ui/http_server.c
index 1f61ef771..5ec072bbc 100644
--- a/src/ui/http_server.c
+++ b/src/ui/http_server.c
@@ -23,6 +23,7 @@
#include "foundation/log.h"
#include "foundation/platform.h"
#include "foundation/compat.h"
+#include "foundation/compat_fs.h"
#include "foundation/str_util.h"
#include "foundation/compat_thread.h"
@@ -39,6 +40,7 @@
#include <process.h>
#include <psapi.h> /* GetProcessMemoryInfo */
#else
+#include <sys/stat.h>
#include <unistd.h>
#include <sys/wait.h>
#endif
@@ -582,9 +584,107 @@ static void handle_adr_save(cbm_http_conn_t *c, const cbm_http_req_t *req) {
static char g_binary_path[1024] = {0};
+static bool copy_path(char *out, size_t outsz, const char *path) {
+ if (!out || outsz == 0 || !path || !path[0]) {
+ return false;
+ }
+ int n = snprintf(out, outsz, "%s", path);
+ return n > 0 && (size_t)n < outsz;
+}
+
+#ifndef _WIN32
+static bool is_executable_file(const char *path) {
+ struct stat st;
+ return path && stat(path, &st) == 0 && S_ISREG(st.st_mode) && access(path, X_OK) == 0;
+}
+
+static bool resolve_from_path(const char *name, char *out, size_t outsz) {
+ const char *path = getenv("PATH");
+ if (!name || !name[0] || strchr(name, '/') || !path || !path[0]) {
+ return false;
+ }
+
+ const char *cur = path;
+ while (*cur) {
+ const char *colon = strchr(cur, ':');
+ size_t dir_len = colon ? (size_t)(colon - cur) : strlen(cur);
+ if (dir_len > 0 && dir_len < 900) {
+ char candidate[1024];
+ int n = snprintf(candidate, sizeof(candidate), "%.*s/%s", (int)dir_len, cur, name);
+ if (n > 0 && (size_t)n < sizeof(candidate) && is_executable_file(candidate)) {
+ return copy_path(out, outsz, candidate);
+ }
+ }
+ if (!colon) {
+ break;
+ }
+ cur = colon + 1;
+ }
+ return false;
+}
+
+static bool resolve_self_executable(char *out, size_t outsz) {
+#if defined(__APPLE__)
+ char buf[1024];
+ uint32_t sz = sizeof(buf);
+ if (_NSGetExecutablePath(buf, &sz) == 0 && buf[0]) {
+ return copy_path(out, outsz, buf);
+ }
+ return false;
+#else
+ char buf[1024];
+ ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
+ if (len > 0) {
+ buf[len] = '\0';
+ return copy_path(out, outsz, buf);
+ }
+ return false;
+#endif
+}
+#else
+static bool resolve_self_executable(char *out, size_t outsz) {
+ char buf[1024];
+ DWORD n = GetModuleFileNameA(NULL, buf, (DWORD)sizeof(buf));
+ if (n > 0 && n < sizeof(buf)) {
+ return copy_path(out, outsz, buf);
+ }
+ return false;
+}
+#endif
+
+bool cbm_http_server_resolve_binary_path(const char *argv0, char *out, size_t outsz) {
+ if (!out || outsz == 0) {
+ return false;
+ }
+ out[0] = '\0';
+
+#ifndef _WIN32
+ if (argv0 && strchr(argv0, '/') && is_executable_file(argv0)) {
+ return copy_path(out, outsz, argv0);
+ }
+ if (resolve_from_path(argv0, out, outsz)) {
+ return true;
+ }
+#else
+ if (argv0 && argv0[0]) {
+ DWORD attrs = GetFileAttributesA(argv0);
+ if (attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY)) {
+ return copy_path(out, outsz, argv0);
+ }
+ }
+#endif
+
+ if (resolve_self_executable(out, outsz)) {
+ return true;
+ }
+ return copy_path(out, outsz, argv0);
+}
+
void cbm_http_server_set_binary_path(const char *path) {
if (path) {
- snprintf(g_binary_path, sizeof(g_binary_path), "%s", path);
+ if (!cbm_http_server_resolve_binary_path(path, g_binary_path, sizeof(g_binary_path))) {
+ g_binary_path[0] = '\0';
+ }
}
}
@@ -597,16 +697,7 @@ static void *index_thread_fn(void *arg) {
const char *bin = g_binary_path;
char self_path[1024] = {0};
if (!bin[0]) {
-#ifdef _WIN32
- GetModuleFileNameA(NULL, self_path, sizeof(self_path));
-#elif defined(__APPLE__)
- uint32_t sz = sizeof(self_path);
- _NSGetExecutablePath(self_path, &sz);
-#else
- ssize_t len = readlink("/proc/self/exe", self_path, sizeof(self_path) - 1);
- if (len > 0)
- self_path[len] = '\0';
-#endif
+ cbm_http_server_resolve_binary_path(NULL, self_path, sizeof(self_path));
bin = self_path[0] ? self_path : "codebase-memory-mcp";
}
diff --git a/src/ui/http_server.h b/src/ui/http_server.h
index 741a9f990..69d89b5f8 100644
--- a/src/ui/http_server.h
+++ b/src/ui/http_server.h
@@ -11,6 +11,7 @@
#define CBM_UI_HTTP_SERVER_H
#include <stdbool.h>
+#include <stddef.h>
typedef struct cbm_http_server cbm_http_server_t;
@@ -47,4 +48,7 @@ void cbm_ui_log_append(const char *line);
/* Set the binary path for subprocess spawning (call from main). */
void cbm_http_server_set_binary_path(const char *path);
+/* Resolve argv[0] into an executable path suitable for subprocess spawning. */
+bool cbm_http_server_resolve_binary_path(const char *argv0, char *out, size_t outsz);
+
#endif /* CBM_UI_HTTP_SERVER_H */
diff --git a/src/ui/layout3d.c b/src/ui/layout3d.c
index 5758a3334..e7e69f0dd 100644
--- a/src/ui/layout3d.c
+++ b/src/ui/layout3d.c
@@ -17,13 +17,15 @@
#include <yyjson/yyjson.h>
#include <math.h>
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
/* ── Constants ────────────────────────────────────────────────── */
-#define DEFAULT_MAX_NODES 50000
+#define DEFAULT_MAX_NODES 2000
+#define HARD_MAX_NODES 10000
#define BH_THETA 1.2f
/* Local optimization: gentle, preserves structure */
@@ -110,6 +112,31 @@ static float rand_float(uint32_t *seed) {
return (float)((*seed >> 16) & 0x7FFF) / 32768.0f - 0.5f;
}
+static int render_node_limit(void) {
+ const char *raw = getenv("CBM_UI_MAX_RENDER_NODES");
+ if (!raw || !raw[0]) {
+ return DEFAULT_MAX_NODES;
+ }
+ errno = 0;
+ char *end = NULL;
+ long v = strtol(raw, &end, 10);
+ if (errno != 0 || end == raw || *end != '\0' || v <= 0) {
+ return DEFAULT_MAX_NODES;
+ }
+ if (v > HARD_MAX_NODES) {
+ return HARD_MAX_NODES;
+ }
+ return (int)v;
+}
+
+static int clamp_max_nodes(int requested) {
+ int cap = render_node_limit();
+ if (requested <= 0 || requested > cap) {
+ return cap;
+ }
+ return requested;
+}
+
/* ── Barnes-Hut Octree ────────────────────────────────────────── */
typedef struct octree_node {
@@ -387,8 +414,7 @@ cbm_layout_result_t *cbm_layout_compute(cbm_store_t *store, const char *project,
int radius, int max_nodes) {
if (!store || !project)
return NULL;
- if (max_nodes <= 0)
- max_nodes = DEFAULT_MAX_NODES;
+ max_nodes = clamp_max_nodes(max_nodes);
(void)center_node;
(void)radius;
(void)level;
diff --git a/tests/test_httpd.c b/tests/test_httpd.c
index d5609786f..c8d42bed3 100644
--- a/tests/test_httpd.c
+++ b/tests/test_httpd.c
@@ -11,8 +11,10 @@
* RPC dispatch, transport limits, receive deadline, clean shutdown.
*/
#include "../src/foundation/compat.h"
+#include "../src/foundation/compat_fs.h"
#include "../src/foundation/compat_thread.h"
#include "../src/foundation/log.h"
+#include "../src/ui/http_server.h"
#include "test_framework.h"
#include "test_helpers.h"
#include "ui/httpd.h"
@@ -21,6 +23,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef _WIN32
+#include <sys/stat.h>
+#endif
#ifdef _WIN32
#include <winsock2.h>
@@ -325,6 +330,41 @@ TEST(httpd_path_match_matrix) {
PASS();
}
+TEST(httpd_resolves_bare_binary_path_from_path) {
+#ifdef _WIN32
+ PASS();
+#else
+ char tmpdir[256];
+ snprintf(tmpdir, sizeof(tmpdir), "/tmp/cbm_httpd_bin_XXXXXX");
+ char *td = cbm_mkdtemp(tmpdir);
+ ASSERT_NOT_NULL(td);
+
+ char exe[512];
+ snprintf(exe, sizeof(exe), "%s/codebase-memory-mcp", td);
+ FILE *f = fopen(exe, "w");
+ ASSERT_NOT_NULL(f);
+ fputs("#!/bin/sh\nexit 0\n", f);
+ fclose(f);
+ ASSERT_EQ(chmod(exe, 0755), 0);
+
+ char *old_path = getenv("PATH") ? strdup(getenv("PATH")) : NULL;
+ cbm_setenv("PATH", td, 1);
+
+ char resolved[1024];
+ ASSERT_TRUE(cbm_http_server_resolve_binary_path("codebase-memory-mcp", resolved,
+ sizeof(resolved)));
+ ASSERT_STR_EQ(resolved, exe);
+
+ if (old_path) {
+ cbm_setenv("PATH", old_path, 1);
+ free(old_path);
+ } else {
+ cbm_unsetenv("PATH");
+ }
+ PASS();
+#endif
+}
+
/* ── Transport integration (listener only) ────────────────────── */
TEST(httpd_listen_ephemeral_port) {
@@ -604,6 +644,7 @@ SUITE(httpd) {
RUN_TEST(httpd_query_param_decode);
RUN_TEST(httpd_query_param_edge_cases);
RUN_TEST(httpd_path_match_matrix);
+ RUN_TEST(httpd_resolves_bare_binary_path_from_path);
/* Transport */
RUN_TEST(httpd_listen_ephemeral_port);
diff --git a/tests/test_main.c b/tests/test_main.c
index ee2d8a9d7..227e838dd 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -10,6 +10,30 @@ int tf_skip_count = 0;
#include "test_framework.h"
#include <sqlite3.h>
+#include <stdbool.h>
+#include <string.h>
+
+static int g_suite_argc = 0;
+static char **g_suite_argv = NULL;
+
+static bool suite_requested(const char *name) {
+ if (g_suite_argc <= 1) {
+ return true;
+ }
+ for (int i = 1; i < g_suite_argc; i++) {
+ if (strcmp(g_suite_argv[i], name) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
+#define RUN_SELECTED_SUITE(name) \
+ do { \
+ if (suite_requested(#name)) { \
+ RUN_SUITE(name); \
+ } \
+ } while (0)
/* Forward declarations of suite functions */
extern void suite_arena(void);
@@ -106,155 +130,157 @@ extern void suite_dump_verify_io(void);
* caches at thread teardown (pass_parallel.c). */
extern void cbm_kind_in_set_free_cache(void);
-int main(void) {
+int main(int argc, char **argv) {
+ g_suite_argc = argc;
+ g_suite_argv = argv;
printf("\n codebase-memory-mcp C test suite\n");
/* Foundation */
- RUN_SUITE(arena);
- RUN_SUITE(hash_table);
- RUN_SUITE(dyn_array);
- RUN_SUITE(str_intern);
- RUN_SUITE(log);
- RUN_SUITE(str_util);
- RUN_SUITE(platform);
- RUN_SUITE(dump_verify);
+ RUN_SELECTED_SUITE(arena);
+ RUN_SELECTED_SUITE(hash_table);
+ RUN_SELECTED_SUITE(dyn_array);
+ RUN_SELECTED_SUITE(str_intern);
+ RUN_SELECTED_SUITE(log);
+ RUN_SELECTED_SUITE(str_util);
+ RUN_SELECTED_SUITE(platform);
+ RUN_SELECTED_SUITE(dump_verify);
/* Existing C code regression tests */
- RUN_SUITE(ac);
- RUN_SUITE(extraction);
- RUN_SUITE(extraction_inheritance);
- RUN_SUITE(extraction_imports);
- RUN_SUITE(grammar_regression);
- RUN_SUITE(grammar_labels);
- RUN_SUITE(grammar_imports);
+ RUN_SELECTED_SUITE(ac);
+ RUN_SELECTED_SUITE(extraction);
+ RUN_SELECTED_SUITE(extraction_inheritance);
+ RUN_SELECTED_SUITE(extraction_imports);
+ RUN_SELECTED_SUITE(grammar_regression);
+ RUN_SELECTED_SUITE(grammar_labels);
+ RUN_SELECTED_SUITE(grammar_imports);
/* Store (M5) */
- RUN_SUITE(store_nodes);
- RUN_SUITE(store_edges);
- RUN_SUITE(store_search);
- RUN_SUITE(store_bulk);
- RUN_SUITE(store_pragmas);
- RUN_SUITE(store_checkpoint);
- RUN_SUITE(dump_verify_io);
+ RUN_SELECTED_SUITE(store_nodes);
+ RUN_SELECTED_SUITE(store_edges);
+ RUN_SELECTED_SUITE(store_search);
+ RUN_SELECTED_SUITE(store_bulk);
+ RUN_SELECTED_SUITE(store_pragmas);
+ RUN_SELECTED_SUITE(store_checkpoint);
+ RUN_SELECTED_SUITE(dump_verify_io);
/* Cypher (M6) */
- RUN_SUITE(cypher);
+ RUN_SELECTED_SUITE(cypher);
/* MCP Server (M9) */
- RUN_SUITE(mcp);
+ RUN_SELECTED_SUITE(mcp);
/* Discover (M2) */
- RUN_SUITE(language);
- RUN_SUITE(userconfig);
- RUN_SUITE(gitignore);
- RUN_SUITE(discover);
+ RUN_SELECTED_SUITE(language);
+ RUN_SELECTED_SUITE(userconfig);
+ RUN_SELECTED_SUITE(gitignore);
+ RUN_SELECTED_SUITE(discover);
/* Graph Buffer (M7) */
- RUN_SUITE(graph_buffer);
+ RUN_SELECTED_SUITE(graph_buffer);
/* Pipeline (M8) */
- RUN_SUITE(registry);
- RUN_SUITE(pipeline);
- RUN_SUITE(fqn);
- RUN_SUITE(route_canon);
- RUN_SUITE(path_alias);
+ RUN_SELECTED_SUITE(registry);
+ RUN_SELECTED_SUITE(pipeline);
+ RUN_SELECTED_SUITE(fqn);
+ RUN_SELECTED_SUITE(route_canon);
+ RUN_SELECTED_SUITE(path_alias);
/* Watcher (M10) */
- RUN_SUITE(watcher);
+ RUN_SELECTED_SUITE(watcher);
/* LZ4 + zstd + SQLite writer */
- RUN_SUITE(lz4);
- RUN_SUITE(zstd);
- RUN_SUITE(sqlite_writer);
+ RUN_SELECTED_SUITE(lz4);
+ RUN_SELECTED_SUITE(zstd);
+ RUN_SELECTED_SUITE(sqlite_writer);
/* Persistent artifact export/import */
- RUN_SUITE(artifact);
+ RUN_SELECTED_SUITE(artifact);
/* LSP resolvers */
- RUN_SUITE(scope);
- RUN_SUITE(type_rep);
- RUN_SUITE(go_lsp);
- RUN_SUITE(c_lsp);
- RUN_SUITE(php_lsp);
- RUN_SUITE(cs_lsp);
- RUN_SUITE(cs_lsp_bench);
- RUN_SUITE(py_lsp);
- RUN_SUITE(kotlin_lsp);
- RUN_SUITE(rust_lsp);
- RUN_SUITE(py_lsp_bench);
- RUN_SUITE(py_lsp_stress);
- RUN_SUITE(py_lsp_scale);
- RUN_SUITE(ts_lsp);
- RUN_SUITE(java_lsp);
- RUN_SUITE(java_lsp_coverage);
+ RUN_SELECTED_SUITE(scope);
+ RUN_SELECTED_SUITE(type_rep);
+ RUN_SELECTED_SUITE(go_lsp);
+ RUN_SELECTED_SUITE(c_lsp);
+ RUN_SELECTED_SUITE(php_lsp);
+ RUN_SELECTED_SUITE(cs_lsp);
+ RUN_SELECTED_SUITE(cs_lsp_bench);
+ RUN_SELECTED_SUITE(py_lsp);
+ RUN_SELECTED_SUITE(kotlin_lsp);
+ RUN_SELECTED_SUITE(rust_lsp);
+ RUN_SELECTED_SUITE(py_lsp_bench);
+ RUN_SELECTED_SUITE(py_lsp_stress);
+ RUN_SELECTED_SUITE(py_lsp_scale);
+ RUN_SELECTED_SUITE(ts_lsp);
+ RUN_SELECTED_SUITE(java_lsp);
+ RUN_SELECTED_SUITE(java_lsp_coverage);
/* Architecture + ADR + Louvain */
- RUN_SUITE(store_arch);
+ RUN_SELECTED_SUITE(store_arch);
/* HTTP link */
/* Traces helpers */
- RUN_SUITE(traces);
+ RUN_SELECTED_SUITE(traces);
/* Config link */
- RUN_SUITE(configlink);
+ RUN_SELECTED_SUITE(configlink);
/* Infrastructure scanning */
- RUN_SUITE(infrascan);
+ RUN_SELECTED_SUITE(infrascan);
/* CLI (install, update, config) */
- RUN_SUITE(cli);
+ RUN_SELECTED_SUITE(cli);
/* System info + worker pool (parallelism) */
- RUN_SUITE(system_info);
- RUN_SUITE(worker_pool);
+ RUN_SELECTED_SUITE(system_info);
+ RUN_SELECTED_SUITE(worker_pool);
/* Parallel pipeline */
- RUN_SUITE(parallel);
+ RUN_SELECTED_SUITE(parallel);
/* mem + arena + slab integration */
- RUN_SUITE(mem);
+ RUN_SELECTED_SUITE(mem);
/* UI (config, embedded assets, layout) */
- RUN_SUITE(ui);
+ RUN_SELECTED_SUITE(ui);
/* UI HTTP server (transport + routing) */
- RUN_SUITE(httpd);
+ RUN_SELECTED_SUITE(httpd);
/* Security defenses */
- RUN_SUITE(security);
+ RUN_SELECTED_SUITE(security);
/* YAML parser */
- RUN_SUITE(yaml);
+ RUN_SELECTED_SUITE(yaml);
/* SimHash / SIMILAR_TO */
- RUN_SUITE(simhash);
+ RUN_SELECTED_SUITE(simhash);
/* Stack overflow regression (GitHub #199) */
- RUN_SUITE(stack_overflow);
+ RUN_SELECTED_SUITE(stack_overflow);
/* Integration (end-to-end) */
- RUN_SUITE(integration);
+ RUN_SELECTED_SUITE(integration);
/* Per-language graph contracts (node/edge types, attribution, no-crash) */
- RUN_SUITE(lang_contract);
- RUN_SUITE(edge_imports);
- RUN_SUITE(edge_structural);
- RUN_SUITE(lsp_resolution_probe);
- RUN_SUITE(node_creation_probe);
- RUN_SUITE(edge_types_probe);
- RUN_SUITE(convergence_probe);
- RUN_SUITE(matrix_known_classes);
- RUN_SUITE(matrix_new_constructs);
- RUN_SUITE(grammar_probe_a);
- RUN_SUITE(grammar_probe_b);
- RUN_SUITE(grammar_probe_c);
- RUN_SUITE(grammar_probe_d);
- RUN_SUITE(grammar_probe_e);
- RUN_SUITE(grammar_probe_f);
- RUN_SUITE(grammar_probe_g);
-
- RUN_SUITE(incremental);
+ RUN_SELECTED_SUITE(lang_contract);
+ RUN_SELECTED_SUITE(edge_imports);
+ RUN_SELECTED_SUITE(edge_structural);
+ RUN_SELECTED_SUITE(lsp_resolution_probe);
+ RUN_SELECTED_SUITE(node_creation_probe);
+ RUN_SELECTED_SUITE(edge_types_probe);
+ RUN_SELECTED_SUITE(convergence_probe);
+ RUN_SELECTED_SUITE(matrix_known_classes);
+ RUN_SELECTED_SUITE(matrix_new_constructs);
+ RUN_SELECTED_SUITE(grammar_probe_a);
+ RUN_SELECTED_SUITE(grammar_probe_b);
+ RUN_SELECTED_SUITE(grammar_probe_c);
+ RUN_SELECTED_SUITE(grammar_probe_d);
+ RUN_SELECTED_SUITE(grammar_probe_e);
+ RUN_SELECTED_SUITE(grammar_probe_f);
+ RUN_SELECTED_SUITE(grammar_probe_g);
+
+ RUN_SELECTED_SUITE(incremental);
/* Release process-lifetime caches so LeakSanitizer reports no leaks. */
cbm_kind_in_set_free_cache();
diff --git a/tests/test_ui.c b/tests/test_ui.c
index 002e8d39a..9cb8efd45 100644
--- a/tests/test_ui.c
+++ b/tests/test_ui.c
@@ -317,6 +317,46 @@ TEST(layout_respects_max_nodes) {
PASS();
}
+TEST(layout_clamps_render_cap_from_env) {
+ cbm_store_t *store = cbm_store_open_memory();
+ ASSERT_NOT_NULL(store);
+
+ const char *old_raw = getenv("CBM_UI_MAX_RENDER_NODES");
+ char *old_cap = old_raw ? strdup(old_raw) : NULL;
+ cbm_setenv("CBM_UI_MAX_RENDER_NODES", "25", 1);
+
+ cbm_store_upsert_project(store, "test", "/tmp/test");
+
+ for (int i = 0; i < 40; i++) {
+ char name[32], qn[64];
+ snprintf(name, sizeof(name), "fn%d", i);
+ snprintf(qn, sizeof(qn), "test::fn%d", i);
+ cbm_node_t n = {.project = "test",
+ .label = "Function",
+ .name = name,
+ .qualified_name = qn,
+ .file_path = "a.c",
+ .start_line = i,
+ .end_line = i + 1};
+ cbm_store_upsert_node(store, &n);
+ }
+
+ cbm_layout_result_t *r = cbm_layout_compute(store, "test", CBM_LAYOUT_OVERVIEW, NULL, 0, 50000);
+ ASSERT_NOT_NULL(r);
+ ASSERT_LTE(r->node_count, 25);
+ ASSERT_EQ(r->total_nodes, 40);
+
+ cbm_layout_free(r);
+ cbm_store_close(store);
+ if (old_cap) {
+ cbm_setenv("CBM_UI_MAX_RENDER_NODES", old_cap, 1);
+ free(old_cap);
+ } else {
+ cbm_unsetenv("CBM_UI_MAX_RENDER_NODES");
+ }
+ PASS();
+}
+
TEST(layout_deterministic) {
cbm_store_t *store = cbm_store_open_memory();
ASSERT_NOT_NULL(store);
@@ -433,6 +473,7 @@ SUITE(ui) {
RUN_TEST(layout_single_node);
RUN_TEST(layout_two_connected);
RUN_TEST(layout_respects_max_nodes);
+ RUN_TEST(layout_clamps_render_cap_from_env);
RUN_TEST(layout_deterministic);
RUN_TEST(layout_to_json);
RUN_TEST(layout_null_inputs);