Skip to content

Commit 9500059

Browse files
committed
feat(memory): enable KnowledgeGraph by default, add disabled opt-out flag
Graph now activates automatically when CognitiveMemoryManager initializes, providing spreading activation (Collins & Quillian), Hebbian co-activation learning, and graph-boosted retrieval scoring out of the box. Set graph.disabled=true to opt out. All MemoryGraphConfig fields are now optional with sensible defaults exported as DEFAULT_GRAPH_CONFIG.
1 parent f4fc891 commit 9500059

2 files changed

Lines changed: 48 additions & 12 deletions

File tree

src/memory/CognitiveMemoryManager.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
DEFAULT_ENCODING_CONFIG,
2828
DEFAULT_DECAY_CONFIG,
2929
DEFAULT_BUDGET_ALLOCATION,
30+
DEFAULT_GRAPH_CONFIG,
3031
} from './core/config.js';
3132
import { computeEncodingStrength, buildEmotionalContext } from './core/encoding/EncodingModel.js';
3233
import {
@@ -256,9 +257,13 @@ export class CognitiveMemoryManager implements ICognitiveMemoryManager {
256257
config.featureDetectionLlmInvoker
257258
);
258259

259-
// --- Batch 2: Memory Graph ---
260-
if (config.graph) {
261-
const backend = config.graph.backend ?? 'knowledge-graph';
260+
// --- Memory Graph (enabled by default, opt-out via disabled: true) ---
261+
// The knowledge graph powers spreading activation (Collins & Quillian model),
262+
// Hebbian co-activation learning ("neurons that fire together wire together"),
263+
// and graph-boosted retrieval scoring. It is fundamental to associative memory.
264+
if (config.graph?.disabled !== true) {
265+
const graphConfig = { ...DEFAULT_GRAPH_CONFIG, ...config.graph };
266+
const backend = graphConfig.backend;
262267
if (backend === 'graphology') {
263268
this.graph = new GraphologyMemoryGraph();
264269
} else {

src/memory/core/config.ts

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,50 @@ export interface ReflectorConfig {
7878
llmInvoker?: (systemPrompt: string, userPrompt: string) => Promise<string>;
7979
}
8080

81+
/**
82+
* Configuration for the memory graph subsystem.
83+
*
84+
* The memory graph powers spreading activation (Collins & Quillian model),
85+
* Hebbian co-activation learning ("neurons that fire together wire together"),
86+
* conflict detection, clustering, and graph-boosted retrieval scoring.
87+
*
88+
* Enabled by default when CognitiveMemoryManager is initialized.
89+
* Set `disabled: true` to opt out entirely.
90+
*/
8191
export interface MemoryGraphConfig {
82-
/** Which backend to use. @default 'knowledge-graph' */
83-
backend: 'graphology' | 'knowledge-graph';
92+
/**
93+
* Set to true to disable the memory graph entirely.
94+
* When disabled, spreading activation, Hebbian co-activation,
95+
* and graph-based retrieval boosting are all skipped.
96+
* @default false
97+
*/
98+
disabled?: boolean;
99+
/** Which graph backend to use. @default 'knowledge-graph' */
100+
backend?: 'graphology' | 'knowledge-graph';
84101
/** Max hops for spreading activation. @default 3 */
85-
maxDepth: number;
86-
/** Activation decay per hop. @default 0.5 */
87-
decayPerHop: number;
88-
/** Minimum activation to continue spreading. @default 0.1 */
89-
activationThreshold: number;
90-
/** Hebbian learning rate for co-activation edge strengthening. @default 0.1 */
91-
hebbianLearningRate: number;
102+
maxDepth?: number;
103+
/** Activation decay per hop (0-1). @default 0.5 */
104+
decayPerHop?: number;
105+
/** Minimum activation to continue spreading (0-1). @default 0.1 */
106+
activationThreshold?: number;
107+
/** Hebbian learning rate for co-activation edge strengthening (0-1). @default 0.1 */
108+
hebbianLearningRate?: number;
92109
}
93110

111+
/**
112+
* Default memory graph configuration.
113+
* Graph is enabled by default with the KnowledgeGraph backend,
114+
* providing spreading activation and Hebbian learning out of the box.
115+
*/
116+
export const DEFAULT_GRAPH_CONFIG: Required<Omit<MemoryGraphConfig, 'disabled'>> & { disabled: false } = {
117+
disabled: false,
118+
backend: 'knowledge-graph',
119+
maxDepth: 3,
120+
decayPerHop: 0.5,
121+
activationThreshold: 0.1,
122+
hebbianLearningRate: 0.1,
123+
};
124+
94125
export interface ConsolidationConfig {
95126
/** How often to run consolidation (ms). @default 3_600_000 (1 hour) */
96127
intervalMs: number;

0 commit comments

Comments
 (0)