{
"primitive": "schedule",
"scenarios": [
{
"name": "at_then_list_roundtrip_ms",
"note": "Canonical absolute time is epoch MILLISECONDS in every language (Node scheduleAt and Python schedule_at both take ms). list() returns a page: {items, cursor}.",
"steps": [
{ "op": "schedule.at", "args": { "when_epoch_ms": 4102444800000, "queue": "q", "payload": "{}" } },
{ "op": "schedule.list", "args": {},
"expect": { "value": { "items": [ { "kind": "at", "next_run_ms": { "$approx": 4102444800000, "tol": 5000 } } ], "cursor": null } } }
]
},
{
"name": "cancel_at_recalls_a_pending_oneshot",
"note": "One-shots created by at() can be recalled by JobId, supporting send-later and disappearing-message cancellation.",
"steps": [
{ "op": "schedule.at", "args": { "when_epoch_ms": 4102444800000, "queue": "q", "payload": "{}" }, "as": "jid" },
{ "op": "schedule.cancel_at", "args": { "job_id": { "$ref": "jid" } }, "expect": { "value": true } },
{ "op": "schedule.cancel_at", "args": { "job_id": { "$ref": "jid" } }, "expect": { "value": false } }
]
},
{
"name": "namespace_isolation",
"note": "Schedules are scoped per app: a cron registered in one namespace must not appear in another's list(), and names do not collide across apps.",
"steps": [
{ "op": "schedule.cron", "args": { "name": "c1", "expr": "0 0 * * *", "queue": "q", "payload": "{}" }, "namespace": "app-a" },
{ "op": "schedule.list", "args": {}, "namespace": "app-b", "expect": { "value": { "items": [], "cursor": null } } },
{ "op": "schedule.list", "args": {}, "namespace": "app-a", "expect": { "value": { "items": [ { "kind": "cron", "name": "c1" } ], "cursor": null } } }
]
},
{
"name": "cron_register_then_cancel",
"steps": [
{ "op": "schedule.cron", "args": { "name": "c1", "expr": "0 0 * * *", "queue": "q", "payload": "{}" } },
{ "op": "schedule.cancel", "args": { "name": "c1" }, "expect": { "value": true } },
{ "op": "schedule.cancel", "args": { "name": "c1" }, "expect": { "value": false } }
]
},
{
"name": "list_paginates_by_cursor",
"note": "list() pages by cursor so a backlog of pending one-shots never forces an unbounded materialization. A full page returns an opaque cursor; the final short page returns null.",
"steps": [
{ "op": "schedule.cron", "args": { "name": "a", "expr": "0 0 * * *", "queue": "q", "payload": "{}" } },
{ "op": "schedule.cron", "args": { "name": "b", "expr": "0 0 * * *", "queue": "q", "payload": "{}" } },
{ "op": "schedule.cron", "args": { "name": "c", "expr": "0 0 * * *", "queue": "q", "payload": "{}" } },
{ "op": "schedule.list", "args": { "limit": 2 }, "as": "page1",
"expect": { "value": { "items": [ { "name": "a" }, { "name": "b" } ], "cursor": { "$type": "string" } } } },
{ "op": "schedule.list", "args": { "limit": 2, "cursor": { "$ref": "page1.cursor" } },
"expect": { "value": { "items": [ { "name": "c" } ], "cursor": null } } }
]
},
{
"name": "opts_carry_max_attempts_to_the_enqueued_job",
"note": "Per-schedule queue opts carry through to the enqueued job. Backend-agnostic: the memory scheduler delivers through its resolved queue backend too.",
"steps": [
{ "op": "schedule.at", "args": { "when_epoch_ms": { "$now_ms": -2000 }, "queue": "oneshot", "payload": "x", "max_attempts": 1 } },
{ "op": "schedule.tick", "args": {}, "expect": { "value": 1 } },
{ "op": "queue.dequeue", "args": { "queue": "oneshot", "visibility_seconds": 30, "wait_seconds": 0 },
"expect": { "shape": { "max_attempts": 1 } } }
]
},
{
"name": "named_schedule_control_and_diagnostics",
"note": "Pause keeps a schedule inspectable but removes it from the due backlog; all canonical timestamps are UTC epoch milliseconds.",
"steps": [
{ "op": "schedule.cron", "args": { "name": "controlled", "expr": "0 0 * * *", "queue": "q", "payload": "{}" } },
{ "op": "schedule.pause", "args": { "name": "controlled" }, "expect": { "value": true } },
{ "op": "schedule.inspect", "args": { "name": "controlled" }, "expect": { "shape": { "name": "controlled", "paused": true, "misfire_policy": "run_once", "max_catch_up": 0 } } },
{ "op": "schedule.diagnostics", "args": {}, "expect": { "shape": { "due_count": 0, "enqueue_failures": 0 } } },
{ "op": "schedule.resume", "args": { "name": "controlled" }, "expect": { "value": true } }
]
}
]
}