MCPcopy
hub / github.com/CaviraOSS/OpenMemory / testDecayAndReflection

Function testDecayAndReflection

tests/backend/decay-reflection.test.js:37–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35 });
36
37async function testDecayAndReflection() {
38 console.log('🧪 Testing Decay & Reflection Systems\n');
39
40 try {
41 // 1. Create test memories
42 console.log('📝 Creating test memories...');
43 const mems = [];
44
45 for (let i = 0; i < 25; i++) {
46 const res = await post(`${BASE_URL}/memory/add`, {
47 content: `Test memory ${i}: This is about ${
48 i % 3 === 0 ? 'coding' : i % 3 === 1 ? 'debugging' : 'testing'
49 } patterns`,
50 primary_sector:
51 i % 4 === 0
52 ? 'episodic'
53 : i % 4 === 1
54 ? 'semantic'
55 : i % 4 === 2
56 ? 'procedural'
57 : 'emotional',
58 metadata: { test: true, batch: 'decay-reflection' },
59 });
60 mems.push(res.id);
61 }
62 console.log(`✅ Created ${mems.length} memories\n`);
63
64 // 2. Check initial salience
65 console.log('📊 Initial salience values:');
66 for (let i = 0; i < 3; i++) {
67 const m = await get(`${BASE_URL}/memory/${mems[i]}`);
68 console.log(` Memory ${i}:`, m);
69 if (m.salience !== undefined && m.recency !== undefined) {
70 console.log(
71 ` salience=${m.salience.toFixed(3)}, recency=${m.recency.toFixed(
72 3,
73 )}`,
74 );
75 }
76 }
77 console.log();
78
79 // 3. Wait for decay (10 seconds interval)
80 console.log('⏳ Waiting 15 seconds for decay to run...');
81 await wait(15000);
82
83 // 4. Check post-decay salience
84 console.log('📉 Post-decay salience values:');
85 for (let i = 0; i < 3; i++) {
86 const m = await get(`${BASE_URL}/memory/${mems[i]}`);
87 if (m.salience !== undefined && m.recency !== undefined) {
88 console.log(
89 ` Memory ${i}: salience=${m.salience.toFixed(
90 3,
91 )}, recency=${m.recency.toFixed(3)}`,
92 );
93 }
94 }

Callers 1

Calls 4

postFunction · 0.85
getFunction · 0.85
waitFunction · 0.85
delFunction · 0.85

Tested by

no test coverage detected