Add these columns to memories table:
ALTER TABLE memories ADD COLUMN IF NOT EXISTS used_count INTEGER DEFAULT 0;
ALTER TABLE memories ADD COLUMN IF NOT EXISTS last_accessed TIMESTAMPTZ;
ALTER TABLE memories ADD COLUMN IF NOT EXISTS confidence TEXT DEFAULT 'speculative'; -- speculative, validated, auto
ALTER TABLE memories ADD COLUMN IF NOT EXISTS scope TEXT DEFAULT 'project'; -- project, team, global
ALTER TABLE memories ADD COLUMN IF NOT EXISTS version TEXT DEFAULT '';Also add to PowerSync schema.ts: used_count, last_accessed, confidence, scope, version.
- API: return
freshnessscore (0-1) based on age + used_count + last_accessed - Formula:
freshness = (recency_weight * recency) + (usage_weight * usage_score) - Dashboard: dim cards with low freshness, show "stale" badge on old unused memories
- MCP: sort results by freshness by default
confidencefield:speculative(default),validated(confirmed by human/test),auto(from git hooks)- Dashboard: show confidence badge on cards
- API: accept
confidenceon POST, filter by confidence on GET
- On POST /api/memories: check for similar content using Postgres
similarity()(pg_trgm extension) - If >80% similar memory exists from same project, update it instead of creating new
- Need:
CREATE EXTENSION IF NOT EXISTS pg_trgm;in migrate-v2.sql
- POST /api/memories/auto — accepts git commit messages, test results, PR descriptions
- Parses and extracts learnings automatically
- Source: "git-hook", "ci", "pr-review"
- Example git hook:
git log -1 --format="%B" | curl -X POST .../api/memories/auto -d @-
scopefield: project, team, global- GET /api/memories?scope=global returns cross-project memories
- Memories with scope=global visible in all projects
- GET /api/memories: increment
used_countandlast_accessedfor returned memories - Separate endpoint: POST /api/memories/:id/bump (so MCP can explicitly mark "I used this")
- MemoryBrowser: show freshness bar, confidence badge, scope indicator
- StatsBar: add "stale memories" count, "most used" stat
- Color coding: fresh=bright, stale=dimmed, validated=green border, speculative=dashed border
lib/db/migrate-v2.sql— new columns + pg_trgm extensionlib/powersync/schema.ts— add new columnsapp/api/memories/route.ts— freshness scoring, dedup, bump, scope filtermcp-server/index.js— return freshness, add bump toolcomponents/dashboard/MemoryBrowser.tsx— visual freshness, confidence, scopecomponents/dashboard/StatsBar.tsx— new statsapp/api/sync/route.ts— handle new columns in PowerSync sync
- Schema + API changes (freshness, confidence, scope, used_count)
- Smart dedup on write
- Dashboard visual updates
- MCP server updates
- Auto-capture endpoint (stretch)