Revert "Holla"#23
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the Structural Memory Protocol (SMP) V2, a graph-based memory system for AI agents that utilizes static AST analysis to model complex codebases. The implementation includes a FastAPI-based JSON-RPC server, a Python SDK, and backends for Neo4j and ChromaDB. The code review identifies several critical issues, including a TypeError in the server initialization due to a missing argument in the MerkleIndex constructor, a potential UnboundLocalError in the linker, and inefficient O(N^2) complexity in the community detection algorithm. Additionally, the Merkle index synchronization logic is incomplete, the CLI's node ID generation is unreliable, and the codebase contains redundant routing logic. Feedback also suggests improving exception handling in the query engine and replacing inline imports with standard top-level imports for better readability.
| engine = SeedWalkEngine(graph_store=graph, vector_store=vector, enricher=enricher) | ||
| builder = DefaultGraphBuilder(graph) | ||
| registry = ParserRegistry() | ||
| merkle_index = MerkleIndex() |
There was a problem hiding this comment.
| continue | ||
|
|
||
| if entity_name in import_map: | ||
| module_path, original_name = import_map[entity_name] |
There was a problem hiding this comment.
| ki = len(adjacency.get(nid, set())) | ||
|
|
||
| for comm, ki_comm in neighbor_comms.items(): | ||
| sigma_tot = sum(1 for n, c in community.items() if c == comm and n in adjacency) |
There was a problem hiding this comment.
This line performs a full iteration over all nodes in the graph (community.items()) inside a loop that already iterates over nodes and their neighbors. This leads to
| if self._tree.hash() == remote_hash: | ||
| return None | ||
|
|
||
| log.info("merkle_sync_diff_triggered", local=self._tree.hash(), remote=remote_hash) |
| language=doc.language, | ||
| nodes=[ | ||
| type(n)( | ||
| id=n.id.replace(str(file_path), rel_path), |
There was a problem hiding this comment.
Using replace(str(file_path), rel_path) on the node ID is risky. If the absolute path string happens to be part of another component of the ID (e.g., a name or a signature that coincidentally contains the path), it will be incorrectly replaced. It is safer to construct the ID using the relative path directly or use more robust path manipulation utilities.
| @@ -0,0 +1,653 @@ | |||
| """JSON-RPC 2.0 dispatcher for the Structural Memory Protocol (SMP(3)). | |||
There was a problem hiding this comment.
This file appears to be a duplicate implementation of the JSON-RPC dispatching logic found in smp/protocol/dispatcher.py. Since smp/protocol/server.py is configured to use the modular handler pattern from dispatcher.py, this file is redundant and should be removed to avoid confusion and maintenance overhead.
| edges_out = await self._graph.get_edges(current_id, direction="outgoing") | ||
| except Exception: | ||
| edges_out = [] | ||
| try: | ||
| edges_in = await self._graph.get_edges(current_id, direction="incoming") | ||
| except Exception: | ||
| edges_in = [] | ||
| all_edges = edges_out + edges_in |
There was a problem hiding this comment.
| id=comm.id, | ||
| type=NodeType("Community") if "Community" in NodeType._value2member_map_ else NodeType.FILE, | ||
| file_path=comm.majority_path_prefix, | ||
| structural=__import__("smp.core.models", fromlist=["StructuralProperties"]).StructuralProperties( |
Reverts #22