symfonic.core.learning.phases¶
phases ¶
The consolidation phases, now owned by the memory capability.
Every phase this module used to define lives in
symfonic.capabilities.memory.phases and is imported back here for the
legacy consolidator to call. A phase transcribed into two packages is two
behaviours under one name, drifting until the copy an adopter runs is not the
copy the tests exercise -- and the roster tables in
capabilities.memory.rosters carry three findings that were exactly that
mistake made in three places.
This module is the name the shipped consolidator and its tests already import.
consolidate_pending_edges
async
¶
consolidate_pending_edges(graph: GraphMemoryStore, scope: TenantScope, all_nodes: list[MemoryNode], pending_connections: list[dict[str, Any]]) -> int
Write inferred pending_connections as real graph edges.
Source code in symfonic/capabilities/memory/phases/pruning.py
create_cooccurrence_edges
async
¶
create_cooccurrence_edges(graph: GraphMemoryStore, scope: TenantScope, recent_nodes: list[MemoryNode]) -> int
Create CO_OCCURRED edges between nodes updated within 1 hour.
Weight reinforcement: repeated co-occurrence increments the edge weight rather than inserting a duplicate.
Degree cap: a node that already has >= MAX_CO_OCCUR_DEGREE CO_OCCURRED neighbours will not receive new CO_OCCURRED edges (existing edges still get reinforced).
Source code in symfonic/capabilities/memory/phases/structural.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
generate_meta_nodes
async
¶
generate_meta_nodes(graph: GraphMemoryStore, scope: TenantScope, all_nodes: list[MemoryNode], llm_summarise: Any | None = None) -> int
Create meta-nodes from clusters of related nodes.
Idempotence: generated META: and Entity: nodes are excluded from
the clustering input. Without the first filter, a second consolidation run
groups every META:foo/META:bar node under the shared prefix
META and emits a META:META cascade node -- correct but
cosmetically noisy. Without the second, every entity minted late in DEEP's
roster groups under META:Entity on the next unchanged cycle. Phase 4
clusters raw domain nodes; both kinds are phase outputs, not inputs.
Source code in symfonic/capabilities/memory/phases/pruning.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
prune_orphans
async
¶
Delete orphan nodes: few edges, stale, low confidence, or TTL-expired.
Source code in symfonic/capabilities/memory/phases/pruning.py
strengthen
async
¶
strengthen(graph: GraphMemoryStore, scope: TenantScope, recent_nodes: list[MemoryNode], *, spreading_weight: float = 0.5) -> int
Increment importance on recently accessed (recurring) nodes.
A node qualifies as "recurring" when EITHER:
-
It appears >= 2 times in
recent_nodes(duplicate-in-list signal). This covers access-log replay / neighbourhood traversal callers that intentionally feed per-hit records into the consolidator. -
Its combined recurrence score
access_count + spreading_weight * spreading_access_count >= 2. -
access_countis bumped byGraphMemoryStore.get_nodeon every direct fetch (one-shot reads). spreading_access_countis bumped byGraphMemoryStore.bump_spreadingon every BFS-induced visit (spreading activation throughGraphTraversal.bfs).
spreading_weight (default 0.5) comes from
FrameworkConfig.phase1_spreading_weight. At 0.5 the combined
score matches v6.1.x observable behaviour: two BFS visits count
like one direct fetch. Setting the weight to 0.0 yields the
direct-only semantic from the user task description.
Before the v6.0.x fix, Phase 1 silently never fired in production:
GraphMemoryStore.query_nodes returns each node exactly once, so
the duplicate-in-list count was always 1 and the < 2 guard always
skipped. Falling back to the per-node access_count surfaces the
access-recurrence signal already captured at retrieval time without
requiring a new DB schema or access log.
The count semantics of the list-duplicate path are preserved: a node that appears N>=2 times in the list still gets N successful update attempts (each subsequent read loads the freshly-boosted value).
ADR (v6.1 T02/T03, revised v6.2 T02): the canonical recurrence signal
is the combined access_count + weighted spreading_access_count.
v6.1 aligned spreading-activation reads with the single access_count
counter by routing GraphTraversal.bfs through store.get_node.
v6.2 decomposed the counter so callers can distinguish direct fetches
from one-shot spreading visits. BFS now bumps
spreading_access_count via GraphMemoryStore.bump_spreading.
Intentionally excluded from bumping: query_nodes (returns
candidate sets for scoring -- one query bumping N nodes would distort
the frequency signal that scoring.py also reads), and
shortest_path / graph_proximity (run inside the scoring
loop itself -- same contamination risk).
Source code in symfonic/capabilities/memory/phases/strengthen.py
tag_risk_nodes
async
¶
Mark nodes with negative context as RISK_NODE.