Repository navigation
Routines (1/2): the scheduler - #23
Merged
Merged
Conversation
Routines are the first item after the MVP: a bot works on its own on a weekly schedule, an interval or a cron expression, in the routine's own time zone. Each run is a message the owner wrote, delivered into the bot's one conversation through the courier like any other, so it is durable and needs no second session. A run ends with the turn its message started; overlapping runs are skipped (or one waits), paused bots skip, and missed times run once when the computer is back. The schedule is stored as structured JSON so the app can show and edit it in plain words; cron stays behind "Advanced". Milestones R1 (daemon) and R2 (app) start once M5 is closed.
A routine makes a bot work on its own: weekly at a time, every N minutes or on a cron expression, in its own time zone. When its time comes, the daemon posts the owner's request to the bot on the usual message path, with an envelope that names the routine, the local time it is for and that nobody is watching. The run ends with the turn that began with that message: done, or failed on an error, a dead message, a process that ended mid-turn or a daemon that stopped mid-turn. A run still open skips the next time (or lets one wait, with queue), a paused bot skips its times, and times missed while the daemon was away run once for the latest (or not at all). Run now fires outside the schedule. Archiving a bot archives its routines. Zones use jiff with the IANA database it bundles on Windows. The daemon evaluates cron itself, walking the days in the routine's zone: a time the clock skips runs right after the jump, one it repeats runs once. The app gets the protocol (routines.* and two notifications) and a fake; its screens come in R2. The spec also records the M5 reboot check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Routines, part 1 (R1): the scheduler in the daemon. A routine makes a bot work on its own at set times. The design (spec section 20) ships with it; the app's screens are in the next PR.
What changes
overlap: queue; a paused bot skips its times; times missed while the daemon was away run once for the latest, or not at all withmissed: skip(a time up to 2 minutes late counts as on time); turning a routine back on counts from now; run now fires outside the schedule; archiving a bot archives its routines.doneorfailedon an error. A dead message, a process that ends mid-turn, or a daemon that stopped mid-turn (found at the next start) also fail the run.jiff, with the IANA database it bundles on Windows. The daemon evaluates cron itself, walking the days in the routine's zone.routines,routine_runs,messages.routine_id). Protocol:routines.list/create/update/setEnabled/runNow/archive/runs, notificationsroutine.changedandroutine.run,Message.routineIdand kindroutine. The app gets the types and a fake.Tested
cargo fmt,clippy -D warningsandcargo test: new tests for the schedule math (New York's 2026 jump and repeat, São Paulo and Lisbon zones, a0 0 29 2 *cron that next runs in 2028, validation), cron parsing, the store, and 11 integration tests onFakeRuntimewith a manual clock (on time, overlap skip and queue, missed run once and skip, paused bot, run now, a failed turn, a dead message, a process and a daemon gone mid-turn, turning off, archiving).pnpm checkpasses.