Skip to content

feat(celery Wave 6 #33 chunk 1): LightRAG-style query layer Protocol stubs#1737

Merged
earayu merged 1 commit into
mainfrom
bryce/celery-wave6
Apr 27, 2026
Merged

feat(celery Wave 6 #33 chunk 1): LightRAG-style query layer Protocol stubs#1737
earayu merged 1 commit into
mainfrom
bryce/celery-wave6

Conversation

@earayu
Copy link
Copy Markdown
Collaborator

@earayu earayu commented Apr 27, 2026

Summary

Wave 6 PR-A "graphindex elimination" — chunk 1 of 3 per §K.11.11 sub-spec.

Adds 3 new Protocol method declarations on LineageGraphStore that 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 recall
  • query_entities_by_vector(embedding, top_k) — vector recall (caller pre-embeds)
  • expand_neighbors_n_hops(entity_names, hops=1) — bounded graph traversal

Returns canonical EntityWithLineage / RelationWithLineage shapes (uniform with get_*). InMemoryLineageGraphStore ships NotImplementedError("chunk 2 — pending") stubs.

Out of scope (per §K.11.11 chunk decomposition)

  • chunk 2: Postgres / Neo4j / Nebula backend implementations + tests
  • chunk 3: caller migration (retrieval / knowledge_graph / graph_curation) + legacy package hard-cut delete + grep-zero verify

Test plan

  • 5 new unit tests in tests/unit_test/indexing/test_lineage_query_protocol.py
  • Protocol surface pinned via inspect.signature (kw-only args + default hops=1)
  • NotImplementedError chunk-1 contract pinned on in-memory store
  • 157/157 existing indexing unit tests pass (no regression)
  • ruff check + format clean

🤖 Generated with Claude Code

…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>
@earayu earayu merged commit 20b9071 into main Apr 27, 2026
4 checks passed
@earayu earayu deleted the bryce/celery-wave6 branch April 27, 2026 11:42
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