feat(celery Wave 6 #33 chunk 1): LightRAG-style query layer Protocol stubs#1737
Merged
Conversation
…stubs on LineageGraphStore
Per §K.11.11 sub-spec — first chunk of Wave 6 PR-A "graphindex
elimination" cross-cutting refactor. Adds the read API the retrieval
pipeline + graph-curation flows will consume in chunk 3 (caller
migration), so chunk 2 (per-backend implementations) can be reviewed
against a stable Protocol surface without spec drift.
`aperag/indexing/graph.py`:
* New `LineageGraphStore` Protocol methods (declarations + docstrings
only, ~85 LOC):
- `query_entities_by_keyword(query, top_k)` — lexical recall
- `query_entities_by_vector(embedding, top_k)` — vector recall (caller
pre-embeds; backend stays embedder-agnostic per
simple-stable-directive separation of concerns)
- `expand_neighbors_n_hops(entity_names, hops=1)` — graph traversal
bounded by `hops` (no per-collection traversal-budget knob;
operator/dev pick `hops=1` for plain 1-hop or pass higher
explicitly).
* Returns are the canonical `EntityWithLineage` /
`RelationWithLineage` shapes already used by `get_*` — uniform read
surface. Callers compose context text themselves rather than
receiving a backend-formatted string (cleaner than legacy
`query_context() -> ctx.text`).
* `InMemoryLineageGraphStore` ships `NotImplementedError("Wave 6 #33
chunk 2 — pending")` stubs so chunk 2 can switch to real behaviour
without rewriting test scaffolding, and so any caller that
accidentally invokes the API before chunk 2 lands gets a clear
diagnostic.
`tests/unit_test/indexing/test_lineage_query_protocol.py`: 5 new
unit tests pinning the Protocol surface (3 method names + signature
shape via `inspect.signature` + the `NotImplementedError` chunk-1
contract on the in-memory store).
Out of scope (deferred to chunk 2 / chunk 3 per §K.11.11):
* Postgres / Neo4j / Nebula backend implementations (chunk 2).
* Caller migration: retrieval/pipeline.py + knowledge_graph/service.py
+ graph_curation/* (chunk 3).
* Legacy `aperag/domains/knowledge_graph/graphindex/` package delete
+ legacy tests delete + grep-zero verify (chunk 3).
Production-readiness 三类 (chunk 1 specific):
- must-be-real: Protocol surface declared with full docstrings; tests
pin signatures and chunk-1 stub contract.
- may-be-gated: in-memory + production backends raise
`NotImplementedError` until chunk 2 — gate fires loudly so a caller
cannot silently fall through to wrong behaviour.
- fully-resolves: §K.11.11 chunk 1 acceptance scope (Protocol stubs
~200 LOC).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wave 6 PR-A "graphindex elimination" — chunk 1 of 3 per §K.11.11 sub-spec.
Adds 3 new Protocol method declarations on
LineageGraphStorethat the chunk 3 caller migration will consume. No implementation, no caller migration — just the stable surface so chunk 2 (per-backend impl) can be reviewed without spec drift.query_entities_by_keyword(query, top_k)— lexical recallquery_entities_by_vector(embedding, top_k)— vector recall (caller pre-embeds)expand_neighbors_n_hops(entity_names, hops=1)— bounded graph traversalReturns canonical
EntityWithLineage/RelationWithLineageshapes (uniform withget_*).InMemoryLineageGraphStoreshipsNotImplementedError("chunk 2 — pending")stubs.Out of scope (per §K.11.11 chunk decomposition)
Test plan
tests/unit_test/indexing/test_lineage_query_protocol.pyinspect.signature(kw-only args + defaulthops=1)NotImplementedErrorchunk-1 contract pinned on in-memory store🤖 Generated with Claude Code