The schedules document stored interval as a bare time.Duration, so its JSON was
the nanosecond count -- 1800000000000 for thirty minutes -- and the Web UI, which
now derives field metadata from the document type, correctly rendered a number
input. Same defect 02rm fixed for rate_limit.window, in the second stored time
this tree has. Nobody should be asked for a count of nanoseconds to configure a
schedule.
cronstore.Duration writes the string time.ParseDuration reads and reads that, a
nanosecond count, and nothing else: every schedule stored before this shape
existed carries a count, in both the control plane's schedules resource and this
package's own jobs table, which persists the spec as JSON. A value that parses as
neither is refused rather than decoding as zero, because a zero interval is a job
that never fires.
The derived schema needed no change and gets it for free -- which exposed a fix
the derivation itself needed: it classified durations by NAME, so cronstore.Duration
derived as an integer. durationLike now asks the type instead -- does it expose the
standard duration, and does it marshal as a quoted string -- so the next duration
type is classified correctly rather than silently rendering as a number box. That
failure mode was invisible until a live daemon showed it.
normalizeSchedules already re-marshals, so a stored document converges on its next
write while reads keep tolerating the count.
Verified: cronstore, crondelivery, controlplane, scheduling, webui and archied
suites, go vet ./..., go build ./..., golangci-lint run ./... (0 issues),
docs:check. Against a live daemon (8484): the catalog serves schedule.interval as
{type: string, format: duration}.
WIRE, not delete: cronstore.Store.MarkRun is the documented run-completion
step ("once the ticker has dispatched a job, the runner ... calls MarkRun to
keep next_run fresh") and the scheduling engine is now started at boot, but
nothing in production called it. Due returns every job whose NextRun is at or
before now, so with NextRun frozen in the past a job with a 1h interval was
handed to the runner on every tick.
The delivery Router is the single Runner the engine is given and, per this
package's own doc, the only place that knows a job store exists, so it is the
producer-side site. RouterStore (SpecLookup + RunRecorder) widens only what
the Router takes; the per-kind runners keep the narrow SpecLookup, and
NewRouter's signature is unchanged, so no call site moved.
Only a successful run records, matching the store's own contract that an
interval or cron schedule fires "after the last successful run". A one-shot
schedule reports ErrScheduleUnsupported -- it has no recurring next run by
definition -- which is swallowed rather than returned, because propagating it
would make the engine emit KindJobError for a job that actually succeeded.
Red-then-green: TestRouterAdvancesTheScheduleAfterASuccessfulRun asserts
LastRun is set and NextRun moved past now, and failed on both counts before
the change. TestRouterToleratesAOnceScheduleWithoutANextRun pins the
sentinel half. Mutation-verified by replacing only the record call with
`return nil`, keeping the API intact.
The ticker engine had no work to dispatch. Add the delivery half as a new
infrastructure package with three scheduling.Runner implementations:
- ChatCourier sends a job's payload text to its target chat.
- WorkflowTask submits a job as a unit of work.
- Router dispatches on the job's kind and is the single runner the engine
is given, so the engine stays unaware that more than one delivery exists.
Nothing here talks to a channel, a broker or a forge. The outbound send is
an injected Courier function and work intake is a narrow TaskSubmitter
interface, so which transport carries a message stays the deployment's
decision rather than the cron's, and the package is testable without a
network.
An unrecognised kind is refused at the gate, not failed: it emits
KindJobError with phase "dispatch" in the engine's own data shape and
returns nil, so a misconfigured job is visible without being reported as a
job that tried and broke. A nil sink still refuses, just unobservably.
Every runner returns the context error on a cancelled run and produces no
side effect, so the engine's bounded shutdown drains rather than waiting
out the per-run timeout.
Tests exercise a real cronstore on a temp path, including the epic's
headline daily-status scenario end to end from a persisted due job through
the router to the delivered message.