symfonic.memory.graph.traversal¶
traversal ¶
GraphTraversal -- BFS traversal and path queries for graph proximity scoring.
Provides breadth-first search, shortest-path computation, and the graph_proximity metric used in the four-signal scoring formula.
v6.1 T03 (deprecated by v6.2 T02): bfs used to route through
GraphMemoryStore.get_node (bumping access_count on every
traversal hit). v6.2 decomposed the counter: BFS now bumps
spreading_access_count via GraphMemoryStore.bump_spreading.
Direct fetches keep using get_node (= direct access_count bump).
This lets Phase 1 strengthen weight the two signals independently
via FrameworkConfig.phase1_spreading_weight (default 0.5 -- a node
that was spread-activated twice contributes like one direct fetch,
matching the v6.1.x observable behaviour).
shortest_path / graph_proximity deliberately do NOT bump
either counter -- they run inside the scoring loop, and bumping there
would pollute the frequency signal with one-query-N-bumps noise.
GraphTraversal ¶
Graph traversal utilities operating on a GraphMemoryStore.
All methods enforce tenant isolation through the required TenantScope.
Source code in src/symfonic/memory/graph/traversal.py
bfs
async
¶
Breadth-first traversal returning all reachable nodes within depth.
v6.2 T02: visited nodes are fetched via
GraphMemoryStore.bump_spreading which bumps
spreading_access_count on every hit. Phase 1
strengthen combines it with the direct access_count
using FrameworkConfig.phase1_spreading_weight so callers
can tune how strongly one-shot spreading activation contributes
to recurrence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
TenantScope
|
Tenant scope for isolation. |
required |
start
|
NodeId
|
Starting node ID. |
required |
max_depth
|
int
|
Maximum traversal depth (inclusive). |
3
|
Returns:
| Type | Description |
|---|---|
list[MemoryNode]
|
List of reachable MemoryNodes (including the start node if it exists). |
Source code in src/symfonic/memory/graph/traversal.py
graph_proximity
async
¶
Compute graph proximity between two nodes.
Returns 1.0 / (1 + shortest_path_length), or 0.0 if no path exists. Same node returns 1.0. Direct neighbors return 0.5.
This metric feeds the graph_proximity component of the scoring formula.
Source code in src/symfonic/memory/graph/traversal.py
shortest_path
async
¶
Find the shortest path between two nodes using BFS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
TenantScope
|
Tenant scope for isolation. |
required |
source
|
NodeId
|
Start node ID. |
required |
target
|
NodeId
|
End node ID. |
required |
Returns:
| Type | Description |
|---|---|
list[NodeId] | None
|
List of NodeIds forming the shortest path (inclusive of both |
list[NodeId] | None
|
endpoints), or None if no path exists. |