Add User Model Service and Temporal Recall for MeMind V0.1.

Introduce UMS ingest/snapshot pipeline, Context Planner with multi-source recall, runtime context injection, canonical user mapping, and session snapshot loading on auth/me.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-09-03 23:25:18 +08:00
parent bf66fdf493
commit 212ff3ff80
47 changed files with 4534 additions and 6 deletions
+30
View File
@@ -0,0 +1,30 @@
import { resolveCanonicalUserId } from './canonical-user.mjs';
import { getActiveSnapshot } from './snapshot.mjs';
/**
* Session bootstrap payload for /auth/me (RFC: 510KB snapshot at session start).
*
* @param {import('mysql2/promise').Pool | null | undefined} pool
* @param {string} userId
* @param {string} [projection]
*/
export async function loadSessionUserModelSnapshot(pool, userId, projection = 'default') {
if (!pool?.query || !userId) return null;
const canonicalUserId = resolveCanonicalUserId(userId);
const snap = await getActiveSnapshot(pool, canonicalUserId, projection);
if (!snap) return null;
return {
snapshot_id: snap.snapshot_id,
user_id: snap.user_id,
projection: snap.projection,
profile_version: snap.profile_version,
fast_revision: snap.fast_revision,
content_hash: snap.content_hash,
byte_size: snap.byte_size,
stale_after_sec: snap.stale_after_sec,
loaded_at_hint: 'session_start',
core: snap.core,
meta: snap.meta,
...(canonicalUserId !== userId ? { canonical_user_id: canonicalUserId } : {}),
};
}