Fix #1681: feat: expose cube creation in HTTP API + clarify mem_cube_id semantics#1822
Open
Memtensor-AI wants to merge 1 commit into
Open
Fix #1681: feat: expose cube creation in HTTP API + clarify mem_cube_id semantics#1822Memtensor-AI wants to merge 1 commit into
Memtensor-AI wants to merge 1 commit into
Conversation
Adds POST /product/create_cube to the server-mode HTTP API so integrators can pre-register cubes for multi-tenant / multi-cube deployments. Without this endpoint, /product/add silently accepted arbitrary mem_cube_id values and wrote embeddings to the vector store, but /product/search returned empty results because the tree registry had no entry for the cube. Changes: - New CreateCubeRequest/CreateCubeResponse pydantic models - New idempotent graph_db.create_user_name() helper on Neo4jGraphDB and PolarDBGraphDB that inserts a deterministic '_cube_marker:<id>' node - New POST /product/create_cube endpoint wired to the helper, with a graceful 501 fallback for backends that haven't adopted the helper yet - Opt-in MEMOS_STRICT_CUBE_VALIDATION env var: when enabled, /add and /search return 404 with a clear message if an explicit mem_cube_id references a cube that has not been registered (Option 3 in the issue); off by default to preserve existing client behaviour - Unit tests for the new endpoint, idempotency, strict-mode validation, and the create_user_name graph_db helper Fixes #1681 Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Description
实现 Issue #1681:在 server-mode HTTP API 暴露 cube 创建能力,并补充 cube 校验。新增 POST /product/create_cube 端点、CreateCube 请求/响应模型、Neo4j/PolarDB 的 create_user_name 幂等标记节点方法,以及 MEMOS_STRICT_CUBE_VALIDATION 开关(启用后 /add 与 /search 对未注册 cube 返回 404);同步新增了端点、幂等行为、严格模式校验和 graph_db 辅助方法的单元测试。Ruff lint 和 format 均通过;6 个文件、553 行新增。已 commit 并 push 到 autodev/MemOS-1681 分支,由调度器兜底创建 PR。
Related Issue (Required): Fixes #1681
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Not run; documentation-only change.
Checklist
@CarltonXiang, @syzsunshine219 please review this PR.
Reviewer Checklist