()
| 35 | }); |
| 36 | |
| 37 | async 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 | } |
no test coverage detected