Skip to content

feat: expose import graph sites for move - #2075

Closed
vitali87 wants to merge 1 commit into
pr-split/split-pr1549-source/pr-1from
pr-split/split-pr1549-source/pr-3
Closed

vitali87 wants to merge 1 commit into
pr-split/split-pr1549-source/pr-1from
pr-split/split-pr1549-source/pr-3

Conversation

@vitali87

Copy link
Copy Markdown
Owner

Query imports by module and make the stateful test ingestor preserve per-site edge properties.

Files changed

  • codebase_rag/cypher_queries.py
  • evals/cgr_graph.py
  • codebase_rag/tests/test_change_signature.py

Diff stats

+65 additions, -33 deletions (98 LOC)

Dependencies

This PR depends on: pr-1

Dependency graph

Merge in this order:

pr-1: feat: add move public API and constants
├── pr-2: feat: parse move spans and imports
│   └── pr-5: feat: retarget move imports safely
│       └── pr-6: feat: implement move refactoring operation
│           ├── pr-7: feat: expose move through CLI
│           │   └── pr-11: docs: document move operation
│           ├── pr-8: feat: expose move through MCP
│           │   ├── pr-10: test: cover move MCP wiring
│           │   └── pr-11: docs: document move operation
│           └── pr-9: test: cover move operation behavior
│               └── pr-10: test: cover move MCP wiring
├── pr-3: feat: expose import graph sites for move  <-- this PR
│   └── pr-5: feat: retarget move imports safely
│       └── pr-6: feat: implement move refactoring operation
│           ├── pr-7: feat: expose move through CLI
│           │   └── pr-11: docs: document move operation
│           ├── pr-8: feat: expose move through MCP
│           │   ├── pr-10: test: cover move MCP wiring
│           │   └── pr-11: docs: document move operation
│           └── pr-9: test: cover move operation behavior
│               └── pr-10: test: cover move MCP wiring
└── pr-4: feat: detect move contract deltas
    └── pr-5: feat: retarget move imports safely
        └── pr-6: feat: implement move refactoring operation
            ├── pr-7: feat: expose move through CLI
            │   └── pr-11: docs: document move operation
            ├── pr-8: feat: expose move through MCP
            │   ├── pr-10: test: cover move MCP wiring
            │   └── pr-11: docs: document move operation
            └── pr-9: test: cover move operation behavior
                └── pr-10: test: cover move MCP wiring

@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • ^feat/.*
  • ^fix/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: vitali87/code-graph-rag/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 465731a0-d5f4-4e6f-92e0-8965a191717a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

Safe to merge from a production-behavior perspective: the reproduced issue is limited to the in-memory test fixture, but it should be corrected to keep test results faithful to graph behavior.

Findings

  1. P2 Preserve site-less relationships ▶

Summary

This PR adds outgoing-import query support and expands the stateful graph fixture to retain relationship-site metadata. One non-blocking fixture-fidelity issue remains: a propertyless relationship is lost when the same edge already has a property-bearing site.

Reviews (1) · Last reviewed commit: "feat: expose import graph sites for move"

Comment thread evals/cgr_graph.py
Comment on lines 237 to +245
if properties:
self.edge_props[edge] = dict(properties)
sites = self.edge_sites.setdefault(edge, [])
if dict(properties) not in sites:
sites.append(dict(properties))

def sites_of(self, edge: _RelTuple) -> list[PropertyDict]:
"""Every site of an edge (one empty record for a site-less edge)."""
return self.edge_sites.get(edge) or [self.edge_props.get(edge, {})]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Preserve site-less relationships

When the same source, type, and target are recorded first with site properties and then without them, this code retains only the property-bearing site. sites_of() consequently returns fewer relationship rows than the graph would expose, so tests using this fixture can miss behavior involving imports that have both site-bearing and site-less relationships. This is non-blocking for merge, but store an empty site for propertyless insertions to keep the fixture faithful.

Knowledge Base Used: Models and Schemas

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Artifacts

Evidence from the check

  • A narrow Python harness loads the exact checked-out stateful ingestor class and inserts matching property-bearing and propertyless CALLS relationships, ending with the reproducible assertion.

Command output from the check

  • The executed baseline adds only the property-bearing CALLS relationship and shows one stored site, establishing the expected starting state.

Command output from the check

  • The executed paired run adds a propertyless relationship after the property-bearing one and reports confirmed because sites_of omits the empty site.

View artifacts

T-Rex Ran code and verified through T-Rex

@greptile-apps

greptile-apps Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.

  • P2 Stateful ingestor drops a propertyless relationship after a property-bearing duplicate ▶

    • Bug
      • In evals/cgr_graph.py:237-245, ensure_relationship_batch() adds to edge_sites only for truthy properties. When an identical source/type/target relationship is first inserted with {"line": 10, "col": 2} and then inserted without properties, sites_of() returns only the first site instead of both relationship records.
    • Cause
      • The edge_sites.setdefault(...).append(...) path is inside if properties:. sites_of() then prefers the nonempty stored list and has no representation from which to synthesize the later propertyless site.
    • Fix
      • Record a site for every relationship insertion, including an empty property dictionary for None/empty properties; retain duplicate-site deduplication only if it matches the production graph's exact relationship semantics.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Five unresolved moderate findings affect module-root queries and per-site edge fidelity.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds module-level import-site querying and per-site relationship handling for move refactoring.

Changes:

  • Adds CYPHER_GRAPH_IMPORTS_OF.
  • Preserves per-site edge properties in the stateful evaluator.
  • Updates signature-change tests for stored call sites.
File Review summary
evals/​cgr_graph.py Adds per-site tracking and query support. Four moderate findings: missing Module/project filtering (1 vote), incorrect merge-key deduplication (3 votes), incomplete inbound-site capture (2 votes), and omitted site-less relationships (1 vote).
codebase_rag/​tests/​test_change_signature.py Updates heuristic-site handling.
codebase_rag/​cypher_queries.py Adds the import-site query. One moderate finding (1 vote): root-module matching must include the exact project name.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread evals/cgr_graph.py
# Every distinct site of an endpoint pair (issue #1522): the real
# store keeps one edge per site; `edge_props` keeps the last one
# for the callers that only need the pair.
self.edge_sites: dict[_RelTuple, list[PropertyDict]] = {}
Comment thread evals/cgr_graph.py
Comment on lines +239 to +241
sites = self.edge_sites.setdefault(edge, [])
if dict(properties) not in sites:
sites.append(dict(properties))

vitali87 commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

Closing as superseded: this is part of the split of #1549, which was closed without merging, and it targets the stale feat/change-signature branch rather than main. The change_signature base was rebuilt on main as #1912 (now stacked as #2161–#2169). The branch is kept, so the move-op work can be rebased onto main if it's picked up again.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants