consolidation test
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
// scratch.js — run with: SQLITE_PATH=./packages/memory-service/data/test-copy.db node scratch.js
|
||||
const { getDB } = require('./packages/memory-service/src/db');
|
||||
const episodic = require('./packages/memory-service/src/episodic');
|
||||
|
||||
const db = getDB();
|
||||
|
||||
// Backdate half the episodes to 10-40 days old, give some fake access history
|
||||
const eps = db.prepare('SELECT id FROM episodes').all();
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
|
||||
for (const { id } of eps) {
|
||||
if (Math.random() < 0.5) continue; // leave half young, so the age floor stays testable
|
||||
const daysOld = 10 + Math.floor(Math.random() * 30);
|
||||
const createdAt = now - daysOld * 86400;
|
||||
const touched = Math.random() < 0.6;
|
||||
db.prepare(`
|
||||
UPDATE episodes
|
||||
SET created_at = ?,
|
||||
access_count = ?,
|
||||
last_accessed_at = ?
|
||||
WHERE id = ?
|
||||
`).run(
|
||||
createdAt,
|
||||
touched ? 1 + Math.floor(Math.random() * 5) : 0,
|
||||
touched ? (createdAt + Math.floor(Math.random() * daysOld) * 86400) * 1000 : null, // accessed sometime after creation, in ms
|
||||
id
|
||||
);
|
||||
}
|
||||
|
||||
// Now run the actual candidate function against the doctored data
|
||||
console.table(episodic.getConsolidationCandidates(1)); // whatever session id has rows
|
||||
Reference in New Issue
Block a user