Skip to content

Revert "Holla"#23

Merged
offx-zinth merged 1 commit intomainfrom
revert-22-holla
Apr 15, 2026
Merged

Revert "Holla"#23
offx-zinth merged 1 commit intomainfrom
revert-22-holla

Conversation

@offx-zinth
Copy link
Copy Markdown
Owner

Reverts #22

@offx-zinth offx-zinth merged commit 87cfd96 into main Apr 15, 2026
1 check failed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread smp/protocol/server.py
engine = SeedWalkEngine(graph_store=graph, vector_store=vector, enricher=enricher)
builder = DefaultGraphBuilder(graph)
registry = ParserRegistry()
merkle_index = MerkleIndex()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The MerkleIndex constructor requires a MerkleTree instance as an argument, but it is being called here without any arguments. This will result in a TypeError when the application starts.

Suggested change
merkle_index = MerkleIndex()
tree = MerkleTree()
merkle_index = MerkleIndex(tree)

Comment thread smp/engine/linker.py
continue

if entity_name in import_map:
module_path, original_name = import_map[entity_name]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The variable entity_name is defined inside the conditional block starting at line 98. If that condition is not met, accessing entity_name here will raise an UnboundLocalError. This entire block (lines 108-134) should likely be nested within the if statement at line 98.

Comment thread smp/engine/community.py
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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 $O(N^2)$ complexity per iteration of the Louvain algorithm, which will not scale to large codebases. Consider maintaining community weights or sizes incrementally to keep this check efficient.

Comment thread smp/core/merkle.py
if self._tree.hash() == remote_hash:
return None

log.info("merkle_sync_diff_triggered", local=self._tree.hash(), remote=remote_hash)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The sync method currently returns None even when a hash mismatch is detected and logged. It should return the result of the diff or a signal to the caller that synchronization is required, as per the method's intended purpose.

Comment thread smp/cli.py
language=doc.language,
nodes=[
type(n)(
id=n.id.replace(str(file_path), rel_path),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Comment thread smp/protocol/router.py
@@ -0,0 +1,653 @@
"""JSON-RPC 2.0 dispatcher for the Structural Memory Protocol (SMP(3)).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Comment thread smp/engine/seed_walk.py
Comment on lines +230 to +237
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Catching all exceptions and returning an empty list here masks potential issues with the graph store (e.g., connection timeouts or authentication failures). It is better to let the exception propagate or log it with a stack trace so that system failures are visible.

Comment thread smp/engine/community.py
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(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using __import__ inline here is unnecessary and less readable than a standard import at the top of the file. Since smp.core.models is already used elsewhere, it should be imported normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant