|
11 | 11 | // --------------------------------------------------------------------------- |
12 | 12 |
|
13 | 13 | import type { Edge, Hash, MetadataStore } from "../core/types"; |
14 | | -import { DEFAULT_HOTPATH_POLICY, type HotpathPolicy } from "../core/HotpathPolicy"; |
| 14 | +import { computeNeighborMaxDegree, DEFAULT_HOTPATH_POLICY, type HotpathPolicy } from "../core/HotpathPolicy"; |
15 | 15 | import { batchComputeSalience, runPromotionSweep } from "../core/SalienceEngine"; |
16 | 16 |
|
17 | 17 | // --------------------------------------------------------------------------- |
@@ -43,7 +43,8 @@ export interface HebbianUpdaterOptions { |
43 | 43 | ltdDecay?: number; |
44 | 44 | /** Prune edges whose weight drops below this value. Default: DEFAULT_PRUNE_THRESHOLD. */ |
45 | 45 | pruneThreshold?: number; |
46 | | - /** Maximum outgoing degree per node. Default: DEFAULT_MAX_DEGREE. */ |
| 46 | + /** Maximum outgoing Hebbian edges per node. |
| 47 | + * When omitted, uses Williams-derived `computeNeighborMaxDegree(graphMass)`. */ |
47 | 48 | maxDegree?: number; |
48 | 49 | /** Current timestamp (ms since epoch). Defaults to Date.now(). */ |
49 | 50 | now?: number; |
@@ -135,13 +136,15 @@ export async function decayAndPrune( |
135 | 136 | policy = DEFAULT_HOTPATH_POLICY, |
136 | 137 | ltdDecay = DEFAULT_LTD_DECAY, |
137 | 138 | pruneThreshold = DEFAULT_PRUNE_THRESHOLD, |
138 | | - maxDegree = DEFAULT_MAX_DEGREE, |
139 | 139 | now = Date.now(), |
140 | 140 | } = options; |
141 | 141 |
|
142 | 142 | const allPages = await metadataStore.getAllPages(); |
143 | 143 | if (allPages.length === 0) return { decayed: 0, pruned: 0 }; |
144 | 144 |
|
| 145 | + // Derive max degree from Williams bounds if not explicitly provided. |
| 146 | + const maxDegree = options.maxDegree ?? computeNeighborMaxDegree(allPages.length, policy.c); |
| 147 | + |
145 | 148 | const changedNodeIds = new Set<Hash>(); |
146 | 149 | let totalDecayed = 0; |
147 | 150 | let totalPruned = 0; |
|
0 commit comments