From b3765f30fa3034dce9f8fe5c6de02b829fe08be6 Mon Sep 17 00:00:00 2001 From: Storme-bit Date: Sun, 23 Aug 2026 22:46:53 -0700 Subject: [PATCH] consolidation test --- scratch.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scratch.js diff --git a/scratch.js b/scratch.js new file mode 100644 index 0000000..619c790 --- /dev/null +++ b/scratch.js @@ -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 \ No newline at end of file