fix(contracts): reject invalid legacy intervals

Keep positive sub-minute schedules readable without accepting corrupt zero or negative persisted intervals.

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex committed 2026-08-14 11:23:28 +02:00
1 parent c30c681c1f
commit 7219dbfea7
2 files changed
+10 -4

No files matched your search

@@ -22,6 +22,10 @@ describe("ScheduledTaskSchedule", () => {
everyMs: MIN_SCHEDULED_TASK_INTERVAL_MS - 1,
});
});
it("still rejects corrupt non-positive persisted intervals", () => {
expect(() => decodeSchedule({ type: "interval", everyMs: 0 })).toThrow();
});
});
describe("ScheduledTaskUpsertSchedule", () => {
+6 -4
View File
@@ -23,13 +23,15 @@ const TimeOfDay = TrimmedNonEmptyString.check(
export const MIN_SCHEDULED_TASK_INTERVAL_MS = 60_000;
const ScheduledTaskIntervalMs = Schema.Int.check(Schema.isGreaterThan(0)).annotate({
description: "Positive interval in milliseconds.",
});
const ScheduledTaskIntervalSchedule = Schema.Struct({
type: Schema.Literal("interval").annotate({
description: "Select interval scheduling.",
}),
everyMs: Schema.Int.annotate({
description: "Interval in milliseconds.",
}),
everyMs: ScheduledTaskIntervalMs,
}).annotate({
description: "Run repeatedly after a fixed number of milliseconds.",
});
@@ -71,7 +73,7 @@ export const ScheduledTaskUpsertSchedule = Schema.Union([
type: Schema.Literal("interval").annotate({
description: "Select interval scheduling.",
}),
everyMs: Schema.Int.check(
everyMs: ScheduledTaskIntervalMs.check(
Schema.isGreaterThanOrEqualTo(MIN_SCHEDULED_TASK_INTERVAL_MS),
).annotate({
description: "Interval in milliseconds, with a minimum of 60000 (one minute).",