zettelkasten.synapse.candidates¶
zettelkasten.synapse.candidates ¶
Cross-store connection candidates: which memory<->ZK pairs MIGHT be related.
Candidates are the cheap, deterministic pre-filter before the (expensive) LLM typing pass. Two signals, unioned:
- Semantic NN — using each ZK note's text as a query into memory's shared vector space (and the reverse for a single node), pairs whose cosine clears a floor are candidates. Both stores embed with the same model, so this is a true cross-store nearest-neighbour.
- Shared provenance — a memory entry's git-pinned
filesoverlapping a ZK note's referenced provenance (cited-work ids, or file-path tokens in its body). Rare but high-signal: it means both nodes are anchored to the same artifact.
Every candidate is BIPARTITE by construction: one memory endpoint, one ZK endpoint. Read-only; no store is touched.
Candidate
dataclass
¶
A possible cross-store link (one memory node, one ZK node) + why.
Source code in zettelkasten/synapse/candidates.py
score ¶
Combined candidate strength (provenance overlap is a strong prior).
generate_candidates ¶
generate_candidates(zk_get_graph: GetGraph, projects: list[str] | None = None, graphs_dir: 'Path | None' = None, per_node_k: int = 5, sim_threshold: float = 0.45, limit: int | None = None, canon_types: 'tuple[str, ...] | None' = None, practice_types: 'tuple[str, ...] | None' = None, overfetch: int = 1) -> list[Candidate]
Generate cross-store candidate pairs across the intersection scope.
ZK-anchored: each ZK note is used as a query into memory's vector space
(bounded by per_node_k neighbours per note, sim_threshold floor), and
the shared-provenance index is intersected. limit caps the number of
canon-endpoint (candidate) notes scanned for lazy/partial builds — with a
canon_types filter only canon-passing notes count against it, so claims
beyond the first limit non-canon notes stay reachable.
The claim-aligned build restricts the two registers with canon_types
(only these ZK note types become canon endpoints — e.g. claim/finding)
and practice_types (only these memory entry types become practice
endpoints — e.g. decision/experiment/checkpoint, which keeps a
large annotation/note-heavy tree from exploding the candidate pool). Because
that type filter is applied AFTER semantic recall, cross-register recall would
otherwise bleed — so overfetch (>=1) widens the per-note neighbour fetch
to per_node_k * overfetch and then keeps the first per_node_k that pass
the practice filter. _cross synthesis-claim endpoints get a small score
prior so they are preferred over single-source findings covering a pair. The
shared-provenance channel is register-independent and always kept.
canon_types/practice_types None (the default) preserves the
original, unfiltered note-note behaviour exactly.
Source code in zettelkasten/synapse/candidates.py
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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 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 | |
candidates_for ¶
candidates_for(node_id: str, zk_get_graph: GetGraph, projects: list[str] | None = None, graphs_dir: 'Path | None' = None, per_node_k: int = 8, sim_threshold: float = 0.45, canon_types: 'tuple[str, ...] | None' = None, practice_types: 'tuple[str, ...] | None' = None) -> list[Candidate]
Lazy single-node candidate generation (either a memory id or a ZK note id).
Used by the on-demand connection path: given one node, find its cross-store
neighbours in the other store via semantic NN + shared provenance.
canon_types/practice_types optionally restrict which note types are
accepted on the canon (ZK) and practice (memory) endpoints — None (the
default) accepts all, preserving the original behaviour.
Source code in zettelkasten/synapse/candidates.py
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 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |