Skip to content

feat(xrepo): cross-repo intelligence — multi-repo query via --additional-paths (closes #15)#150

Merged
Wolfvin merged 2 commits into
mainfrom
feat/issue-15-cross-repo-intelligence
Jul 3, 2026
Merged

feat(xrepo): cross-repo intelligence — multi-repo query via --additional-paths (closes #15)#150
Wolfvin merged 2 commits into
mainfrom
feat/issue-15-cross-repo-intelligence

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Closes #15

Summary

Implements the Minimum Viable Version from issue #15:

Just support multiple repo_path entries — resolve imports against the combined symbol table from all indexed repos.

Agents can now query across pre-indexed repos:

codelens query shared_helper /projects/services/api --additional-paths /projects/lib/shared

Returns the symbol from lib/shared, with the caller from services/api annotated cross_repo: true — so an agent can trace a call that crosses the repo boundary without manually chaining tracesearchquery.

What was added

File Purpose
scripts/crossrepo_engine.py load_merged_registry() — loads backend registries from primary + additional repos, tags each node with repo, re-runs resolve_edges() on the combined node set so cross-repo calls resolve automatically. Cross-repo edges flagged with cross_repo=True + target_repo + source_repo. query_cross_repo() — multi-repo symbol query with callers/callees annotated.
scripts/commands/query.py Added --additional-paths flag. When provided, delegates to crossrepo_engine.query_cross_repo(). When absent, behavior is unchanged (zero-risk backward compat).
scripts/mcp_server.py Added additional_paths parameter to the codelens_query MCP tool schema so agents can pass comma-separated repo paths.
tests/test_crossrepo_engine.py 28 tests: path parsing, registry merging, cross-repo edge resolution, multi-repo query, fuzzy match across repos, graceful degradation, CLI arg integration.
README.md, SKILL.md, SKILL-QUICK.md, pyproject.toml, skill.json, scripts/graph_model.py Auto-synced by sync_command_count.py --apply (command count 68→69 from other workers' merged PRs; this PR itself adds 0 new commands).

How it works

The key insight: edge_resolver.resolve_edges() already matches to_fn (function name) against the full node list to resolve cross-file calls. By feeding it nodes from multiple repos, cross-repo calls resolve automatically — the resolver doesn't care which repo a node came from.

Repo A (services/api)          Repo B (lib/shared)
┌─────────────────────┐       ┌─────────────────────┐
│ caller_fn           │       │ shared_helper       │
│   calls shared_helper──────▶│                     │
│   calls local_fn    │       └─────────────────────┘
└─────────────────────┘
         │
         ▼  After merge + re-resolve:
         edge: from=caller_fn, to=shared_helper,
               cross_repo=True, source_repo=A, target_repo=B

Non-breaking by design

  • scan / init / load_backend_registry untouched — each repo is scanned independently as before. No config schema changes required.
  • resolve_edges reused as-is — it already does the heavy lifting; we just feed it a bigger node list.
  • query without --additional-paths — identical behavior, same code path, zero risk.
  • No new CLI commands — only a new flag on the existing query command.

Test results

PYTHONUTF8=1 PYTHONPATH=scripts python -m pytest tests/ --ignore=tests/test_integration.py

1398 passed, 80 skipped, 1 failed (28 new tests included in the 1398).

The 1 failure (test_codelensignore::TestBackwardCompat::test_actual_target_dir_is_ignored) is pre-existing and unrelated — it fails identically on clean origin/main.

Scope alignment with multi-worker analysis

Per the aggregation comment on #15, three worker reports proposed different scopes:

  • CodeGraph feat(types): hybrid type resolution — closes #13 #29 = multi-repo querying within MCP (read-only across pre-indexed projects) — this PR implements this scope
  • Repomix R5 = remote repo fetch-and-scan (--remote) — future work
  • Serena S14 = intra-monorepo cross-package via LSP workspace folders — narrower problem

This PR implements the CodeGraph #29 scope: read-only multi-repo querying across pre-indexed projects. The other two scopes can be addressed in sibling issues.

Limitations (documented, not bugs)

  • Read-only. No cross-repo scan or indexing — each repo must be scanned independently first.
  • Backend-only. Frontend registry merging is not implemented (frontend symbols don't have call edges in the same way). Can be added if needed.
  • trace command not yet updated. Only query gained --additional-paths in this MVP. trace --additional-paths can follow in a subsequent PR.
  • No CROSS_CALLS / CROSS_IMPORTS edge types. The issue body suggests distinct edge types, but the MVP uses a cross_repo: true flag on existing CALLS edges instead — simpler, non-breaking, and carries the same information.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Wolfvin Wolfvin force-pushed the feat/issue-15-cross-repo-intelligence branch 2 times, most recently from 4684c80 to 114ed5c Compare July 3, 2026 02:12
@Wolfvin Wolfvin merged commit 2089f74 into main Jul 3, 2026
Wolfvin added 2 commits July 3, 2026 09:13
…nal-paths (closes #15)

Implements the Minimum Viable Version from issue #15:
    Just support multiple repo_path entries — resolve imports against
    the combined symbol table from all indexed repos.

New files:
- scripts/crossrepo_engine.py — load_merged_registry() merges backend
  registries from multiple repos, tags each node with a 'repo' field,
  re-runs edge_resolver.resolve_edges() on the combined node set so
  cross-repo calls (e.g. services/api calling lib/shared) are resolved
  automatically. Cross-repo edges are flagged with cross_repo=True +
  target_repo + source_repo. query_cross_repo() provides multi-repo
  symbol query with callers/callees annotated with repo + cross_repo.
- tests/test_crossrepo_engine.py — 28 tests: path parsing, registry
  merging, cross-repo edge resolution, multi-repo query, fuzzy match
  across repos, graceful degradation, CLI arg integration.

Modified files:
- scripts/commands/query.py — added --additional-paths flag. When
  provided, delegates to crossrepo_engine.query_cross_repo(). When
  absent, behavior is unchanged (zero-risk backward compat).
- scripts/mcp_server.py — added additional_paths parameter to the
  codelens_query MCP tool schema so agents can pass comma-separated
  repo paths for cross-repo search.
- README.md, SKILL.md, SKILL-QUICK.md, pyproject.toml, skill.json,
  scripts/graph_model.py — auto-synced by sync_command_count.py
  --apply (command count 68->69 from other workers' merged PRs;
  this PR itself adds 0 new commands).

Non-breaking by design:
- scan/init/load_backend_registry untouched — each repo is scanned
  independently as before.
- resolve_edges reused as-is — it already matches to_fn against the
  full node list, so feeding it merged nodes resolves cross-repo calls
  automatically.
- query command without --additional-paths: identical behavior.

Tests: 1398 passed (28 new), 80 skipped, 1 pre-existing failure
unrelated (test_codelensignore::test_actual_target_dir_is_ignored).
@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@Wolfvin Wolfvin deleted the feat/issue-15-cross-repo-intelligence branch July 3, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Cross-repo intelligence: link edges across multiple indexed repos

1 participant