ADR 0016doc/{zh,en}/adr/0016-host-schedules.md
ADR 0016: Schedules Are a Host Mechanism
Status: proposed, 2026-11-26.
Status: proposed, 2026-11-26.
Context
People want work that runs at set times and sends its result to several conversations, possibly on different channels ("every weekday at 9, the news to the Market group and to me"). The plugin scenarios analysis decided "no Host timer: schedules are a plugin" (scenarios, section 4). Designing it showed two things a plugin cannot provide without a new privileged API: a scheduled run must run as its creator, a Host principal the plugin can only assert, and its result must reach several targets, each authorized by the Host and delivered independently. Giving plugins "start a run as principal X with these targets" would let any granted plugin act as anyone.
Decision
- Host-owned state and timer.
internal/host/scheduleskeeps the schedules and their fire records; the engine's worker loop fires due ones. The owner, tenant and origin come only from the trusted call context or the configuration. - A scheduled run is an ordinary run with the owner as principal, on the Host connection
schedule(no transport, presentation or delivery), with its targets recorded. - Fan-out.
finishRunenqueues one delivery per target for a final result, in the run's ending transaction; failures and questions go to the owner's direct chat on the origin connection. Deliveries never re-execute the run. - Plugins keep the model-facing part.
ScheduleHost.Schedules(), behind a new grantschedule, gives a tool plugin the schedules of the call's principal; the builtinscheduleplugin offers the tools. - One store. Schedules live only in the Host's database, whoever made them (a conversation, the CLI, a declared maintenance task); the configuration holds settings only.
- Maintenance. A schedule runs either a prompt (an agent run) or a maintenance task provided by the Host (
host.retention,host.artifacts_expire) or declared in a plugin manifest (maintenance:,Maintainer.RunMaintenance). Declared maintenance tasks get default schedules that admins can retime or pause; the Host's hourly cleanup timer is removed. Maintenance schedules are managed by Host admins only.
Consequences
- ◆Reverses the scenarios decision for schedules; webhooks stay transports.
- ◆New tables, a Host connection name
schedule, a grant, aToolHostmethod, a manifest fieldmaintenancewithMaintainer, configuration keystimezone,artifact_retentionandschedules(limits), and a CLI command. - ◆Scheduled runs exist only while the Host runs; missed fires follow each schedule's grace window.
Design: Schedules.