You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PostgresGraphDB is missing several graph-store methods that Neo4jGraphDB already implements. When MOS_ENABLE_REORGANIZE=true, the reorganizer and handler call these methods during structure optimization and redundant-memory merge (MERGED_TO edge inheritance), causing background thread crashes or silent merge failures.
This change adds:
node_not_exist / get_memory_count for structure optimization pre-checks
get_edges and extended edge_exists (direction / type=ANY / user_name) for MERGED_TO edge inheritance
user_name kwarg support in get_structure_optimization_candidates
search_by_fulltext stub (matches Neo4j stub behavior) to avoid AttributeError on keyword recall path
Also includes prior embedding normalization fix (list[float] coercion for pgvector string values) required by reorganizer GraphDBNode validation.
The import psycopg2 and import psycopg2.pool statements live inside the __init__ body of PostgresGraphDB. Patching require_python_package only removes the decorator wrapper — it does not suppress these local imports. If psycopg2 is not installed in the test environment (e.g., a lightweight CI runner), every test that calls _build_db() will raise ImportError and fail.
Consider adding a module-level skip guard:
psycopg2=pytest.importorskip("psycopg2")
or use a try/except ImportError fixture, so the entire test module is gracefully skipped when the optional dependency is absent.
The parameter name filter shadows Python's builtin filter function. Since search_filter is already present as a separate parameter, this filter parameter is redundant and its naming is problematic. Rename it to avoid shadowing the builtin — e.g., use extra_filter or simply remove it if it duplicates search_filter.
💡 Suggested Change
Before:
filter: dict | None = None,
After:
extra_filter: dict | None = None,
3. src/memos/graph_dbs/postgres.py (L1153-L1154)
This stub silently returns an empty list without any warning, which makes it very hard to diagnose why keyword recall produces no results in production. Add at least a logger.warning to alert callers that the method is not implemented, or raise NotImplementedError if it is not expected to be called yet.
💡 Suggested Change
Before:
"""Stub for TreeTextMemory keyword recall; Postgres fulltext search is not implemented yet."""
return []
After:
"""Stub for TreeTextMemory keyword recall; Postgres fulltext search is not implemented yet."""
logger.warning(
"[search_by_fulltext] Full-text search is not implemented for PostgresGraphDB; "
"returning empty results."
)
return []
Generated by cloud-assistant via Open Code Review.
The test environment encountered an issue that requires manual attention.
Details: Executor error: Command failed: git clone --depth 1 --branch fix/postgres-reorganizer-compat git@github.com:Kwizii/MemOS.git /data/test-workspaces/470076c0e05b72ea/repo
Cloning into '/data/test-workspaces/470076c0e05b72ea/repo'...
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists. Branch:fix/postgres-reorganizer-compat
The test environment encountered an issue that requires manual attention.
Details: Executor error: Command failed: git clone --depth 1 --branch fix/postgres-reorganizer-compat git@github.com:Kwizii/MemOS.git /data/test-workspaces/e8ae6dfd1a4d4c78/repo
Cloning into '/data/test-workspaces/e8ae6dfd1a4d4c78/repo'...
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists. Branch:fix/postgres-reorganizer-compat
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
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
PostgresGraphDBis missing several graph-store methods thatNeo4jGraphDBalready implements. WhenMOS_ENABLE_REORGANIZE=true, the reorganizer and handler call these methods during structure optimization and redundant-memory merge (MERGED_TOedge inheritance), causing background thread crashes or silent merge failures.This change adds:
node_not_exist/get_memory_countfor structure optimization pre-checksget_edgesand extendededge_exists(direction/type=ANY/user_name) for MERGED_TO edge inheritanceuser_namekwarg support inget_structure_optimization_candidatessearch_by_fulltextstub (matches Neo4j stub behavior) to avoid AttributeError on keyword recall pathAlso includes prior embedding normalization fix (
list[float]coercion for pgvector string values) required by reorganizerGraphDBNodevalidation.Related Issue (Required): Fixes #2272
Type of change
How Has This Been Tested?
Added regression tests in
tests/graph_dbs/test_postgres_reorganizer_compat.py:node_not_exist/get_memory_countget_edgesand extendededge_existsget_structure_optimization_candidates(..., user_name=...)search_by_fulltextstubExisting tests in
tests/graph_dbs/test_postgres_embedding_parse.pycover embedding normalization.Reproduce with:
Checklist
Reviewer Checklist