fix(memory): sync new memories into pgvector
Memind CI / Test, build, and release guards (push) Successful in 2m31s
Memind CI / Test, build, and release guards (push) Successful in 2m31s
This commit is contained in:
@@ -95,3 +95,35 @@ test('expire is limited to the configured canary user', async () => {
|
||||
assert.match(calls[0].sql, /user_id = \?/);
|
||||
assert.equal(calls[0].params.at(-1), 'u-1');
|
||||
});
|
||||
|
||||
test('promotion reports the users whose memories were inserted', async () => {
|
||||
const pool = {
|
||||
async query(sql) {
|
||||
if (sql.startsWith('SELECT * FROM h5_memory_v2_candidates')) {
|
||||
return [[{
|
||||
user_id: 'u-1',
|
||||
memory_type: 'episodic',
|
||||
content: '记住灰度代号',
|
||||
session_id: 's-1',
|
||||
confidence: 0.9,
|
||||
evidence_json: '{}',
|
||||
created_at: 100,
|
||||
}]];
|
||||
}
|
||||
if (sql.startsWith('INSERT IGNORE INTO h5_user_memory_items')) {
|
||||
return [{ affectedRows: 1 }];
|
||||
}
|
||||
throw new Error(`Unexpected SQL: ${sql}`);
|
||||
},
|
||||
};
|
||||
const lifecycle = createMemoryV2LifecycleService({ pool, env: {
|
||||
MEMORY_LIFECYCLE_ENABLED: '1',
|
||||
MEMORY_PROMOTION_ENABLED: '1',
|
||||
MEMORY_LIFECYCLE_ROLLOUT_MODE: 'canary',
|
||||
MEMORY_LIFECYCLE_ROLLOUT_USER_IDS: 'u-1',
|
||||
} });
|
||||
|
||||
const result = await lifecycle.promote({ userId: 'u-1' });
|
||||
assert.equal(result.promoted, 1);
|
||||
assert.deepEqual(result.promotedUserIds, ['u-1']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user