fix(schedule): close fixed-rate review gaps

This commit is contained in:
pku-xht
2026-08-06 21:39:01 +08:00
committed by Tianyi Cui
parent 93d239b5d7
commit 49a6e4ddb9
13 changed files with 133 additions and 17 deletions

View File

@@ -641,6 +641,13 @@ export function foldScheduleEvents(
}
}
}
// A gate beyond the supported time profile can never admit another Every batch.
if (lastRecurringAcceptedAt !== undefined
&& Date.parse(lastRecurringAcceptedAt) + MIN_RECURRING_INTERVAL_SECONDS * 1_000 > MAX_FOUR_DIGIT_YEAR_MS) {
for (const [id, record] of active) {
if (record.kind === 'every') active.delete(id)
}
}
return Object.freeze({
active: Object.freeze([...active.values()]),
seenIds: Object.freeze([...seen]),
@@ -801,7 +808,8 @@ export function createEveryScheduleRecord(
const interval = everySeconds * 1_000
const target = now + interval
if (!Number.isSafeInteger(now) || !Number.isSafeInteger(interval)
|| !Number.isSafeInteger(target) || target <= now || target > MAX_FOUR_DIGIT_YEAR_MS) {
|| !Number.isSafeInteger(target) || target <= now
|| target < MIN_FOUR_DIGIT_YEAR_MS || target > MAX_FOUR_DIGIT_YEAR_MS) {
throw new ScheduleInputError(
'time_out_of_range',
'The scheduled time must be representable as a four-digit-year RFC 3339 UTC instant.',

View File

@@ -1,5 +1,5 @@
/**
* Agent-scoped durable one-shot reminders over the session event log.
* Agent-scoped durable one-shot and fixed-rate reminders over the session event log.
* @module @deepseek-ai/dsh-tool-schedule
*/

View File

@@ -68,6 +68,7 @@ function dueDecision(folded: FoldedSchedules, now: number): DueDecision {
}
const future = folded.active
.filter(record => recurring.length === 0 || record.kind !== 'every')
.map(record => Date.parse(record.scheduledAt))
.filter(target => target > now)
if (recurring.length > 0) future.push(gate)

View File

@@ -120,6 +120,16 @@ export type ScheduleView = ScheduleRecord & {
readonly deliveryNotBefore?: string
}
/** JSON-compatible Web receipt derived from one durable dispatch. */
export interface ScheduleReminderPresentation {
/** Session-local reminder identity. */
readonly scheduleId: ScheduleId
/** Original user-authored reminder content. */
readonly prompt: string
/** Scheduled occurrence represented by the dispatch. */
readonly occurrenceAt: string
}
/** Management operations whose persistence barrier may be uncertain. */
export type SchedulePersistenceOperation = 'create' | 'list' | 'delete'