codebase-memory-mcp icon indicating copy to clipboard operation
codebase-memory-mcp copied to clipboard

`CALLS` edges are created across separate service roots in a monorepo

Open avigdorsky opened this issue 2 months ago • 3 comments

Severity: high — poisons impact analysis and "who calls X".

In a monorepo where each top-level directory is a separate process (apps/service_a = Django, apps/service_b = an independent FastAPI app), the indexer emits ~5 700 CALLS edges between them. In-process calls between separate processes cannot exist.

A random sample of 50 such edges was 100% false at every confidence level, including the top band:

confidence strategy callee in source resolved to
0.95 import_map RedisIntegration — from sentry_sdk.integrations.redis import RedisIntegration a class attribute named redis in the other service
0.95 import_map Config — from botocore.config import Config a pydantic Config inner class in the other service
0.90 qualified_suffix registry.get, where registry.py exists in the caller's own package registry.get in the other service
0.85 field_type_hint resp.json() on an httpx response _FakeResponse.json in the other service's tests

Minimal repro: two packages under one repo root, each with a module of the same name; import the stdlib/third-party symbol in one and observe the edge landing in the other.

Ask: allow a configurable list of resolution boundaries (service roots) that calls may not cross unless the target module is genuinely imported. Absent config, at minimum do not let import_map bind a name to a target when the caller's own import of that name resolves elsewhere (stdlib or third-party).


Observed on v0.10.8 (build 996bad5fe6fb), macOS arm64, Python monorepo (~36k nodes / ~179k edges). Happy to provide a minimal reproduction repo if useful.

avigdorsky avatar Sep 09 '26 07:09 avigdorsky

Thank you for the detailed examples across #2125, #2126, #2127, #2128, #2129, #2130, #2131, #2132, #2133 and #2134. They expose several distinct contracts, so I have kept them separate rather than closing them as duplicates.

On current main, the registry resolution path still includes import-map, same-module and name-based candidate resolution (src/pipeline/registry.c). That is the relevant area to investigate for the cross-service and symbol-misattribution reports, but reading that chain alone does not establish the root cause of every example or validate the reported precision figures.

The incorrect-edge, false-dead-status, wildcard and project-identity reports are labeled as high-priority bugs. The proposed layout ranking, additional confidence fields/filtering and generated-contract representation are tracked as enhancements whose API/default decisions still need review. Those priorities describe scheduling urgency, not the value of the reports.

Code checked: https://github.com/DeusData/codebase-memory-mcp/blob/5b6a30dee6e9ddfd1ed304614b4b32fec7f3e05e/src/pipeline/registry.c#L1010

No need to refile these or send private repository contents. Thank you for doing the investigation and making the failure modes concrete.

DeusData avatar Sep 09 '26 21:09 DeusData

Thank you for sampling the edges by confidence band. Seeing 100% false even at 0.95 is what made the import-map path the first target!

The clearest part of your "at minimum" ask is in review in PR #2345. For Python, a name imported from a module outside the project (e.g. from sentry_sdk.integrations.redis import RedisIntegration or from botocore.config import Config) can no longer be bound to a same-named symbol inside the project. The same applies on the call side, through weaker name-only matches. That covers your first two examples.

The registry.get case (preferring the caller's own package) and the httpx resp.json() case take different resolution paths, so they stay open here. The configurable service-boundary list is a separate design question, tracked as an enhancement. We'll update this issue when #2345 lands.

DeusData avatar Sep 26 '26 03:09 DeusData

Thank you again for the concrete cross-service examples. The earlier update separates #2345's external-import work from package preference, typed receivers, and configurable boundaries. I have no new verified landing or release status for those remaining cases.

DeusData avatar Oct 19 '26 22:10 DeusData