What's wrong
MemgraphDocStatusStorage.get_docs_paginated() in integrations/lightrag-memgraph/src/lightrag_memgraph/docstatus_impl.py sorts by a single field with no secondary tiebreaker:
ORDER BY {sort_expr} {order}
The reference JsonDocStatusStorage sorts an in-memory Python list, whose sort is stable and gives deterministic tie-breaking (by insertion order) for free. Memgraph's ORDER BY gives no stability guarantee among tied rows across separate query executions.
LightRAG commonly batch-writes many documents sharing the identical updated_at/created_at timestamp within one ingestion batch. Paging through the same listing (page 1, then page 2) can return the same document twice or silently skip one whenever ties exist — a pagination-correctness regression from the reference semantics. Doesn't show up in the current single-page integration tests, only with real timestamp-colliding data.
Acceptance criteria
Blocked by
None - can start immediately
What's wrong
MemgraphDocStatusStorage.get_docs_paginated()inintegrations/lightrag-memgraph/src/lightrag_memgraph/docstatus_impl.pysorts by a single field with no secondary tiebreaker:The reference
JsonDocStatusStoragesorts an in-memory Python list, whose sort is stable and gives deterministic tie-breaking (by insertion order) for free. Memgraph'sORDER BYgives no stability guarantee among tied rows across separate query executions.LightRAG commonly batch-writes many documents sharing the identical
updated_at/created_attimestamp within one ingestion batch. Paging through the same listing (page 1, then page 2) can return the same document twice or silently skip one whenever ties exist — a pagination-correctness regression from the reference semantics. Doesn't show up in the current single-page integration tests, only with real timestamp-colliding data.Acceptance criteria
get_docs_paginated()'sORDER BYincludes a secondary, always-unique tiebreaker (e.g.id)Blocked by
None - can start immediately