Fix #2272: PostgresGraphDB missing reorganizer/handler methods when MOS_ENABLE_REORGANIZE=t - #2276
Conversation
PostgresGraphDB lacked the graph-store interface used by the tree text memory reorganizer and handler (node_not_exist, get_memory_count, get_edges, edge_exists direction/user_name semantics, per-user structure optimization candidates, search_by_fulltext), crashing the background structure optimization thread with AttributeError when MOS_ENABLE_REORGANIZE=true and graph_db.backend=postgres, and blocking MERGED_TO edge creation during redundant-memory merge. Add the missing methods with Neo4j-compatible semantics, extend edge_exists with direction/type-ANY handling, honor user_name in get_structure_optimization_candidates, implement search_by_fulltext on PostgreSQL built-in full-text search, and add a default get_edges contract on BaseGraphDB. Covered by 22 new unit tests stubbing psycopg2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🤖 Open Code ReviewTarget: PR #2276 🔍 OpenCodeReview found 5 issue(s) in this PR. 1.
|
🔧 Open Code Review requested Agent fixOpen Code Review found 5 issue(s). I have resumed the development Agent to fix them.
The Agent will push a new commit to this PR branch. OCR will recheck after the commit is pushed. |
- edge_exists: skip edge_type condition when type="ANY" for OUT/IN directions, matching the direction="ANY" branch and Neo4j semantics - get_edges: require both endpoints in the same user scope (AND instead of OR) for strict tenant isolation, matching Neo4j reference - base.py: mark get_edges @AbstractMethod to guarantee subclasses implement the edge query contract - tests: pin params[1] == user_name in optimization candidates test and select the first tsquery_string slot via [-3] with layout comments Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Description
Fixed issue #2272: PostgresGraphDB was missing the graph-store interface used by the tree text memory reorganizer and handler, crashing the background structure optimization thread (AttributeError: 'PostgresGraphDB' object has no attribute 'node_not_exist') when MOS_ENABLE_REORGANIZE=true with graph_db.backend=postgres, and blocking MERGED_TO edge creation during redundant-memory merge.
Changes (all in src/memos/graph_dbs/):
Tests: new tests/graph_dbs/test_postgres_graph_db.py with 22 unit tests stubbing psycopg2 (no live DB needed) - all pass. Regression: tests/graph_dbs (53 passed, 3 skipped), tests/memories/textual (60 passed), full suite 743 passed; the only failures are pre-existing and environment-related (missing optional markitdown/qdrant packages, and an unrelated kv-cache bug reproduced on a clean checkout of dev-v2.0.30). ruff check and ruff format are clean.
Committed as 14720c2 on bugfix/autodev-2272-20260822153326438 (pushed to origin) and the opsp artifacts (.ai-tasks task file + openspec proposal/spec/design/tasks/test-cases/verification-report) were synced to the memos-autodev-specs repo.
Related Issue (Required): Fixes #2272
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@wustzdy please review this PR.
Reviewer Checklist