fix(memory): initialize candidates and enforce lifecycle rollout
Memind CI / Test, build, and release guards (push) Successful in 3m29s
Memind CI / Test, build, and release guards (push) Successful in 3m29s
This commit is contained in:
+13
-2
@@ -33,6 +33,15 @@ export function resolveMemoryV2LifecyclePolicy(env = process.env) {
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveMemoryV2LifecycleWorkerScopes(policy = {}) {
|
||||
if (!policy.enabled) return [];
|
||||
if (policy.rolloutMode === 'active') return [null];
|
||||
if (policy.rolloutMode === 'canary') {
|
||||
return [...new Set((policy.rolloutUserIds ?? []).map(String).filter(Boolean))];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
function normalizeItem(row) {
|
||||
return {
|
||||
id: String(row.id),
|
||||
@@ -71,7 +80,7 @@ export function createMemoryV2LifecycleService({ pool = null, env = process.env,
|
||||
}
|
||||
|
||||
async function forgetMemory({ userId, memoryId } = {}) {
|
||||
if (!canRun(userId) && !policy.forgettingEnabled) return { ok: true, updated: false, skipped: true, reason: 'disabled' };
|
||||
if (!policy.forgettingEnabled || !canRun(userId)) return { ok: true, updated: false, skipped: true, reason: 'disabled' };
|
||||
if (!pool?.query || !userId || !memoryId) return { ok: false, updated: false, reason: 'invalid_input' };
|
||||
const [result] = await pool.query(
|
||||
`UPDATE ${MEMORY_TABLE} SET status = 'deleted', updated_at = ? WHERE id = ? AND user_id = ? AND status <> 'deleted'`,
|
||||
@@ -82,7 +91,9 @@ export function createMemoryV2LifecycleService({ pool = null, env = process.env,
|
||||
}
|
||||
|
||||
async function expire({ userId = null } = {}) {
|
||||
if (!pool?.query || !policy.forgettingEnabled) return { ok: true, skipped: true, reason: 'disabled', expired: 0 };
|
||||
if (!pool?.query || !policy.forgettingEnabled || !canRun(userId)) {
|
||||
return { ok: true, skipped: true, reason: 'disabled', expired: 0 };
|
||||
}
|
||||
const cutoff = now() - policy.retentionDays * 86400000;
|
||||
const params = [cutoff];
|
||||
let scope = '';
|
||||
|
||||
Reference in New Issue
Block a user