Skip to content

Commit 3b37d9e

Browse files
authored
Merge branch 'main' into fix/issue-2265-unresolved-call-coverage
2 parents ed52f62 + 10ab613 commit 3b37d9e

15 files changed

Lines changed: 1150 additions & 19 deletions

‎graph-ui/package-lock.json‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎graph-ui/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"playwright": "1.62.1",
6363
"three-stdlib": "2.36.1",
6464
"typescript": "5.9.3",
65-
"vite": "6.4.3",
65+
"vite": "6.4.4",
6666
"vitest": "4.1.11"
6767
},
6868
"overrides": {

‎graph-ui/src/galaxy/GalaxyPanel.reader-focus.test.tsx‎

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createRoot, type Root } from 'react-dom/client';
44
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
55
import GalaxyPanel, { type GalaxyPanelProps } from './GalaxyPanel';
66
import type { GraphData, GraphNode } from './types';
7+
import type { OrganicLayoutRequest, OrganicLayoutResponse } from './organic-layout.worker';
78

89
/** The layout can be capped; focused relationships come independently from RPC. */
910
function graphFetch(nodes: GraphNode[], edges: GraphData['edges'], total = nodes.length) {
@@ -102,10 +103,24 @@ it('opens a file hierarchy without a caret symbol and follows literal marked ran
102103
expect(fetchLayout.mock.calls.filter(([url]) => String(url).includes('/api/layout'))).toHaveLength(1);
103104
});
104105

