symfonic.memory.janitor_dedup¶
janitor_dedup ¶
The graph-facing half of SemanticMerge: dedupe one node, or a whole layer.
This mixin reads candidates, writes merges, and walks a whole layer.
Similarity and pure merging remain in :mod:symfonic.memory.janitor.
SemanticMerge mixes this in, so both entry points are called as before.
SemanticDeduplicationMixin ¶
Store-backed deduplication passes for :class:SemanticMerge.
deduplicate
async
¶
Check for duplicates and merge when found; otherwise return new_node.
If one or more duplicate nodes exist this method:
1. Merges new_node into the first duplicate (sequential merge for
multiple duplicates would require an additional loop; a single merge
covers the most common case).
2. Persists the merged node back to the graph via update_node.
3. Returns the canonical (merged) node.
If no duplicates are found the caller should persist new_node as a fresh graph record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
TenantScope
|
Tenant context for graph queries. |
required |
graph_store
|
GraphMemoryStore
|
Live graph store to query and update. |
required |
new_node
|
MemoryNode
|
Incoming node that may duplicate an existing record. |
required |
Returns:
| Type | Description |
|---|---|
MemoryNode
|
The canonical MemoryNode (either the merged existing node or the |
MemoryNode
|
unchanged new_node when no duplicate was found). |
Source code in src/symfonic/memory/janitor_dedup.py
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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |