feat(server): complete pending-memory auto-promotion sweep at session end#62
Open
ryantlee25-droid wants to merge 3 commits into
Open
feat(server): complete pending-memory auto-promotion sweep at session end#62ryantlee25-droid wants to merge 3 commits into
ryantlee25-droid wants to merge 3 commits into
Conversation
Adds `SqliteCache.promoteMemories(projectId, threshold)` — a single UPDATE that promotes all pending memories with confidence >= threshold to live, setting verified_at and dirty=1. Idempotent: the WHERE clause filters on status='pending' so already-live rows are never touched. Wires the sweep into `handleSessionEnd` via an optional `autoSaveThreshold` parameter (null = no sweep, preserving existing call-site behavior). The guard `if (autoSaveThreshold != null)` matches the pattern in index.ts and observe.ts; index.ts can pass the threshold in a follow-up without touching this file. 8 tests in session-end-sweep.test.ts cover: below-threshold stays pending, at/above-threshold promoted with verifiedAt set, already-live not re-promoted (idempotent, two-run check), empty pending set is a no-op, null threshold skips sweep entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
handleSessionEnd accepted autoSaveThreshold (6th param) after 9d54467 but the MCP tool registration in index.ts:378 dropped it on the floor, making the pending-memory promotion sweep unreachable end-to-end. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes a half-shipped feature. Migration 0054 added
auto_save_thresholdand the CLI writes to it, but the sweep that reads it and promotes pending memories to live was missing fromsession_end. This PR wires it end-to-end.cache/sqlite.ts— addspromoteMemories(projectId, threshold)using a single SQL UPDATE (atomic, vs N round-trips).tools/session-end.ts— accepts optional 6th paramautoSaveThreshold; sweep runs only when non-null. Preserves prior "session_end doesn't auto-promote" default for callers that don't pass it.index.ts:378— wires the configuredautoSaveThreshold(already in scope at line 95, populated fromprojectRow.auto_save_thresholdat line 164) to the call site. Without this line the feature was unreachable end-to-end.__tests__/session-end-sweep.test.ts— below/at/above threshold, idempotency, empty pending, null-threshold opt-out. All 640 server tests pass.Warnings from pre-PR review (non-blocking)
__tests__/auto-save.test.ts:168describes a "session_end does not sweep" invariant that's now architecturally false when a threshold is configured. Production is safe (default is null), but the doc-rot is misleading. Cheap follow-up: update the comment or add a session-end-sweep test at threshold=0.8 over session-extracted memories.auto-save.ts::runAutoSaveSweepLocaland the newcache::promoteMemoriesare parallel implementations for the same logical op (different call surfaces — periodic vs session-end). Tracked tech debt, not a correctness issue.@vitest/coverage-v8isn't in the workspace; per-file coverage on changed files was not obtainable for this run.packages/server/vitest.config.tsdoes not exclude.claude/worktrees/**. Did not manifest as a failure here, but per a prior incident memory it can. Follow-up ticket worth opening.Test plan
pnpm --filter @tages/server testpasses locally (verified: 640 pass / 0 fail / 13 skipped)pnpm --filter @tages/server typecheckpasses (verified clean)auto_save_threshold = 0.85on a test project, run a session that produces pending memories, confirm session_end promotes those ≥ 0.85.🤖 Generated with Claude Code