Expand description
eclipse cron: prompts that run on a timer.
Three files, all under one root: <root>/cron/jobs.toml says what should run and when,
<root>/state/cron.json remembers what did, and <root>/cron/runs/<job>/<ms>.md is what came
back. The jobs file is yours to edit — the tool and the CLI write the same format — and a
hand-edit is never lost: nothing here rewrites blocks it was not asked to touch.
Time is the hard part. A schedule of “daily 07:30” means 07:30 where the person is, not
07:30 UTC, and the project takes no date-time dependency, so local time comes from libc
(offset at an instant, and the civil calendar) with a pure-Rust civil-date conversion that is
also what the tests use. An interval schedule never consults a calendar at all.
Nothing here runs an agent: due decides, and the caller runs. That keeps the decision
testable with a clock the test controls, and keeps the core free of a dependency cycle
(runtime depends on this, not the other way round).
Structs§
- Draft
- A job as a surface submits it:
cron add’s arguments, or a page’s form. - Job
- A named job: what to say, when to say it.
- JobState
- JobView
- One job, plus what has run and when it fires next.
- Lock
- Held for the duration of one tick, so two timers (a systemd one and a hand-run one) cannot run the same job twice.
- RunView
- One run of a job, as a surface reads it.
- State
Enums§
- Schedule
- When a job fires.
Constants§
- ANSWER_
CAP - How much of a run’s first line fits in a table: enough to know what happened, short enough to
sit in one row. The rest is in
RunView::text. - MIN_
EVERY_ SECS - A minute is the floor: anything finer is a busy loop wearing a schedule’s clothes, and the timer that drives these ticks wakes once a minute anyway.
- RUN_
TEXT_ CAP - How much of a run’s text a surface is handed. A job that answers in ten thousand words is a
job whose log is an essay; the page shows the beginning and says the rest is on disk in
path, rather than shipping a megabyte of JSON to a browser to render four lines of it. - STALE_
LOCK_ MS - How long a lock may be ignored before it is taken as abandoned.
Functions§
- append_
job - Append a job to the file, creating it with a one-line explanation if it does not exist.
- due
- The jobs that should run now.
- expand_
tilde ~/xand$HOME/xas the path they mean.- iso_
local 2026-11-29 07:30, in local time.- jobs_
path - Where jobs live:
<root>/cron/jobs.toml. - load
- Read
<root>/cron/jobs.toml. A missing file is not an error: it is a machine with no jobs. - load_
reporting - Read
<root>/cron/jobs.tomland say which blocks are unusable. - load_
state - local_
parts (year, month, day, hour, minute)in local time.- lock
- next_
due_ for - When a job fires next, given what has run.
Nonefor a disabled job. - recent_
runs - The most recent runs of a job, newest first.
- remove_
job - Remove a job by name, leaving every other block exactly as it was.
- replace_
job - Replace a job’s
[[job]]block in place, leaving every other byte of the file alone. - runs
- The newest runs of one job, read off the files the tick wrote.
- runs_
dir - runs_
root - Where a job’s run history goes:
<root>/cron/runs/<name>/. Every job’s run logs:<root>/cron/runs, before a job name is appended. - save_
state - set_
enabled - Turn a job on or off, in place.
falsewhen no job has that name. - state_
path - Where
<root>/state/cron.json— the record of what ran — lives. - validate_
job_ name - Names become directory names, so they are held to the same alphabet as profile names.
- view
- views
- Every job, in the order the file has them, as a surface reads them.
- weekday_
of - Which day of the week a local instant falls on: 0 = Sunday.
- write_
run - The run log for one execution:
<root>/cron/runs/<job>/<ms>.md.