Skip to content

Commit d1b8e44

Browse files
Copilotdevlux76
andcommitted
fix(#95): audit Daydreamer consolidation — HebbianUpdater uses Williams-derived max degree
HebbianUpdater.decayAndPrune now derives maxDegree from computeNeighborMaxDegree(graphMass) instead of a fixed 16, matching the design requirement for Williams-bound-driven edge pruning. Closes #95 Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>
1 parent f1ca929 commit d1b8e44

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/daydreamer/HebbianUpdater.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// ---------------------------------------------------------------------------
1212

1313
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";
1515
import { batchComputeSalience, runPromotionSweep } from "../core/SalienceEngine";
1616

1717
// ---------------------------------------------------------------------------
@@ -43,7 +43,8 @@ export interface HebbianUpdaterOptions {
4343
ltdDecay?: number;
4444
/** Prune edges whose weight drops below this value. Default: DEFAULT_PRUNE_THRESHOLD. */
4545
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)`. */
4748
maxDegree?: number;
4849
/** Current timestamp (ms since epoch). Defaults to Date.now(). */
4950
now?: number;
@@ -135,13 +136,15 @@ export async function decayAndPrune(
135136
policy = DEFAULT_HOTPATH_POLICY,
136137
ltdDecay = DEFAULT_LTD_DECAY,
137138
pruneThreshold = DEFAULT_PRUNE_THRESHOLD,
138-
maxDegree = DEFAULT_MAX_DEGREE,
139139
now = Date.now(),
140140
} = options;
141141

142142
const allPages = await metadataStore.getAllPages();
143143
if (allPages.length === 0) return { decayed: 0, pruned: 0 };
144144

145+
// Derive max degree from Williams bounds if not explicitly provided.
146+
const maxDegree = options.maxDegree ?? computeNeighborMaxDegree(allPages.length, policy.c);
147+
145148
const changedNodeIds = new Set<Hash>();
146149
let totalDecayed = 0;
147150
let totalPruned = 0;

0 commit comments

Comments
 (0)