feat(memory-v2): close Phase A with auto-review, product events, and H5 recall UI.
Add candidate auto-review pipeline, shadow audit tooling, admin metrics page, and user-visible memory recall hints in chat with phase-a readiness checks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+14
-1
@@ -57,6 +57,19 @@ function normalizeItem(row) {
|
||||
};
|
||||
}
|
||||
|
||||
function normalizePromoteRawJson(value) {
|
||||
if (value == null) return null;
|
||||
if (typeof value === 'object') return JSON.stringify(value);
|
||||
const text = String(value).trim();
|
||||
if (!text) return null;
|
||||
try {
|
||||
JSON.parse(text);
|
||||
return text;
|
||||
} catch {
|
||||
return JSON.stringify({ legacyEvidence: text });
|
||||
}
|
||||
}
|
||||
|
||||
export function createMemoryV2LifecycleService({ pool = null, env = process.env, now = () => Date.now(), logger = console } = {}) {
|
||||
const policy = resolveMemoryV2LifecyclePolicy(env);
|
||||
const metrics = { list: 0, forget: 0, expire: 0, compact: 0, promote: 0, reflect: 0, errors: 0, lastRunAt: null, lastError: null };
|
||||
@@ -134,7 +147,7 @@ export function createMemoryV2LifecycleService({ pool = null, env = process.env,
|
||||
`INSERT IGNORE INTO ${MEMORY_TABLE}
|
||||
(id,user_id,label,memory_hash,memory_text,evidence_message_id,source_session_id,confidence,status,raw_json,created_at,updated_at)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)`,
|
||||
[id, row.user_id, row.memory_type === 'semantic' ? 'knowledge' : row.memory_type, hash, row.content, null, row.session_id, row.confidence, 'active', row.evidence_json, row.created_at, now()],
|
||||
[id, row.user_id, row.memory_type === 'semantic' ? 'knowledge' : row.memory_type, hash, row.content, null, row.session_id, row.confidence, 'active', normalizePromoteRawJson(row.evidence_json), row.created_at, now()],
|
||||
);
|
||||
if (Number(result?.affectedRows ?? 0) > 0) {
|
||||
promoted += 1;
|
||||
|
||||
Reference in New Issue
Block a user