From 89dea36c3aeb2d9a7254cc35488ea4bf3bcea943 Mon Sep 17 00:00:00 2001 From: rUv Date: Tue, 10 Feb 2026 16:49:21 +0000 Subject: [PATCH] Checkpoint: File edits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatic checkpoint created by Claude Code - Branch: rebrand/ruvflow-umbrella - Timestamp: 2026-02-10T16:49:21Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .claude/helpers/context-persistence-hook.mjs | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.claude/helpers/context-persistence-hook.mjs b/.claude/helpers/context-persistence-hook.mjs index 27c2054828..9e7f5cd9a7 100644 --- a/.claude/helpers/context-persistence-hook.mjs +++ b/.claude/helpers/context-persistence-hook.mjs @@ -533,6 +533,41 @@ class RuVectorBackend { return rows.map(r => ({ session_id: r.session_id, cnt: parseInt(r.cnt, 10) })); } + async markAccessed(ids) { + const now = Date.now(); + for (const id of ids) { + await this.pool.query( + 'UPDATE transcript_entries SET access_count = access_count + 1, last_accessed_at = $1 WHERE id = $2', + [now, id] + ); + } + } + + async pruneStale(namespace, maxAgeDays) { + const cutoff = Date.now() - (maxAgeDays * 24 * 60 * 60 * 1000); + const { rowCount } = await this.pool.query( + 'DELETE FROM transcript_entries WHERE namespace = $1 AND access_count = 0 AND created_at < $2', + [namespace || NAMESPACE, cutoff] + ); + return rowCount; + } + + async queryByImportance(namespace, sessionId) { + const now = Date.now(); + const { rows } = await this.pool.query(` + SELECT *, ( + (CAST(access_count AS REAL) + 1) * + (1.0 / (1.0 + ($1 - created_at) / 86400000.0)) * + (CASE WHEN jsonb_array_length(metadata->'toolNames') > 0 THEN 1.5 ELSE 1.0 END) * + (CASE WHEN jsonb_array_length(metadata->'filePaths') > 0 THEN 1.3 ELSE 1.0 END) + ) AS importance_score + FROM transcript_entries + WHERE namespace = $2 AND session_id = $3 + ORDER BY importance_score DESC + `, [now, namespace, sessionId]); + return rows.map(r => ({ ...this._rowToEntry(r), importanceScore: r.importance_score })); + } + async shutdown() { if (this.pool) { await this.pool.end();