fix(prod): dedupe scheduled tasks and reconcile orphan delivery contracts
Memind CI / Test, build, and release guards (push) Successful in 2m58s

Prevent duplicate active scheduled tasks, fail static preparing contracts
when HTML is missing, raise MindSpace remote timeout default to 30s, and
add 103 repair scripts for inspection follow-ups.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-16 08:52:16 +08:00
parent f20302fe65
commit 843e4d1002
8 changed files with 296 additions and 5 deletions
+24 -3
View File
@@ -137,6 +137,27 @@ export function createScheduledTaskService(pool, { defaultTimezone = DEFAULT_TIM
timezone: tz,
now: clock.now(),
});
const normalizedTitle = safeTitle || safeTaskSpec.slice(0, 80);
const normalizedHour = hour == null ? null : Number(hour);
const normalizedMinute = Number(minute ?? 0);
if (safeRecurrence !== 'once') {
const [duplicateRows] = await pool.query(
`SELECT *
FROM h5_scheduled_tasks
WHERE user_id = ?
AND status = 'active'
AND recurrence = ?
AND hour <=> ?
AND minute = ?
AND title = ?
ORDER BY created_at ASC
LIMIT 1`,
[userId, safeRecurrence, normalizedHour, normalizedMinute, normalizedTitle],
);
if (duplicateRows?.[0]) {
return rowToTask(duplicateRows[0]);
}
}
const id = crypto.randomUUID();
const ts = clock.now();
await pool.query(
@@ -148,11 +169,11 @@ export function createScheduledTaskService(pool, { defaultTimezone = DEFAULT_TIM
[
id,
userId,
safeTitle || safeTaskSpec.slice(0, 80),
normalizedTitle,
safeTaskSpec,
safeRecurrence,
hour == null ? null : Number(hour),
Number(minute ?? 0),
normalizedHour,
normalizedMinute,
weekday == null ? null : Number(weekday),
tz,
nextRunAt,