Skip to content

refactor: move MemgraphIngestor into services/graph behind a re-export shim and add the GraphIngestor protocol - #2

Open
robfrank wants to merge 1 commit into
mainfrom
graph-seam/01-ingestor-protocol
Open

robfrank wants to merge 1 commit into
mainfrom
graph-seam/01-ingestor-protocol

Conversation

@robfrank

Copy link
Copy Markdown
Owner

Summary

  • Moves MemgraphIngestor from services/graph_service.py into a new services/graph/ package, leaving graph_service.py as a permanent re-export shim.
  • Adds GraphIngestor, a protocol that extends the already-existing IngestorProtocol and QueryProtocol in services/__init__.py rather than inventing a parallel one.
  • No behaviour change. MemgraphIngestor's body is byte-identical apart from the import depth.

First of a small series splitting up vitali87#1397, following the request there for smaller PRs. Each subsequent piece is independently green and goes out one at a time rather than stacked, so no PR ever shows a cumulative diff.

Type of Change

  • Refactoring (no functional changes)

Related Issues

Related to vitali87#1397 — that PR should be closed or retargeted once this series lands.

Why

services/__init__.py already defines IngestorProtocol and QueryProtocol, and evals/cgr_graph.py's _CapturingIngestor already duck-types that surface. The seam exists informally today; this makes it explicit and gives the storage layer a package of its own instead of one 700-line module hanging off services/.

MemgraphIngestor is public API via cgr.__all__, so codebase_rag.services.graph_service has to keep resolving. The shim is deliberate and permanent, not a migration step.

Three patch() targets are repointed (test_graph_service.py, test_memory_limit.py) because they patch the module attribute, not the re-exported name.

A note on the diff size

GitHub renders this as a 691-line new file plus a 695-line deletion. With copy detection on it is a move plus 14 changed lines:

$ git diff -C -C --find-copies-harder --stat main..HEAD
 codebase_rag/services/graph/__init__.py            |   4 +
 .../{graph_service.py => graph/memgraph.py}        |  14 +-
 codebase_rag/services/graph/protocol.py            |  50 ++
 codebase_rag/services/graph_service.py             | 695 +--------------------
 codebase_rag/tests/test_graph_protocol.py          |  26 +
 codebase_rag/tests/test_graph_service.py           |   6 +-
 codebase_rag/tests/test_memory_limit.py            |   2 +-
 7 files changed, 98 insertions(+), 699 deletions(-)

The 14 lines in the moved file are all import-depth changes (.. to ...). protocol.py and the shim are the only genuinely new code.

Test Plan

  • Unit tests pass — 7901 passed, 29 skipped
  • New tests added — test_graph_protocol.py: the protocol is satisfied, the shim still exports the same object, cgr.__all__ still exposes it, and _CapturingIngestor still satisfies IngestorProtocol
  • Integration tests pass — 300 passed, 5 skipped
  • make pre-commit clean end to end

Checklist

  • PR title follows Conventional Commits
  • All pre-commit checks pass (make pre-commit)
  • No hardcoded strings in non-config/non-constants files
  • No # type: ignore, cast(), Any, or object type hints — none added
  • No new comments or docstrings — not met, deliberately. protocol.py and the shim each carry one docstring, because "why does this indirection exist" is not derivable from the code: the shim in particular looks deletable without the note that it backs public API. This also reads as a conflict with CONTRIBUTING.md's comment policy ("explain why and how"). Easy to strip if the checklist is meant literally.

@claude

claude Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

1 similar comment
@claude

claude Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@robfrank
robfrank force-pushed the graph-seam/01-ingestor-protocol branch from 415d8dd to 0a6f1ca Compare August 29, 2026 18:41
@claude

claude Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

This branch has not been deployed

No deployments
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.

1 participant