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.

feat(atlas): honest lists — overflow shape, seam dots, boundary spanners

Martin Vogela30656959666
diff --git a/graph-ui/src/components/OverviewTab.tsx b/graph-ui/src/components/OverviewTab.tsx
index e8e081718..ab1cf4265 100644
--- a/graph-ui/src/components/OverviewTab.tsx
+++ b/graph-ui/src/components/OverviewTab.tsx
@@ -5,7 +5,13 @@
* away instead of shouting; inventory lives in the footer. */
import { useEffect, useMemo, useState } from "react";
import { ScrollArea } from "@/components/ui/scroll-area";
-import { fetchArchitecture, archRows, type ArchitectureJson } from "../lib/atlas";
+import {
+ fetchArchitecture,
+ fetchBridges,
+ archRows,
+ type ArchitectureJson,
+ type BridgeRow,
+} from "../lib/atlas";
import { fetchRegions } from "../hooks/useGraphData";
import {
disambiguateRegionNames,
@@ -114,6 +120,24 @@ export function OverviewTab({
const [error, setError] = useState<string | null>(null);
const [includeTests, setIncludeTests] = useState(false);
const [dismissedTick, setDismissedTick] = useState(0);
+ const [bridges, setBridges] = useState<BridgeRow[]>([]);
+
+ /* Boundary spanners ride alongside the main load; best-effort, silent on
+ * failure. (A true staleness banner needs a files-changed-since-indexing
+ * signal the server does not expose yet — recorded as a follow-up rather
+ * than shipped with wrong semantics.) */
+ useEffect(() => {
+ let cancelled = false;
+ setBridges([]);
+ fetchBridges(project)
+ .then((payload) => {
+ if (!cancelled) setBridges(payload.bridges ?? []);
+ })
+ .catch(() => {});
+ return () => {
+ cancelled = true;
+ };
+ }, [project]);
useEffect(() => {
let cancelled = false;
@@ -409,6 +433,35 @@ export function OverviewTab({
)}
</div>
+ {/* Boundary spanners — the seam-stitching metric, distinct from
+ * degree hubs (which find utilities). */}
+ {bridges.length > 0 && (
+ <div className="bg-card border border-border/40 rounded-md p-4 mb-5">
+ <p className="text-[12px] uppercase tracking-widest text-foreground/40 mb-2">
+ Boundary spanners — code that reaches into many regions
+ </p>
+ {bridges.map((bridge) => (
+ <div key={bridge.id} className="flex items-center gap-2 py-[3px]">
+ <button
+ onClick={() => bridge.qualified_name && onOpenSymbol(bridge.qualified_name)}
+ className="text-[13px] font-mono text-foreground/65 hover:text-primary truncate text-left transition-colors"
+ title={bridge.file_path}
+ >
+ {bridge.name}
+ </button>
+ <span className="text-[12px] text-foreground/40 tabular-nums ml-auto shrink-0">
+ {bridge.regions} regions · {bridge.cross_calls.toLocaleString("en-US")}{" "}
+ cross calls
+ </span>
+ </div>
+ ))}
+ <p className="text-[12px] text-foreground/35 mt-1.5">
+ Changes here ripple across regions — mention these names when a task spans
+ areas.
+ </p>
+ </div>
+ )}
+
{/* Reference — one disclosure away, never shouting. */}
<details className="mb-5">
<summary className="cursor-pointer text-[12px] uppercase tracking-widest text-foreground/40 hover:text-foreground/60 transition-colors select-none">
diff --git a/graph-ui/src/components/SymbolTab.tsx b/graph-ui/src/components/SymbolTab.tsx
index 669422fc5..829dd2168 100644
--- a/graph-ui/src/components/SymbolTab.tsx
+++ b/graph-ui/src/components/SymbolTab.tsx
@@ -33,11 +33,13 @@ const CONFIDENCE: Record<string, { label: string; tone: string }> = {
function ConnectionList({
title,
page,
+ homeRegion,
onLoadMore,
onOpenSymbol,
}: {
title: string;
page: ConnectionPage;
+ homeRegion?: number;
onLoadMore: () => void;
onOpenSymbol: (ref: { id?: number; qn?: string }) => void;
}) {
@@ -70,6 +72,14 @@ function ConnectionList({
<span className="text-[13px] font-mono text-foreground/65 group-hover:text-primary truncate transition-colors">
{item.name}
</span>
+ {item.region !== undefined &&
+ homeRegion !== undefined &&
+ item.region !== homeRegion && (
+ <span
+ className="w-[6px] h-[6px] rounded-full bg-primary/70 shrink-0"
+ title="in another region — this edge crosses an architectural seam"
+ />
+ )}
<span className="text-[12px] text-foreground/35 truncate ml-auto shrink-0 max-w-[45%]">
{item.file_path}
</span>
@@ -80,12 +90,27 @@ function ConnectionList({
)}
</div>
{shown < page.total && (
- <button
- onClick={onLoadMore}
- className="mt-1.5 px-2 text-[12px] text-primary/70 hover:text-primary transition-colors"
- >
- Show more ({(page.total - shown).toLocaleString("en-US")} hidden)
- </button>
+ <>
+ <button
+ onClick={onLoadMore}
+ className="mt-1.5 px-2 text-[12px] text-primary/70 hover:text-primary transition-colors"
+ >
+ Show more ({(page.total - shown).toLocaleString("en-US")} hidden)
+ </button>
+ {(page.overflow_by_file?.length ?? 0) > 0 && (
+ <div className="mt-1 px-2">
+ <p className="text-[12px] text-foreground/35 mb-0.5">hidden, by file:</p>
+ {page.overflow_by_file!.map((row) => (
+ <p
+ key={row.file}
+ className="text-[12px] font-mono text-foreground/45 truncate tabular-nums"
+ >
+ {row.file} × {row.count}
+ </p>
+ ))}
+ </div>
+ )}
+ </>
)}
</div>
);
@@ -276,12 +301,14 @@ export function SymbolTab({ project, symbolRef, onOpenSymbol, onOpenRegion }: Sy
<ConnectionList
title="Called by"
page={bundle.callers}
+ homeRegion={bundle.region?.id}
onLoadMore={() => setLimit((value) => value + 100)}
onOpenSymbol={onOpenSymbol}
/>
<ConnectionList
title="Calls"
page={bundle.callees}
+ homeRegion={bundle.region?.id}
onLoadMore={() => setLimit((value) => value + 100)}
onOpenSymbol={onOpenSymbol}
/>
@@ -328,6 +355,7 @@ export function SymbolTab({ project, symbolRef, onOpenSymbol, onOpenRegion }: Sy
</p>
)}
</div>
+ {bundle.project_has_data_flows !== false && (
<div className="bg-card border border-border/50 rounded-md p-4">
<p className="text-[12px] uppercase tracking-widest text-foreground/40 mb-2">
Data flows
@@ -369,6 +397,7 @@ export function SymbolTab({ project, symbolRef, onOpenSymbol, onOpenRegion }: Sy
</p>
)}
</div>
+ )}
</div>
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
diff --git a/graph-ui/src/lib/atlas.ts b/graph-ui/src/lib/atlas.ts
index 32b9a0880..476eddf73 100644
--- a/graph-ui/src/lib/atlas.ts
+++ b/graph-ui/src/lib/atlas.ts
@@ -39,6 +39,7 @@ export function fetchTree(project: string, path: string): Promise<TreePayload> {
/* ── /api/symbol ────────────────────────────────────────────── */
export interface SymbolRef {
+ region?: number;
id: number;
name: string;
label?: string;
@@ -54,6 +55,8 @@ export interface ConnectionPage {
limit: number;
offset: number;
items: SymbolRef[];
+ /* The shape of what the page cut: hidden remainder grouped by file. */
+ overflow_by_file?: { file: string; count: number }[];
}
export interface DataFlowRef {
@@ -96,6 +99,9 @@ export interface SymbolBundle {
data_in?: DataFlowRef[];
data_out?: DataFlowRef[];
file_history?: FileHistory;
+ /* False = this project has no DATA_FLOWS edges at all, so the panel
+ * would only ever say "none" and should not render. */
+ project_has_data_flows?: boolean;
}
export function fetchSymbol(
@@ -292,3 +298,18 @@ export function fetchScent(project: string, q: string): Promise<ScentPayload> {
const params = new URLSearchParams({ project, q });
return getJson(`/api/scent?${params}`);
}
+
+/* ── /api/bridges — boundary spanners by distinct-region reach ── */
+
+export interface BridgeRow {
+ id: number;
+ name: string;
+ qualified_name?: string;
+ file_path?: string;
+ regions: number;
+ cross_calls: number;
+}
+
+export function fetchBridges(project: string): Promise<{ bridges: BridgeRow[] }> {
+ return getJson(`/api/bridges?${new URLSearchParams({ project })}`);
+}
diff --git a/src/ui/atlas.h b/src/ui/atlas.h
index 125895c0e..f320c74a2 100644
--- a/src/ui/atlas.h
+++ b/src/ui/atlas.h
@@ -55,6 +55,8 @@ char *cbm_atlas_file_history_json(cbm_store_t *store, const char *project, const
* Reachability between two callables over CALLS ("calls") or DATA_FLOWS
* ("data"): shortest path within a bounded depth, honest about the bound.
* Endpoints resolve by node id (>=0) or qualified name. */
+char *cbm_atlas_bridges_json(cbm_store_t *store, const char *project);
+
char *cbm_atlas_scent_json(cbm_store_t *store, const char *project, const char *query);
char *cbm_atlas_trace_json(cbm_store_t *store, const char *project, int64_t from_id,
diff --git a/src/ui/atlas_api.c b/src/ui/atlas_api.c
index be41fda8a..1b916aacb 100644
--- a/src/ui/atlas_api.c
+++ b/src/ui/atlas_api.c
@@ -289,7 +289,8 @@ char *cbm_atlas_tree_json(cbm_store_t *store, const char *project, const char *p
/* Call-ish edge families shown on the symbol page, most certain first. */
#define AA_CALLISH_TYPES "'CALLS','CALL_REFERENCE','USAGE','HTTP_CALLS','ASYNC_CALLS'"
-static void aa_add_conn_rows(yyjson_mut_doc *doc, yyjson_mut_val *parent, sqlite3_stmt *st) {
+static void aa_add_conn_rows(yyjson_mut_doc *doc, yyjson_mut_val *parent, sqlite3_stmt *st,
+ cbm_store_t *store, const char *project) {
yyjson_mut_val *items = yyjson_mut_arr(doc);
while (sqlite3_step(st) == SQLITE_ROW) {
yyjson_mut_val *row = yyjson_mut_obj(doc);
@@ -306,6 +307,11 @@ static void aa_add_conn_rows(yyjson_mut_doc *doc, yyjson_mut_val *parent, sqlite
const char *qn = (const char *)sqlite3_column_text(st, 6);
if (qn)
yyjson_mut_obj_add_strcpy(doc, row, "qualified_name", qn);
+ if (file && store) {
+ int region = cbm_layout_region_for_file(store, project, file, NULL);
+ if (region >= 0)
+ yyjson_mut_obj_add_int(doc, row, "region", region);
+ }
yyjson_mut_arr_append(items, row);
}
yyjson_mut_obj_add_val(doc, parent, "items", items);
@@ -313,8 +319,8 @@ static void aa_add_conn_rows(yyjson_mut_doc *doc, yyjson_mut_val *parent, sqlite
/* callers (inbound=true) or callees of `id`, with totals and pagination. */
static void aa_add_connections(yyjson_mut_doc *doc, yyjson_mut_val *root, struct sqlite3 *db,
- const char *project, int64_t id, bool inbound, int limit,
- int offset) {
+ cbm_store_t *store, const char *project, int64_t id, bool inbound,
+ int limit, int offset) {
yyjson_mut_val *section = yyjson_mut_obj(doc);
const char *count_sql =
inbound ? "SELECT e.type, COUNT(*) FROM edges e WHERE e.project=?1 AND e.target_id=?2 "
@@ -360,9 +366,45 @@ static void aa_add_connections(yyjson_mut_doc *doc, yyjson_mut_val *root, struct
sqlite3_bind_int64(st, 2, id);
sqlite3_bind_int(st, 3, limit);
sqlite3_bind_int(st, 4, offset);
- aa_add_conn_rows(doc, section, st);
+ aa_add_conn_rows(doc, section, st, store, project);
sqlite3_finalize(st);
}
+
+ /* The shape of what the page cut, not just its size: the hidden
+ * remainder grouped by file (top 10 files). A bare "+N more" hides the
+ * answer to "who calls this" on every high-degree node. */
+ if (total > offset + limit) {
+ const char *tail_sql =
+ inbound ? "SELECT file_path, COUNT(*) FROM (SELECT n.file_path AS file_path FROM edges "
+ "e JOIN nodes n ON n.project=e.project AND n.id=e.source_id WHERE "
+ "e.project=?1 AND e.target_id=?2 AND e.type IN (" AA_CALLISH_TYPES ") ORDER "
+ "BY CASE e.type WHEN 'CALLS' THEN 0 WHEN 'CALL_REFERENCE' THEN 1 ELSE 2 END, "
+ "n.id LIMIT -1 OFFSET ?3) WHERE file_path IS NOT NULL GROUP BY file_path "
+ "ORDER BY COUNT(*) DESC, file_path LIMIT 10"
+ : "SELECT file_path, COUNT(*) FROM (SELECT n.file_path AS file_path FROM edges "
+ "e JOIN nodes n ON n.project=e.project AND n.id=e.target_id WHERE "
+ "e.project=?1 AND e.source_id=?2 AND e.type IN (" AA_CALLISH_TYPES ") ORDER "
+ "BY CASE e.type WHEN 'CALLS' THEN 0 WHEN 'CALL_REFERENCE' THEN 1 ELSE 2 END, "
+ "n.id LIMIT -1 OFFSET ?3) WHERE file_path IS NOT NULL GROUP BY file_path "
+ "ORDER BY COUNT(*) DESC, file_path LIMIT 10";
+ if (sqlite3_prepare_v2(db, tail_sql, -1, &st, NULL) == SQLITE_OK) {
+ sqlite3_bind_text(st, 1, project, -1, SQLITE_STATIC);
+ sqlite3_bind_int64(st, 2, id);
+ sqlite3_bind_int(st, 3, offset + limit);
+ yyjson_mut_val *tail = yyjson_mut_arr(doc);
+ while (sqlite3_step(st) == SQLITE_ROW) {
+ const char *file = (const char *)sqlite3_column_text(st, 0);
+ if (!file)
+ continue;
+ yyjson_mut_val *row = yyjson_mut_obj(doc);
+ yyjson_mut_obj_add_strcpy(doc, row, "file", file);
+ yyjson_mut_obj_add_int(doc, row, "count", sqlite3_column_int64(st, 1));
+ yyjson_mut_arr_append(tail, row);
+ }
+ sqlite3_finalize(st);
+ yyjson_mut_obj_add_val(doc, section, "overflow_by_file", tail);
+ }
+ }
yyjson_mut_obj_add_val(doc, root, inbound ? "callers" : "callees", section);
}
@@ -451,8 +493,24 @@ char *cbm_atlas_symbol_json(cbm_store_t *store, const char *project, int64_t nod
free(region_name);
}
- aa_add_connections(doc, root, db, project, id, true, limit, offset);
- aa_add_connections(doc, root, db, project, id, false, limit, offset);
+ aa_add_connections(doc, root, db, store, project, id, true, limit, offset);
+ aa_add_connections(doc, root, db, store, project, id, false, limit, offset);
+
+ /* A panel that can only ever say "none" should not render: tell the
+ * client whether this project has DATA_FLOWS edges at all. */
+ {
+ sqlite3_stmt *pst = NULL;
+ bool any = false;
+ if (sqlite3_prepare_v2(db,
+ "SELECT 1 FROM edges WHERE project=?1 AND type='DATA_FLOWS' "
+ "LIMIT 1",
+ -1, &pst, NULL) == SQLITE_OK) {
+ sqlite3_bind_text(pst, 1, project, -1, SQLITE_STATIC);
+ any = sqlite3_step(pst) == SQLITE_ROW;
+ sqlite3_finalize(pst);
+ }
+ yyjson_mut_obj_add_bool(doc, root, "project_has_data_flows", any);
+ }
/* Tests exercising this symbol (inbound TESTS edges). */
if (sqlite3_prepare_v2(db,
@@ -678,3 +736,150 @@ char *cbm_atlas_scent_json(cbm_store_t *store, const char *project, const char *
yyjson_mut_doc_free(doc);
return json;
}
+
+/* ── Bridges: the nodes that stitch regions together ──────────────
+ * Ranked by DISTINCT foreign regions a node CALLS INTO (cross-call count as
+ * tiebreak) — orchestrators, the seam metric. Inbound direction is
+ * deliberately ignored (a logger called from everywhere is a utility hub,
+ * already listed under hubs) and test files are excluded (a test harness
+ * calls everything). */
+
+enum { BR_MAX_TRACK = 8, BR_TOP = 5, BR_EDGE_CAP = 2000000 };
+
+typedef struct {
+ int64_t id;
+ char key[24]; /* the ht borrows key pointers — the node owns its key */
+ int regions[BR_MAX_TRACK]; /* distinct foreign regions (first 8) */
+ int region_count;
+ long long cross_calls;
+} br_node_t;
+
+static void br_touch(br_node_t *node, int foreign_region) {
+ node->cross_calls++;
+ for (int i = 0; i < node->region_count; i++)
+ if (node->regions[i] == foreign_region)
+ return;
+ if (node->region_count < BR_MAX_TRACK)
+ node->regions[node->region_count++] = foreign_region;
+}
+
+char *cbm_atlas_bridges_json(cbm_store_t *store, const char *project) {
+ if (!store || !project)
+ return NULL;
+ struct sqlite3 *db = cbm_store_get_db(store);
+ if (!db)
+ return NULL;
+
+ CBMHashTable *ht = cbm_ht_create(4096); /* id (as %lld string) → br_node_t* */
+ if (!ht)
+ return NULL;
+ br_node_t **all = NULL;
+ int all_count = 0, all_cap = 0;
+
+ sqlite3_stmt *st = NULL;
+ long long scanned = 0;
+ if (sqlite3_prepare_v2(db,
+ "SELECT e.source_id, ns.file_path, e.target_id, nt.file_path FROM "
+ "edges e JOIN nodes ns ON ns.project=e.project AND ns.id=e.source_id "
+ "JOIN nodes nt ON nt.project=e.project AND nt.id=e.target_id WHERE "
+ "e.project=?1 AND e.type='CALLS'",
+ -1, &st, NULL) == SQLITE_OK) {
+ sqlite3_bind_text(st, 1, project, -1, SQLITE_STATIC);
+ while (sqlite3_step(st) == SQLITE_ROW && scanned < BR_EDGE_CAP) {
+ scanned++;
+ const char *sf = (const char *)sqlite3_column_text(st, 1);
+ const char *tf = (const char *)sqlite3_column_text(st, 3);
+ if (!sf || !tf)
+ continue;
+ if (cbm_is_test_file_path(sf))
+ continue;
+ int sr = cbm_layout_region_for_file(store, project, sf, NULL);
+ int tr = cbm_layout_region_for_file(store, project, tf, NULL);
+ if (sr < 0 || tr < 0 || sr == tr)
+ continue;
+ int64_t ids[1] = {sqlite3_column_int64(st, 0)};
+ int foreign[1] = {tr};
+ for (int k = 0; k < 1; k++) {
+ char key[24];
+ snprintf(key, sizeof(key), "%lld", (long long)ids[k]);
+ br_node_t *node = cbm_ht_get(ht, key);
+ if (!node) {
+ if (all_count >= all_cap) {
+ int nc = all_cap ? all_cap * 2 : 256;
+ br_node_t **grown = realloc(all, (size_t)nc * sizeof(br_node_t *));
+ if (!grown)
+ continue;
+ all = grown;
+ all_cap = nc;
+ }
+ node = calloc(1, sizeof(br_node_t));
+ if (!node)
+ continue;
+ node->id = ids[k];
+ snprintf(node->key, sizeof(node->key), "%s", key);
+ cbm_ht_set(ht, node->key, node);
+ all[all_count++] = node;
+ }
+ br_touch(node, foreign[k]);
+ }
+ }
+ sqlite3_finalize(st);
+ }
+
+ /* Top BR_TOP by (region_count, cross_calls) — selection sort is fine. */
+ yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL);
+ yyjson_mut_val *root = yyjson_mut_obj(doc);
+ yyjson_mut_doc_set_root(doc, root);
+ yyjson_mut_obj_add_int(doc, root, "cross_edges_scanned", scanned);
+ yyjson_mut_val *arr = yyjson_mut_arr(doc);
+ for (int pick = 0; pick < BR_TOP; pick++) {
+ int best = -1;
+ for (int i = 0; i < all_count; i++) {
+ if (!all[i])
+ continue;
+ if (best < 0 || all[i]->region_count > all[best]->region_count ||
+ (all[i]->region_count == all[best]->region_count &&
+ all[i]->cross_calls > all[best]->cross_calls))
+ best = i;
+ }
+ if (best < 0 || all[best]->region_count < 2)
+ break;
+ br_node_t *node = all[best];
+ all[best] = NULL;
+ sqlite3_stmt *nst = NULL;
+ if (sqlite3_prepare_v2(db,
+ "SELECT name, file_path, qualified_name FROM nodes WHERE "
+ "project=?1 AND id=?2 AND label NOT IN ('File','Folder') LIMIT 1",
+ -1, &nst, NULL) == SQLITE_OK) {
+ sqlite3_bind_text(nst, 1, project, -1, SQLITE_STATIC);
+ sqlite3_bind_int64(nst, 2, node->id);
+ if (sqlite3_step(nst) == SQLITE_ROW) {
+ yyjson_mut_val *row = yyjson_mut_obj(doc);
+ yyjson_mut_obj_add_int(doc, row, "id", node->id);
+ yyjson_mut_obj_add_strcpy(doc, row, "name",
+ (const char *)sqlite3_column_text(nst, 0));
+ const char *file = (const char *)sqlite3_column_text(nst, 1);
+ if (file)
+ yyjson_mut_obj_add_strcpy(doc, row, "file_path", file);
+ const char *qn = (const char *)sqlite3_column_text(nst, 2);
+ if (qn)
+ yyjson_mut_obj_add_strcpy(doc, row, "qualified_name", qn);
+ yyjson_mut_obj_add_int(doc, row, "regions", node->region_count);
+ yyjson_mut_obj_add_int(doc, row, "cross_calls", node->cross_calls);
+ yyjson_mut_arr_append(arr, row);
+ } else {
+ pick--; /* a File node slipped in — skip without burning a slot */
+ }
+ sqlite3_finalize(nst);
+ }
+ free(node);
+ }
+ yyjson_mut_obj_add_val(doc, root, "bridges", arr);
+ for (int i = 0; i < all_count; i++)
+ free(all[i]);
+ free(all);
+ cbm_ht_free(ht);
+ char *json = yyjson_mut_write(doc, 0, NULL);
+ yyjson_mut_doc_free(doc);
+ return json;
+}
diff --git a/src/ui/http_server.c b/src/ui/http_server.c
index 16ed7c7de..6c88bb6b8 100644
--- a/src/ui/http_server.c
+++ b/src/ui/http_server.c
@@ -1848,6 +1848,17 @@ static void handle_atlas_trace(cbm_http_conn_t *c, const cbm_http_req_t *req) {
atlas_reply_json(c, json, 500, "{\"error\":\"trace failed\"}");
}
+/* GET /api/bridges?project=X — boundary spanners by distinct-region reach. */
+static void handle_atlas_bridges(cbm_http_conn_t *c, const cbm_http_req_t *req) {
+ char project[256] = {0};
+ cbm_store_t *store = atlas_open_project(c, req, project, sizeof(project));
+ if (!store)
+ return;
+ char *json = cbm_atlas_bridges_json(store, project);
+ cbm_store_close(store);
+ atlas_reply_json(c, json, 500, "{\"error\":\"bridges failed\"}");
+}
+
/* GET /api/scent?project=X&q=pattern — per-region search hit counts. */
static void handle_atlas_scent(cbm_http_conn_t *c, const cbm_http_req_t *req) {
char project[256] = {0};
@@ -2185,6 +2196,12 @@ static void dispatch_request(cbm_http_server_t *srv, cbm_http_conn_t *c,
return;
}
+ /* GET /api/bridges → CBM Atlas boundary spanners */
+ if (is_get && cbm_http_path_match(req->path, "/api/bridges*")) {
+ handle_atlas_bridges(c, req);
+ return;
+ }
+
/* GET /api/scent → CBM Atlas per-region search counts */
if (is_get && cbm_http_path_match(req->path, "/api/scent*")) {
handle_atlas_scent(c, req);
diff --git a/tests/test_httpd.c b/tests/test_httpd.c
index d66799004..3a2185e1c 100644
--- a/tests/test_httpd.c
+++ b/tests/test_httpd.c
@@ -1191,8 +1191,9 @@ TEST(ui_server_atlas_routes_are_wired) {
* falls through to the static handler's 404. This pins the /api/flow
* (singular) route, which once used a "?*" pattern that never matched
* because req->path carries no query string. */
- static const char *const routes[] = {"/api/tree", "/api/symbol", "/api/flows", "/api/flow",
- "/api/metrics", "/api/trace", "/api/scent"};
+ static const char *const routes[] = {"/api/tree", "/api/symbol", "/api/flows",
+ "/api/flow", "/api/metrics", "/api/trace",
+ "/api/scent", "/api/bridges"};
char req[256];
char resp[4096];
for (size_t i = 0; i < sizeof(routes) / sizeof(routes[0]); i++) {
diff --git a/tests/test_ui.c b/tests/test_ui.c
index 0013bb35b..4726ad82e 100644
--- a/tests/test_ui.c
+++ b/tests/test_ui.c
@@ -1497,6 +1497,162 @@ TEST(atlas_scent_buckets_matches_by_region) {
PASS();
}
+TEST(atlas_bridges_rank_by_region_reach) {
+ cbm_layout_regions_cache_clear();
+ cbm_store_t *store = atlas_fixture(NULL);
+ ASSERT_NOT_NULL(store);
+
+ /* The fixture's one cross-region CALLS edge is alpha_one → beta_one, so
+ * both endpoints are boundary spanners touching exactly one foreign
+ * region; nothing else qualifies (test_alpha_one has a TESTS edge, not
+ * CALLS). */
+ char *json = cbm_atlas_bridges_json(store, "regions-test");
+ ASSERT_NOT_NULL(json);
+ yyjson_doc *doc = yyjson_read(json, strlen(json), 0);
+ ASSERT_NOT_NULL(doc);
+ yyjson_val *root = yyjson_doc_get_root(doc);
+ yyjson_val *bridges = yyjson_obj_get(root, "bridges");
+ ASSERT_NOT_NULL(bridges);
+ /* regions < 2 rows are dropped: with one cross pair each node touches
+ * exactly 1 foreign region, so the honest answer is an empty list. */
+ ASSERT_EQ((int)yyjson_arr_size(bridges), 0);
+ yyjson_doc_free(doc);
+ free(json);
+
+ /* A third dense community (mirroring the beta pattern: a 3-cycle plus
+ * exactly one inbound cross call) so alpha_one spans TWO foreign
+ * regions. A single linked node would be absorbed into alpha's own
+ * Leiden community and prove nothing. */
+ int64_t gamma_ids[3] = {0, 0, 0};
+ for (int i = 0; i < 3; i++) {
+ cbm_node_t node;
+ memset(&node, 0, sizeof(node));
+ node.project = "regions-test";
+ node.label = "Function";
+ char name[32], qn[64], fp[32];
+ snprintf(name, sizeof(name), "gamma_%d", i + 1);
+ snprintf(qn, sizeof(qn), "regions-test::gamma_%d", i + 1);
+ snprintf(fp, sizeof(fp), "src/gamma/g%d.c", i + 1);
+ node.name = name;
+ node.qualified_name = qn;
+ node.file_path = fp;
+ node.start_line = 1;
+ node.end_line = 3;
+ gamma_ids[i] = cbm_store_upsert_node(store, &node);
+ ASSERT_GT(gamma_ids[i], 0);
+ }
+ for (int i = 0; i < 3; i++) {
+ cbm_edge_t gedge;
+ memset(&gedge, 0, sizeof(gedge));
+ gedge.project = "regions-test";
+ gedge.source_id = gamma_ids[i];
+ gedge.target_id = gamma_ids[(i + 1) % 3];
+ gedge.type = "CALLS";
+ ASSERT_GT(cbm_store_insert_edge(store, &gedge), 0);
+ }
+ int64_t gamma_id = gamma_ids[0];
+
+ int64_t alpha_id = -1;
+ {
+ cbm_search_params_t params;
+ memset(&params, 0, sizeof(params));
+ params.project = "regions-test";
+ params.qn_pattern = "regions-test::alpha_one";
+ params.limit = 1;
+ params.min_degree = -1;
+ params.max_degree = -1;
+ cbm_search_output_t out;
+ memset(&out, 0, sizeof(out));
+ ASSERT_EQ(cbm_store_search(store, &params, &out), CBM_STORE_OK);
+ ASSERT_EQ(out.count, 1);
+ alpha_id = out.results[0].node.id;
+ cbm_store_search_free(&out);
+ }
+ cbm_edge_t edge;
+ memset(&edge, 0, sizeof(edge));
+ edge.project = "regions-test";
+ edge.source_id = alpha_id;
+ edge.target_id = gamma_id;
+ edge.type = "CALLS";
+ ASSERT_GT(cbm_store_insert_edge(store, &edge), 0);
+ cbm_layout_regions_cache_clear(); /* region map must include src/gamma */
+
+ json = cbm_atlas_bridges_json(store, "regions-test");
+ ASSERT_NOT_NULL(json);
+ doc = yyjson_read(json, strlen(json), 0);
+ root = yyjson_doc_get_root(doc);
+ bridges = yyjson_obj_get(root, "bridges");
+ ASSERT_GT((int)yyjson_arr_size(bridges), 0);
+ yyjson_val *top = yyjson_arr_get(bridges, 0);
+ ASSERT_STR_EQ(yyjson_get_str(yyjson_obj_get(top, "name")), "alpha_one");
+ ASSERT_EQ((int)yyjson_get_int(yyjson_obj_get(top, "regions")), 2);
+ yyjson_doc_free(doc);
+ free(json);
+
+ cbm_store_close(store);
+ cbm_layout_regions_cache_clear();
+ PASS();
+}
+
+TEST(atlas_symbol_overflow_tail_and_dataflow_presence) {
+ cbm_layout_regions_cache_clear();
+ cbm_atlas_metrics_cache_clear();
+ int64_t alpha_one = -1;
+ cbm_store_t *store = atlas_fixture(&alpha_one);
+ ASSERT_NOT_NULL(store);
+
+ /* limit=1 on beta_one's callers (alpha_one crosses in, beta_three
+ * closes the cycle) forces an overflow tail grouped by file. */
+ int64_t beta_one = -1;
+ {
+ cbm_search_params_t params;
+ memset(&params, 0, sizeof(params));
+ params.project = "regions-test";
+ params.qn_pattern = "regions-test::beta_one";
+ params.limit = 1;
+ params.min_degree = -1;
+ params.max_degree = -1;
+ cbm_search_output_t out;
+ memset(&out, 0, sizeof(out));
+ ASSERT_EQ(cbm_store_search(store, &params, &out), CBM_STORE_OK);
+ ASSERT_EQ(out.count, 1);
+ beta_one = out.results[0].node.id;
+ cbm_store_search_free(&out);
+ }
+ char *json = cbm_atlas_symbol_json(store, "regions-test", beta_one, NULL, 1, 0);
+ ASSERT_NOT_NULL(json);
+ yyjson_doc *doc = yyjson_read(json, strlen(json), 0);
+ ASSERT_NOT_NULL(doc);
+ yyjson_val *root = yyjson_doc_get_root(doc);
+ yyjson_val *callers = yyjson_obj_get(root, "callers");
+ long long total = yyjson_get_int(yyjson_obj_get(callers, "total"));
+ ASSERT_GT((int)total, 1);
+ ASSERT_EQ((int)yyjson_arr_size(yyjson_obj_get(callers, "items")), 1);
+ yyjson_val *tail = yyjson_obj_get(callers, "overflow_by_file");
+ ASSERT_NOT_NULL(tail);
+ long long tail_total = 0;
+ for (size_t i = 0; i < yyjson_arr_size(tail); i++) {
+ yyjson_val *row = yyjson_arr_get(tail, i);
+ ASSERT_NOT_NULL(yyjson_get_str(yyjson_obj_get(row, "file")));
+ tail_total += yyjson_get_int(yyjson_obj_get(row, "count"));
+ }
+ /* The tail accounts for exactly what the page cut. */
+ ASSERT_EQ((int)tail_total, (int)(total - 1));
+
+ /* Connection rows carry the neighbor's region; the fixture has
+ * DATA_FLOWS so the presence flag is true. */
+ yyjson_val *first = yyjson_arr_get(yyjson_obj_get(callers, "items"), 0);
+ ASSERT_NOT_NULL(yyjson_obj_get(first, "region"));
+ ASSERT_TRUE(yyjson_get_bool(yyjson_obj_get(root, "project_has_data_flows")));
+
+ yyjson_doc_free(doc);
+ free(json);
+ cbm_store_close(store);
+ cbm_atlas_metrics_cache_clear();
+ cbm_layout_regions_cache_clear();
+ PASS();
+}
+
/* ── Suite ────────────────────────────────────────────────────── */
SUITE(ui) {
@@ -1537,4 +1693,6 @@ SUITE(ui) {
RUN_TEST(atlas_trace_reachability_calls_and_data);
RUN_TEST(atlas_symbol_data_flows_and_history_shape);
RUN_TEST(atlas_scent_buckets_matches_by_region);
+ RUN_TEST(atlas_bridges_rank_by_region_reach);
+ RUN_TEST(atlas_symbol_overflow_tail_and_dataflow_presence);
}