feat: add OceanBase/seekdb vector and graph storage providers - #2130
feat: add OceanBase/seekdb vector and graph storage providers#2130Evenss wants to merge 4 commits into
Conversation
Add optional OceanBase / seekdb backends reusing the existing BaseVecDB and BaseGraphDB contracts, without changing any default behavior. - vec_dbs/oceanbase.py: OceanBaseVecDB on top of pyseekdb's Collection API, serving General Memory; require a positive vector_dimension in config. - graph_dbs/oceanbase.py: OceanBaseGraphDB ported from the postgres backend (nodes + edges + JSON + VECTOR) over the MySQL-compatible protocol, with a thread-safe connection pool, atomic multi-step deletes, and identifier whitelisting (table_prefix / search_filter keys). - Register "oceanbase" / "seekdb" aliases in the vec/graph factories and config factories; add GraphDBError; declare the optional "ob-mem" extra. - Add contract tests for both providers.
🤖 Open Code ReviewTarget: PR #2130 🔍 OpenCodeReview found 12 issue(s) in this PR. 1.
|
…ection handling - Updated pyseekdb version constraints in pyproject.toml to restrict to <1.5.0. - Increased default embedding dimension in APIConfig from 768 to 1024. - Improved connection handling in OceanBaseGraphDB and OceanBaseVecDB to ensure better resource management and error handling. - Added validation for table prefix length in OceanBaseGraphDB to prevent identifier overflow. - Enhanced logging for empty password configurations in OceanBaseGraphDB. - Updated tests to reflect changes in search behavior and connection management.
✅ Automated Test Results: PASSEDAll tests passed (31/31 executed). memos_python_core/changed-repo-python: 31/31. Duration: 5s Branch: |
✅ Automated Test Results: PASSEDAll tests passed (31/31 executed). memos_python_core/changed-repo-python: 31/31. Duration: 6s Branch: |
|
@wustzdy 感谢 review!想跟您确认一下「不符合本项目代码结构」具体指的是哪方面,以便我针对性调整: 本次改动的文件布局是参照现有
如果您指的是其他结构问题,麻烦指明一下期望的结构,我尽快调整,谢谢! |
✅ Automated Test Results: PASSEDAll tests passed (31/31 executed). memos_python_core/changed-repo-python: 31/31. Duration: 8s [advisory, non-gating] AI-generated tests on branch test/auto-gen-abad4fed10e4fccd-20260727164640: 181/186 passed, 5 failed — these do NOT affect the PR verdict; review the branch manually. Branch: |
|
@wustzdy PTAL |
WeiminLee
left a comment
There was a problem hiding this comment.
Thanks for adding the OceanBase/seekdb backends. I don't think this is ready to merge yet; there are a few provider-contract and tenant-safety issues that need to be fixed first.
Blocking findings:
-
src/memos/graph_dbs/oceanbase.py:890-search_by_embedding()acceptsfilter,knowledgebase_ids, andreturn_fields, but never applies or returns them. Existing graph backends use these parameters, and API context recall callssearch_by_embedding(..., return_fields=["memory", "key", ...]); with this implementation OceanBase returns onlyid/score, so recall results are filtered out becausememoryis missing. Ignoringfilter/knowledgebase_idsalso breaks caller-provided metadata and multi-cube filtering. -
src/memos/graph_dbs/oceanbase.py:669-delete_node_by_prams()allowsfile_idsorfilterdeletion without anywritable_cube_ids/ tenant scope, then selects and deletes matching nodes from the whole shared table. The API model allowswritable_cube_ids=None, and the Neo4j community backend explicitly rejectsfile_idsdeletes withoutwritable_cube_ids; OceanBase should either require the scope for these modes or default safely to the configureduser_name, with regression tests. -
src/memos/configs/vec_db.py:66- thevector_dimensionvalidator does not run when the inherited defaultNoneis omitted in Pydantic v2, soOceanBaseVecDBConfigcan still be constructed without a positive dimension and only fail later insideHNSWConfiguration. Please make the field required or validate the default value at config-construction time.
Please also make sure the new OceanBase tests cover these contracts, especially return_fields, structured filter / knowledgebase_ids, and tenant-scoped deletes.
…nd return field projection
|
Thanks for the review. All three blocking issues have been addressed:
Regression tests have been added: all OceanBase tests pass, and Ruff checks pass. Please take another look when convenient. Thanks! |
✅ Automated Test Results: PASSEDAll tests passed (48/48 executed). memos_python_core/changed-repo-python: 48/48. Duration: 5s [advisory, non-gating] AI-generated tests on branch test/auto-gen-9ed8ee6946107e51-20260804173940: 185/199 passed, 14 failed — these do NOT affect the PR verdict; review the branch manually. Branch: |

Description
Add two optional storage providers for OceanBase / seekdb, reusing the existing
BaseVecDB/BaseGraphDBcontracts. No default behavior changes: unless a user selects theoceanbase/seekdbbackend, everything works exactly as before.vec_dbs/oceanbase.py): built on pyseekdb's Collection / vector API, serving General Memory. Config now enforces a positivevector_dimension.graph_dbs/oceanbase.py): ported from the PostgreSQL + pgvector backend (nodes + edges + JSON properties +VECTORcolumn) over the MySQL-compatible protocol. Includes a thread-safe connection pool (maxconnnow effective), atomic multi-step deletes, and identifier whitelisting fortable_prefix/search_filterkeys.oceanbase/seekdbaliases in the vector & graph factories and config factories; add theGraphDBErrorexception.Dependencies: adds an optional extra
ob-mem(containingpyseekdb); imports are guarded with try/except ImportError and are not added to core dependencies.Related Issue (Required): Fixes #2109
Type of change
How Has This Been Tested?
External seekdb / OceanBase drivers (pyseekdb / pymysql) are stubbed with mocks; no live server is required. A live-server smoke test is not included in this PR.
Checklist
Reviewer Checklist