105-
it('does not report a file missing from a capped layout while its indexed scope is loading', async () => {
106+
it.each([true, false])('does not report a file missing while its scope or layout is loading (indexed: %s)', async indexed => {
107+
let worker!: LayoutWorker;
108+
class LayoutWorker {
109+
onmessage: ((event: MessageEvent<OrganicLayoutResponse>) => void) | null = null;
110+
requests: OrganicLayoutRequest[] = [];
111+
constructor() { worker = this; }
112+
postMessage(request: OrganicLayoutRequest) { this.requests.push(request); }
113+
terminate() {}
114+
reply() {
115+
const { sequence, data } = this.requests.at(-1)!;
116+
this.onmessage?.(new MessageEvent<OrganicLayoutResponse>('message', { data: { sequence,
117+
result: { data, groups: [], groupByNode: new Map() } } }));
118+
}
119+
}
120+
vi.stubGlobal('Worker', LayoutWorker);
106121
const node: GraphNode = { id: 15, name: 'outside', qualified_name: 'sample.outside', label: 'Function',
107122
file_path: 'src/a.ts', start_line: 1, end_line: 10, x: 0, y: 0, z: 0, size: 1, color: '#999999' };
108-
const source = graphFetch([node], []);
123+
const source = graphFetch(indexed ? [node] : [], []);
109124
let release!: () => void;
110125
const pending = new Promise<void>(resolve => { release = resolve; });
111126
const fetchImpl = vi.fn(async (url: RequestInfo | URL, init?: RequestInit) => {
@@ -114,15 +129,27 @@ it('does not report a file missing from a capped layout while its indexed scope
114129
return source(url, init);
115130
});
116131
await act(async () => root.render(<GalaxyPanel project="sample" visible focusFilePath="src/a.ts" onOpenNode={vi.fn()} fetch={fetchImpl} />));
117-
// Hand test K8: the status names the layer that is loading instead of an endless "Loading relationships".
118-
// It may first say "Checking index…" while the index generation is read; wait for the load itself.
119-
await vi.waitFor(() => expect(host.textContent).toContain('Loading layer 1…'));
132+
expect(host.textContent).toContain('Loading layer 1…');
133+
// Finish the empty capped-layout preview while the indexed scope is held.
134+
// This leaves a missing-file note in state, hidden until the scope finishes.
135+
expect(worker.requests).toHaveLength(1);
136+
expect(worker.requests[0]!.data.nodes).toEqual([]);
137+
await act(async () => worker.reply());
120138
expect(host.querySelector('[data-testid="atlas-galaxy-note"]')).toBeNull();
121139
await act(async () => { release(); });
122140
expect(host.textContent).toContain('All indexed direct dependencies included.');
141+
// The scope is complete, but its new picture has not been arranged yet.
142+
expect(worker.requests).toHaveLength(2);
143+
expect(host.querySelector('[role="status"][data-state="arranging"]')).not.toBeNull();
144+
expect(host.querySelector('[data-testid="atlas-galaxy-note"]')).toBeNull();
123145
expect(host.textContent).not.toContain('not in the loaded graph');
146+
await act(async () => worker.reply());
147+
expect(host.querySelector('[role="status"][data-state="complete"]')).not.toBeNull();
148+
expect(JSON.parse(host.querySelector('[data-testid="graph-selection"]')!.textContent!)).toEqual(indexed ? [15] : []);
149+
if (indexed) expect(host.querySelector('[data-testid="atlas-galaxy-note"]')).toBeNull();
150+
else expect(host.querySelector('[data-testid="atlas-galaxy-note"]')?.textContent).toBe('src/a.ts is not in the loaded graph layout.');
124151
});
125-
afterEach(async () => { await act(async () => root.unmount()); host.remove(); globalThis.__atlasGalaxy = undefined; });
152+
afterEach(async () => { await act(async () => root.unmount()); host.remove(); globalThis.__atlasGalaxy = undefined; vi.unstubAllGlobals(); });
126153

127154
it('selects the whole file, narrows only to marked code, and restores the file when the mark clears', async () => {
128155
const common = { file_path: 'src/a.ts', x: 0, y: 0, z: 0, size: 1, color: '#999999' };

‎graph-ui/src/galaxy/GalaxyPanel.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {
30553055
<summary>Selection details</summary>
30563056
<div className="atlas-galaxy-selection-details-body">{selectionContent}</div>
30573057
</details>}
3058-
{note.length > 0 && !scope.loading && (
3058+
{note.length > 0 && !scope.loading && !organicTask.loading && (
30593059
<p className="atlas-galaxy-note" data-testid="atlas-galaxy-note">
30603060
{props.workspaceExpanded && note === GALAXY_NO_FOCUS_NOTE
30613061
? 'Select a node or entry point to attach graph context to chat.' : note}

‎pkg/pypi/requirements-publish.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
build==1.3.0 \
1616
--hash=sha256:698edd0ea270bde950f53aed21f3a0135672206f3911e0176261a31e0e07b397 \
1717
--hash=sha256:7145f0b5061ba90a1500d60bd1b13ca0a8a4cebdd0cc16ed8adf1c0e739f43b4
18-
certifi==2026.7.22 \
19-
--hash=sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775 \
20-
--hash=sha256:741e2c3b351ddf169a738da9f2c048608ff7f2c5cc02f1ebc6b118bb090d5d55
18+
certifi==2026.10.19 \
19+
--hash=sha256:035c1e85572b141bf1c3a3eff0e33a8eb74917522f2559075ff8d2fea780a1ae \
20+
--hash=sha256:42d35340cc5b9ba78e818ddbff0c5b1c2b779de448a340fd1b989f5fa8670e1b
2121
cffi==2.1.1 \
2222
--hash=sha256:046bfc24911b37851ee1b51aab8bffe713d89c68c6a057b09484ce9fd5f69b4e \
2323
--hash=sha256:06c72bb76605a4b0cd0aad6930b69d4baf7dd5d806cfc409b824191099700e66 \

‎src/pipeline/pass_calls.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,15 @@ static int resolve_single_call(cbm_pipeline_ctx_t *ctx, CBMCall *call, const CBM
12621262
/* The member guard's one exemption (Python, self/cls-rooted receiver,
12631263
* unique_name, not a builtin type's method) — see
12641264
* cbm_weak_member_unique_name_exempt. MUST match pass_parallel.c exactly. */
1265+
/* #1355: `import { eq } from "drizzle-orm"` binds `eq` to a package that is
1266+
* not in the indexed tree, so a project-wide same-name guess must not turn
1267+
* `eq(...)` into a CALLS edge to an unrelated project `eq`. Joined to
1268+
* drop_plain_call for the reason spelled out above: dropping the call here
1269+
* would also skip route/HTTP/CONFIG classification, and a route
1270+
* registration reached through a static import (`import static
1271+
* spark.Spark.get` + `get("/x", handler)`) is exactly a bare call bound by
1272+
* a package specifier. Suppressing only the plain-CALLS fall-through keeps
1273+
* every Route node and service edge main-identical. */
12651274
bool drop_plain_call =
12661275
(cbm_suppress_weak_member_match(suppress_weak_member, call->is_method, res.strategy) &&
12671276
!cbm_weak_member_unique_name_exempt(lang == CBM_LANG_PYTHON,
@@ -1278,6 +1287,9 @@ static int resolve_single_call(cbm_pipeline_ctx_t *ctx, CBMCall *call, const CBM
12781287
(lang == CBM_LANG_PYTHON && cbm_suppress_weak_import_bound_call(true, true, res.strategy) &&
12791288
cbm_python_import_binding_contradicts(imports, call->callee_name, res.qualified_name,
12801289
ctx->gbuf, ctx->project_name, rel)) ||
1290+
cbm_suppress_external_import_shadow(call->callee_name, res.strategy, imports, imp_keys,
1291+
imp_count, cbm_pipeline_get_pkgmap(),
1292+
cbm_pipeline_get_nsmap()) ||
12811293
/* MUST match pass_parallel.c exactly. */
12821294
(lang == CBM_LANG_PHP && cbm_suppress_weak_member_match(true, true, res.strategy) &&
12831295
cbm_pipeline_php_receiver_type_unindexed(lsp_calls, call, ctx->registry));

‎src/pipeline/pass_definitions.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,9 @@ int cbm_pipeline_pass_definitions(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t
11841184
cbm_pipeline_diagram_arrows(ctx, result);
11851185
cbm_pipeline_create_env_configures_for_file(ctx, result, files[i].rel_path);
11861186
}
1187-
cbm_pipeline_namespace_map_free(namespace_map);
1187+
/* Publish instead of free — see the twin in pass_parallel.c (#1355). */
1188+
cbm_pipeline_namespace_map_free(cbm_pipeline_get_nsmap());
1189+
cbm_pipeline_set_nsmap(namespace_map);
11881190
if (owns_local_cache) {
11891191
for (int i = 0; i < file_count; i++) {
11901192
if (local_cache[i]) {

‎src/pipeline/pass_parallel.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,11 @@ int cbm_build_registry_from_cache(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t
20412041
}
20422042
}
20432043

2044-
cbm_pipeline_namespace_map_free(namespace_map);
2044+
/* Publish instead of free: the call pass needs the same declared-package
2045+
* set to tell an in-tree package path from a third-party one (#1355).
2046+
* The pipeline owns it from here and frees it in its cleanup. */
2047+
cbm_pipeline_namespace_map_free(cbm_pipeline_get_nsmap());
2048+
cbm_pipeline_set_nsmap(namespace_map);
20452049

20462050
cbm_log_info("parallel.registry.done", "entries", itoa_log(reg_entries), "defines",
20472051
itoa_log(defines_edges), "imports", itoa_log(imports_edges));
@@ -3434,6 +3438,11 @@ static void resolve_file_calls(resolve_ctx_t *rc, resolve_worker_state_t *ws, CB
34343438
* This gate MUST stay identical to the one there. */
34353439
bool suppress_weak_local_binding = lang == CBM_LANG_PYTHON;
34363440
/* The member guard's one exemption — MUST match pass_calls.c exactly. */
3441+
/* #1355: same guard as pass_calls.c, and joined to drop_plain_call for
3442+
* the same reason — a `continue` here would also skip route/HTTP/CONFIG
3443+
* classification, and a static-import route registration is a bare call
3444+
* bound by a package specifier. Suppress only the plain-CALLS
3445+
* fall-through so every Route node stays main-identical. */
34373446
bool drop_plain_call =
34383447
(cbm_suppress_weak_member_match(suppress_weak_member, call->is_method, res.strategy) &&
34393448
!cbm_weak_member_unique_name_exempt(lang == CBM_LANG_PYTHON,
@@ -3450,6 +3459,9 @@ static void resolve_file_calls(resolve_ctx_t *rc, resolve_worker_state_t *ws, CB
34503459
cbm_python_import_binding_contradicts(&result->imports, call->callee_name,
34513460
res.qualified_name, rc->main_gbuf,
34523461
rc->project_name, rel)) ||
3462+
cbm_suppress_external_import_shadow(call->callee_name, res.strategy, &result->imports,
3463+
imp_keys, imp_count, cbm_pipeline_get_pkgmap(),
3464+
cbm_pipeline_get_nsmap()) ||
34533465
/* MUST match pass_calls.c exactly. */
34543466
(lang == CBM_LANG_PHP && cbm_suppress_weak_member_match(true, true, res.strategy) &&
34553467
cbm_pipeline_php_receiver_type_unindexed(&result->resolved_calls, call, rc->registry));

‎src/pipeline/pipeline.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,18 @@ void cbm_pipeline_set_pkgmap(CBMHashTable *map) {
808808
g_pkgmap = map;
809809
}
810810

811+
/* ── Global declared-package map (one active pipeline at a time) ── */
812+
813+
static CBMHashTable *g_nsmap = NULL;
814+
815+
CBMHashTable *cbm_pipeline_get_nsmap(void) {
816+
return g_nsmap;
817+
}
818+
819+
void cbm_pipeline_set_nsmap(CBMHashTable *map) {
820+
g_nsmap = map;
821+
}
822+
811823
bool cbm_pipeline_had_format_migration(const cbm_pipeline_t *p) {
812824
return p && p->format_migration;
813825
}
@@ -4517,6 +4529,8 @@ static int cbm_pipeline_run_staged(cbm_pipeline_t *p) {
45174529
cleanup:
45184530
cbm_pkgmap_free(cbm_pipeline_get_pkgmap());
45194531
cbm_pipeline_set_pkgmap(NULL);
4532+
cbm_pipeline_namespace_map_free(cbm_pipeline_get_nsmap());
4533+
cbm_pipeline_set_nsmap(NULL);
45204534
cbm_discover_free(files, file_count);
45214535
if (p->frozen) {
45224536
p->frozen->baseline = baseline_manifest;

‎src/pipeline/pipeline.h‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#include <stdint.h>
2020
#include <stdatomic.h>
2121

22-
#include "discover/discover.h" /* cbm_ignored_file_t (#963) */
23-
#include "foundation/constants.h" /* CBM_SZ_512 */
22+
#include "discover/discover.h" /* cbm_ignored_file_t (#963) */
23+
#include "foundation/constants.h" /* CBM_SZ_512 */
24+
#include "foundation/hash_table.h" /* CBMHashTable (#1355 pkgmap lookup) */
2425

2526
/* Forward declarations */
2627
typedef struct cbm_store cbm_store_t;
@@ -411,6 +412,25 @@ bool cbm_weak_member_unique_name_exempt(bool is_python, bool receiver_is_self_at
411412
* Pure; unit-tested in test_registry.c. */
412413
bool cbm_suppress_weak_local_binding_call(bool enabled, bool callee_is_locally_bound,
413414
const char *strategy);
415+
/* #1355: drop a project-wide same-name guess (suffix_match / unique_name /
416+
* field_type_hint / fuzzy) for a BARE call whose name the calling file binds to
417+
* a NON-RELATIVE (package) import that resolved to nothing in the graph —
418+
* `import { eq } from "drizzle-orm"` must not make `eq(...)` a CALLS edge to an
419+
* unrelated project `eq`. A name the import map does bind, a relative
420+
* specifier, a member/qualified callee, and every import-/receiver-aware
421+
* strategy are all kept. `indexed_packages` is the pipeline package map: a
422+
* specifier naming a package the tree itself declares (a workspace sibling)
423+
* counts as in-tree and is kept too; NULL disables that check.
424+
* `declared_packages` is the pipeline namespace map and does the same job for
425+
* package-path specifiers, which have no in-tree/external shape of their own:
426+
* `import org.example.util.assertThing` is kept when some indexed file
427+
* declares `package org.example.util`; NULL disables that check.
428+
* Pure; unit-tested in test_registry.c. */
429+
bool cbm_suppress_external_import_shadow(const char *callee_name, const char *strategy,
430+
const CBMImportArray *file_imports,
431+
const char **import_map_keys, int import_map_count,
432+
const CBMHashTable *indexed_packages,
433+
const CBMHashTable *declared_packages);
414434

415435
/* Go analog of the TS/JS guard, same failure class: a selector call whose
416436
* receiver the Go LSP could not type must not be bound by a receiver-blind

0 commit comments

Comments
 (0)